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