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