From 0a42892d2d3060476db0d32ee25ee179c85ec518 Mon Sep 17 00:00:00 2001 From: Yuriy Liskov Date: Mon, 17 Sep 2018 01:59:05 +0300 Subject: [PATCH] mouse pointer animation fix --- leankeykeyboard/build.gradle | 4 +-- .../ime/LeanbackKeyboardContainer.java | 11 ++++++- .../ime/LeanbackKeyboardController.java | 32 +++++++++---------- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/leankeykeyboard/build.gradle b/leankeykeyboard/build.gradle index f5f54f8..f20b4de 100644 --- a/leankeykeyboard/build.gradle +++ b/leankeykeyboard/build.gradle @@ -8,8 +8,8 @@ android { applicationId "org.liskovsoft.leankeykeyboard.pro" minSdkVersion project.properties.minSdkVersion targetSdkVersion project.properties.targetSdkVersion - versionCode 77 - versionName "4.3.27" + versionCode 78 + versionName "4.3.28" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardContainer.java b/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardContainer.java index cc0bc60..679ecc0 100644 --- a/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardContainer.java +++ b/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardContainer.java @@ -594,7 +594,12 @@ public class LeanbackKeyboardContainer { mSelector.setX(translatedX); mSelector.setY(translatedY); } else { - mSelector.animate().x(translatedX).y(translatedY).setInterpolator(sMovementInterpolator).setDuration(MOVEMENT_ANIMATION_DURATION).start(); + mSelector.animate() + .x(translatedX) + .y(translatedY) + .setInterpolator(sMovementInterpolator) + .setDuration(MOVEMENT_ANIMATION_DURATION) + .start(); } } @@ -1031,6 +1036,10 @@ public class LeanbackKeyboardContainer { setKbFocus(focus, false, true); } + public void setFocus(LeanbackKeyboardContainer.KeyFocus focus, final boolean animate) { + setKbFocus(focus, false, animate); + } + public void setSelectorToFocus(Rect rect, boolean overestimateWidth, boolean overestimateHeight, boolean animate) { if (this.mSelector.getWidth() != 0 && this.mSelector.getHeight() != 0 && rect.width() != 0 && rect.height() != 0) { final float width = (float) rect.width(); diff --git a/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardController.java b/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardController.java index b203ee5..e7262a3 100644 --- a/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardController.java +++ b/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardController.java @@ -540,13 +540,10 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi } private void moveSelectorToPoint(float x, float y) { - LeanbackKeyboardContainer container = this.mContainer; - LeanbackKeyboardContainer.KeyFocus focus = this.mTempFocus; - container.getBestFocus(new Float(x), new Float(y), focus); - this.mContainer.setFocus(this.mTempFocus); - container = this.mContainer; - Rect rect = this.mTempFocus.rect; - container.alignSelector((float) rect.centerX(), (float) rect.centerY(), false); + LeanbackKeyboardContainer container = mContainer; + LeanbackKeyboardContainer.KeyFocus focus = mTempFocus; + container.getBestFocus(x, y, focus); + mContainer.setFocus(mTempFocus, false); } private boolean onDirectionalMove(int dir) { @@ -634,21 +631,24 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi } /** - * Try to handle on hover event + * Control keyboard from the mouse. Movement catching * @param view active view * @param event event object * @return is hover handled */ + @Override public boolean onHover(View view, MotionEvent event) { - boolean allowed = isCallAllowed(300); - if (allowed) { - if (event.getAction() == MotionEvent.ACTION_HOVER_MOVE) { - PointF pos = getRelativePosition(mContainer.getView(), event); - moveSelectorToPoint(pos.x, pos.y); - } - } + return false; - return allowed; + //boolean allowed = isCallAllowed(300); + //if (allowed) { + // if (event.getAction() == MotionEvent.ACTION_HOVER_MOVE) { + // PointF pos = getRelativePosition(mContainer.getView(), event); + // moveSelectorToPoint(pos.x, pos.y); + // } + //} + // + //return allowed; } /**