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