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