Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 19 | import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator.ExpandAnimationParameters; |
| 20 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 21 | import android.animation.Animator; |
| 22 | import android.animation.AnimatorListenerAdapter; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 23 | import android.animation.ObjectAnimator; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 24 | import android.animation.ValueAnimator; |
Zhentao Sun | 04f9740 | 2015-08-26 17:37:30 -0700 | [diff] [blame] | 25 | import android.app.ActivityManager; |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 26 | import android.app.Fragment; |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 27 | import android.app.StatusBarManager; |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 28 | import android.content.Context; |
Zhentao Sun | 04f9740 | 2015-08-26 17:37:30 -0700 | [diff] [blame] | 29 | import android.content.pm.ResolveInfo; |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 30 | import android.content.res.Configuration; |
Anthony Chen | 04d1ea7 | 2017-04-21 14:30:11 -0700 | [diff] [blame] | 31 | import android.content.res.Resources; |
Jorim Jaggi | 58bef33 | 2014-11-21 18:10:32 +0100 | [diff] [blame] | 32 | import android.graphics.Canvas; |
| 33 | import android.graphics.Color; |
| 34 | import android.graphics.Paint; |
shawnlin | 4ef7ca5 | 2018-05-11 16:44:42 +0800 | [diff] [blame] | 35 | import android.graphics.PorterDuff; |
| 36 | import android.graphics.PorterDuffXfermode; |
Jorim Jaggi | 613f55f | 2015-07-16 15:30:10 -0700 | [diff] [blame] | 37 | import android.graphics.Rect; |
Selim Cinek | e64f52a | 2017-08-24 14:48:38 -0700 | [diff] [blame] | 38 | import android.os.PowerManager; |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 39 | import android.util.AttributeSet; |
Adrian Roos | 52414e3 | 2017-04-28 09:23:19 -0700 | [diff] [blame] | 40 | import android.util.FloatProperty; |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 41 | import android.util.Log; |
Jorim Jaggi | 3afddce | 2014-08-14 20:44:43 +0200 | [diff] [blame] | 42 | import android.util.MathUtils; |
Lucas Dupin | 987f193 | 2017-05-13 21:02:52 -0700 | [diff] [blame] | 43 | import android.view.LayoutInflater; |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 44 | import android.view.MotionEvent; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 45 | import android.view.VelocityTracker; |
Daniel Sandler | 13522a2 | 2012-09-27 14:46:58 -0400 | [diff] [blame] | 46 | import android.view.View; |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 47 | import android.view.ViewGroup; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 48 | import android.view.WindowInsets; |
Phil Weaver | 428e397 | 2018-01-18 12:50:05 -0800 | [diff] [blame] | 49 | import android.view.accessibility.AccessibilityManager; |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 50 | import android.view.animation.Interpolator; |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 51 | import android.widget.FrameLayout; |
Lucas Dupin | 0cd882f | 2018-01-30 12:19:49 -0800 | [diff] [blame] | 52 | |
Chris Wren | 49f06f5 | 2015-05-01 16:12:12 -0400 | [diff] [blame] | 53 | import com.android.internal.logging.MetricsLogger; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 54 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Jorim Jaggi | d09def751 | 2014-09-02 18:36:45 +0200 | [diff] [blame] | 55 | import com.android.keyguard.KeyguardStatusView; |
Jorim Jaggi | 613f55f | 2015-07-16 15:30:10 -0700 | [diff] [blame] | 56 | import com.android.systemui.DejankUtils; |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 57 | import com.android.systemui.Interpolators; |
Chet Haase | 4d179dc | 2012-08-22 07:14:42 -0700 | [diff] [blame] | 58 | import com.android.systemui.R; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 59 | import com.android.systemui.classifier.FalsingManager; |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 60 | import com.android.systemui.fragments.FragmentHostManager; |
| 61 | import com.android.systemui.fragments.FragmentHostManager.FragmentListener; |
| 62 | import com.android.systemui.plugins.qs.QS; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 63 | import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; |
| 64 | import com.android.systemui.statusbar.notification.row.ExpandableView; |
Jorim Jaggi | 87cd5e7 | 2014-05-12 23:29:10 +0200 | [diff] [blame] | 65 | import com.android.systemui.statusbar.FlingAnimationUtils; |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 66 | import com.android.systemui.statusbar.GestureRecorder; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 67 | import com.android.systemui.statusbar.KeyguardAffordanceView; |
Lucas Dupin | 987f193 | 2017-05-13 21:02:52 -0700 | [diff] [blame] | 68 | import com.android.systemui.statusbar.KeyguardIndicationController; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 69 | import com.android.systemui.statusbar.notification.NotificationData; |
Anthony Chen | 9e05d46 | 2017-04-07 10:10:21 -0700 | [diff] [blame] | 70 | import com.android.systemui.statusbar.NotificationShelf; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 71 | import com.android.systemui.statusbar.StatusBarState; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 72 | import com.android.systemui.statusbar.notification.ActivityLaunchAnimator; |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 73 | import com.android.systemui.statusbar.notification.AnimatableProperty; |
| 74 | import com.android.systemui.statusbar.notification.PropertyAnimator; |
Jorim Jaggi | bf1899e | 2014-08-07 02:04:18 +0200 | [diff] [blame] | 75 | import com.android.systemui.statusbar.policy.KeyguardUserSwitcher; |
Selim Cinek | a7d4f82 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 76 | import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 77 | import com.android.systemui.statusbar.notification.stack.AnimationProperties; |
| 78 | import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; |
| 79 | import com.android.systemui.statusbar.notification.stack.StackStateAnimator; |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 80 | |
Lucas Dupin | c510d41 | 2018-06-12 13:08:23 -0700 | [diff] [blame] | 81 | import java.io.FileDescriptor; |
| 82 | import java.io.PrintWriter; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 83 | import java.util.ArrayList; |
Zhentao Sun | 04f9740 | 2015-08-26 17:37:30 -0700 | [diff] [blame] | 84 | import java.util.List; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 85 | import java.util.function.Consumer; |
Zhentao Sun | 04f9740 | 2015-08-26 17:37:30 -0700 | [diff] [blame] | 86 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 87 | public class NotificationPanelView extends PanelView implements |
Jason Monk | 8b9d67f | 2016-03-02 08:59:08 -0500 | [diff] [blame] | 88 | ExpandableView.OnHeightChangedListener, |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 89 | View.OnClickListener, NotificationStackScrollLayout.OnOverscrollTopChangedListener, |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 90 | KeyguardAffordanceHelper.Callback, NotificationStackScrollLayout.OnEmptySpaceClickListener, |
Selim Cinek | a7d4f82 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 91 | OnHeadsUpChangedListener, QS.HeightListener { |
Chet Haase | 4d179dc | 2012-08-22 07:14:42 -0700 | [diff] [blame] | 92 | |
Jorim Jaggi | 58bef33 | 2014-11-21 18:10:32 +0100 | [diff] [blame] | 93 | private static final boolean DEBUG = false; |
| 94 | |
Selim Cinek | f99d000 | 2014-06-13 07:36:01 +0200 | [diff] [blame] | 95 | // Cap and total height of Roboto font. Needs to be adjusted when font for the big clock is |
| 96 | // changed. |
| 97 | private static final int CAP_HEIGHT = 1456; |
| 98 | private static final int FONT_HEIGHT = 2163; |
| 99 | |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 100 | private static final float LOCK_ICON_ACTIVE_SCALE = 1.2f; |
Selim Cinek | a02fe52 | 2014-05-30 17:01:21 +0200 | [diff] [blame] | 101 | |
Doris Ling | 3c00afb | 2016-07-19 17:04:21 -0700 | [diff] [blame] | 102 | static final String COUNTER_PANEL_OPEN = "panel_open"; |
| 103 | static final String COUNTER_PANEL_OPEN_QS = "panel_open_qs"; |
Chris Wren | 49f06f5 | 2015-05-01 16:12:12 -0400 | [diff] [blame] | 104 | private static final String COUNTER_PANEL_OPEN_PEEK = "panel_open_peek"; |
| 105 | |
Jorim Jaggi | 613f55f | 2015-07-16 15:30:10 -0700 | [diff] [blame] | 106 | private static final Rect mDummyDirtyRect = new Rect(0, 0, 1, 1); |
| 107 | |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 108 | public static final long DOZE_ANIMATION_DURATION = 700; |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 109 | |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 110 | private static final AnimationProperties CLOCK_ANIMATION_PROPERTIES = new AnimationProperties() |
| 111 | .setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD); |
Adrian Roos | 52414e3 | 2017-04-28 09:23:19 -0700 | [diff] [blame] | 112 | private static final FloatProperty<NotificationPanelView> SET_DARK_AMOUNT_PROPERTY = |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 113 | new FloatProperty<NotificationPanelView>("mInterpolatedDarkAmount") { |
| 114 | |
Adrian Roos | 52414e3 | 2017-04-28 09:23:19 -0700 | [diff] [blame] | 115 | @Override |
| 116 | public void setValue(NotificationPanelView object, float value) { |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 117 | object.setDarkAmount(value, object.mDarkInterpolator.getInterpolation(value)); |
Adrian Roos | 52414e3 | 2017-04-28 09:23:19 -0700 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | @Override |
| 121 | public Float get(NotificationPanelView object) { |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 122 | return object.mLinearDarkAmount; |
Adrian Roos | 52414e3 | 2017-04-28 09:23:19 -0700 | [diff] [blame] | 123 | } |
| 124 | }; |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 125 | |
| 126 | private Interpolator mDarkInterpolator; |
Selim Cinek | e64f52a | 2017-08-24 14:48:38 -0700 | [diff] [blame] | 127 | private final PowerManager mPowerManager; |
Phil Weaver | 428e397 | 2018-01-18 12:50:05 -0800 | [diff] [blame] | 128 | private final AccessibilityManager mAccessibilityManager; |
Adrian Roos | 52414e3 | 2017-04-28 09:23:19 -0700 | [diff] [blame] | 129 | |
Adrian Roos | e31f30e | 2017-01-25 14:48:15 -0800 | [diff] [blame] | 130 | private KeyguardAffordanceHelper mAffordanceHelper; |
Jorim Jaggi | bf1899e | 2014-08-07 02:04:18 +0200 | [diff] [blame] | 131 | private KeyguardUserSwitcher mKeyguardUserSwitcher; |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 132 | private KeyguardStatusBarView mKeyguardStatusBar; |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 133 | private QS mQs; |
| 134 | private FrameLayout mQsFrame; |
Jorim Jaggi | d09def751 | 2014-09-02 18:36:45 +0200 | [diff] [blame] | 135 | private KeyguardStatusView mKeyguardStatusView; |
Jorim Jaggi | dd5b886 | 2014-08-05 21:04:39 +0200 | [diff] [blame] | 136 | private View mQsNavbarScrim; |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 137 | protected NotificationsQuickSettingsContainer mNotificationContainerParent; |
Xiaohui Chen | 9528f43 | 2016-02-12 15:03:18 -0800 | [diff] [blame] | 138 | protected NotificationStackScrollLayout mNotificationStackScroller; |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 139 | private boolean mAnimateNextPositionUpdate; |
Chet Haase | 4d179dc | 2012-08-22 07:14:42 -0700 | [diff] [blame] | 140 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 141 | private int mTrackingPointer; |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 142 | private VelocityTracker mQsVelocityTracker; |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 143 | private boolean mQsTracking; |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 144 | |
| 145 | /** |
Jorim Jaggi | dc96d63 | 2014-07-01 18:48:52 +0200 | [diff] [blame] | 146 | * If set, the ongoing touch gesture might both trigger the expansion in {@link PanelView} and |
| 147 | * the expansion for quick settings. |
| 148 | */ |
| 149 | private boolean mConflictingQsExpansionGesture; |
| 150 | |
| 151 | /** |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 152 | * Whether we are currently handling a motion gesture in #onInterceptTouchEvent, but haven't |
| 153 | * intercepted yet. |
| 154 | */ |
| 155 | private boolean mIntercepting; |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 156 | private boolean mPanelExpanded; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 157 | private boolean mQsExpanded; |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 158 | private boolean mQsExpandedWhenExpandingStarted; |
John Spurlock | bc3a5e9 | 2014-05-30 16:20:05 -0400 | [diff] [blame] | 159 | private boolean mQsFullyExpanded; |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 160 | private boolean mKeyguardShowing; |
John Spurlock | d54da8a | 2014-08-03 23:23:52 -0400 | [diff] [blame] | 161 | private boolean mDozing; |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 162 | private boolean mDozingOnDown; |
Jiaquan He | 92bce83 | 2016-05-11 10:30:01 -0700 | [diff] [blame] | 163 | protected int mStatusBarState; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 164 | private float mInitialHeightOnTouch; |
| 165 | private float mInitialTouchX; |
| 166 | private float mInitialTouchY; |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 167 | private float mLastTouchX; |
| 168 | private float mLastTouchY; |
Xiaohui Chen | 9528f43 | 2016-02-12 15:03:18 -0800 | [diff] [blame] | 169 | protected float mQsExpansionHeight; |
| 170 | protected int mQsMinExpansionHeight; |
| 171 | protected int mQsMaxExpansionHeight; |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 172 | private int mQsPeekHeight; |
Lucas Dupin | 4c2aa39 | 2018-03-28 18:00:45 -0700 | [diff] [blame] | 173 | private int mBouncerTop; |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 174 | private boolean mStackScrollerOverscrolling; |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 175 | private boolean mQsExpansionFromOverscroll; |
Jorim Jaggi | 11c071a | 2014-08-14 19:17:11 +0200 | [diff] [blame] | 176 | private float mLastOverscroll; |
Muyuan Li | 5969004 | 2016-03-23 16:45:16 -0700 | [diff] [blame] | 177 | protected boolean mQsExpansionEnabled = true; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 178 | private ValueAnimator mQsExpansionAnimator; |
Jorim Jaggi | 87cd5e7 | 2014-05-12 23:29:10 +0200 | [diff] [blame] | 179 | private FlingAnimationUtils mFlingAnimationUtils; |
Selim Cinek | 9dbbca8 | 2014-05-15 15:23:37 +0200 | [diff] [blame] | 180 | private int mStatusBarMinHeight; |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 181 | private boolean mUnlockIconActive; |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 182 | private int mNotificationsHeaderCollideDistance; |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 183 | private int mUnlockMoveDistance; |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 184 | private float mEmptyDragAmount; |
John Spurlock | 3e04cc8 | 2014-05-30 12:34:03 -0400 | [diff] [blame] | 185 | |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 186 | private KeyguardClockPositionAlgorithm mClockPositionAlgorithm = |
| 187 | new KeyguardClockPositionAlgorithm(); |
| 188 | private KeyguardClockPositionAlgorithm.Result mClockPositionResult = |
| 189 | new KeyguardClockPositionAlgorithm.Result(); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 190 | private boolean mIsExpanding; |
Selim Cinek | f99d000 | 2014-06-13 07:36:01 +0200 | [diff] [blame] | 191 | |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 192 | private boolean mBlockTouches; |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 193 | // Used for two finger gesture as well as accessibility shortcut to QS. |
| 194 | private boolean mQsExpandImmediate; |
Jorim Jaggi | 1e2554b | 2014-07-10 23:07:00 +0200 | [diff] [blame] | 195 | private boolean mTwoFingerQsExpandPossible; |
Jorim Jaggi | 5630625 | 2014-07-03 00:40:09 +0200 | [diff] [blame] | 196 | |
| 197 | /** |
| 198 | * If we are in a panel collapsing motion, we reset scrollY of our scroll view but still |
| 199 | * need to take this into account in our panel height calculation. |
| 200 | */ |
Jorim Jaggi | bd00310 | 2014-07-04 00:02:42 +0200 | [diff] [blame] | 201 | private boolean mQsAnimatorExpand; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 202 | private boolean mIsLaunchTransitionFinished; |
| 203 | private boolean mIsLaunchTransitionRunning; |
| 204 | private Runnable mLaunchAnimationEndRunnable; |
| 205 | private boolean mOnlyAffordanceInThisMotion; |
Jorim Jaggi | 6ff837a | 2014-07-31 21:46:39 +0200 | [diff] [blame] | 206 | private boolean mKeyguardStatusViewAnimating; |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 207 | private ValueAnimator mQsSizeChangeAnimator; |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 208 | |
Selim Cinek | 24176c3 | 2017-03-01 16:50:30 -0800 | [diff] [blame] | 209 | private boolean mShowEmptyShadeView; |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 210 | |
Jorim Jaggi | dd5b886 | 2014-08-05 21:04:39 +0200 | [diff] [blame] | 211 | private boolean mQsScrimEnabled = true; |
Selim Cinek | 90c9465 | 2014-08-18 16:46:22 +0200 | [diff] [blame] | 212 | private boolean mLastAnnouncementWasQuickSettings; |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 213 | private boolean mQsTouchAboveFalsingThreshold; |
| 214 | private int mQsFalsingThreshold; |
Jorim Jaggi | dd5b886 | 2014-08-05 21:04:39 +0200 | [diff] [blame] | 215 | |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 216 | private float mKeyguardStatusBarAnimateAlpha = 1f; |
Jorim Jaggi | 0a81822 | 2014-11-10 19:04:34 +0100 | [diff] [blame] | 217 | private int mOldLayoutDirection; |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 218 | private HeadsUpTouchHelper mHeadsUpTouchHelper; |
| 219 | private boolean mIsExpansionFromHeadsUp; |
Selim Cinek | 79d79c4 | 2015-05-21 16:14:45 -0700 | [diff] [blame] | 220 | private boolean mListenForHeadsUp; |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 221 | private int mNavigationBarBottomHeight; |
Selim Cinek | d228115 | 2015-04-10 14:37:46 -0700 | [diff] [blame] | 222 | private boolean mExpandingFromHeadsUp; |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 223 | private boolean mCollapsedOnDown; |
Jorim Jaggi | 6d4a27f | 2015-04-20 16:01:53 -0700 | [diff] [blame] | 224 | private int mPositionMinSideMargin; |
Selim Cinek | a981d08 | 2016-08-03 14:45:31 -0700 | [diff] [blame] | 225 | private int mMaxFadeoutHeight; |
Jorim Jaggi | 6d4a27f | 2015-04-20 16:01:53 -0700 | [diff] [blame] | 226 | private int mLastOrientation = -1; |
Selim Cinek | bbc580b | 2015-06-03 14:11:03 +0200 | [diff] [blame] | 227 | private boolean mClosingWithAlphaFadeOut; |
Selim Cinek | 0fccc72 | 2015-07-29 17:04:36 -0700 | [diff] [blame] | 228 | private boolean mHeadsUpAnimatingAway; |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 229 | private boolean mLaunchingAffordance; |
Lucas Dupin | 193677c | 2018-06-11 19:16:03 -0700 | [diff] [blame] | 230 | private boolean mAffordanceHasPreview; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 231 | private FalsingManager mFalsingManager; |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 232 | private String mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_AFFORDANCE; |
Jorim Jaggi | 6d4a27f | 2015-04-20 16:01:53 -0700 | [diff] [blame] | 233 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 234 | private Runnable mHeadsUpExistenceChangedRunnable = new Runnable() { |
| 235 | @Override |
| 236 | public void run() { |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 237 | setHeadsUpAnimatingAway(false); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 238 | notifyBarPanelExpansionChanged(); |
| 239 | } |
| 240 | }; |
Selim Cinek | 53f8e7d | 2016-03-25 02:28:01 -0700 | [diff] [blame] | 241 | private NotificationGroupManager mGroupManager; |
Selim Cinek | 24176c3 | 2017-03-01 16:50:30 -0800 | [diff] [blame] | 242 | private boolean mShowIconsWhenExpanded; |
Selim Cinek | 378053a | 2016-12-07 15:41:28 -0800 | [diff] [blame] | 243 | private int mIndicationBottomPadding; |
Adrian Roos | 75fa964 | 2017-04-18 11:34:56 -0700 | [diff] [blame] | 244 | private int mAmbientIndicationBottomPadding; |
Selim Cinek | fcff4c6 | 2016-12-27 14:26:06 +0100 | [diff] [blame] | 245 | private boolean mIsFullWidth; |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 246 | |
| 247 | /** |
| 248 | * Current dark amount that follows regular interpolation curve of animation. |
| 249 | */ |
| 250 | private float mInterpolatedDarkAmount; |
| 251 | |
| 252 | /** |
| 253 | * Dark amount that animates from 0 to 1 or vice-versa in linear manner, even if the |
| 254 | * interpolation curve is different. |
| 255 | */ |
| 256 | private float mLinearDarkAmount; |
| 257 | |
Adrian Roos | 51465ea | 2017-07-27 13:57:35 +0200 | [diff] [blame] | 258 | private float mDarkAmountTarget; |
Lucas Dupin | 5605734 | 2018-04-10 11:49:18 -0700 | [diff] [blame] | 259 | private boolean mPulsing; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 260 | private LockscreenGestureLogger mLockscreenGestureLogger = new LockscreenGestureLogger(); |
Selim Cinek | 24176c3 | 2017-03-01 16:50:30 -0800 | [diff] [blame] | 261 | private boolean mNoVisibleNotifications = true; |
Adrian Roos | 52414e3 | 2017-04-28 09:23:19 -0700 | [diff] [blame] | 262 | private ValueAnimator mDarkAnimator; |
Lucas Dupin | 987f193 | 2017-05-13 21:02:52 -0700 | [diff] [blame] | 263 | private boolean mUserSetupComplete; |
Selim Cinek | d7768f4 | 2017-11-22 06:43:44 -0800 | [diff] [blame] | 264 | private int mQsNotificationTopPadding; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 265 | private float mExpandOffset; |
| 266 | private boolean mHideIconsDuringNotificationLaunch = true; |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 267 | private int mStackScrollerMeasuringPass; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 268 | private ArrayList<Consumer<ExpandableNotificationRow>> mTrackingHeadsUpListeners |
| 269 | = new ArrayList<>(); |
Selim Cinek | 60ffea6 | 2018-03-22 13:16:44 -0700 | [diff] [blame] | 270 | private ArrayList<Runnable> mVerticalTranslationListener = new ArrayList<>(); |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 271 | private HeadsUpAppearanceController mHeadsUpAppearanceController; |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 272 | |
shawnlin | 4ef7ca5 | 2018-05-11 16:44:42 +0800 | [diff] [blame] | 273 | private int mPanelAlpha; |
| 274 | private int mCurrentPanelAlpha; |
| 275 | private final Paint mAlphaPaint = new Paint(); |
| 276 | private Runnable mPanelAlphaEndAction; |
| 277 | private AnimatorListenerAdapter mAnimatorListenerAdapter = new AnimatorListenerAdapter() { |
| 278 | @Override |
| 279 | public void onAnimationEnd(Animator animation) { |
| 280 | if (mPanelAlphaEndAction != null) { |
| 281 | mPanelAlphaEndAction.run(); |
| 282 | } |
| 283 | } |
| 284 | }; |
| 285 | private final AnimatableProperty PANEL_ALPHA = AnimatableProperty.from( |
| 286 | "panelAlpha", |
| 287 | NotificationPanelView::setPanelAlphaInternal, |
| 288 | NotificationPanelView::getCurrentPanelAlpha, |
| 289 | R.id.panel_alpha_animator_tag, |
| 290 | R.id.panel_alpha_animator_start_tag, |
| 291 | R.id.panel_alpha_animator_end_tag); |
| 292 | private final AnimationProperties PANEL_ALPHA_OUT_PROPERTIES = new AnimationProperties() |
| 293 | .setDuration(150) |
| 294 | .setCustomInterpolator(PANEL_ALPHA.getProperty(), Interpolators.ALPHA_OUT); |
| 295 | private final AnimationProperties PANEL_ALPHA_IN_PROPERTIES = new AnimationProperties() |
| 296 | .setDuration(200) |
| 297 | .setAnimationFinishListener(mAnimatorListenerAdapter) |
| 298 | .setCustomInterpolator(PANEL_ALPHA.getProperty(), Interpolators.ALPHA_IN); |
| 299 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 300 | public NotificationPanelView(Context context, AttributeSet attrs) { |
| 301 | super(context, attrs); |
Jorim Jaggi | 58bef33 | 2014-11-21 18:10:32 +0100 | [diff] [blame] | 302 | setWillNotDraw(!DEBUG); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 303 | mFalsingManager = FalsingManager.getInstance(context); |
Selim Cinek | e64f52a | 2017-08-24 14:48:38 -0700 | [diff] [blame] | 304 | mPowerManager = context.getSystemService(PowerManager.class); |
Phil Weaver | 428e397 | 2018-01-18 12:50:05 -0800 | [diff] [blame] | 305 | mAccessibilityManager = context.getSystemService(AccessibilityManager.class); |
| 306 | setAccessibilityPaneTitle(determineAccessibilityPaneTitle()); |
shawnlin | 4ef7ca5 | 2018-05-11 16:44:42 +0800 | [diff] [blame] | 307 | mAlphaPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY)); |
| 308 | setPanelAlpha(255, false /* animate */); |
Daniel Sandler | 13522a2 | 2012-09-27 14:46:58 -0400 | [diff] [blame] | 309 | } |
Chet Haase | 4d179dc | 2012-08-22 07:14:42 -0700 | [diff] [blame] | 310 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 311 | public void setStatusBar(StatusBar bar) { |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 312 | mStatusBar = bar; |
Lucas Dupin | 987f193 | 2017-05-13 21:02:52 -0700 | [diff] [blame] | 313 | mKeyguardBottomArea.setStatusBar(mStatusBar); |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 314 | } |
| 315 | |
Daniel Sandler | 13522a2 | 2012-09-27 14:46:58 -0400 | [diff] [blame] | 316 | @Override |
| 317 | protected void onFinishInflate() { |
| 318 | super.onFinishInflate(); |
Alan Viverette | 51efddb | 2017-04-05 10:00:01 -0400 | [diff] [blame] | 319 | mKeyguardStatusBar = findViewById(R.id.keyguard_header); |
| 320 | mKeyguardStatusView = findViewById(R.id.keyguard_status_view); |
Jason Monk | d075b21 | 2016-05-25 12:30:51 -0400 | [diff] [blame] | 321 | |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 322 | mNotificationContainerParent = findViewById(R.id.notification_container_parent); |
| 323 | mNotificationStackScroller = findViewById(R.id.notification_stack_scroller); |
Jason Monk | d075b21 | 2016-05-25 12:30:51 -0400 | [diff] [blame] | 324 | mNotificationStackScroller.setOnHeightChangedListener(this); |
| 325 | mNotificationStackScroller.setOverscrollTopChangedListener(this); |
| 326 | mNotificationStackScroller.setOnEmptySpaceClickListener(this); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 327 | addTrackingHeadsUpListener(mNotificationStackScroller::setTrackingHeadsUp); |
Alan Viverette | 51efddb | 2017-04-05 10:00:01 -0400 | [diff] [blame] | 328 | mKeyguardBottomArea = findViewById(R.id.keyguard_bottom_area); |
Jason Monk | d075b21 | 2016-05-25 12:30:51 -0400 | [diff] [blame] | 329 | mQsNavbarScrim = findViewById(R.id.qs_navbar_scrim); |
Jason Monk | d075b21 | 2016-05-25 12:30:51 -0400 | [diff] [blame] | 330 | mLastOrientation = getResources().getConfiguration().orientation; |
| 331 | |
Lucas Dupin | 987f193 | 2017-05-13 21:02:52 -0700 | [diff] [blame] | 332 | initBottomArea(); |
| 333 | |
Alan Viverette | 51efddb | 2017-04-05 10:00:01 -0400 | [diff] [blame] | 334 | mQsFrame = findViewById(R.id.qs_frame); |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 335 | } |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 336 | |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 337 | @Override |
| 338 | protected void onAttachedToWindow() { |
| 339 | super.onAttachedToWindow(); |
| 340 | FragmentHostManager.get(this).addTagListener(QS.TAG, mFragmentListener); |
| 341 | } |
| 342 | |
| 343 | @Override |
| 344 | protected void onDetachedFromWindow() { |
| 345 | super.onDetachedFromWindow(); |
| 346 | FragmentHostManager.get(this).removeTagListener(QS.TAG, mFragmentListener); |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | @Override |
| 350 | protected void loadDimens() { |
| 351 | super.loadDimens(); |
Jorim Jaggi | 1d48069 | 2014-05-20 19:41:58 +0200 | [diff] [blame] | 352 | mFlingAnimationUtils = new FlingAnimationUtils(getContext(), 0.4f); |
Selim Cinek | 9dbbca8 | 2014-05-15 15:23:37 +0200 | [diff] [blame] | 353 | mStatusBarMinHeight = getResources().getDimensionPixelSize( |
| 354 | com.android.internal.R.dimen.status_bar_height); |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 355 | mQsPeekHeight = getResources().getDimensionPixelSize(R.dimen.qs_peek_height); |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 356 | mNotificationsHeaderCollideDistance = |
| 357 | getResources().getDimensionPixelSize(R.dimen.header_notifications_collide_distance); |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 358 | mUnlockMoveDistance = getResources().getDimensionPixelOffset(R.dimen.unlock_move_distance); |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 359 | mClockPositionAlgorithm.loadDimens(getResources()); |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 360 | mQsFalsingThreshold = getResources().getDimensionPixelSize( |
| 361 | R.dimen.qs_falsing_threshold); |
Jorim Jaggi | 6d4a27f | 2015-04-20 16:01:53 -0700 | [diff] [blame] | 362 | mPositionMinSideMargin = getResources().getDimensionPixelSize( |
| 363 | R.dimen.notification_panel_min_side_margin); |
Selim Cinek | a981d08 | 2016-08-03 14:45:31 -0700 | [diff] [blame] | 364 | mMaxFadeoutHeight = getResources().getDimensionPixelSize( |
| 365 | R.dimen.max_notification_fadeout_height); |
Selim Cinek | 378053a | 2016-12-07 15:41:28 -0800 | [diff] [blame] | 366 | mIndicationBottomPadding = getResources().getDimensionPixelSize( |
| 367 | R.dimen.keyguard_indication_bottom_padding); |
Selim Cinek | d7768f4 | 2017-11-22 06:43:44 -0800 | [diff] [blame] | 368 | mQsNotificationTopPadding = getResources().getDimensionPixelSize( |
Selim Cinek | b95fd18 | 2017-12-21 13:03:32 -0800 | [diff] [blame] | 369 | R.dimen.qs_notification_padding); |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 370 | } |
| 371 | |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 372 | public void updateResources() { |
Anthony Chen | 04d1ea7 | 2017-04-21 14:30:11 -0700 | [diff] [blame] | 373 | Resources res = getResources(); |
| 374 | int qsWidth = res.getDimensionPixelSize(R.dimen.qs_panel_width); |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 375 | int panelGravity = getResources().getInteger(R.integer.notification_panel_layout_gravity); |
Jason Monk | 845b3b9 | 2016-03-10 14:38:13 -0500 | [diff] [blame] | 376 | FrameLayout.LayoutParams lp = |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 377 | (FrameLayout.LayoutParams) mQsFrame.getLayoutParams(); |
Anthony Chen | 04d1ea7 | 2017-04-21 14:30:11 -0700 | [diff] [blame] | 378 | if (lp.width != qsWidth || lp.gravity != panelGravity) { |
| 379 | lp.width = qsWidth; |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 380 | lp.gravity = panelGravity; |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 381 | mQsFrame.setLayoutParams(lp); |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 382 | } |
| 383 | |
Anthony Chen | 04d1ea7 | 2017-04-21 14:30:11 -0700 | [diff] [blame] | 384 | int panelWidth = res.getDimensionPixelSize(R.dimen.notification_panel_width); |
Jorim Jaggi | bf1899e | 2014-08-07 02:04:18 +0200 | [diff] [blame] | 385 | lp = (FrameLayout.LayoutParams) mNotificationStackScroller.getLayoutParams(); |
Selim Cinek | 9e87cba | 2017-02-17 13:01:01 -0800 | [diff] [blame] | 386 | if (lp.width != panelWidth || lp.gravity != panelGravity) { |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 387 | lp.width = panelWidth; |
| 388 | lp.gravity = panelGravity; |
Jorim Jaggi | bf1899e | 2014-08-07 02:04:18 +0200 | [diff] [blame] | 389 | mNotificationStackScroller.setLayoutParams(lp); |
| 390 | } |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 391 | } |
| 392 | |
Lucas Dupin | 8c51ce2 | 2017-11-21 13:21:05 -0800 | [diff] [blame] | 393 | public void onThemeChanged() { |
Lucas Dupin | 987f193 | 2017-05-13 21:02:52 -0700 | [diff] [blame] | 394 | // Re-inflate the status view group. |
| 395 | int index = indexOfChild(mKeyguardStatusView); |
| 396 | removeView(mKeyguardStatusView); |
| 397 | mKeyguardStatusView = (KeyguardStatusView) LayoutInflater.from(mContext).inflate( |
| 398 | R.layout.keyguard_status_view, |
| 399 | this, |
| 400 | false); |
| 401 | addView(mKeyguardStatusView, index); |
| 402 | |
| 403 | // Update keyguard bottom area |
| 404 | index = indexOfChild(mKeyguardBottomArea); |
| 405 | removeView(mKeyguardBottomArea); |
| 406 | mKeyguardBottomArea = (KeyguardBottomAreaView) LayoutInflater.from(mContext).inflate( |
| 407 | R.layout.keyguard_bottom_area, |
| 408 | this, |
| 409 | false); |
| 410 | addView(mKeyguardBottomArea, index); |
| 411 | initBottomArea(); |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 412 | setDarkAmount(mLinearDarkAmount, mInterpolatedDarkAmount); |
Jason Monk | bd9745a | 2017-07-06 16:03:01 -0400 | [diff] [blame] | 413 | |
| 414 | setKeyguardStatusViewVisibility(mStatusBarState, false, false); |
| 415 | setKeyguardBottomAreaVisibility(mStatusBarState, false); |
Lucas Dupin | 987f193 | 2017-05-13 21:02:52 -0700 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | private void initBottomArea() { |
| 419 | mAffordanceHelper = new KeyguardAffordanceHelper(this, getContext()); |
| 420 | mKeyguardBottomArea.setAffordanceHelper(mAffordanceHelper); |
| 421 | mKeyguardBottomArea.setStatusBar(mStatusBar); |
| 422 | mKeyguardBottomArea.setUserSetupComplete(mUserSetupComplete); |
| 423 | } |
| 424 | |
| 425 | public void setKeyguardIndicationController(KeyguardIndicationController indicationController) { |
| 426 | mKeyguardBottomArea.setKeyguardIndicationController(indicationController); |
| 427 | } |
| 428 | |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 429 | @Override |
| 430 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
| 431 | super.onLayout(changed, left, top, right, bottom); |
Selim Cinek | fcff4c6 | 2016-12-27 14:26:06 +0100 | [diff] [blame] | 432 | setIsFullWidth(mNotificationStackScroller.getWidth() == getWidth()); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 433 | |
Selim Cinek | f99d000 | 2014-06-13 07:36:01 +0200 | [diff] [blame] | 434 | // Update Clock Pivot |
| 435 | mKeyguardStatusView.setPivotX(getWidth() / 2); |
Lucas Dupin | 987f193 | 2017-05-13 21:02:52 -0700 | [diff] [blame] | 436 | mKeyguardStatusView.setPivotY((FONT_HEIGHT - CAP_HEIGHT) / 2048f * |
| 437 | mKeyguardStatusView.getClockTextSize()); |
Selim Cinek | f99d000 | 2014-06-13 07:36:01 +0200 | [diff] [blame] | 438 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 439 | // Calculate quick setting heights. |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 440 | int oldMaxHeight = mQsMaxExpansionHeight; |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 441 | if (mQs != null) { |
| 442 | mQsMinExpansionHeight = mKeyguardShowing ? 0 : mQs.getQsMinExpansionHeight(); |
| 443 | mQsMaxExpansionHeight = mQs.getDesiredHeight(); |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 444 | mNotificationStackScroller.setMaxTopPadding( |
| 445 | mQsMaxExpansionHeight + mQsNotificationTopPadding); |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 446 | } |
Selim Cinek | 237a701 | 2014-09-10 18:12:18 +0200 | [diff] [blame] | 447 | positionClockAndNotifications(); |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 448 | if (mQsExpanded && mQsFullyExpanded) { |
| 449 | mQsExpansionHeight = mQsMaxExpansionHeight; |
| 450 | requestScrollerTopPaddingUpdate(false /* animate */); |
| 451 | requestPanelHeightUpdate(); |
| 452 | |
| 453 | // Size has changed, start an animation. |
| 454 | if (mQsMaxExpansionHeight != oldMaxHeight) { |
| 455 | startQsSizeChangeAnimation(oldMaxHeight, mQsMaxExpansionHeight); |
John Spurlock | bc3a5e9 | 2014-05-30 16:20:05 -0400 | [diff] [blame] | 456 | } |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 457 | } else if (!mQsExpanded) { |
Jorim Jaggi | 11c071a | 2014-08-14 19:17:11 +0200 | [diff] [blame] | 458 | setQsExpansion(mQsMinExpansionHeight + mLastOverscroll); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 459 | } |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 460 | updateExpandedHeight(getExpandedHeight()); |
Jorim Jaggi | 0bc4917 | 2014-11-03 15:52:13 +0100 | [diff] [blame] | 461 | updateHeader(); |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 462 | |
| 463 | // If we are running a size change animation, the animation takes care of the height of |
| 464 | // the container. However, if we are not animating, we always need to make the QS container |
| 465 | // the desired height so when closing the QS detail, it stays smaller after the size change |
| 466 | // animation is finished but the detail view is still being animated away (this animation |
| 467 | // takes longer than the size change animation). |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 468 | if (mQsSizeChangeAnimator == null && mQs != null) { |
| 469 | mQs.setHeightOverride(mQs.getDesiredHeight()); |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 470 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 471 | updateMaxHeadsUpTranslation(); |
Jorim Jaggi | 98fb09c | 2014-05-01 22:40:56 +0200 | [diff] [blame] | 472 | } |
| 473 | |
Selim Cinek | fcff4c6 | 2016-12-27 14:26:06 +0100 | [diff] [blame] | 474 | private void setIsFullWidth(boolean isFullWidth) { |
| 475 | mIsFullWidth = isFullWidth; |
| 476 | mNotificationStackScroller.setIsFullWidth(isFullWidth); |
| 477 | } |
| 478 | |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 479 | private void startQsSizeChangeAnimation(int oldHeight, final int newHeight) { |
| 480 | if (mQsSizeChangeAnimator != null) { |
| 481 | oldHeight = (int) mQsSizeChangeAnimator.getAnimatedValue(); |
| 482 | mQsSizeChangeAnimator.cancel(); |
| 483 | } |
| 484 | mQsSizeChangeAnimator = ValueAnimator.ofInt(oldHeight, newHeight); |
| 485 | mQsSizeChangeAnimator.setDuration(300); |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 486 | mQsSizeChangeAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 487 | mQsSizeChangeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { |
| 488 | @Override |
| 489 | public void onAnimationUpdate(ValueAnimator animation) { |
| 490 | requestScrollerTopPaddingUpdate(false /* animate */); |
| 491 | requestPanelHeightUpdate(); |
| 492 | int height = (int) mQsSizeChangeAnimator.getAnimatedValue(); |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 493 | mQs.setHeightOverride(height); |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 494 | } |
| 495 | }); |
| 496 | mQsSizeChangeAnimator.addListener(new AnimatorListenerAdapter() { |
| 497 | @Override |
| 498 | public void onAnimationEnd(Animator animation) { |
| 499 | mQsSizeChangeAnimator = null; |
| 500 | } |
| 501 | }); |
| 502 | mQsSizeChangeAnimator.start(); |
| 503 | } |
| 504 | |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 505 | /** |
| 506 | * Positions the clock and notifications dynamically depending on how many notifications are |
| 507 | * showing. |
| 508 | */ |
| 509 | private void positionClockAndNotifications() { |
Selim Cinek | f99d000 | 2014-06-13 07:36:01 +0200 | [diff] [blame] | 510 | boolean animate = mNotificationStackScroller.isAddOrRemoveAnimationPending(); |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 511 | boolean animateClock = animate || mAnimateNextPositionUpdate; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 512 | int stackScrollerPadding; |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 513 | if (mStatusBarState != StatusBarState.KEYGUARD) { |
Selim Cinek | b95fd18 | 2017-12-21 13:03:32 -0800 | [diff] [blame] | 514 | stackScrollerPadding = (mQs != null ? mQs.getHeader().getHeight() : 0) + mQsPeekHeight |
| 515 | + mQsNotificationTopPadding; |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 516 | } else { |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 517 | int totalHeight = getHeight(); |
| 518 | int bottomPadding = Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding); |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 519 | mClockPositionAlgorithm.setup( |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 520 | mStatusBarMinHeight, |
| 521 | totalHeight - bottomPadding, |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 522 | mNotificationStackScroller.getIntrinsicContentHeight(), |
| 523 | getExpandedFraction(), |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 524 | totalHeight, |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 525 | mKeyguardStatusView.getHeight(), |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 526 | mInterpolatedDarkAmount, |
Selim Cinek | dbf172e | 2018-08-08 18:31:45 +0000 | [diff] [blame^] | 527 | mStatusBar.isKeyguardCurrentlySecure(), |
Lucas Dupin | 5605734 | 2018-04-10 11:49:18 -0700 | [diff] [blame] | 528 | mPulsing, |
Lucas Dupin | 4c2aa39 | 2018-03-28 18:00:45 -0700 | [diff] [blame] | 529 | mBouncerTop); |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 530 | mClockPositionAlgorithm.run(mClockPositionResult); |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 531 | PropertyAnimator.setProperty(mKeyguardStatusView, AnimatableProperty.X, |
| 532 | mClockPositionResult.clockX, CLOCK_ANIMATION_PROPERTIES, animateClock); |
| 533 | PropertyAnimator.setProperty(mKeyguardStatusView, AnimatableProperty.Y, |
| 534 | mClockPositionResult.clockY, CLOCK_ANIMATION_PROPERTIES, animateClock); |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 535 | updateClock(); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 536 | stackScrollerPadding = mClockPositionResult.stackScrollerPadding; |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 537 | } |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 538 | mNotificationStackScroller.setIntrinsicPadding(stackScrollerPadding); |
Lucas Dupin | 0cd882f | 2018-01-30 12:19:49 -0800 | [diff] [blame] | 539 | mNotificationStackScroller.setAntiBurnInOffsetX(mClockPositionResult.clockX); |
Lucas Dupin | 4272f44 | 2018-01-13 22:00:35 -0800 | [diff] [blame] | 540 | mKeyguardBottomArea.setBurnInXOffset(mClockPositionResult.clockX); |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 541 | |
| 542 | mStackScrollerMeasuringPass++; |
Selim Cinek | f99d000 | 2014-06-13 07:36:01 +0200 | [diff] [blame] | 543 | requestScrollerTopPaddingUpdate(animate); |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 544 | mStackScrollerMeasuringPass = 0; |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 545 | mAnimateNextPositionUpdate = false; |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 546 | } |
| 547 | |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 548 | /** |
| 549 | * @param maximum the maximum to return at most |
| 550 | * @return the maximum keyguard notifications that can fit on the screen |
| 551 | */ |
| 552 | public int computeMaxKeyguardNotifications(int maximum) { |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 553 | float minPadding = mClockPositionAlgorithm.getMinStackScrollerPadding(); |
Selim Cinek | cacc604 | 2016-01-21 16:16:41 -0800 | [diff] [blame] | 554 | int notificationPadding = Math.max(1, getResources().getDimensionPixelSize( |
| 555 | R.dimen.notification_divider_height)); |
Anthony Chen | 9e05d46 | 2017-04-07 10:10:21 -0700 | [diff] [blame] | 556 | NotificationShelf shelf = mNotificationStackScroller.getNotificationShelf(); |
| 557 | float shelfSize = shelf.getVisibility() == GONE ? 0 |
| 558 | : shelf.getIntrinsicHeight() + notificationPadding; |
Selim Cinek | 378053a | 2016-12-07 15:41:28 -0800 | [diff] [blame] | 559 | float availableSpace = mNotificationStackScroller.getHeight() - minPadding - shelfSize |
Alex Chau | ff7653d | 2018-02-01 17:18:08 +0000 | [diff] [blame] | 560 | - Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding) |
| 561 | - mKeyguardStatusView.getLogoutButtonHeight(); |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 562 | int count = 0; |
| 563 | for (int i = 0; i < mNotificationStackScroller.getChildCount(); i++) { |
| 564 | ExpandableView child = (ExpandableView) mNotificationStackScroller.getChildAt(i); |
| 565 | if (!(child instanceof ExpandableNotificationRow)) { |
| 566 | continue; |
| 567 | } |
Selim Cinek | fa760d4 | 2016-05-10 15:50:53 -0400 | [diff] [blame] | 568 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
Selim Cinek | 53f8e7d | 2016-03-25 02:28:01 -0700 | [diff] [blame] | 569 | boolean suppressedSummary = mGroupManager.isSummaryOfSuppressedGroup( |
Selim Cinek | fa760d4 | 2016-05-10 15:50:53 -0400 | [diff] [blame] | 570 | row.getStatusBarNotification()); |
Selim Cinek | 53f8e7d | 2016-03-25 02:28:01 -0700 | [diff] [blame] | 571 | if (suppressedSummary) { |
| 572 | continue; |
| 573 | } |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 574 | if (!mStatusBar.getNotificationLockscreenUserManager().shouldShowOnKeyguard( |
| 575 | row.getStatusBarNotification())) { |
Selim Cinek | fa760d4 | 2016-05-10 15:50:53 -0400 | [diff] [blame] | 576 | continue; |
| 577 | } |
| 578 | if (row.isRemoved()) { |
| 579 | continue; |
| 580 | } |
Selim Cinek | eb3fc3d | 2017-09-15 13:37:14 -0700 | [diff] [blame] | 581 | availableSpace -= child.getMinHeight(true /* ignoreTemporaryStates */) |
| 582 | + notificationPadding; |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 583 | if (availableSpace >= 0 && count < maximum) { |
| 584 | count++; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 585 | } else if (availableSpace > -shelfSize) { |
| 586 | // if we are exactly the last view, then we can show us still! |
| 587 | for (int j = i + 1; j < mNotificationStackScroller.getChildCount(); j++) { |
| 588 | if (mNotificationStackScroller.getChildAt(j) |
| 589 | instanceof ExpandableNotificationRow) { |
| 590 | return count; |
| 591 | } |
| 592 | } |
| 593 | count++; |
| 594 | return count; |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 595 | } else { |
| 596 | return count; |
| 597 | } |
| 598 | } |
| 599 | return count; |
| 600 | } |
| 601 | |
Lucas Dupin | 4c2aa39 | 2018-03-28 18:00:45 -0700 | [diff] [blame] | 602 | public void setBouncerTop(int bouncerTop) { |
| 603 | mBouncerTop = bouncerTop; |
| 604 | positionClockAndNotifications(); |
| 605 | } |
| 606 | |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 607 | private void updateClock() { |
Jorim Jaggi | 6ff837a | 2014-07-31 21:46:39 +0200 | [diff] [blame] | 608 | if (!mKeyguardStatusViewAnimating) { |
Lucas Dupin | 78db090 | 2018-02-24 19:42:06 -0800 | [diff] [blame] | 609 | mKeyguardStatusView.setAlpha(mClockPositionResult.clockAlpha); |
Jorim Jaggi | 6ff837a | 2014-07-31 21:46:39 +0200 | [diff] [blame] | 610 | } |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 611 | } |
| 612 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 613 | public void animateToFullShade(long delay) { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 614 | mNotificationStackScroller.goToFullShade(delay); |
Jorim Jaggi | 98fb09c | 2014-05-01 22:40:56 +0200 | [diff] [blame] | 615 | requestLayout(); |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 616 | mAnimateNextPositionUpdate = true; |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 617 | } |
| 618 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 619 | public void setQsExpansionEnabled(boolean qsExpansionEnabled) { |
| 620 | mQsExpansionEnabled = qsExpansionEnabled; |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 621 | if (mQs == null) return; |
| 622 | mQs.setHeaderClickable(qsExpansionEnabled); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 623 | } |
| 624 | |
Selim Cinek | 3c4635c | 2014-05-29 02:12:47 +0200 | [diff] [blame] | 625 | @Override |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 626 | public void resetViews() { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 627 | mIsLaunchTransitionFinished = false; |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 628 | mBlockTouches = false; |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 629 | mUnlockIconActive = false; |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 630 | if (!mLaunchingAffordance) { |
Adrian Roos | e31f30e | 2017-01-25 14:48:15 -0800 | [diff] [blame] | 631 | mAffordanceHelper.reset(false); |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 632 | mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_AFFORDANCE; |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 633 | } |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 634 | closeQs(); |
Eliot Courtney | 47098cb | 2017-10-18 17:30:30 +0900 | [diff] [blame] | 635 | mStatusBar.getGutsManager().closeAndSaveGuts(true /* leavebehind */, true /* force */, |
Mady Mellor | c2dbe49 | 2017-03-30 13:22:03 -0700 | [diff] [blame] | 636 | true /* controls */, -1 /* x */, -1 /* y */, true /* resetMenu */); |
Jorim Jaggi | dbbf45e | 2014-06-25 21:54:48 +0200 | [diff] [blame] | 637 | mNotificationStackScroller.setOverScrollAmount(0f, true /* onTop */, false /* animate */, |
| 638 | true /* cancelAnimators */); |
Selim Cinek | b24e0a9 | 2015-06-09 20:17:30 -0700 | [diff] [blame] | 639 | mNotificationStackScroller.resetScrollPosition(); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 640 | } |
| 641 | |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 642 | @Override |
| 643 | public void collapse(boolean delayed, float speedUpFactor) { |
| 644 | if (!canPanelBeCollapsed()) { |
| 645 | return; |
| 646 | } |
| 647 | |
| 648 | if (mQsExpanded) { |
| 649 | mQsExpandImmediate = true; |
| 650 | mNotificationStackScroller.setShouldShowShelfOnly(true); |
| 651 | } |
| 652 | super.collapse(delayed, speedUpFactor); |
| 653 | } |
| 654 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 655 | public void closeQs() { |
Selim Cinek | 831941f | 2015-06-17 15:09:30 -0700 | [diff] [blame] | 656 | cancelQsAnimation(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 657 | setQsExpansion(mQsMinExpansionHeight); |
| 658 | } |
| 659 | |
Jorim Jaggi | bd00310 | 2014-07-04 00:02:42 +0200 | [diff] [blame] | 660 | public void animateCloseQs() { |
| 661 | if (mQsExpansionAnimator != null) { |
| 662 | if (!mQsAnimatorExpand) { |
| 663 | return; |
| 664 | } |
| 665 | float height = mQsExpansionHeight; |
| 666 | mQsExpansionAnimator.cancel(); |
| 667 | setQsExpansion(height); |
| 668 | } |
| 669 | flingSettings(0 /* vel */, false); |
| 670 | } |
| 671 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 672 | public void openQs() { |
Selim Cinek | 831941f | 2015-06-17 15:09:30 -0700 | [diff] [blame] | 673 | cancelQsAnimation(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 674 | if (mQsExpansionEnabled) { |
| 675 | setQsExpansion(mQsMaxExpansionHeight); |
| 676 | } |
| 677 | } |
| 678 | |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 679 | public void expandWithQs() { |
| 680 | if (mQsExpansionEnabled) { |
| 681 | mQsExpandImmediate = true; |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 682 | mNotificationStackScroller.setShouldShowShelfOnly(true); |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 683 | } |
Oren Blasberg | 8d3fea1 | 2015-07-10 14:21:44 -0700 | [diff] [blame] | 684 | expand(true /* animate */); |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 685 | } |
| 686 | |
Eugene Susla | 2de6955 | 2018-03-20 13:22:17 -0700 | [diff] [blame] | 687 | public void expandWithoutQs() { |
| 688 | if (isQsExpanded()) { |
| 689 | flingSettings(0 /* velocity */, false /* expand */); |
| 690 | } else { |
| 691 | expand(true /* animate */); |
| 692 | } |
| 693 | } |
| 694 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 695 | @Override |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 696 | public void fling(float vel, boolean expand) { |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 697 | GestureRecorder gr = ((PhoneStatusBarView) mBar).mBar.getGestureRecorder(); |
| 698 | if (gr != null) { |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 699 | gr.tag("fling " + ((vel > 0) ? "open" : "closed"), "notifications,v=" + vel); |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 700 | } |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 701 | super.fling(vel, expand); |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 702 | } |
Chet Haase | 4d179dc | 2012-08-22 07:14:42 -0700 | [diff] [blame] | 703 | |
Casey Burkhardt | 23b0a4e | 2013-04-29 12:18:32 -0700 | [diff] [blame] | 704 | @Override |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 705 | protected void flingToHeight(float vel, boolean expand, float target, |
Selim Cinek | 9db7105 | 2015-04-24 18:54:30 -0700 | [diff] [blame] | 706 | float collapseSpeedUpFactor, boolean expandBecauseOfFalsing) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 707 | mHeadsUpTouchHelper.notifyFling(!expand); |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 708 | setClosingWithAlphaFadeout(!expand && getFadeoutAlpha() == 1.0f); |
Selim Cinek | 9db7105 | 2015-04-24 18:54:30 -0700 | [diff] [blame] | 709 | super.flingToHeight(vel, expand, target, collapseSpeedUpFactor, expandBecauseOfFalsing); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 710 | } |
| 711 | |
| 712 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 713 | public boolean onInterceptTouchEvent(MotionEvent event) { |
Jason Monk | 231b052 | 2018-01-04 10:49:55 -0500 | [diff] [blame] | 714 | if (mBlockTouches || mQsFullyExpanded && mQs.onInterceptTouchEvent(event)) { |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 715 | return false; |
| 716 | } |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 717 | initDownStates(event); |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 718 | if (mBar.panelEnabled() && mHeadsUpTouchHelper.onInterceptTouchEvent(event)) { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 719 | mIsExpansionFromHeadsUp = true; |
Chris Wren | 49f06f5 | 2015-05-01 16:12:12 -0400 | [diff] [blame] | 720 | MetricsLogger.count(mContext, COUNTER_PANEL_OPEN, 1); |
| 721 | MetricsLogger.count(mContext, COUNTER_PANEL_OPEN_PEEK, 1); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 722 | return true; |
| 723 | } |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 724 | |
Anthony Chen | 54daefe | 2017-04-07 17:19:54 -0700 | [diff] [blame] | 725 | if (!isFullyCollapsed() && onQsIntercept(event)) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 726 | return true; |
| 727 | } |
| 728 | return super.onInterceptTouchEvent(event); |
| 729 | } |
| 730 | |
| 731 | private boolean onQsIntercept(MotionEvent event) { |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 732 | int pointerIndex = event.findPointerIndex(mTrackingPointer); |
| 733 | if (pointerIndex < 0) { |
| 734 | pointerIndex = 0; |
| 735 | mTrackingPointer = event.getPointerId(pointerIndex); |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 736 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 737 | final float x = event.getX(pointerIndex); |
| 738 | final float y = event.getY(pointerIndex); |
| 739 | |
| 740 | switch (event.getActionMasked()) { |
| 741 | case MotionEvent.ACTION_DOWN: |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 742 | mIntercepting = true; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 743 | mInitialTouchY = y; |
| 744 | mInitialTouchX = x; |
| 745 | initVelocityTracker(); |
| 746 | trackMovement(event); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 747 | if (shouldQuickSettingsIntercept(mInitialTouchX, mInitialTouchY, 0)) { |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 748 | getParent().requestDisallowInterceptTouchEvent(true); |
| 749 | } |
Jorim Jaggi | 5404542 | 2014-07-03 18:30:40 +0200 | [diff] [blame] | 750 | if (mQsExpansionAnimator != null) { |
| 751 | onQsExpansionStarted(); |
| 752 | mInitialHeightOnTouch = mQsExpansionHeight; |
| 753 | mQsTracking = true; |
| 754 | mIntercepting = false; |
Geoffrey Pitsch | 409db27 | 2017-08-28 14:51:52 +0000 | [diff] [blame] | 755 | mNotificationStackScroller.cancelLongPress(); |
Jorim Jaggi | 5404542 | 2014-07-03 18:30:40 +0200 | [diff] [blame] | 756 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 757 | break; |
| 758 | case MotionEvent.ACTION_POINTER_UP: |
| 759 | final int upPointer = event.getPointerId(event.getActionIndex()); |
| 760 | if (mTrackingPointer == upPointer) { |
| 761 | // gesture is ongoing, find a new pointer to track |
| 762 | final int newIndex = event.getPointerId(0) != upPointer ? 0 : 1; |
| 763 | mTrackingPointer = event.getPointerId(newIndex); |
| 764 | mInitialTouchX = event.getX(newIndex); |
| 765 | mInitialTouchY = event.getY(newIndex); |
| 766 | } |
| 767 | break; |
| 768 | |
| 769 | case MotionEvent.ACTION_MOVE: |
| 770 | final float h = y - mInitialTouchY; |
| 771 | trackMovement(event); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 772 | if (mQsTracking) { |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 773 | |
| 774 | // Already tracking because onOverscrolled was called. We need to update here |
| 775 | // so we don't stop for a frame until the next touch event gets handled in |
| 776 | // onTouchEvent. |
| 777 | setQsExpansion(h + mInitialHeightOnTouch); |
| 778 | trackMovement(event); |
| 779 | mIntercepting = false; |
| 780 | return true; |
| 781 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 782 | if (Math.abs(h) > mTouchSlop && Math.abs(h) > Math.abs(x - mInitialTouchX) |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 783 | && shouldQuickSettingsIntercept(mInitialTouchX, mInitialTouchY, h)) { |
Jorim Jaggi | 58bef33 | 2014-11-21 18:10:32 +0100 | [diff] [blame] | 784 | mQsTracking = true; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 785 | onQsExpansionStarted(); |
Jorim Jaggi | 26aa04c | 2015-07-29 14:52:22 -0700 | [diff] [blame] | 786 | notifyExpandingFinished(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 787 | mInitialHeightOnTouch = mQsExpansionHeight; |
| 788 | mInitialTouchY = y; |
| 789 | mInitialTouchX = x; |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 790 | mIntercepting = false; |
Geoffrey Pitsch | 409db27 | 2017-08-28 14:51:52 +0000 | [diff] [blame] | 791 | mNotificationStackScroller.cancelLongPress(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 792 | return true; |
| 793 | } |
| 794 | break; |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 795 | |
| 796 | case MotionEvent.ACTION_CANCEL: |
| 797 | case MotionEvent.ACTION_UP: |
Jorim Jaggi | c9a52ab | 2014-05-12 23:46:19 +0200 | [diff] [blame] | 798 | trackMovement(event); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 799 | if (mQsTracking) { |
Chris Wren | 49f06f5 | 2015-05-01 16:12:12 -0400 | [diff] [blame] | 800 | flingQsWithCurrentVelocity(y, |
Jorim Jaggi | aea80f4 | 2014-11-10 22:41:54 +0100 | [diff] [blame] | 801 | event.getActionMasked() == MotionEvent.ACTION_CANCEL); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 802 | mQsTracking = false; |
Jorim Jaggi | c9a52ab | 2014-05-12 23:46:19 +0200 | [diff] [blame] | 803 | } |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 804 | mIntercepting = false; |
| 805 | break; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 806 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 807 | return false; |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 808 | } |
| 809 | |
Selim Cinek | ab1dc95 | 2014-10-30 20:20:29 +0100 | [diff] [blame] | 810 | @Override |
| 811 | protected boolean isInContentBounds(float x, float y) { |
Selim Cinek | ab1dc95 | 2014-10-30 20:20:29 +0100 | [diff] [blame] | 812 | float stackScrollerX = mNotificationStackScroller.getX(); |
Selim Cinek | 04fb258 | 2015-06-02 19:58:09 +0200 | [diff] [blame] | 813 | return !mNotificationStackScroller.isBelowLastNotification(x - stackScrollerX, y) |
| 814 | && stackScrollerX < x && x < stackScrollerX + mNotificationStackScroller.getWidth(); |
Selim Cinek | ab1dc95 | 2014-10-30 20:20:29 +0100 | [diff] [blame] | 815 | } |
| 816 | |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 817 | private void initDownStates(MotionEvent event) { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 818 | if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { |
| 819 | mOnlyAffordanceInThisMotion = false; |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 820 | mQsTouchAboveFalsingThreshold = mQsFullyExpanded; |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 821 | mDozingOnDown = isDozing(); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 822 | mCollapsedOnDown = isFullyCollapsed(); |
Selim Cinek | 79d79c4 | 2015-05-21 16:14:45 -0700 | [diff] [blame] | 823 | mListenForHeadsUp = mCollapsedOnDown && mHeadsUpManager.hasPinnedHeadsUp(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 824 | } |
| 825 | } |
| 826 | |
Chris Wren | 49f06f5 | 2015-05-01 16:12:12 -0400 | [diff] [blame] | 827 | private void flingQsWithCurrentVelocity(float y, boolean isCancelMotionEvent) { |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 828 | float vel = getCurrentQSVelocity(); |
Chris Wren | 49f06f5 | 2015-05-01 16:12:12 -0400 | [diff] [blame] | 829 | final boolean expandsQs = flingExpandsQs(vel); |
| 830 | if (expandsQs) { |
| 831 | logQsSwipeDown(y); |
| 832 | } |
| 833 | flingSettings(vel, expandsQs && !isCancelMotionEvent); |
| 834 | } |
| 835 | |
| 836 | private void logQsSwipeDown(float y) { |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 837 | float vel = getCurrentQSVelocity(); |
Chris Wren | 49f06f5 | 2015-05-01 16:12:12 -0400 | [diff] [blame] | 838 | final int gesture = mStatusBarState == StatusBarState.KEYGUARD |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 839 | ? MetricsEvent.ACTION_LS_QS |
| 840 | : MetricsEvent.ACTION_SHADE_QS_PULL; |
| 841 | mLockscreenGestureLogger.write(gesture, |
Chris Wren | 49f06f5 | 2015-05-01 16:12:12 -0400 | [diff] [blame] | 842 | (int) ((y - mInitialTouchY) / mStatusBar.getDisplayDensity()), |
| 843 | (int) (vel / mStatusBar.getDisplayDensity())); |
Jorim Jaggi | c9a52ab | 2014-05-12 23:46:19 +0200 | [diff] [blame] | 844 | } |
| 845 | |
Jorim Jaggi | dc96d63 | 2014-07-01 18:48:52 +0200 | [diff] [blame] | 846 | private boolean flingExpandsQs(float vel) { |
Blazej Magnowski | 6dc59b4 | 2015-09-22 15:14:20 -0700 | [diff] [blame] | 847 | if (isFalseTouch()) { |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 848 | return false; |
| 849 | } |
Jorim Jaggi | dc96d63 | 2014-07-01 18:48:52 +0200 | [diff] [blame] | 850 | if (Math.abs(vel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) { |
| 851 | return getQsExpansionFraction() > 0.5f; |
| 852 | } else { |
| 853 | return vel > 0; |
| 854 | } |
| 855 | } |
| 856 | |
Blazej Magnowski | 6dc59b4 | 2015-09-22 15:14:20 -0700 | [diff] [blame] | 857 | private boolean isFalseTouch() { |
Adrian Roos | 6a70b88 | 2016-04-19 17:09:07 -0700 | [diff] [blame] | 858 | if (!needsAntiFalsing()) { |
Blazej Magnowski | 6dc59b4 | 2015-09-22 15:14:20 -0700 | [diff] [blame] | 859 | return false; |
| 860 | } |
| 861 | if (mFalsingManager.isClassiferEnabled()) { |
| 862 | return mFalsingManager.isFalseTouch(); |
| 863 | } |
| 864 | return !mQsTouchAboveFalsingThreshold; |
Selim Cinek | 5386fb3 | 2014-09-03 16:37:36 +0200 | [diff] [blame] | 865 | } |
| 866 | |
Jorim Jaggi | dc96d63 | 2014-07-01 18:48:52 +0200 | [diff] [blame] | 867 | private float getQsExpansionFraction() { |
Jorim Jaggi | 11c071a | 2014-08-14 19:17:11 +0200 | [diff] [blame] | 868 | return Math.min(1f, (mQsExpansionHeight - mQsMinExpansionHeight) |
Selim Cinek | d7768f4 | 2017-11-22 06:43:44 -0800 | [diff] [blame] | 869 | / (mQsMaxExpansionHeight - mQsMinExpansionHeight)); |
Jorim Jaggi | dc96d63 | 2014-07-01 18:48:52 +0200 | [diff] [blame] | 870 | } |
Jorim Jaggi | 5404542 | 2014-07-03 18:30:40 +0200 | [diff] [blame] | 871 | |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 872 | @Override |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 873 | protected float getOpeningHeight() { |
Selim Cinek | fcff4c6 | 2016-12-27 14:26:06 +0100 | [diff] [blame] | 874 | return mNotificationStackScroller.getOpeningHeight(); |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 875 | } |
| 876 | |
| 877 | @Override |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 878 | public boolean onTouchEvent(MotionEvent event) { |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 879 | if (mBlockTouches || (mQs != null && mQs.isCustomizing())) { |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 880 | return false; |
| 881 | } |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 882 | initDownStates(event); |
Selim Cinek | 79d79c4 | 2015-05-21 16:14:45 -0700 | [diff] [blame] | 883 | if (mListenForHeadsUp && !mHeadsUpTouchHelper.isTrackingHeadsUp() |
| 884 | && mHeadsUpTouchHelper.onInterceptTouchEvent(event)) { |
| 885 | mIsExpansionFromHeadsUp = true; |
Selim Cinek | 79d79c4 | 2015-05-21 16:14:45 -0700 | [diff] [blame] | 886 | MetricsLogger.count(mContext, COUNTER_PANEL_OPEN_PEEK, 1); |
| 887 | } |
Adrian Roos | 8008bd1 | 2017-02-22 15:02:09 +0100 | [diff] [blame] | 888 | boolean handled = false; |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 889 | if ((!mIsExpanding || mHintAnimationRunning) |
| 890 | && !mQsExpanded |
Adrian Roos | 2a31841 | 2017-01-25 14:48:26 -0800 | [diff] [blame] | 891 | && mStatusBar.getBarState() != StatusBarState.SHADE |
| 892 | && !mDozing) { |
Adrian Roos | 8008bd1 | 2017-02-22 15:02:09 +0100 | [diff] [blame] | 893 | handled |= mAffordanceHelper.onTouchEvent(event); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 894 | } |
| 895 | if (mOnlyAffordanceInThisMotion) { |
| 896 | return true; |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 897 | } |
Adrian Roos | 8008bd1 | 2017-02-22 15:02:09 +0100 | [diff] [blame] | 898 | handled |= mHeadsUpTouchHelper.onTouchEvent(event); |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 899 | |
Anthony Chen | 54daefe | 2017-04-07 17:19:54 -0700 | [diff] [blame] | 900 | if (!mHeadsUpTouchHelper.isTrackingHeadsUp() && handleQsTouch(event)) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 901 | return true; |
| 902 | } |
Jorim Jaggi | 6d4a27f | 2015-04-20 16:01:53 -0700 | [diff] [blame] | 903 | if (event.getActionMasked() == MotionEvent.ACTION_DOWN && isFullyCollapsed()) { |
Chris Wren | 49f06f5 | 2015-05-01 16:12:12 -0400 | [diff] [blame] | 904 | MetricsLogger.count(mContext, COUNTER_PANEL_OPEN, 1); |
Jorim Jaggi | 6d4a27f | 2015-04-20 16:01:53 -0700 | [diff] [blame] | 905 | updateVerticalPanelPosition(event.getX()); |
Adrian Roos | 8008bd1 | 2017-02-22 15:02:09 +0100 | [diff] [blame] | 906 | handled = true; |
Jorim Jaggi | 6d4a27f | 2015-04-20 16:01:53 -0700 | [diff] [blame] | 907 | } |
Adrian Roos | 8008bd1 | 2017-02-22 15:02:09 +0100 | [diff] [blame] | 908 | handled |= super.onTouchEvent(event); |
| 909 | return mDozing ? handled : true; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 910 | } |
| 911 | |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 912 | private boolean handleQsTouch(MotionEvent event) { |
Mady Mellor | aaf32f6 | 2015-05-01 17:06:50 -0700 | [diff] [blame] | 913 | final int action = event.getActionMasked(); |
| 914 | if (action == MotionEvent.ACTION_DOWN && getExpandedFraction() == 1f |
Jorim Jaggi | 18bd04f | 2014-08-15 00:03:09 +0200 | [diff] [blame] | 915 | && mStatusBar.getBarState() != StatusBarState.KEYGUARD && !mQsExpanded |
| 916 | && mQsExpansionEnabled) { |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 917 | |
Jorim Jaggi | dc96d63 | 2014-07-01 18:48:52 +0200 | [diff] [blame] | 918 | // Down in the empty area while fully expanded - go to QS. |
| 919 | mQsTracking = true; |
| 920 | mConflictingQsExpansionGesture = true; |
| 921 | onQsExpansionStarted(); |
| 922 | mInitialHeightOnTouch = mQsExpansionHeight; |
| 923 | mInitialTouchY = event.getX(); |
| 924 | mInitialTouchX = event.getY(); |
| 925 | } |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 926 | if (!isFullyCollapsed()) { |
Jorim Jaggi | 853b070 | 2014-07-05 04:31:14 +0200 | [diff] [blame] | 927 | handleQsDown(event); |
| 928 | } |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 929 | if (!mQsExpandImmediate && mQsTracking) { |
Jorim Jaggi | dc96d63 | 2014-07-01 18:48:52 +0200 | [diff] [blame] | 930 | onQsTouch(event); |
| 931 | if (!mConflictingQsExpansionGesture) { |
| 932 | return true; |
| 933 | } |
| 934 | } |
Mady Mellor | aaf32f6 | 2015-05-01 17:06:50 -0700 | [diff] [blame] | 935 | if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) { |
Jorim Jaggi | dc96d63 | 2014-07-01 18:48:52 +0200 | [diff] [blame] | 936 | mConflictingQsExpansionGesture = false; |
| 937 | } |
Mady Mellor | aaf32f6 | 2015-05-01 17:06:50 -0700 | [diff] [blame] | 938 | if (action == MotionEvent.ACTION_DOWN && isFullyCollapsed() |
Jorim Jaggi | 18bd04f | 2014-08-15 00:03:09 +0200 | [diff] [blame] | 939 | && mQsExpansionEnabled) { |
Jorim Jaggi | 1e2554b | 2014-07-10 23:07:00 +0200 | [diff] [blame] | 940 | mTwoFingerQsExpandPossible = true; |
| 941 | } |
Mady Mellor | 3a4bc79 | 2015-05-27 09:10:22 -0700 | [diff] [blame] | 942 | if (mTwoFingerQsExpandPossible && isOpenQsEvent(event) |
Jorim Jaggi | 1e2554b | 2014-07-10 23:07:00 +0200 | [diff] [blame] | 943 | && event.getY(event.getActionIndex()) < mStatusBarMinHeight) { |
Chris Wren | 49f06f5 | 2015-05-01 16:12:12 -0400 | [diff] [blame] | 944 | MetricsLogger.count(mContext, COUNTER_PANEL_OPEN_QS, 1); |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 945 | mQsExpandImmediate = true; |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 946 | mNotificationStackScroller.setShouldShowShelfOnly(true); |
Jorim Jaggi | 1e2554b | 2014-07-10 23:07:00 +0200 | [diff] [blame] | 947 | requestPanelHeightUpdate(); |
Jorim Jaggi | 8599a33 | 2014-08-14 21:44:23 +0200 | [diff] [blame] | 948 | |
| 949 | // Normally, we start listening when the panel is expanded, but here we need to start |
| 950 | // earlier so the state is already up to date when dragging down. |
| 951 | setListening(true); |
Jorim Jaggi | 1e2554b | 2014-07-10 23:07:00 +0200 | [diff] [blame] | 952 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 953 | return false; |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 954 | } |
| 955 | |
Jorim Jaggi | e0640dd | 2014-08-05 23:12:40 +0200 | [diff] [blame] | 956 | private boolean isInQsArea(float x, float y) { |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 957 | return (x >= mQsFrame.getX() |
| 958 | && x <= mQsFrame.getX() + mQsFrame.getWidth()) |
Jason Monk | 85686d6 | 2016-03-29 12:34:28 -0400 | [diff] [blame] | 959 | && (y <= mNotificationStackScroller.getBottomMostNotificationBottom() |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 960 | || y <= mQs.getView().getY() + mQs.getView().getHeight()); |
Jorim Jaggi | e0640dd | 2014-08-05 23:12:40 +0200 | [diff] [blame] | 961 | } |
| 962 | |
Mady Mellor | 3a4bc79 | 2015-05-27 09:10:22 -0700 | [diff] [blame] | 963 | private boolean isOpenQsEvent(MotionEvent event) { |
| 964 | final int pointerCount = event.getPointerCount(); |
| 965 | final int action = event.getActionMasked(); |
| 966 | |
| 967 | final boolean twoFingerDrag = action == MotionEvent.ACTION_POINTER_DOWN |
| 968 | && pointerCount == 2; |
| 969 | |
| 970 | final boolean stylusButtonClickDrag = action == MotionEvent.ACTION_DOWN |
| 971 | && (event.isButtonPressed(MotionEvent.BUTTON_STYLUS_PRIMARY) |
| 972 | || event.isButtonPressed(MotionEvent.BUTTON_STYLUS_SECONDARY)); |
| 973 | |
| 974 | final boolean mouseButtonClickDrag = action == MotionEvent.ACTION_DOWN |
| 975 | && (event.isButtonPressed(MotionEvent.BUTTON_SECONDARY) |
| 976 | || event.isButtonPressed(MotionEvent.BUTTON_TERTIARY)); |
| 977 | |
| 978 | return twoFingerDrag || stylusButtonClickDrag || mouseButtonClickDrag; |
| 979 | } |
| 980 | |
Jorim Jaggi | 853b070 | 2014-07-05 04:31:14 +0200 | [diff] [blame] | 981 | private void handleQsDown(MotionEvent event) { |
| 982 | if (event.getActionMasked() == MotionEvent.ACTION_DOWN |
Jorim Jaggi | e0640dd | 2014-08-05 23:12:40 +0200 | [diff] [blame] | 983 | && shouldQuickSettingsIntercept(event.getX(), event.getY(), -1)) { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 984 | mFalsingManager.onQsDown(); |
Jorim Jaggi | 853b070 | 2014-07-05 04:31:14 +0200 | [diff] [blame] | 985 | mQsTracking = true; |
| 986 | onQsExpansionStarted(); |
| 987 | mInitialHeightOnTouch = mQsExpansionHeight; |
| 988 | mInitialTouchY = event.getX(); |
| 989 | mInitialTouchX = event.getY(); |
Jorim Jaggi | 8599a33 | 2014-08-14 21:44:23 +0200 | [diff] [blame] | 990 | |
| 991 | // If we interrupt an expansion gesture here, make sure to update the state correctly. |
Jorim Jaggi | 26aa04c | 2015-07-29 14:52:22 -0700 | [diff] [blame] | 992 | notifyExpandingFinished(); |
Jorim Jaggi | 853b070 | 2014-07-05 04:31:14 +0200 | [diff] [blame] | 993 | } |
| 994 | } |
| 995 | |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 996 | @Override |
Selim Cinek | 9db7105 | 2015-04-24 18:54:30 -0700 | [diff] [blame] | 997 | protected boolean flingExpands(float vel, float vectorVel, float x, float y) { |
| 998 | boolean expands = super.flingExpands(vel, vectorVel, x, y); |
Jorim Jaggi | dc96d63 | 2014-07-01 18:48:52 +0200 | [diff] [blame] | 999 | |
| 1000 | // If we are already running a QS expansion, make sure that we keep the panel open. |
| 1001 | if (mQsExpansionAnimator != null) { |
| 1002 | expands = true; |
| 1003 | } |
| 1004 | return expands; |
| 1005 | } |
| 1006 | |
| 1007 | @Override |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 1008 | protected boolean hasConflictingGestures() { |
| 1009 | return mStatusBar.getBarState() != StatusBarState.SHADE; |
| 1010 | } |
| 1011 | |
Selim Cinek | 9db7105 | 2015-04-24 18:54:30 -0700 | [diff] [blame] | 1012 | @Override |
| 1013 | protected boolean shouldGestureIgnoreXTouchSlop(float x, float y) { |
Adrian Roos | e31f30e | 2017-01-25 14:48:15 -0800 | [diff] [blame] | 1014 | return !mAffordanceHelper.isOnAffordanceIcon(x, y); |
Selim Cinek | 9db7105 | 2015-04-24 18:54:30 -0700 | [diff] [blame] | 1015 | } |
| 1016 | |
Jorim Jaggi | dc96d63 | 2014-07-01 18:48:52 +0200 | [diff] [blame] | 1017 | private void onQsTouch(MotionEvent event) { |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 1018 | int pointerIndex = event.findPointerIndex(mTrackingPointer); |
| 1019 | if (pointerIndex < 0) { |
| 1020 | pointerIndex = 0; |
| 1021 | mTrackingPointer = event.getPointerId(pointerIndex); |
| 1022 | } |
| 1023 | final float y = event.getY(pointerIndex); |
| 1024 | final float x = event.getX(pointerIndex); |
Chris Wren | 49f06f5 | 2015-05-01 16:12:12 -0400 | [diff] [blame] | 1025 | final float h = y - mInitialTouchY; |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 1026 | |
| 1027 | switch (event.getActionMasked()) { |
| 1028 | case MotionEvent.ACTION_DOWN: |
| 1029 | mQsTracking = true; |
| 1030 | mInitialTouchY = y; |
| 1031 | mInitialTouchX = x; |
| 1032 | onQsExpansionStarted(); |
| 1033 | mInitialHeightOnTouch = mQsExpansionHeight; |
| 1034 | initVelocityTracker(); |
| 1035 | trackMovement(event); |
| 1036 | break; |
| 1037 | |
| 1038 | case MotionEvent.ACTION_POINTER_UP: |
| 1039 | final int upPointer = event.getPointerId(event.getActionIndex()); |
| 1040 | if (mTrackingPointer == upPointer) { |
| 1041 | // gesture is ongoing, find a new pointer to track |
| 1042 | final int newIndex = event.getPointerId(0) != upPointer ? 0 : 1; |
| 1043 | final float newY = event.getY(newIndex); |
| 1044 | final float newX = event.getX(newIndex); |
| 1045 | mTrackingPointer = event.getPointerId(newIndex); |
| 1046 | mInitialHeightOnTouch = mQsExpansionHeight; |
| 1047 | mInitialTouchY = newY; |
| 1048 | mInitialTouchX = newX; |
| 1049 | } |
| 1050 | break; |
| 1051 | |
| 1052 | case MotionEvent.ACTION_MOVE: |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 1053 | setQsExpansion(h + mInitialHeightOnTouch); |
Selim Cinek | 34cf5c4 | 2014-09-26 15:39:00 +0200 | [diff] [blame] | 1054 | if (h >= getFalsingThreshold()) { |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 1055 | mQsTouchAboveFalsingThreshold = true; |
| 1056 | } |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 1057 | trackMovement(event); |
| 1058 | break; |
| 1059 | |
| 1060 | case MotionEvent.ACTION_UP: |
| 1061 | case MotionEvent.ACTION_CANCEL: |
| 1062 | mQsTracking = false; |
| 1063 | mTrackingPointer = -1; |
| 1064 | trackMovement(event); |
Selim Cinek | 84e6de7 | 2016-02-22 20:57:43 -0800 | [diff] [blame] | 1065 | float fraction = getQsExpansionFraction(); |
| 1066 | if (fraction != 0f || y >= mInitialTouchY) { |
| 1067 | flingQsWithCurrentVelocity(y, |
| 1068 | event.getActionMasked() == MotionEvent.ACTION_CANCEL); |
| 1069 | } |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 1070 | if (mQsVelocityTracker != null) { |
| 1071 | mQsVelocityTracker.recycle(); |
| 1072 | mQsVelocityTracker = null; |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 1073 | } |
| 1074 | break; |
| 1075 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1076 | } |
| 1077 | |
Selim Cinek | 34cf5c4 | 2014-09-26 15:39:00 +0200 | [diff] [blame] | 1078 | private int getFalsingThreshold() { |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 1079 | float factor = mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f; |
Selim Cinek | 34cf5c4 | 2014-09-26 15:39:00 +0200 | [diff] [blame] | 1080 | return (int) (mQsFalsingThreshold * factor); |
| 1081 | } |
| 1082 | |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 1083 | @Override |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1084 | public void onOverscrollTopChanged(float amount, boolean isRubberbanded) { |
Selim Cinek | 831941f | 2015-06-17 15:09:30 -0700 | [diff] [blame] | 1085 | cancelQsAnimation(); |
Jorim Jaggi | 18bd04f | 2014-08-15 00:03:09 +0200 | [diff] [blame] | 1086 | if (!mQsExpansionEnabled) { |
| 1087 | amount = 0f; |
| 1088 | } |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 1089 | float rounded = amount >= 1f ? amount : 0f; |
Jason Monk | e1be342 | 2016-02-09 10:51:40 -0500 | [diff] [blame] | 1090 | setOverScrolling(rounded != 0f && isRubberbanded); |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1091 | mQsExpansionFromOverscroll = rounded != 0f; |
Jorim Jaggi | 11c071a | 2014-08-14 19:17:11 +0200 | [diff] [blame] | 1092 | mLastOverscroll = rounded; |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 1093 | updateQsState(); |
Jorim Jaggi | 90e0df2 | 2014-07-30 01:10:35 +0200 | [diff] [blame] | 1094 | setQsExpansion(mQsMinExpansionHeight + rounded); |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 1095 | } |
| 1096 | |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 1097 | @Override |
| 1098 | public void flingTopOverscroll(float velocity, boolean open) { |
Jorim Jaggi | b7a3303 | 2014-08-20 16:21:36 +0200 | [diff] [blame] | 1099 | mLastOverscroll = 0f; |
Selim Cinek | f91de68 | 2016-05-11 13:01:02 -0400 | [diff] [blame] | 1100 | mQsExpansionFromOverscroll = false; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 1101 | setQsExpansion(mQsExpansionHeight); |
Jorim Jaggi | 18bd04f | 2014-08-15 00:03:09 +0200 | [diff] [blame] | 1102 | flingSettings(!mQsExpansionEnabled && open ? 0f : velocity, open && mQsExpansionEnabled, |
| 1103 | new Runnable() { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1104 | @Override |
| 1105 | public void run() { |
| 1106 | mStackScrollerOverscrolling = false; |
Jason Monk | e1be342 | 2016-02-09 10:51:40 -0500 | [diff] [blame] | 1107 | setOverScrolling(false); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1108 | updateQsState(); |
| 1109 | } |
Jorim Jaggi | 46ac19f | 2015-06-05 17:55:21 -0700 | [diff] [blame] | 1110 | }, false /* isClick */); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 1111 | } |
| 1112 | |
Jason Monk | e1be342 | 2016-02-09 10:51:40 -0500 | [diff] [blame] | 1113 | private void setOverScrolling(boolean overscrolling) { |
| 1114 | mStackScrollerOverscrolling = overscrolling; |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 1115 | if (mQs == null) return; |
| 1116 | mQs.setOverscrolling(overscrolling); |
Jason Monk | e1be342 | 2016-02-09 10:51:40 -0500 | [diff] [blame] | 1117 | } |
| 1118 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1119 | private void onQsExpansionStarted() { |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 1120 | onQsExpansionStarted(0); |
| 1121 | } |
| 1122 | |
Muyuan Li | 0e9f538 | 2016-04-27 15:51:15 -0700 | [diff] [blame] | 1123 | protected void onQsExpansionStarted(int overscrollAmount) { |
Selim Cinek | 831941f | 2015-06-17 15:09:30 -0700 | [diff] [blame] | 1124 | cancelQsAnimation(); |
| 1125 | cancelHeightAnimator(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1126 | |
| 1127 | // Reset scroll position and apply that position to the expanded height. |
Jason Monk | 16ac377 | 2016-02-10 15:39:21 -0500 | [diff] [blame] | 1128 | float height = mQsExpansionHeight - overscrollAmount; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1129 | setQsExpansion(height); |
Jorim Jaggi | 58bef33 | 2014-11-21 18:10:32 +0100 | [diff] [blame] | 1130 | requestPanelHeightUpdate(); |
Mady Mellor | c2dbe49 | 2017-03-30 13:22:03 -0700 | [diff] [blame] | 1131 | mNotificationStackScroller.checkSnoozeLeavebehind(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1132 | } |
| 1133 | |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 1134 | private void setQsExpanded(boolean expanded) { |
| 1135 | boolean changed = mQsExpanded != expanded; |
| 1136 | if (changed) { |
| 1137 | mQsExpanded = expanded; |
| 1138 | updateQsState(); |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 1139 | requestPanelHeightUpdate(); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 1140 | mFalsingManager.setQsExpanded(expanded); |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 1141 | mStatusBar.setQsExpanded(expanded); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1142 | mNotificationContainerParent.setQsExpanded(expanded); |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 1143 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1144 | } |
| 1145 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1146 | public void setBarState(int statusBarState, boolean keyguardFadingAway, |
| 1147 | boolean goingToFullShade) { |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1148 | int oldState = mStatusBarState; |
| 1149 | boolean keyguardShowing = statusBarState == StatusBarState.KEYGUARD; |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1150 | setKeyguardStatusViewVisibility(statusBarState, keyguardFadingAway, goingToFullShade); |
| 1151 | setKeyguardBottomAreaVisibility(statusBarState, goingToFullShade); |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1152 | |
| 1153 | mStatusBarState = statusBarState; |
| 1154 | mKeyguardShowing = keyguardShowing; |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 1155 | if (mQs != null) { |
| 1156 | mQs.setKeyguardShowing(mKeyguardShowing); |
| 1157 | } |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1158 | |
Selim Cinek | 5f2ca6b | 2016-10-07 14:45:55 -0400 | [diff] [blame] | 1159 | if (oldState == StatusBarState.KEYGUARD |
| 1160 | && (goingToFullShade || statusBarState == StatusBarState.SHADE_LOCKED)) { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1161 | animateKeyguardStatusBarOut(); |
Jason Monk | e1be342 | 2016-02-09 10:51:40 -0500 | [diff] [blame] | 1162 | long delay = mStatusBarState == StatusBarState.SHADE_LOCKED |
| 1163 | ? 0 : mStatusBar.calculateGoingToFullShadeDelay(); |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 1164 | mQs.animateHeaderSlidingIn(delay); |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1165 | } else if (oldState == StatusBarState.SHADE_LOCKED |
| 1166 | && statusBarState == StatusBarState.KEYGUARD) { |
| 1167 | animateKeyguardStatusBarIn(StackStateAnimator.ANIMATION_DURATION_STANDARD); |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 1168 | mQs.animateHeaderSlidingOut(); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1169 | } else { |
| 1170 | mKeyguardStatusBar.setAlpha(1f); |
| 1171 | mKeyguardStatusBar.setVisibility(keyguardShowing ? View.VISIBLE : View.INVISIBLE); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 1172 | if (keyguardShowing && oldState != mStatusBarState) { |
Selim Cinek | 5f14502 | 2016-08-02 16:00:12 -0700 | [diff] [blame] | 1173 | mKeyguardBottomArea.onKeyguardShowingChanged(); |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 1174 | if (mQs != null) { |
| 1175 | mQs.hideImmediately(); |
| 1176 | } |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 1177 | } |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1178 | } |
Jorim Jaggi | 0e0942d | 2015-06-05 14:12:20 -0700 | [diff] [blame] | 1179 | if (keyguardShowing) { |
| 1180 | updateDozingVisibilities(false /* animate */); |
| 1181 | } |
Jorim Jaggi | 6d4a27f | 2015-04-20 16:01:53 -0700 | [diff] [blame] | 1182 | resetVerticalPanelPosition(); |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 1183 | updateQsState(); |
| 1184 | } |
| 1185 | |
Jorim Jaggi | 6ff837a | 2014-07-31 21:46:39 +0200 | [diff] [blame] | 1186 | private final Runnable mAnimateKeyguardStatusViewInvisibleEndRunnable = new Runnable() { |
| 1187 | @Override |
| 1188 | public void run() { |
| 1189 | mKeyguardStatusViewAnimating = false; |
Lucas Dupin | 9375255 | 2018-03-19 21:32:19 -0700 | [diff] [blame] | 1190 | mKeyguardStatusView.setVisibility(View.INVISIBLE); |
| 1191 | } |
| 1192 | }; |
| 1193 | |
| 1194 | private final Runnable mAnimateKeyguardStatusViewGoneEndRunnable = new Runnable() { |
| 1195 | @Override |
| 1196 | public void run() { |
| 1197 | mKeyguardStatusViewAnimating = false; |
Jorim Jaggi | 6ff837a | 2014-07-31 21:46:39 +0200 | [diff] [blame] | 1198 | mKeyguardStatusView.setVisibility(View.GONE); |
| 1199 | } |
| 1200 | }; |
| 1201 | |
| 1202 | private final Runnable mAnimateKeyguardStatusViewVisibleEndRunnable = new Runnable() { |
| 1203 | @Override |
| 1204 | public void run() { |
| 1205 | mKeyguardStatusViewAnimating = false; |
| 1206 | } |
| 1207 | }; |
| 1208 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1209 | private final Runnable mAnimateKeyguardStatusBarInvisibleEndRunnable = new Runnable() { |
| 1210 | @Override |
| 1211 | public void run() { |
| 1212 | mKeyguardStatusBar.setVisibility(View.INVISIBLE); |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 1213 | mKeyguardStatusBar.setAlpha(1f); |
| 1214 | mKeyguardStatusBarAnimateAlpha = 1f; |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1215 | } |
| 1216 | }; |
| 1217 | |
| 1218 | private void animateKeyguardStatusBarOut() { |
Jorim Jaggi | e4f1a20 | 2015-06-30 13:35:11 -0700 | [diff] [blame] | 1219 | ValueAnimator anim = ValueAnimator.ofFloat(mKeyguardStatusBar.getAlpha(), 0f); |
| 1220 | anim.addUpdateListener(mStatusBarAnimateAlphaListener); |
| 1221 | anim.setStartDelay(mStatusBar.isKeyguardFadingAway() |
| 1222 | ? mStatusBar.getKeyguardFadingAwayDelay() |
| 1223 | : 0); |
| 1224 | anim.setDuration(mStatusBar.isKeyguardFadingAway() |
| 1225 | ? mStatusBar.getKeyguardFadingAwayDuration() / 2 |
| 1226 | : StackStateAnimator.ANIMATION_DURATION_STANDARD); |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 1227 | anim.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN); |
Jorim Jaggi | e4f1a20 | 2015-06-30 13:35:11 -0700 | [diff] [blame] | 1228 | anim.addListener(new AnimatorListenerAdapter() { |
| 1229 | @Override |
| 1230 | public void onAnimationEnd(Animator animation) { |
| 1231 | mAnimateKeyguardStatusBarInvisibleEndRunnable.run(); |
| 1232 | } |
| 1233 | }); |
| 1234 | anim.start(); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1235 | } |
| 1236 | |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 1237 | private final ValueAnimator.AnimatorUpdateListener mStatusBarAnimateAlphaListener = |
| 1238 | new ValueAnimator.AnimatorUpdateListener() { |
| 1239 | @Override |
| 1240 | public void onAnimationUpdate(ValueAnimator animation) { |
Jorim Jaggi | e4f1a20 | 2015-06-30 13:35:11 -0700 | [diff] [blame] | 1241 | mKeyguardStatusBarAnimateAlpha = (float) animation.getAnimatedValue(); |
| 1242 | updateHeaderKeyguardAlpha(); |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 1243 | } |
| 1244 | }; |
| 1245 | |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1246 | private void animateKeyguardStatusBarIn(long duration) { |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 1247 | mKeyguardStatusBar.setVisibility(View.VISIBLE); |
| 1248 | mKeyguardStatusBar.setAlpha(0f); |
Jorim Jaggi | e4f1a20 | 2015-06-30 13:35:11 -0700 | [diff] [blame] | 1249 | ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f); |
| 1250 | anim.addUpdateListener(mStatusBarAnimateAlphaListener); |
| 1251 | anim.setDuration(duration); |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 1252 | anim.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN); |
Jorim Jaggi | e4f1a20 | 2015-06-30 13:35:11 -0700 | [diff] [blame] | 1253 | anim.start(); |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 1254 | } |
| 1255 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1256 | private final Runnable mAnimateKeyguardBottomAreaInvisibleEndRunnable = new Runnable() { |
| 1257 | @Override |
| 1258 | public void run() { |
| 1259 | mKeyguardBottomArea.setVisibility(View.GONE); |
| 1260 | } |
| 1261 | }; |
| 1262 | |
| 1263 | private void setKeyguardBottomAreaVisibility(int statusBarState, |
| 1264 | boolean goingToFullShade) { |
Xiaohui Chen | 9528f43 | 2016-02-12 15:03:18 -0800 | [diff] [blame] | 1265 | mKeyguardBottomArea.animate().cancel(); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1266 | if (goingToFullShade) { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1267 | mKeyguardBottomArea.animate() |
| 1268 | .alpha(0f) |
| 1269 | .setStartDelay(mStatusBar.getKeyguardFadingAwayDelay()) |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1270 | .setDuration(mStatusBar.getKeyguardFadingAwayDuration() / 2) |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 1271 | .setInterpolator(Interpolators.ALPHA_OUT) |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1272 | .withEndAction(mAnimateKeyguardBottomAreaInvisibleEndRunnable) |
| 1273 | .start(); |
| 1274 | } else if (statusBarState == StatusBarState.KEYGUARD |
| 1275 | || statusBarState == StatusBarState.SHADE_LOCKED) { |
Adrian Roos | 91ba307 | 2017-02-14 16:50:46 +0100 | [diff] [blame] | 1276 | mKeyguardBottomArea.setVisibility(View.VISIBLE); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1277 | mKeyguardBottomArea.setAlpha(1f); |
| 1278 | } else { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1279 | mKeyguardBottomArea.setVisibility(View.GONE); |
| 1280 | mKeyguardBottomArea.setAlpha(1f); |
| 1281 | } |
| 1282 | } |
| 1283 | |
| 1284 | private void setKeyguardStatusViewVisibility(int statusBarState, boolean keyguardFadingAway, |
| 1285 | boolean goingToFullShade) { |
Lucas Dupin | 9375255 | 2018-03-19 21:32:19 -0700 | [diff] [blame] | 1286 | mKeyguardStatusView.animate().cancel(); |
| 1287 | mKeyguardStatusViewAnimating = false; |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1288 | if ((!keyguardFadingAway && mStatusBarState == StatusBarState.KEYGUARD |
| 1289 | && statusBarState != StatusBarState.KEYGUARD) || goingToFullShade) { |
Jorim Jaggi | 6ff837a | 2014-07-31 21:46:39 +0200 | [diff] [blame] | 1290 | mKeyguardStatusViewAnimating = true; |
| 1291 | mKeyguardStatusView.animate() |
| 1292 | .alpha(0f) |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1293 | .setStartDelay(0) |
Jorim Jaggi | 6ff837a | 2014-07-31 21:46:39 +0200 | [diff] [blame] | 1294 | .setDuration(160) |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 1295 | .setInterpolator(Interpolators.ALPHA_OUT) |
Lucas Dupin | 9375255 | 2018-03-19 21:32:19 -0700 | [diff] [blame] | 1296 | .withEndAction(mAnimateKeyguardStatusViewGoneEndRunnable); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1297 | if (keyguardFadingAway) { |
| 1298 | mKeyguardStatusView.animate() |
| 1299 | .setStartDelay(mStatusBar.getKeyguardFadingAwayDelay()) |
| 1300 | .setDuration(mStatusBar.getKeyguardFadingAwayDuration()/2) |
| 1301 | .start(); |
| 1302 | } |
Jorim Jaggi | 6ff837a | 2014-07-31 21:46:39 +0200 | [diff] [blame] | 1303 | } else if (mStatusBarState == StatusBarState.SHADE_LOCKED |
| 1304 | && statusBarState == StatusBarState.KEYGUARD) { |
Jorim Jaggi | 6ff837a | 2014-07-31 21:46:39 +0200 | [diff] [blame] | 1305 | mKeyguardStatusView.setVisibility(View.VISIBLE); |
| 1306 | mKeyguardStatusViewAnimating = true; |
| 1307 | mKeyguardStatusView.setAlpha(0f); |
| 1308 | mKeyguardStatusView.animate() |
| 1309 | .alpha(1f) |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 1310 | .setStartDelay(0) |
Jorim Jaggi | 6ff837a | 2014-07-31 21:46:39 +0200 | [diff] [blame] | 1311 | .setDuration(320) |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 1312 | .setInterpolator(Interpolators.ALPHA_IN) |
Jorim Jaggi | 6ff837a | 2014-07-31 21:46:39 +0200 | [diff] [blame] | 1313 | .withEndAction(mAnimateKeyguardStatusViewVisibleEndRunnable); |
| 1314 | } else if (statusBarState == StatusBarState.KEYGUARD) { |
Lucas Dupin | 9375255 | 2018-03-19 21:32:19 -0700 | [diff] [blame] | 1315 | if (keyguardFadingAway) { |
| 1316 | mKeyguardStatusViewAnimating = true; |
| 1317 | mKeyguardStatusView.animate() |
| 1318 | .alpha(0) |
| 1319 | .translationYBy(-getHeight() * 0.05f) |
| 1320 | .setInterpolator(Interpolators.FAST_OUT_LINEAR_IN) |
| 1321 | .setDuration(125) |
| 1322 | .setStartDelay(0) |
| 1323 | .withEndAction(mAnimateKeyguardStatusViewInvisibleEndRunnable) |
| 1324 | .start(); |
| 1325 | } else { |
| 1326 | mKeyguardStatusView.setVisibility(View.VISIBLE); |
| 1327 | mKeyguardStatusView.setAlpha(1f); |
| 1328 | } |
Jorim Jaggi | 6ff837a | 2014-07-31 21:46:39 +0200 | [diff] [blame] | 1329 | } else { |
Jorim Jaggi | 6ff837a | 2014-07-31 21:46:39 +0200 | [diff] [blame] | 1330 | mKeyguardStatusView.setVisibility(View.GONE); |
| 1331 | mKeyguardStatusView.setAlpha(1f); |
| 1332 | } |
| 1333 | } |
| 1334 | |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 1335 | private void updateQsState() { |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 1336 | mNotificationStackScroller.setQsExpanded(mQsExpanded); |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 1337 | mNotificationStackScroller.setScrollingEnabled( |
| 1338 | mStatusBarState != StatusBarState.KEYGUARD && (!mQsExpanded |
| 1339 | || mQsExpansionFromOverscroll)); |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 1340 | updateEmptyShadeView(); |
Jorim Jaggi | dd5b886 | 2014-08-05 21:04:39 +0200 | [diff] [blame] | 1341 | mQsNavbarScrim.setVisibility(mStatusBarState == StatusBarState.SHADE && mQsExpanded |
| 1342 | && !mStackScrollerOverscrolling && mQsScrimEnabled |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1343 | ? View.VISIBLE |
| 1344 | : View.INVISIBLE); |
Jorim Jaggi | bf1899e | 2014-08-07 02:04:18 +0200 | [diff] [blame] | 1345 | if (mKeyguardUserSwitcher != null && mQsExpanded && !mStackScrollerOverscrolling) { |
Adrian Roos | 2d1ef30 | 2014-10-24 18:42:51 +0200 | [diff] [blame] | 1346 | mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */); |
Jorim Jaggi | bf1899e | 2014-08-07 02:04:18 +0200 | [diff] [blame] | 1347 | } |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 1348 | if (mQs == null) return; |
| 1349 | mQs.setExpanded(mQsExpanded); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1350 | } |
| 1351 | |
| 1352 | private void setQsExpansion(float height) { |
| 1353 | height = Math.min(Math.max(height, mQsMinExpansionHeight), mQsMaxExpansionHeight); |
Jason Monk | bd28a85b | 2015-02-10 13:29:02 -0500 | [diff] [blame] | 1354 | mQsFullyExpanded = height == mQsMaxExpansionHeight && mQsMaxExpansionHeight != 0; |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 1355 | if (height > mQsMinExpansionHeight && !mQsExpanded && !mStackScrollerOverscrolling) { |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 1356 | setQsExpanded(true); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1357 | } else if (height <= mQsMinExpansionHeight && mQsExpanded) { |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 1358 | setQsExpanded(false); |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 1359 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1360 | mQsExpansionHeight = height; |
Jason Monk | e1be342 | 2016-02-09 10:51:40 -0500 | [diff] [blame] | 1361 | updateQsExpansion(); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 1362 | requestScrollerTopPaddingUpdate(false /* animate */); |
Selim Cinek | fc22296 | 2018-07-20 20:09:23 -0700 | [diff] [blame] | 1363 | updateHeaderKeyguardAlpha(); |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1364 | if (mStatusBarState == StatusBarState.SHADE_LOCKED |
| 1365 | || mStatusBarState == StatusBarState.KEYGUARD) { |
| 1366 | updateKeyguardBottomAreaAlpha(); |
| 1367 | } |
Jorim Jaggi | dd5b886 | 2014-08-05 21:04:39 +0200 | [diff] [blame] | 1368 | if (mStatusBarState == StatusBarState.SHADE && mQsExpanded |
| 1369 | && !mStackScrollerOverscrolling && mQsScrimEnabled) { |
| 1370 | mQsNavbarScrim.setAlpha(getQsExpansionFraction()); |
| 1371 | } |
Selim Cinek | 90c9465 | 2014-08-18 16:46:22 +0200 | [diff] [blame] | 1372 | |
Phil Weaver | 428e397 | 2018-01-18 12:50:05 -0800 | [diff] [blame] | 1373 | if (mAccessibilityManager.isEnabled()) { |
| 1374 | setAccessibilityPaneTitle(determineAccessibilityPaneTitle()); |
Selim Cinek | 90c9465 | 2014-08-18 16:46:22 +0200 | [diff] [blame] | 1375 | } |
Phil Weaver | 428e397 | 2018-01-18 12:50:05 -0800 | [diff] [blame] | 1376 | |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 1377 | if (mQsFullyExpanded && mFalsingManager.shouldEnforceBouncer()) { |
Blazej Magnowski | 7232332 | 2015-07-24 11:49:40 -0700 | [diff] [blame] | 1378 | mStatusBar.executeRunnableDismissingKeyguard(null, null /* cancelAction */, |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 1379 | false /* dismissShade */, true /* afterKeyguardGone */, false /* deferred */); |
Blazej Magnowski | 7232332 | 2015-07-24 11:49:40 -0700 | [diff] [blame] | 1380 | } |
Jorim Jaggi | 58bef33 | 2014-11-21 18:10:32 +0100 | [diff] [blame] | 1381 | if (DEBUG) { |
| 1382 | invalidate(); |
| 1383 | } |
Selim Cinek | 90c9465 | 2014-08-18 16:46:22 +0200 | [diff] [blame] | 1384 | } |
| 1385 | |
Xiaohui Chen | 9528f43 | 2016-02-12 15:03:18 -0800 | [diff] [blame] | 1386 | protected void updateQsExpansion() { |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 1387 | if (mQs == null) return; |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 1388 | float qsExpansionFraction = getQsExpansionFraction(); |
| 1389 | mQs.setQsExpansion(qsExpansionFraction, getHeaderTranslation()); |
| 1390 | mNotificationStackScroller.setQsExpansionFraction(qsExpansionFraction); |
Jason Monk | e1be342 | 2016-02-09 10:51:40 -0500 | [diff] [blame] | 1391 | } |
| 1392 | |
Phil Weaver | 428e397 | 2018-01-18 12:50:05 -0800 | [diff] [blame] | 1393 | private String determineAccessibilityPaneTitle() { |
Jason Monk | 7a95288 | 2016-11-15 15:38:30 -0500 | [diff] [blame] | 1394 | if (mQs != null && mQs.isCustomizing()) { |
Jason Monk | 39c98e6 | 2016-03-16 09:18:35 -0400 | [diff] [blame] | 1395 | return getContext().getString(R.string.accessibility_desc_quick_settings_edit); |
Phil Weaver | 428e397 | 2018-01-18 12:50:05 -0800 | [diff] [blame] | 1396 | } else if (mQsExpansionHeight != 0.0f && mQsFullyExpanded) { |
| 1397 | // Upon initialisation when we are not layouted yet we don't want to announce that we |
| 1398 | // are fully expanded, hence the != 0.0f check. |
| 1399 | return getContext().getString(R.string.accessibility_desc_quick_settings); |
Jason Monk | 39c98e6 | 2016-03-16 09:18:35 -0400 | [diff] [blame] | 1400 | } else if (mStatusBarState == StatusBarState.KEYGUARD) { |
Selim Cinek | 90c9465 | 2014-08-18 16:46:22 +0200 | [diff] [blame] | 1401 | return getContext().getString(R.string.accessibility_desc_lock_screen); |
| 1402 | } else { |
| 1403 | return getContext().getString(R.string.accessibility_desc_notification_shade); |
| 1404 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1405 | } |
| 1406 | |
Jorim Jaggi | 61d37f6 | 2014-07-30 17:26:55 +0200 | [diff] [blame] | 1407 | private float calculateQsTopPadding() { |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 1408 | if (mKeyguardShowing |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 1409 | && (mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted)) { |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 1410 | |
| 1411 | // Either QS pushes the notifications down when fully expanded, or QS is fully above the |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 1412 | // notifications (mostly on tablets). maxNotificationPadding denotes the normal top |
| 1413 | // padding on Keyguard, maxQsPadding denotes the top padding from the quick settings |
| 1414 | // panel. We need to take the maximum and linearly interpolate with the panel expansion |
| 1415 | // for a nice motion. |
| 1416 | int maxNotificationPadding = mClockPositionResult.stackScrollerPadding; |
| 1417 | int maxQsPadding = mQsMaxExpansionHeight + mQsNotificationTopPadding; |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 1418 | int max = mStatusBarState == StatusBarState.KEYGUARD |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 1419 | ? Math.max(maxNotificationPadding, maxQsPadding) |
| 1420 | : maxQsPadding; |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 1421 | return (int) interpolate(getExpandedFraction(), |
| 1422 | mQsMinExpansionHeight, max); |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 1423 | } else if (mQsSizeChangeAnimator != null) { |
| 1424 | return (int) mQsSizeChangeAnimator.getAnimatedValue(); |
Jason Monk | 16ac377 | 2016-02-10 15:39:21 -0500 | [diff] [blame] | 1425 | } else if (mKeyguardShowing) { |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 1426 | // We can only do the smoother transition on Keyguard when we also are not collapsing |
| 1427 | // from a scrolled quick settings. |
Jorim Jaggi | 61d37f6 | 2014-07-30 17:26:55 +0200 | [diff] [blame] | 1428 | return interpolate(getQsExpansionFraction(), |
Selim Cinek | 33d4614 | 2016-01-15 18:58:39 -0800 | [diff] [blame] | 1429 | mNotificationStackScroller.getIntrinsicPadding(), |
Selim Cinek | d7768f4 | 2017-11-22 06:43:44 -0800 | [diff] [blame] | 1430 | mQsMaxExpansionHeight + mQsNotificationTopPadding); |
Jorim Jaggi | 61d37f6 | 2014-07-30 17:26:55 +0200 | [diff] [blame] | 1431 | } else { |
Selim Cinek | b95fd18 | 2017-12-21 13:03:32 -0800 | [diff] [blame] | 1432 | return mQsExpansionHeight + mQsNotificationTopPadding; |
Jorim Jaggi | 61d37f6 | 2014-07-30 17:26:55 +0200 | [diff] [blame] | 1433 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1434 | } |
| 1435 | |
Xiaohui Chen | 9528f43 | 2016-02-12 15:03:18 -0800 | [diff] [blame] | 1436 | protected void requestScrollerTopPaddingUpdate(boolean animate) { |
Jorim Jaggi | 61d37f6 | 2014-07-30 17:26:55 +0200 | [diff] [blame] | 1437 | mNotificationStackScroller.updateTopPadding(calculateQsTopPadding(), |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 1438 | animate, mKeyguardShowing |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 1439 | && (mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted)); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1440 | } |
| 1441 | |
| 1442 | private void trackMovement(MotionEvent event) { |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 1443 | if (mQsVelocityTracker != null) mQsVelocityTracker.addMovement(event); |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 1444 | mLastTouchX = event.getX(); |
| 1445 | mLastTouchY = event.getY(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1446 | } |
| 1447 | |
| 1448 | private void initVelocityTracker() { |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 1449 | if (mQsVelocityTracker != null) { |
| 1450 | mQsVelocityTracker.recycle(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1451 | } |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 1452 | mQsVelocityTracker = VelocityTracker.obtain(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1453 | } |
| 1454 | |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 1455 | private float getCurrentQSVelocity() { |
| 1456 | if (mQsVelocityTracker == null) { |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1457 | return 0; |
| 1458 | } |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 1459 | mQsVelocityTracker.computeCurrentVelocity(1000); |
| 1460 | return mQsVelocityTracker.getYVelocity(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1461 | } |
| 1462 | |
Selim Cinek | 831941f | 2015-06-17 15:09:30 -0700 | [diff] [blame] | 1463 | private void cancelQsAnimation() { |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1464 | if (mQsExpansionAnimator != null) { |
| 1465 | mQsExpansionAnimator.cancel(); |
| 1466 | } |
| 1467 | } |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1468 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 1469 | public void flingSettings(float vel, boolean expand) { |
Jorim Jaggi | 46ac19f | 2015-06-05 17:55:21 -0700 | [diff] [blame] | 1470 | flingSettings(vel, expand, null, false /* isClick */); |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1471 | } |
| 1472 | |
Muyuan Li | d6298fd | 2016-05-27 13:02:58 -0700 | [diff] [blame] | 1473 | protected void flingSettings(float vel, boolean expand, final Runnable onFinishRunnable, |
Jorim Jaggi | 46ac19f | 2015-06-05 17:55:21 -0700 | [diff] [blame] | 1474 | boolean isClick) { |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1475 | float target = expand ? mQsMaxExpansionHeight : mQsMinExpansionHeight; |
Jorim Jaggi | 9cd731a | 2014-05-22 14:26:06 +0200 | [diff] [blame] | 1476 | if (target == mQsExpansionHeight) { |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1477 | if (onFinishRunnable != null) { |
| 1478 | onFinishRunnable.run(); |
| 1479 | } |
Jorim Jaggi | 9cd731a | 2014-05-22 14:26:06 +0200 | [diff] [blame] | 1480 | return; |
| 1481 | } |
Jorim Jaggi | 519779e | 2016-10-12 16:52:14 +0200 | [diff] [blame] | 1482 | |
| 1483 | // If we move in the opposite direction, reset velocity and use a different duration. |
| 1484 | boolean oppositeDirection = false; |
| 1485 | if (vel > 0 && !expand || vel < 0 && expand) { |
Selim Cinek | 5386fb3 | 2014-09-03 16:37:36 +0200 | [diff] [blame] | 1486 | vel = 0; |
Jorim Jaggi | 519779e | 2016-10-12 16:52:14 +0200 | [diff] [blame] | 1487 | oppositeDirection = true; |
Selim Cinek | 5386fb3 | 2014-09-03 16:37:36 +0200 | [diff] [blame] | 1488 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1489 | ValueAnimator animator = ValueAnimator.ofFloat(mQsExpansionHeight, target); |
Jorim Jaggi | 46ac19f | 2015-06-05 17:55:21 -0700 | [diff] [blame] | 1490 | if (isClick) { |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 1491 | animator.setInterpolator(Interpolators.TOUCH_RESPONSE); |
Jorim Jaggi | 46ac19f | 2015-06-05 17:55:21 -0700 | [diff] [blame] | 1492 | animator.setDuration(368); |
| 1493 | } else { |
| 1494 | mFlingAnimationUtils.apply(animator, mQsExpansionHeight, target, vel); |
| 1495 | } |
Jorim Jaggi | 519779e | 2016-10-12 16:52:14 +0200 | [diff] [blame] | 1496 | if (oppositeDirection) { |
Selim Cinek | 5386fb3 | 2014-09-03 16:37:36 +0200 | [diff] [blame] | 1497 | animator.setDuration(350); |
| 1498 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1499 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { |
| 1500 | @Override |
| 1501 | public void onAnimationUpdate(ValueAnimator animation) { |
| 1502 | setQsExpansion((Float) animation.getAnimatedValue()); |
| 1503 | } |
| 1504 | }); |
| 1505 | animator.addListener(new AnimatorListenerAdapter() { |
| 1506 | @Override |
| 1507 | public void onAnimationEnd(Animator animation) { |
Mady Mellor | c2dbe49 | 2017-03-30 13:22:03 -0700 | [diff] [blame] | 1508 | mNotificationStackScroller.resetCheckSnoozeLeavebehind(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1509 | mQsExpansionAnimator = null; |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1510 | if (onFinishRunnable != null) { |
| 1511 | onFinishRunnable.run(); |
| 1512 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1513 | } |
| 1514 | }); |
| 1515 | animator.start(); |
| 1516 | mQsExpansionAnimator = animator; |
Jorim Jaggi | bd00310 | 2014-07-04 00:02:42 +0200 | [diff] [blame] | 1517 | mQsAnimatorExpand = expand; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1518 | } |
| 1519 | |
| 1520 | /** |
| 1521 | * @return Whether we should intercept a gesture to open Quick Settings. |
| 1522 | */ |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 1523 | private boolean shouldQuickSettingsIntercept(float x, float y, float yDiff) { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1524 | if (!mQsExpansionEnabled || mCollapsedOnDown) { |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1525 | return false; |
| 1526 | } |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 1527 | View header = mKeyguardShowing ? mKeyguardStatusBar : mQs.getHeader(); |
| 1528 | final boolean onHeader = x >= mQsFrame.getX() |
| 1529 | && x <= mQsFrame.getX() + mQsFrame.getWidth() |
Jorim Jaggi | 61d37f6 | 2014-07-30 17:26:55 +0200 | [diff] [blame] | 1530 | && y >= header.getTop() && y <= header.getBottom(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1531 | if (mQsExpanded) { |
Jason Monk | 16ac377 | 2016-02-10 15:39:21 -0500 | [diff] [blame] | 1532 | return onHeader || (yDiff < 0 && isInQsArea(x, y)); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1533 | } else { |
| 1534 | return onHeader; |
| 1535 | } |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1536 | } |
| 1537 | |
| 1538 | @Override |
| 1539 | protected boolean isScrolledToBottom() { |
| 1540 | if (!isInSettings()) { |
Jorim Jaggi | 58bef33 | 2014-11-21 18:10:32 +0100 | [diff] [blame] | 1541 | return mStatusBar.getBarState() == StatusBarState.KEYGUARD |
| 1542 | || mNotificationStackScroller.isScrolledToBottom(); |
Jorim Jaggi | e0640dd | 2014-08-05 23:12:40 +0200 | [diff] [blame] | 1543 | } else { |
Jason Monk | 16ac377 | 2016-02-10 15:39:21 -0500 | [diff] [blame] | 1544 | return true; |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 1545 | } |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1546 | } |
| 1547 | |
| 1548 | @Override |
| 1549 | protected int getMaxPanelHeight() { |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 1550 | int min = mStatusBarMinHeight; |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1551 | if (mStatusBar.getBarState() != StatusBarState.KEYGUARD |
| 1552 | && mNotificationStackScroller.getNotGoneChildCount() == 0) { |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1553 | int minHeight = (int) (mQsMinExpansionHeight + getOverExpansionAmount()); |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 1554 | min = Math.max(min, minHeight); |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1555 | } |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 1556 | int maxHeight; |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 1557 | if (mQsExpandImmediate || mQsExpanded || mIsExpanding && mQsExpandedWhenExpandingStarted) { |
Jorim Jaggi | 58bef33 | 2014-11-21 18:10:32 +0100 | [diff] [blame] | 1558 | maxHeight = calculatePanelHeightQsExpanded(); |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 1559 | } else { |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 1560 | maxHeight = calculatePanelHeightShade(); |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 1561 | } |
| 1562 | maxHeight = Math.max(maxHeight, min); |
Jorim Jaggi | 1d48069 | 2014-05-20 19:41:58 +0200 | [diff] [blame] | 1563 | return maxHeight; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1564 | } |
| 1565 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 1566 | public boolean isInSettings() { |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1567 | return mQsExpanded; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1568 | } |
| 1569 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 1570 | public boolean isExpanding() { |
| 1571 | return mIsExpanding; |
| 1572 | } |
| 1573 | |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1574 | @Override |
| 1575 | protected void onHeightUpdated(float expandedHeight) { |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 1576 | if (!mQsExpanded || mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted) { |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 1577 | // Updating the clock position will set the top padding which might |
| 1578 | // trigger a new panel height and re-position the clock. |
| 1579 | // This is a circular dependency and should be avoided, otherwise we'll have |
| 1580 | // a stack overflow. |
| 1581 | if (mStackScrollerMeasuringPass > 2) { |
| 1582 | if (DEBUG) Log.d(TAG, "Unstable notification panel height. Aborting."); |
| 1583 | } else { |
| 1584 | positionClockAndNotifications(); |
| 1585 | } |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 1586 | } |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 1587 | if (mQsExpandImmediate || mQsExpanded && !mQsTracking && mQsExpansionAnimator == null |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 1588 | && !mQsExpansionFromOverscroll) { |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 1589 | float t; |
| 1590 | if (mKeyguardShowing) { |
Jorim Jaggi | 5404542 | 2014-07-03 18:30:40 +0200 | [diff] [blame] | 1591 | |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 1592 | // On Keyguard, interpolate the QS expansion linearly to the panel expansion |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 1593 | t = expandedHeight / (getMaxPanelHeight()); |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 1594 | } else { |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 1595 | // In Shade, interpolate linearly such that QS is closed whenever panel height is |
| 1596 | // minimum QS expansion + minStackHeight |
| 1597 | float panelHeightQsCollapsed = mNotificationStackScroller.getIntrinsicPadding() |
Selim Cinek | d1ad9ab | 2016-03-01 17:52:20 -0800 | [diff] [blame] | 1598 | + mNotificationStackScroller.getLayoutMinHeight(); |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 1599 | float panelHeightQsExpanded = calculatePanelHeightQsExpanded(); |
| 1600 | t = (expandedHeight - panelHeightQsCollapsed) |
| 1601 | / (panelHeightQsExpanded - panelHeightQsCollapsed); |
| 1602 | } |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 1603 | setQsExpansion(mQsMinExpansionHeight |
Selim Cinek | d7768f4 | 2017-11-22 06:43:44 -0800 | [diff] [blame] | 1604 | + t * (mQsMaxExpansionHeight - mQsMinExpansionHeight)); |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 1605 | } |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 1606 | updateExpandedHeight(expandedHeight); |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1607 | updateHeader(); |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 1608 | updateUnlockIcon(); |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1609 | updateNotificationTranslucency(); |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 1610 | updatePanelExpanded(); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1611 | mNotificationStackScroller.setShadeExpanded(!isFullyCollapsed()); |
Jorim Jaggi | 58bef33 | 2014-11-21 18:10:32 +0100 | [diff] [blame] | 1612 | if (DEBUG) { |
| 1613 | invalidate(); |
| 1614 | } |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1615 | } |
| 1616 | |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 1617 | private void updatePanelExpanded() { |
| 1618 | boolean isExpanded = !isFullyCollapsed(); |
| 1619 | if (mPanelExpanded != isExpanded) { |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 1620 | mHeadsUpManager.setIsPanelExpanded(isExpanded); |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 1621 | mStatusBar.setPanelExpanded(isExpanded); |
| 1622 | mPanelExpanded = isExpanded; |
| 1623 | } |
| 1624 | } |
| 1625 | |
Jorim Jaggi | 61d37f6 | 2014-07-30 17:26:55 +0200 | [diff] [blame] | 1626 | private int calculatePanelHeightShade() { |
| 1627 | int emptyBottomMargin = mNotificationStackScroller.getEmptyBottomMargin(); |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 1628 | int maxHeight = mNotificationStackScroller.getHeight() - emptyBottomMargin; |
Jorim Jaggi | 61d37f6 | 2014-07-30 17:26:55 +0200 | [diff] [blame] | 1629 | maxHeight += mNotificationStackScroller.getTopPaddingOverflow(); |
Jorim Jaggi | 61d37f6 | 2014-07-30 17:26:55 +0200 | [diff] [blame] | 1630 | |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 1631 | if (mStatusBarState == StatusBarState.KEYGUARD) { |
| 1632 | int minKeyguardPanelBottom = mClockPositionAlgorithm.getExpandedClockPosition() |
| 1633 | + mKeyguardStatusView.getHeight() |
| 1634 | + mNotificationStackScroller.getIntrinsicContentHeight(); |
| 1635 | return Math.max(maxHeight, minKeyguardPanelBottom); |
| 1636 | } else { |
| 1637 | return maxHeight; |
| 1638 | } |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 1639 | } |
| 1640 | |
Jorim Jaggi | 61d37f6 | 2014-07-30 17:26:55 +0200 | [diff] [blame] | 1641 | private int calculatePanelHeightQsExpanded() { |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 1642 | float notificationHeight = mNotificationStackScroller.getHeight() |
| 1643 | - mNotificationStackScroller.getEmptyBottomMargin() |
| 1644 | - mNotificationStackScroller.getTopPadding(); |
Jorim Jaggi | 0cce70c | 2014-11-04 16:13:41 +0100 | [diff] [blame] | 1645 | |
| 1646 | // When only empty shade view is visible in QS collapsed state, simulate that we would have |
| 1647 | // it in expanded QS state as well so we don't run into troubles when fading the view in/out |
| 1648 | // and expanding/collapsing the whole panel from/to quick settings. |
Julia Reynolds | 34f1496 | 2018-05-03 12:40:20 +0000 | [diff] [blame] | 1649 | if (mNotificationStackScroller.getNotGoneChildCount() == 0 |
| 1650 | && mShowEmptyShadeView) { |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 1651 | notificationHeight = mNotificationStackScroller.getEmptyShadeViewHeight(); |
Jorim Jaggi | 0cce70c | 2014-11-04 16:13:41 +0100 | [diff] [blame] | 1652 | } |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 1653 | int maxQsHeight = mQsMaxExpansionHeight; |
| 1654 | |
Selim Cinek | d7768f4 | 2017-11-22 06:43:44 -0800 | [diff] [blame] | 1655 | if (mKeyguardShowing) { |
| 1656 | maxQsHeight += mQsNotificationTopPadding; |
| 1657 | } |
| 1658 | |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 1659 | // If an animation is changing the size of the QS panel, take the animated value. |
| 1660 | if (mQsSizeChangeAnimator != null) { |
| 1661 | maxQsHeight = (int) mQsSizeChangeAnimator.getAnimatedValue(); |
| 1662 | } |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 1663 | float totalHeight = Math.max( |
Selim Cinek | 33d4614 | 2016-01-15 18:58:39 -0800 | [diff] [blame] | 1664 | maxQsHeight, mStatusBarState == StatusBarState.KEYGUARD |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 1665 | ? mClockPositionResult.stackScrollerPadding : 0) |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 1666 | + notificationHeight + mNotificationStackScroller.getTopPaddingOverflow(); |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 1667 | if (totalHeight > mNotificationStackScroller.getHeight()) { |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 1668 | float fullyCollapsedHeight = maxQsHeight |
Selim Cinek | d1ad9ab | 2016-03-01 17:52:20 -0800 | [diff] [blame] | 1669 | + mNotificationStackScroller.getLayoutMinHeight(); |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 1670 | totalHeight = Math.max(fullyCollapsedHeight, mNotificationStackScroller.getHeight()); |
| 1671 | } |
Jorim Jaggi | 61d37f6 | 2014-07-30 17:26:55 +0200 | [diff] [blame] | 1672 | return (int) totalHeight; |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 1673 | } |
| 1674 | |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1675 | private void updateNotificationTranslucency() { |
Selim Cinek | bbc580b | 2015-06-03 14:11:03 +0200 | [diff] [blame] | 1676 | float alpha = 1f; |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 1677 | if (mClosingWithAlphaFadeOut && !mExpandingFromHeadsUp && |
| 1678 | !mHeadsUpManager.hasPinnedHeadsUp()) { |
Selim Cinek | bbc580b | 2015-06-03 14:11:03 +0200 | [diff] [blame] | 1679 | alpha = getFadeoutAlpha(); |
Jorim Jaggi | 5ad92c5 | 2014-07-28 21:07:32 +0200 | [diff] [blame] | 1680 | } |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1681 | mNotificationStackScroller.setAlpha(alpha); |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 1682 | } |
| 1683 | |
Selim Cinek | bbc580b | 2015-06-03 14:11:03 +0200 | [diff] [blame] | 1684 | private float getFadeoutAlpha() { |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 1685 | float alpha = (getNotificationsTopY() + mNotificationStackScroller.getFirstItemMinHeight()) |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 1686 | / mQsMinExpansionHeight; |
Selim Cinek | bbc580b | 2015-06-03 14:11:03 +0200 | [diff] [blame] | 1687 | alpha = Math.max(0, Math.min(alpha, 1)); |
| 1688 | alpha = (float) Math.pow(alpha, 0.75); |
| 1689 | return alpha; |
| 1690 | } |
| 1691 | |
Jorim Jaggi | 47c85a3 | 2014-06-05 17:25:40 +0200 | [diff] [blame] | 1692 | @Override |
| 1693 | protected float getOverExpansionAmount() { |
| 1694 | return mNotificationStackScroller.getCurrentOverScrollAmount(true /* top */); |
| 1695 | } |
| 1696 | |
| 1697 | @Override |
| 1698 | protected float getOverExpansionPixels() { |
| 1699 | return mNotificationStackScroller.getCurrentOverScrolledPixels(true /* top */); |
| 1700 | } |
| 1701 | |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 1702 | private void updateUnlockIcon() { |
| 1703 | if (mStatusBar.getBarState() == StatusBarState.KEYGUARD |
| 1704 | || mStatusBar.getBarState() == StatusBarState.SHADE_LOCKED) { |
| 1705 | boolean active = getMaxPanelHeight() - getExpandedHeight() > mUnlockMoveDistance; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 1706 | KeyguardAffordanceView lockIcon = mKeyguardBottomArea.getLockIcon(); |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 1707 | if (active && !mUnlockIconActive && mTracking) { |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 1708 | lockIcon.setImageAlpha(1.0f, true, 150, Interpolators.FAST_OUT_LINEAR_IN, null); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 1709 | lockIcon.setImageScale(LOCK_ICON_ACTIVE_SCALE, true, 150, |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 1710 | Interpolators.FAST_OUT_LINEAR_IN); |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 1711 | } else if (!active && mUnlockIconActive && mTracking) { |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 1712 | lockIcon.setImageAlpha(lockIcon.getRestingAlpha(), true /* animate */, |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 1713 | 150, Interpolators.FAST_OUT_LINEAR_IN, null); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 1714 | lockIcon.setImageScale(1.0f, true, 150, |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 1715 | Interpolators.FAST_OUT_LINEAR_IN); |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 1716 | } |
| 1717 | mUnlockIconActive = active; |
| 1718 | } |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 1719 | } |
| 1720 | |
| 1721 | /** |
| 1722 | * Hides the header when notifications are colliding with it. |
| 1723 | */ |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1724 | private void updateHeader() { |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1725 | if (mStatusBar.getBarState() == StatusBarState.KEYGUARD) { |
Jason Monk | e1be342 | 2016-02-09 10:51:40 -0500 | [diff] [blame] | 1726 | updateHeaderKeyguardAlpha(); |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 1727 | } |
Jason Monk | e1be342 | 2016-02-09 10:51:40 -0500 | [diff] [blame] | 1728 | updateQsExpansion(); |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1729 | } |
| 1730 | |
Xiaohui Chen | 9528f43 | 2016-02-12 15:03:18 -0800 | [diff] [blame] | 1731 | protected float getHeaderTranslation() { |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1732 | if (mStatusBar.getBarState() == StatusBarState.KEYGUARD) { |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1733 | return 0; |
| 1734 | } |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 1735 | float translation = MathUtils.lerp(-mQsMinExpansionHeight, 0, |
| 1736 | Math.min(1.0f, mNotificationStackScroller.getAppearFraction(mExpandedHeight))) |
| 1737 | + mExpandOffset; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1738 | return Math.min(0, translation); |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1739 | } |
| 1740 | |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1741 | /** |
| 1742 | * @return the alpha to be used to fade out the contents on Keyguard (status bar, bottom area) |
| 1743 | * during swiping up |
| 1744 | */ |
| 1745 | private float getKeyguardContentsAlpha() { |
| 1746 | float alpha; |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1747 | if (mStatusBar.getBarState() == StatusBarState.KEYGUARD) { |
| 1748 | |
| 1749 | // When on Keyguard, we hide the header as soon as the top card of the notification |
| 1750 | // stack scroller is close enough (collision distance) to the bottom of the header. |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1751 | alpha = getNotificationsTopY() |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1752 | / |
Jorim Jaggi | 3afddce | 2014-08-14 20:44:43 +0200 | [diff] [blame] | 1753 | (mKeyguardStatusBar.getHeight() + mNotificationsHeaderCollideDistance); |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1754 | } else { |
| 1755 | |
| 1756 | // In SHADE_LOCKED, the top card is already really close to the header. Hide it as |
| 1757 | // soon as we start translating the stack. |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1758 | alpha = getNotificationsTopY() / mKeyguardStatusBar.getHeight(); |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 1759 | } |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1760 | alpha = MathUtils.constrain(alpha, 0, 1); |
| 1761 | alpha = (float) Math.pow(alpha, 0.75); |
| 1762 | return alpha; |
| 1763 | } |
| 1764 | |
Jorim Jaggi | e4f1a20 | 2015-06-30 13:35:11 -0700 | [diff] [blame] | 1765 | private void updateHeaderKeyguardAlpha() { |
Selim Cinek | fc22296 | 2018-07-20 20:09:23 -0700 | [diff] [blame] | 1766 | if (!mKeyguardShowing) { |
| 1767 | return; |
| 1768 | } |
Jorim Jaggi | 3afddce | 2014-08-14 20:44:43 +0200 | [diff] [blame] | 1769 | float alphaQsExpansion = 1 - Math.min(1, getQsExpansionFraction() * 2); |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1770 | mKeyguardStatusBar.setAlpha(Math.min(getKeyguardContentsAlpha(), alphaQsExpansion) |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 1771 | * mKeyguardStatusBarAnimateAlpha); |
Selim Cinek | 8f2d767f | 2015-06-15 20:55:04 -0700 | [diff] [blame] | 1772 | mKeyguardStatusBar.setVisibility(mKeyguardStatusBar.getAlpha() != 0f |
| 1773 | && !mDozing ? VISIBLE : INVISIBLE); |
Jorim Jaggi | e4f1a20 | 2015-06-30 13:35:11 -0700 | [diff] [blame] | 1774 | } |
| 1775 | |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1776 | private void updateKeyguardBottomAreaAlpha() { |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 1777 | // There are two possible panel expansion behaviors: |
| 1778 | // • User dragging up to unlock: we want to fade out as quick as possible |
| 1779 | // (ALPHA_EXPANSION_THRESHOLD) to avoid seeing the bouncer over the bottom area. |
| 1780 | // • User tapping on lock screen: bouncer won't be visible but panel expansion will |
| 1781 | // change due to "unlock hint animation." In this case, fading out the bottom area |
| 1782 | // would also hide the message that says "swipe to unlock," we don't want to do that. |
| 1783 | float expansionAlpha = MathUtils.map(isUnlockHintRunning() |
| 1784 | ? 0 : KeyguardBouncer.ALPHA_EXPANSION_THRESHOLD, 1f, |
| 1785 | 0f, 1f, getExpandedFraction()); |
| 1786 | float alpha = Math.min(expansionAlpha, 1 - getQsExpansionFraction()); |
Adrian Roos | 14410b0 | 2015-06-10 13:35:41 -0700 | [diff] [blame] | 1787 | mKeyguardBottomArea.setAlpha(alpha); |
| 1788 | mKeyguardBottomArea.setImportantForAccessibility(alpha == 0f |
| 1789 | ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS |
| 1790 | : IMPORTANT_FOR_ACCESSIBILITY_AUTO); |
Adrian Roos | 8d4e99f | 2017-05-25 18:03:58 -0700 | [diff] [blame] | 1791 | View ambientIndicationContainer = mStatusBar.getAmbientIndicationContainer(); |
| 1792 | if (ambientIndicationContainer != null) { |
| 1793 | ambientIndicationContainer.setAlpha(alpha); |
| 1794 | } |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 1795 | } |
| 1796 | |
Jorim Jaggi | ad46ffef | 2014-07-04 18:05:06 +0200 | [diff] [blame] | 1797 | private float getNotificationsTopY() { |
| 1798 | if (mNotificationStackScroller.getNotGoneChildCount() == 0) { |
| 1799 | return getExpandedHeight(); |
| 1800 | } |
| 1801 | return mNotificationStackScroller.getNotificationsTopY(); |
| 1802 | } |
| 1803 | |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1804 | @Override |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1805 | protected void onExpandingStarted() { |
| 1806 | super.onExpandingStarted(); |
| 1807 | mNotificationStackScroller.onExpansionStarted(); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 1808 | mIsExpanding = true; |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 1809 | mQsExpandedWhenExpandingStarted = mQsFullyExpanded; |
Jorim Jaggi | 5630625 | 2014-07-03 00:40:09 +0200 | [diff] [blame] | 1810 | if (mQsExpanded) { |
Jorim Jaggi | 5630625 | 2014-07-03 00:40:09 +0200 | [diff] [blame] | 1811 | onQsExpansionStarted(); |
| 1812 | } |
Jason Monk | b5ece9a | 2016-04-22 11:40:36 -0400 | [diff] [blame] | 1813 | // Since there are QS tiles in the header now, we need to make sure we start listening |
| 1814 | // immediately so they can be up to date. |
Jason Monk | f4e019a | 2016-11-03 09:07:20 -0400 | [diff] [blame] | 1815 | if (mQs == null) return; |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 1816 | mQs.setHeaderListening(true); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1817 | } |
| 1818 | |
| 1819 | @Override |
| 1820 | protected void onExpandingFinished() { |
| 1821 | super.onExpandingFinished(); |
| 1822 | mNotificationStackScroller.onExpansionStopped(); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1823 | mHeadsUpManager.onExpandingFinished(); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 1824 | mIsExpanding = false; |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1825 | if (isFullyCollapsed()) { |
Jorim Jaggi | 613f55f | 2015-07-16 15:30:10 -0700 | [diff] [blame] | 1826 | DejankUtils.postAfterTraversal(new Runnable() { |
| 1827 | @Override |
| 1828 | public void run() { |
| 1829 | setListening(false); |
| 1830 | } |
| 1831 | }); |
| 1832 | |
| 1833 | // Workaround b/22639032: Make sure we invalidate something because else RenderThread |
| 1834 | // thinks we are actually drawing a frame put in reality we don't, so RT doesn't go |
| 1835 | // ahead with rendering and we jank. |
| 1836 | postOnAnimation(new Runnable() { |
| 1837 | @Override |
| 1838 | public void run() { |
| 1839 | getParent().invalidateChild(NotificationPanelView.this, mDummyDirtyRect); |
| 1840 | } |
| 1841 | }); |
Jorim Jaggi | e65e310 | 2014-07-01 22:00:50 +0200 | [diff] [blame] | 1842 | } else { |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 1843 | setListening(true); |
Jorim Jaggi | e65e310 | 2014-07-01 22:00:50 +0200 | [diff] [blame] | 1844 | } |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 1845 | mQsExpandImmediate = false; |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 1846 | mNotificationStackScroller.setShouldShowShelfOnly(false); |
Jorim Jaggi | 1e2554b | 2014-07-10 23:07:00 +0200 | [diff] [blame] | 1847 | mTwoFingerQsExpandPossible = false; |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1848 | mIsExpansionFromHeadsUp = false; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1849 | notifyListenersTrackingHeadsUp(null); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1850 | mExpandingFromHeadsUp = false; |
Selim Cinek | 3d395c6 | 2015-06-16 19:37:37 -0700 | [diff] [blame] | 1851 | setPanelScrimMinFraction(0.0f); |
Jorim Jaggi | e65e310 | 2014-07-01 22:00:50 +0200 | [diff] [blame] | 1852 | } |
| 1853 | |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1854 | private void notifyListenersTrackingHeadsUp(ExpandableNotificationRow pickedChild) { |
| 1855 | for (int i = 0; i < mTrackingHeadsUpListeners.size(); i++) { |
| 1856 | Consumer<ExpandableNotificationRow> listener |
| 1857 | = mTrackingHeadsUpListeners.get(i); |
| 1858 | listener.accept(pickedChild); |
| 1859 | } |
| 1860 | } |
| 1861 | |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 1862 | private void setListening(boolean listening) { |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 1863 | mKeyguardStatusBar.setListening(listening); |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 1864 | if (mQs == null) return; |
| 1865 | mQs.setListening(listening); |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 1866 | } |
| 1867 | |
Jorim Jaggi | e65e310 | 2014-07-01 22:00:50 +0200 | [diff] [blame] | 1868 | @Override |
Oren Blasberg | 8d3fea1 | 2015-07-10 14:21:44 -0700 | [diff] [blame] | 1869 | public void expand(boolean animate) { |
| 1870 | super.expand(animate); |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 1871 | setListening(true); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1872 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1873 | |
| 1874 | @Override |
Jorim Jaggi | 47c85a3 | 2014-06-05 17:25:40 +0200 | [diff] [blame] | 1875 | protected void setOverExpansion(float overExpansion, boolean isPixels) { |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 1876 | if (mConflictingQsExpansionGesture || mQsExpandImmediate) { |
Jorim Jaggi | dc96d63 | 2014-07-01 18:48:52 +0200 | [diff] [blame] | 1877 | return; |
| 1878 | } |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 1879 | if (mStatusBar.getBarState() != StatusBarState.KEYGUARD) { |
Jorim Jaggi | 47c85a3 | 2014-06-05 17:25:40 +0200 | [diff] [blame] | 1880 | mNotificationStackScroller.setOnHeightChangedListener(null); |
| 1881 | if (isPixels) { |
| 1882 | mNotificationStackScroller.setOverScrolledPixels( |
| 1883 | overExpansion, true /* onTop */, false /* animate */); |
| 1884 | } else { |
| 1885 | mNotificationStackScroller.setOverScrollAmount( |
| 1886 | overExpansion, true /* onTop */, false /* animate */); |
| 1887 | } |
| 1888 | mNotificationStackScroller.setOnHeightChangedListener(this); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 1889 | } |
Selim Cinek | 24120a5 | 2014-05-26 10:05:42 +0200 | [diff] [blame] | 1890 | } |
| 1891 | |
| 1892 | @Override |
Jorim Jaggi | 282a615 | 2014-06-02 23:37:53 +0200 | [diff] [blame] | 1893 | protected void onTrackingStarted() { |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 1894 | mFalsingManager.onTrackingStarted(mStatusBar.isKeyguardCurrentlySecure()); |
Jorim Jaggi | 282a615 | 2014-06-02 23:37:53 +0200 | [diff] [blame] | 1895 | super.onTrackingStarted(); |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 1896 | if (mQsFullyExpanded) { |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 1897 | mQsExpandImmediate = true; |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 1898 | mNotificationStackScroller.setShouldShowShelfOnly(true); |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 1899 | } |
Jorim Jaggi | 282a615 | 2014-06-02 23:37:53 +0200 | [diff] [blame] | 1900 | if (mStatusBar.getBarState() == StatusBarState.KEYGUARD |
| 1901 | || mStatusBar.getBarState() == StatusBarState.SHADE_LOCKED) { |
Adrian Roos | e31f30e | 2017-01-25 14:48:15 -0800 | [diff] [blame] | 1902 | mAffordanceHelper.animateHideLeftRightIcon(); |
Jorim Jaggi | e0640dd | 2014-08-05 23:12:40 +0200 | [diff] [blame] | 1903 | } |
Jorim Jaggi | e4b840d | 2015-06-30 16:19:17 -0700 | [diff] [blame] | 1904 | mNotificationStackScroller.onPanelTrackingStarted(); |
Jorim Jaggi | 282a615 | 2014-06-02 23:37:53 +0200 | [diff] [blame] | 1905 | } |
| 1906 | |
| 1907 | @Override |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 1908 | protected void onTrackingStopped(boolean expand) { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 1909 | mFalsingManager.onTrackingStopped(); |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 1910 | super.onTrackingStopped(expand); |
Jorim Jaggi | 47c85a3 | 2014-06-05 17:25:40 +0200 | [diff] [blame] | 1911 | if (expand) { |
| 1912 | mNotificationStackScroller.setOverScrolledPixels( |
| 1913 | 0.0f, true /* onTop */, true /* animate */); |
| 1914 | } |
Jorim Jaggi | e4b840d | 2015-06-30 16:19:17 -0700 | [diff] [blame] | 1915 | mNotificationStackScroller.onPanelTrackingStopped(); |
Jorim Jaggi | 282a615 | 2014-06-02 23:37:53 +0200 | [diff] [blame] | 1916 | if (expand && (mStatusBar.getBarState() == StatusBarState.KEYGUARD |
| 1917 | || mStatusBar.getBarState() == StatusBarState.SHADE_LOCKED)) { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 1918 | if (!mHintAnimationRunning) { |
Adrian Roos | e31f30e | 2017-01-25 14:48:15 -0800 | [diff] [blame] | 1919 | mAffordanceHelper.reset(true); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 1920 | } |
Jorim Jaggi | 282a615 | 2014-06-02 23:37:53 +0200 | [diff] [blame] | 1921 | } |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 1922 | if (!expand && (mStatusBar.getBarState() == StatusBarState.KEYGUARD |
| 1923 | || mStatusBar.getBarState() == StatusBarState.SHADE_LOCKED)) { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 1924 | KeyguardAffordanceView lockIcon = mKeyguardBottomArea.getLockIcon(); |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 1925 | lockIcon.setImageAlpha(0.0f, true, 100, Interpolators.FAST_OUT_LINEAR_IN, null); |
| 1926 | lockIcon.setImageScale(2.0f, true, 100, Interpolators.FAST_OUT_LINEAR_IN); |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 1927 | } |
Selim Cinek | 24120a5 | 2014-05-26 10:05:42 +0200 | [diff] [blame] | 1928 | } |
| 1929 | |
Selim Cinek | 24120a5 | 2014-05-26 10:05:42 +0200 | [diff] [blame] | 1930 | @Override |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1931 | public void onHeightChanged(ExpandableView view, boolean needsAnimation) { |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 1932 | |
| 1933 | // Block update if we are in quick settings and just the top padding changed |
| 1934 | // (i.e. view == null). |
| 1935 | if (view == null && mQsExpanded) { |
| 1936 | return; |
| 1937 | } |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 1938 | if (needsAnimation && mInterpolatedDarkAmount == 0) { |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 1939 | mAnimateNextPositionUpdate = true; |
| 1940 | } |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 1941 | ExpandableView firstChildNotGone = mNotificationStackScroller.getFirstChildNotGone(); |
| 1942 | ExpandableNotificationRow firstRow = firstChildNotGone instanceof ExpandableNotificationRow |
| 1943 | ? (ExpandableNotificationRow) firstChildNotGone |
| 1944 | : null; |
| 1945 | if (firstRow != null |
| 1946 | && (view == firstRow || (firstRow.getNotificationParent() == firstRow))) { |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 1947 | requestScrollerTopPaddingUpdate(false /* animate */); |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 1948 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1949 | requestPanelHeightUpdate(); |
| 1950 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1951 | |
| 1952 | @Override |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 1953 | public void onReset(ExpandableView view) { |
| 1954 | } |
| 1955 | |
Jason Monk | 8b9d67f | 2016-03-02 08:59:08 -0500 | [diff] [blame] | 1956 | public void onQsHeightChanged() { |
Jason Monk | f4e019a | 2016-11-03 09:07:20 -0400 | [diff] [blame] | 1957 | mQsMaxExpansionHeight = mQs != null ? mQs.getDesiredHeight() : 0; |
Jason Monk | f50e882 | 2016-06-01 11:19:26 -0400 | [diff] [blame] | 1958 | if (mQsExpanded && mQsFullyExpanded) { |
Jason Monk | 8b9d67f | 2016-03-02 08:59:08 -0500 | [diff] [blame] | 1959 | mQsExpansionHeight = mQsMaxExpansionHeight; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 1960 | requestScrollerTopPaddingUpdate(false /* animate */); |
Jorim Jaggi | 5630625 | 2014-07-03 00:40:09 +0200 | [diff] [blame] | 1961 | requestPanelHeightUpdate(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1962 | } |
Phil Weaver | 428e397 | 2018-01-18 12:50:05 -0800 | [diff] [blame] | 1963 | if (mAccessibilityManager.isEnabled()) { |
| 1964 | setAccessibilityPaneTitle(determineAccessibilityPaneTitle()); |
| 1965 | } |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 1966 | mNotificationStackScroller.setMaxTopPadding( |
| 1967 | mQsMaxExpansionHeight + mQsNotificationTopPadding); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 1968 | } |
| 1969 | |
| 1970 | @Override |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 1971 | protected void onConfigurationChanged(Configuration newConfig) { |
| 1972 | super.onConfigurationChanged(newConfig); |
Adrian Roos | e31f30e | 2017-01-25 14:48:15 -0800 | [diff] [blame] | 1973 | mAffordanceHelper.onConfigurationChanged(); |
Jorim Jaggi | 6d4a27f | 2015-04-20 16:01:53 -0700 | [diff] [blame] | 1974 | if (newConfig.orientation != mLastOrientation) { |
| 1975 | resetVerticalPanelPosition(); |
| 1976 | } |
| 1977 | mLastOrientation = newConfig.orientation; |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 1978 | } |
| 1979 | |
| 1980 | @Override |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1981 | public WindowInsets onApplyWindowInsets(WindowInsets insets) { |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 1982 | mNavigationBarBottomHeight = insets.getStableInsetBottom(); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1983 | updateMaxHeadsUpTranslation(); |
| 1984 | return insets; |
| 1985 | } |
| 1986 | |
| 1987 | private void updateMaxHeadsUpTranslation() { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1988 | mNotificationStackScroller.setHeadsUpBoundaries(getHeight(), mNavigationBarBottomHeight); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1989 | } |
| 1990 | |
| 1991 | @Override |
Jorim Jaggi | 0a81822 | 2014-11-10 19:04:34 +0100 | [diff] [blame] | 1992 | public void onRtlPropertiesChanged(int layoutDirection) { |
| 1993 | if (layoutDirection != mOldLayoutDirection) { |
Adrian Roos | e31f30e | 2017-01-25 14:48:15 -0800 | [diff] [blame] | 1994 | mAffordanceHelper.onRtlPropertiesChanged(); |
Jorim Jaggi | 0a81822 | 2014-11-10 19:04:34 +0100 | [diff] [blame] | 1995 | mOldLayoutDirection = layoutDirection; |
| 1996 | } |
| 1997 | } |
| 1998 | |
| 1999 | @Override |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 2000 | public void onClick(View v) { |
Amin Shaikh | 8a3e23c | 2018-04-17 11:14:32 -0400 | [diff] [blame] | 2001 | onQsExpansionStarted(); |
| 2002 | if (mQsExpanded) { |
| 2003 | flingSettings(0 /* vel */, false /* expand */, null, true /* isClick */); |
| 2004 | } else if (mQsExpansionEnabled) { |
| 2005 | mLockscreenGestureLogger.write(MetricsEvent.ACTION_SHADE_QS_TAP, 0, 0); |
| 2006 | flingSettings(0 /* vel */, true /* expand */, null, true /* isClick */); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 2007 | } |
| 2008 | } |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 2009 | |
| 2010 | @Override |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 2011 | public void onAnimationToSideStarted(boolean rightPage, float translation, float vel) { |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 2012 | boolean start = getLayoutDirection() == LAYOUT_DIRECTION_RTL ? rightPage : !rightPage; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 2013 | mIsLaunchTransitionRunning = true; |
| 2014 | mLaunchAnimationEndRunnable = null; |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 2015 | float displayDensity = mStatusBar.getDisplayDensity(); |
| 2016 | int lengthDp = Math.abs((int) (translation / displayDensity)); |
| 2017 | int velocityDp = Math.abs((int) (vel / displayDensity)); |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 2018 | if (start) { |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 2019 | mLockscreenGestureLogger.write(MetricsEvent.ACTION_LS_DIALER, lengthDp, velocityDp); |
Blazej Magnowski | 7232332 | 2015-07-24 11:49:40 -0700 | [diff] [blame] | 2020 | |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 2021 | mFalsingManager.onLeftAffordanceOn(); |
| 2022 | if (mFalsingManager.shouldEnforceBouncer()) { |
Blazej Magnowski | 7232332 | 2015-07-24 11:49:40 -0700 | [diff] [blame] | 2023 | mStatusBar.executeRunnableDismissingKeyguard(new Runnable() { |
| 2024 | @Override |
| 2025 | public void run() { |
| 2026 | mKeyguardBottomArea.launchLeftAffordance(); |
| 2027 | } |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 2028 | }, null, true /* dismissShade */, false /* afterKeyguardGone */, |
| 2029 | true /* deferred */); |
Blazej Magnowski | 7232332 | 2015-07-24 11:49:40 -0700 | [diff] [blame] | 2030 | } |
| 2031 | else { |
| 2032 | mKeyguardBottomArea.launchLeftAffordance(); |
| 2033 | } |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 2034 | } else { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 2035 | if (KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_AFFORDANCE.equals( |
| 2036 | mLastCameraLaunchSource)) { |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 2037 | mLockscreenGestureLogger.write(MetricsEvent.ACTION_LS_CAMERA, lengthDp, velocityDp); |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 2038 | } |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 2039 | mFalsingManager.onCameraOn(); |
| 2040 | if (mFalsingManager.shouldEnforceBouncer()) { |
Blazej Magnowski | 7232332 | 2015-07-24 11:49:40 -0700 | [diff] [blame] | 2041 | mStatusBar.executeRunnableDismissingKeyguard(new Runnable() { |
| 2042 | @Override |
| 2043 | public void run() { |
Jorim Jaggi | fc832e3 | 2015-09-25 11:54:05 -0700 | [diff] [blame] | 2044 | mKeyguardBottomArea.launchCamera(mLastCameraLaunchSource); |
Blazej Magnowski | 7232332 | 2015-07-24 11:49:40 -0700 | [diff] [blame] | 2045 | } |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 2046 | }, null, true /* dismissShade */, false /* afterKeyguardGone */, |
| 2047 | true /* deferred */); |
Blazej Magnowski | 7232332 | 2015-07-24 11:49:40 -0700 | [diff] [blame] | 2048 | } |
| 2049 | else { |
Jorim Jaggi | fc832e3 | 2015-09-25 11:54:05 -0700 | [diff] [blame] | 2050 | mKeyguardBottomArea.launchCamera(mLastCameraLaunchSource); |
Blazej Magnowski | 7232332 | 2015-07-24 11:49:40 -0700 | [diff] [blame] | 2051 | } |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 2052 | } |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 2053 | mStatusBar.startLaunchTransitionTimeout(); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 2054 | mBlockTouches = true; |
| 2055 | } |
| 2056 | |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 2057 | @Override |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 2058 | public void onAnimationToSideEnded() { |
| 2059 | mIsLaunchTransitionRunning = false; |
| 2060 | mIsLaunchTransitionFinished = true; |
| 2061 | if (mLaunchAnimationEndRunnable != null) { |
| 2062 | mLaunchAnimationEndRunnable.run(); |
| 2063 | mLaunchAnimationEndRunnable = null; |
| 2064 | } |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 2065 | mStatusBar.readyForKeyguardDone(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 2066 | } |
| 2067 | |
| 2068 | @Override |
Jorim Jaggi | 93a2bb2 | 2014-06-02 19:57:28 +0200 | [diff] [blame] | 2069 | protected void startUnlockHintAnimation() { |
Selim Cinek | e64f52a | 2017-08-24 14:48:38 -0700 | [diff] [blame] | 2070 | if (mPowerManager.isPowerSaveMode()) { |
| 2071 | onUnlockHintStarted(); |
| 2072 | onUnlockHintFinished(); |
| 2073 | return; |
| 2074 | } |
Jorim Jaggi | 93a2bb2 | 2014-06-02 19:57:28 +0200 | [diff] [blame] | 2075 | super.startUnlockHintAnimation(); |
| 2076 | startHighlightIconAnimation(getCenterIcon()); |
| 2077 | } |
| 2078 | |
| 2079 | /** |
| 2080 | * Starts the highlight (making it fully opaque) animation on an icon. |
| 2081 | */ |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 2082 | private void startHighlightIconAnimation(final KeyguardAffordanceView icon) { |
| 2083 | icon.setImageAlpha(1.0f, true, KeyguardAffordanceHelper.HINT_PHASE1_DURATION, |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 2084 | Interpolators.FAST_OUT_SLOW_IN, new Runnable() { |
Jorim Jaggi | 93a2bb2 | 2014-06-02 19:57:28 +0200 | [diff] [blame] | 2085 | @Override |
| 2086 | public void run() { |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 2087 | icon.setImageAlpha(icon.getRestingAlpha(), |
| 2088 | true /* animate */, KeyguardAffordanceHelper.HINT_PHASE1_DURATION, |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 2089 | Interpolators.FAST_OUT_SLOW_IN, null); |
Jorim Jaggi | 93a2bb2 | 2014-06-02 19:57:28 +0200 | [diff] [blame] | 2090 | } |
| 2091 | }); |
| 2092 | } |
| 2093 | |
| 2094 | @Override |
Selim Cinek | 6746c28 | 2015-04-21 19:58:31 -0700 | [diff] [blame] | 2095 | public float getMaxTranslationDistance() { |
| 2096 | return (float) Math.hypot(getWidth(), getHeight()); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 2097 | } |
| 2098 | |
| 2099 | @Override |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 2100 | public void onSwipingStarted(boolean rightIcon) { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 2101 | mFalsingManager.onAffordanceSwipingStarted(rightIcon); |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 2102 | boolean camera = getLayoutDirection() == LAYOUT_DIRECTION_RTL ? !rightIcon |
| 2103 | : rightIcon; |
| 2104 | if (camera) { |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 2105 | mKeyguardBottomArea.bindCameraPrewarmService(); |
Jorim Jaggi | a86790b | 2015-04-02 16:32:29 -0700 | [diff] [blame] | 2106 | } |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 2107 | requestDisallowInterceptTouchEvent(true); |
| 2108 | mOnlyAffordanceInThisMotion = true; |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 2109 | mQsTracking = false; |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 2110 | } |
| 2111 | |
| 2112 | @Override |
Jorim Jaggi | a86790b | 2015-04-02 16:32:29 -0700 | [diff] [blame] | 2113 | public void onSwipingAborted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 2114 | mFalsingManager.onAffordanceSwipingAborted(); |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 2115 | mKeyguardBottomArea.unbindCameraPrewarmService(false /* launched */); |
Jorim Jaggi | a86790b | 2015-04-02 16:32:29 -0700 | [diff] [blame] | 2116 | } |
| 2117 | |
| 2118 | @Override |
Selim Cinek | 6746c28 | 2015-04-21 19:58:31 -0700 | [diff] [blame] | 2119 | public void onIconClicked(boolean rightIcon) { |
| 2120 | if (mHintAnimationRunning) { |
| 2121 | return; |
| 2122 | } |
| 2123 | mHintAnimationRunning = true; |
Adrian Roos | e31f30e | 2017-01-25 14:48:15 -0800 | [diff] [blame] | 2124 | mAffordanceHelper.startHintAnimation(rightIcon, new Runnable() { |
Selim Cinek | 6746c28 | 2015-04-21 19:58:31 -0700 | [diff] [blame] | 2125 | @Override |
| 2126 | public void run() { |
| 2127 | mHintAnimationRunning = false; |
| 2128 | mStatusBar.onHintFinished(); |
| 2129 | } |
| 2130 | }); |
| 2131 | rightIcon = getLayoutDirection() == LAYOUT_DIRECTION_RTL ? !rightIcon : rightIcon; |
| 2132 | if (rightIcon) { |
| 2133 | mStatusBar.onCameraHintStarted(); |
| 2134 | } else { |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2135 | if (mKeyguardBottomArea.isLeftVoiceAssist()) { |
| 2136 | mStatusBar.onVoiceAssistHintStarted(); |
| 2137 | } else { |
| 2138 | mStatusBar.onPhoneHintStarted(); |
| 2139 | } |
Selim Cinek | 6746c28 | 2015-04-21 19:58:31 -0700 | [diff] [blame] | 2140 | } |
| 2141 | } |
| 2142 | |
| 2143 | @Override |
Selim Cinek | ec29d34 | 2017-05-05 18:31:49 -0700 | [diff] [blame] | 2144 | protected void onUnlockHintFinished() { |
| 2145 | super.onUnlockHintFinished(); |
| 2146 | mNotificationStackScroller.setUnlockHintRunning(false); |
| 2147 | } |
| 2148 | |
| 2149 | @Override |
| 2150 | protected void onUnlockHintStarted() { |
| 2151 | super.onUnlockHintStarted(); |
| 2152 | mNotificationStackScroller.setUnlockHintRunning(true); |
| 2153 | } |
| 2154 | |
| 2155 | @Override |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 2156 | public KeyguardAffordanceView getLeftIcon() { |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 2157 | return getLayoutDirection() == LAYOUT_DIRECTION_RTL |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2158 | ? mKeyguardBottomArea.getRightView() |
| 2159 | : mKeyguardBottomArea.getLeftView(); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 2160 | } |
| 2161 | |
| 2162 | @Override |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 2163 | public KeyguardAffordanceView getCenterIcon() { |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 2164 | return mKeyguardBottomArea.getLockIcon(); |
| 2165 | } |
| 2166 | |
| 2167 | @Override |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 2168 | public KeyguardAffordanceView getRightIcon() { |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 2169 | return getLayoutDirection() == LAYOUT_DIRECTION_RTL |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2170 | ? mKeyguardBottomArea.getLeftView() |
| 2171 | : mKeyguardBottomArea.getRightView(); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 2172 | } |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 2173 | |
| 2174 | @Override |
Jorim Jaggi | b6cdcbc | 2014-07-25 21:58:29 +0200 | [diff] [blame] | 2175 | public View getLeftPreview() { |
| 2176 | return getLayoutDirection() == LAYOUT_DIRECTION_RTL |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2177 | ? mKeyguardBottomArea.getRightPreview() |
| 2178 | : mKeyguardBottomArea.getLeftPreview(); |
Jorim Jaggi | b6cdcbc | 2014-07-25 21:58:29 +0200 | [diff] [blame] | 2179 | } |
| 2180 | |
| 2181 | @Override |
| 2182 | public View getRightPreview() { |
| 2183 | return getLayoutDirection() == LAYOUT_DIRECTION_RTL |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2184 | ? mKeyguardBottomArea.getLeftPreview() |
| 2185 | : mKeyguardBottomArea.getRightPreview(); |
Jorim Jaggi | b6cdcbc | 2014-07-25 21:58:29 +0200 | [diff] [blame] | 2186 | } |
| 2187 | |
| 2188 | @Override |
Selim Cinek | 34cf5c4 | 2014-09-26 15:39:00 +0200 | [diff] [blame] | 2189 | public float getAffordanceFalsingFactor() { |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 2190 | return mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f; |
Selim Cinek | 34cf5c4 | 2014-09-26 15:39:00 +0200 | [diff] [blame] | 2191 | } |
| 2192 | |
| 2193 | @Override |
Adrian Roos | 6a70b88 | 2016-04-19 17:09:07 -0700 | [diff] [blame] | 2194 | public boolean needsAntiFalsing() { |
| 2195 | return mStatusBarState == StatusBarState.KEYGUARD; |
| 2196 | } |
| 2197 | |
| 2198 | @Override |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 2199 | protected float getPeekHeight() { |
| 2200 | if (mNotificationStackScroller.getNotGoneChildCount() > 0) { |
| 2201 | return mNotificationStackScroller.getPeekHeight(); |
| 2202 | } else { |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 2203 | return mQsMinExpansionHeight; |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 2204 | } |
| 2205 | } |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 2206 | |
| 2207 | @Override |
Selim Cinek | 2411f76 | 2016-12-28 17:05:08 +0100 | [diff] [blame] | 2208 | protected boolean shouldUseDismissingAnimation() { |
| 2209 | return mStatusBarState != StatusBarState.SHADE |
Selim Cinek | df5501b | 2017-04-14 20:01:27 -0700 | [diff] [blame] | 2210 | && (!mStatusBar.isKeyguardCurrentlySecure() || !isTracking()); |
Selim Cinek | 2411f76 | 2016-12-28 17:05:08 +0100 | [diff] [blame] | 2211 | } |
| 2212 | |
| 2213 | @Override |
Jorim Jaggi | 4b04a3a | 2014-07-28 17:43:56 +0200 | [diff] [blame] | 2214 | protected boolean fullyExpandedClearAllVisible() { |
Julia Reynolds | ed1c9af | 2018-03-21 15:21:09 -0400 | [diff] [blame] | 2215 | return mNotificationStackScroller.isFooterViewNotGone() |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 2216 | && mNotificationStackScroller.isScrolledToBottom() && !mQsExpandImmediate; |
Jorim Jaggi | 4b04a3a | 2014-07-28 17:43:56 +0200 | [diff] [blame] | 2217 | } |
| 2218 | |
| 2219 | @Override |
| 2220 | protected boolean isClearAllVisible() { |
Selim Cinek | 3847544 | 2018-05-18 11:11:46 -0700 | [diff] [blame] | 2221 | return mNotificationStackScroller.isFooterViewContentVisible(); |
Jorim Jaggi | 4b04a3a | 2014-07-28 17:43:56 +0200 | [diff] [blame] | 2222 | } |
| 2223 | |
| 2224 | @Override |
| 2225 | protected int getClearAllHeight() { |
Julia Reynolds | ed1c9af | 2018-03-21 15:21:09 -0400 | [diff] [blame] | 2226 | return mNotificationStackScroller.getFooterViewHeight(); |
Jorim Jaggi | 4b04a3a | 2014-07-28 17:43:56 +0200 | [diff] [blame] | 2227 | } |
| 2228 | |
| 2229 | @Override |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 2230 | protected boolean isTrackingBlocked() { |
| 2231 | return mConflictingQsExpansionGesture && mQsExpanded; |
| 2232 | } |
Jorim Jaggi | 5404542 | 2014-07-03 18:30:40 +0200 | [diff] [blame] | 2233 | |
Jorim Jaggi | bd00310 | 2014-07-04 00:02:42 +0200 | [diff] [blame] | 2234 | public boolean isQsExpanded() { |
| 2235 | return mQsExpanded; |
| 2236 | } |
Jorim Jaggi | 853b070 | 2014-07-05 04:31:14 +0200 | [diff] [blame] | 2237 | |
John Spurlock | f7ae442 | 2014-08-01 12:45:18 -0400 | [diff] [blame] | 2238 | public boolean isQsDetailShowing() { |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 2239 | return mQs.isShowingDetail(); |
John Spurlock | f7ae442 | 2014-08-01 12:45:18 -0400 | [diff] [blame] | 2240 | } |
| 2241 | |
| 2242 | public void closeQsDetail() { |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 2243 | mQs.closeDetail(); |
John Spurlock | f7ae442 | 2014-08-01 12:45:18 -0400 | [diff] [blame] | 2244 | } |
| 2245 | |
Jorim Jaggi | 853b070 | 2014-07-05 04:31:14 +0200 | [diff] [blame] | 2246 | @Override |
| 2247 | public boolean shouldDelayChildPressedState() { |
| 2248 | return true; |
| 2249 | } |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 2250 | |
| 2251 | public boolean isLaunchTransitionFinished() { |
| 2252 | return mIsLaunchTransitionFinished; |
| 2253 | } |
| 2254 | |
| 2255 | public boolean isLaunchTransitionRunning() { |
| 2256 | return mIsLaunchTransitionRunning; |
| 2257 | } |
| 2258 | |
| 2259 | public void setLaunchTransitionEndRunnable(Runnable r) { |
| 2260 | mLaunchAnimationEndRunnable = r; |
| 2261 | } |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 2262 | |
| 2263 | public void setEmptyDragAmount(float amount) { |
Selim Cinek | 5386fb3 | 2014-09-03 16:37:36 +0200 | [diff] [blame] | 2264 | float factor = 0.8f; |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 2265 | if (mNotificationStackScroller.getNotGoneChildCount() > 0) { |
Selim Cinek | 5386fb3 | 2014-09-03 16:37:36 +0200 | [diff] [blame] | 2266 | factor = 0.4f; |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 2267 | } else if (!mStatusBar.hasActiveNotifications()) { |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 2268 | factor = 0.4f; |
| 2269 | } |
| 2270 | mEmptyDragAmount = amount * factor; |
| 2271 | positionClockAndNotifications(); |
| 2272 | } |
Jorim Jaggi | 61d37f6 | 2014-07-30 17:26:55 +0200 | [diff] [blame] | 2273 | |
| 2274 | private static float interpolate(float t, float start, float end) { |
| 2275 | return (1 - t) * start + t * end; |
| 2276 | } |
John Spurlock | d54da8a | 2014-08-03 23:23:52 -0400 | [diff] [blame] | 2277 | |
Jorim Jaggi | 0e0942d | 2015-06-05 14:12:20 -0700 | [diff] [blame] | 2278 | private void updateDozingVisibilities(boolean animate) { |
John Spurlock | d54da8a | 2014-08-03 23:23:52 -0400 | [diff] [blame] | 2279 | if (mDozing) { |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 2280 | mKeyguardStatusBar.setVisibility(View.INVISIBLE); |
Adrian Roos | 91ba307 | 2017-02-14 16:50:46 +0100 | [diff] [blame] | 2281 | mKeyguardBottomArea.setDozing(mDozing, animate); |
John Spurlock | d54da8a | 2014-08-03 23:23:52 -0400 | [diff] [blame] | 2282 | } else { |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 2283 | mKeyguardStatusBar.setVisibility(View.VISIBLE); |
Adrian Roos | 91ba307 | 2017-02-14 16:50:46 +0100 | [diff] [blame] | 2284 | mKeyguardBottomArea.setDozing(mDozing, animate); |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 2285 | if (animate) { |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 2286 | animateKeyguardStatusBarIn(DOZE_ANIMATION_DURATION); |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 2287 | } |
John Spurlock | d54da8a | 2014-08-03 23:23:52 -0400 | [diff] [blame] | 2288 | } |
John Spurlock | d54da8a | 2014-08-03 23:23:52 -0400 | [diff] [blame] | 2289 | } |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 2290 | |
Jorim Jaggi | d7912d2 | 2014-09-30 17:38:19 +0200 | [diff] [blame] | 2291 | @Override |
John Spurlock | cf5d3c9 | 2014-09-21 17:55:01 -0400 | [diff] [blame] | 2292 | public boolean isDozing() { |
| 2293 | return mDozing; |
| 2294 | } |
| 2295 | |
Selim Cinek | 24176c3 | 2017-03-01 16:50:30 -0800 | [diff] [blame] | 2296 | public void showEmptyShadeView(boolean emptyShadeViewVisible) { |
| 2297 | mShowEmptyShadeView = emptyShadeViewVisible; |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 2298 | updateEmptyShadeView(); |
| 2299 | } |
| 2300 | |
| 2301 | private void updateEmptyShadeView() { |
Julia Reynolds | 34f1496 | 2018-05-03 12:40:20 +0000 | [diff] [blame] | 2302 | |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 2303 | // Hide "No notifications" in QS. |
Selim Cinek | 24176c3 | 2017-03-01 16:50:30 -0800 | [diff] [blame] | 2304 | mNotificationStackScroller.updateEmptyShadeView(mShowEmptyShadeView && !mQsExpanded); |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 2305 | } |
Jorim Jaggi | dd5b886 | 2014-08-05 21:04:39 +0200 | [diff] [blame] | 2306 | |
| 2307 | public void setQsScrimEnabled(boolean qsScrimEnabled) { |
| 2308 | boolean changed = mQsScrimEnabled != qsScrimEnabled; |
| 2309 | mQsScrimEnabled = qsScrimEnabled; |
| 2310 | if (changed) { |
| 2311 | updateQsState(); |
| 2312 | } |
| 2313 | } |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 2314 | |
Jorim Jaggi | bf1899e | 2014-08-07 02:04:18 +0200 | [diff] [blame] | 2315 | public void setKeyguardUserSwitcher(KeyguardUserSwitcher keyguardUserSwitcher) { |
| 2316 | mKeyguardUserSwitcher = keyguardUserSwitcher; |
| 2317 | } |
| 2318 | |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 2319 | public void onScreenTurningOn() { |
Lucas Dupin | 9fedb89 | 2018-05-04 17:42:33 -0700 | [diff] [blame] | 2320 | mKeyguardStatusView.dozeTimeTick(); |
Jorim Jaggi | d09def751 | 2014-09-02 18:36:45 +0200 | [diff] [blame] | 2321 | } |
Selim Cinek | 3a9c10a | 2014-10-28 14:21:10 +0100 | [diff] [blame] | 2322 | |
| 2323 | @Override |
| 2324 | public void onEmptySpaceClicked(float x, float y) { |
| 2325 | onEmptySpaceClick(x); |
| 2326 | } |
Jorim Jaggi | 58bef33 | 2014-11-21 18:10:32 +0100 | [diff] [blame] | 2327 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2328 | @Override |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 2329 | protected boolean onMiddleClicked() { |
| 2330 | switch (mStatusBar.getBarState()) { |
| 2331 | case StatusBarState.KEYGUARD: |
| 2332 | if (!mDozingOnDown) { |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 2333 | mLockscreenGestureLogger.write( |
| 2334 | MetricsEvent.ACTION_LS_HINT, |
Jorim Jaggi | 1cf6e10 | 2015-01-20 16:45:05 +0100 | [diff] [blame] | 2335 | 0 /* lengthDp - N/A */, 0 /* velocityDp - N/A */); |
| 2336 | startUnlockHintAnimation(); |
| 2337 | } |
| 2338 | return true; |
| 2339 | case StatusBarState.SHADE_LOCKED: |
| 2340 | if (!mQsExpanded) { |
| 2341 | mStatusBar.goToKeyguard(); |
| 2342 | } |
| 2343 | return true; |
| 2344 | case StatusBarState.SHADE: |
| 2345 | |
| 2346 | // This gets called in the middle of the touch handling, where the state is still |
| 2347 | // that we are tracking the panel. Collapse the panel after this is done. |
| 2348 | post(mPostCollapseRunnable); |
| 2349 | return false; |
| 2350 | default: |
| 2351 | return true; |
| 2352 | } |
| 2353 | } |
| 2354 | |
Jorim Jaggi | 58bef33 | 2014-11-21 18:10:32 +0100 | [diff] [blame] | 2355 | @Override |
shawnlin | 4ef7ca5 | 2018-05-11 16:44:42 +0800 | [diff] [blame] | 2356 | protected void dispatchDraw(Canvas canvas) { |
| 2357 | super.dispatchDraw(canvas); |
| 2358 | if (mCurrentPanelAlpha != 255) { |
| 2359 | canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mAlphaPaint); |
| 2360 | } |
| 2361 | } |
| 2362 | |
| 2363 | public float getCurrentPanelAlpha() { |
| 2364 | return mCurrentPanelAlpha; |
| 2365 | } |
| 2366 | |
| 2367 | public boolean setPanelAlpha(int alpha, boolean animate) { |
| 2368 | if (mPanelAlpha != alpha) { |
| 2369 | mPanelAlpha = alpha; |
| 2370 | PropertyAnimator.setProperty(this, PANEL_ALPHA, alpha, |
| 2371 | alpha == 255 ? PANEL_ALPHA_IN_PROPERTIES : PANEL_ALPHA_OUT_PROPERTIES, animate); |
| 2372 | return true; |
| 2373 | } |
| 2374 | return false; |
| 2375 | } |
| 2376 | |
| 2377 | public void setPanelAlphaInternal(float alpha) { |
| 2378 | mCurrentPanelAlpha = (int) alpha; |
| 2379 | mAlphaPaint.setARGB(mCurrentPanelAlpha, 255, 255, 255); |
| 2380 | invalidate(); |
| 2381 | } |
| 2382 | |
| 2383 | public void setPanelAlphaEndAction(Runnable r) { |
| 2384 | mPanelAlphaEndAction = r; |
| 2385 | } |
| 2386 | |
| 2387 | @Override |
Lucas Dupin | 41ff695 | 2018-02-18 19:39:32 -0800 | [diff] [blame] | 2388 | protected void onDraw(Canvas canvas) { |
| 2389 | super.onDraw(canvas); |
| 2390 | |
Jorim Jaggi | 58bef33 | 2014-11-21 18:10:32 +0100 | [diff] [blame] | 2391 | if (DEBUG) { |
| 2392 | Paint p = new Paint(); |
| 2393 | p.setColor(Color.RED); |
| 2394 | p.setStrokeWidth(2); |
| 2395 | p.setStyle(Paint.Style.STROKE); |
| 2396 | canvas.drawLine(0, getMaxPanelHeight(), getWidth(), getMaxPanelHeight(), p); |
| 2397 | p.setColor(Color.BLUE); |
| 2398 | canvas.drawLine(0, getExpandedHeight(), getWidth(), getExpandedHeight(), p); |
| 2399 | p.setColor(Color.GREEN); |
| 2400 | canvas.drawLine(0, calculatePanelHeightQsExpanded(), getWidth(), |
| 2401 | calculatePanelHeightQsExpanded(), p); |
| 2402 | p.setColor(Color.YELLOW); |
| 2403 | canvas.drawLine(0, calculatePanelHeightShade(), getWidth(), |
| 2404 | calculatePanelHeightShade(), p); |
| 2405 | p.setColor(Color.MAGENTA); |
| 2406 | canvas.drawLine(0, calculateQsTopPadding(), getWidth(), |
| 2407 | calculateQsTopPadding(), p); |
| 2408 | p.setColor(Color.CYAN); |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 2409 | canvas.drawLine(0, mClockPositionResult.stackScrollerPadding, getWidth(), |
Jorim Jaggi | 58bef33 | 2014-11-21 18:10:32 +0100 | [diff] [blame] | 2410 | mNotificationStackScroller.getTopPadding(), p); |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 2411 | p.setColor(Color.GRAY); |
| 2412 | canvas.drawLine(0, mClockPositionResult.clockY, getWidth(), |
| 2413 | mClockPositionResult.clockY, p); |
Jorim Jaggi | 58bef33 | 2014-11-21 18:10:32 +0100 | [diff] [blame] | 2414 | } |
| 2415 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2416 | |
| 2417 | @Override |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 2418 | public void onHeadsUpPinnedModeChanged(final boolean inPinnedMode) { |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 2419 | mNotificationStackScroller.setInHeadsUpPinnedMode(inPinnedMode); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2420 | if (inPinnedMode) { |
| 2421 | mHeadsUpExistenceChangedRunnable.run(); |
| 2422 | updateNotificationTranslucency(); |
| 2423 | } else { |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 2424 | setHeadsUpAnimatingAway(true); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2425 | mNotificationStackScroller.runAfterAnimationFinished( |
| 2426 | mHeadsUpExistenceChangedRunnable); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2427 | } |
| 2428 | } |
| 2429 | |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 2430 | public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) { |
| 2431 | mHeadsUpAnimatingAway = headsUpAnimatingAway; |
| 2432 | mNotificationStackScroller.setHeadsUpAnimatingAway(headsUpAnimatingAway); |
| 2433 | } |
| 2434 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2435 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2436 | public void onHeadsUpPinned(ExpandableNotificationRow headsUp) { |
| 2437 | mNotificationStackScroller.generateHeadsUpAnimation(headsUp, true); |
Selim Cinek | 1f3f544 | 2015-04-10 17:54:46 -0700 | [diff] [blame] | 2438 | } |
| 2439 | |
| 2440 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2441 | public void onHeadsUpUnPinned(ExpandableNotificationRow headsUp) { |
Selim Cinek | a303a64 | 2018-03-08 21:24:55 -0800 | [diff] [blame] | 2442 | |
| 2443 | // When we're unpinning the notification via active edge they remain heads-upped, |
| 2444 | // we need to make sure that an animation happens in this case, otherwise the notification |
| 2445 | // will stick to the top without any interaction. |
| 2446 | if (isFullyCollapsed() && headsUp.isHeadsUp()) { |
| 2447 | mNotificationStackScroller.generateHeadsUpAnimation(headsUp, false); |
| 2448 | headsUp.setHeadsUpIsVisible(); |
| 2449 | } |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2450 | } |
| 2451 | |
| 2452 | @Override |
| 2453 | public void onHeadsUpStateChanged(NotificationData.Entry entry, boolean isHeadsUp) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2454 | mNotificationStackScroller.generateHeadsUpAnimation(entry.row, isHeadsUp); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2455 | } |
| 2456 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 2457 | @Override |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 2458 | public void setHeadsUpManager(HeadsUpManagerPhone headsUpManager) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2459 | super.setHeadsUpManager(headsUpManager); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2460 | mHeadsUpTouchHelper = new HeadsUpTouchHelper(headsUpManager, mNotificationStackScroller, |
| 2461 | this); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2462 | } |
| 2463 | |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 2464 | public void setTrackedHeadsUp(ExpandableNotificationRow pickedChild) { |
| 2465 | if (pickedChild != null) { |
| 2466 | notifyListenersTrackingHeadsUp(pickedChild); |
Selim Cinek | d228115 | 2015-04-10 14:37:46 -0700 | [diff] [blame] | 2467 | mExpandingFromHeadsUp = true; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2468 | } |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2469 | // otherwise we update the state when the expansion is finished |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2470 | } |
Jorim Jaggi | 6d4a27f | 2015-04-20 16:01:53 -0700 | [diff] [blame] | 2471 | |
| 2472 | @Override |
| 2473 | protected void onClosingFinished() { |
| 2474 | super.onClosingFinished(); |
| 2475 | resetVerticalPanelPosition(); |
Selim Cinek | bbc580b | 2015-06-03 14:11:03 +0200 | [diff] [blame] | 2476 | setClosingWithAlphaFadeout(false); |
| 2477 | } |
| 2478 | |
| 2479 | private void setClosingWithAlphaFadeout(boolean closing) { |
| 2480 | mClosingWithAlphaFadeOut = closing; |
| 2481 | mNotificationStackScroller.forceNoOverlappingRendering(closing); |
Jorim Jaggi | 6d4a27f | 2015-04-20 16:01:53 -0700 | [diff] [blame] | 2482 | } |
| 2483 | |
| 2484 | /** |
| 2485 | * Updates the vertical position of the panel so it is positioned closer to the touch |
| 2486 | * responsible for opening the panel. |
| 2487 | * |
| 2488 | * @param x the x-coordinate the touch event |
| 2489 | */ |
Xiaohui Chen | 9528f43 | 2016-02-12 15:03:18 -0800 | [diff] [blame] | 2490 | protected void updateVerticalPanelPosition(float x) { |
Jorim Jaggi | 6d4a27f | 2015-04-20 16:01:53 -0700 | [diff] [blame] | 2491 | if (mNotificationStackScroller.getWidth() * 1.75f > getWidth()) { |
| 2492 | resetVerticalPanelPosition(); |
| 2493 | return; |
| 2494 | } |
| 2495 | float leftMost = mPositionMinSideMargin + mNotificationStackScroller.getWidth() / 2; |
| 2496 | float rightMost = getWidth() - mPositionMinSideMargin |
| 2497 | - mNotificationStackScroller.getWidth() / 2; |
| 2498 | if (Math.abs(x - getWidth() / 2) < mNotificationStackScroller.getWidth() / 4) { |
| 2499 | x = getWidth() / 2; |
| 2500 | } |
| 2501 | x = Math.min(rightMost, Math.max(leftMost, x)); |
| 2502 | setVerticalPanelTranslation(x - |
Selim Cinek | 3d395c6 | 2015-06-16 19:37:37 -0700 | [diff] [blame] | 2503 | (mNotificationStackScroller.getLeft() + mNotificationStackScroller.getWidth() / 2)); |
Jorim Jaggi | 6d4a27f | 2015-04-20 16:01:53 -0700 | [diff] [blame] | 2504 | } |
| 2505 | |
| 2506 | private void resetVerticalPanelPosition() { |
| 2507 | setVerticalPanelTranslation(0f); |
| 2508 | } |
| 2509 | |
Xiaohui Chen | f43491f | 2016-02-01 12:19:35 -0800 | [diff] [blame] | 2510 | protected void setVerticalPanelTranslation(float translation) { |
Bill Lin | e60aa1e | 2018-06-13 18:07:15 +0800 | [diff] [blame] | 2511 | mNotificationStackScroller.setVerticalPanelTranslation(translation); |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 2512 | mQsFrame.setTranslationX(translation); |
Selim Cinek | 60ffea6 | 2018-03-22 13:16:44 -0700 | [diff] [blame] | 2513 | int size = mVerticalTranslationListener.size(); |
| 2514 | for (int i = 0; i < size; i++) { |
| 2515 | mVerticalTranslationListener.get(i).run(); |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 2516 | } |
Jorim Jaggi | 6d4a27f | 2015-04-20 16:01:53 -0700 | [diff] [blame] | 2517 | } |
Xiyuan Xia | b3a6f1e | 2015-04-28 16:17:18 -0700 | [diff] [blame] | 2518 | |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 2519 | protected void updateExpandedHeight(float expandedHeight) { |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 2520 | if (mTracking) { |
| 2521 | mNotificationStackScroller.setExpandingVelocity(getCurrentExpandVelocity()); |
| 2522 | } |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 2523 | mNotificationStackScroller.setExpandedHeight(expandedHeight); |
Xiyuan Xia | b3a6f1e | 2015-04-28 16:17:18 -0700 | [diff] [blame] | 2524 | updateKeyguardBottomAreaAlpha(); |
Selim Cinek | 24176c3 | 2017-03-01 16:50:30 -0800 | [diff] [blame] | 2525 | updateStatusBarIcons(); |
Selim Cinek | fcff4c6 | 2016-12-27 14:26:06 +0100 | [diff] [blame] | 2526 | } |
| 2527 | |
| 2528 | /** |
| 2529 | * @return whether the notifications are displayed full width and don't have any margins on |
| 2530 | * the side. |
| 2531 | */ |
| 2532 | public boolean isFullWidth() { |
| 2533 | return mIsFullWidth; |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 2534 | } |
| 2535 | |
Selim Cinek | 24176c3 | 2017-03-01 16:50:30 -0800 | [diff] [blame] | 2536 | private void updateStatusBarIcons() { |
felkachang | ca4eee8 | 2018-06-29 15:34:28 +0800 | [diff] [blame] | 2537 | boolean showIconsWhenExpanded = (isPanelVisibleBecauseOfHeadsUp() || isFullWidth()) |
| 2538 | && getExpandedHeight() < getOpeningHeight(); |
Selim Cinek | 24176c3 | 2017-03-01 16:50:30 -0800 | [diff] [blame] | 2539 | if (showIconsWhenExpanded && mNoVisibleNotifications && isOnKeyguard()) { |
| 2540 | showIconsWhenExpanded = false; |
| 2541 | } |
| 2542 | if (showIconsWhenExpanded != mShowIconsWhenExpanded) { |
| 2543 | mShowIconsWhenExpanded = showIconsWhenExpanded; |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 2544 | mStatusBar.recomputeDisableFlags(false); |
| 2545 | } |
Xiyuan Xia | b3a6f1e | 2015-04-28 16:17:18 -0700 | [diff] [blame] | 2546 | } |
Selim Cinek | 3d395c6 | 2015-06-16 19:37:37 -0700 | [diff] [blame] | 2547 | |
Selim Cinek | 24176c3 | 2017-03-01 16:50:30 -0800 | [diff] [blame] | 2548 | private boolean isOnKeyguard() { |
| 2549 | return mStatusBar.getBarState() == StatusBarState.KEYGUARD; |
| 2550 | } |
| 2551 | |
Selim Cinek | 3d395c6 | 2015-06-16 19:37:37 -0700 | [diff] [blame] | 2552 | public void setPanelScrimMinFraction(float minFraction) { |
| 2553 | mBar.panelScrimMinFractionChanged(minFraction); |
| 2554 | } |
Chris Wren | 1689594 | 2015-06-23 11:22:20 -0400 | [diff] [blame] | 2555 | |
Xiaohui Chen | 9528f43 | 2016-02-12 15:03:18 -0800 | [diff] [blame] | 2556 | public void clearNotificationEffects() { |
Chris Wren | 1689594 | 2015-06-23 11:22:20 -0400 | [diff] [blame] | 2557 | mStatusBar.clearNotificationEffects(); |
| 2558 | } |
Selim Cinek | 0fccc72 | 2015-07-29 17:04:36 -0700 | [diff] [blame] | 2559 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2560 | @Override |
Selim Cinek | 0fccc72 | 2015-07-29 17:04:36 -0700 | [diff] [blame] | 2561 | protected boolean isPanelVisibleBecauseOfHeadsUp() { |
| 2562 | return mHeadsUpManager.hasPinnedHeadsUp() || mHeadsUpAnimatingAway; |
| 2563 | } |
Jorim Jaggi | 9097885 | 2015-08-18 19:55:53 -0700 | [diff] [blame] | 2564 | |
| 2565 | @Override |
| 2566 | public boolean hasOverlappingRendering() { |
| 2567 | return !mDozing; |
| 2568 | } |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 2569 | |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 2570 | public void launchCamera(boolean animate, int source) { |
| 2571 | if (source == StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) { |
| 2572 | mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP; |
| 2573 | } else if (source == StatusBarManager.CAMERA_LAUNCH_SOURCE_WIGGLE) { |
| 2574 | mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_WIGGLE; |
Jonathan Solnit | a413816 | 2017-05-10 21:06:04 -0700 | [diff] [blame] | 2575 | } else if (source == StatusBarManager.CAMERA_LAUNCH_SOURCE_LIFT_TRIGGER) { |
| 2576 | mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_LIFT_TRIGGER; |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 2577 | } else { |
| 2578 | |
| 2579 | // Default. |
| 2580 | mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_AFFORDANCE; |
| 2581 | } |
| 2582 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 2583 | // If we are launching it when we are occluded already we don't want it to animate, |
| 2584 | // nor setting these flags, since the occluded state doesn't change anymore, hence it's |
| 2585 | // never reset. |
| 2586 | if (!isFullyCollapsed()) { |
| 2587 | mLaunchingAffordance = true; |
| 2588 | setLaunchingAffordance(true); |
| 2589 | } else { |
| 2590 | animate = false; |
| 2591 | } |
Lucas Dupin | 193677c | 2018-06-11 19:16:03 -0700 | [diff] [blame] | 2592 | mAffordanceHasPreview = mKeyguardBottomArea.getRightPreview() != null; |
Adrian Roos | e31f30e | 2017-01-25 14:48:15 -0800 | [diff] [blame] | 2593 | mAffordanceHelper.launchAffordance(animate, getLayoutDirection() == LAYOUT_DIRECTION_RTL); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 2594 | } |
| 2595 | |
| 2596 | public void onAffordanceLaunchEnded() { |
| 2597 | mLaunchingAffordance = false; |
| 2598 | setLaunchingAffordance(false); |
| 2599 | } |
| 2600 | |
Selim Cinek | 07304f522 | 2016-05-19 18:31:36 -0700 | [diff] [blame] | 2601 | @Override |
| 2602 | public void setAlpha(float alpha) { |
| 2603 | super.setAlpha(alpha); |
Adrian Roos | 88e61aa | 2017-05-23 16:16:50 -0700 | [diff] [blame] | 2604 | updateFullyVisibleState(false /* forceNotFullyVisible */); |
| 2605 | } |
| 2606 | |
| 2607 | /** |
| 2608 | * Must be called before starting a ViewPropertyAnimator alpha animation because those |
| 2609 | * do NOT call setAlpha and therefore don't properly update the fullyVisibleState. |
| 2610 | */ |
| 2611 | public void notifyStartFading() { |
| 2612 | updateFullyVisibleState(true /* forceNotFullyVisible */); |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 2613 | } |
| 2614 | |
| 2615 | @Override |
| 2616 | public void setVisibility(int visibility) { |
| 2617 | super.setVisibility(visibility); |
Adrian Roos | 88e61aa | 2017-05-23 16:16:50 -0700 | [diff] [blame] | 2618 | updateFullyVisibleState(false /* forceNotFullyVisible */); |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 2619 | } |
| 2620 | |
Adrian Roos | 88e61aa | 2017-05-23 16:16:50 -0700 | [diff] [blame] | 2621 | private void updateFullyVisibleState(boolean forceNotFullyVisible) { |
| 2622 | mNotificationStackScroller.setParentNotFullyVisible(forceNotFullyVisible |
| 2623 | || getAlpha() != 1.0f |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 2624 | || getVisibility() != VISIBLE); |
Selim Cinek | 07304f522 | 2016-05-19 18:31:36 -0700 | [diff] [blame] | 2625 | } |
| 2626 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 2627 | /** |
| 2628 | * Set whether we are currently launching an affordance. This is currently only set when |
| 2629 | * launched via a camera gesture. |
| 2630 | */ |
| 2631 | private void setLaunchingAffordance(boolean launchingAffordance) { |
| 2632 | getLeftIcon().setLaunchingAffordance(launchingAffordance); |
| 2633 | getRightIcon().setLaunchingAffordance(launchingAffordance); |
| 2634 | getCenterIcon().setLaunchingAffordance(launchingAffordance); |
| 2635 | } |
| 2636 | |
Zhentao Sun | 04f9740 | 2015-08-26 17:37:30 -0700 | [diff] [blame] | 2637 | /** |
Lucas Dupin | 193677c | 2018-06-11 19:16:03 -0700 | [diff] [blame] | 2638 | * Return true when a bottom affordance is launching an occluded activity with a splash screen. |
| 2639 | */ |
| 2640 | public boolean isLaunchingAffordanceWithPreview() { |
| 2641 | return mLaunchingAffordance && mAffordanceHasPreview; |
| 2642 | } |
| 2643 | |
| 2644 | /** |
Zhentao Sun | 04f9740 | 2015-08-26 17:37:30 -0700 | [diff] [blame] | 2645 | * Whether the camera application can be launched for the camera launch gesture. |
| 2646 | * |
| 2647 | * @param keyguardIsShowing whether keyguard is being shown |
| 2648 | */ |
| 2649 | public boolean canCameraGestureBeLaunched(boolean keyguardIsShowing) { |
Esteban Talavera | 40f8b99 | 2017-07-14 16:14:07 +0100 | [diff] [blame] | 2650 | if (!mStatusBar.isCameraAllowedByAdmin()) { |
| 2651 | return false; |
| 2652 | } |
| 2653 | |
Zhentao Sun | 04f9740 | 2015-08-26 17:37:30 -0700 | [diff] [blame] | 2654 | ResolveInfo resolveInfo = mKeyguardBottomArea.resolveCameraIntent(); |
| 2655 | String packageToLaunch = (resolveInfo == null || resolveInfo.activityInfo == null) |
| 2656 | ? null : resolveInfo.activityInfo.packageName; |
| 2657 | return packageToLaunch != null && |
| 2658 | (keyguardIsShowing || !isForegroundApp(packageToLaunch)) && |
Adrian Roos | e31f30e | 2017-01-25 14:48:15 -0800 | [diff] [blame] | 2659 | !mAffordanceHelper.isSwipingInProgress(); |
Zhentao Sun | 04f9740 | 2015-08-26 17:37:30 -0700 | [diff] [blame] | 2660 | } |
| 2661 | |
| 2662 | /** |
| 2663 | * Return true if the applications with the package name is running in foreground. |
| 2664 | * |
| 2665 | * @param pkgName application package name. |
| 2666 | */ |
| 2667 | private boolean isForegroundApp(String pkgName) { |
| 2668 | ActivityManager am = getContext().getSystemService(ActivityManager.class); |
| 2669 | List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(1); |
| 2670 | return !tasks.isEmpty() && pkgName.equals(tasks.get(0).topActivity.getPackageName()); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 2671 | } |
Selim Cinek | 53f8e7d | 2016-03-25 02:28:01 -0700 | [diff] [blame] | 2672 | |
| 2673 | public void setGroupManager(NotificationGroupManager groupManager) { |
| 2674 | mGroupManager = groupManager; |
| 2675 | } |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 2676 | |
Selim Cinek | 24176c3 | 2017-03-01 16:50:30 -0800 | [diff] [blame] | 2677 | public boolean hideStatusBarIconsWhenExpanded() { |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 2678 | if (mLaunchingNotification) { |
| 2679 | return mHideIconsDuringNotificationLaunch; |
| 2680 | } |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 2681 | if (mHeadsUpAppearanceController != null |
| 2682 | && mHeadsUpAppearanceController.shouldBeVisible()) { |
| 2683 | return false; |
| 2684 | } |
Selim Cinek | 24176c3 | 2017-03-01 16:50:30 -0800 | [diff] [blame] | 2685 | return !isFullWidth() || !mShowIconsWhenExpanded; |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 2686 | } |
| 2687 | |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 2688 | private final FragmentListener mFragmentListener = new FragmentListener() { |
| 2689 | @Override |
| 2690 | public void onFragmentViewCreated(String tag, Fragment fragment) { |
| 2691 | mQs = (QS) fragment; |
| 2692 | mQs.setPanelView(NotificationPanelView.this); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 2693 | mQs.setExpandClickListener(NotificationPanelView.this); |
Jason Monk | 0ceef21 | 2016-11-02 14:05:23 -0400 | [diff] [blame] | 2694 | mQs.setHeaderClickable(mQsExpansionEnabled); |
| 2695 | mQs.setKeyguardShowing(mKeyguardShowing); |
| 2696 | mQs.setOverscrolling(mStackScrollerOverscrolling); |
| 2697 | |
| 2698 | // recompute internal state when qspanel height changes |
| 2699 | mQs.getView().addOnLayoutChangeListener( |
| 2700 | (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { |
| 2701 | final int height = bottom - top; |
| 2702 | final int oldHeight = oldBottom - oldTop; |
| 2703 | if (height != oldHeight) { |
| 2704 | onQsHeightChanged(); |
| 2705 | } |
| 2706 | }); |
| 2707 | mNotificationStackScroller.setQsContainer((ViewGroup) mQs.getView()); |
| 2708 | updateQsExpansion(); |
| 2709 | } |
| 2710 | |
| 2711 | @Override |
| 2712 | public void onFragmentViewDestroyed(String tag, Fragment fragment) { |
| 2713 | // Manual handling of fragment lifecycle is only required because this bridges |
| 2714 | // non-fragment and fragment code. Once we are using a fragment for the notification |
| 2715 | // panel, mQs will not need to be null cause it will be tied to the same lifecycle. |
| 2716 | if (fragment == mQs) { |
| 2717 | mQs = null; |
| 2718 | } |
| 2719 | } |
| 2720 | }; |
Adrian Roos | c934c43 | 2017-01-13 11:44:56 -0800 | [diff] [blame] | 2721 | |
Selim Cinek | 2c2f0e2 | 2017-05-02 20:02:30 -0700 | [diff] [blame] | 2722 | @Override |
| 2723 | public void setTouchDisabled(boolean disabled) { |
| 2724 | super.setTouchDisabled(disabled); |
| 2725 | if (disabled && mAffordanceHelper.isSwipingInProgress() && !mIsLaunchTransitionRunning) { |
Selim Cinek | c5fec9a | 2017-07-05 16:22:53 +0200 | [diff] [blame] | 2726 | mAffordanceHelper.reset(false /* animate */); |
Selim Cinek | 2c2f0e2 | 2017-05-02 20:02:30 -0700 | [diff] [blame] | 2727 | } |
| 2728 | } |
| 2729 | |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 2730 | public void setDozing(boolean dozing, boolean animate) { |
| 2731 | if (dozing == mDozing) return; |
| 2732 | mDozing = dozing; |
| 2733 | |
| 2734 | if (mStatusBarState == StatusBarState.KEYGUARD |
| 2735 | || mStatusBarState == StatusBarState.SHADE_LOCKED) { |
| 2736 | updateDozingVisibilities(animate); |
Adrian Roos | 52414e3 | 2017-04-28 09:23:19 -0700 | [diff] [blame] | 2737 | } |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 2738 | |
| 2739 | final float darkAmount = dozing ? 1 : 0; |
Adrian Roos | 52414e3 | 2017-04-28 09:23:19 -0700 | [diff] [blame] | 2740 | if (mDarkAnimator != null && mDarkAnimator.isRunning()) { |
Adrian Roos | 51465ea | 2017-07-27 13:57:35 +0200 | [diff] [blame] | 2741 | if (animate && mDarkAmountTarget == darkAmount) { |
| 2742 | return; |
| 2743 | } else { |
| 2744 | mDarkAnimator.cancel(); |
| 2745 | } |
Adrian Roos | 52414e3 | 2017-04-28 09:23:19 -0700 | [diff] [blame] | 2746 | } |
Adrian Roos | 51465ea | 2017-07-27 13:57:35 +0200 | [diff] [blame] | 2747 | mDarkAmountTarget = darkAmount; |
Adrian Roos | 52414e3 | 2017-04-28 09:23:19 -0700 | [diff] [blame] | 2748 | if (animate) { |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 2749 | if (mInterpolatedDarkAmount == 0f || mInterpolatedDarkAmount == 1f) { |
| 2750 | mDarkInterpolator = dozing |
| 2751 | ? Interpolators.FAST_OUT_SLOW_IN |
| 2752 | : Interpolators.TOUCH_RESPONSE_REVERSE; |
| 2753 | } |
| 2754 | mNotificationStackScroller.notifyDarkAnimationStart(dozing); |
Adrian Roos | 52414e3 | 2017-04-28 09:23:19 -0700 | [diff] [blame] | 2755 | mDarkAnimator = ObjectAnimator.ofFloat(this, SET_DARK_AMOUNT_PROPERTY, darkAmount); |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 2756 | mDarkAnimator.setInterpolator(Interpolators.LINEAR); |
| 2757 | mDarkAnimator.setDuration(mNotificationStackScroller.getDarkAnimationDuration(dozing)); |
Adrian Roos | 52414e3 | 2017-04-28 09:23:19 -0700 | [diff] [blame] | 2758 | mDarkAnimator.start(); |
| 2759 | } else { |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 2760 | setDarkAmount(darkAmount, darkAmount); |
Adrian Roos | 52414e3 | 2017-04-28 09:23:19 -0700 | [diff] [blame] | 2761 | } |
| 2762 | } |
| 2763 | |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 2764 | private void setDarkAmount(float linearAmount, float amount) { |
| 2765 | mInterpolatedDarkAmount = amount; |
| 2766 | mLinearDarkAmount = linearAmount; |
| 2767 | mKeyguardStatusView.setDarkAmount(mInterpolatedDarkAmount); |
| 2768 | mKeyguardBottomArea.setDarkAmount(mInterpolatedDarkAmount); |
Adrian Roos | c934c43 | 2017-01-13 11:44:56 -0800 | [diff] [blame] | 2769 | positionClockAndNotifications(); |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 2770 | mNotificationStackScroller.setDarkAmount(linearAmount, mInterpolatedDarkAmount); |
Adrian Roos | c934c43 | 2017-01-13 11:44:56 -0800 | [diff] [blame] | 2771 | } |
Selim Cinek | 24176c3 | 2017-03-01 16:50:30 -0800 | [diff] [blame] | 2772 | |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 2773 | public void setPulsing(boolean pulsing) { |
Lucas Dupin | 5605734 | 2018-04-10 11:49:18 -0700 | [diff] [blame] | 2774 | mPulsing = pulsing; |
Lucas Dupin | 2a6bdfd | 2018-06-12 17:45:21 -0700 | [diff] [blame] | 2775 | DozeParameters dozeParameters = DozeParameters.getInstance(mContext); |
| 2776 | final boolean animatePulse = !dozeParameters.getDisplayNeedsBlanking() |
| 2777 | && dozeParameters.getAlwaysOn(); |
| 2778 | if (animatePulse) { |
Lucas Dupin | 3d7ccaf | 2018-04-02 21:19:23 -0700 | [diff] [blame] | 2779 | mAnimateNextPositionUpdate = true; |
| 2780 | } |
Lucas Dupin | 2a6bdfd | 2018-06-12 17:45:21 -0700 | [diff] [blame] | 2781 | mNotificationStackScroller.setPulsing(pulsing, animatePulse); |
| 2782 | mKeyguardStatusView.setPulsing(pulsing, animatePulse); |
Adrian Roos | d83e999 | 2017-03-16 15:17:57 -0700 | [diff] [blame] | 2783 | } |
Adrian Roos | 75fa964 | 2017-04-18 11:34:56 -0700 | [diff] [blame] | 2784 | |
| 2785 | public void setAmbientIndicationBottomPadding(int ambientIndicationBottomPadding) { |
| 2786 | if (mAmbientIndicationBottomPadding != ambientIndicationBottomPadding) { |
| 2787 | mAmbientIndicationBottomPadding = ambientIndicationBottomPadding; |
| 2788 | mStatusBar.updateKeyguardMaxNotifications(); |
| 2789 | } |
| 2790 | } |
Lucas Dupin | 987f193 | 2017-05-13 21:02:52 -0700 | [diff] [blame] | 2791 | |
Lucas Dupin | 4272f44 | 2018-01-13 22:00:35 -0800 | [diff] [blame] | 2792 | public void dozeTimeTick() { |
Lucas Dupin | 9fedb89 | 2018-05-04 17:42:33 -0700 | [diff] [blame] | 2793 | mKeyguardStatusView.dozeTimeTick(); |
Lucas Dupin | 4272f44 | 2018-01-13 22:00:35 -0800 | [diff] [blame] | 2794 | mKeyguardBottomArea.dozeTimeTick(); |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 2795 | if (mInterpolatedDarkAmount > 0) { |
Adrian Roos | 4fc6de8 | 2017-06-01 16:09:15 -0700 | [diff] [blame] | 2796 | positionClockAndNotifications(); |
| 2797 | } |
Lucas Dupin | 987f193 | 2017-05-13 21:02:52 -0700 | [diff] [blame] | 2798 | } |
| 2799 | |
| 2800 | public void setStatusAccessibilityImportance(int mode) { |
| 2801 | mKeyguardStatusView.setImportantForAccessibility(mode); |
| 2802 | } |
| 2803 | |
| 2804 | /** |
| 2805 | * TODO: this should be removed. |
| 2806 | * It's not correct to pass this view forward because other classes will end up adding |
| 2807 | * children to it. Theme will be out of sync. |
| 2808 | * @return bottom area view |
| 2809 | */ |
| 2810 | public KeyguardBottomAreaView getKeyguardBottomAreaView() { |
| 2811 | return mKeyguardBottomArea; |
| 2812 | } |
| 2813 | |
| 2814 | public void setUserSetupComplete(boolean userSetupComplete) { |
| 2815 | mUserSetupComplete = userSetupComplete; |
| 2816 | mKeyguardBottomArea.setUserSetupComplete(userSetupComplete); |
| 2817 | } |
| 2818 | |
| 2819 | public LockIcon getLockIcon() { |
| 2820 | return mKeyguardBottomArea.getLockIcon(); |
| 2821 | } |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 2822 | |
| 2823 | public void applyExpandAnimationParams(ExpandAnimationParameters params) { |
| 2824 | mExpandOffset = params != null ? params.getTopChange() : 0; |
| 2825 | updateQsExpansion(); |
| 2826 | if (params != null) { |
| 2827 | boolean hideIcons = params.getProgress( |
| 2828 | ActivityLaunchAnimator.ANIMATION_DELAY_ICON_FADE_IN, 100) == 0.0f; |
| 2829 | if (hideIcons != mHideIconsDuringNotificationLaunch) { |
| 2830 | mHideIconsDuringNotificationLaunch = hideIcons; |
| 2831 | if (!hideIcons) { |
| 2832 | mStatusBar.recomputeDisableFlags(true /* animate */); |
| 2833 | } |
| 2834 | } |
| 2835 | } |
| 2836 | } |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 2837 | |
| 2838 | public void addTrackingHeadsUpListener(Consumer<ExpandableNotificationRow> listener) { |
| 2839 | mTrackingHeadsUpListeners.add(listener); |
| 2840 | } |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 2841 | |
Selim Cinek | 60ffea6 | 2018-03-22 13:16:44 -0700 | [diff] [blame] | 2842 | public void removeTrackingHeadsUpListener(Consumer<ExpandableNotificationRow> listener) { |
| 2843 | mTrackingHeadsUpListeners.remove(listener); |
| 2844 | } |
| 2845 | |
| 2846 | public void addVerticalTranslationListener(Runnable verticalTranslationListener) { |
| 2847 | mVerticalTranslationListener.add(verticalTranslationListener); |
| 2848 | } |
| 2849 | |
| 2850 | public void removeVerticalTranslationListener(Runnable verticalTranslationListener) { |
| 2851 | mVerticalTranslationListener.remove(verticalTranslationListener); |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 2852 | } |
| 2853 | |
| 2854 | public void setHeadsUpAppearanceController( |
| 2855 | HeadsUpAppearanceController headsUpAppearanceController) { |
| 2856 | mHeadsUpAppearanceController = headsUpAppearanceController; |
| 2857 | } |
Lucas Dupin | 9375255 | 2018-03-19 21:32:19 -0700 | [diff] [blame] | 2858 | |
| 2859 | /** |
| 2860 | * Starts the animation before we dismiss Keyguard, i.e. an disappearing animation on the |
| 2861 | * security view of the bouncer. |
| 2862 | */ |
| 2863 | public void onBouncerPreHideAnimation() { |
| 2864 | setKeyguardStatusViewVisibility(mStatusBarState, true /* keyguardFadingAway */, |
| 2865 | false /* goingToFullShade */); |
| 2866 | } |
Lucas Dupin | c510d41 | 2018-06-12 13:08:23 -0700 | [diff] [blame] | 2867 | |
| 2868 | @Override |
| 2869 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 2870 | super.dump(fd, pw, args); |
| 2871 | if (mKeyguardStatusBar != null) { |
| 2872 | mKeyguardStatusBar.dump(fd, pw, args); |
| 2873 | } |
| 2874 | } |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2875 | } |