summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorezio84 <brabus84@gmail.com>2018-06-07 15:45:47 +0200
committerezio84 <brabus84@gmail.com>2018-06-07 15:48:52 +0200
commitedfa500da30bfe5e72819f7e304ef05417294a58 (patch)
tree43fc91d081b0f53b8e21369d5cab00c39c91b08d
parentd0a4c87e456b950f324ef540c6257d4368d84b83 (diff)
Smartbar: keep pressing on ime arrows to move kb cursor
like we did for Fling
-rw-r--r--src/com/android/systemui/navigation/smartbar/SmartButtonView.java41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/com/android/systemui/navigation/smartbar/SmartButtonView.java b/src/com/android/systemui/navigation/smartbar/SmartButtonView.java
index ecabaf9..df35b45 100644
--- a/src/com/android/systemui/navigation/smartbar/SmartButtonView.java
+++ b/src/com/android/systemui/navigation/smartbar/SmartButtonView.java
@@ -31,6 +31,8 @@ import android.app.ActivityManager;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
+import android.os.Handler;
+import android.os.Looper;
import android.text.TextUtils;
import android.util.AttributeSet;
//import android.content.res.ThemeConfig;
@@ -217,6 +219,16 @@ public class SmartButtonView extends ImageView {
return mConfig != null && mConfig.getActionConfig(ActionConfig.THIRD).isActionRecents();
}
+ private boolean isImeLeftArrowButton() {
+ final String action = mConfig.getActionConfig(ActionConfig.PRIMARY).getAction();
+ return "task_ime_navigation_left".equals(action);
+ }
+
+ private boolean isImeRightArrowButton() {
+ final String action = mConfig.getActionConfig(ActionConfig.PRIMARY).getAction();
+ return "task_ime_navigation_right".equals(action);
+ }
+
public ButtonConfig getButtonConfig() {
return mConfig;
}
@@ -254,8 +266,10 @@ public class SmartButtonView extends ImageView {
if (mInEditMode) {
return false;
}
- final int action = ev.getAction();
+ final int action = ev.getAction();
+ boolean imeLeft = mConfig != null && isImeLeftArrowButton();
+ boolean imeRight = mConfig != null && isImeRightArrowButton();
switch (action) {
case MotionEvent.ACTION_DOWN:
setPressed(true);
@@ -265,7 +279,9 @@ public class SmartButtonView extends ImageView {
checkAndDoFlipAnim();
performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
playSoundEffect(SoundEffectConstants.CLICK);
- if (isDoubleTapPending) {
+ if (imeLeft || imeRight) {
+ moveKbCursor(imeRight, true);
+ } else if (isDoubleTapPending) {
isDoubleTapPending = false;
wasConsumed = true;
removeCallbacks(mDoubleTapTimeout);
@@ -288,7 +304,7 @@ public class SmartButtonView extends ImageView {
removeCallbacks(mDoubleTapTimeout);
wasConsumed = true;
isDoubleTapPending = false;
- setPressed(false);
+ setPressed(false); // this will stop also the ime arrows handler
if (opa != null) {
opa.startCancelAction();
}
@@ -310,7 +326,7 @@ public class SmartButtonView extends ImageView {
isDoubleTapPending = true;
postDelayed(mDoubleTapTimeout, sDoubleTapTimeout);
} else {
- if (!wasConsumed && hasSingleAction()) {
+ if (!imeLeft && !imeRight && !wasConsumed && hasSingleAction()) {
doSinglePress();
}
}
@@ -319,6 +335,23 @@ public class SmartButtonView extends ImageView {
return true;
}
+ private void moveKbCursor(boolean right, boolean firstTrigger) {
+ ActionHandler.performTask(mContext, right ? ActionHandler.SYSTEMUI_TASK_IME_NAVIGATION_RIGHT
+ : ActionHandler.SYSTEMUI_TASK_IME_NAVIGATION_LEFT);
+ final Handler handler = new Handler(Looper.getMainLooper());
+ final Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ if (isPressed()) {
+ moveKbCursor(right, false);
+ }
+ }
+ };
+ if (isPressed()) {
+ handler.postDelayed(r, firstTrigger ? 500 : 250);
+ }
+ }
+
private void doSinglePress() {
isDoubleTapPending = false;
if (mConfig != null) {