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