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