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