summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Lee <llee@cyngn.com>2015-08-11 14:26:46 -0700
committerLinus Lee <llee@cyngn.com>2015-08-11 16:24:41 -0700
commitb073b4937d3cd30ce0ff48d34ce68a9995baf3b6 (patch)
tree9bd4a7080f76bf8a6d8c309b52f30dc8a5485341
parente5673a5842f9ec36c878bcc76e363dd8fa9ea630 (diff)
downloadandroid_packages_apps_Trebuchet-b073b4937d3cd30ce0ff48d34ce68a9995baf3b6.tar.gz
android_packages_apps_Trebuchet-b073b4937d3cd30ce0ff48d34ce68a9995baf3b6.tar.bz2
android_packages_apps_Trebuchet-b073b4937d3cd30ce0ff48d34ce68a9995baf3b6.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 (cherry picked from commit 4319d899e32d7fb4c385c4ac5f9b7d61a0a873e0)
-rw-r--r--src/com/android/launcher3/FocusIndicatorView.java55
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) {