summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonsta <konsta09@gmail.com>2012-08-20 10:39:57 +0300
committerSteve Kondik <steve@cyngn.com>2015-10-25 21:49:37 -0700
commit7565f878c20c0a262ed5b0ac83d69f385a259b8d (patch)
tree66f8586165a405ee7ffe93ab1d08ffcfc84ef866
parent47e1d1f59e1f35a9eacc99ecc7e638d7eeb860e8 (diff)
downloadframeworks_base-7565f878c20c0a262ed5b0ac83d69f385a259b8d.zip
frameworks_base-7565f878c20c0a262ed5b0ac83d69f385a259b8d.tar.gz
frameworks_base-7565f878c20c0a262ed5b0ac83d69f385a259b8d.tar.bz2
Framework: Volume key cursor control (1/2)
This feature is moved to framework so it also works with third party keyboards. Change-Id: I8e20240e7bee5351ab20bb3d701eb95a5fd3e112
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java34
-rw-r--r--core/java/android/provider/Settings.java9
2 files changed, 43 insertions, 0 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index ff7a300..5e9cd97 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -317,6 +317,11 @@ public class InputMethodService extends AbstractInputMethodService {
final Insets mTmpInsets = new Insets();
final int[] mTmpLocation = new int[2];
+ int mVolumeKeyCursorControl;
+ private static final int VOLUME_CURSOR_OFF = 0;
+ private static final int VOLUME_CURSOR_ON = 1;
+ private static final int VOLUME_CURSOR_ON_REVERSE = 2;
+
final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsComputer =
new ViewTreeObserver.OnComputeInternalInsetsListener() {
public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo info) {
@@ -1856,6 +1861,26 @@ public class InputMethodService extends AbstractInputMethodService {
}
return false;
}
+ if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP) {
+ mVolumeKeyCursorControl = Settings.System.getInt(getContentResolver(),
+ Settings.System.VOLUME_KEY_CURSOR_CONTROL, 0);
+ if (isInputViewShown() && (mVolumeKeyCursorControl != VOLUME_CURSOR_OFF)) {
+ sendDownUpKeyEvents((mVolumeKeyCursorControl == VOLUME_CURSOR_ON_REVERSE)
+ ? KeyEvent.KEYCODE_DPAD_RIGHT : KeyEvent.KEYCODE_DPAD_LEFT);
+ return true;
+ }
+ return false;
+ }
+ if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) {
+ mVolumeKeyCursorControl = Settings.System.getInt(getContentResolver(),
+ Settings.System.VOLUME_KEY_CURSOR_CONTROL, 0);
+ if (isInputViewShown() && (mVolumeKeyCursorControl != VOLUME_CURSOR_OFF)) {
+ sendDownUpKeyEvents((mVolumeKeyCursorControl == VOLUME_CURSOR_ON_REVERSE)
+ ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT);
+ return true;
+ }
+ return false;
+ }
return doMovementKey(keyCode, event, MOVEMENT_DOWN);
}
@@ -1906,6 +1931,15 @@ public class InputMethodService extends AbstractInputMethodService {
return handleBack(true);
}
}
+ if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP
+ || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
+ mVolumeKeyCursorControl = Settings.System.getInt(getContentResolver(),
+ Settings.System.VOLUME_KEY_CURSOR_CONTROL, 0);
+ if (isInputViewShown() && (mVolumeKeyCursorControl != VOLUME_CURSOR_OFF)) {
+ return true;
+ }
+ return false;
+ }
return doMovementKey(keyCode, event, MOVEMENT_UP);
}
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index e2f002b..c441038 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -3648,6 +3648,15 @@ public final class Settings {
public static final String DOUBLE_TAP_SLEEP_GESTURE = "double_tap_sleep_gesture";
/**
+ * Volume keys control cursor in text fields (default is 0)
+ * 0 - Disabled
+ * 1 - Volume up/down moves cursor left/right
+ * 2 - Volume up/down moves cursor right/left
+ * @hide
+ */
+ public static final String VOLUME_KEY_CURSOR_CONTROL = "volume_key_cursor_control";
+
+ /**
* Settings to backup. This is here so that it's in the same place as the settings
* keys and easy to update.
*