Kenny Root | 15a4d2f | 2010-03-11 18:20:12 -0800 | [diff] [blame] | 1 | /* |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 2 | * Copyright (C) 2014 The Android Open Source Project |
Kenny Root | 15a4d2f | 2010-03-11 18:20:12 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 14 | * limitations under the License |
Kenny Root | 15a4d2f | 2010-03-11 18:20:12 -0800 | [diff] [blame] | 15 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 16 | |
Joe Onorato | 79de0c5 | 2010-05-26 17:03:26 -0400 | [diff] [blame] | 17 | package com.android.systemui.statusbar; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 19 | import android.animation.Animator; |
| 20 | import android.animation.AnimatorListenerAdapter; |
| 21 | import android.animation.ObjectAnimator; |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 22 | import android.animation.TimeAnimator; |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 23 | import android.animation.ValueAnimator; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | import android.content.Context; |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 25 | import android.graphics.Canvas; |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 26 | import android.graphics.RectF; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.util.AttributeSet; |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 28 | import android.view.MotionEvent; |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 29 | import android.view.View; |
ztenghui | 62f30e0 | 2014-06-05 09:55:04 -0700 | [diff] [blame] | 30 | import android.view.ViewAnimationUtils; |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 31 | import android.view.ViewConfiguration; |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 32 | import android.view.animation.Interpolator; |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 33 | import android.view.animation.PathInterpolator; |
ztenghui | 62f30e0 | 2014-06-05 09:55:04 -0700 | [diff] [blame] | 34 | |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 35 | import com.android.systemui.Interpolators; |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 36 | import com.android.systemui.R; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 37 | import com.android.systemui.classifier.FalsingManager; |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 38 | import com.android.systemui.statusbar.notification.FakeShadowView; |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 39 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; |
Jorim Jaggi | 4673985 | 2014-04-15 09:58:24 +0200 | [diff] [blame] | 40 | |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 41 | /** |
| 42 | * Base class for both {@link ExpandableNotificationRow} and {@link NotificationOverflowContainer} |
| 43 | * to implement dimming/activating on Keyguard for the double-tap gesture |
| 44 | */ |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 45 | public abstract class ActivatableNotificationView extends ExpandableOutlineView { |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 46 | |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 47 | private static final long DOUBLETAP_TIMEOUT_MS = 1200; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 48 | private static final int BACKGROUND_ANIMATION_LENGTH_MS = 220; |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 49 | private static final int ACTIVATE_ANIMATION_LENGTH = 220; |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 50 | private static final int DARK_ANIMATION_LENGTH = 170; |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 51 | |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 52 | /** |
| 53 | * The amount of width, which is kept in the end when performing a disappear animation (also |
| 54 | * the amount from which the horizontal appearing begins) |
| 55 | */ |
| 56 | private static final float HORIZONTAL_COLLAPSED_REST_PARTIAL = 0.05f; |
| 57 | |
| 58 | /** |
| 59 | * At which point from [0,1] does the horizontal collapse animation end (or start when |
| 60 | * expanding)? 1.0 meaning that it ends immediately and 0.0 that it is continuously animated. |
| 61 | */ |
| 62 | private static final float HORIZONTAL_ANIMATION_END = 0.2f; |
| 63 | |
| 64 | /** |
| 65 | * At which point from [0,1] does the alpha animation end (or start when |
| 66 | * expanding)? 1.0 meaning that it ends immediately and 0.0 that it is continuously animated. |
| 67 | */ |
| 68 | private static final float ALPHA_ANIMATION_END = 0.0f; |
| 69 | |
| 70 | /** |
| 71 | * At which point from [0,1] does the horizontal collapse animation start (or start when |
| 72 | * expanding)? 1.0 meaning that it starts immediately and 0.0 that it is animated at all. |
| 73 | */ |
| 74 | private static final float HORIZONTAL_ANIMATION_START = 1.0f; |
| 75 | |
| 76 | /** |
| 77 | * At which point from [0,1] does the vertical collapse animation start (or end when |
| 78 | * expanding) 1.0 meaning that it starts immediately and 0.0 that it is animated at all. |
| 79 | */ |
| 80 | private static final float VERTICAL_ANIMATION_START = 1.0f; |
| 81 | |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 82 | /** |
| 83 | * Scale for the background to animate from when exiting dark mode. |
| 84 | */ |
| 85 | private static final float DARK_EXIT_SCALE_START = 0.93f; |
| 86 | |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 87 | private static final Interpolator ACTIVATE_INVERSE_INTERPOLATOR |
| 88 | = new PathInterpolator(0.6f, 0, 0.5f, 1); |
| 89 | private static final Interpolator ACTIVATE_INVERSE_ALPHA_INTERPOLATOR |
| 90 | = new PathInterpolator(0, 0, 0.5f, 1); |
Selim Cinek | b2da91b | 2014-09-02 17:35:20 +0200 | [diff] [blame] | 91 | private final int mTintedRippleColor; |
| 92 | private final int mLowPriorityRippleColor; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 93 | protected final int mNormalRippleColor; |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 94 | |
| 95 | private boolean mDimmed; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 96 | private boolean mDark; |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 97 | |
Dan Sandler | fe266a3 | 2014-05-15 22:28:06 -0400 | [diff] [blame] | 98 | private int mBgTint = 0; |
Dan Sandler | fe266a3 | 2014-05-15 22:28:06 -0400 | [diff] [blame] | 99 | |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 100 | /** |
| 101 | * Flag to indicate that the notification has been touched once and the second touch will |
| 102 | * click it. |
| 103 | */ |
| 104 | private boolean mActivated; |
| 105 | |
| 106 | private float mDownX; |
| 107 | private float mDownY; |
| 108 | private final float mTouchSlop; |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 109 | |
| 110 | private OnActivatedListener mOnActivatedListener; |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 111 | |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 112 | private final Interpolator mSlowOutFastInInterpolator; |
| 113 | private final Interpolator mSlowOutLinearInInterpolator; |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 114 | private Interpolator mCurrentAppearInterpolator; |
| 115 | private Interpolator mCurrentAlphaInterpolator; |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 116 | |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 117 | private NotificationBackgroundView mBackgroundNormal; |
| 118 | private NotificationBackgroundView mBackgroundDimmed; |
| 119 | private ObjectAnimator mBackgroundAnimator; |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 120 | private RectF mAppearAnimationRect = new RectF(); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 121 | private float mAnimationTranslationY; |
| 122 | private boolean mDrawingAppearAnimation; |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 123 | private ValueAnimator mAppearAnimator; |
| 124 | private float mAppearAnimationFraction = -1.0f; |
| 125 | private float mAppearAnimationTranslation; |
Selim Cinek | 697178b | 2014-07-02 19:40:30 +0200 | [diff] [blame] | 126 | private boolean mShowingLegacyBackground; |
| 127 | private final int mLegacyColor; |
| 128 | private final int mNormalColor; |
Selim Cinek | 3d2b94bf | 2014-07-02 22:12:47 +0200 | [diff] [blame] | 129 | private final int mLowPriorityColor; |
| 130 | private boolean mIsBelowSpeedBump; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 131 | private FalsingManager mFalsingManager; |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 132 | private boolean mTrackTouch; |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 133 | |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 134 | private float mNormalBackgroundVisibilityAmount; |
| 135 | private ValueAnimator mFadeInFromDarkAnimator; |
| 136 | private ValueAnimator.AnimatorUpdateListener mBackgroundVisibilityUpdater |
| 137 | = new ValueAnimator.AnimatorUpdateListener() { |
| 138 | @Override |
| 139 | public void onAnimationUpdate(ValueAnimator animation) { |
| 140 | setNormalBackgroundVisibilityAmount(mBackgroundNormal.getAlpha()); |
| 141 | } |
| 142 | }; |
| 143 | private AnimatorListenerAdapter mFadeInEndListener = new AnimatorListenerAdapter() { |
| 144 | @Override |
| 145 | public void onAnimationEnd(Animator animation) { |
| 146 | super.onAnimationEnd(animation); |
| 147 | mFadeInFromDarkAnimator = null; |
| 148 | updateOutlineAlpha(); |
| 149 | } |
| 150 | }; |
| 151 | private ValueAnimator.AnimatorUpdateListener mUpdateOutlineListener |
| 152 | = new ValueAnimator.AnimatorUpdateListener() { |
| 153 | @Override |
| 154 | public void onAnimationUpdate(ValueAnimator animation) { |
| 155 | updateOutlineAlpha(); |
| 156 | } |
| 157 | }; |
Selim Cinek | 277a8aa | 2016-01-22 12:12:37 -0800 | [diff] [blame] | 158 | private float mShadowAlpha = 1.0f; |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 159 | private FakeShadowView mFakeShadow; |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 160 | |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 161 | public ActivatableNotificationView(Context context, AttributeSet attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 162 | super(context, attrs); |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 163 | mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 164 | mSlowOutFastInInterpolator = new PathInterpolator(0.8f, 0.0f, 0.6f, 1.0f); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 165 | mSlowOutLinearInInterpolator = new PathInterpolator(0.8f, 0.0f, 1.0f, 1.0f); |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 166 | setClipChildren(false); |
| 167 | setClipToPadding(false); |
Alan Viverette | 4a357cd | 2015-03-18 18:37:18 -0700 | [diff] [blame] | 168 | mLegacyColor = context.getColor(R.color.notification_legacy_background_color); |
| 169 | mNormalColor = context.getColor(R.color.notification_material_background_color); |
| 170 | mLowPriorityColor = context.getColor( |
Selim Cinek | 3d2b94bf | 2014-07-02 22:12:47 +0200 | [diff] [blame] | 171 | R.color.notification_material_background_low_priority_color); |
Alan Viverette | 4a357cd | 2015-03-18 18:37:18 -0700 | [diff] [blame] | 172 | mTintedRippleColor = context.getColor( |
Selim Cinek | b2da91b | 2014-09-02 17:35:20 +0200 | [diff] [blame] | 173 | R.color.notification_ripple_tinted_color); |
Alan Viverette | 4a357cd | 2015-03-18 18:37:18 -0700 | [diff] [blame] | 174 | mLowPriorityRippleColor = context.getColor( |
Selim Cinek | b2da91b | 2014-09-02 17:35:20 +0200 | [diff] [blame] | 175 | R.color.notification_ripple_color_low_priority); |
Alan Viverette | 4a357cd | 2015-03-18 18:37:18 -0700 | [diff] [blame] | 176 | mNormalRippleColor = context.getColor( |
Selim Cinek | b2da91b | 2014-09-02 17:35:20 +0200 | [diff] [blame] | 177 | R.color.notification_ripple_untinted_color); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 178 | mFalsingManager = FalsingManager.getInstance(context); |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | @Override |
| 182 | protected void onFinishInflate() { |
| 183 | super.onFinishInflate(); |
| 184 | mBackgroundNormal = (NotificationBackgroundView) findViewById(R.id.backgroundNormal); |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 185 | mFakeShadow = (FakeShadowView) findViewById(R.id.fake_shadow); |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 186 | mBackgroundDimmed = (NotificationBackgroundView) findViewById(R.id.backgroundDimmed); |
Selim Cinek | 697178b | 2014-07-02 19:40:30 +0200 | [diff] [blame] | 187 | mBackgroundNormal.setCustomBackground(R.drawable.notification_material_bg); |
| 188 | mBackgroundDimmed.setCustomBackground(R.drawable.notification_material_bg_dim); |
Adrian Roos | bcbb75a | 2014-05-27 16:38:11 +0200 | [diff] [blame] | 189 | updateBackground(); |
Selim Cinek | 697178b | 2014-07-02 19:40:30 +0200 | [diff] [blame] | 190 | updateBackgroundTint(); |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 191 | updateOutlineAlpha(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 192 | } |
| 193 | |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 194 | private final Runnable mTapTimeoutRunnable = new Runnable() { |
| 195 | @Override |
| 196 | public void run() { |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 197 | makeInactive(true /* animate */); |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 198 | } |
| 199 | }; |
| 200 | |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 201 | @Override |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 202 | public boolean onInterceptTouchEvent(MotionEvent ev) { |
| 203 | if (mDimmed && !mActivated |
| 204 | && ev.getActionMasked() == MotionEvent.ACTION_DOWN && disallowSingleClick(ev)) { |
| 205 | return true; |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 206 | } |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 207 | return super.onInterceptTouchEvent(ev); |
| 208 | } |
| 209 | |
| 210 | protected boolean disallowSingleClick(MotionEvent ev) { |
| 211 | return false; |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 212 | } |
| 213 | |
Mady Mellor | f062580 | 2016-02-11 18:03:48 -0800 | [diff] [blame] | 214 | protected boolean handleSlideBack() { |
| 215 | return false; |
| 216 | } |
| 217 | |
Selim Cinek | 697178b | 2014-07-02 19:40:30 +0200 | [diff] [blame] | 218 | @Override |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 219 | public boolean onTouchEvent(MotionEvent event) { |
| 220 | boolean result; |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 221 | if (mDimmed) { |
| 222 | boolean wasActivated = mActivated; |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 223 | result = handleTouchEventDimmed(event); |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 224 | if (wasActivated && result && event.getAction() == MotionEvent.ACTION_UP) { |
| 225 | mFalsingManager.onNotificationDoubleTap(); |
| 226 | removeCallbacks(mTapTimeoutRunnable); |
| 227 | } |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 228 | } else { |
| 229 | result = super.onTouchEvent(event); |
| 230 | } |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 231 | return result; |
| 232 | } |
| 233 | |
| 234 | @Override |
Selim Cinek | 697178b | 2014-07-02 19:40:30 +0200 | [diff] [blame] | 235 | public void drawableHotspotChanged(float x, float y) { |
| 236 | if (!mDimmed){ |
| 237 | mBackgroundNormal.drawableHotspotChanged(x, y); |
| 238 | } |
| 239 | } |
| 240 | |
Selim Cinek | b2da91b | 2014-09-02 17:35:20 +0200 | [diff] [blame] | 241 | @Override |
| 242 | protected void drawableStateChanged() { |
| 243 | super.drawableStateChanged(); |
| 244 | if (mDimmed) { |
| 245 | mBackgroundDimmed.setState(getDrawableState()); |
| 246 | } else { |
| 247 | mBackgroundNormal.setState(getDrawableState()); |
| 248 | } |
| 249 | } |
| 250 | |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 251 | private boolean handleTouchEventDimmed(MotionEvent event) { |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 252 | int action = event.getActionMasked(); |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 253 | switch (action) { |
| 254 | case MotionEvent.ACTION_DOWN: |
| 255 | mDownX = event.getX(); |
| 256 | mDownY = event.getY(); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 257 | mTrackTouch = true; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 258 | if (mDownY > getActualHeight()) { |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 259 | mTrackTouch = false; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 260 | } |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 261 | break; |
| 262 | case MotionEvent.ACTION_MOVE: |
| 263 | if (!isWithinTouchSlop(event)) { |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 264 | makeInactive(true /* animate */); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 265 | mTrackTouch = false; |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 266 | } |
| 267 | break; |
| 268 | case MotionEvent.ACTION_UP: |
| 269 | if (isWithinTouchSlop(event)) { |
Mady Mellor | f062580 | 2016-02-11 18:03:48 -0800 | [diff] [blame] | 270 | if (handleSlideBack()) { |
| 271 | return true; |
| 272 | } |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 273 | if (!mActivated) { |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 274 | makeActive(); |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 275 | postDelayed(mTapTimeoutRunnable, DOUBLETAP_TIMEOUT_MS); |
| 276 | } else { |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 277 | if (!performClick()) { |
| 278 | return false; |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 279 | } |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 280 | } |
| 281 | } else { |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 282 | makeInactive(true /* animate */); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 283 | mTrackTouch = false; |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 284 | } |
| 285 | break; |
| 286 | case MotionEvent.ACTION_CANCEL: |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 287 | makeInactive(true /* animate */); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 288 | mTrackTouch = false; |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 289 | break; |
| 290 | default: |
| 291 | break; |
| 292 | } |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 293 | return mTrackTouch; |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 294 | } |
| 295 | |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 296 | private void makeActive() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 297 | mFalsingManager.onNotificationActive(); |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 298 | startActivateAnimation(false /* reverse */); |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 299 | mActivated = true; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 300 | if (mOnActivatedListener != null) { |
| 301 | mOnActivatedListener.onActivated(this); |
| 302 | } |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 303 | } |
| 304 | |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 305 | private void startActivateAnimation(final boolean reverse) { |
Selim Cinek | f4d7fc3 | 2014-09-26 17:15:34 +0200 | [diff] [blame] | 306 | if (!isAttachedToWindow()) { |
| 307 | return; |
| 308 | } |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 309 | int widthHalf = mBackgroundNormal.getWidth()/2; |
| 310 | int heightHalf = mBackgroundNormal.getActualHeight()/2; |
| 311 | float radius = (float) Math.sqrt(widthHalf*widthHalf + heightHalf*heightHalf); |
Selim Cinek | 6aaf217 | 2014-08-25 19:29:49 +0200 | [diff] [blame] | 312 | Animator animator; |
| 313 | if (reverse) { |
| 314 | animator = ViewAnimationUtils.createCircularReveal(mBackgroundNormal, |
| 315 | widthHalf, heightHalf, radius, 0); |
| 316 | } else { |
| 317 | animator = ViewAnimationUtils.createCircularReveal(mBackgroundNormal, |
| 318 | widthHalf, heightHalf, 0, radius); |
| 319 | } |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 320 | mBackgroundNormal.setVisibility(View.VISIBLE); |
| 321 | Interpolator interpolator; |
| 322 | Interpolator alphaInterpolator; |
| 323 | if (!reverse) { |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 324 | interpolator = Interpolators.LINEAR_OUT_SLOW_IN; |
| 325 | alphaInterpolator = Interpolators.LINEAR_OUT_SLOW_IN; |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 326 | } else { |
| 327 | interpolator = ACTIVATE_INVERSE_INTERPOLATOR; |
| 328 | alphaInterpolator = ACTIVATE_INVERSE_ALPHA_INTERPOLATOR; |
| 329 | } |
| 330 | animator.setInterpolator(interpolator); |
| 331 | animator.setDuration(ACTIVATE_ANIMATION_LENGTH); |
| 332 | if (reverse) { |
| 333 | mBackgroundNormal.setAlpha(1f); |
| 334 | animator.addListener(new AnimatorListenerAdapter() { |
| 335 | @Override |
| 336 | public void onAnimationEnd(Animator animation) { |
Selim Cinek | 23e6acb | 2014-08-12 16:01:41 +0200 | [diff] [blame] | 337 | if (mDimmed) { |
| 338 | mBackgroundNormal.setVisibility(View.INVISIBLE); |
| 339 | } |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 340 | } |
| 341 | }); |
Selim Cinek | 6aaf217 | 2014-08-25 19:29:49 +0200 | [diff] [blame] | 342 | animator.start(); |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 343 | } else { |
| 344 | mBackgroundNormal.setAlpha(0.4f); |
| 345 | animator.start(); |
| 346 | } |
| 347 | mBackgroundNormal.animate() |
| 348 | .alpha(reverse ? 0f : 1f) |
| 349 | .setInterpolator(alphaInterpolator) |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 350 | .setUpdateListener(new ValueAnimator.AnimatorUpdateListener() { |
| 351 | @Override |
| 352 | public void onAnimationUpdate(ValueAnimator animation) { |
| 353 | float animatedFraction = animation.getAnimatedFraction(); |
| 354 | if (reverse) { |
| 355 | animatedFraction = 1.0f - animatedFraction; |
| 356 | } |
| 357 | setNormalBackgroundVisibilityAmount(animatedFraction); |
| 358 | } |
| 359 | }) |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 360 | .setDuration(ACTIVATE_ANIMATION_LENGTH); |
| 361 | } |
| 362 | |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 363 | /** |
| 364 | * Cancels the hotspot and makes the notification inactive. |
| 365 | */ |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 366 | public void makeInactive(boolean animate) { |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 367 | if (mActivated) { |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 368 | if (mDimmed) { |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 369 | if (animate) { |
| 370 | startActivateAnimation(true /* reverse */); |
| 371 | } else { |
| 372 | mBackgroundNormal.setVisibility(View.INVISIBLE); |
| 373 | } |
Jorim Jaggi | bccb912 | 2014-05-08 14:55:48 +0200 | [diff] [blame] | 374 | } |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 375 | mActivated = false; |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 376 | } |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 377 | if (mOnActivatedListener != null) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 378 | mOnActivatedListener.onActivationReset(this); |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 379 | } |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 380 | removeCallbacks(mTapTimeoutRunnable); |
| 381 | } |
| 382 | |
| 383 | private boolean isWithinTouchSlop(MotionEvent event) { |
| 384 | return Math.abs(event.getX() - mDownX) < mTouchSlop |
| 385 | && Math.abs(event.getY() - mDownY) < mTouchSlop; |
| 386 | } |
| 387 | |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 388 | public void setDimmed(boolean dimmed, boolean fade) { |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 389 | if (mDimmed != dimmed) { |
| 390 | mDimmed = dimmed; |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 391 | if (fade) { |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 392 | fadeDimmedBackground(); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 393 | } else { |
Jorim Jaggi | 3c3c3fc | 2014-05-20 23:16:42 +0200 | [diff] [blame] | 394 | updateBackground(); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 395 | } |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 396 | } |
| 397 | } |
| 398 | |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 399 | public void setDark(boolean dark, boolean fade, long delay) { |
| 400 | super.setDark(dark, fade, delay); |
| 401 | if (mDark == dark) { |
| 402 | return; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 403 | } |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 404 | mDark = dark; |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 405 | if (!dark && fade && !shouldHideBackground()) { |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 406 | if (mActivated) { |
| 407 | mBackgroundDimmed.setVisibility(View.VISIBLE); |
| 408 | mBackgroundNormal.setVisibility(View.VISIBLE); |
Selim Cinek | c430a5b | 2014-12-10 16:29:01 +0100 | [diff] [blame] | 409 | } else if (mDimmed) { |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 410 | mBackgroundDimmed.setVisibility(View.VISIBLE); |
| 411 | mBackgroundNormal.setVisibility(View.INVISIBLE); |
Selim Cinek | c430a5b | 2014-12-10 16:29:01 +0100 | [diff] [blame] | 412 | } else { |
| 413 | mBackgroundDimmed.setVisibility(View.INVISIBLE); |
| 414 | mBackgroundNormal.setVisibility(View.VISIBLE); |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 415 | } |
Selim Cinek | c430a5b | 2014-12-10 16:29:01 +0100 | [diff] [blame] | 416 | fadeInFromDark(delay); |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 417 | } else { |
| 418 | updateBackground(); |
| 419 | } |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 420 | updateOutlineAlpha(); |
| 421 | } |
| 422 | |
| 423 | private void updateOutlineAlpha() { |
| 424 | if (mDark) { |
| 425 | setOutlineAlpha(0f); |
| 426 | return; |
| 427 | } |
| 428 | float alpha = NotificationStackScrollLayout.BACKGROUND_ALPHA_DIMMED; |
| 429 | alpha = (alpha + (1.0f - alpha) * mNormalBackgroundVisibilityAmount); |
Selim Cinek | 277a8aa | 2016-01-22 12:12:37 -0800 | [diff] [blame] | 430 | alpha *= mShadowAlpha; |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 431 | if (mFadeInFromDarkAnimator != null) { |
| 432 | alpha *= mFadeInFromDarkAnimator.getAnimatedFraction(); |
| 433 | } |
| 434 | setOutlineAlpha(alpha); |
| 435 | } |
| 436 | |
| 437 | public void setNormalBackgroundVisibilityAmount(float normalBackgroundVisibilityAmount) { |
| 438 | mNormalBackgroundVisibilityAmount = normalBackgroundVisibilityAmount; |
| 439 | updateOutlineAlpha(); |
| 440 | } |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 441 | |
Selim Cinek | 697178b | 2014-07-02 19:40:30 +0200 | [diff] [blame] | 442 | public void setShowingLegacyBackground(boolean showing) { |
| 443 | mShowingLegacyBackground = showing; |
| 444 | updateBackgroundTint(); |
Jorim Jaggi | 4673985 | 2014-04-15 09:58:24 +0200 | [diff] [blame] | 445 | } |
| 446 | |
Selim Cinek | 3d2b94bf | 2014-07-02 22:12:47 +0200 | [diff] [blame] | 447 | @Override |
| 448 | public void setBelowSpeedBump(boolean below) { |
| 449 | super.setBelowSpeedBump(below); |
| 450 | if (below != mIsBelowSpeedBump) { |
| 451 | mIsBelowSpeedBump = below; |
| 452 | updateBackgroundTint(); |
| 453 | } |
| 454 | } |
| 455 | |
Selim Cinek | 697178b | 2014-07-02 19:40:30 +0200 | [diff] [blame] | 456 | /** |
| 457 | * Sets the tint color of the background |
| 458 | */ |
| 459 | public void setTintColor(int color) { |
| 460 | mBgTint = color; |
| 461 | updateBackgroundTint(); |
| 462 | } |
| 463 | |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 464 | protected void updateBackgroundTint() { |
Chet Haase | 5058c38 | 2015-01-06 06:29:35 -0800 | [diff] [blame] | 465 | int color = getBgColor(); |
Selim Cinek | b2da91b | 2014-09-02 17:35:20 +0200 | [diff] [blame] | 466 | int rippleColor = getRippleColor(); |
Selim Cinek | 697178b | 2014-07-02 19:40:30 +0200 | [diff] [blame] | 467 | if (color == mNormalColor) { |
| 468 | // We don't need to tint a normal notification |
| 469 | color = 0; |
| 470 | } |
| 471 | mBackgroundDimmed.setTint(color); |
| 472 | mBackgroundNormal.setTint(color); |
Selim Cinek | b2da91b | 2014-09-02 17:35:20 +0200 | [diff] [blame] | 473 | mBackgroundDimmed.setRippleColor(rippleColor); |
| 474 | mBackgroundNormal.setRippleColor(rippleColor); |
Dan Sandler | fe266a3 | 2014-05-15 22:28:06 -0400 | [diff] [blame] | 475 | } |
| 476 | |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 477 | /** |
Selim Cinek | c430a5b | 2014-12-10 16:29:01 +0100 | [diff] [blame] | 478 | * Fades in the background when exiting dark mode. |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 479 | */ |
Selim Cinek | c430a5b | 2014-12-10 16:29:01 +0100 | [diff] [blame] | 480 | private void fadeInFromDark(long delay) { |
| 481 | final View background = mDimmed ? mBackgroundDimmed : mBackgroundNormal; |
| 482 | background.setAlpha(0f); |
| 483 | background.setPivotX(mBackgroundDimmed.getWidth() / 2f); |
| 484 | background.setPivotY(getActualHeight() / 2f); |
| 485 | background.setScaleX(DARK_EXIT_SCALE_START); |
| 486 | background.setScaleY(DARK_EXIT_SCALE_START); |
| 487 | background.animate() |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 488 | .alpha(1f) |
| 489 | .scaleX(1f) |
| 490 | .scaleY(1f) |
| 491 | .setDuration(DARK_ANIMATION_LENGTH) |
| 492 | .setStartDelay(delay) |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 493 | .setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN) |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 494 | .setListener(new AnimatorListenerAdapter() { |
| 495 | @Override |
| 496 | public void onAnimationCancel(Animator animation) { |
| 497 | // Jump state if we are cancelled |
Selim Cinek | c430a5b | 2014-12-10 16:29:01 +0100 | [diff] [blame] | 498 | background.setScaleX(1f); |
| 499 | background.setScaleY(1f); |
| 500 | background.setAlpha(1f); |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 501 | } |
| 502 | }) |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 503 | .setUpdateListener(mBackgroundVisibilityUpdater) |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 504 | .start(); |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 505 | mFadeInFromDarkAnimator = TimeAnimator.ofFloat(0.0f, 1.0f); |
| 506 | mFadeInFromDarkAnimator.setDuration(DARK_ANIMATION_LENGTH); |
| 507 | mFadeInFromDarkAnimator.setStartDelay(delay); |
| 508 | mFadeInFromDarkAnimator.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN); |
| 509 | mFadeInFromDarkAnimator.addListener(mFadeInEndListener); |
| 510 | mFadeInFromDarkAnimator.addUpdateListener(mUpdateOutlineListener); |
| 511 | mFadeInFromDarkAnimator.start(); |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | /** |
| 515 | * Fades the background when the dimmed state changes. |
| 516 | */ |
| 517 | private void fadeDimmedBackground() { |
| 518 | mBackgroundDimmed.animate().cancel(); |
Selim Cinek | 59d9723 | 2014-10-09 15:54:40 -0700 | [diff] [blame] | 519 | mBackgroundNormal.animate().cancel(); |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 520 | if (!shouldHideBackground()) { |
| 521 | if (mDimmed) { |
| 522 | mBackgroundDimmed.setVisibility(View.VISIBLE); |
| 523 | } else { |
| 524 | mBackgroundNormal.setVisibility(View.VISIBLE); |
| 525 | } |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 526 | } |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 527 | float startAlpha = mDimmed ? 1f : 0; |
| 528 | float endAlpha = mDimmed ? 0 : 1f; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 529 | int duration = BACKGROUND_ANIMATION_LENGTH_MS; |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 530 | // Check whether there is already a background animation running. |
| 531 | if (mBackgroundAnimator != null) { |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 532 | startAlpha = (Float) mBackgroundAnimator.getAnimatedValue(); |
Jorim Jaggi | 98fb09c | 2014-05-01 22:40:56 +0200 | [diff] [blame] | 533 | duration = (int) mBackgroundAnimator.getCurrentPlayTime(); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 534 | mBackgroundAnimator.removeAllListeners(); |
| 535 | mBackgroundAnimator.cancel(); |
Jorim Jaggi | 98fb09c | 2014-05-01 22:40:56 +0200 | [diff] [blame] | 536 | if (duration <= 0) { |
Jorim Jaggi | 3c3c3fc | 2014-05-20 23:16:42 +0200 | [diff] [blame] | 537 | updateBackground(); |
Jorim Jaggi | 98fb09c | 2014-05-01 22:40:56 +0200 | [diff] [blame] | 538 | return; |
| 539 | } |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 540 | } |
| 541 | mBackgroundNormal.setAlpha(startAlpha); |
| 542 | mBackgroundAnimator = |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 543 | ObjectAnimator.ofFloat(mBackgroundNormal, View.ALPHA, startAlpha, endAlpha); |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 544 | mBackgroundAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 545 | mBackgroundAnimator.setDuration(duration); |
| 546 | mBackgroundAnimator.addListener(new AnimatorListenerAdapter() { |
| 547 | @Override |
| 548 | public void onAnimationEnd(Animator animation) { |
| 549 | if (mDimmed) { |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 550 | mBackgroundNormal.setVisibility(View.INVISIBLE); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 551 | } else { |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 552 | mBackgroundDimmed.setVisibility(View.INVISIBLE); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 553 | } |
| 554 | mBackgroundAnimator = null; |
| 555 | } |
| 556 | }); |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 557 | mBackgroundAnimator.addUpdateListener(mBackgroundVisibilityUpdater); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 558 | mBackgroundAnimator.start(); |
| 559 | } |
| 560 | |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 561 | protected void updateBackground() { |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 562 | cancelFadeAnimations(); |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 563 | if (shouldHideBackground()) { |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 564 | mBackgroundDimmed.setVisibility(View.INVISIBLE); |
| 565 | mBackgroundNormal.setVisibility(View.INVISIBLE); |
| 566 | } else if (mDimmed) { |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 567 | mBackgroundDimmed.setVisibility(View.VISIBLE); |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 568 | mBackgroundNormal.setVisibility(View.INVISIBLE); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 569 | } else { |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 570 | mBackgroundDimmed.setVisibility(View.INVISIBLE); |
| 571 | mBackgroundNormal.setVisibility(View.VISIBLE); |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 572 | mBackgroundNormal.setAlpha(1f); |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 573 | removeCallbacks(mTapTimeoutRunnable); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 574 | } |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 575 | setNormalBackgroundVisibilityAmount( |
| 576 | mBackgroundNormal.getVisibility() == View.VISIBLE ? 1.0f : 0.0f); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 577 | } |
| 578 | |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 579 | protected boolean shouldHideBackground() { |
| 580 | return mDark; |
| 581 | } |
| 582 | |
Selim Cinek | 59d9723 | 2014-10-09 15:54:40 -0700 | [diff] [blame] | 583 | private void cancelFadeAnimations() { |
| 584 | if (mBackgroundAnimator != null) { |
| 585 | mBackgroundAnimator.cancel(); |
| 586 | } |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 587 | mBackgroundDimmed.animate().cancel(); |
Selim Cinek | 59d9723 | 2014-10-09 15:54:40 -0700 | [diff] [blame] | 588 | mBackgroundNormal.animate().cancel(); |
| 589 | } |
| 590 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 591 | @Override |
| 592 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
| 593 | super.onLayout(changed, left, top, right, bottom); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 594 | setPivotX(getWidth() / 2); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | @Override |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 598 | public void setActualHeight(int actualHeight, boolean notifyListeners) { |
| 599 | super.setActualHeight(actualHeight, notifyListeners); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 600 | setPivotY(actualHeight / 2); |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 601 | mBackgroundNormal.setActualHeight(actualHeight); |
| 602 | mBackgroundDimmed.setActualHeight(actualHeight); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | @Override |
| 606 | public void setClipTopAmount(int clipTopAmount) { |
| 607 | super.setClipTopAmount(clipTopAmount); |
Jorim Jaggi | a8b48e1 | 2014-05-19 20:26:46 +0200 | [diff] [blame] | 608 | mBackgroundNormal.setClipTopAmount(clipTopAmount); |
| 609 | mBackgroundDimmed.setClipTopAmount(clipTopAmount); |
Jorim Jaggi | 4673985 | 2014-04-15 09:58:24 +0200 | [diff] [blame] | 610 | } |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 611 | |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 612 | @Override |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 613 | public void performRemoveAnimation(long duration, float translationDirection, |
| 614 | Runnable onFinishedRunnable) { |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 615 | enableAppearDrawing(true); |
| 616 | if (mDrawingAppearAnimation) { |
| 617 | startAppearAnimation(false /* isAppearing */, translationDirection, |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 618 | 0, duration, onFinishedRunnable); |
Selim Cinek | 95ed592 | 2014-08-28 14:30:12 +0200 | [diff] [blame] | 619 | } else if (onFinishedRunnable != null) { |
| 620 | onFinishedRunnable.run(); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 621 | } |
| 622 | } |
| 623 | |
| 624 | @Override |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 625 | public void performAddAnimation(long delay, long duration) { |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 626 | enableAppearDrawing(true); |
| 627 | if (mDrawingAppearAnimation) { |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 628 | startAppearAnimation(true /* isAppearing */, -1.0f, delay, duration, null); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 629 | } |
| 630 | } |
| 631 | |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 632 | private void startAppearAnimation(boolean isAppearing, float translationDirection, long delay, |
| 633 | long duration, final Runnable onFinishedRunnable) { |
Selim Cinek | 2cd45df | 2015-06-09 18:00:07 -0700 | [diff] [blame] | 634 | cancelAppearAnimation(); |
Chris Wren | 310df31 | 2014-10-31 14:29:46 -0400 | [diff] [blame] | 635 | mAnimationTranslationY = translationDirection * getActualHeight(); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 636 | if (mAppearAnimationFraction == -1.0f) { |
| 637 | // not initialized yet, we start anew |
| 638 | if (isAppearing) { |
| 639 | mAppearAnimationFraction = 0.0f; |
| 640 | mAppearAnimationTranslation = mAnimationTranslationY; |
| 641 | } else { |
| 642 | mAppearAnimationFraction = 1.0f; |
| 643 | mAppearAnimationTranslation = 0; |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | float targetValue; |
| 648 | if (isAppearing) { |
| 649 | mCurrentAppearInterpolator = mSlowOutFastInInterpolator; |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 650 | mCurrentAlphaInterpolator = Interpolators.LINEAR_OUT_SLOW_IN; |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 651 | targetValue = 1.0f; |
| 652 | } else { |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 653 | mCurrentAppearInterpolator = Interpolators.FAST_OUT_SLOW_IN; |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 654 | mCurrentAlphaInterpolator = mSlowOutLinearInInterpolator; |
| 655 | targetValue = 0.0f; |
| 656 | } |
| 657 | mAppearAnimator = ValueAnimator.ofFloat(mAppearAnimationFraction, |
| 658 | targetValue); |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 659 | mAppearAnimator.setInterpolator(Interpolators.LINEAR); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 660 | mAppearAnimator.setDuration( |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 661 | (long) (duration * Math.abs(mAppearAnimationFraction - targetValue))); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 662 | mAppearAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { |
| 663 | @Override |
| 664 | public void onAnimationUpdate(ValueAnimator animation) { |
| 665 | mAppearAnimationFraction = (float) animation.getAnimatedValue(); |
| 666 | updateAppearAnimationAlpha(); |
| 667 | updateAppearRect(); |
| 668 | invalidate(); |
| 669 | } |
| 670 | }); |
| 671 | if (delay > 0) { |
| 672 | // we need to apply the initial state already to avoid drawn frames in the wrong state |
| 673 | updateAppearAnimationAlpha(); |
| 674 | updateAppearRect(); |
| 675 | mAppearAnimator.setStartDelay(delay); |
| 676 | } |
| 677 | mAppearAnimator.addListener(new AnimatorListenerAdapter() { |
| 678 | private boolean mWasCancelled; |
| 679 | |
| 680 | @Override |
| 681 | public void onAnimationEnd(Animator animation) { |
| 682 | if (onFinishedRunnable != null) { |
| 683 | onFinishedRunnable.run(); |
| 684 | } |
| 685 | if (!mWasCancelled) { |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 686 | enableAppearDrawing(false); |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | @Override |
| 691 | public void onAnimationStart(Animator animation) { |
| 692 | mWasCancelled = false; |
| 693 | } |
| 694 | |
| 695 | @Override |
| 696 | public void onAnimationCancel(Animator animation) { |
| 697 | mWasCancelled = true; |
| 698 | } |
| 699 | }); |
| 700 | mAppearAnimator.start(); |
| 701 | } |
| 702 | |
Selim Cinek | 2cd45df | 2015-06-09 18:00:07 -0700 | [diff] [blame] | 703 | private void cancelAppearAnimation() { |
| 704 | if (mAppearAnimator != null) { |
| 705 | mAppearAnimator.cancel(); |
Selim Cinek | b65c6db | 2015-12-28 12:48:15 +0100 | [diff] [blame] | 706 | mAppearAnimator = null; |
Selim Cinek | 2cd45df | 2015-06-09 18:00:07 -0700 | [diff] [blame] | 707 | } |
| 708 | } |
| 709 | |
| 710 | public void cancelAppearDrawing() { |
| 711 | cancelAppearAnimation(); |
| 712 | enableAppearDrawing(false); |
| 713 | } |
| 714 | |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 715 | private void updateAppearRect() { |
| 716 | float inverseFraction = (1.0f - mAppearAnimationFraction); |
| 717 | float translationFraction = mCurrentAppearInterpolator.getInterpolation(inverseFraction); |
| 718 | float translateYTotalAmount = translationFraction * mAnimationTranslationY; |
| 719 | mAppearAnimationTranslation = translateYTotalAmount; |
| 720 | |
| 721 | // handle width animation |
| 722 | float widthFraction = (inverseFraction - (1.0f - HORIZONTAL_ANIMATION_START)) |
| 723 | / (HORIZONTAL_ANIMATION_START - HORIZONTAL_ANIMATION_END); |
| 724 | widthFraction = Math.min(1.0f, Math.max(0.0f, widthFraction)); |
| 725 | widthFraction = mCurrentAppearInterpolator.getInterpolation(widthFraction); |
| 726 | float left = (getWidth() * (0.5f - HORIZONTAL_COLLAPSED_REST_PARTIAL / 2.0f) * |
| 727 | widthFraction); |
| 728 | float right = getWidth() - left; |
| 729 | |
| 730 | // handle top animation |
| 731 | float heightFraction = (inverseFraction - (1.0f - VERTICAL_ANIMATION_START)) / |
| 732 | VERTICAL_ANIMATION_START; |
| 733 | heightFraction = Math.max(0.0f, heightFraction); |
| 734 | heightFraction = mCurrentAppearInterpolator.getInterpolation(heightFraction); |
| 735 | |
| 736 | float top; |
| 737 | float bottom; |
Chris Wren | 310df31 | 2014-10-31 14:29:46 -0400 | [diff] [blame] | 738 | final int actualHeight = getActualHeight(); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 739 | if (mAnimationTranslationY > 0.0f) { |
Chris Wren | 310df31 | 2014-10-31 14:29:46 -0400 | [diff] [blame] | 740 | bottom = actualHeight - heightFraction * mAnimationTranslationY * 0.1f |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 741 | - translateYTotalAmount; |
| 742 | top = bottom * heightFraction; |
| 743 | } else { |
Chris Wren | 310df31 | 2014-10-31 14:29:46 -0400 | [diff] [blame] | 744 | top = heightFraction * (actualHeight + mAnimationTranslationY) * 0.1f - |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 745 | translateYTotalAmount; |
Chris Wren | 310df31 | 2014-10-31 14:29:46 -0400 | [diff] [blame] | 746 | bottom = actualHeight * (1 - heightFraction) + top * heightFraction; |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 747 | } |
| 748 | mAppearAnimationRect.set(left, top, right, bottom); |
| 749 | setOutlineRect(left, top + mAppearAnimationTranslation, right, |
| 750 | bottom + mAppearAnimationTranslation); |
| 751 | } |
| 752 | |
| 753 | private void updateAppearAnimationAlpha() { |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 754 | float contentAlphaProgress = mAppearAnimationFraction; |
| 755 | contentAlphaProgress = contentAlphaProgress / (1.0f - ALPHA_ANIMATION_END); |
| 756 | contentAlphaProgress = Math.min(1.0f, contentAlphaProgress); |
| 757 | contentAlphaProgress = mCurrentAlphaInterpolator.getInterpolation(contentAlphaProgress); |
| 758 | setContentAlpha(contentAlphaProgress); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 759 | } |
| 760 | |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 761 | private void setContentAlpha(float contentAlpha) { |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 762 | View contentView = getContentView(); |
Jorim Jaggi | 1f98c62 | 2015-07-20 11:43:27 -0700 | [diff] [blame] | 763 | if (contentView.hasOverlappingRendering()) { |
| 764 | int layerType = contentAlpha == 0.0f || contentAlpha == 1.0f ? LAYER_TYPE_NONE |
| 765 | : LAYER_TYPE_HARDWARE; |
| 766 | int currentLayerType = contentView.getLayerType(); |
| 767 | if (currentLayerType != layerType) { |
| 768 | contentView.setLayerType(layerType, null); |
| 769 | } |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 770 | } |
| 771 | contentView.setAlpha(contentAlpha); |
| 772 | } |
| 773 | |
| 774 | protected abstract View getContentView(); |
| 775 | |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 776 | public int getBgColor() { |
Selim Cinek | 697178b | 2014-07-02 19:40:30 +0200 | [diff] [blame] | 777 | if (mBgTint != 0) { |
| 778 | return mBgTint; |
| 779 | } else if (mShowingLegacyBackground) { |
| 780 | return mLegacyColor; |
Selim Cinek | 3d2b94bf | 2014-07-02 22:12:47 +0200 | [diff] [blame] | 781 | } else if (mIsBelowSpeedBump) { |
| 782 | return mLowPriorityColor; |
Selim Cinek | 697178b | 2014-07-02 19:40:30 +0200 | [diff] [blame] | 783 | } else { |
| 784 | return mNormalColor; |
| 785 | } |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 786 | } |
| 787 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 788 | protected int getRippleColor() { |
Selim Cinek | b2da91b | 2014-09-02 17:35:20 +0200 | [diff] [blame] | 789 | if (mBgTint != 0) { |
| 790 | return mTintedRippleColor; |
| 791 | } else if (mShowingLegacyBackground) { |
| 792 | return mTintedRippleColor; |
| 793 | } else if (mIsBelowSpeedBump) { |
| 794 | return mLowPriorityRippleColor; |
| 795 | } else { |
| 796 | return mNormalRippleColor; |
| 797 | } |
| 798 | } |
| 799 | |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 800 | /** |
| 801 | * When we draw the appear animation, we render the view in a bitmap and render this bitmap |
| 802 | * as a shader of a rect. This call creates the Bitmap and switches the drawing mode, |
| 803 | * such that the normal drawing of the views does not happen anymore. |
| 804 | * |
| 805 | * @param enable Should it be enabled. |
| 806 | */ |
| 807 | private void enableAppearDrawing(boolean enable) { |
| 808 | if (enable != mDrawingAppearAnimation) { |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 809 | mDrawingAppearAnimation = enable; |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 810 | if (!enable) { |
| 811 | setContentAlpha(1.0f); |
Selim Cinek | b65c6db | 2015-12-28 12:48:15 +0100 | [diff] [blame] | 812 | mAppearAnimationFraction = -1; |
| 813 | setOutlineRect(null); |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 814 | } |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 815 | invalidate(); |
| 816 | } |
| 817 | } |
| 818 | |
| 819 | @Override |
| 820 | protected void dispatchDraw(Canvas canvas) { |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 821 | if (mDrawingAppearAnimation) { |
| 822 | canvas.save(); |
| 823 | canvas.translate(0, mAppearAnimationTranslation); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 824 | } |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 825 | super.dispatchDraw(canvas); |
| 826 | if (mDrawingAppearAnimation) { |
| 827 | canvas.restore(); |
| 828 | } |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 829 | } |
| 830 | |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 831 | public void setOnActivatedListener(OnActivatedListener onActivatedListener) { |
| 832 | mOnActivatedListener = onActivatedListener; |
| 833 | } |
| 834 | |
Christoph Studer | 22f2ee5 | 2014-07-29 22:57:21 +0200 | [diff] [blame] | 835 | public void reset() { |
| 836 | setTintColor(0); |
| 837 | setShowingLegacyBackground(false); |
| 838 | setBelowSpeedBump(false); |
| 839 | } |
| 840 | |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 841 | public boolean hasSameBgColor(ActivatableNotificationView otherView) { |
| 842 | return getBgColor() == otherView.getBgColor(); |
| 843 | } |
| 844 | |
Selim Cinek | 277a8aa | 2016-01-22 12:12:37 -0800 | [diff] [blame] | 845 | @Override |
| 846 | public float getShadowAlpha() { |
| 847 | return mShadowAlpha; |
| 848 | } |
| 849 | |
| 850 | @Override |
| 851 | public void setShadowAlpha(float shadowAlpha) { |
| 852 | if (shadowAlpha != mShadowAlpha) { |
| 853 | mShadowAlpha = shadowAlpha; |
| 854 | updateOutlineAlpha(); |
| 855 | } |
| 856 | } |
| 857 | |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 858 | @Override |
| 859 | public void setFakeShadowIntensity(float shadowIntensity, float outlineAlpha, int shadowYEnd, |
| 860 | int outlineTranslation) { |
| 861 | mFakeShadow.setFakeShadowTranslationZ(shadowIntensity * (getTranslationZ() |
| 862 | + FakeShadowView.SHADOW_SIBLING_TRESHOLD), outlineAlpha, shadowYEnd, |
| 863 | outlineTranslation); |
| 864 | } |
| 865 | |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 866 | public interface OnActivatedListener { |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 867 | void onActivated(ActivatableNotificationView view); |
| 868 | void onActivationReset(ActivatableNotificationView view); |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 869 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 870 | } |