aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-10-09 13:25:17 -0700
committerKenny Root <kenny@the-b.org>2015-10-09 13:25:17 -0700
commit584cc8c9478b2fd14463f23a3b841c4991822617 (patch)
tree52ce817c838cfbf23dadbd5a46cdf0d469a25997
parent93f28ba0db2d4c3cfe699aa7b217362e608bdccd (diff)
parentfc35568a1ad2b9eb852bc7577908f5aba161f413 (diff)
downloadconnectbot-584cc8c9478b2fd14463f23a3b841c4991822617.tar.gz
connectbot-584cc8c9478b2fd14463f23a3b841c4991822617.tar.bz2
connectbot-584cc8c9478b2fd14463f23a3b841c4991822617.zip
Merge pull request #279 from jklein24/pgsetting
Make the pg up/down gesture a preference which is disabled by default.
-rw-r--r--app/src/main/java/org/connectbot/TerminalView.java42
-rw-r--r--app/src/main/java/org/connectbot/util/PreferenceConstants.java1
-rw-r--r--app/src/main/res/values/strings.xml7
-rw-r--r--app/src/main/res/xml-v14/preferences.xml7
-rw-r--r--app/src/main/res/xml/preferences.xml7
5 files changed, 56 insertions, 8 deletions
diff --git a/app/src/main/java/org/connectbot/TerminalView.java b/app/src/main/java/org/connectbot/TerminalView.java
index bc095fc..767a4a0 100644
--- a/app/src/main/java/org/connectbot/TerminalView.java
+++ b/app/src/main/java/org/connectbot/TerminalView.java
@@ -25,6 +25,7 @@ import org.connectbot.bean.SelectionArea;
import org.connectbot.service.FontSizeChangedListener;
import org.connectbot.service.TerminalBridge;
import org.connectbot.service.TerminalKeyListener;
+import org.connectbot.util.PreferenceConstants;
import org.connectbot.util.TerminalViewPager;
import android.annotation.TargetApi;
@@ -32,6 +33,7 @@ import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.graphics.Canvas;
@@ -45,6 +47,7 @@ import android.graphics.Typeface;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
+import android.preference.PreferenceManager;
import android.support.v4.view.MotionEventCompat;
import android.text.ClipboardManager;
import android.view.ActionMode;
@@ -54,6 +57,7 @@ import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
+import android.view.ViewConfiguration;
import android.view.ViewGroup.LayoutParams;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
@@ -83,6 +87,7 @@ public class TerminalView extends TextView implements FontSizeChangedListener {
private final TerminalViewPager viewPager;
private GestureDetector gestureDetector;
+ private SharedPreferences prefs;
private ClipboardManager clipboard;
private ActionMode selectionActionMode = null;
@@ -180,6 +185,7 @@ public class TerminalView extends TextView implements FontSizeChangedListener {
new AccessibilityStateTester().execute((Void) null);
clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
+ prefs = PreferenceManager.getDefaultSharedPreferences(context);
setTextColor(Color.TRANSPARENT);
setTypeface(Typeface.MONOSPACE);
@@ -202,13 +208,35 @@ public class TerminalView extends TextView implements FontSizeChangedListener {
totalY = 0;
}
- totalY += distanceY;
- final int moved = (int) (totalY / bridge.charHeight);
-
- if (moved != 0) {
- int base = bridge.buffer.getWindowBase();
- bridge.buffer.setWindowBase(base + moved);
- totalY = 0;
+ // activate consider if within x tolerance
+ int touchSlop =
+ ViewConfiguration.get(TerminalView.this.context).getScaledTouchSlop();
+ if (Math.abs(e1.getX() - e2.getX()) < touchSlop * 4) {
+ // estimate how many rows we have scrolled through
+ // accumulate distance that doesn't trigger immediate scroll
+ totalY += distanceY;
+ final int moved = (int) (totalY / bridge.charHeight);
+
+ // Consume as pg up/dn only if towards left third of screen with the gesture
+ // enabled.
+ boolean pgUpDnGestureEnabled =
+ prefs.getBoolean(PreferenceConstants.PG_UPDN_GESTURE, false);
+ if (e2.getX() <= getWidth() / 3 && pgUpDnGestureEnabled) {
+ // otherwise consume as pgup/pgdown for every 5 lines
+ if (moved > 5) {
+ ((vt320) bridge.buffer).keyPressed(vt320.KEY_PAGE_DOWN, ' ', 0);
+ bridge.tryKeyVibrate();
+ totalY = 0;
+ } else if (moved < -5) {
+ ((vt320) bridge.buffer).keyPressed(vt320.KEY_PAGE_UP, ' ', 0);
+ bridge.tryKeyVibrate();
+ totalY = 0;
+ }
+ } else if (moved != 0) {
+ int base = bridge.buffer.getWindowBase();
+ bridge.buffer.setWindowBase(base + moved);
+ totalY = 0;
+ }
}
return true;
diff --git a/app/src/main/java/org/connectbot/util/PreferenceConstants.java b/app/src/main/java/org/connectbot/util/PreferenceConstants.java
index eb0e396..fe80f24 100644
--- a/app/src/main/java/org/connectbot/util/PreferenceConstants.java
+++ b/app/src/main/java/org/connectbot/util/PreferenceConstants.java
@@ -46,6 +46,7 @@ public class PreferenceConstants {
public static final String FULLSCREEN = "fullscreen";
public static final String TITLEBARHIDE = "titlebarhide";
+ public static final String PG_UPDN_GESTURE = "pgupdngesture";
public static final String KEYMODE = "keymode";
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 7d44f8d..b92cc28 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -83,7 +83,7 @@
<string name="page_updn_header">"Page Up / Page Down"</string>
<!-- Instructions about paging up and down in the terminal. -->
- <string name="page_updn_content">"Swiping your finger up and down on the left third of the screen will send a page up and page down key to the remote host. Many programs map this to scrolling back into history such as irssi or tinyfugue."</string>
+ <string name="page_updn_content">"NOTE: This must be enabled in settings."\n\n"Swiping your finger up and down on the left third of the screen will send a page up and page down key to the remote host. Many programs map this to scrolling back into history such as irssi or tinyfugue."</string>
<!-- Captions for images showing the page up/down gestures. -->
<string name="page_up">"Page up"</string>
@@ -236,6 +236,11 @@
<!-- Summary for the titlebar hide preference -->
<string name="pref_titlebarhide_summary">"Tap console to show title bar and access menu"</string>
+ <!-- Name for the page up/down gesture preference -->
+ <string name="pref_pg_updn_gesture_title">"Page up/down gesture"</string>
+ <!-- Summary for the full screen preference -->
+ <string name="pref_pg_updn_gesture_summary">"Swipe the left third of the screen to send pg up/dn to the terminal"</string>
+
<!-- Name for the full screen preference -->
<string name="pref_fullscreen_title">"Full screen"</string>
<!-- Summary for the full screen preference -->
diff --git a/app/src/main/res/xml-v14/preferences.xml b/app/src/main/res/xml-v14/preferences.xml
index d04119f..9e76c36 100644
--- a/app/src/main/res/xml-v14/preferences.xml
+++ b/app/src/main/res/xml-v14/preferences.xml
@@ -89,6 +89,13 @@
android:defaultValue="false"
/>
+ <org.connectbot.util.SwitchCompatPreference
+ android:key="pgupdngesture"
+ android:title="@string/pref_pg_updn_gesture_title"
+ android:summary="@string/pref_pg_updn_gesture_summary"
+ android:defaultValue="false"
+ />
+
<SwitchPreference
android:key="volumefont"
android:title="@string/pref_volumefont_title"
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index 88b9855..e87b263 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -90,6 +90,13 @@
/>
<org.connectbot.util.SwitchCompatPreference
+ android:key="pgupdngesture"
+ android:title="@string/pref_pg_updn_gesture_title"
+ android:summary="@string/pref_pg_updn_gesture_summary"
+ android:defaultValue="false"
+ />
+
+ <org.connectbot.util.SwitchCompatPreference
android:key="volumefont"
android:title="@string/pref_volumefont_title"
android:summary="@string/pref_volumefont_summary"