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