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