Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scroll sensitivity option #487

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bVNC/src/main/java/com/iiordanov/bVNC/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ public class Constants {
public static final String showOnlyConnectionNicknames = "showOnlyConnectionNicknames";

public static final String softwareKeyboardType = "softwareKeyboardType";
public static final String scrollSensitivityTag = "scrollSensitivity";

public static final String ACTION_USB_PERMISSION = "com.iiordanov.aSPICE.USB_PERMISSION";
public static final int usbDeviceTimeout = 5000;
Expand Down
22 changes: 18 additions & 4 deletions bVNC/src/main/java/com/iiordanov/bVNC/RemoteCanvasActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1346,13 +1346,13 @@ InputHandler getInputHandlerById(int id) {
if (inputModeIds[i] == id) {
if (inputModeHandlers[i] == null) {
if (id == R.id.itemInputTouchPanZoomMouse) {
inputModeHandlers[i] = new InputHandlerDirectSwipePan(this, canvas, canvas.getPointer(), App.debugLog);
inputModeHandlers[i] = new InputHandlerDirectSwipePan(this, canvas, canvas.getPointer(), App.debugLog, getScrollSensitivitySetting());
} else if (id == R.id.itemInputDragPanZoomMouse) {
inputModeHandlers[i] = new InputHandlerDirectDragPan(this, canvas, canvas.getPointer(), App.debugLog);
inputModeHandlers[i] = new InputHandlerDirectDragPan(this, canvas, canvas.getPointer(), App.debugLog, getScrollSensitivitySetting());
} else if (id == R.id.itemInputTouchpad) {
inputModeHandlers[i] = new InputHandlerTouchpad(this, canvas, canvas.getPointer(), App.debugLog);
inputModeHandlers[i] = new InputHandlerTouchpad(this, canvas, canvas.getPointer(), App.debugLog, getScrollSensitivitySetting());
} else if (id == R.id.itemInputSingleHanded) {
inputModeHandlers[i] = new InputHandlerSingleHanded(this, canvas, canvas.getPointer(), App.debugLog);
inputModeHandlers[i] = new InputHandlerSingleHanded(this, canvas, canvas.getPointer(), App.debugLog, getScrollSensitivitySetting());
} else {
throw new IllegalStateException("Unexpected value: " + id);
}
Expand Down Expand Up @@ -1396,6 +1396,11 @@ int getModeIdFromHandler(InputHandler handler) {
return R.id.itemInputTouchPanZoomMouse;
}

int getScrollSensitivitySetting() {
// SeekBar starts at 0 so +1 to ensure speed of at least 1
return Utils.querySharedPreferenceInt(this, Constants.scrollSensitivityTag, 6) + 1;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
RemoteKeyboard k = canvas.getKeyboard();
Expand Down Expand Up @@ -1760,5 +1765,14 @@ public void onBackPressed() {
}
}

// public boolean setScrollSensitivity(int sensitivity) {
// try {
// InputHandlerDirectSwipePan swipePan = (InputHandlerDirectSwipePan)inputHandler;
// swipePan.setScrollSensitivity(sensitivity);
// return true;
// } catch (ClassCastException e) {
// return false;
// }
// }
Comment on lines +1768 to +1776
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this commented out section?


}
9 changes: 9 additions & 0 deletions bVNC/src/main/java/com/iiordanov/bVNC/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,15 @@ public static String querySharedPreferenceString(Context context, String key, St
return result;
}

public static int querySharedPreferenceInt(Context context, String key, int dftValue) {
int result = dftValue;
if (context != null) {
SharedPreferences sp = context.getSharedPreferences(Constants.generalSettingsTag, Context.MODE_PRIVATE);
result = sp.getInt(key, dftValue);
}
return result;
}

public static void setSharedPreferenceString(Context context, String key, String value) {
if (context != null) {
SharedPreferences sp = context.getSharedPreferences(Constants.generalSettingsTag, Context.MODE_PRIVATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class InputHandlerDirectDragPan extends InputHandlerGeneric {
public static final String ID = "TOUCH_ZOOM_MODE_DRAG_PAN";

public InputHandlerDirectDragPan(RemoteCanvasActivity activity, RemoteCanvas canvas,
RemotePointer pointer, boolean debugLogging) {
super(activity, canvas, pointer, debugLogging);
RemotePointer pointer, boolean debugLogging, int swipeSpeed) {
super(activity, canvas, pointer, debugLogging, swipeSpeed);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class InputHandlerDirectSwipePan extends InputHandlerGeneric {
public static final String ID = "TOUCH_ZOOM_MODE";

public InputHandlerDirectSwipePan(RemoteCanvasActivity activity, RemoteCanvas canvas,
RemotePointer pointer, boolean debugLogging) {
super(activity, canvas, pointer, debugLogging);
RemotePointer pointer, boolean debugLogging, int swipeSpeed) {
super(activity, canvas, pointer, debugLogging, swipeSpeed);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ abstract class InputHandlerGeneric extends GestureDetector.SimpleOnGestureListen
// The variables which indicates how many scroll events to send per swipe
// event and the maximum number to send at one time.
long swipeSpeed = 1;
final int maxSwipeSpeed = 7;
int maxSwipeSpeed = 1;

// If swipe events are registered once every baseSwipeTime miliseconds, then
// swipeSpeed will be one. If more often, swipe-speed goes up, if less, down.
Expand Down Expand Up @@ -126,11 +126,12 @@ abstract class InputHandlerGeneric extends GestureDetector.SimpleOnGestureListen
protected RemotePointer pointer;

InputHandlerGeneric(RemoteCanvasActivity activity, RemoteCanvas canvas, RemotePointer pointer,
boolean debugLogging) {
boolean debugLogging, int swipeSpeed) {
this.activity = activity;
this.canvas = canvas;
this.pointer = pointer;
this.debugLogging = debugLogging;
this.maxSwipeSpeed = swipeSpeed;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this variable at all anymore, do we?


// TODO: Implement this
useDpadAsArrows = true; //activity.getUseDpadAsArrows();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public class InputHandlerSingleHanded extends InputHandlerDirectSwipePan {
private boolean needInitPan;

public InputHandlerSingleHanded(RemoteCanvasActivity activity, RemoteCanvas canvas,
RemotePointer pointer, boolean debugLogging) {
super(activity, canvas, pointer, debugLogging);
RemotePointer pointer, boolean debugLogging, int swipeSpeed) {
super(activity, canvas, pointer, debugLogging, swipeSpeed);
initializeButtons();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class InputHandlerTouchpad extends InputHandlerGeneric {
public static final String ID = "TOUCHPAD_MODE";

public InputHandlerTouchpad(RemoteCanvasActivity activity, RemoteCanvas canvas,
RemotePointer pointer, boolean debugLogging) {
super(activity, canvas, pointer, debugLogging);
RemotePointer pointer, boolean debugLogging, int swipeSpeed) {
super(activity, canvas, pointer, debugLogging, swipeSpeed);
}

/*
Expand Down
2 changes: 2 additions & 0 deletions bVNC/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ All Input Methods:
<string name="color_format_caption">Color Mode</string>
<string name="color_mode">Color Mode</string>

<string name="scroll_sensitivity">Scroll Sensitivity</string>

<string name="connect_button">Connect</string>
<string name="back_button">Go Back</string>
<string name="update_button">Update</string>
Expand Down
5 changes: 5 additions & 0 deletions bVNC/src/main/res/xml/global_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@
android:entryValues="@array/pref_keyboard_type_option_values"
android:key="softwareKeyboardType"
android:title="@string/keyboard_type" />
<SeekBarPreference
android:defaultValue="6"
android:max="9"
android:key="scrollSensitivity"
android:title="@string/scroll_sensitivity" />
</PreferenceScreen>