diff options
author | Linus Lee <llee@cyngn.com> | 2015-08-11 14:26:46 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2015-08-11 16:21:53 -0700 |
commit | 4319d899e32d7fb4c385c4ac5f9b7d61a0a873e0 (patch) | |
tree | 6027738b1b8ec585c66927953539aa911380d1be /src | |
parent | ba2f9eb8801e5517f8b6d1c52cf300ca0202e933 (diff) | |
download | android_packages_apps_Trebuchet-4319d899e32d7fb4c385c4ac5f9b7d61a0a873e0.tar.gz android_packages_apps_Trebuchet-4319d899e32d7fb4c385c4ac5f9b7d61a0a873e0.tar.bz2 android_packages_apps_Trebuchet-4319d899e32d7fb4c385c4ac5f9b7d61a0a873e0.zip |
Trebuchet: Make focus animate and move faster
If you use a keyboard and hold the tab key, the focus
animation looks weird. The fix is when we focus to a new item,
jump to the item being focused out and animate from there as
opposed to animating from where the focus is currently is
ref: QRDL-978
Change-Id: I007c7566b6524dbbf748475e98ad53f9c3cbbcf5
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/FocusIndicatorView.java | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/src/com/android/launcher3/FocusIndicatorView.java b/src/com/android/launcher3/FocusIndicatorView.java index 12b7a4076..8ccef9387 100644 --- a/src/com/android/launcher3/FocusIndicatorView.java +++ b/src/com/android/launcher3/FocusIndicatorView.java @@ -79,39 +79,46 @@ public class FocusIndicatorView extends View implements View.OnFocusChangeListen } if (hasFocus) { - int indicatorWidth = getWidth(); - int indicatorHeight = getHeight(); - - float scaleX = v.getScaleX() * v.getWidth() / indicatorWidth; - float scaleY = v.getScaleY() * v.getHeight() / indicatorHeight; - - getLocationRelativeToParentPagedView(v, mTargetViewPos); - float x = mTargetViewPos[0] - mIndicatorPos[0] - (1 - scaleX) * indicatorWidth / 2; - float y = mTargetViewPos[1] - mIndicatorPos[1] - (1 - scaleY) * indicatorHeight / 2; - - if (getAlpha() > MIN_VISIBLE_ALPHA) { - animate() - .translationX(x) - .translationY(y) - .scaleX(scaleX) - .scaleY(scaleY) - .alpha(1); - } else { - setTranslationX(x); - setTranslationY(y); - setScaleX(scaleX); - setScaleY(scaleY); - animate().alpha(1); - } + setViewAnimation(getAlpha() > MIN_VISIBLE_ALPHA, v); mLastFocusedView = v; } else { if (mLastFocusedView == v) { mLastFocusedView = null; + // force the translation to the target position + setViewAnimation(false, v); animate().alpha(0); } } } + private void setViewAnimation(boolean animate, View v) { + int indicatorWidth = getWidth(); + int indicatorHeight = getHeight(); + + float scaleX = v.getScaleX() * v.getWidth() / indicatorWidth; + float scaleY = v.getScaleY() * v.getHeight() / indicatorHeight; + + getLocationRelativeToParentPagedView(v, mTargetViewPos); + float x = mTargetViewPos[0] - mIndicatorPos[0] - (1 - scaleX) * indicatorWidth / 2; + float y = mTargetViewPos[1] - mIndicatorPos[1] - (1 - scaleY) * indicatorHeight / 2; + + if (animate) { + animate() + .translationX(x) + .translationY(y) + .scaleX(scaleX) + .scaleY(scaleY) + .alpha(1) + .setDuration(100); + } else { + setTranslationX(x); + setTranslationY(y); + setScaleX(scaleX); + setScaleY(scaleY); + animate().alpha(1); + } + } + @Override protected void onDraw(Canvas canvas) { if (mPendingCall != null) { |