Skip to content

Commit aa5ed99

Browse files
committed
Implemented ability to specify custom resolution for Opaque.
1 parent 1b91fc8 commit aa5ed99

File tree

12 files changed

+189
-21
lines changed

12 files changed

+189
-21
lines changed

CustomVnc-app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.iiordanov.CUSTOM_VNC_APP_PACKAGE_NAME"
55
android:installLocation="auto"
6-
android:versionCode="115043" android:versionName="v5.0.4">
6+
android:versionCode="115044" android:versionName="v5.0.4">
77

88
<uses-permission tools:node="removeAll"/>
99
<uses-permission android:name="android.permission.INTERNET"> </uses-permission>

Opaque-app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.undatech.opaque"
5-
android:versionCode="115043" android:versionName="v5.0.4">
5+
android:versionCode="115044" android:versionName="v5.0.4">
66

77
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
88
<uses-permission android:name="android.permission.VIBRATE" />

aRDP-app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.iiordanov.aRDP" android:installLocation="auto"
5-
android:versionCode="115043" android:versionName="v5.0.4">
5+
android:versionCode="115044" android:versionName="v5.0.4">
66

77
<uses-permission tools:node="removeAll"/>
88
<uses-permission android:name="android.permission.INTERNET"> </uses-permission>

aSPICE-app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.iiordanov.aSPICE" android:installLocation="auto"
5-
android:versionCode="115043" android:versionName="v5.0.4">
5+
android:versionCode="115044" android:versionName="v5.0.4">
66

77
<uses-permission tools:node="removeAll"/>
88
<uses-permission android:name="android.permission.INTERNET"> </uses-permission>

bVNC-app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.iiordanov.bVNC" android:installLocation="auto"
5-
android:versionCode="115043" android:versionName="v5.0.4">
5+
android:versionCode="115044" android:versionName="v5.0.4">
66

77
<uses-permission tools:node="removeAll"/>
88
<uses-permission android:name="android.permission.INTERNET"> </uses-permission>

bVNC/src/main/java/com/iiordanov/bVNC/RemoteCanvas.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ void init(final Connection settings, final Handler handler, final Runnable setMo
258258
checkNetworkConnectivity();
259259
initializeClipboardMonitor();
260260
spicecomm = new SpiceCommunicator(getContext(), handler, this,
261-
settings.isRequestingNewDisplayResolution(), settings.isUsbEnabled(), App.debugLog);
261+
settings.isRequestingNewDisplayResolution() || settings.getRdpResType() == Constants.RDP_GEOM_SELECT_CUSTOM,
262+
settings.isUsbEnabled(), App.debugLog);
262263
rfbconn = spicecomm;
263264
pointer = new RemoteSpicePointer(spicecomm, this, handler);
264265
try {
@@ -460,6 +461,9 @@ private void handleUncaughtException(Throwable e) {
460461
@Override
461462
public int getDesiredWidth() {
462463
int w = getWidth();
464+
if (connection.getRdpResType() == Constants.RDP_GEOM_SELECT_CUSTOM) {
465+
w = connection.getRdpWidth();
466+
}
463467
android.util.Log.d(TAG, "Width requested: " + w);
464468
return w;
465469
}
@@ -470,6 +474,9 @@ public int getDesiredWidth() {
470474
@Override
471475
public int getDesiredHeight() {
472476
int h = getHeight();
477+
if (connection.getRdpResType() == Constants.RDP_GEOM_SELECT_CUSTOM) {
478+
h = connection.getRdpHeight();
479+
}
473480
android.util.Log.d(TAG, "Height requested: " + h);
474481
return h;
475482
}

bVNC/src/main/java/com/undatech/opaque/AdvancedSettingsActivity.java

Lines changed: 102 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
package com.undatech.opaque;
2121

2222
import java.io.IOException;
23+
import java.text.ParseException;
2324
import java.util.Arrays;
2425
import java.util.List;
2526

27+
import com.iiordanov.bVNC.Constants;
2628
import com.iiordanov.util.PermissionsManager;
2729
import com.undatech.opaque.dialogs.ManageCustomCaFragment;
2830

@@ -33,12 +35,15 @@
3335
import android.os.Bundle;
3436
import android.support.v4.app.FragmentActivity;
3537
import android.support.v4.app.FragmentManager;
38+
import android.text.Editable;
39+
import android.text.TextWatcher;
3640
import android.util.Log;
3741
import android.view.View;
3842
import android.widget.AdapterView;
3943
import android.widget.AdapterView.OnItemSelectedListener;
4044
import android.widget.ArrayAdapter;
4145
import android.widget.Button;
46+
import android.widget.EditText;
4247
import android.widget.LinearLayout;
4348
import android.widget.Spinner;
4449
import android.widget.TextView;
@@ -55,13 +60,18 @@ public class AdvancedSettingsActivity extends FragmentActivity implements Manage
5560
private ToggleButton toggleAudioPlayback;
5661
private ToggleButton toggleAutoRotation;
5762
private ToggleButton toggleAutoRequestDisplayResolution;
63+
private ToggleButton toggleCustomDisplayResolution;
5864
private ToggleButton toggleSslStrict;
5965
private ToggleButton toggleUsbEnabled;
6066
private ToggleButton toggleUsingCustomOvirtCa;
6167
private Button buttonManageOvirtCa;
6268
private Spinner layoutMapSpinner;
6369
private LinearLayout layoutManageOvirtCa;
6470
private LinearLayout layoutToggleUsingCustomOvirtCa;
71+
private LinearLayout layoutCustomRemoteResolution;
72+
private LinearLayout layoutToggleCustomRemoteResolution;
73+
private EditText rdpWidth;
74+
private EditText rdpHeight;
6575

6676
@Override
6777
public void onCreate(Bundle icicle) {
@@ -79,10 +89,13 @@ public void onCreate(Bundle icicle) {
7989

8090
toggleAutoRotation = (ToggleButton)findViewById(R.id.toggleAutoRotation);
8191
toggleAutoRotation.setChecked(currentConnection.isRotationEnabled());
82-
92+
8393
toggleAutoRequestDisplayResolution = (ToggleButton)findViewById(R.id.toggleAutoRequestDisplayResolution);
8494
toggleAutoRequestDisplayResolution.setChecked(currentConnection.isRequestingNewDisplayResolution());
8595

96+
toggleCustomDisplayResolution = (ToggleButton)findViewById(R.id.toggleCustomDisplayResolution);
97+
toggleCustomDisplayResolution.setChecked(currentConnection.getRdpResType() == Constants.RDP_GEOM_SELECT_CUSTOM);
98+
8699
toggleSslStrict = (ToggleButton)findViewById(R.id.toggleSslStrict);
87100
toggleSslStrict.setChecked(currentConnection.isSslStrict());
88101

@@ -119,7 +132,64 @@ public void onItemSelected(AdapterView<?> parent, View view,
119132
@Override
120133
public void onNothingSelected(AdapterView<?> parent) { }
121134
});
122-
135+
136+
layoutToggleCustomRemoteResolution = (LinearLayout)findViewById(R.id.layoutToggleCustomRemoteResolution);
137+
layoutCustomRemoteResolution = findViewById(R.id.layoutCustomRemoteResolution);
138+
139+
if (toggleCustomDisplayResolution.isChecked()) {
140+
layoutCustomRemoteResolution.setVisibility(View.VISIBLE);
141+
} else {
142+
layoutCustomRemoteResolution.setVisibility(View.GONE);
143+
}
144+
145+
if (!toggleAutoRequestDisplayResolution.isChecked()) {
146+
layoutToggleCustomRemoteResolution.setVisibility(View.VISIBLE);
147+
} else {
148+
layoutToggleCustomRemoteResolution.setVisibility(View.GONE);
149+
layoutCustomRemoteResolution.setVisibility(View.GONE);
150+
}
151+
152+
rdpWidth = findViewById(R.id.rdpWidth);
153+
rdpWidth.addTextChangedListener(new TextWatcher() {
154+
@Override
155+
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
156+
@Override
157+
public void onTextChanged(CharSequence s, int start, int before, int count) {}
158+
@Override
159+
public void afterTextChanged(Editable s) {
160+
int res = 0;
161+
if (!s.toString().isEmpty()) {
162+
try {
163+
res = Integer.parseInt(s.toString());
164+
} catch (NumberFormatException e) {
165+
res = currentConnection.getRdpWidth();
166+
}
167+
}
168+
currentConnection.setRdpWidth(res);
169+
}
170+
});
171+
rdpWidth.setText(Integer.toString(currentConnection.getRdpWidth()));
172+
rdpHeight = findViewById(R.id.rdpHeight);
173+
rdpHeight.addTextChangedListener(new TextWatcher() {
174+
@Override
175+
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
176+
@Override
177+
public void onTextChanged(CharSequence s, int start, int before, int count) {}
178+
@Override
179+
public void afterTextChanged(Editable s) {
180+
int res = 0;
181+
if (!s.toString().isEmpty()) {
182+
try {
183+
res = Integer.parseInt(s.toString());
184+
} catch (NumberFormatException e) {
185+
res = currentConnection.getRdpHeight();
186+
}
187+
}
188+
currentConnection.setRdpHeight(res);
189+
}
190+
});
191+
rdpHeight.setText(Integer.toString(currentConnection.getRdpHeight()));
192+
123193
// Send the generated data back to the calling activity.
124194
Intent databackIntent = new Intent();
125195
databackIntent.putExtra("com.undatech.opaque.ConnectionSettings", currentConnection);
@@ -163,9 +233,36 @@ public void toggleAutoRotation (View view) {
163233
*/
164234
public void toggleAutoRequestDisplayResolution (View view) {
165235
ToggleButton s = (ToggleButton) view;
166-
currentConnection.setRequestingNewDisplayResolution(s.isChecked());
167-
}
168-
236+
boolean autoDisplayResolution = s.isChecked();
237+
currentConnection.setRequestingNewDisplayResolution(autoDisplayResolution);
238+
if (autoDisplayResolution) {
239+
layoutToggleCustomRemoteResolution.setVisibility(View.GONE);
240+
layoutCustomRemoteResolution.setVisibility(View.GONE);
241+
} else {
242+
layoutToggleCustomRemoteResolution.setVisibility(View.VISIBLE);
243+
layoutCustomRemoteResolution.setVisibility(View.VISIBLE);
244+
}
245+
}
246+
247+
/**
248+
* Automatically linked with android:onClick to the toggleRotation button.
249+
* @param view
250+
*/
251+
public void toggleCustomDisplayResolution (View view) {
252+
ToggleButton s = (ToggleButton) view;
253+
boolean customDisplayResolution = s.isChecked();
254+
int resType = 0;
255+
if (customDisplayResolution) {
256+
resType = Constants.RDP_GEOM_SELECT_CUSTOM;
257+
}
258+
currentConnection.setRdpResType(resType);
259+
if (customDisplayResolution) {
260+
layoutCustomRemoteResolution.setVisibility(View.VISIBLE);
261+
} else {
262+
layoutCustomRemoteResolution.setVisibility(View.GONE);
263+
}
264+
}
265+
169266
/**
170267
* Automatically linked with android:onClick to the toggleSslStrict button.
171268
* @param view

bVNC/src/main/java/com/undatech/opaque/ConnectionSettings.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import android.util.Log;
2929
import android.widget.ImageView;
3030

31+
import com.iiordanov.bVNC.Constants;
32+
3133
import org.json.JSONException;
3234
import org.json.JSONObject;
3335

@@ -72,7 +74,11 @@ public class ConnectionSettings implements Connection, Serializable {
7274
private String x509KeySignature = "";
7375

7476
private int extraKeysToggleType = RemoteClientLibConstants.EXTRA_KEYS_ON;
75-
77+
78+
private int rdpWidth = 0;
79+
private int rdpHeight = 0;
80+
private int rdpResType = Constants.RDP_GEOM_SELECT_CUSTOM;
81+
7682
public ConnectionSettings(String filename) {
7783
super();
7884
this.filename = filename;
@@ -365,6 +371,8 @@ public void saveToSharedPreferences(Context context) {
365371
editor.putString("scaleMode", scaleMode);
366372
editor.putString("x509KeySignature", x509KeySignature);
367373
editor.putString("screenshotFilename", screenshotFilename);
374+
editor.putInt("rdpWidth", rdpWidth);
375+
editor.putInt("rdpHeight", rdpHeight);
368376
editor.apply();
369377
// Make sure the CA gets saved to a file if necessary.
370378
ovirtCaFile = saveCaToFile (context, ovirtCaData);
@@ -416,12 +424,12 @@ public void setScaleMode(ImageView.ScaleType value) {
416424

417425
@Override
418426
public int getRdpResType() {
419-
return 0;
427+
return rdpResType;
420428
}
421429

422430
@Override
423431
public void setRdpResType(int rdpResType) {
424-
432+
this.rdpResType = rdpResType;
425433
}
426434

427435
@Override
@@ -560,6 +568,8 @@ public void loadAdvancedSettings (Context context, String file) {
560568
ovirtCaData = sp.getString("ovirtCaData", "").trim();
561569
layoutMap = sp.getString("layoutMap", RemoteClientLibConstants.DEFAULT_LAYOUT_MAP).trim();
562570
scaleMode = sp.getString("scaleMode", ImageView.ScaleType.MATRIX.toString()).trim();
571+
rdpWidth = sp.getInt("rdpWidth", 0);
572+
rdpHeight = sp.getInt("rdpHeight", 0);
563573
// Make sure the CAs get saved to files if necessary.
564574
ovirtCaFile = saveCaToFile (context, ovirtCaData);
565575
}
@@ -656,22 +666,22 @@ public void setRdpDomain(String rdpDomain) {
656666

657667
@Override
658668
public int getRdpWidth() {
659-
return 0;
669+
return rdpWidth;
660670
}
661671

662672
@Override
663673
public void setRdpWidth(int rdpWidth) {
664-
674+
this.rdpWidth = rdpWidth;
665675
}
666676

667677
@Override
668678
public int getRdpHeight() {
669-
return 0;
679+
return rdpHeight;
670680
}
671681

672682
@Override
673683
public void setRdpHeight(int rdpHeight) {
674-
684+
this.rdpHeight = rdpHeight;
675685
}
676686

677687
@Override

bVNC/src/main/res/layout/advanced_settings_activity.xml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,60 @@
115115

116116
</LinearLayout>
117117

118+
<LinearLayout
119+
android:id="@+id/layoutToggleCustomRemoteResolution"
120+
android:layout_width="fill_parent"
121+
android:layout_height="wrap_content"
122+
android:orientation="horizontal"
123+
android:padding="10dip">
124+
125+
<TextView
126+
android:layout_width="0dp"
127+
android:layout_height="wrap_content"
128+
android:layout_weight="4"
129+
android:text="@string/resolution_custom"
130+
android:textAppearance="?android:attr/textAppearanceMedium" />
131+
132+
<ToggleButton
133+
android:id="@+id/toggleCustomDisplayResolution"
134+
android:layout_width="0dp"
135+
android:layout_height="wrap_content"
136+
android:layout_weight="1"
137+
android:onClick="toggleCustomDisplayResolution" />
138+
139+
</LinearLayout>
140+
141+
<LinearLayout
142+
android:id="@+id/layoutCustomRemoteResolution"
143+
android:layout_width="fill_parent"
144+
android:layout_height="wrap_content"
145+
android:orientation="horizontal"
146+
android:padding="5dp"
147+
android:visibility="gone">
148+
149+
<EditText
150+
android:id="@+id/rdpWidth"
151+
android:layout_width="wrap_content"
152+
android:layout_height="wrap_content"
153+
android:layout_weight="0.3"
154+
android:singleLine="true"
155+
android:textAppearance="?android:attr/textAppearanceMedium" />
156+
157+
<TextView
158+
android:layout_width="wrap_content"
159+
android:layout_height="wrap_content"
160+
android:text="x"
161+
android:textAppearance="?android:attr/textAppearanceMedium" />
162+
163+
<EditText
164+
android:id="@+id/rdpHeight"
165+
android:layout_width="wrap_content"
166+
android:layout_height="wrap_content"
167+
android:layout_weight="0.3"
168+
android:singleLine="true"
169+
android:textAppearance="?android:attr/textAppearanceMedium" />
170+
</LinearLayout>
171+
118172
<LinearLayout
119173
android:layout_width="fill_parent"
120174
android:layout_height="wrap_content"

freeaRDP-app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.iiordanov.freeaRDP" android:installLocation="auto"
5-
android:versionCode="115043" android:versionName="v5.0.4">
5+
android:versionCode="115044" android:versionName="v5.0.4">
66

77
<uses-permission tools:node="removeAll"/>
88
<uses-permission android:name="android.permission.INTERNET"> </uses-permission>

0 commit comments

Comments
 (0)