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