diff options
| author | 2016-02-24 20:24:11 +0000 | |
|---|---|---|
| committer | 2016-02-24 20:24:13 +0000 | |
| commit | f9935c511b38bf37dfea46731a2448abb258b145 (patch) | |
| tree | 08774a274352aacd81f6042d000bd99568c880eb | |
| parent | 84ec4fbf7b3be8bbf51c775de5dd4f4db549100f (diff) | |
| parent | e80654bf7f3fc817e93d52bea7907a260cf036a2 (diff) | |
Merge "QS Animation tweaks" into nyc-dev
5 files changed, 46 insertions, 48 deletions
diff --git a/packages/SystemUI/res/layout/qs_panel.xml b/packages/SystemUI/res/layout/qs_panel.xml index b8f10dbec87c..3ee2475ec94a 100644 --- a/packages/SystemUI/res/layout/qs_panel.xml +++ b/packages/SystemUI/res/layout/qs_panel.xml @@ -18,7 +18,9 @@ android:id="@+id/quick_settings_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/qs_background_primary"> + android:background="@drawable/qs_background_primary" + android:clipToPadding="false" + android:clipChildren="false"> <com.android.systemui.qs.QSPanel android:id="@+id/quick_settings_panel" diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java index 4cfa042cb23b..dc645914e183 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java @@ -39,6 +39,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha public static final float EXPANDED_TILE_DELAY = .7f; private final ArrayList<View> mAllViews = new ArrayList<>(); + private final ArrayList<View> mTopFiveQs = new ArrayList<>(); private final QuickQSPanel mQuickQsPanel; private final QSPanel mQsPanel; private final QSContainer mQsContainer; @@ -86,7 +87,10 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha firstPageDelayedBuilder.setStartDelay(EXPANDED_TILE_DELAY); firstPageBuilder.setListener(this); translationYBuilder.setInterpolator(TRANSLATION_Y_INTERPOLATOR); + // Fade in the tiles/labels as we reach the final position. + firstPageDelayedBuilder.addFloat(mQsPanel.getTileLayout(), "alpha", 0, 1); mAllViews.clear(); + mTopFiveQs.clear(); for (QSTile<?> tile : tiles) { QSTileBaseView tileView = mQsPanel.getTileView(tile); final TextView label = ((QSTileView) tileView).getLabel(); @@ -104,21 +108,17 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha translationYBuilder.addFloat(quickTileView, "translationY", 0, yDiff); // Counteract the parent translation on the tile. So we have a static base to - // animate off from. + // animate the label position off from. firstPageBuilder.addFloat(tileView, "translationY", mQsPanel.getHeight(), 0); - // Move the real tile's icon and label from the quick tile position to its final + // Move the real tile's label from the quick tile position to its final // location. - firstPageBuilder.addFloat(tileIcon, "translationX", -xDiff, 0); - translationYBuilder.addFloat(tileIcon, "translationY", -yDiff, 0); firstPageBuilder.addFloat(label, "translationX", -xDiff, 0); translationYBuilder.addFloat(label, "translationY", -yDiff, 0); - // Fade in the label as we reach the final position. - firstPageDelayedBuilder.addFloat(label, "alpha", 0, 1); + mTopFiveQs.add(tileIcon); + mAllViews.add(tileIcon); mAllViews.add(quickTileView); - } else { - firstPageDelayedBuilder.addFloat(tileView, "alpha", 0, 1); } mAllViews.add(tileView); mAllViews.add(label); @@ -159,17 +159,26 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha @Override public void onAnimationAtStart() { - } @Override public void onAnimationAtEnd() { mQuickQsPanel.setVisibility(View.INVISIBLE); + final int N = mTopFiveQs.size(); + for (int i = 0; i < N; i++) { + mTopFiveQs.get(i).setVisibility(View.VISIBLE); + } } @Override public void onAnimationStarted() { mQuickQsPanel.setVisibility(View.VISIBLE); + if (mOnFirstPage) { + final int N = mTopFiveQs.size(); + for (int i = 0; i < N; i++) { + mTopFiveQs.get(i).setVisibility(View.INVISIBLE); + } + } } private void clearAnimationState() { diff --git a/packages/SystemUI/src/com/android/systemui/qs/TouchAnimator.java b/packages/SystemUI/src/com/android/systemui/qs/TouchAnimator.java index b33d31df1cbd..94d8524188ee 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/TouchAnimator.java +++ b/packages/SystemUI/src/com/android/systemui/qs/TouchAnimator.java @@ -14,8 +14,6 @@ package com.android.systemui.qs; -import android.animation.Keyframe; -import android.util.Log; import android.util.MathUtils; import android.util.Property; import android.view.View; @@ -34,7 +32,6 @@ import java.util.List; public class TouchAnimator { private final Object[] mTargets; - private final Property[] mProperties; private final KeyframeSet[] mKeyframeSets; private final float mStartDelay; private final float mEndDelay; @@ -43,10 +40,9 @@ public class TouchAnimator { private final Listener mListener; private float mLastT; - private TouchAnimator(Object[] targets, Property[] properties, KeyframeSet[] keyframeSets, + private TouchAnimator(Object[] targets, KeyframeSet[] keyframeSets, float startDelay, float endDelay, Interpolator interpolator, Listener listener) { mTargets = targets; - mProperties = properties; mKeyframeSets = keyframeSets; mStartDelay = startDelay; mEndDelay = endDelay; @@ -73,8 +69,7 @@ public class TouchAnimator { mLastT = t; } for (int i = 0; i < mTargets.length; i++) { - Object value = mKeyframeSets[i].getValue(t); - mProperties[i].set(mTargets[i], value); + mKeyframeSets[i].setValue(t, mTargets[i]); } } @@ -111,7 +106,6 @@ public class TouchAnimator { public static class Builder { private List<Object> mTargets = new ArrayList<>(); - private List<Property> mProperties = new ArrayList<>(); private List<KeyframeSet> mValues = new ArrayList<>(); private float mStartDelay; @@ -120,18 +114,17 @@ public class TouchAnimator { private Listener mListener; public Builder addFloat(Object target, String property, float... values) { - add(target, property, KeyframeSet.ofFloat(values)); + add(target, KeyframeSet.ofFloat(getProperty(target, property), values)); return this; } public Builder addInt(Object target, String property, int... values) { - add(target, property, KeyframeSet.ofInt(values)); + add(target, KeyframeSet.ofInt(getProperty(target, property), values)); return this; } - private void add(Object target, String property, KeyframeSet keyframeSet) { + private void add(Object target, KeyframeSet keyframeSet) { mTargets.add(target); - mProperties.add(getProperty(target, property)); mValues.add(keyframeSet); } @@ -183,7 +176,6 @@ public class TouchAnimator { public TouchAnimator build() { return new TouchAnimator(mTargets.toArray(new Object[mTargets.size()]), - mProperties.toArray(new Property[mProperties.size()]), mValues.toArray(new KeyframeSet[mValues.size()]), mStartDelay, mEndDelay, mInterpolator, mListener); } @@ -199,54 +191,57 @@ public class TouchAnimator { mFrameWidth = 1 / (float) (size - 1); } - Object getValue(float fraction) { + void setValue(float fraction, Object target) { int i; for (i = 1; i < mSize - 1 && fraction > mFrameWidth; i++); float amount = fraction / mFrameWidth; - return interpolate(i, amount); + interpolate(i, amount, target); } - protected abstract Object interpolate(int index, float amount); + protected abstract void interpolate(int index, float amount, Object target); - public static KeyframeSet ofInt(int... values) { - return new IntKeyframeSet(values); + public static KeyframeSet ofInt(Property property, int... values) { + return new IntKeyframeSet((Property<?, Integer>) property, values); } - public static KeyframeSet ofFloat(float... values) { - return new FloatKeyframeSet(values); + public static KeyframeSet ofFloat(Property property, float... values) { + return new FloatKeyframeSet((Property<?, Float>) property, values); } } - private static class FloatKeyframeSet extends KeyframeSet { + private static class FloatKeyframeSet<T> extends KeyframeSet { private final float[] mValues; + private final Property<T, Float> mProperty; - public FloatKeyframeSet(float[] values) { + public FloatKeyframeSet(Property<T, Float> property, float[] values) { super(values.length); + mProperty = property; mValues = values; } @Override - protected Object interpolate(int index, float amount) { + protected void interpolate(int index, float amount, Object target) { float firstFloat = mValues[index - 1]; float secondFloat = mValues[index]; - return firstFloat + (secondFloat - firstFloat) * amount; + mProperty.set((T) target, firstFloat + (secondFloat - firstFloat) * amount); } } - private static class IntKeyframeSet extends KeyframeSet { - + private static class IntKeyframeSet<T> extends KeyframeSet { private final int[] mValues; + private final Property<T, Integer> mProperty; - public IntKeyframeSet(int[] values) { + public IntKeyframeSet(Property<T, Integer> property, int[] values) { super(values.length); + mProperty = property; mValues = values; } @Override - protected Object interpolate(int index, float amount) { + protected void interpolate(int index, float amount, Object target) { int firstFloat = mValues[index - 1]; int secondFloat = mValues[index]; - return (int) (firstFloat + (secondFloat - firstFloat) * amount); + mProperty.set((T) target, (int) (firstFloat + (secondFloat - firstFloat) * amount)); } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ExpandableIndicator.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ExpandableIndicator.java index 8c7c71f11159..04095e76add4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ExpandableIndicator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ExpandableIndicator.java @@ -45,6 +45,7 @@ public class ExpandableIndicator extends ImageView { final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getContext() .getDrawable(res).getConstantState().newDrawable(); setImageDrawable(avd); + avd.forceAnimationOnUI(); avd.start(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java index ab8067ddebbe..cf5531fd3eb8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java @@ -21,7 +21,6 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.res.Configuration; -import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.graphics.drawable.RippleDrawable; import android.util.AttributeSet; @@ -129,14 +128,6 @@ public class QuickStatusBarHeader extends BaseStatusBarHeader implements ((RippleDrawable) getBackground()).setForceSoftware(true); ((RippleDrawable) mSettingsButton.getBackground()).setForceSoftware(true); - addOnLayoutChangeListener(new View.OnLayoutChangeListener() { - @Override - public void onLayoutChange(View v, int left, int top, int right, - int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { - setClipBounds(new Rect(getPaddingLeft(), 0, getWidth() - getPaddingRight(), - getHeight())); - } - }); updateResources(); } |