|
17 | 17 |
|
18 | 18 | package com.android.systemui; |
19 | 19 |
|
| 20 | +import android.animation.Animator; |
| 21 | +import android.animation.AnimatorListenerAdapter; |
20 | 22 | import android.animation.AnimatorSet; |
21 | 23 | import android.animation.ObjectAnimator; |
22 | 24 | import android.content.Context; |
23 | | -import android.graphics.RectF; |
24 | 25 | import android.util.Log; |
25 | 26 | import android.view.MotionEvent; |
26 | 27 | import android.view.ScaleGestureDetector; |
27 | 28 | import android.view.View; |
28 | 29 | import android.view.ViewGroup; |
29 | 30 | import android.view.View.OnClickListener; |
30 | | -import com.android.internal.widget.SizeAdaptiveLayout; |
31 | 31 |
|
32 | 32 | public class ExpandHelper implements Gefingerpoken, OnClickListener { |
33 | 33 | public interface Callback { |
@@ -130,8 +130,28 @@ public ExpandHelper(Context context, Callback callback, int small, int large) { |
130 | 130 | mScaleAnimation = ObjectAnimator.ofFloat(mScaler, "height", 0f); |
131 | 131 | mScaleAnimation.setDuration(EXPAND_DURATION); |
132 | 132 |
|
| 133 | + AnimatorListenerAdapter glowVisibilityController = new AnimatorListenerAdapter() { |
| 134 | + @Override |
| 135 | + public void onAnimationStart(Animator animation) { |
| 136 | + View target = (View) ((ObjectAnimator) animation).getTarget(); |
| 137 | + if (target.getAlpha() <= 0.0f) { |
| 138 | + target.setVisibility(View.VISIBLE); |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + @Override |
| 143 | + public void onAnimationEnd(Animator animation) { |
| 144 | + View target = (View) ((ObjectAnimator) animation).getTarget(); |
| 145 | + if (target.getAlpha() <= 0.0f) { |
| 146 | + target.setVisibility(View.INVISIBLE); |
| 147 | + } |
| 148 | + } |
| 149 | + }; |
| 150 | + |
133 | 151 | mGlowTopAnimation = ObjectAnimator.ofFloat(null, "alpha", 0f); |
| 152 | + mGlowTopAnimation.addListener(glowVisibilityController); |
134 | 153 | mGlowBottomAnimation = ObjectAnimator.ofFloat(null, "alpha", 0f); |
| 154 | + mGlowBottomAnimation.addListener(glowVisibilityController); |
135 | 155 | mGlowAnimationSet = new AnimatorSet(); |
136 | 156 | mGlowAnimationSet.play(mGlowTopAnimation).with(mGlowBottomAnimation); |
137 | 157 | mGlowAnimationSet.setDuration(GLOW_DURATION); |
@@ -225,10 +245,19 @@ public void setGlow(float glow) { |
225 | 245 | // set it explicitly in reponse to touches. |
226 | 246 | mCurrViewTopGlow.setAlpha(glow); |
227 | 247 | mCurrViewBottomGlow.setAlpha(glow); |
| 248 | + handleGlowVisibility(); |
228 | 249 | } |
229 | 250 | } |
230 | 251 | } |
231 | 252 | } |
| 253 | + |
| 254 | + private void handleGlowVisibility() { |
| 255 | + mCurrViewTopGlow.setVisibility(mCurrViewTopGlow.getAlpha() <= 0.0f ? |
| 256 | + View.INVISIBLE : View.VISIBLE); |
| 257 | + mCurrViewBottomGlow.setVisibility(mCurrViewBottomGlow.getAlpha() <= 0.0f ? |
| 258 | + View.INVISIBLE : View.VISIBLE); |
| 259 | + } |
| 260 | + |
232 | 261 | public boolean onInterceptTouchEvent(MotionEvent ev) { |
233 | 262 | if (DEBUG) Log.d(TAG, "interceptTouch: act=" + (ev.getAction()) + |
234 | 263 | " stretching=" + mStretching); |
|
0 commit comments