Skip to content

Commit

Permalink
Implemented Custom Scaling support for aRDP.
Browse files Browse the repository at this point in the history
  • Loading branch information
iiordanov committed Nov 20, 2024
1 parent 1ebe992 commit 6eda6fb
Show file tree
Hide file tree
Showing 13 changed files with 204 additions and 9 deletions.
22 changes: 20 additions & 2 deletions bVNC/src/main/java/com/iiordanov/bVNC/AbstractConnectionBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract class AbstractConnectionBean extends com.antlersoft.android.dbim
public static final String TAG = "AbstractConnectionBean";

public static final String GEN_TABLE_NAME = "CONNECTION_BEAN";
public static final int GEN_COUNT = 92;
public static final int GEN_COUNT = 93;

// Field constants
public static final String GEN_FIELD__ID = "_id";
Expand Down Expand Up @@ -223,6 +223,8 @@ public abstract class AbstractConnectionBean extends com.antlersoft.android.dbim
public static final int GEN_ID_RDPGATEWAYPASSWORD = 90;
public static final String GEN_FIELD_KEEPRDPGATEWAYPASSWORD = "KEEPRDPGATEWAYPASSWORD";
public static final int GEN_ID_KEEPRDPGATEWAYPASSWORD = 91;
public static final String GEN_FIELD_DESKTOPSCALEPERCENTAGE = "DESKTOPSCALEPERCENTAGE";
public static final int GEN_ID_DESKTOPSCALEPERCENTAGE = 92;

// SQL Command for creating the table
public static String GEN_CREATE = "CREATE TABLE CONNECTION_BEAN (" +
Expand Down Expand Up @@ -317,7 +319,8 @@ public abstract class AbstractConnectionBean extends com.antlersoft.android.dbim
"RDPGATEWAYUSERNAME TEXT," +
"RDPGATEWAYDOMAIN TEXT," +
"RDPGATEWAYPASSWORD TEXT," +
"KEEPRDPGATEWAYPASSWORD INTEGER" +
"KEEPRDPGATEWAYPASSWORD INTEGER," +
"DESKTOPSCALEPERCENTAGE INTEGER" +
")";

// Members corresponding to defined fields
Expand Down Expand Up @@ -417,6 +420,7 @@ public abstract class AbstractConnectionBean extends com.antlersoft.android.dbim
private String gen_rdpGatewayDomain;
private String gen_rdpGatewayPassword;
private boolean gen_keepRdpGatewayPassword;
private int gen_desktopScalePercentage;

public String Gen_tableName() {
return GEN_TABLE_NAME;
Expand Down Expand Up @@ -1161,6 +1165,14 @@ public void setKeepRdpGatewayPassword(boolean keepRdpGatewayPassword) {
this.gen_keepRdpGatewayPassword = keepRdpGatewayPassword;
}

public int getDesktopScalePercentage() {
return gen_desktopScalePercentage;
}

public void setDesktopScalePercentage(int desktopScalePercentage) {
this.gen_desktopScalePercentage = desktopScalePercentage;
}

public android.content.ContentValues Gen_getValues() {
android.content.ContentValues values = new android.content.ContentValues();
values.put(GEN_FIELD__ID, Long.toString(this.gen__Id));
Expand Down Expand Up @@ -1260,6 +1272,7 @@ public android.content.ContentValues Gen_getValues() {
values.put(GEN_FIELD_RDPGATEWAYDOMAIN, (this.gen_rdpGatewayDomain));
values.put(GEN_FIELD_RDPGATEWAYPASSWORD, (this.gen_rdpGatewayPassword));
values.put(GEN_FIELD_KEEPRDPGATEWAYPASSWORD, (this.gen_keepRdpGatewayPassword));
values.put(GEN_FIELD_DESKTOPSCALEPERCENTAGE, (this.gen_desktopScalePercentage));

return values;
}
Expand Down Expand Up @@ -1373,6 +1386,7 @@ public int[] Gen_columnIndices(android.database.Cursor cursor) {
result[89] = cursor.getColumnIndex(GEN_FIELD_RDPGATEWAYDOMAIN);
result[90] = cursor.getColumnIndex(GEN_FIELD_RDPGATEWAYPASSWORD);
result[91] = cursor.getColumnIndex(GEN_FIELD_KEEPRDPGATEWAYPASSWORD);
result[92] = cursor.getColumnIndex(GEN_FIELD_DESKTOPSCALEPERCENTAGE);

return result;
}
Expand Down Expand Up @@ -1661,6 +1675,9 @@ public void Gen_populate(android.database.Cursor cursor, int[] columnIndices) {
if (columnIndices[GEN_ID_KEEPRDPGATEWAYPASSWORD] >= 0 && !cursor.isNull(columnIndices[GEN_ID_KEEPRDPGATEWAYPASSWORD])) {
gen_keepRdpGatewayPassword = (cursor.getInt(columnIndices[GEN_ID_KEEPRDPGATEWAYPASSWORD]) != 0);
}
if (columnIndices[GEN_ID_DESKTOPSCALEPERCENTAGE] >= 0 && !cursor.isNull(columnIndices[GEN_ID_DESKTOPSCALEPERCENTAGE])) {
gen_desktopScalePercentage = cursor.getInt(columnIndices[GEN_ID_DESKTOPSCALEPERCENTAGE]);
}
}

/**
Expand Down Expand Up @@ -1764,6 +1781,7 @@ public void Gen_populate(android.content.ContentValues values) {
gen_rdpGatewayDomain = values.getAsString(GEN_FIELD_RDPGATEWAYDOMAIN);
gen_rdpGatewayPassword = values.getAsString(GEN_FIELD_RDPGATEWAYPASSWORD);
gen_keepRdpGatewayPassword = values.getAsBoolean(GEN_FIELD_KEEPRDPGATEWAYPASSWORD);
gen_desktopScalePercentage = values.getAsInteger(GEN_FIELD_DESKTOPSCALEPERCENTAGE);
}

/**
Expand Down
1 change: 1 addition & 0 deletions bVNC/src/main/java/com/iiordanov/bVNC/ConnectionBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public ConnectionBean(Context context) {
setUseLastPositionToolbarMoved(false);

setRdpGatewayPort(Constants.DEFAULT_RDP_GATEWAY_PORT);
setDesktopScalePercentage(Constants.DEFAULT_DESKTOP_SCALE_PERCENTAGE);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions bVNC/src/main/java/com/iiordanov/bVNC/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ public class Constants {
public static final int CURSOR_AUTO = 0;
public static final int CURSOR_FORCE_LOCAL = 1;
public static final int CURSOR_FORCE_DISABLE = 2;
public static final int DEFAULT_DESKTOP_SCALE_PERCENTAGE = 100;
public static final int MIN_DESKTOP_SCALE_PERCENTAGE = 100;
public static final int MAX_DESKTOP_SCALE_PERCENTAGE = 300;
public static volatile int DEFAULT_PROTOCOL_PORT = 5900;
public static final int DEFAULT_SCROLL_SPEED = 6;

Expand Down
12 changes: 11 additions & 1 deletion bVNC/src/main/java/com/iiordanov/bVNC/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public class Database extends SQLiteOpenHelper {
static final int DBV_2_1_8 = 507;
static final int DBV_2_1_9 = 521;
static final int DBV_2_2_0 = 525;
static final int CURRVERS = DBV_2_2_0;
static final int DBV_2_2_1 = 561;
static final int CURRVERS = DBV_2_2_1;
private static final String dbName = "VncDatabase";
private static String password = "";

Expand Down Expand Up @@ -433,6 +434,15 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
);
oldVersion = DBV_2_2_0;
}
if (oldVersion == DBV_2_2_0) {
Log.i(TAG, "Doing upgrade from 515 to 561");
db.execSQL(
"ALTER TABLE " + AbstractConnectionBean.GEN_TABLE_NAME + " ADD COLUMN "
+ AbstractConnectionBean.GEN_FIELD_DESKTOPSCALEPERCENTAGE + " INTEGER DEFAULT "
+ Constants.DEFAULT_DESKTOP_SCALE_PERCENTAGE
);
oldVersion = DBV_2_2_1;
}
}

public boolean checkMasterPassword(String password, Context context) {
Expand Down
38 changes: 37 additions & 1 deletion bVNC/src/main/java/com/iiordanov/bVNC/aRDP.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

package com.iiordanov.bVNC;

import static com.iiordanov.bVNC.Constants.MAX_DESKTOP_SCALE_PERCENTAGE;
import static com.iiordanov.bVNC.Constants.MIN_DESKTOP_SCALE_PERCENTAGE;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.MenuItem;
Expand All @@ -28,7 +31,9 @@
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.SeekBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.ToggleButton;

import com.iiordanov.bVNC.dialogs.IntroTextDialog;
Expand Down Expand Up @@ -71,6 +76,8 @@ public class aRDP extends MainConfiguration {
private CheckBox checkboxPreferSendingUnicode;
private Spinner spinnerRdpColor;
private List<String> rdpColorArray;
private SeekBar desktopScaleSeekBar;
private TextView desktopScaleProgressTextView;

@Override
public void onCreate(Bundle icicle) {
Expand All @@ -90,6 +97,33 @@ private void initializeRdpSpecificConnectionParameters() {
}

private void initializeAdvancedSettings() {
desktopScaleSeekBar = findViewById(R.id.desktopScaleSeekBar);
desktopScaleProgressTextView = findViewById(R.id.desktopScaleProgressTextView);
desktopScaleSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@SuppressLint("SetTextI18n")
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (seekBar.getProgress() < MIN_DESKTOP_SCALE_PERCENTAGE) {
seekBar.setProgress(MIN_DESKTOP_SCALE_PERCENTAGE);
}
if (seekBar.getProgress() > MAX_DESKTOP_SCALE_PERCENTAGE) {
seekBar.setProgress(MAX_DESKTOP_SCALE_PERCENTAGE);
}
int val = (seekBar.getProgress() * (seekBar.getWidth() - 2 * seekBar.getThumbOffset())) / seekBar.getMax();
desktopScaleProgressTextView.setText(seekBar.getProgress() + "%");
desktopScaleProgressTextView.setX(seekBar.getX() + val + (float) seekBar.getThumbOffset() / 2);
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

}
});
groupRemoteSoundType = findViewById(R.id.groupRemoteSoundType);
groupRemoteSoundType.setOnCheckedChangeListener((radioGroup, selection) -> {
if (Utils.isFree(aRDP.this) && selection != R.id.radioRemoteSoundDisabled) {
Expand Down Expand Up @@ -146,7 +180,7 @@ private void initializeRdpGatewaySettings() {
layoutRdpGatewaySettings = findViewById(R.id.layoutRdpGatewaySettings);
rdpGatewayEnabled = findViewById(R.id.rdpGatewayEnabled);
rdpGatewayEnabled.setOnClickListener(v -> {
layoutRdpGatewaySettings.setVisibility(((ToggleButton)v).isChecked() ? View.VISIBLE : View.GONE);
layoutRdpGatewaySettings.setVisibility(((ToggleButton) v).isChecked() ? View.VISIBLE : View.GONE);
});
rdpGatewayHostname = findViewById(R.id.rdpGatewayHostname);
rdpGatewayPort = findViewById(R.id.rdpGatewayPort);
Expand Down Expand Up @@ -193,6 +227,7 @@ private void setRdpColorSpinnerPositionFromSelected() {
}

private void updateAdvancedSettingsViewsFromSelected() {
desktopScaleSeekBar.setProgress(selected.getDesktopScalePercentage());
checkboxEnableRecording.setChecked(selected.getEnableRecording());
checkboxConsoleMode.setChecked(selected.getConsoleMode());
checkboxRedirectSdCard.setChecked(selected.getRedirectSdCard());
Expand Down Expand Up @@ -238,6 +273,7 @@ private void updateSelectedRdpResolutionTypeFromRdpGeometrySpinnerPosition() {
}

private void updateSelectedAdvancedSettingsFromViews() {
selected.setDesktopScalePercentage(desktopScaleSeekBar.getProgress());
setRemoteSoundTypeFromView(groupRemoteSoundType);
selected.setEnableRecording(checkboxEnableRecording.isChecked());
selected.setConsoleMode(checkboxConsoleMode.isChecked());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class RemoteRdpConnection(
connection.redirectSdCard, connection.consoleMode,
connection.remoteSoundType, connection.enableRecording,
connection.remoteFx, connection.enableGfx, connection.enableGfxH264,
connection.rdpColor
connection.rdpColor, connection.desktopScalePercentage
)
rdpComm!!.connect()
pd.dismiss()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1476,4 +1476,12 @@ public boolean getEnableGfxH264() {
public void setEnableGfxH264(boolean enableGfxH264) {
}

@Override
public int getDesktopScalePercentage() {
return 0;
}

@Override
public void setDesktopScalePercentage(int desktopScalePercentage) {
}
}
17 changes: 17 additions & 0 deletions bVNC/src/main/res/layout-large/main_rdp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,23 @@
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/desktop_scale_percentage"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/desktopScaleProgressTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" />
<SeekBar
android:id="@+id/desktopScaleSeekBar"
android:max="300"
android:title="@string/desktop_scale_percentage"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>

<CheckBox
android:id="@+id/checkboxPreferSendingUnicode"
android:layout_width="wrap_content"
Expand Down
18 changes: 18 additions & 0 deletions bVNC/src/main/res/layout/main_rdp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,26 @@
android:layout_weight="0.3"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium" />

</LinearLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/desktop_scale_percentage"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/desktopScaleProgressTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" />
<SeekBar
android:id="@+id/desktopScaleSeekBar"
android:max="300"
android:title="@string/desktop_scale_percentage"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>

<CheckBox
android:id="@+id/checkboxPreferSendingUnicode"
android:layout_width="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions bVNC/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -908,4 +908,5 @@ Below that is where you configure your connection.
<string name="vnc_viewer_started">VNC Viewer started</string>
<string name="enable_gateway">Enable Gateway</string>
<string name="scroll_speed">Touch Scroll Speed</string>
<string name="desktop_scale_percentage">Custom Scaling Percentage</string>
</resources>
77 changes: 77 additions & 0 deletions remoteClientLib/jni/libs/11_freerdp_customize_desktop_scale.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/BookmarkBase.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/BookmarkBase.java
index 5b64ed3a6..2e0fe2191 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/BookmarkBase.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/BookmarkBase.java
@@ -572,6 +572,7 @@ public class BookmarkBase implements Parcelable, Cloneable
private int colors;
private int width;
private int height;
+ private int desktopScalePercentage;

public ScreenSettings()
{
@@ -622,6 +623,11 @@ public class BookmarkBase implements Parcelable, Cloneable
resolution = AUTOMATIC;
break;
}
+
+ if ((desktopScalePercentage < 100) || (desktopScalePercentage > 500))
+ {
+ desktopScalePercentage = 100;
+ }
}

private void init()
@@ -751,6 +757,16 @@ public class BookmarkBase implements Parcelable, Cloneable
out.writeInt(colors);
out.writeInt(width);
out.writeInt(height);
+ out.writeInt(desktopScalePercentage);
+ }
+
+ public int getDesktopScalePercentage() {
+ validate();
+ return desktopScalePercentage;
+ }
+
+ public void setDesktopScalePercentage(int desktopScalePercentage) {
+ this.desktopScalePercentage = desktopScalePercentage;
}
}

diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java
index 317582373..fc89b4737 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java
@@ -13,9 +13,10 @@ package com.freerdp.freerdpcore.services;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
-import androidx.collection.LongSparseArray;
import android.util.Log;

+import androidx.collection.LongSparseArray;
+
import com.freerdp.freerdpcore.application.GlobalApp;
import com.freerdp.freerdpcore.application.SessionState;
import com.freerdp.freerdpcore.domain.BookmarkBase;
@@ -24,9 +25,7 @@ import com.freerdp.freerdpcore.presentation.ApplicationSettingsActivity;

import java.io.File;
import java.util.ArrayList;
-import java.util.List;
import java.util.Objects;
-import java.util.regex.MatchResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@@ -386,6 +385,9 @@ public class LibFreeRDP
args.add("/microphone");
}

+ args.add("/scale-device:100");
+ args.add("/scale-desktop:" + screenSettings.getDesktopScalePercentage());
+
//args.add("/cert-ignore");
args.add("/log-level:" + debug.getDebugLevel());
String[] arrayArgs = args.toArray(new String[args.size()]);
Original file line number Diff line number Diff line change
Expand Up @@ -474,4 +474,8 @@ public interface Connection {
public boolean getKeepRdpGatewayPassword();

public void setKeepRdpGatewayPassword(boolean keepRdpGatewayPassword);

public int getDesktopScalePercentage();

public void setDesktopScalePercentage(int desktopScalePercentage);
}
Loading

0 comments on commit 6eda6fb

Please sign in to comment.