changeset 237:f9b1a07c0e96

configurable hardware buttons can now change font size
author Carl Byington <carl@five-ten-sg.com>
date Mon, 14 Jul 2014 08:46:06 -0700
parents 35ed530366d9
children bd803721f94a
files res/values/arrays.xml res/values/strings.xml src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java src/com/five_ten_sg/connectbot/util/PreferenceConstants.java
diffstat 4 files changed, 35 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/res/values/arrays.xml	Sun Jul 13 12:35:52 2014 -0700
+++ b/res/values/arrays.xml	Mon Jul 14 08:46:06 2014 -0700
@@ -58,6 +58,8 @@
 		<item>@string/list_hwbutton_esc_a</item>
 		<item>@string/list_hwbutton_monitor</item>
 		<item>@string/list_hwbutton_soft_function_keys</item>
+		<item>@string/list_hwbutton_increase_fontsize</item>
+		<item>@string/list_hwbutton_decrease_fontsize</item>
 		<item>@string/list_hwbutton_none</item>
 	</string-array>
 
@@ -72,6 +74,8 @@
 		<item>Esc+A</item>
 		<item>Monitor Key</item>
         <item>Soft Function Keypad</item>
+		<item>Increase Font Size</item>
+		<item>Decrease Font Size</item>
 		<item>None</item>
 	</string-array>
 
--- a/res/values/strings.xml	Sun Jul 13 12:35:52 2014 -0700
+++ b/res/values/strings.xml	Mon Jul 14 08:46:06 2014 -0700
@@ -475,6 +475,10 @@
 	<string name="list_hwbutton_monitor">"Monitor Key"</string>
 	<!-- Selection to indicate pressing a hardware button should bring up the soft function key pad. -->
 	<string name="list_hwbutton_soft_function_keys">"Soft Function Keypad"</string>
+	<!-- Selection to indicate pressing a hardware button should increase font size. -->
+	<string name="list_hwbutton_increase_fontsize">"Increase Font Size"</string>
+	<!-- Selection to indicate pressing a hardware button should decrease font size. -->
+	<string name="list_hwbutton_decrease_fontsize">"Decrease Font Size"</string>
 	<!-- Selection to indicate pressing a hardware button should send nothing at all. -->
 	<string name="list_hwbutton_none">"None"</string>
 
--- a/src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java	Sun Jul 13 12:35:52 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java	Mon Jul 14 08:46:06 2014 -0700
@@ -568,40 +568,41 @@
     }
 
     private boolean handleShortcuts(View v, int keyCode, KeyEvent event, int repeat, boolean down) {
+        String hwbuttonShortcut;
         switch (keyCode) {
             case KeyEvent.KEYCODE_CAMERA:
                 // check to see which shortcut the camera button triggers
-                String hwbuttonShortcut = manager.prefs.getString(
-                                              PreferenceConstants.CAMERA,
-                                              PreferenceConstants.HWBUTTON_SCREEN_CAPTURE);
+                hwbuttonShortcut = manager.prefs.getString(
+                                        PreferenceConstants.CAMERA,
+                                        PreferenceConstants.HWBUTTON_SCREEN_CAPTURE);
                 return (handleShortcut(v, hwbuttonShortcut, repeat, down));
 
             case KeyEvent.KEYCODE_VOLUME_UP:
                 // check to see which shortcut the volume button triggers
                 hwbuttonShortcut = manager.prefs.getString(
-                                       PreferenceConstants.VOLUP,
-                                       PreferenceConstants.HWBUTTON_FUNCTION_KEYS);
+                                        PreferenceConstants.VOLUP,
+                                        PreferenceConstants.HWBUTTON_FUNCTION_KEYS);
                 return (handleShortcut(v, hwbuttonShortcut, repeat, down));
 
             case KeyEvent.KEYCODE_VOLUME_DOWN:
                 // check to see which shortcut the camera button triggers
                 hwbuttonShortcut = manager.prefs.getString(
-                                       PreferenceConstants.VOLDN,
-                                       PreferenceConstants.HWBUTTON_TAB);
+                                        PreferenceConstants.VOLDN,
+                                        PreferenceConstants.HWBUTTON_TAB);
                 return (handleShortcut(v, hwbuttonShortcut, repeat, down));
 
             case KeyEvent.KEYCODE_SEARCH:
                 // check to see which shortcut the search button triggers
                 hwbuttonShortcut = manager.prefs.getString(
-                                       PreferenceConstants.SEARCH,
-                                       PreferenceConstants.HWBUTTON_ESC);
+                                        PreferenceConstants.SEARCH,
+                                        PreferenceConstants.HWBUTTON_ESC);
                 return (handleShortcut(v, hwbuttonShortcut, repeat, down));
 
             case KeyEvent.KEYCODE_BUTTON_L2:
                 // check to see which shortcut the ptt button triggers
                 hwbuttonShortcut = manager.prefs.getString(
-                                       PreferenceConstants.PTT,
-                                       PreferenceConstants.HWBUTTON_MONITOR);
+                                        PreferenceConstants.PTT,
+                                        PreferenceConstants.HWBUTTON_MONITOR);
                 return (handleShortcut(v, hwbuttonShortcut, repeat, down));
 
             default: return false;
@@ -609,20 +610,28 @@
     }
 
     private boolean handleShortcut(View v, String shortcut, int repeat, boolean down) {
-        if (PreferenceConstants.HWBUTTON_FUNCTION_KEYS.equals(shortcut)) {
+        if (PreferenceConstants.HWBUTTON_DECREASE_FONTSIZE.equals(shortcut)) {
+            if (!down) return false;
+            bridge.decreaseFontSize();
+        }
+        else if (PreferenceConstants.HWBUTTON_INCREASE_FONTSIZE.equals(shortcut)) {
+            if (!down) return false;
+            bridge.increaseFontSize();
+        }
+        else if (PreferenceConstants.HWBUTTON_FUNCTION_KEYS.equals(shortcut)) {
             if (repeat > 0) return false;
             if (!down) return false;
             bridge.showFKeysDialog();
         }
+        else if (PreferenceConstants.HWBUTTON_MONITOR.equals(shortcut)) {
+            if (repeat > 0) return false;
+            buffer.monitorKey(down);
+        }
         else if (PreferenceConstants.HWBUTTON_SCREEN_CAPTURE.equals(shortcut)) {
             if (repeat > 0) return false;
             if (!down) return false;
             bridge.captureScreen();
         }
-        else if (PreferenceConstants.HWBUTTON_MONITOR.equals(shortcut)) {
-            if (repeat > 0) return false;
-            buffer.monitorKey(down);
-        }
         else if (PreferenceConstants.HWBUTTON_CTRL.equals(shortcut)) {
             if (!down) return false;
             showMetakeyToast(v, PreferenceConstants.HWBUTTON_CTRL);
--- a/src/com/five_ten_sg/connectbot/util/PreferenceConstants.java	Sun Jul 13 12:35:52 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/util/PreferenceConstants.java	Mon Jul 14 08:46:06 2014 -0700
@@ -62,6 +62,8 @@
     public static final String HWBUTTON_ESC_A = "Esc+A";
     public static final String HWBUTTON_MONITOR = "Monitor Key";
     public static final String HWBUTTON_FUNCTION_KEYS = "Soft Function Keypad";
+    public static final String HWBUTTON_INCREASE_FONTSIZE = "Increase Font Size";
+    public static final String HWBUTTON_DECREASE_FONTSIZE = "Decrease Font Size";
     public static final String HWBUTTON_NONE = "None";
 
     public static final String KEEP_ALIVE = "keepalive";