Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 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 |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.statusbar.phone; |
| 18 | |
| 19 | import android.animation.Animator; |
| 20 | import android.animation.AnimatorListenerAdapter; |
| 21 | import android.animation.ValueAnimator; |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 22 | import android.content.Context; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 23 | import android.graphics.Color; |
| 24 | import android.graphics.drawable.ColorDrawable; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 25 | import android.util.Log; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 26 | import android.view.View; |
| 27 | import android.view.ViewTreeObserver; |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 28 | import android.view.animation.AnimationUtils; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 29 | import android.view.animation.DecelerateInterpolator; |
| 30 | import android.view.animation.Interpolator; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 31 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 32 | import com.android.systemui.R; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame^] | 33 | import com.android.systemui.doze.DozeLog; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 34 | |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 35 | /** |
| 36 | * Controls both the scrim behind the notifications and in front of the notifications (when a |
| 37 | * security method gets shown). |
| 38 | */ |
| 39 | public class ScrimController implements ViewTreeObserver.OnPreDrawListener { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 40 | private static final String TAG = "ScrimController"; |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 41 | private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 42 | |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 43 | public static final long ANIMATION_DURATION = 220; |
| 44 | |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 45 | private static final float SCRIM_BEHIND_ALPHA = 0.62f; |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 46 | private static final float SCRIM_BEHIND_ALPHA_KEYGUARD = 0.55f; |
| 47 | private static final float SCRIM_BEHIND_ALPHA_UNLOCKING = 0.2f; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 48 | private static final float SCRIM_IN_FRONT_ALPHA = 0.75f; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 49 | private static final int TAG_KEY_ANIM = R.id.scrim; |
| 50 | |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 51 | private final View mScrimBehind; |
| 52 | private final View mScrimInFront; |
| 53 | private final UnlockMethodCache mUnlockMethodCache; |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 54 | private final DozeParameters mDozeParameters; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 55 | |
| 56 | private boolean mKeyguardShowing; |
| 57 | private float mFraction; |
| 58 | |
| 59 | private boolean mDarkenWhileDragging; |
| 60 | private boolean mBouncerShowing; |
| 61 | private boolean mAnimateChange; |
| 62 | private boolean mUpdatePending; |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 63 | private boolean mExpanding; |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 64 | private boolean mAnimateKeyguardFadingOut; |
| 65 | private long mDurationOverride = -1; |
| 66 | private long mAnimationDelay; |
| 67 | private Runnable mOnAnimationFinished; |
| 68 | private boolean mAnimationStarted; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 69 | private boolean mDozing; |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 70 | private long mPulseEndTime; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 71 | private final Interpolator mInterpolator = new DecelerateInterpolator(); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 72 | private final Interpolator mLinearOutSlowInInterpolator; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 73 | |
| 74 | public ScrimController(View scrimBehind, View scrimInFront) { |
| 75 | mScrimBehind = scrimBehind; |
| 76 | mScrimInFront = scrimInFront; |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 77 | final Context context = scrimBehind.getContext(); |
| 78 | mUnlockMethodCache = UnlockMethodCache.getInstance(context); |
| 79 | mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 80 | android.R.interpolator.linear_out_slow_in); |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 81 | mDozeParameters = new DozeParameters(context); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | public void setKeyguardShowing(boolean showing) { |
| 85 | mKeyguardShowing = showing; |
| 86 | scheduleUpdate(); |
| 87 | } |
| 88 | |
| 89 | public void onTrackingStarted() { |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 90 | mExpanding = true; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 91 | mDarkenWhileDragging = !mUnlockMethodCache.isMethodInsecure(); |
| 92 | } |
| 93 | |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 94 | public void onExpandingFinished() { |
| 95 | mExpanding = false; |
| 96 | } |
| 97 | |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 98 | public void setPanelExpansion(float fraction) { |
Jorim Jaggi | 93439da | 2014-06-30 23:53:39 +0200 | [diff] [blame] | 99 | if (mFraction != fraction) { |
| 100 | mFraction = fraction; |
| 101 | scheduleUpdate(); |
| 102 | } |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | public void setBouncerShowing(boolean showing) { |
| 106 | mBouncerShowing = showing; |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 107 | mAnimateChange = !mExpanding; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 108 | scheduleUpdate(); |
| 109 | } |
| 110 | |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 111 | public void animateKeyguardFadingOut(long delay, long duration, Runnable onAnimationFinished) { |
| 112 | mAnimateKeyguardFadingOut = true; |
| 113 | mDurationOverride = duration; |
| 114 | mAnimationDelay = delay; |
| 115 | mAnimateChange = true; |
| 116 | mOnAnimationFinished = onAnimationFinished; |
| 117 | scheduleUpdate(); |
| 118 | } |
| 119 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 120 | public void animateGoingToFullShade(long delay, long duration) { |
| 121 | mDurationOverride = duration; |
| 122 | mAnimationDelay = delay; |
| 123 | mAnimateChange = true; |
| 124 | scheduleUpdate(); |
| 125 | } |
| 126 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 127 | public void setDozing(boolean dozing) { |
| 128 | if (mDozing == dozing) return; |
| 129 | mDozing = dozing; |
| 130 | if (!mDozing) { |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 131 | cancelPulsing(); |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 132 | mAnimateChange = true; |
John Spurlock | 190d026 | 2014-09-14 15:39:13 -0400 | [diff] [blame] | 133 | } else { |
| 134 | mAnimateChange = false; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 135 | } |
| 136 | scheduleUpdate(); |
| 137 | } |
| 138 | |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 139 | /** When dozing, fade screen contents in and out using the front scrim. */ |
John Spurlock | 190d026 | 2014-09-14 15:39:13 -0400 | [diff] [blame] | 140 | public long pulse() { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 141 | if (!mDozing) return 0; |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 142 | final long now = System.currentTimeMillis(); |
John Spurlock | 190d026 | 2014-09-14 15:39:13 -0400 | [diff] [blame] | 143 | if (DEBUG) Log.d(TAG, "pulse mPulseEndTime=" + mPulseEndTime + " now=" + now); |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 144 | if (mPulseEndTime != 0 && mPulseEndTime > now) return mPulseEndTime - now; |
John Spurlock | 190d026 | 2014-09-14 15:39:13 -0400 | [diff] [blame] | 145 | mScrimInFront.post(mPulseIn); |
| 146 | mPulseEndTime = now + mDozeParameters.getPulseDuration(); |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 147 | return mPulseEndTime - now; |
| 148 | } |
| 149 | |
| 150 | public boolean isPulsing() { |
| 151 | return mDozing && mPulseEndTime != 0; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 152 | } |
| 153 | |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 154 | private void cancelPulsing() { |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 155 | if (DEBUG) Log.d(TAG, "Cancel pulsing"); |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 156 | mScrimInFront.removeCallbacks(mPulseIn); |
| 157 | mScrimInFront.removeCallbacks(mPulseOut); |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 158 | mPulseEndTime = 0; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 159 | } |
| 160 | |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 161 | private void scheduleUpdate() { |
| 162 | if (mUpdatePending) return; |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 163 | |
| 164 | // Make sure that a frame gets scheduled. |
| 165 | mScrimBehind.invalidate(); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 166 | mScrimBehind.getViewTreeObserver().addOnPreDrawListener(this); |
| 167 | mUpdatePending = true; |
| 168 | } |
| 169 | |
| 170 | private void updateScrims() { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 171 | if (mAnimateKeyguardFadingOut) { |
| 172 | setScrimInFrontColor(0f); |
| 173 | setScrimBehindColor(0f); |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 174 | } else if (!mKeyguardShowing && !mBouncerShowing) { |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 175 | updateScrimNormal(); |
| 176 | setScrimInFrontColor(0); |
| 177 | } else { |
| 178 | updateScrimKeyguard(); |
| 179 | } |
| 180 | mAnimateChange = false; |
| 181 | } |
| 182 | |
| 183 | private void updateScrimKeyguard() { |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 184 | if (mExpanding && mDarkenWhileDragging) { |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 185 | float behindFraction = Math.max(0, Math.min(mFraction, 1)); |
| 186 | float fraction = 1 - behindFraction; |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 187 | fraction = (float) Math.pow(fraction, 0.8f); |
| 188 | behindFraction = (float) Math.pow(behindFraction, 0.8f); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 189 | setScrimInFrontColor(fraction * SCRIM_IN_FRONT_ALPHA); |
| 190 | setScrimBehindColor(behindFraction * SCRIM_BEHIND_ALPHA_KEYGUARD); |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 191 | } else if (mBouncerShowing) { |
| 192 | setScrimInFrontColor(SCRIM_IN_FRONT_ALPHA); |
| 193 | setScrimBehindColor(0f); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 194 | } else if (mDozing) { |
| 195 | setScrimInFrontColor(1); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 196 | } else { |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 197 | float fraction = Math.max(0, Math.min(mFraction, 1)); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 198 | setScrimInFrontColor(0f); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 199 | setScrimBehindColor(fraction |
| 200 | * (SCRIM_BEHIND_ALPHA_KEYGUARD - SCRIM_BEHIND_ALPHA_UNLOCKING) |
| 201 | + SCRIM_BEHIND_ALPHA_UNLOCKING); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 202 | } |
| 203 | } |
| 204 | |
| 205 | private void updateScrimNormal() { |
| 206 | float frac = mFraction; |
| 207 | // let's start this 20% of the way down the screen |
| 208 | frac = frac * 1.2f - 0.2f; |
| 209 | if (frac <= 0) { |
| 210 | setScrimBehindColor(0); |
| 211 | } else { |
| 212 | // woo, special effects |
| 213 | final float k = (float)(1f-0.5f*(1f-Math.cos(3.14159f * Math.pow(1f-frac, 2f)))); |
| 214 | setScrimBehindColor(k * SCRIM_BEHIND_ALPHA); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | private void setScrimBehindColor(float alpha) { |
| 219 | setScrimColor(mScrimBehind, alpha); |
| 220 | } |
| 221 | |
| 222 | private void setScrimInFrontColor(float alpha) { |
| 223 | setScrimColor(mScrimInFront, alpha); |
| 224 | if (alpha == 0f) { |
| 225 | mScrimInFront.setClickable(false); |
| 226 | } else { |
| 227 | |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 228 | // Eat touch events (unless dozing). |
| 229 | mScrimInFront.setClickable(!mDozing); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 230 | } |
| 231 | } |
| 232 | |
| 233 | private void setScrimColor(View scrim, float alpha) { |
| 234 | int color = Color.argb((int) (alpha * 255), 0, 0, 0); |
| 235 | if (mAnimateChange) { |
| 236 | startScrimAnimation(scrim, color); |
| 237 | } else { |
| 238 | scrim.setBackgroundColor(color); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | private void startScrimAnimation(final View scrim, int targetColor) { |
| 243 | int current = getBackgroundAlpha(scrim); |
| 244 | int target = Color.alpha(targetColor); |
| 245 | if (current == targetColor) { |
| 246 | return; |
| 247 | } |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 248 | Object runningAnim = scrim.getTag(TAG_KEY_ANIM); |
| 249 | if (runningAnim instanceof ValueAnimator) { |
| 250 | ((ValueAnimator) runningAnim).cancel(); |
| 251 | } |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 252 | ValueAnimator anim = ValueAnimator.ofInt(current, target); |
| 253 | anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { |
| 254 | @Override |
| 255 | public void onAnimationUpdate(ValueAnimator animation) { |
| 256 | int value = (int) animation.getAnimatedValue(); |
| 257 | scrim.setBackgroundColor(Color.argb(value, 0, 0, 0)); |
| 258 | } |
| 259 | }); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 260 | anim.setInterpolator(mAnimateKeyguardFadingOut |
| 261 | ? mLinearOutSlowInInterpolator |
| 262 | : mInterpolator); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 263 | anim.setStartDelay(mAnimationDelay); |
| 264 | anim.setDuration(mDurationOverride != -1 ? mDurationOverride : ANIMATION_DURATION); |
| 265 | anim.addListener(new AnimatorListenerAdapter() { |
| 266 | |
| 267 | @Override |
| 268 | public void onAnimationEnd(Animator animation) { |
| 269 | if (mOnAnimationFinished != null) { |
| 270 | mOnAnimationFinished.run(); |
| 271 | mOnAnimationFinished = null; |
| 272 | } |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 273 | scrim.setTag(TAG_KEY_ANIM, null); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 274 | } |
| 275 | }); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 276 | anim.start(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 277 | scrim.setTag(TAG_KEY_ANIM, anim); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 278 | mAnimationStarted = true; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | private int getBackgroundAlpha(View scrim) { |
| 282 | if (scrim.getBackground() instanceof ColorDrawable) { |
| 283 | ColorDrawable drawable = (ColorDrawable) scrim.getBackground(); |
| 284 | return Color.alpha(drawable.getColor()); |
| 285 | } else { |
| 286 | return 0; |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | @Override |
| 291 | public boolean onPreDraw() { |
| 292 | mScrimBehind.getViewTreeObserver().removeOnPreDrawListener(this); |
| 293 | mUpdatePending = false; |
| 294 | updateScrims(); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 295 | mAnimateKeyguardFadingOut = false; |
| 296 | mDurationOverride = -1; |
| 297 | mAnimationDelay = 0; |
| 298 | |
| 299 | // Make sure that we always call the listener even if we didn't start an animation. |
| 300 | if (!mAnimationStarted && mOnAnimationFinished != null) { |
| 301 | mOnAnimationFinished.run(); |
| 302 | mOnAnimationFinished = null; |
| 303 | } |
| 304 | mAnimationStarted = false; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 305 | return true; |
| 306 | } |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 307 | |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 308 | private final Runnable mPulseIn = new Runnable() { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 309 | @Override |
| 310 | public void run() { |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 311 | if (DEBUG) Log.d(TAG, "Pulse in, mDozing=" + mDozing); |
| 312 | if (!mDozing) return; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame^] | 313 | DozeLog.tracePulseStart(); |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 314 | mDurationOverride = mDozeParameters.getPulseInDuration(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 315 | mAnimationDelay = 0; |
| 316 | mAnimateChange = true; |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 317 | mOnAnimationFinished = mPulseInFinished; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 318 | setScrimColor(mScrimInFront, 0); |
| 319 | } |
| 320 | }; |
| 321 | |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 322 | private final Runnable mPulseInFinished = new Runnable() { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 323 | @Override |
| 324 | public void run() { |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 325 | if (DEBUG) Log.d(TAG, "Pulse in finished, mDozing=" + mDozing); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 326 | if (!mDozing) return; |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 327 | mScrimInFront.postDelayed(mPulseOut, mDozeParameters.getPulseVisibleDuration()); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 328 | } |
| 329 | }; |
| 330 | |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 331 | private final Runnable mPulseOut = new Runnable() { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 332 | @Override |
| 333 | public void run() { |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 334 | if (DEBUG) Log.d(TAG, "Pulse out, mDozing=" + mDozing); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 335 | if (!mDozing) return; |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 336 | mDurationOverride = mDozeParameters.getPulseOutDuration(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 337 | mAnimationDelay = 0; |
| 338 | mAnimateChange = true; |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 339 | mOnAnimationFinished = mPulseOutFinished; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 340 | setScrimColor(mScrimInFront, 1); |
| 341 | } |
| 342 | }; |
| 343 | |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 344 | private final Runnable mPulseOutFinished = new Runnable() { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 345 | @Override |
| 346 | public void run() { |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 347 | if (DEBUG) Log.d(TAG, "Pulse out finished"); |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame^] | 348 | DozeLog.tracePulseFinish(); |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 349 | mPulseEndTime = 0; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 350 | } |
| 351 | }; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 352 | } |