Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 17 | package com.android.systemui.statusbar.notification.stack; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 18 | |
Gus Prevas | 59ec2ff | 2018-12-28 16:20:28 -0500 | [diff] [blame] | 19 | import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME; |
Gus Prevas | e83700cb | 2018-12-14 11:42:51 -0500 | [diff] [blame] | 20 | import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator.ExpandAnimationParameters; |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 21 | import static com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.ANCHOR_SCROLLING; |
Gus Prevas | e83700cb | 2018-12-14 11:42:51 -0500 | [diff] [blame] | 22 | import static com.android.systemui.statusbar.notification.stack.StackStateAnimator.ANIMATION_DURATION_SWIPE; |
Gus Prevas | 33619af | 2018-10-26 15:40:27 -0400 | [diff] [blame] | 23 | import static com.android.systemui.statusbar.phone.NotificationIconAreaController.LOW_PRIORITY; |
Gus Prevas | 59ec2ff | 2018-12-28 16:20:28 -0500 | [diff] [blame] | 24 | import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 25 | |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 26 | import android.animation.Animator; |
| 27 | import android.animation.AnimatorListenerAdapter; |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 28 | import android.animation.TimeAnimator; |
| 29 | import android.animation.ValueAnimator; |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 30 | import android.annotation.NonNull; |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 31 | import android.annotation.Nullable; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 32 | import android.app.WallpaperManager; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 33 | import android.content.Context; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 34 | import android.content.Intent; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 35 | import android.content.res.Configuration; |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 36 | import android.content.res.Resources; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 37 | import android.graphics.Canvas; |
Lucas Dupin | d285cf0 | 2018-01-18 09:18:23 -0800 | [diff] [blame] | 38 | import android.graphics.Color; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 39 | import android.graphics.Paint; |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 40 | import android.graphics.PointF; |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 41 | import android.graphics.PorterDuff; |
| 42 | import android.graphics.PorterDuffXfermode; |
| 43 | import android.graphics.Rect; |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 44 | import android.os.Bundle; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 45 | import android.os.ServiceManager; |
| 46 | import android.provider.Settings; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 47 | import android.service.notification.StatusBarNotification; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 48 | import android.util.AttributeSet; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 49 | import android.util.DisplayMetrics; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 50 | import android.util.Log; |
Lucas Dupin | d285cf0 | 2018-01-18 09:18:23 -0800 | [diff] [blame] | 51 | import android.util.MathUtils; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 52 | import android.util.Pair; |
Lucas Dupin | e17ce52 | 2017-07-17 15:45:06 -0700 | [diff] [blame] | 53 | import android.view.ContextThemeWrapper; |
Selim Cinek | 11e3323 | 2016-08-05 15:30:53 -0700 | [diff] [blame] | 54 | import android.view.InputDevice; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 55 | import android.view.LayoutInflater; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 56 | import android.view.MotionEvent; |
| 57 | import android.view.VelocityTracker; |
| 58 | import android.view.View; |
| 59 | import android.view.ViewConfiguration; |
| 60 | import android.view.ViewGroup; |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 61 | import android.view.ViewTreeObserver; |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 62 | import android.view.WindowInsets; |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 63 | import android.view.accessibility.AccessibilityEvent; |
| 64 | import android.view.accessibility.AccessibilityNodeInfo; |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 65 | import android.view.animation.AnimationUtils; |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 66 | import android.view.animation.Interpolator; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 67 | import android.widget.OverScroller; |
Selim Cinek | 41fe89a | 2016-06-02 15:27:56 -0700 | [diff] [blame] | 68 | import android.widget.ScrollView; |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 69 | |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 70 | import com.android.internal.annotations.VisibleForTesting; |
| 71 | import com.android.internal.graphics.ColorUtils; |
Mady Mellor | a41587b | 2016-02-11 18:43:06 -0800 | [diff] [blame] | 72 | import com.android.internal.logging.MetricsLogger; |
Tamas Berghammer | 383db5eb | 2016-06-22 15:21:38 +0100 | [diff] [blame] | 73 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 74 | import com.android.internal.statusbar.IStatusBarService; |
Lucas Dupin | 4e02381 | 2018-04-02 21:19:23 -0700 | [diff] [blame] | 75 | import com.android.keyguard.KeyguardSliceView; |
Lucas Dupin | e17ce52 | 2017-07-17 15:45:06 -0700 | [diff] [blame] | 76 | import com.android.settingslib.Utils; |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 77 | import com.android.systemui.Dependency; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 78 | import com.android.systemui.Dumpable; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 79 | import com.android.systemui.ExpandHelper; |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 80 | import com.android.systemui.Interpolators; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 81 | import com.android.systemui.R; |
| 82 | import com.android.systemui.SwipeHelper; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 83 | import com.android.systemui.classifier.FalsingManager; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 84 | import com.android.systemui.colorextraction.SysuiColorExtractor; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 85 | import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; |
| 86 | import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem; |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 87 | import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.OnMenuEventListener; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 88 | import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 89 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
| 90 | import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 91 | import com.android.systemui.statusbar.CommandQueue; |
| 92 | import com.android.systemui.statusbar.DragDownHelper.DragDownCallback; |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 93 | import com.android.systemui.statusbar.EmptyShadeView; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 94 | import com.android.systemui.statusbar.NotificationLockscreenUserManager; |
| 95 | import com.android.systemui.statusbar.NotificationRemoteInputManager; |
| 96 | import com.android.systemui.statusbar.NotificationShelf; |
| 97 | import com.android.systemui.statusbar.RemoteInputController; |
| 98 | import com.android.systemui.statusbar.StatusBarState; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 99 | import com.android.systemui.statusbar.SysuiStatusBarStateController; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 100 | import com.android.systemui.statusbar.notification.FakeShadowView; |
Gus Prevas | 5ecd2b8 | 2019-01-04 17:19:26 -0500 | [diff] [blame] | 101 | import com.android.systemui.statusbar.notification.NotificationEntryListener; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 102 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
| 103 | import com.android.systemui.statusbar.notification.NotificationUtils; |
| 104 | import com.android.systemui.statusbar.notification.ShadeViewRefactor; |
| 105 | import com.android.systemui.statusbar.notification.ShadeViewRefactor.RefactorComponent; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 106 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 107 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 108 | import com.android.systemui.statusbar.notification.logging.NotificationLogger; |
| 109 | import com.android.systemui.statusbar.notification.row.ActivatableNotificationView; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 110 | import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; |
| 111 | import com.android.systemui.statusbar.notification.row.ExpandableView; |
| 112 | import com.android.systemui.statusbar.notification.row.FooterView; |
| 113 | import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 114 | import com.android.systemui.statusbar.notification.row.NotificationGuts; |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 115 | import com.android.systemui.statusbar.notification.row.NotificationGutsManager; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 116 | import com.android.systemui.statusbar.notification.row.NotificationSnooze; |
| 117 | import com.android.systemui.statusbar.notification.row.StackScrollerDecorView; |
Lucas Dupin | 7fc9dc1 | 2019-01-03 09:19:43 -0800 | [diff] [blame] | 118 | import com.android.systemui.statusbar.phone.DozeParameters; |
Selim Cinek | f0c79e1 | 2018-05-14 17:17:31 -0700 | [diff] [blame] | 119 | import com.android.systemui.statusbar.phone.HeadsUpAppearanceController; |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 120 | import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 121 | import com.android.systemui.statusbar.phone.HeadsUpTouchHelper; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 122 | import com.android.systemui.statusbar.phone.LockscreenGestureLogger; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 123 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 124 | import com.android.systemui.statusbar.phone.NotificationGroupManager.OnGroupChangeListener; |
Selim Cinek | 9bfc7a5 | 2018-06-11 16:09:00 -0700 | [diff] [blame] | 125 | import com.android.systemui.statusbar.phone.NotificationIconAreaController; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 126 | import com.android.systemui.statusbar.phone.NotificationPanelView; |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 127 | import com.android.systemui.statusbar.phone.ScrimController; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 128 | import com.android.systemui.statusbar.phone.ShadeController; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 129 | import com.android.systemui.statusbar.phone.StatusBar; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 130 | import com.android.systemui.statusbar.policy.ConfigurationController; |
| 131 | import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 132 | import com.android.systemui.statusbar.policy.HeadsUpUtil; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 133 | import com.android.systemui.statusbar.policy.ScrollAdapter; |
Gus Prevas | 33619af | 2018-10-26 15:40:27 -0400 | [diff] [blame] | 134 | import com.android.systemui.tuner.TunerService; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 135 | |
Selim Cinek | 707e207 | 2017-06-30 18:32:40 +0200 | [diff] [blame] | 136 | import java.io.FileDescriptor; |
| 137 | import java.io.PrintWriter; |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 138 | import java.util.ArrayList; |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 139 | import java.util.Collections; |
| 140 | import java.util.Comparator; |
Jorim Jaggi | ff9c9c4 | 2014-08-01 05:36:22 +0200 | [diff] [blame] | 141 | import java.util.HashSet; |
Selim Cinek | ef8c225 | 2017-02-10 14:52:18 -0800 | [diff] [blame] | 142 | import java.util.List; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 143 | import java.util.function.BiConsumer; |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 144 | |
Gus Prevas | 59ec2ff | 2018-12-28 16:20:28 -0500 | [diff] [blame] | 145 | import javax.inject.Inject; |
| 146 | import javax.inject.Named; |
| 147 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 148 | /** |
| 149 | * A layout which handles a dynamic amount of notifications and presents them in a scrollable stack. |
| 150 | */ |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 151 | public class NotificationStackScrollLayout extends ViewGroup implements ScrollAdapter, |
| 152 | NotificationListContainer, ConfigurationListener, Dumpable { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 153 | |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 154 | public static final float BACKGROUND_ALPHA_DIMMED = 0.7f; |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 155 | private static final String TAG = "StackScroller"; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 156 | private static final boolean DEBUG = false; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 157 | private static final float RUBBER_BAND_FACTOR_NORMAL = 0.35f; |
| 158 | private static final float RUBBER_BAND_FACTOR_AFTER_EXPAND = 0.15f; |
Jorim Jaggi | 47c85a3 | 2014-06-05 17:25:40 +0200 | [diff] [blame] | 159 | private static final float RUBBER_BAND_FACTOR_ON_PANEL_EXPAND = 0.21f; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 160 | /** |
| 161 | * Sentinel value for no current active pointer. Used by {@link #mActivePointerId}. |
| 162 | */ |
Lucas Dupin | d285cf0 | 2018-01-18 09:18:23 -0800 | [diff] [blame] | 163 | private static final int INVALID_POINTER = -1; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 164 | static final int NUM_SECTIONS = 2; |
| 165 | /** |
| 166 | * The distance in pixels between sections when the sections are directly adjacent (no visible |
| 167 | * gap is drawn between them). In this case we don't want to round their corners. |
| 168 | */ |
| 169 | private static final int DISTANCE_BETWEEN_ADJACENT_SECTIONS_PX = 1; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 170 | |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 171 | private ExpandHelper mExpandHelper; |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 172 | private final NotificationSwipeHelper mSwipeHelper; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 173 | private int mCurrentStackHeight = Integer.MAX_VALUE; |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 174 | private final Paint mBackgroundPaint = new Paint(); |
Adrian Roos | f0b4f96 | 2017-05-25 11:53:11 -0700 | [diff] [blame] | 175 | private final boolean mShouldDrawNotificationBackground; |
Gus Prevas | 33619af | 2018-10-26 15:40:27 -0400 | [diff] [blame] | 176 | private boolean mLowPriorityBeforeSpeedBump; |
Gus Prevas | 59ec2ff | 2018-12-28 16:20:28 -0500 | [diff] [blame] | 177 | private final boolean mAllowLongPress; |
Gus Prevas | a18dc57 | 2019-01-14 16:11:22 -0500 | [diff] [blame] | 178 | private boolean mDismissRtl; |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 179 | |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 180 | private float mExpandedHeight; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 181 | private int mOwnScrollY; |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 182 | private View mScrollAnchorView; |
| 183 | private int mScrollAnchorViewY; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 184 | private int mMaxLayoutHeight; |
| 185 | |
| 186 | private VelocityTracker mVelocityTracker; |
| 187 | private OverScroller mScroller; |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 188 | /** Last Y position reported by {@link #mScroller}, used to calculate scroll delta. */ |
| 189 | private int mLastScrollerY; |
| 190 | /** |
| 191 | * True if the max position was set to a known position on the last call to {@link #mScroller}. |
| 192 | */ |
| 193 | private boolean mIsScrollerBoundSet; |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 194 | private Runnable mFinishScrollingCallback; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 195 | private int mTouchSlop; |
| 196 | private int mMinimumVelocity; |
| 197 | private int mMaximumVelocity; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 198 | private int mOverflingDistance; |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 199 | private float mMaxOverScroll; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 200 | private boolean mIsBeingDragged; |
| 201 | private int mLastMotionY; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 202 | private int mDownX; |
Dong-wan Kim | b926666 | 2016-09-21 13:08:30 -0700 | [diff] [blame] | 203 | private int mActivePointerId = INVALID_POINTER; |
Selim Cinek | 3a9c10a | 2014-10-28 14:21:10 +0100 | [diff] [blame] | 204 | private boolean mTouchIsClick; |
| 205 | private float mInitialTouchX; |
| 206 | private float mInitialTouchY; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 207 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 208 | private Paint mDebugPaint; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 209 | private int mContentHeight; |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 210 | private int mIntrinsicContentHeight; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 211 | private int mCollapsedSize; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 212 | private int mPaddingBetweenElements; |
Selim Cinek | 61633a8 | 2016-01-25 15:54:10 -0800 | [diff] [blame] | 213 | private int mIncreasedPaddingBetweenElements; |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 214 | private int mMaxTopPadding; |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 215 | private int mTopPadding; |
Anthony Chen | 9fe1ee7 | 2017-04-07 13:53:37 -0700 | [diff] [blame] | 216 | private int mBottomMargin; |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 217 | private int mBottomInset = 0; |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 218 | private float mQsExpansionFraction; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 219 | |
| 220 | /** |
| 221 | * The algorithm which calculates the properties for our children |
| 222 | */ |
Muyuan Li | 8779802 | 2016-04-07 17:51:25 -0700 | [diff] [blame] | 223 | protected final StackScrollAlgorithm mStackScrollAlgorithm; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 224 | |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 225 | private final AmbientState mAmbientState; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 226 | private NotificationGroupManager mGroupManager; |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 227 | private HashSet<ExpandableView> mChildrenToAddAnimated = new HashSet<>(); |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 228 | private ArrayList<View> mAddedHeadsUpChildren = new ArrayList<>(); |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 229 | private ArrayList<ExpandableView> mChildrenToRemoveAnimated = new ArrayList<>(); |
| 230 | private ArrayList<ExpandableView> mChildrenChangingPositions = new ArrayList<>(); |
Jorim Jaggi | ff9c9c4 | 2014-08-01 05:36:22 +0200 | [diff] [blame] | 231 | private HashSet<View> mFromMoreCardAdditions = new HashSet<>(); |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 232 | private ArrayList<AnimationEvent> mAnimationEvents = new ArrayList<>(); |
| 233 | private ArrayList<View> mSwipedOutViews = new ArrayList<>(); |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 234 | private final StackStateAnimator mStateAnimator = new StackStateAnimator(this); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 235 | private boolean mAnimationsEnabled; |
Selim Cinek | 159ffdb | 2014-06-04 22:24:18 +0200 | [diff] [blame] | 236 | private boolean mChangePositionInProgress; |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 237 | private boolean mChildTransferInProgress; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 238 | |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 239 | /** |
| 240 | * The raw amount of the overScroll on the top, which is not rubber-banded. |
| 241 | */ |
| 242 | private float mOverScrolledTopPixels; |
| 243 | |
| 244 | /** |
| 245 | * The raw amount of the overScroll on the bottom, which is not rubber-banded. |
| 246 | */ |
| 247 | private float mOverScrolledBottomPixels; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 248 | private NotificationLogger.OnChildLocationsChangedListener mListener; |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 249 | private OnOverscrollTopChangedListener mOverscrollTopChangedListener; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 250 | private ExpandableView.OnHeightChangedListener mOnHeightChangedListener; |
Selim Cinek | 3a9c10a | 2014-10-28 14:21:10 +0100 | [diff] [blame] | 251 | private OnEmptySpaceClickListener mOnEmptySpaceClickListener; |
Jorim Jaggi | 0dd6881 | 2014-05-01 19:17:37 +0200 | [diff] [blame] | 252 | private boolean mNeedsAnimation; |
| 253 | private boolean mTopPaddingNeedsAnimation; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 254 | private boolean mDimmedNeedsAnimation; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 255 | private boolean mHideSensitiveNeedsAnimation; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 256 | private boolean mDarkNeedsAnimation; |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 257 | private int mDarkAnimationOriginIndex; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 258 | private boolean mActivateNeedsAnimation; |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 259 | private boolean mGoToFullShadeNeedsAnimation; |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 260 | private boolean mIsExpanded = true; |
Selim Cinek | 1f553cf | 2014-05-02 12:01:36 +0200 | [diff] [blame] | 261 | private boolean mChildrenUpdateRequested; |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 262 | private boolean mIsExpansionChanging; |
Jorim Jaggi | e4b840d | 2015-06-30 16:19:17 -0700 | [diff] [blame] | 263 | private boolean mPanelTracking; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 264 | private boolean mExpandingNotification; |
| 265 | private boolean mExpandedInThisMotion; |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 266 | private boolean mShouldShowShelfOnly; |
Muyuan Li | 84b4561 | 2016-06-01 11:05:08 -0700 | [diff] [blame] | 267 | protected boolean mScrollingEnabled; |
Julia Reynolds | ed1c9af | 2018-03-21 15:21:09 -0400 | [diff] [blame] | 268 | protected FooterView mFooterView; |
Muyuan Li | dd9ae75 | 2016-05-13 16:45:43 -0700 | [diff] [blame] | 269 | protected EmptyShadeView mEmptyShadeView; |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 270 | private boolean mDismissAllInProgress; |
Anthony Chen | 7acbb77 | 2017-04-07 16:45:25 -0700 | [diff] [blame] | 271 | private boolean mFadeNotificationsOnDismiss; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 272 | |
| 273 | /** |
| 274 | * Was the scroller scrolled to the top when the down motion was observed? |
| 275 | */ |
| 276 | private boolean mScrolledToTopOnFirstDown; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 277 | /** |
| 278 | * The minimal amount of over scroll which is needed in order to switch to the quick settings |
| 279 | * when over scrolling on a expanded card. |
| 280 | */ |
| 281 | private float mMinTopOverScrollToEscape; |
| 282 | private int mIntrinsicPadding; |
Selim Cinek | d228115 | 2015-04-10 14:37:46 -0700 | [diff] [blame] | 283 | private float mStackTranslation; |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 284 | private float mTopPaddingOverflow; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 285 | private boolean mDontReportNextOverScroll; |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 286 | private boolean mDontClampNextScroll; |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 287 | private boolean mNeedViewResizeAnimation; |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 288 | private ExpandableView mExpandedGroupView; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 289 | private boolean mEverythingNeedsAnimation; |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 290 | |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 291 | /** |
| 292 | * The maximum scrollPosition which we are allowed to reach when a notification was expanded. |
| 293 | * This is needed to avoid scrolling too far after the notification was collapsed in the same |
| 294 | * motion. |
| 295 | */ |
| 296 | private int mMaxScrollAfterExpand; |
Geoffrey Pitsch | 409db27 | 2017-08-28 14:51:52 +0000 | [diff] [blame] | 297 | private ExpandableNotificationRow.LongPressListener mLongPressListener; |
Mady Mellor | c2dbe49 | 2017-03-30 13:22:03 -0700 | [diff] [blame] | 298 | boolean mCheckForLeavebehind; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 299 | |
| 300 | /** |
| 301 | * Should in this touch motion only be scrolling allowed? It's true when the scroller was |
| 302 | * animating. |
| 303 | */ |
| 304 | private boolean mOnlyScrollingInThisMotion; |
Adrian Roos | fa13975 | 2016-04-27 09:59:08 -0700 | [diff] [blame] | 305 | private boolean mDisallowDismissInThisMotion; |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 306 | private boolean mDisallowScrollingInThisMotion; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 307 | private long mGoToFullShadeDelay; |
Selim Cinek | 1f553cf | 2014-05-02 12:01:36 +0200 | [diff] [blame] | 308 | private ViewTreeObserver.OnPreDrawListener mChildrenUpdater |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 309 | = new ViewTreeObserver.OnPreDrawListener() { |
| 310 | @Override |
| 311 | public boolean onPreDraw() { |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 312 | updateForcedScroll(); |
Selim Cinek | 1f553cf | 2014-05-02 12:01:36 +0200 | [diff] [blame] | 313 | updateChildren(); |
| 314 | mChildrenUpdateRequested = false; |
| 315 | getViewTreeObserver().removeOnPreDrawListener(this); |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 316 | return true; |
| 317 | } |
| 318 | }; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 319 | private StatusBar mStatusBar; |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 320 | private int[] mTempInt2 = new int[2]; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 321 | private boolean mGenerateChildOrderChangedEvent; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 322 | private HashSet<Runnable> mAnimationFinishedRunnables = new HashSet<>(); |
Selim Cinek | 9dd0d04 | 2018-05-14 18:12:42 -0700 | [diff] [blame] | 323 | private HashSet<ExpandableView> mClearTransientViewsWhenFinished = new HashSet<>(); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 324 | private HashSet<Pair<ExpandableNotificationRow, Boolean>> mHeadsUpChangeAnimations |
| 325 | = new HashSet<>(); |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 326 | private HeadsUpManagerPhone mHeadsUpManager; |
Lucas Dupin | 00be88f | 2019-01-03 17:50:52 -0800 | [diff] [blame] | 327 | private final NotificationRoundnessManager mRoundnessManager; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 328 | private boolean mTrackingHeadsUp; |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 329 | private ScrimController mScrimController; |
Selim Cinek | bbc580b | 2015-06-03 14:11:03 +0200 | [diff] [blame] | 330 | private boolean mForceNoOverlappingRendering; |
Selim Cinek | e0890e5 | 2015-06-17 11:17:08 -0700 | [diff] [blame] | 331 | private final ArrayList<Pair<ExpandableNotificationRow, Boolean>> mTmpList = new ArrayList<>(); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 332 | private FalsingManager mFalsingManager; |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 333 | private boolean mAnimationRunning; |
Selim Cinek | c383fd0 | 2016-10-21 15:31:26 -0700 | [diff] [blame] | 334 | private ViewTreeObserver.OnPreDrawListener mRunningAnimationUpdater |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 335 | = new ViewTreeObserver.OnPreDrawListener() { |
| 336 | @Override |
| 337 | public boolean onPreDraw() { |
Selim Cinek | c383fd0 | 2016-10-21 15:31:26 -0700 | [diff] [blame] | 338 | onPreDrawDuringAnimation(); |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 339 | return true; |
| 340 | } |
| 341 | }; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 342 | private NotificationSection[] mSections = new NotificationSection[NUM_SECTIONS]; |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 343 | private boolean mAnimateNextBackgroundTop; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 344 | private boolean mAnimateNextBackgroundBottom; |
| 345 | private boolean mAnimateNextSectionBoundsChange; |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 346 | private int mBgColor; |
| 347 | private float mDimAmount; |
| 348 | private ValueAnimator mDimAnimator; |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 349 | private ArrayList<ExpandableView> mTmpSortedChildren = new ArrayList<>(); |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 350 | private final Animator.AnimatorListener mDimEndListener = new AnimatorListenerAdapter() { |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 351 | @Override |
| 352 | public void onAnimationEnd(Animator animation) { |
| 353 | mDimAnimator = null; |
| 354 | } |
| 355 | }; |
| 356 | private ValueAnimator.AnimatorUpdateListener mDimUpdateListener |
| 357 | = new ValueAnimator.AnimatorUpdateListener() { |
| 358 | |
| 359 | @Override |
| 360 | public void onAnimationUpdate(ValueAnimator animation) { |
| 361 | setDimAmount((Float) animation.getAnimatedValue()); |
| 362 | } |
| 363 | }; |
Muyuan Li | 4fe4a40 | 2016-03-30 16:50:11 -0700 | [diff] [blame] | 364 | protected ViewGroup mQsContainer; |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 365 | private boolean mContinuousShadowUpdate; |
| 366 | private ViewTreeObserver.OnPreDrawListener mShadowUpdater |
| 367 | = new ViewTreeObserver.OnPreDrawListener() { |
| 368 | |
| 369 | @Override |
| 370 | public boolean onPreDraw() { |
| 371 | updateViewShadows(); |
| 372 | return true; |
| 373 | } |
| 374 | }; |
| 375 | private Comparator<ExpandableView> mViewPositionComparator = new Comparator<ExpandableView>() { |
| 376 | @Override |
| 377 | public int compare(ExpandableView view, ExpandableView otherView) { |
| 378 | float endY = view.getTranslationY() + view.getActualHeight(); |
| 379 | float otherEndY = otherView.getTranslationY() + otherView.getActualHeight(); |
| 380 | if (endY < otherEndY) { |
| 381 | return -1; |
| 382 | } else if (endY > otherEndY) { |
| 383 | return 1; |
| 384 | } else { |
| 385 | // The two notifications end at the same location |
| 386 | return 0; |
| 387 | } |
| 388 | } |
| 389 | }; |
Selim Cinek | 2550325 | 2016-03-03 15:31:43 -0800 | [diff] [blame] | 390 | private PorterDuffXfermode mSrcMode = new PorterDuffXfermode(PorterDuff.Mode.SRC); |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 391 | private boolean mPulsing; |
Selim Cinek | 1b2a05e | 2016-04-28 14:20:39 -0700 | [diff] [blame] | 392 | private boolean mGroupExpandedForMeasure; |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 393 | private boolean mScrollable; |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 394 | private View mForcedScroll; |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 395 | private ExpandableView mNeedingPulseAnimation; |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 396 | |
| 397 | /** |
| 398 | * @see #setDarkAmount(float, float) |
| 399 | */ |
| 400 | private float mInterpolatedDarkAmount = 0f; |
| 401 | |
| 402 | /** |
| 403 | * @see #setDarkAmount(float, float) |
| 404 | */ |
| 405 | private float mLinearDarkAmount = 0f; |
Lucas Dupin | 439bd44 | 2018-06-12 15:05:28 -0700 | [diff] [blame] | 406 | |
| 407 | /** |
| 408 | * How fast the background scales in the X direction as a factor of the Y expansion. |
| 409 | */ |
| 410 | private float mBackgroundXFactor = 1f; |
Selim Cinek | 972123d | 2016-05-03 14:25:58 -0700 | [diff] [blame] | 411 | |
Aaron Heuckroth | 9dc9d4f | 2018-11-15 11:04:01 -0500 | [diff] [blame] | 412 | private boolean mSwipingInProgress; |
| 413 | |
Lucas Dupin | e17ce52 | 2017-07-17 15:45:06 -0700 | [diff] [blame] | 414 | private boolean mUsingLightTheme; |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 415 | private boolean mQsExpanded; |
Selim Cinek | ef40606 | 2016-09-29 17:33:13 -0700 | [diff] [blame] | 416 | private boolean mForwardScrollable; |
| 417 | private boolean mBackwardScrollable; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 418 | private NotificationShelf mShelf; |
Selim Cinek | ad7fac0 | 2016-10-18 17:09:15 -0700 | [diff] [blame] | 419 | private int mMaxDisplayedNotifications = -1; |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 420 | private int mStatusBarHeight; |
Selim Cinek | 51d2197 | 2017-07-19 17:39:20 -0700 | [diff] [blame] | 421 | private int mMinInteractionHeight; |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 422 | private boolean mNoAmbient; |
| 423 | private final Rect mClipRect = new Rect(); |
| 424 | private boolean mIsClipped; |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 425 | private Rect mRequestedClipBounds; |
| 426 | private boolean mInHeadsUpPinnedMode; |
| 427 | private boolean mHeadsUpAnimatingAway; |
Selim Cinek | 355652a | 2016-12-07 13:32:12 -0800 | [diff] [blame] | 428 | private int mStatusBarState; |
Selim Cinek | fb6ee6d | 2016-12-29 16:49:26 +0100 | [diff] [blame] | 429 | private int mCachedBackgroundColor; |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 430 | private boolean mHeadsUpGoingAwayAnimationsAllowed = true; |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 431 | private Runnable mReflingAndAnimateScroll = () -> { |
| 432 | if (ANCHOR_SCROLLING) { |
| 433 | maybeReflingScroller(); |
| 434 | } |
| 435 | animateScroll(); |
| 436 | }; |
Selim Cinek | 0fe0739 | 2017-11-09 13:26:34 -0800 | [diff] [blame] | 437 | private int mCornerRadius; |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 438 | private int mSidePaddings; |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 439 | private final Rect mBackgroundAnimationRect = new Rect(); |
Lucas Dupin | 0cd882f | 2018-01-30 12:19:49 -0800 | [diff] [blame] | 440 | private int mAntiBurnInOffsetX; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 441 | private ArrayList<BiConsumer<Float, Float>> mExpandedHeightListeners = new ArrayList<>(); |
| 442 | private int mHeadsUpInset; |
Selim Cinek | f0c79e1 | 2018-05-14 17:17:31 -0700 | [diff] [blame] | 443 | private HeadsUpAppearanceController mHeadsUpAppearanceController; |
Selim Cinek | 9bfc7a5 | 2018-06-11 16:09:00 -0700 | [diff] [blame] | 444 | private NotificationIconAreaController mIconAreaController; |
Lucas Dupin | b46d0a2 | 2019-01-11 16:57:16 -0800 | [diff] [blame] | 445 | private float mHorizontalPanelTranslation; |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 446 | private final NotificationLockscreenUserManager mLockscreenUserManager = |
| 447 | Dependency.get(NotificationLockscreenUserManager.class); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 448 | protected final NotificationGutsManager mGutsManager = |
| 449 | Dependency.get(NotificationGutsManager.class); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 450 | private final Rect mTmpRect = new Rect(); |
| 451 | private final NotificationEntryManager mEntryManager = |
| 452 | Dependency.get(NotificationEntryManager.class); |
| 453 | private final IStatusBarService mBarService = IStatusBarService.Stub.asInterface( |
| 454 | ServiceManager.getService(Context.STATUS_BAR_SERVICE)); |
Will Brockman | e718d58 | 2019-01-17 16:38:38 -0500 | [diff] [blame] | 455 | @VisibleForTesting |
| 456 | protected final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 457 | private final NotificationRemoteInputManager mRemoteInputManager = |
| 458 | Dependency.get(NotificationRemoteInputManager.class); |
| 459 | private final SysuiColorExtractor mColorExtractor = Dependency.get(SysuiColorExtractor.class); |
| 460 | |
| 461 | private final DisplayMetrics mDisplayMetrics = Dependency.get(DisplayMetrics.class); |
| 462 | private final LockscreenGestureLogger mLockscreenGestureLogger = |
| 463 | Dependency.get(LockscreenGestureLogger.class); |
| 464 | private final VisualStabilityManager mVisualStabilityManager = |
| 465 | Dependency.get(VisualStabilityManager.class); |
| 466 | protected boolean mClearAllEnabled; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 467 | |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 468 | private Interpolator mDarkXInterpolator = Interpolators.FAST_OUT_SLOW_IN; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 469 | private NotificationPanelView mNotificationPanel; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 470 | private final ShadeController mShadeController = Dependency.get(ShadeController.class); |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 471 | |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 472 | private final NotificationGutsManager |
| 473 | mNotificationGutsManager = Dependency.get(NotificationGutsManager.class); |
Lucas Dupin | 7fc9dc1 | 2019-01-03 09:19:43 -0800 | [diff] [blame] | 474 | /** |
| 475 | * If the {@link NotificationShelf} should be visible when dark. |
| 476 | */ |
| 477 | private boolean mShowDarkShelf; |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 478 | |
Gus Prevas | 59ec2ff | 2018-12-28 16:20:28 -0500 | [diff] [blame] | 479 | @Inject |
| 480 | public NotificationStackScrollLayout( |
| 481 | @Named(VIEW_CONTEXT) Context context, |
| 482 | AttributeSet attrs, |
Lucas Dupin | 00be88f | 2019-01-03 17:50:52 -0800 | [diff] [blame] | 483 | @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowLongPress, |
| 484 | NotificationRoundnessManager notificationRoundnessManager) { |
Gus Prevas | 59ec2ff | 2018-12-28 16:20:28 -0500 | [diff] [blame] | 485 | super(context, attrs, 0, 0); |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 486 | Resources res = getResources(); |
| 487 | |
Gus Prevas | 59ec2ff | 2018-12-28 16:20:28 -0500 | [diff] [blame] | 488 | mAllowLongPress = allowLongPress; |
| 489 | |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 490 | for (int i = 0; i < NUM_SECTIONS; i++) { |
| 491 | mSections[i] = new NotificationSection(this); |
| 492 | } |
| 493 | |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 494 | mAmbientState = new AmbientState(context); |
Lucas Dupin | 00be88f | 2019-01-03 17:50:52 -0800 | [diff] [blame] | 495 | mRoundnessManager = notificationRoundnessManager; |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 496 | mBgColor = context.getColor(R.color.notification_shade_background_color); |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 497 | int minHeight = res.getDimensionPixelSize(R.dimen.notification_min_height); |
| 498 | int maxHeight = res.getDimensionPixelSize(R.dimen.notification_max_height); |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 499 | mExpandHelper = new ExpandHelper(getContext(), mExpandHelperCallback, |
Selim Cinek | 1cf41c1 | 2014-08-12 20:06:19 +0200 | [diff] [blame] | 500 | minHeight, maxHeight); |
| 501 | mExpandHelper.setEventSource(this); |
| 502 | mExpandHelper.setScrollAdapter(this); |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 503 | mSwipeHelper = new NotificationSwipeHelper(SwipeHelper.X, mNotificationCallback, |
| 504 | getContext(), mMenuEventListener); |
Muyuan Li | 333a4fc | 2016-04-16 17:13:46 -0700 | [diff] [blame] | 505 | mStackScrollAlgorithm = createStackScrollAlgorithm(context); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 506 | initView(context); |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 507 | mFalsingManager = FalsingManager.getInstance(context); |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 508 | mShouldDrawNotificationBackground = |
| 509 | res.getBoolean(R.bool.config_drawNotificationBackground); |
Anthony Chen | 7acbb77 | 2017-04-07 16:45:25 -0700 | [diff] [blame] | 510 | mFadeNotificationsOnDismiss = |
| 511 | res.getBoolean(R.bool.config_fadeNotificationsOnDismiss); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 512 | mRoundnessManager.setAnimatedChildren(mChildrenToAddAnimated); |
| 513 | mRoundnessManager.setOnRoundingChangedCallback(this::invalidate); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 514 | addOnExpandedHeightListener(mRoundnessManager::setExpanded); |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 515 | |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 516 | // Blocking helper manager wants to know the expanded state, update as well. |
| 517 | NotificationBlockingHelperManager blockingHelperManager = |
| 518 | Dependency.get(NotificationBlockingHelperManager.class); |
| 519 | addOnExpandedHeightListener((height, unused) -> { |
| 520 | blockingHelperManager.setNotificationShadeExpanded(height); |
| 521 | }); |
| 522 | |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 523 | updateWillNotDraw(); |
Lucas Dupin | d285cf0 | 2018-01-18 09:18:23 -0800 | [diff] [blame] | 524 | mBackgroundPaint.setAntiAlias(true); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 525 | if (DEBUG) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 526 | mDebugPaint = new Paint(); |
| 527 | mDebugPaint.setColor(0xffff0000); |
| 528 | mDebugPaint.setStrokeWidth(2); |
| 529 | mDebugPaint.setStyle(Paint.Style.STROKE); |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 530 | mDebugPaint.setTextSize(25f); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 531 | } |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 532 | mClearAllEnabled = res.getBoolean(R.bool.config_enableNotificationsClearAll); |
Gus Prevas | 33619af | 2018-10-26 15:40:27 -0400 | [diff] [blame] | 533 | |
| 534 | TunerService tunerService = Dependency.get(TunerService.class); |
| 535 | tunerService.addTunable((key, newValue) -> { |
| 536 | if (key.equals(LOW_PRIORITY)) { |
| 537 | mLowPriorityBeforeSpeedBump = "1".equals(newValue); |
Gus Prevas | a18dc57 | 2019-01-14 16:11:22 -0500 | [diff] [blame] | 538 | } else if (key.equals(Settings.Secure.NOTIFICATION_DISMISS_RTL)) { |
| 539 | updateDismissRtlSetting("1".equals(newValue)); |
Gus Prevas | 33619af | 2018-10-26 15:40:27 -0400 | [diff] [blame] | 540 | } |
Gus Prevas | a18dc57 | 2019-01-14 16:11:22 -0500 | [diff] [blame] | 541 | }, LOW_PRIORITY, Settings.Secure.NOTIFICATION_DISMISS_RTL); |
Gus Prevas | 5ecd2b8 | 2019-01-04 17:19:26 -0500 | [diff] [blame] | 542 | |
| 543 | mEntryManager.addNotificationEntryListener(new NotificationEntryListener() { |
| 544 | @Override |
Mady Mellor | 0ad5b9d | 2019-01-08 14:59:55 -0800 | [diff] [blame] | 545 | public void onPostEntryUpdated(NotificationEntry entry) { |
Gus Prevas | 5ecd2b8 | 2019-01-04 17:19:26 -0500 | [diff] [blame] | 546 | if (!entry.notification.isClearable()) { |
| 547 | // The user may have performed a dismiss action on the notification, since it's |
| 548 | // not clearable we should snap it back. |
| 549 | snapViewIfNeeded(entry); |
| 550 | } |
| 551 | } |
| 552 | }); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 553 | } |
| 554 | |
Gus Prevas | a18dc57 | 2019-01-14 16:11:22 -0500 | [diff] [blame] | 555 | private void updateDismissRtlSetting(boolean dismissRtl) { |
| 556 | mDismissRtl = dismissRtl; |
| 557 | for (int i = 0; i < getChildCount(); i++) { |
| 558 | View child = getChildAt(i); |
| 559 | if (child instanceof ExpandableNotificationRow) { |
| 560 | ((ExpandableNotificationRow) child).setDismissRtl(dismissRtl); |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 565 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 566 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 567 | protected void onFinishInflate() { |
| 568 | super.onFinishInflate(); |
| 569 | |
| 570 | inflateEmptyShadeView(); |
| 571 | inflateFooterView(); |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 572 | mVisualStabilityManager.setVisibilityLocationProvider(this::isInVisibleLocation); |
Gus Prevas | 59ec2ff | 2018-12-28 16:20:28 -0500 | [diff] [blame] | 573 | if (mAllowLongPress) { |
| 574 | setLongPressListener(mGutsManager::openGuts); |
| 575 | } |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 576 | } |
| 577 | |
| 578 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 579 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 580 | public void onDensityOrFontScaleChanged() { |
Selim Cinek | dd26a7e | 2019-02-11 18:42:55 -0800 | [diff] [blame] | 581 | reinflateViews(); |
| 582 | } |
| 583 | |
| 584 | private void reinflateViews() { |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 585 | inflateFooterView(); |
| 586 | inflateEmptyShadeView(); |
| 587 | updateFooter(); |
| 588 | } |
| 589 | |
| 590 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 591 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 592 | public void onThemeChanged() { |
| 593 | int which; |
| 594 | if (mStatusBarState == StatusBarState.KEYGUARD |
| 595 | || mStatusBarState == StatusBarState.SHADE_LOCKED) { |
| 596 | which = WallpaperManager.FLAG_LOCK; |
| 597 | } else { |
| 598 | which = WallpaperManager.FLAG_SYSTEM; |
| 599 | } |
| 600 | final boolean useDarkText = mColorExtractor.getColors(which, |
| 601 | true /* ignoreVisibility */).supportsDarkText(); |
| 602 | updateDecorViews(useDarkText); |
| 603 | |
| 604 | updateFooter(); |
| 605 | } |
| 606 | |
Fabian Kozynski | d254b19 | 2019-02-05 13:42:58 -0500 | [diff] [blame] | 607 | @Override |
| 608 | public void onOverlayChanged() { |
| 609 | int newRadius = mContext.getResources().getDimensionPixelSize( |
| 610 | Utils.getThemeAttr(mContext, android.R.attr.dialogCornerRadius)); |
| 611 | if (mCornerRadius != newRadius) { |
| 612 | mCornerRadius = newRadius; |
| 613 | invalidate(); |
| 614 | } |
Selim Cinek | dd26a7e | 2019-02-11 18:42:55 -0800 | [diff] [blame] | 615 | reinflateViews(); |
Fabian Kozynski | d254b19 | 2019-02-05 13:42:58 -0500 | [diff] [blame] | 616 | } |
| 617 | |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 618 | @VisibleForTesting |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 619 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 620 | public void updateFooter() { |
| 621 | boolean showDismissView = mClearAllEnabled && hasActiveClearableNotifications(); |
| 622 | boolean showFooterView = (showDismissView || |
| 623 | mEntryManager.getNotificationData().getActiveNotifications().size() != 0) |
| 624 | && mStatusBarState != StatusBarState.KEYGUARD |
| 625 | && !mRemoteInputManager.getController().isRemoteInputActive(); |
| 626 | |
| 627 | updateFooterView(showFooterView, showDismissView); |
| 628 | } |
| 629 | |
| 630 | /** |
| 631 | * Return whether there are any clearable notifications |
| 632 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 633 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 634 | public boolean hasActiveClearableNotifications() { |
| 635 | int childCount = getChildCount(); |
| 636 | for (int i = 0; i < childCount; i++) { |
| 637 | View child = getChildAt(i); |
| 638 | if (!(child instanceof ExpandableNotificationRow)) { |
| 639 | continue; |
| 640 | } |
| 641 | if (((ExpandableNotificationRow) child).canViewBeDismissed()) { |
| 642 | return true; |
| 643 | } |
| 644 | } |
| 645 | return false; |
| 646 | } |
| 647 | |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 648 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 649 | public RemoteInputController.Delegate createDelegate() { |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 650 | return new RemoteInputController.Delegate() { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 651 | public void setRemoteInputActive(NotificationEntry entry, |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 652 | boolean remoteInputActive) { |
| 653 | mHeadsUpManager.setRemoteInputActive(entry, remoteInputActive); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 654 | entry.notifyHeightChanged(true /* needsAnimation */); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 655 | updateFooter(); |
| 656 | } |
| 657 | |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 658 | public void lockScrollTo(NotificationEntry entry) { |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 659 | NotificationStackScrollLayout.this.lockScrollTo(entry.getRow()); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | public void requestDisallowLongPressAndDismiss() { |
| 663 | requestDisallowLongPress(); |
| 664 | requestDisallowDismiss(); |
| 665 | } |
| 666 | }; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 667 | } |
| 668 | |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 669 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 670 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 671 | protected void onAttachedToWindow() { |
| 672 | super.onAttachedToWindow(); |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 673 | ((SysuiStatusBarStateController) Dependency.get(StatusBarStateController.class)) |
| 674 | .addCallback(mStateListener, SysuiStatusBarStateController.RANK_STACK_SCROLLER); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 675 | Dependency.get(ConfigurationController.class).addCallback(this); |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 679 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 680 | protected void onDetachedFromWindow() { |
| 681 | super.onDetachedFromWindow(); |
Jason Monk | af08c15 | 2018-12-04 11:12:39 -0500 | [diff] [blame] | 682 | Dependency.get(StatusBarStateController.class).removeCallback(mStateListener); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 683 | Dependency.get(ConfigurationController.class).removeCallback(this); |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | @Override |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 687 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 688 | public NotificationSwipeActionHelper getSwipeActionHelper() { |
| 689 | return mSwipeHelper; |
| 690 | } |
| 691 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 692 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 693 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Lucas Dupin | f03e752 | 2018-06-25 16:21:13 -0700 | [diff] [blame] | 694 | public void onUiModeChanged() { |
| 695 | mBgColor = mContext.getColor(R.color.notification_shade_background_color); |
| 696 | updateBackgroundDimming(); |
Selim Cinek | ab9c7b2 | 2018-12-11 18:15:47 -0800 | [diff] [blame] | 697 | mShelf.onUiModeChanged(); |
Lucas Dupin | f03e752 | 2018-06-25 16:21:13 -0700 | [diff] [blame] | 698 | } |
| 699 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 700 | @ShadeViewRefactor(RefactorComponent.DECORATOR) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 701 | protected void onDraw(Canvas canvas) { |
Lucas Dupin | d285cf0 | 2018-01-18 09:18:23 -0800 | [diff] [blame] | 702 | if (mShouldDrawNotificationBackground |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 703 | && (mSections[0].getCurrentBounds().top |
| 704 | < mSections[NUM_SECTIONS - 1].getCurrentBounds().bottom |
| 705 | || mAmbientState.isDark())) { |
Lucas Dupin | d285cf0 | 2018-01-18 09:18:23 -0800 | [diff] [blame] | 706 | drawBackground(canvas); |
Gus Prevas | 21118153 | 2018-12-13 14:49:33 -0500 | [diff] [blame] | 707 | } else if (mInHeadsUpPinnedMode || mHeadsUpAnimatingAway) { |
| 708 | drawHeadsUpBackground(canvas); |
Selim Cinek | d381bc3 | 2016-08-15 12:40:57 -0700 | [diff] [blame] | 709 | } |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 710 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 711 | if (DEBUG) { |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 712 | int y = mTopPadding; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 713 | canvas.drawLine(0, y, getWidth(), y, mDebugPaint); |
Mady Mellor | 43c2cd1 | 2016-12-12 21:05:13 -0800 | [diff] [blame] | 714 | y = getLayoutHeight(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 715 | canvas.drawLine(0, y, getWidth(), y, mDebugPaint); |
Jorim Jaggi | 1d48069 | 2014-05-20 19:41:58 +0200 | [diff] [blame] | 716 | y = getHeight() - getEmptyBottomMargin(); |
| 717 | canvas.drawLine(0, y, getWidth(), y, mDebugPaint); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 718 | } |
| 719 | } |
| 720 | |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 721 | @Override |
| 722 | public void draw(Canvas canvas) { |
| 723 | super.draw(canvas); |
| 724 | |
| 725 | if (DEBUG && ANCHOR_SCROLLING) { |
| 726 | if (mScrollAnchorView instanceof ExpandableNotificationRow) { |
| 727 | canvas.drawRect(0, |
| 728 | mScrollAnchorView.getTranslationY(), |
| 729 | getWidth(), |
| 730 | mScrollAnchorView.getTranslationY() |
| 731 | + ((ExpandableNotificationRow) mScrollAnchorView).getActualHeight(), |
| 732 | mDebugPaint); |
| 733 | canvas.drawText(Integer.toString(mScrollAnchorViewY), getWidth() - 200, |
| 734 | mScrollAnchorView.getTranslationY() + 30, mDebugPaint); |
| 735 | int y = (int) mShelf.getTranslationY(); |
| 736 | canvas.drawLine(0, y, getWidth(), y, mDebugPaint); |
| 737 | } |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 738 | canvas.drawText(Integer.toString(getMaxNegativeScrollAmount()), getWidth() - 100, |
| 739 | getIntrinsicPadding() + 30, mDebugPaint); |
| 740 | canvas.drawText(Integer.toString(getMaxPositiveScrollAmount()), getWidth() - 100, |
| 741 | getHeight() - 30, mDebugPaint); |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 742 | } |
| 743 | } |
| 744 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 745 | @ShadeViewRefactor(RefactorComponent.DECORATOR) |
Lucas Dupin | d285cf0 | 2018-01-18 09:18:23 -0800 | [diff] [blame] | 746 | private void drawBackground(Canvas canvas) { |
Lucas Dupin | 23a8d3b | 2018-10-08 20:57:35 -0700 | [diff] [blame] | 747 | int lockScreenLeft = mSidePaddings; |
| 748 | int lockScreenRight = getWidth() - mSidePaddings; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 749 | int lockScreenTop = mSections[0].getCurrentBounds().top; |
| 750 | int lockScreenBottom = mSections[NUM_SECTIONS - 1].getCurrentBounds().bottom; |
Lucas Dupin | 23a8d3b | 2018-10-08 20:57:35 -0700 | [diff] [blame] | 751 | int darkLeft = getWidth() / 2; |
Lucas Dupin | 00be88f | 2019-01-03 17:50:52 -0800 | [diff] [blame] | 752 | int darkTop = mTopPadding; |
Lucas Dupin | d285cf0 | 2018-01-18 09:18:23 -0800 | [diff] [blame] | 753 | |
Lucas Dupin | 23a8d3b | 2018-10-08 20:57:35 -0700 | [diff] [blame] | 754 | float yProgress = 1 - mInterpolatedDarkAmount; |
| 755 | float xProgress = mDarkXInterpolator.getInterpolation( |
| 756 | (1 - mLinearDarkAmount) * mBackgroundXFactor); |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 757 | |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 758 | int left = (int) MathUtils.lerp(darkLeft, lockScreenLeft, xProgress); |
| 759 | int right = (int) MathUtils.lerp(darkLeft, lockScreenRight, xProgress); |
| 760 | int top = (int) MathUtils.lerp(darkTop, lockScreenTop, yProgress); |
| 761 | int bottom = (int) MathUtils.lerp(darkTop, lockScreenBottom, yProgress); |
Lucas Dupin | 23a8d3b | 2018-10-08 20:57:35 -0700 | [diff] [blame] | 762 | mBackgroundAnimationRect.set( |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 763 | left, |
| 764 | top, |
| 765 | right, |
| 766 | bottom); |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 767 | |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 768 | int backgroundTopAnimationOffset = top - lockScreenTop; |
| 769 | // TODO(kprevas): this may not be necessary any more since we don't display the shelf in AOD |
| 770 | boolean anySectionHasVisibleChild = false; |
| 771 | for (NotificationSection section : mSections) { |
| 772 | if (section.getFirstVisibleChild() != null) { |
| 773 | anySectionHasVisibleChild = true; |
| 774 | break; |
| 775 | } |
| 776 | } |
| 777 | if (!mAmbientState.isDark() || anySectionHasVisibleChild) { |
| 778 | drawBackgroundRects(canvas, left, right, top, backgroundTopAnimationOffset); |
Lucas Dupin | d285cf0 | 2018-01-18 09:18:23 -0800 | [diff] [blame] | 779 | } |
Lucas Dupin | 23a8d3b | 2018-10-08 20:57:35 -0700 | [diff] [blame] | 780 | |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 781 | updateClipping(); |
Lucas Dupin | d285cf0 | 2018-01-18 09:18:23 -0800 | [diff] [blame] | 782 | } |
| 783 | |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 784 | /** |
| 785 | * Draws round rects for each background section. |
| 786 | * |
| 787 | * We want to draw a round rect for each background section as defined by {@link #mSections}. |
| 788 | * However, if two sections are directly adjacent with no gap between them (e.g. on the |
| 789 | * lockscreen where the shelf can appear directly below the high priority section, or while |
| 790 | * scrolling the shade so that the top of the shelf is right at the bottom of the high priority |
| 791 | * section), we don't want to round the adjacent corners. |
| 792 | * |
| 793 | * Since {@link Canvas} doesn't provide a way to draw a half-rounded rect, this means that we |
| 794 | * need to coalesce the backgrounds for adjacent sections and draw them as a single round rect. |
| 795 | * This method tracks the top of each rect we need to draw, then iterates through the visible |
| 796 | * sections. If a section is not adjacent to the previous section, we draw the previous rect |
| 797 | * behind the sections we've accumulated up to that point, then start a new rect at the top of |
| 798 | * the current section. When we're done iterating we will always have one rect left to draw. |
| 799 | */ |
| 800 | private void drawBackgroundRects(Canvas canvas, int left, int right, int top, |
| 801 | int animationYOffset) { |
| 802 | int backgroundRectTop = top; |
| 803 | int lastSectionBottom = |
| 804 | mSections[0].getCurrentBounds().bottom + animationYOffset; |
| 805 | for (NotificationSection section : mSections) { |
| 806 | if (section.getFirstVisibleChild() == null) { |
| 807 | continue; |
| 808 | } |
| 809 | int sectionTop = section.getCurrentBounds().top + animationYOffset; |
| 810 | // If sections are directly adjacent to each other, we don't want to draw them |
| 811 | // as separate roundrects, as the rounded corners right next to each other look |
| 812 | // bad. |
| 813 | if (sectionTop - lastSectionBottom > DISTANCE_BETWEEN_ADJACENT_SECTIONS_PX) { |
| 814 | canvas.drawRoundRect(left, |
| 815 | backgroundRectTop, |
| 816 | right, |
| 817 | lastSectionBottom, |
| 818 | mCornerRadius, mCornerRadius, mBackgroundPaint); |
| 819 | backgroundRectTop = sectionTop; |
| 820 | } |
| 821 | lastSectionBottom = |
| 822 | section.getCurrentBounds().bottom + animationYOffset; |
| 823 | } |
| 824 | canvas.drawRoundRect(left, |
| 825 | backgroundRectTop, |
| 826 | right, |
| 827 | lastSectionBottom, |
| 828 | mCornerRadius, mCornerRadius, mBackgroundPaint); |
| 829 | } |
| 830 | |
Gus Prevas | 21118153 | 2018-12-13 14:49:33 -0500 | [diff] [blame] | 831 | private void drawHeadsUpBackground(Canvas canvas) { |
| 832 | int left = mSidePaddings; |
| 833 | int right = getWidth() - mSidePaddings; |
| 834 | |
| 835 | float top = getHeight(); |
| 836 | float bottom = 0; |
| 837 | int childCount = getChildCount(); |
| 838 | for (int i = 0; i < childCount; i++) { |
| 839 | View child = getChildAt(i); |
| 840 | if (child.getVisibility() != View.GONE |
| 841 | && child instanceof ExpandableNotificationRow) { |
| 842 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 843 | if ((row.isPinned() || row.isHeadsUpAnimatingAway()) && row.getTranslation() < 0) { |
| 844 | top = Math.min(top, row.getTranslationY()); |
| 845 | bottom = Math.max(bottom, row.getTranslationY() + row.getActualHeight()); |
| 846 | } |
| 847 | } |
| 848 | } |
| 849 | |
| 850 | if (top < bottom) { |
| 851 | canvas.drawRoundRect( |
| 852 | left, top, right, bottom, |
| 853 | mCornerRadius, mCornerRadius, mBackgroundPaint); |
| 854 | } |
| 855 | } |
| 856 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 857 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 858 | private void updateBackgroundDimming() { |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 859 | // No need to update the background color if it's not being drawn. |
| 860 | if (!mShouldDrawNotificationBackground) { |
| 861 | return; |
| 862 | } |
| 863 | |
Lucas Dupin | b561eda | 2018-04-09 17:25:04 -0700 | [diff] [blame] | 864 | float alpha = |
| 865 | BACKGROUND_ALPHA_DIMMED + (1 - BACKGROUND_ALPHA_DIMMED) * (1.0f - mDimAmount); |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 866 | alpha *= 1f - mInterpolatedDarkAmount; |
Lucas Dupin | b561eda | 2018-04-09 17:25:04 -0700 | [diff] [blame] | 867 | // We need to manually blend in the background color. |
| 868 | int scrimColor = mScrimController.getBackgroundColor(); |
| 869 | int awakeColor = ColorUtils.blendARGB(scrimColor, mBgColor, alpha); |
| 870 | |
| 871 | // Interpolate between semi-transparent notification panel background color |
| 872 | // and white AOD separator. |
Lucas Dupin | f03e752 | 2018-06-25 16:21:13 -0700 | [diff] [blame] | 873 | float colorInterpolation = MathUtils.smoothStep(0.4f /* start */, 1f /* end */, |
| 874 | mLinearDarkAmount); |
Lucas Dupin | b561eda | 2018-04-09 17:25:04 -0700 | [diff] [blame] | 875 | int color = ColorUtils.blendARGB(awakeColor, Color.WHITE, colorInterpolation); |
Lucas Dupin | d285cf0 | 2018-01-18 09:18:23 -0800 | [diff] [blame] | 876 | |
Selim Cinek | fb6ee6d | 2016-12-29 16:49:26 +0100 | [diff] [blame] | 877 | if (mCachedBackgroundColor != color) { |
| 878 | mCachedBackgroundColor = color; |
| 879 | mBackgroundPaint.setColor(color); |
| 880 | invalidate(); |
| 881 | } |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 882 | } |
| 883 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 884 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 885 | private void initView(Context context) { |
| 886 | mScroller = new OverScroller(getContext()); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 887 | setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 888 | setClipChildren(false); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 889 | final ViewConfiguration configuration = ViewConfiguration.get(context); |
| 890 | mTouchSlop = configuration.getScaledTouchSlop(); |
| 891 | mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); |
| 892 | mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 893 | mOverflingDistance = configuration.getScaledOverflingDistance(); |
Anthony Chen | 9fe1ee7 | 2017-04-07 13:53:37 -0700 | [diff] [blame] | 894 | |
| 895 | Resources res = context.getResources(); |
| 896 | mCollapsedSize = res.getDimensionPixelSize(R.dimen.notification_min_height); |
Selim Cinek | af0dc31 | 2015-12-15 17:01:44 -0800 | [diff] [blame] | 897 | mStackScrollAlgorithm.initView(context); |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 898 | mAmbientState.reload(context); |
Anthony Chen | 9fe1ee7 | 2017-04-07 13:53:37 -0700 | [diff] [blame] | 899 | mPaddingBetweenElements = Math.max(1, |
| 900 | res.getDimensionPixelSize(R.dimen.notification_divider_height)); |
| 901 | mIncreasedPaddingBetweenElements = |
| 902 | res.getDimensionPixelSize(R.dimen.notification_divider_height_increased); |
| 903 | mMinTopOverScrollToEscape = res.getDimensionPixelSize( |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 904 | R.dimen.min_top_overscroll_to_qs); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 905 | mStatusBarHeight = res.getDimensionPixelSize(R.dimen.status_bar_height); |
Anthony Chen | 9fe1ee7 | 2017-04-07 13:53:37 -0700 | [diff] [blame] | 906 | mBottomMargin = res.getDimensionPixelSize(R.dimen.notification_panel_margin_bottom); |
Selim Cinek | b95fd18 | 2017-12-21 13:03:32 -0800 | [diff] [blame] | 907 | mSidePaddings = res.getDimensionPixelSize(R.dimen.notification_side_paddings); |
Selim Cinek | 51d2197 | 2017-07-19 17:39:20 -0700 | [diff] [blame] | 908 | mMinInteractionHeight = res.getDimensionPixelSize( |
| 909 | R.dimen.notification_min_interaction_height); |
Selim Cinek | 0fe0739 | 2017-11-09 13:26:34 -0800 | [diff] [blame] | 910 | mCornerRadius = res.getDimensionPixelSize( |
| 911 | Utils.getThemeAttr(mContext, android.R.attr.dialogCornerRadius)); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 912 | mHeadsUpInset = mStatusBarHeight + res.getDimensionPixelSize( |
| 913 | R.dimen.heads_up_status_bar_padding); |
Selim Cinek | a5eaa60 | 2014-05-12 21:27:47 +0200 | [diff] [blame] | 914 | } |
| 915 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 916 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | aef92ef | 2014-06-06 18:06:04 +0200 | [diff] [blame] | 917 | private void notifyHeightChangeListener(ExpandableView view) { |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 918 | notifyHeightChangeListener(view, false /* needsAnimation */); |
| 919 | } |
| 920 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 921 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 922 | private void notifyHeightChangeListener(ExpandableView view, boolean needsAnimation) { |
Selim Cinek | aef92ef | 2014-06-06 18:06:04 +0200 | [diff] [blame] | 923 | if (mOnHeightChangedListener != null) { |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 924 | mOnHeightChangedListener.onHeightChanged(view, needsAnimation); |
Selim Cinek | aef92ef | 2014-06-06 18:06:04 +0200 | [diff] [blame] | 925 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 926 | } |
| 927 | |
| 928 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 929 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 930 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 931 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
Selim Cinek | b95fd18 | 2017-12-21 13:03:32 -0800 | [diff] [blame] | 932 | |
| 933 | int width = MeasureSpec.getSize(widthMeasureSpec); |
| 934 | int childWidthSpec = MeasureSpec.makeMeasureSpec(width - mSidePaddings * 2, |
| 935 | MeasureSpec.getMode(widthMeasureSpec)); |
Evan Laird | eb7dbd5 | 2018-06-28 13:17:25 -0400 | [diff] [blame] | 936 | // Don't constrain the height of the children so we know how big they'd like to be |
| 937 | int childHeightSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), |
| 938 | MeasureSpec.UNSPECIFIED); |
| 939 | |
Selim Cinek | fa760d4 | 2016-05-10 15:50:53 -0400 | [diff] [blame] | 940 | // We need to measure all children even the GONE ones, such that the heights are calculated |
| 941 | // correctly as they are used to calculate how many we can fit on the screen. |
| 942 | final int size = getChildCount(); |
| 943 | for (int i = 0; i < size; i++) { |
Evan Laird | eb7dbd5 | 2018-06-28 13:17:25 -0400 | [diff] [blame] | 944 | measureChild(getChildAt(i), childWidthSpec, childHeightSpec); |
Selim Cinek | fa760d4 | 2016-05-10 15:50:53 -0400 | [diff] [blame] | 945 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 949 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 950 | protected void onLayout(boolean changed, int l, int t, int r, int b) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 951 | // we layout all our children centered on the top |
| 952 | float centerX = getWidth() / 2.0f; |
| 953 | for (int i = 0; i < getChildCount(); i++) { |
| 954 | View child = getChildAt(i); |
Selim Cinek | fa760d4 | 2016-05-10 15:50:53 -0400 | [diff] [blame] | 955 | // We need to layout all children even the GONE ones, such that the heights are |
| 956 | // calculated correctly as they are used to calculate how many we can fit on the screen |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 957 | float width = child.getMeasuredWidth(); |
| 958 | float height = child.getMeasuredHeight(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 959 | child.layout((int) (centerX - width / 2.0f), |
| 960 | 0, |
| 961 | (int) (centerX + width / 2.0f), |
| 962 | (int) height); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 963 | } |
Jorim Jaggi | 1d48069 | 2014-05-20 19:41:58 +0200 | [diff] [blame] | 964 | setMaxLayoutHeight(getHeight()); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 965 | updateContentHeight(); |
Selim Cinek | f7a14c0 | 2014-07-07 14:01:46 +0200 | [diff] [blame] | 966 | clampScrollPosition(); |
Selim Cinek | 319bdc4 | 2014-05-01 23:01:58 +0200 | [diff] [blame] | 967 | requestChildrenUpdate(); |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 968 | updateFirstAndLastBackgroundViews(); |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 969 | updateAlgorithmLayoutMinHeight(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 970 | } |
| 971 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 972 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 5bc852a | 2015-12-21 12:19:09 -0800 | [diff] [blame] | 973 | private void requestAnimationOnViewResize(ExpandableNotificationRow row) { |
| 974 | if (mAnimationsEnabled && (mIsExpanded || row != null && row.isPinned())) { |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 975 | mNeedViewResizeAnimation = true; |
| 976 | mNeedsAnimation = true; |
| 977 | } |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 978 | } |
| 979 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 980 | @ShadeViewRefactor(RefactorComponent.ADAPTER) |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 981 | public void updateSpeedBumpIndex(int newIndex, boolean noAmbient) { |
| 982 | mAmbientState.setSpeedBumpIndex(newIndex); |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 983 | mNoAmbient = noAmbient; |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 984 | } |
| 985 | |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 986 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 987 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 988 | public void setChildLocationsChangedListener( |
| 989 | NotificationLogger.OnChildLocationsChangedListener listener) { |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 990 | mListener = listener; |
| 991 | } |
| 992 | |
Selim Cinek | a7d4f82 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 993 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 994 | @ShadeViewRefactor(RefactorComponent.LAYOUT_ALGORITHM) |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 995 | public boolean isInVisibleLocation(NotificationEntry entry) { |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 996 | ExpandableNotificationRow row = entry.getRow(); |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 997 | ExpandableViewState childViewState = row.getViewState(); |
| 998 | |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 999 | if (childViewState == null) { |
Selim Cinek | a7d4f82 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 1000 | return false; |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 1001 | } |
Selim Cinek | 9b9d6e1 | 2017-11-30 12:29:47 +0100 | [diff] [blame] | 1002 | if ((childViewState.location & ExpandableViewState.VISIBLE_LOCATIONS) == 0) { |
Selim Cinek | a7d4f82 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 1003 | return false; |
Christoph Studer | 12cf9e5 | 2014-10-29 17:35:30 +0100 | [diff] [blame] | 1004 | } |
Selim Cinek | a7d4f82 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 1005 | if (row.getVisibility() != View.VISIBLE) { |
| 1006 | return false; |
| 1007 | } |
| 1008 | return true; |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 1009 | } |
| 1010 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1011 | @ShadeViewRefactor(RefactorComponent.LAYOUT_ALGORITHM) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1012 | private void setMaxLayoutHeight(int maxLayoutHeight) { |
| 1013 | mMaxLayoutHeight = maxLayoutHeight; |
Selim Cinek | 9458b19 | 2016-10-25 19:02:42 -0700 | [diff] [blame] | 1014 | mShelf.setMaxLayoutHeight(maxLayoutHeight); |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 1015 | updateAlgorithmHeightAndPadding(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1016 | } |
| 1017 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1018 | @ShadeViewRefactor(RefactorComponent.LAYOUT_ALGORITHM) |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 1019 | private void updateAlgorithmHeightAndPadding() { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1020 | mAmbientState.setLayoutHeight(getLayoutHeight()); |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 1021 | updateAlgorithmLayoutMinHeight(); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1022 | mAmbientState.setTopPadding(mTopPadding); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1023 | } |
| 1024 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1025 | @ShadeViewRefactor(RefactorComponent.LAYOUT_ALGORITHM) |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 1026 | private void updateAlgorithmLayoutMinHeight() { |
shawnlin | c345791 | 2018-05-15 16:39:56 +0800 | [diff] [blame] | 1027 | mAmbientState.setLayoutMinHeight(mQsExpanded || isHeadsUpTransition() |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1028 | ? getLayoutMinHeight() : 0); |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 1029 | } |
| 1030 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1031 | /** |
| 1032 | * Updates the children views according to the stack scroll algorithm. Call this whenever |
| 1033 | * modifications to {@link #mOwnScrollY} are performed to reflect it in the view layout. |
| 1034 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1035 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1036 | private void updateChildren() { |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 1037 | updateScrollStateForAddedChildren(); |
Selim Cinek | 727903c | 2016-12-06 17:28:10 -0800 | [diff] [blame] | 1038 | mAmbientState.setCurrentScrollVelocity(mScroller.isFinished() |
| 1039 | ? 0 |
| 1040 | : mScroller.getCurrVelocity()); |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1041 | if (ANCHOR_SCROLLING) { |
| 1042 | mAmbientState.setAnchorViewIndex(indexOfChild(mScrollAnchorView)); |
| 1043 | mAmbientState.setAnchorViewY(mScrollAnchorViewY); |
| 1044 | } else { |
| 1045 | mAmbientState.setScrollY(mOwnScrollY); |
| 1046 | } |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 1047 | mStackScrollAlgorithm.resetViewStates(mAmbientState); |
Jorim Jaggi | 0dd6881 | 2014-05-01 19:17:37 +0200 | [diff] [blame] | 1048 | if (!isCurrentlyAnimating() && !mNeedsAnimation) { |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 1049 | applyCurrentState(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1050 | } else { |
Selim Cinek | f4c1996 | 2014-05-01 21:55:31 +0200 | [diff] [blame] | 1051 | startAnimationToState(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1052 | } |
| 1053 | } |
| 1054 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1055 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | c383fd0 | 2016-10-21 15:31:26 -0700 | [diff] [blame] | 1056 | private void onPreDrawDuringAnimation() { |
Selim Cinek | a686b2c | 2016-10-26 13:58:27 -0700 | [diff] [blame] | 1057 | mShelf.updateAppearance(); |
Selim Cinek | b0ee18f | 2017-12-21 16:15:53 -0800 | [diff] [blame] | 1058 | updateClippingToTopRoundedCorner(); |
Selim Cinek | c383fd0 | 2016-10-21 15:31:26 -0700 | [diff] [blame] | 1059 | if (!mNeedsAnimation && !mChildrenUpdateRequested) { |
| 1060 | updateBackground(); |
| 1061 | } |
Selim Cinek | c383fd0 | 2016-10-21 15:31:26 -0700 | [diff] [blame] | 1062 | } |
| 1063 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1064 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | b0ee18f | 2017-12-21 16:15:53 -0800 | [diff] [blame] | 1065 | private void updateClippingToTopRoundedCorner() { |
Arthur Hung | c0ef565 | 2018-05-22 14:00:42 +0800 | [diff] [blame] | 1066 | Float clipStart = (float) mTopPadding |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1067 | + mStackTranslation |
| 1068 | + mAmbientState.getExpandAnimationTopChange(); |
Selim Cinek | b0ee18f | 2017-12-21 16:15:53 -0800 | [diff] [blame] | 1069 | Float clipEnd = clipStart + mCornerRadius; |
| 1070 | boolean first = true; |
| 1071 | for (int i = 0; i < getChildCount(); i++) { |
| 1072 | ExpandableView child = (ExpandableView) getChildAt(i); |
| 1073 | if (child.getVisibility() == GONE) { |
| 1074 | continue; |
| 1075 | } |
| 1076 | float start = child.getTranslationY(); |
Arthur Hung | c0ef565 | 2018-05-22 14:00:42 +0800 | [diff] [blame] | 1077 | float end = start + child.getActualHeight(); |
Selim Cinek | b0ee18f | 2017-12-21 16:15:53 -0800 | [diff] [blame] | 1078 | boolean clip = clipStart > start && clipStart < end |
| 1079 | || clipEnd >= start && clipEnd <= end; |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1080 | clip &= !(first && isScrolledToTop()); |
Selim Cinek | eccf494 | 2018-05-30 09:55:36 -0700 | [diff] [blame] | 1081 | child.setDistanceToTopRoundness(clip ? Math.max(start - clipStart, 0) |
| 1082 | : ExpandableView.NO_ROUNDNESS); |
Selim Cinek | b0ee18f | 2017-12-21 16:15:53 -0800 | [diff] [blame] | 1083 | first = false; |
| 1084 | } |
| 1085 | } |
| 1086 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1087 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 1088 | private void updateScrollStateForAddedChildren() { |
| 1089 | if (mChildrenToAddAnimated.isEmpty()) { |
| 1090 | return; |
| 1091 | } |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1092 | if (!ANCHOR_SCROLLING) { |
| 1093 | for (int i = 0; i < getChildCount(); i++) { |
| 1094 | ExpandableView child = (ExpandableView) getChildAt(i); |
| 1095 | if (mChildrenToAddAnimated.contains(child)) { |
| 1096 | int startingPosition = getPositionInLinearLayout(child); |
| 1097 | float increasedPaddingAmount = child.getIncreasedPaddingAmount(); |
| 1098 | int padding = increasedPaddingAmount == 1.0f ? mIncreasedPaddingBetweenElements |
| 1099 | : increasedPaddingAmount == -1.0f ? 0 : mPaddingBetweenElements; |
| 1100 | int childHeight = getIntrinsicHeight(child) + padding; |
| 1101 | if (startingPosition < mOwnScrollY) { |
| 1102 | // This child starts off screen, so let's keep it offscreen to keep the |
| 1103 | // others visible |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 1104 | |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1105 | setOwnScrollY(mOwnScrollY + childHeight); |
| 1106 | } |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 1107 | } |
| 1108 | } |
| 1109 | } |
| 1110 | clampScrollPosition(); |
| 1111 | } |
| 1112 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1113 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 1114 | private void updateForcedScroll() { |
| 1115 | if (mForcedScroll != null && (!mForcedScroll.hasFocus() |
| 1116 | || !mForcedScroll.isAttachedToWindow())) { |
| 1117 | mForcedScroll = null; |
| 1118 | } |
| 1119 | if (mForcedScroll != null) { |
| 1120 | ExpandableView expandableView = (ExpandableView) mForcedScroll; |
| 1121 | int positionInLinearLayout = getPositionInLinearLayout(expandableView); |
| 1122 | int targetScroll = targetScrollForView(expandableView, positionInLinearLayout); |
Adrian Roos | 4a57967 | 2016-05-24 16:54:37 -0700 | [diff] [blame] | 1123 | int outOfViewScroll = positionInLinearLayout + expandableView.getIntrinsicHeight(); |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 1124 | |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1125 | if (ANCHOR_SCROLLING) { |
| 1126 | // TODO |
| 1127 | } else { |
| 1128 | targetScroll = Math.max(0, Math.min(targetScroll, getScrollRange())); |
Adrian Roos | 4a57967 | 2016-05-24 16:54:37 -0700 | [diff] [blame] | 1129 | |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1130 | // Only apply the scroll if we're scrolling the view upwards, or the view is so |
| 1131 | // far up that it is not visible anymore. |
| 1132 | if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) { |
| 1133 | setOwnScrollY(targetScroll); |
| 1134 | } |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 1135 | } |
| 1136 | } |
| 1137 | } |
| 1138 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1139 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 319bdc4 | 2014-05-01 23:01:58 +0200 | [diff] [blame] | 1140 | private void requestChildrenUpdate() { |
Selim Cinek | 1f553cf | 2014-05-02 12:01:36 +0200 | [diff] [blame] | 1141 | if (!mChildrenUpdateRequested) { |
| 1142 | getViewTreeObserver().addOnPreDrawListener(mChildrenUpdater); |
| 1143 | mChildrenUpdateRequested = true; |
| 1144 | invalidate(); |
| 1145 | } |
Selim Cinek | 319bdc4 | 2014-05-01 23:01:58 +0200 | [diff] [blame] | 1146 | } |
| 1147 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1148 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1149 | private boolean isCurrentlyAnimating() { |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 1150 | return mStateAnimator.isRunning(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1151 | } |
| 1152 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1153 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | f7a14c0 | 2014-07-07 14:01:46 +0200 | [diff] [blame] | 1154 | private void clampScrollPosition() { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1155 | if (ANCHOR_SCROLLING) { |
| 1156 | // TODO |
| 1157 | } else { |
| 1158 | int scrollRange = getScrollRange(); |
| 1159 | if (scrollRange < mOwnScrollY) { |
| 1160 | setOwnScrollY(scrollRange); |
| 1161 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1162 | } |
| 1163 | } |
| 1164 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1165 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 1166 | public int getTopPadding() { |
| 1167 | return mTopPadding; |
| 1168 | } |
| 1169 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1170 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 1171 | private void setTopPadding(int topPadding, boolean animate) { |
Lucas Dupin | 00be88f | 2019-01-03 17:50:52 -0800 | [diff] [blame] | 1172 | if (mTopPadding != topPadding) { |
| 1173 | mTopPadding = topPadding; |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 1174 | updateAlgorithmHeightAndPadding(); |
| 1175 | updateContentHeight(); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 1176 | if (animate && mAnimationsEnabled && mIsExpanded) { |
Jorim Jaggi | 0dd6881 | 2014-05-01 19:17:37 +0200 | [diff] [blame] | 1177 | mTopPaddingNeedsAnimation = true; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1178 | mNeedsAnimation = true; |
Jorim Jaggi | 0dd6881 | 2014-05-01 19:17:37 +0200 | [diff] [blame] | 1179 | } |
Selim Cinek | 319bdc4 | 2014-05-01 23:01:58 +0200 | [diff] [blame] | 1180 | requestChildrenUpdate(); |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 1181 | notifyHeightChangeListener(null, animate); |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 1182 | } |
| 1183 | } |
| 1184 | |
| 1185 | /** |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 1186 | * Update the height of the panel. |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 1187 | * |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 1188 | * @param height the expanded height of the panel |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 1189 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1190 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 1191 | public void setExpandedHeight(float height) { |
| 1192 | mExpandedHeight = height; |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 1193 | setIsExpanded(height > 0); |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 1194 | int minExpansionHeight = getMinExpansionHeight(); |
| 1195 | if (height < minExpansionHeight) { |
| 1196 | mClipRect.left = 0; |
| 1197 | mClipRect.right = getWidth(); |
| 1198 | mClipRect.top = 0; |
| 1199 | mClipRect.bottom = (int) height; |
| 1200 | height = minExpansionHeight; |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 1201 | setRequestedClipBounds(mClipRect); |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 1202 | } else { |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 1203 | setRequestedClipBounds(null); |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 1204 | } |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 1205 | int stackHeight; |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1206 | float translationY; |
| 1207 | float appearEndPosition = getAppearEndPosition(); |
| 1208 | float appearStartPosition = getAppearStartPosition(); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1209 | float appearFraction = 1.0f; |
shawnlin | 5be1f7c | 2018-05-21 20:50:54 +0800 | [diff] [blame] | 1210 | boolean appearing = height < appearEndPosition; |
| 1211 | mAmbientState.setAppearing(appearing); |
| 1212 | if (!appearing) { |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 1213 | translationY = 0; |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 1214 | if (mShouldShowShelfOnly) { |
| 1215 | stackHeight = mTopPadding + mShelf.getIntrinsicHeight(); |
| 1216 | } else if (mQsExpanded) { |
| 1217 | int stackStartPosition = mContentHeight - mTopPadding + mIntrinsicPadding; |
| 1218 | int stackEndPosition = mMaxTopPadding + mShelf.getIntrinsicHeight(); |
| 1219 | if (stackStartPosition <= stackEndPosition) { |
| 1220 | stackHeight = stackEndPosition; |
| 1221 | } else { |
| 1222 | stackHeight = (int) NotificationUtils.interpolate(stackStartPosition, |
| 1223 | stackEndPosition, mQsExpansionFraction); |
| 1224 | } |
| 1225 | } else { |
| 1226 | stackHeight = (int) height; |
| 1227 | } |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 1228 | } else { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1229 | appearFraction = getAppearFraction(height); |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1230 | if (appearFraction >= 0) { |
| 1231 | translationY = NotificationUtils.interpolate(getExpandTranslationStart(), 0, |
| 1232 | appearFraction); |
| 1233 | } else { |
| 1234 | // This may happen when pushing up a heads up. We linearly push it up from the |
| 1235 | // start |
| 1236 | translationY = height - appearStartPosition + getExpandTranslationStart(); |
| 1237 | } |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1238 | if (isHeadsUpTransition()) { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 1239 | stackHeight = |
| 1240 | getFirstVisibleSection().getFirstVisibleChild().getPinnedHeadsUpHeight(); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1241 | translationY = MathUtils.lerp(mHeadsUpInset - mTopPadding, 0, appearFraction); |
| 1242 | } else { |
| 1243 | stackHeight = (int) (height - translationY); |
| 1244 | } |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 1245 | } |
| 1246 | if (stackHeight != mCurrentStackHeight) { |
| 1247 | mCurrentStackHeight = stackHeight; |
| 1248 | updateAlgorithmHeightAndPadding(); |
Selim Cinek | 319bdc4 | 2014-05-01 23:01:58 +0200 | [diff] [blame] | 1249 | requestChildrenUpdate(); |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 1250 | } |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1251 | setStackTranslation(translationY); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1252 | for (int i = 0; i < mExpandedHeightListeners.size(); i++) { |
| 1253 | BiConsumer<Float, Float> listener = mExpandedHeightListeners.get(i); |
| 1254 | listener.accept(mExpandedHeight, appearFraction); |
| 1255 | } |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 1256 | } |
| 1257 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1258 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 1259 | private void setRequestedClipBounds(Rect clipRect) { |
| 1260 | mRequestedClipBounds = clipRect; |
| 1261 | updateClipping(); |
| 1262 | } |
| 1263 | |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 1264 | /** |
| 1265 | * Return the height of the content ignoring the footer. |
| 1266 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1267 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 1268 | public int getIntrinsicContentHeight() { |
| 1269 | return mIntrinsicContentHeight; |
| 1270 | } |
| 1271 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1272 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 1273 | public void updateClipping() { |
| 1274 | boolean clipped = mRequestedClipBounds != null && !mInHeadsUpPinnedMode |
| 1275 | && !mHeadsUpAnimatingAway; |
| 1276 | if (mIsClipped != clipped) { |
| 1277 | mIsClipped = clipped; |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 1278 | } |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 1279 | |
Lucas Dupin | 7fc9dc1 | 2019-01-03 09:19:43 -0800 | [diff] [blame] | 1280 | if (mPulsing || mAmbientState.isFullyDark() && mShowDarkShelf) { |
Lucas Dupin | 4798ea1 | 2018-11-05 19:26:24 -0800 | [diff] [blame] | 1281 | setClipBounds(null); |
| 1282 | } else if (mAmbientState.isDarkAtAll()) { |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 1283 | setClipBounds(mBackgroundAnimationRect); |
| 1284 | } else if (clipped) { |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 1285 | setClipBounds(mRequestedClipBounds); |
| 1286 | } else { |
| 1287 | setClipBounds(null); |
| 1288 | } |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1289 | } |
| 1290 | |
| 1291 | /** |
| 1292 | * @return The translation at the beginning when expanding. |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1293 | * Measured relative to the resting position. |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1294 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1295 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1296 | private float getExpandTranslationStart() { |
Selim Cinek | 083f214 | 2018-11-06 16:32:23 -0800 | [diff] [blame] | 1297 | return -mTopPadding + getMinExpansionHeight() - mShelf.getIntrinsicHeight(); |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1298 | } |
| 1299 | |
| 1300 | /** |
| 1301 | * @return the position from where the appear transition starts when expanding. |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1302 | * Measured in absolute height. |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1303 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1304 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1305 | private float getAppearStartPosition() { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1306 | if (isHeadsUpTransition()) { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 1307 | return mHeadsUpInset |
| 1308 | + getFirstVisibleSection().getFirstVisibleChild().getPinnedHeadsUpHeight(); |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 1309 | } |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 1310 | return getMinExpansionHeight(); |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1311 | } |
| 1312 | |
| 1313 | /** |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 1314 | * @return the height of the top heads up notification when pinned. This is different from the |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1315 | * intrinsic height, which also includes whether the notification is system expanded and |
| 1316 | * is mainly used when dragging down from a heads up notification. |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 1317 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1318 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 1319 | private int getTopHeadsUpPinnedHeight() { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 1320 | NotificationEntry topEntry = mHeadsUpManager.getTopEntry(); |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 1321 | if (topEntry == null) { |
| 1322 | return 0; |
| 1323 | } |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 1324 | ExpandableNotificationRow row = topEntry.getRow(); |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 1325 | if (row.isChildInGroup()) { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 1326 | final NotificationEntry groupSummary |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 1327 | = mGroupManager.getGroupSummary(row.getStatusBarNotification()); |
| 1328 | if (groupSummary != null) { |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 1329 | row = groupSummary.getRow(); |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 1330 | } |
| 1331 | } |
| 1332 | return row.getPinnedHeadsUpHeight(); |
| 1333 | } |
| 1334 | |
| 1335 | /** |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1336 | * @return the position from where the appear transition ends when expanding. |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1337 | * Measured in absolute height. |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1338 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1339 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1340 | private float getAppearEndPosition() { |
Selim Cinek | aa417da | 2016-10-27 18:17:08 -0700 | [diff] [blame] | 1341 | int appearPosition; |
Selim Cinek | 66440cf | 2017-05-26 13:48:47 -0700 | [diff] [blame] | 1342 | int notGoneChildCount = getNotGoneChildCount(); |
Julia Reynolds | 34f1496 | 2018-05-03 12:40:20 +0000 | [diff] [blame] | 1343 | if (mEmptyShadeView.getVisibility() == GONE && notGoneChildCount != 0) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1344 | if (isHeadsUpTransition() |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 1345 | || (mHeadsUpManager.hasPinnedHeadsUp() && !mAmbientState.isDark())) { |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 1346 | appearPosition = getTopHeadsUpPinnedHeight(); |
Selim Cinek | cde90e5 | 2016-12-22 21:01:49 +0100 | [diff] [blame] | 1347 | } else { |
| 1348 | appearPosition = 0; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1349 | if (notGoneChildCount >= 1 && mShelf.getVisibility() != GONE) { |
| 1350 | appearPosition += mShelf.getIntrinsicHeight(); |
| 1351 | } |
Selim Cinek | cde90e5 | 2016-12-22 21:01:49 +0100 | [diff] [blame] | 1352 | } |
Selim Cinek | aa417da | 2016-10-27 18:17:08 -0700 | [diff] [blame] | 1353 | } else { |
Selim Cinek | cde90e5 | 2016-12-22 21:01:49 +0100 | [diff] [blame] | 1354 | appearPosition = mEmptyShadeView.getHeight(); |
Selim Cinek | aa417da | 2016-10-27 18:17:08 -0700 | [diff] [blame] | 1355 | } |
| 1356 | return appearPosition + (onKeyguard() ? mTopPadding : mIntrinsicPadding); |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1357 | } |
| 1358 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1359 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1360 | private boolean isHeadsUpTransition() { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 1361 | NotificationSection firstVisibleSection = getFirstVisibleSection(); |
| 1362 | return mTrackingHeadsUp && firstVisibleSection != null |
| 1363 | && mAmbientState.isAboveShelf(firstVisibleSection.getFirstVisibleChild()); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1364 | } |
| 1365 | |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1366 | /** |
| 1367 | * @param height the height of the panel |
| 1368 | * @return the fraction of the appear animation that has been performed |
| 1369 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1370 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 1371 | public float getAppearFraction(float height) { |
| 1372 | float appearEndPosition = getAppearEndPosition(); |
| 1373 | float appearStartPosition = getAppearStartPosition(); |
| 1374 | return (height - appearStartPosition) |
| 1375 | / (appearEndPosition - appearStartPosition); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1376 | } |
| 1377 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1378 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | d228115 | 2015-04-10 14:37:46 -0700 | [diff] [blame] | 1379 | public float getStackTranslation() { |
| 1380 | return mStackTranslation; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1381 | } |
| 1382 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1383 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | d228115 | 2015-04-10 14:37:46 -0700 | [diff] [blame] | 1384 | private void setStackTranslation(float stackTranslation) { |
| 1385 | if (stackTranslation != mStackTranslation) { |
| 1386 | mStackTranslation = stackTranslation; |
| 1387 | mAmbientState.setStackTranslation(stackTranslation); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1388 | requestChildrenUpdate(); |
| 1389 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1390 | } |
| 1391 | |
| 1392 | /** |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1393 | * Get the current height of the view. This is at most the msize of the view given by a the |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1394 | * layout but it can also be made smaller by setting {@link #mCurrentStackHeight} |
| 1395 | * |
| 1396 | * @return either the layout height or the externally defined height, whichever is smaller |
| 1397 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1398 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 1399 | private int getLayoutHeight() { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1400 | return Math.min(mMaxLayoutHeight, mCurrentStackHeight); |
| 1401 | } |
| 1402 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1403 | @ShadeViewRefactor(RefactorComponent.ADAPTER) |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 1404 | public int getFirstItemMinHeight() { |
| 1405 | final ExpandableView firstChild = getFirstChildNotGone(); |
| 1406 | return firstChild != null ? firstChild.getMinHeight() : mCollapsedSize; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1407 | } |
| 1408 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1409 | @ShadeViewRefactor(RefactorComponent.ADAPTER) |
Jason Monk | 16ac377 | 2016-02-10 15:39:21 -0500 | [diff] [blame] | 1410 | public void setQsContainer(ViewGroup qsContainer) { |
| 1411 | mQsContainer = qsContainer; |
Jorim Jaggi | 5630625 | 2014-07-03 00:40:09 +0200 | [diff] [blame] | 1412 | } |
| 1413 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1414 | @ShadeViewRefactor(RefactorComponent.ADAPTER) |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1415 | public static boolean isPinnedHeadsUp(View v) { |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 1416 | if (v instanceof ExpandableNotificationRow) { |
| 1417 | ExpandableNotificationRow row = (ExpandableNotificationRow) v; |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1418 | return row.isHeadsUp() && row.isPinned(); |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 1419 | } |
| 1420 | return false; |
| 1421 | } |
| 1422 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1423 | @ShadeViewRefactor(RefactorComponent.ADAPTER) |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 1424 | private boolean isHeadsUp(View v) { |
| 1425 | if (v instanceof ExpandableNotificationRow) { |
| 1426 | ExpandableNotificationRow row = (ExpandableNotificationRow) v; |
| 1427 | return row.isHeadsUp(); |
| 1428 | } |
| 1429 | return false; |
| 1430 | } |
| 1431 | |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 1432 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 1433 | public ExpandableView getClosestChildAtRawPosition(float touchX, float touchY) { |
| 1434 | getLocationOnScreen(mTempInt2); |
| 1435 | float localTouchY = touchY - mTempInt2[1]; |
| 1436 | |
| 1437 | ExpandableView closestChild = null; |
| 1438 | float minDist = Float.MAX_VALUE; |
| 1439 | |
| 1440 | // find the view closest to the location, accounting for GONE views |
| 1441 | final int count = getChildCount(); |
| 1442 | for (int childIdx = 0; childIdx < count; childIdx++) { |
| 1443 | ExpandableView slidingChild = (ExpandableView) getChildAt(childIdx); |
| 1444 | if (slidingChild.getVisibility() == GONE |
Selim Cinek | 4fd5dfc | 2016-01-19 15:16:15 -0800 | [diff] [blame] | 1445 | || slidingChild instanceof StackScrollerDecorView) { |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 1446 | continue; |
| 1447 | } |
| 1448 | float childTop = slidingChild.getTranslationY(); |
| 1449 | float top = childTop + slidingChild.getClipTopAmount(); |
Selim Cinek | a686b2c | 2016-10-26 13:58:27 -0700 | [diff] [blame] | 1450 | float bottom = childTop + slidingChild.getActualHeight() |
| 1451 | - slidingChild.getClipBottomAmount(); |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 1452 | |
| 1453 | float dist = Math.min(Math.abs(top - localTouchY), Math.abs(bottom - localTouchY)); |
| 1454 | if (dist < minDist) { |
| 1455 | closestChild = slidingChild; |
| 1456 | minDist = dist; |
| 1457 | } |
| 1458 | } |
| 1459 | return closestChild; |
| 1460 | } |
| 1461 | |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 1462 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
| 1463 | private ExpandableView getChildAtPosition(float touchX, float touchY) { |
Selim Cinek | 34ed7c0 | 2017-09-08 15:03:12 -0700 | [diff] [blame] | 1464 | return getChildAtPosition(touchX, touchY, true /* requireMinHeight */); |
| 1465 | |
| 1466 | } |
| 1467 | |
| 1468 | /** |
| 1469 | * Get the child at a certain screen location. |
| 1470 | * |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1471 | * @param touchX the x coordinate |
| 1472 | * @param touchY the y coordinate |
Selim Cinek | 34ed7c0 | 2017-09-08 15:03:12 -0700 | [diff] [blame] | 1473 | * @param requireMinHeight Whether a minimum height is required for a child to be returned. |
| 1474 | * @return the child at the given location. |
| 1475 | */ |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 1476 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 34ed7c0 | 2017-09-08 15:03:12 -0700 | [diff] [blame] | 1477 | private ExpandableView getChildAtPosition(float touchX, float touchY, |
| 1478 | boolean requireMinHeight) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1479 | // find the view under the pointer, accounting for GONE views |
| 1480 | final int count = getChildCount(); |
| 1481 | for (int childIdx = 0; childIdx < count; childIdx++) { |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1482 | ExpandableView slidingChild = (ExpandableView) getChildAt(childIdx); |
Selim Cinek | 51d2197 | 2017-07-19 17:39:20 -0700 | [diff] [blame] | 1483 | if (slidingChild.getVisibility() != VISIBLE |
Selim Cinek | 4fd5dfc | 2016-01-19 15:16:15 -0800 | [diff] [blame] | 1484 | || slidingChild instanceof StackScrollerDecorView) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1485 | continue; |
| 1486 | } |
Selim Cinek | 89faff1 | 2014-06-19 16:29:04 -0700 | [diff] [blame] | 1487 | float childTop = slidingChild.getTranslationY(); |
| 1488 | float top = childTop + slidingChild.getClipTopAmount(); |
Selim Cinek | a686b2c | 2016-10-26 13:58:27 -0700 | [diff] [blame] | 1489 | float bottom = childTop + slidingChild.getActualHeight() |
| 1490 | - slidingChild.getClipBottomAmount(); |
Jorim Jaggi | 28f0e59 | 2014-08-05 22:03:07 +0200 | [diff] [blame] | 1491 | |
| 1492 | // Allow the full width of this view to prevent gesture conflict on Keyguard (phone and |
| 1493 | // camera affordance). |
| 1494 | int left = 0; |
| 1495 | int right = getWidth(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1496 | |
Selim Cinek | 34ed7c0 | 2017-09-08 15:03:12 -0700 | [diff] [blame] | 1497 | if ((bottom - top >= mMinInteractionHeight || !requireMinHeight) |
Selim Cinek | 51d2197 | 2017-07-19 17:39:20 -0700 | [diff] [blame] | 1498 | && touchY >= top && touchY <= bottom && touchX >= left && touchX <= right) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1499 | if (slidingChild instanceof ExpandableNotificationRow) { |
| 1500 | ExpandableNotificationRow row = (ExpandableNotificationRow) slidingChild; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 1501 | NotificationEntry entry = row.getEntry(); |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 1502 | if (!mIsExpanded && row.isHeadsUp() && row.isPinned() |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 1503 | && mHeadsUpManager.getTopEntry().getRow() != row |
Selim Cinek | 5bc852a | 2015-12-21 12:19:09 -0800 | [diff] [blame] | 1504 | && mGroupManager.getGroupSummary( |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 1505 | mHeadsUpManager.getTopEntry().notification) |
| 1506 | != entry) { |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 1507 | continue; |
| 1508 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1509 | return row.getViewAtPosition(touchY - childTop); |
| 1510 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1511 | return slidingChild; |
| 1512 | } |
| 1513 | } |
| 1514 | return null; |
| 1515 | } |
| 1516 | |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 1517 | private ExpandableView getChildAtRawPosition(float touchX, float touchY) { |
| 1518 | getLocationOnScreen(mTempInt2); |
| 1519 | return getChildAtPosition(touchX - mTempInt2[0], touchY - mTempInt2[1]); |
Selim Cinek | 1b2a05e | 2016-04-28 14:20:39 -0700 | [diff] [blame] | 1520 | } |
| 1521 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1522 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 1523 | public void setScrollingEnabled(boolean enable) { |
| 1524 | mScrollingEnabled = enable; |
| 1525 | } |
| 1526 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1527 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 1528 | public void lockScrollTo(View v) { |
| 1529 | if (mForcedScroll == v) { |
| 1530 | return; |
| 1531 | } |
| 1532 | mForcedScroll = v; |
| 1533 | scrollTo(v); |
| 1534 | } |
| 1535 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1536 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 1537 | public boolean scrollTo(View v) { |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 1538 | ExpandableView expandableView = (ExpandableView) v; |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1539 | if (ANCHOR_SCROLLING) { |
| 1540 | // TODO |
| 1541 | } else { |
| 1542 | int positionInLinearLayout = getPositionInLinearLayout(v); |
| 1543 | int targetScroll = targetScrollForView(expandableView, positionInLinearLayout); |
| 1544 | int outOfViewScroll = positionInLinearLayout + expandableView.getIntrinsicHeight(); |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 1545 | |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1546 | // Only apply the scroll if we're scrolling the view upwards, or the view is so far up |
| 1547 | // that it is not visible anymore. |
| 1548 | if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) { |
| 1549 | mScroller.startScroll(mScrollX, mOwnScrollY, 0, targetScroll - mOwnScrollY); |
| 1550 | mDontReportNextOverScroll = true; |
| 1551 | animateScroll(); |
| 1552 | return true; |
| 1553 | } |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 1554 | } |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 1555 | return false; |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 1556 | } |
| 1557 | |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 1558 | /** |
| 1559 | * @return the scroll necessary to make the bottom edge of {@param v} align with the top of |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1560 | * the IME. |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 1561 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1562 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 1563 | private int targetScrollForView(ExpandableView v, int positionInLinearLayout) { |
| 1564 | return positionInLinearLayout + v.getIntrinsicHeight() + |
felkachang | 529bfe6 | 2018-07-04 12:51:44 +0800 | [diff] [blame] | 1565 | getImeInset() - getHeight() |
| 1566 | + ((!isExpanded() && isPinnedHeadsUp(v)) ? mHeadsUpInset : getTopPadding()); |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 1567 | } |
| 1568 | |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 1569 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1570 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 1571 | public WindowInsets onApplyWindowInsets(WindowInsets insets) { |
Selim Cinek | a424c50 | 2016-04-05 13:07:54 -0700 | [diff] [blame] | 1572 | mBottomInset = insets.getSystemWindowInsetBottom(); |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 1573 | |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1574 | if (ANCHOR_SCROLLING) { |
| 1575 | // TODO |
| 1576 | } else { |
| 1577 | int range = getScrollRange(); |
| 1578 | if (mOwnScrollY > range) { |
| 1579 | // HACK: We're repeatedly getting staggered insets here while the IME is |
| 1580 | // animating away. To work around that we'll wait until things have settled. |
| 1581 | removeCallbacks(mReclamp); |
| 1582 | postDelayed(mReclamp, 50); |
| 1583 | } else if (mForcedScroll != null) { |
| 1584 | // The scroll was requested before we got the actual inset - in case we need |
| 1585 | // to scroll up some more do so now. |
| 1586 | scrollTo(mForcedScroll); |
| 1587 | } |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 1588 | } |
| 1589 | return insets; |
| 1590 | } |
| 1591 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1592 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 1593 | private Runnable mReclamp = new Runnable() { |
| 1594 | @Override |
| 1595 | public void run() { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1596 | if (ANCHOR_SCROLLING) { |
| 1597 | // TODO |
| 1598 | } else { |
| 1599 | int range = getScrollRange(); |
| 1600 | mScroller.startScroll(mScrollX, mOwnScrollY, 0, range - mOwnScrollY); |
| 1601 | } |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 1602 | mDontReportNextOverScroll = true; |
| 1603 | mDontClampNextScroll = true; |
Selim Cinek | 9212de8 | 2017-02-06 16:04:28 -0800 | [diff] [blame] | 1604 | animateScroll(); |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 1605 | } |
| 1606 | }; |
| 1607 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1608 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
| 1609 | public void setExpandingEnabled(boolean enable) { |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 1610 | mExpandHelper.setEnabled(enable); |
| 1611 | } |
| 1612 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1613 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 1614 | private boolean isScrollingEnabled() { |
| 1615 | return mScrollingEnabled; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1616 | } |
| 1617 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1618 | @ShadeViewRefactor(RefactorComponent.ADAPTER) |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 1619 | private boolean canChildBeDismissed(View v) { |
Selim Cinek | 9c17b77 | 2015-07-07 20:37:09 -0700 | [diff] [blame] | 1620 | return StackScrollAlgorithm.canChildBeDismissed(v); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1621 | } |
| 1622 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1623 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 1624 | private boolean onKeyguard() { |
Selim Cinek | 355652a | 2016-12-07 13:32:12 -0800 | [diff] [blame] | 1625 | return mStatusBarState == StatusBarState.KEYGUARD; |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 1626 | } |
| 1627 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1628 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1629 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1630 | protected void onConfigurationChanged(Configuration newConfig) { |
| 1631 | super.onConfigurationChanged(newConfig); |
Adrian Roos | 22af650 | 2018-02-22 16:57:08 +0100 | [diff] [blame] | 1632 | mStatusBarHeight = getResources().getDimensionPixelOffset(R.dimen.status_bar_height); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1633 | float densityScale = getResources().getDisplayMetrics().density; |
| 1634 | mSwipeHelper.setDensityScale(densityScale); |
| 1635 | float pagingTouchSlop = ViewConfiguration.get(getContext()).getScaledPagingTouchSlop(); |
| 1636 | mSwipeHelper.setPagingTouchSlop(pagingTouchSlop); |
| 1637 | initView(getContext()); |
| 1638 | } |
| 1639 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1640 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1641 | public void dismissViewAnimated(View child, Runnable endRunnable, int delay, long duration) { |
Mady Mellor | 9c2c496 | 2016-04-05 10:43:08 -0700 | [diff] [blame] | 1642 | mSwipeHelper.dismissChild(child, 0, endRunnable, delay, true, duration, |
| 1643 | true /* isDismissAll */); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1644 | } |
| 1645 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1646 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 1647 | private void snapViewIfNeeded(NotificationEntry entry) { |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 1648 | ExpandableNotificationRow child = entry.getRow(); |
dongwan0605.kim | 30637e4 | 2016-03-02 17:16:47 +0900 | [diff] [blame] | 1649 | boolean animate = mIsExpanded || isPinnedHeadsUp(child); |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 1650 | // If the child is showing the notification menu snap to that |
| 1651 | float targetLeft = child.getProvider().isMenuVisible() ? child.getTranslation() : 0; |
Mady Mellor | 86889c2 | 2016-04-18 16:37:06 -0700 | [diff] [blame] | 1652 | mSwipeHelper.snapChildIfNeeded(child, animate, targetLeft); |
dongwan0605.kim | 30637e4 | 2016-03-02 17:16:47 +0900 | [diff] [blame] | 1653 | } |
| 1654 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1655 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1656 | @ShadeViewRefactor(RefactorComponent.ADAPTER) |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 1657 | public ViewGroup getViewParentForNotification(NotificationEntry entry) { |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 1658 | return this; |
| 1659 | } |
| 1660 | |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1661 | /** |
| 1662 | * Perform a scroll upwards and adapt the overscroll amounts accordingly |
| 1663 | * |
| 1664 | * @param deltaY The amount to scroll upwards, has to be positive. |
| 1665 | * @return The amount of scrolling to be performed by the scroller, |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1666 | * not handled by the overScroll amount. |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1667 | */ |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 1668 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1669 | private float overScrollUp(int deltaY, int range) { |
| 1670 | deltaY = Math.max(deltaY, 0); |
| 1671 | float currentTopAmount = getCurrentOverScrollAmount(true); |
| 1672 | float newTopAmount = currentTopAmount - deltaY; |
| 1673 | if (currentTopAmount > 0) { |
| 1674 | setOverScrollAmount(newTopAmount, true /* onTop */, |
| 1675 | false /* animate */); |
| 1676 | } |
| 1677 | // Top overScroll might not grab all scrolling motion, |
| 1678 | // we have to scroll as well. |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1679 | if (ANCHOR_SCROLLING) { |
| 1680 | float scrollAmount = newTopAmount < 0 ? -newTopAmount : 0.0f; |
| 1681 | // TODO: once we're recycling this will need to check the adapter position of the child |
| 1682 | ExpandableView lastRow = getLastRowNotGone(); |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 1683 | if (lastRow != null && !lastRow.isInShelf()) { |
| 1684 | float distanceToMax = Math.max(0, getMaxPositiveScrollAmount()); |
| 1685 | if (scrollAmount > distanceToMax) { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1686 | float currentBottomPixels = getCurrentOverScrolledPixels(false); |
| 1687 | // We overScroll on the bottom |
| 1688 | setOverScrolledPixels(currentBottomPixels + (scrollAmount - distanceToMax), |
| 1689 | false /* onTop */, |
| 1690 | false /* animate */); |
| 1691 | mScrollAnchorViewY -= distanceToMax; |
| 1692 | scrollAmount = 0f; |
| 1693 | } |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 1694 | } |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1695 | return scrollAmount; |
| 1696 | } else { |
| 1697 | float scrollAmount = newTopAmount < 0 ? -newTopAmount : 0.0f; |
| 1698 | float newScrollY = mOwnScrollY + scrollAmount; |
| 1699 | if (newScrollY > range) { |
| 1700 | if (!mExpandedInThisMotion) { |
| 1701 | float currentBottomPixels = getCurrentOverScrolledPixels(false); |
| 1702 | // We overScroll on the bottom |
| 1703 | setOverScrolledPixels(currentBottomPixels + newScrollY - range, |
| 1704 | false /* onTop */, |
| 1705 | false /* animate */); |
| 1706 | } |
| 1707 | setOwnScrollY(range); |
| 1708 | scrollAmount = 0.0f; |
| 1709 | } |
| 1710 | return scrollAmount; |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1711 | } |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1712 | } |
| 1713 | |
| 1714 | /** |
| 1715 | * Perform a scroll downward and adapt the overscroll amounts accordingly |
| 1716 | * |
| 1717 | * @param deltaY The amount to scroll downwards, has to be negative. |
| 1718 | * @return The amount of scrolling to be performed by the scroller, |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1719 | * not handled by the overScroll amount. |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1720 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1721 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1722 | private float overScrollDown(int deltaY) { |
| 1723 | deltaY = Math.min(deltaY, 0); |
| 1724 | float currentBottomAmount = getCurrentOverScrollAmount(false); |
| 1725 | float newBottomAmount = currentBottomAmount + deltaY; |
| 1726 | if (currentBottomAmount > 0) { |
| 1727 | setOverScrollAmount(newBottomAmount, false /* onTop */, |
| 1728 | false /* animate */); |
| 1729 | } |
| 1730 | // Bottom overScroll might not grab all scrolling motion, |
| 1731 | // we have to scroll as well. |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1732 | if (ANCHOR_SCROLLING) { |
| 1733 | float scrollAmount = newBottomAmount < 0 ? newBottomAmount : 0.0f; |
| 1734 | // TODO: once we're recycling this will need to check the adapter position of the child |
| 1735 | ExpandableView firstChild = getFirstChildNotGone(); |
| 1736 | float top = firstChild.getTranslationY(); |
| 1737 | float distanceToTop = mScrollAnchorView.getTranslationY() - top - mScrollAnchorViewY; |
| 1738 | if (distanceToTop < -scrollAmount) { |
| 1739 | float currentTopPixels = getCurrentOverScrolledPixels(true); |
| 1740 | // We overScroll on the top |
| 1741 | setOverScrolledPixels(currentTopPixels + (-scrollAmount - distanceToTop), |
| 1742 | true /* onTop */, |
| 1743 | false /* animate */); |
| 1744 | mScrollAnchorView = firstChild; |
| 1745 | mScrollAnchorViewY = 0; |
| 1746 | scrollAmount = 0f; |
| 1747 | } |
| 1748 | return scrollAmount; |
| 1749 | } else { |
| 1750 | float scrollAmount = newBottomAmount < 0 ? newBottomAmount : 0.0f; |
| 1751 | float newScrollY = mOwnScrollY + scrollAmount; |
| 1752 | if (newScrollY < 0) { |
| 1753 | float currentTopPixels = getCurrentOverScrolledPixels(true); |
| 1754 | // We overScroll on the top |
| 1755 | setOverScrolledPixels(currentTopPixels - newScrollY, |
| 1756 | true /* onTop */, |
| 1757 | false /* animate */); |
| 1758 | setOwnScrollY(0); |
| 1759 | scrollAmount = 0.0f; |
| 1760 | } |
| 1761 | return scrollAmount; |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1762 | } |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1763 | } |
| 1764 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1765 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1766 | private void initVelocityTrackerIfNotExists() { |
| 1767 | if (mVelocityTracker == null) { |
| 1768 | mVelocityTracker = VelocityTracker.obtain(); |
| 1769 | } |
| 1770 | } |
| 1771 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1772 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1773 | private void recycleVelocityTracker() { |
| 1774 | if (mVelocityTracker != null) { |
| 1775 | mVelocityTracker.recycle(); |
| 1776 | mVelocityTracker = null; |
| 1777 | } |
| 1778 | } |
| 1779 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1780 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1781 | private void initOrResetVelocityTracker() { |
| 1782 | if (mVelocityTracker == null) { |
| 1783 | mVelocityTracker = VelocityTracker.obtain(); |
| 1784 | } else { |
| 1785 | mVelocityTracker.clear(); |
| 1786 | } |
| 1787 | } |
| 1788 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1789 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 1790 | public void setFinishScrollingCallback(Runnable runnable) { |
| 1791 | mFinishScrollingCallback = runnable; |
| 1792 | } |
| 1793 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1794 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 9212de8 | 2017-02-06 16:04:28 -0800 | [diff] [blame] | 1795 | private void animateScroll() { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1796 | if (mScroller.computeScrollOffset()) { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1797 | if (ANCHOR_SCROLLING) { |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 1798 | int oldY = mLastScrollerY; |
| 1799 | int y = mScroller.getCurrY(); |
| 1800 | int deltaY = y - oldY; |
| 1801 | if (deltaY != 0) { |
| 1802 | int maxNegativeScrollAmount = getMaxNegativeScrollAmount(); |
| 1803 | int maxPositiveScrollAmount = getMaxPositiveScrollAmount(); |
| 1804 | if ((maxNegativeScrollAmount < 0 && deltaY < maxNegativeScrollAmount) |
| 1805 | || (maxPositiveScrollAmount > 0 && deltaY > maxPositiveScrollAmount)) { |
| 1806 | // This frame takes us into overscroll, so set the max overscroll based on |
| 1807 | // the current velocity |
| 1808 | setMaxOverScrollFromCurrentVelocity(); |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1809 | } |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 1810 | customOverScrollBy(deltaY, oldY, 0, (int) mMaxOverScroll); |
| 1811 | mLastScrollerY = y; |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1812 | } |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1813 | } else { |
| 1814 | int oldY = mOwnScrollY; |
| 1815 | int y = mScroller.getCurrY(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1816 | |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1817 | if (oldY != y) { |
| 1818 | int range = getScrollRange(); |
| 1819 | if (y < 0 && oldY >= 0 || y > range && oldY <= range) { |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 1820 | // This frame takes us into overscroll, so set the max overscroll based on |
| 1821 | // the current velocity |
| 1822 | setMaxOverScrollFromCurrentVelocity(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1823 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1824 | |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1825 | if (mDontClampNextScroll) { |
| 1826 | range = Math.max(range, oldY); |
| 1827 | } |
| 1828 | customOverScrollBy(y - oldY, oldY, range, |
| 1829 | (int) (mMaxOverScroll)); |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 1830 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1831 | } |
| 1832 | |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 1833 | postOnAnimation(mReflingAndAnimateScroll); |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 1834 | } else { |
| 1835 | mDontClampNextScroll = false; |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 1836 | if (mFinishScrollingCallback != null) { |
| 1837 | mFinishScrollingCallback.run(); |
| 1838 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 1839 | } |
| 1840 | } |
| 1841 | |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 1842 | private void setMaxOverScrollFromCurrentVelocity() { |
| 1843 | float currVelocity = mScroller.getCurrVelocity(); |
| 1844 | if (currVelocity >= mMinimumVelocity) { |
| 1845 | mMaxOverScroll = Math.abs(currVelocity) / 1000 * mOverflingDistance; |
Selim Cinek | 4195dd0 | 2014-05-19 18:16:14 +0200 | [diff] [blame] | 1846 | } |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 1847 | } |
Selim Cinek | 4195dd0 | 2014-05-19 18:16:14 +0200 | [diff] [blame] | 1848 | |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 1849 | /** |
| 1850 | * Scrolls by the given delta, overscrolling if needed. If called during a fling and the delta |
| 1851 | * would cause us to exceed the provided maximum overscroll, springs back instead. |
| 1852 | * |
| 1853 | * This method performs the determination of whether we're exceeding the overscroll and clamps |
| 1854 | * the scroll amount if so. The actual scrolling/overscrolling happens in |
| 1855 | * {@link #onCustomOverScrolled(int, boolean)} (absolute scrolling) or |
| 1856 | * {@link #onCustomOverScrolledBy(int, boolean)} (anchor scrolling). |
| 1857 | * |
| 1858 | * @param deltaY The (signed) number of pixels to scroll. |
| 1859 | * @param scrollY The current scroll position (absolute scrolling only). |
| 1860 | * @param scrollRangeY The maximum allowable scroll position (absolute scrolling only). |
| 1861 | * @param maxOverScrollY The current (unsigned) limit on number of pixels to overscroll by. |
| 1862 | */ |
Selim Cinek | 4195dd0 | 2014-05-19 18:16:14 +0200 | [diff] [blame] | 1863 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 1864 | private void customOverScrollBy(int deltaY, int scrollY, int scrollRangeY, int maxOverScrollY) { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1865 | if (ANCHOR_SCROLLING) { |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 1866 | boolean clampedY = false; |
| 1867 | if (deltaY < 0) { |
| 1868 | int maxScrollAmount = getMaxNegativeScrollAmount(); |
| 1869 | if (maxScrollAmount > Integer.MIN_VALUE) { |
| 1870 | maxScrollAmount -= maxOverScrollY; |
| 1871 | if (deltaY < maxScrollAmount) { |
| 1872 | deltaY = maxScrollAmount; |
| 1873 | clampedY = true; |
| 1874 | } |
| 1875 | } |
| 1876 | } else { |
| 1877 | int maxScrollAmount = getMaxPositiveScrollAmount(); |
| 1878 | if (maxScrollAmount < Integer.MAX_VALUE) { |
| 1879 | maxScrollAmount += maxOverScrollY; |
| 1880 | if (deltaY > maxScrollAmount) { |
| 1881 | deltaY = maxScrollAmount; |
| 1882 | clampedY = true; |
| 1883 | } |
| 1884 | } |
| 1885 | } |
| 1886 | onCustomOverScrolledBy(deltaY, clampedY); |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1887 | } else { |
| 1888 | int newScrollY = scrollY + deltaY; |
| 1889 | final int top = -maxOverScrollY; |
| 1890 | final int bottom = maxOverScrollY + scrollRangeY; |
Selim Cinek | 4195dd0 | 2014-05-19 18:16:14 +0200 | [diff] [blame] | 1891 | |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1892 | boolean clampedY = false; |
| 1893 | if (newScrollY > bottom) { |
| 1894 | newScrollY = bottom; |
| 1895 | clampedY = true; |
| 1896 | } else if (newScrollY < top) { |
| 1897 | newScrollY = top; |
| 1898 | clampedY = true; |
| 1899 | } |
Selim Cinek | 4195dd0 | 2014-05-19 18:16:14 +0200 | [diff] [blame] | 1900 | |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 1901 | onCustomOverScrolled(newScrollY, clampedY); |
Selim Cinek | 4195dd0 | 2014-05-19 18:16:14 +0200 | [diff] [blame] | 1902 | } |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1903 | } |
| 1904 | |
| 1905 | /** |
| 1906 | * Set the amount of overScrolled pixels which will force the view to apply a rubber-banded |
| 1907 | * overscroll effect based on numPixels. By default this will also cancel animations on the |
| 1908 | * same overScroll edge. |
| 1909 | * |
| 1910 | * @param numPixels The amount of pixels to overScroll by. These will be scaled according to |
| 1911 | * the rubber-banding logic. |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1912 | * @param onTop Should the effect be applied on top of the scroller. |
| 1913 | * @param animate Should an animation be performed. |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1914 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1915 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1916 | public void setOverScrolledPixels(float numPixels, boolean onTop, boolean animate) { |
Selim Cinek | fed1ab6 | 2014-06-17 14:10:33 -0700 | [diff] [blame] | 1917 | setOverScrollAmount(numPixels * getRubberBandFactor(onTop), onTop, animate, true); |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1918 | } |
| 1919 | |
| 1920 | /** |
| 1921 | * Set the effective overScroll amount which will be directly reflected in the layout. |
| 1922 | * By default this will also cancel animations on the same overScroll edge. |
| 1923 | * |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1924 | * @param amount The amount to overScroll by. |
| 1925 | * @param onTop Should the effect be applied on top of the scroller. |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1926 | * @param animate Should an animation be performed. |
| 1927 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1928 | |
| 1929 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1930 | public void setOverScrollAmount(float amount, boolean onTop, boolean animate) { |
| 1931 | setOverScrollAmount(amount, onTop, animate, true); |
| 1932 | } |
| 1933 | |
| 1934 | /** |
| 1935 | * Set the effective overScroll amount which will be directly reflected in the layout. |
| 1936 | * |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1937 | * @param amount The amount to overScroll by. |
| 1938 | * @param onTop Should the effect be applied on top of the scroller. |
| 1939 | * @param animate Should an animation be performed. |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1940 | * @param cancelAnimators Should running animations be cancelled. |
| 1941 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1942 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1943 | public void setOverScrollAmount(float amount, boolean onTop, boolean animate, |
| 1944 | boolean cancelAnimators) { |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1945 | setOverScrollAmount(amount, onTop, animate, cancelAnimators, isRubberbanded(onTop)); |
| 1946 | } |
| 1947 | |
| 1948 | /** |
| 1949 | * Set the effective overScroll amount which will be directly reflected in the layout. |
| 1950 | * |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1951 | * @param amount The amount to overScroll by. |
| 1952 | * @param onTop Should the effect be applied on top of the scroller. |
| 1953 | * @param animate Should an animation be performed. |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1954 | * @param cancelAnimators Should running animations be cancelled. |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 1955 | * @param isRubberbanded The value which will be passed to |
| 1956 | * {@link OnOverscrollTopChangedListener#onOverscrollTopChanged} |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1957 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1958 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1959 | public void setOverScrollAmount(float amount, boolean onTop, boolean animate, |
| 1960 | boolean cancelAnimators, boolean isRubberbanded) { |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1961 | if (cancelAnimators) { |
| 1962 | mStateAnimator.cancelOverScrollAnimators(onTop); |
| 1963 | } |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1964 | setOverScrollAmountInternal(amount, onTop, animate, isRubberbanded); |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1965 | } |
| 1966 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1967 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1968 | private void setOverScrollAmountInternal(float amount, boolean onTop, boolean animate, |
| 1969 | boolean isRubberbanded) { |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1970 | amount = Math.max(0, amount); |
| 1971 | if (animate) { |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1972 | mStateAnimator.animateOverScrollToAmount(amount, onTop, isRubberbanded); |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1973 | } else { |
Selim Cinek | fed1ab6 | 2014-06-17 14:10:33 -0700 | [diff] [blame] | 1974 | setOverScrolledPixels(amount / getRubberBandFactor(onTop), onTop); |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1975 | mAmbientState.setOverScrollAmount(amount, onTop); |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 1976 | if (onTop) { |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1977 | notifyOverscrollTopListener(amount, isRubberbanded); |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 1978 | } |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 1979 | requestChildrenUpdate(); |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 1980 | } |
| 1981 | } |
| 1982 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1983 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1984 | private void notifyOverscrollTopListener(float amount, boolean isRubberbanded) { |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 1985 | mExpandHelper.onlyObserveMovements(amount > 1.0f); |
| 1986 | if (mDontReportNextOverScroll) { |
| 1987 | mDontReportNextOverScroll = false; |
| 1988 | return; |
| 1989 | } |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 1990 | if (mOverscrollTopChangedListener != null) { |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 1991 | mOverscrollTopChangedListener.onOverscrollTopChanged(amount, isRubberbanded); |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 1992 | } |
| 1993 | } |
| 1994 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 1995 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 1996 | public void setOverscrollTopChangedListener( |
| 1997 | OnOverscrollTopChangedListener overscrollTopChangedListener) { |
| 1998 | mOverscrollTopChangedListener = overscrollTopChangedListener; |
| 1999 | } |
| 2000 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2001 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 2002 | public float getCurrentOverScrollAmount(boolean top) { |
| 2003 | return mAmbientState.getOverScrollAmount(top); |
| 2004 | } |
| 2005 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2006 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 2007 | public float getCurrentOverScrolledPixels(boolean top) { |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 2008 | return top ? mOverScrolledTopPixels : mOverScrolledBottomPixels; |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 2009 | } |
| 2010 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2011 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 2012 | private void setOverScrolledPixels(float amount, boolean onTop) { |
| 2013 | if (onTop) { |
| 2014 | mOverScrolledTopPixels = amount; |
| 2015 | } else { |
| 2016 | mOverScrolledBottomPixels = amount; |
| 2017 | } |
| 2018 | } |
| 2019 | |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 2020 | /** |
| 2021 | * Scrolls by the given delta, overscrolling if needed. If called during a fling and the delta |
| 2022 | * would cause us to exceed the provided maximum overscroll, springs back instead. |
| 2023 | * |
| 2024 | * @param deltaY The (signed) number of pixels to scroll. |
| 2025 | * @param clampedY Whether this value was clamped by the calling method, meaning we've reached |
| 2026 | * the overscroll limit. |
| 2027 | */ |
| 2028 | private void onCustomOverScrolledBy(int deltaY, boolean clampedY) { |
| 2029 | assert ANCHOR_SCROLLING; |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 2030 | mScrollAnchorViewY -= deltaY; |
| 2031 | // Treat animating scrolls differently; see #computeScroll() for why. |
| 2032 | if (!mScroller.isFinished()) { |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 2033 | if (clampedY) { |
| 2034 | springBack(); |
| 2035 | } else { |
| 2036 | float overScrollTop = getCurrentOverScrollAmount(true /* top */); |
| 2037 | if (isScrolledToTop() && mScrollAnchorViewY > 0) { |
| 2038 | notifyOverscrollTopListener(mScrollAnchorViewY, |
| 2039 | isRubberbanded(true /* onTop */)); |
| 2040 | } else { |
| 2041 | notifyOverscrollTopListener(overScrollTop, isRubberbanded(true /* onTop */)); |
| 2042 | } |
| 2043 | } |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 2044 | } |
| 2045 | updateScrollAnchor(); |
| 2046 | updateOnScrollChange(); |
| 2047 | } |
| 2048 | |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 2049 | /** |
| 2050 | * Scrolls to the given position, overscrolling if needed. If called during a fling and the |
| 2051 | * position exceeds the provided maximum overscroll, springs back instead. |
| 2052 | * |
| 2053 | * @param scrollY The target scroll position. |
| 2054 | * @param clampedY Whether this value was clamped by the calling method, meaning we've reached |
| 2055 | * the overscroll limit. |
| 2056 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2057 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 9212de8 | 2017-02-06 16:04:28 -0800 | [diff] [blame] | 2058 | private void onCustomOverScrolled(int scrollY, boolean clampedY) { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 2059 | assert !ANCHOR_SCROLLING; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2060 | // Treat animating scrolls differently; see #computeScroll() for why. |
| 2061 | if (!mScroller.isFinished()) { |
Selim Cinek | ef40606 | 2016-09-29 17:33:13 -0700 | [diff] [blame] | 2062 | setOwnScrollY(scrollY); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2063 | if (clampedY) { |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 2064 | springBack(); |
| 2065 | } else { |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 2066 | float overScrollTop = getCurrentOverScrollAmount(true); |
| 2067 | if (mOwnScrollY < 0) { |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 2068 | notifyOverscrollTopListener(-mOwnScrollY, isRubberbanded(true)); |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 2069 | } else { |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 2070 | notifyOverscrollTopListener(overScrollTop, isRubberbanded(true)); |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 2071 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2072 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2073 | } else { |
Selim Cinek | 9212de8 | 2017-02-06 16:04:28 -0800 | [diff] [blame] | 2074 | setOwnScrollY(scrollY); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2075 | } |
| 2076 | } |
| 2077 | |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 2078 | /** |
| 2079 | * Springs back from an overscroll by stopping the {@link #mScroller} and animating the |
| 2080 | * overscroll amount back to zero. |
| 2081 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2082 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 2083 | private void springBack() { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 2084 | if (ANCHOR_SCROLLING) { |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 2085 | boolean overScrolledTop = isScrolledToTop() && mScrollAnchorViewY > 0; |
| 2086 | int maxPositiveScrollAmount = getMaxPositiveScrollAmount(); |
| 2087 | boolean overscrolledBottom = maxPositiveScrollAmount < 0; |
| 2088 | if (overScrolledTop || overscrolledBottom) { |
| 2089 | float newAmount; |
| 2090 | if (overScrolledTop) { |
| 2091 | newAmount = mScrollAnchorViewY; |
| 2092 | mScrollAnchorViewY = 0; |
| 2093 | mDontReportNextOverScroll = true; |
| 2094 | } else { |
| 2095 | newAmount = -maxPositiveScrollAmount; |
| 2096 | mScrollAnchorViewY -= maxPositiveScrollAmount; |
| 2097 | } |
| 2098 | setOverScrollAmount(newAmount, overScrolledTop, false); |
| 2099 | setOverScrollAmount(0.0f, overScrolledTop, true); |
| 2100 | mScroller.forceFinished(true); |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 2101 | } |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 2102 | } else { |
| 2103 | int scrollRange = getScrollRange(); |
| 2104 | boolean overScrolledTop = mOwnScrollY <= 0; |
| 2105 | boolean overScrolledBottom = mOwnScrollY >= scrollRange; |
| 2106 | if (overScrolledTop || overScrolledBottom) { |
| 2107 | boolean onTop; |
| 2108 | float newAmount; |
| 2109 | if (overScrolledTop) { |
| 2110 | onTop = true; |
| 2111 | newAmount = -mOwnScrollY; |
| 2112 | setOwnScrollY(0); |
| 2113 | mDontReportNextOverScroll = true; |
| 2114 | } else { |
| 2115 | onTop = false; |
| 2116 | newAmount = mOwnScrollY - scrollRange; |
| 2117 | setOwnScrollY(scrollRange); |
| 2118 | } |
| 2119 | setOverScrollAmount(newAmount, onTop, false); |
| 2120 | setOverScrollAmount(0.0f, onTop, true); |
| 2121 | mScroller.forceFinished(true); |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 2122 | } |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 2123 | } |
| 2124 | } |
| 2125 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2126 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2127 | private int getScrollRange() { |
felkachang | 529bfe6 | 2018-07-04 12:51:44 +0800 | [diff] [blame] | 2128 | // In current design, it only use the top HUN to treat all of HUNs |
| 2129 | // although there are more than one HUNs |
| 2130 | int contentHeight = mContentHeight; |
| 2131 | if (!isExpanded() && mHeadsUpManager.hasPinnedHeadsUp()) { |
| 2132 | contentHeight = mHeadsUpInset + getTopHeadsUpPinnedHeight(); |
| 2133 | } |
| 2134 | int scrollRange = Math.max(0, contentHeight - mMaxLayoutHeight); |
Selim Cinek | a424c50 | 2016-04-05 13:07:54 -0700 | [diff] [blame] | 2135 | int imeInset = getImeInset(); |
felkachang | 529bfe6 | 2018-07-04 12:51:44 +0800 | [diff] [blame] | 2136 | scrollRange += Math.min(imeInset, Math.max(0, contentHeight - (getHeight() - imeInset))); |
Selim Cinek | a424c50 | 2016-04-05 13:07:54 -0700 | [diff] [blame] | 2137 | return scrollRange; |
| 2138 | } |
| 2139 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2140 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | a424c50 | 2016-04-05 13:07:54 -0700 | [diff] [blame] | 2141 | private int getImeInset() { |
| 2142 | return Math.max(0, mBottomInset - (getRootView().getHeight() - getHeight())); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2143 | } |
| 2144 | |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 2145 | /** |
| 2146 | * @return the first child which has visibility unequal to GONE |
| 2147 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2148 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | b55386d | 2015-12-16 17:26:49 -0800 | [diff] [blame] | 2149 | public ExpandableView getFirstChildNotGone() { |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 2150 | int childCount = getChildCount(); |
| 2151 | for (int i = 0; i < childCount; i++) { |
| 2152 | View child = getChildAt(i); |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 2153 | if (child.getVisibility() != View.GONE && child != mShelf) { |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 2154 | return (ExpandableView) child; |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 2155 | } |
| 2156 | } |
| 2157 | return null; |
| 2158 | } |
| 2159 | |
Selim Cinek | 4a1ac84 | 2014-05-01 15:51:58 +0200 | [diff] [blame] | 2160 | /** |
Selim Cinek | 1b2a05e | 2016-04-28 14:20:39 -0700 | [diff] [blame] | 2161 | * @return the child before the given view which has visibility unequal to GONE |
| 2162 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2163 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 1b2a05e | 2016-04-28 14:20:39 -0700 | [diff] [blame] | 2164 | public ExpandableView getViewBeforeView(ExpandableView view) { |
| 2165 | ExpandableView previousView = null; |
| 2166 | int childCount = getChildCount(); |
| 2167 | for (int i = 0; i < childCount; i++) { |
| 2168 | View child = getChildAt(i); |
| 2169 | if (child == view) { |
| 2170 | return previousView; |
| 2171 | } |
| 2172 | if (child.getVisibility() != View.GONE) { |
| 2173 | previousView = (ExpandableView) child; |
| 2174 | } |
| 2175 | } |
| 2176 | return null; |
| 2177 | } |
| 2178 | |
| 2179 | /** |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 2180 | * @return The first child which has visibility unequal to GONE which is currently below the |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 2181 | * given translationY or equal to it. |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 2182 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2183 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | ef8c225 | 2017-02-10 14:52:18 -0800 | [diff] [blame] | 2184 | private View getFirstChildBelowTranlsationY(float translationY, boolean ignoreChildren) { |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 2185 | int childCount = getChildCount(); |
| 2186 | for (int i = 0; i < childCount; i++) { |
| 2187 | View child = getChildAt(i); |
Selim Cinek | ef8c225 | 2017-02-10 14:52:18 -0800 | [diff] [blame] | 2188 | if (child.getVisibility() == View.GONE) { |
| 2189 | continue; |
| 2190 | } |
| 2191 | float rowTranslation = child.getTranslationY(); |
| 2192 | if (rowTranslation >= translationY) { |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 2193 | return child; |
Selim Cinek | ef8c225 | 2017-02-10 14:52:18 -0800 | [diff] [blame] | 2194 | } else if (!ignoreChildren && child instanceof ExpandableNotificationRow) { |
| 2195 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 2196 | if (row.isSummaryWithChildren() && row.areChildrenExpanded()) { |
| 2197 | List<ExpandableNotificationRow> notificationChildren = |
| 2198 | row.getNotificationChildren(); |
| 2199 | for (int childIndex = 0; childIndex < notificationChildren.size(); |
| 2200 | childIndex++) { |
| 2201 | ExpandableNotificationRow rowChild = notificationChildren.get(childIndex); |
| 2202 | if (rowChild.getTranslationY() + rowTranslation >= translationY) { |
| 2203 | return rowChild; |
| 2204 | } |
| 2205 | } |
| 2206 | } |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 2207 | } |
| 2208 | } |
| 2209 | return null; |
| 2210 | } |
| 2211 | |
| 2212 | /** |
Selim Cinek | 4a1ac84 | 2014-05-01 15:51:58 +0200 | [diff] [blame] | 2213 | * @return the last child which has visibility unequal to GONE |
| 2214 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2215 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 2216 | public ExpandableView getLastChildNotGone() { |
Selim Cinek | 4a1ac84 | 2014-05-01 15:51:58 +0200 | [diff] [blame] | 2217 | int childCount = getChildCount(); |
| 2218 | for (int i = childCount - 1; i >= 0; i--) { |
| 2219 | View child = getChildAt(i); |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 2220 | if (child.getVisibility() != View.GONE && child != mShelf) { |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 2221 | return (ExpandableView) child; |
Selim Cinek | 4a1ac84 | 2014-05-01 15:51:58 +0200 | [diff] [blame] | 2222 | } |
| 2223 | } |
| 2224 | return null; |
| 2225 | } |
| 2226 | |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 2227 | private ExpandableNotificationRow getLastRowNotGone() { |
| 2228 | int childCount = getChildCount(); |
| 2229 | for (int i = childCount - 1; i >= 0; i--) { |
| 2230 | View child = getChildAt(i); |
| 2231 | if (child instanceof ExpandableNotificationRow && child.getVisibility() != View.GONE) { |
| 2232 | return (ExpandableNotificationRow) child; |
| 2233 | } |
| 2234 | } |
| 2235 | return null; |
| 2236 | } |
| 2237 | |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 2238 | /** |
| 2239 | * @return the number of children which have visibility unequal to GONE |
| 2240 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2241 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 2242 | public int getNotGoneChildCount() { |
| 2243 | int childCount = getChildCount(); |
| 2244 | int count = 0; |
| 2245 | for (int i = 0; i < childCount; i++) { |
Selim Cinek | 2cd45df | 2015-06-09 18:00:07 -0700 | [diff] [blame] | 2246 | ExpandableView child = (ExpandableView) getChildAt(i); |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 2247 | if (child.getVisibility() != View.GONE && !child.willBeGone() && child != mShelf) { |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 2248 | count++; |
| 2249 | } |
| 2250 | } |
| 2251 | return count; |
| 2252 | } |
| 2253 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2254 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2255 | private void updateContentHeight() { |
| 2256 | int height = 0; |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 2257 | float previousPaddingRequest = mPaddingBetweenElements; |
| 2258 | float previousPaddingAmount = 0.0f; |
Selim Cinek | ad7fac0 | 2016-10-18 17:09:15 -0700 | [diff] [blame] | 2259 | int numShownItems = 0; |
| 2260 | boolean finish = false; |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 2261 | int maxDisplayedNotifications = mAmbientState.isFullyDark() |
Selim Cinek | be2c443 | 2017-05-30 12:11:09 -0700 | [diff] [blame] | 2262 | ? (hasPulsingNotifications() ? 1 : 0) |
Adrian Roos | 7a9551a | 2017-01-11 12:27:49 -0800 | [diff] [blame] | 2263 | : mMaxDisplayedNotifications; |
| 2264 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2265 | for (int i = 0; i < getChildCount(); i++) { |
Selim Cinek | 61633a8 | 2016-01-25 15:54:10 -0800 | [diff] [blame] | 2266 | ExpandableView expandableView = (ExpandableView) getChildAt(i); |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 2267 | boolean footerViewOnLockScreen = expandableView == mFooterView && onKeyguard(); |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 2268 | if (expandableView.getVisibility() != View.GONE |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 2269 | && !expandableView.hasNoContentHeight() && !footerViewOnLockScreen) { |
Adrian Roos | 7d062c4 | 2017-03-30 15:11:43 -0700 | [diff] [blame] | 2270 | boolean limitReached = maxDisplayedNotifications != -1 |
| 2271 | && numShownItems >= maxDisplayedNotifications; |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 2272 | boolean notificationOnAmbientThatIsNotPulsing = mAmbientState.isFullyDark() |
Selim Cinek | be2c443 | 2017-05-30 12:11:09 -0700 | [diff] [blame] | 2273 | && hasPulsingNotifications() |
Adrian Roos | 7d062c4 | 2017-03-30 15:11:43 -0700 | [diff] [blame] | 2274 | && expandableView instanceof ExpandableNotificationRow |
| 2275 | && !isPulsing(((ExpandableNotificationRow) expandableView).getEntry()); |
| 2276 | if (limitReached || notificationOnAmbientThatIsNotPulsing) { |
Selim Cinek | ad7fac0 | 2016-10-18 17:09:15 -0700 | [diff] [blame] | 2277 | expandableView = mShelf; |
| 2278 | finish = true; |
| 2279 | } |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 2280 | float increasedPaddingAmount = expandableView.getIncreasedPaddingAmount(); |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 2281 | float padding; |
| 2282 | if (increasedPaddingAmount >= 0.0f) { |
| 2283 | padding = (int) NotificationUtils.interpolate( |
| 2284 | previousPaddingRequest, |
| 2285 | mIncreasedPaddingBetweenElements, |
| 2286 | increasedPaddingAmount); |
| 2287 | previousPaddingRequest = (int) NotificationUtils.interpolate( |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 2288 | mPaddingBetweenElements, |
| 2289 | mIncreasedPaddingBetweenElements, |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 2290 | increasedPaddingAmount); |
| 2291 | } else { |
| 2292 | int ownPadding = (int) NotificationUtils.interpolate( |
| 2293 | 0, |
| 2294 | mPaddingBetweenElements, |
| 2295 | 1.0f + increasedPaddingAmount); |
| 2296 | if (previousPaddingAmount > 0.0f) { |
| 2297 | padding = (int) NotificationUtils.interpolate( |
| 2298 | ownPadding, |
| 2299 | mIncreasedPaddingBetweenElements, |
| 2300 | previousPaddingAmount); |
| 2301 | } else { |
| 2302 | padding = ownPadding; |
| 2303 | } |
| 2304 | previousPaddingRequest = ownPadding; |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 2305 | } |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 2306 | if (height != 0) { |
| 2307 | height += padding; |
| 2308 | } |
| 2309 | previousPaddingAmount = increasedPaddingAmount; |
Selim Cinek | 61633a8 | 2016-01-25 15:54:10 -0800 | [diff] [blame] | 2310 | height += expandableView.getIntrinsicHeight(); |
Selim Cinek | ad7fac0 | 2016-10-18 17:09:15 -0700 | [diff] [blame] | 2311 | numShownItems++; |
| 2312 | if (finish) { |
| 2313 | break; |
| 2314 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2315 | } |
| 2316 | } |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 2317 | mIntrinsicContentHeight = height; |
Selim Cinek | f4b04ae | 2018-06-13 18:23:45 -0700 | [diff] [blame] | 2318 | |
Lucas Dupin | 00be88f | 2019-01-03 17:50:52 -0800 | [diff] [blame] | 2319 | mContentHeight = height + mTopPadding + mBottomMargin; |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 2320 | updateScrollability(); |
Selim Cinek | 51d2197 | 2017-07-19 17:39:20 -0700 | [diff] [blame] | 2321 | clampScrollPosition(); |
Selim Cinek | 91d4cba | 2016-11-10 19:59:48 -0800 | [diff] [blame] | 2322 | mAmbientState.setLayoutMaxHeight(mContentHeight); |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 2323 | } |
| 2324 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2325 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 2326 | private boolean isPulsing(NotificationEntry entry) { |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 2327 | return mAmbientState.isPulsing(entry); |
Adrian Roos | 7d062c4 | 2017-03-30 15:11:43 -0700 | [diff] [blame] | 2328 | } |
| 2329 | |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 2330 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2331 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | be2c443 | 2017-05-30 12:11:09 -0700 | [diff] [blame] | 2332 | public boolean hasPulsingNotifications() { |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 2333 | return mPulsing; |
Adrian Roos | 7d062c4 | 2017-03-30 15:11:43 -0700 | [diff] [blame] | 2334 | } |
| 2335 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2336 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 2337 | private void updateScrollability() { |
Riddle Hsu | 065c01c | 2018-05-10 23:14:19 +0800 | [diff] [blame] | 2338 | boolean scrollable = !mQsExpanded && getScrollRange() > 0; |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 2339 | if (scrollable != mScrollable) { |
| 2340 | mScrollable = scrollable; |
| 2341 | setFocusable(scrollable); |
Selim Cinek | ef40606 | 2016-09-29 17:33:13 -0700 | [diff] [blame] | 2342 | updateForwardAndBackwardScrollability(); |
| 2343 | } |
| 2344 | } |
| 2345 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2346 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | ef40606 | 2016-09-29 17:33:13 -0700 | [diff] [blame] | 2347 | private void updateForwardAndBackwardScrollability() { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 2348 | boolean forwardScrollable = mScrollable && !isScrolledToBottom(); |
| 2349 | boolean backwardsScrollable = mScrollable && !isScrolledToTop(); |
Selim Cinek | ef40606 | 2016-09-29 17:33:13 -0700 | [diff] [blame] | 2350 | boolean changed = forwardScrollable != mForwardScrollable |
| 2351 | || backwardsScrollable != mBackwardScrollable; |
| 2352 | mForwardScrollable = forwardScrollable; |
| 2353 | mBackwardScrollable = backwardsScrollable; |
| 2354 | if (changed) { |
| 2355 | sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 2356 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2357 | } |
| 2358 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2359 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 2360 | private void updateBackground() { |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 2361 | // No need to update the background color if it's not being drawn. |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 2362 | if (!mShouldDrawNotificationBackground || mAmbientState.isFullyDark()) { |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 2363 | return; |
| 2364 | } |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 2365 | |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 2366 | updateBackgroundBounds(); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2367 | if (didSectionBoundsChange()) { |
| 2368 | boolean animate = mAnimateNextSectionBoundsChange || mAnimateNextBackgroundTop |
| 2369 | || mAnimateNextBackgroundBottom || areSectionBoundsAnimating(); |
Selim Cinek | 5468090 | 2016-10-19 16:49:44 -0700 | [diff] [blame] | 2370 | if (!isExpanded()) { |
| 2371 | abortBackgroundAnimators(); |
| 2372 | animate = false; |
| 2373 | } |
| 2374 | if (animate) { |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 2375 | startBackgroundAnimation(); |
| 2376 | } else { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2377 | for (NotificationSection section : mSections) { |
| 2378 | section.resetCurrentBounds(); |
| 2379 | } |
Lucas Dupin | 90a38dd | 2018-09-05 09:37:37 -0700 | [diff] [blame] | 2380 | invalidate(); |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 2381 | } |
| 2382 | } else { |
Selim Cinek | 5468090 | 2016-10-19 16:49:44 -0700 | [diff] [blame] | 2383 | abortBackgroundAnimators(); |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 2384 | } |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 2385 | mAnimateNextBackgroundTop = false; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2386 | mAnimateNextBackgroundBottom = false; |
| 2387 | mAnimateNextSectionBoundsChange = false; |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 2388 | } |
| 2389 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2390 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 5468090 | 2016-10-19 16:49:44 -0700 | [diff] [blame] | 2391 | private void abortBackgroundAnimators() { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2392 | for (NotificationSection section : mSections) { |
| 2393 | section.cancelAnimators(); |
Selim Cinek | 5468090 | 2016-10-19 16:49:44 -0700 | [diff] [blame] | 2394 | } |
| 2395 | } |
| 2396 | |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2397 | private boolean didSectionBoundsChange() { |
| 2398 | for (NotificationSection section : mSections) { |
| 2399 | if (section.didBoundsChange()) { |
| 2400 | return true; |
| 2401 | } |
| 2402 | } |
| 2403 | return false; |
| 2404 | } |
| 2405 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2406 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2407 | private boolean areSectionBoundsAnimating() { |
| 2408 | for (NotificationSection section : mSections) { |
| 2409 | if (section.areBoundsAnimating()) { |
| 2410 | return true; |
| 2411 | } |
| 2412 | } |
| 2413 | return false; |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 2414 | } |
| 2415 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2416 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 2417 | private void startBackgroundAnimation() { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2418 | // TODO(kprevas): do we still need separate fields for top/bottom? |
| 2419 | // or can each section manage its own animation state? |
| 2420 | NotificationSection firstVisibleSection = getFirstVisibleSection(); |
| 2421 | NotificationSection lastVisibleSection = getLastVisibleSection(); |
| 2422 | for (NotificationSection section : mSections) { |
| 2423 | section.startBackgroundAnimation( |
| 2424 | section == firstVisibleSection |
| 2425 | ? mAnimateNextBackgroundTop |
| 2426 | : mAnimateNextSectionBoundsChange, |
| 2427 | section == lastVisibleSection |
| 2428 | ? mAnimateNextBackgroundBottom |
| 2429 | : mAnimateNextSectionBoundsChange); |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 2430 | } |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 2431 | } |
| 2432 | |
| 2433 | /** |
| 2434 | * Update the background bounds to the new desired bounds |
| 2435 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2436 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 2437 | private void updateBackgroundBounds() { |
shawnlin | 3a2a2e2 | 2018-05-04 17:09:50 +0800 | [diff] [blame] | 2438 | getLocationInWindow(mTempInt2); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2439 | int left = mTempInt2[0] + mSidePaddings; |
| 2440 | int right = mTempInt2[0] + getWidth() - mSidePaddings; |
| 2441 | for (NotificationSection section : mSections) { |
| 2442 | section.getBounds().left = left; |
| 2443 | section.getBounds().right = right; |
| 2444 | } |
shawnlin | 3a2a2e2 | 2018-05-04 17:09:50 +0800 | [diff] [blame] | 2445 | |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 2446 | if (!mIsExpanded) { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2447 | for (NotificationSection section : mSections) { |
| 2448 | section.getBounds().top = 0; |
| 2449 | section.getBounds().bottom = 0; |
| 2450 | } |
Selim Cinek | 1791f50 | 2016-10-07 17:38:03 -0400 | [diff] [blame] | 2451 | return; |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 2452 | } |
Gus Prevas | e83700cb | 2018-12-14 11:42:51 -0500 | [diff] [blame] | 2453 | int top = getSectionTopOrFinalTop(getFirstVisibleSection(), mAnimateNextBackgroundTop); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2454 | NotificationSection lastSection = getLastVisibleSection(); |
Anthony Chen | 9e05d46 | 2017-04-07 10:10:21 -0700 | [diff] [blame] | 2455 | ActivatableNotificationView lastView = |
| 2456 | mShelf.hasItemsInStableShelf() && mShelf.getVisibility() != GONE |
| 2457 | ? mShelf |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2458 | : lastSection == null ? null : lastSection.getLastVisibleChild(); |
Anthony Chen | 9e05d46 | 2017-04-07 10:10:21 -0700 | [diff] [blame] | 2459 | int bottom; |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 2460 | if (lastView != null) { |
Gus Prevas | e83700cb | 2018-12-14 11:42:51 -0500 | [diff] [blame] | 2461 | bottom = getSectionBottomOrFinalBottom( |
| 2462 | lastSection, lastView, mAnimateNextBackgroundBottom); |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 2463 | } else { |
Selim Cinek | d393d5c | 2016-08-03 16:18:12 -0700 | [diff] [blame] | 2464 | top = mTopPadding; |
Selim Cinek | 7db4298 | 2016-02-02 15:21:41 -0800 | [diff] [blame] | 2465 | bottom = top; |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 2466 | } |
Selim Cinek | 355652a | 2016-12-07 13:32:12 -0800 | [diff] [blame] | 2467 | if (mStatusBarState != StatusBarState.KEYGUARD) { |
Selim Cinek | d381bc3 | 2016-08-15 12:40:57 -0700 | [diff] [blame] | 2468 | top = (int) Math.max(mTopPadding + mStackTranslation, top); |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 2469 | } else { |
| 2470 | // otherwise the animation from the shade to the keyguard will jump as it's maxed |
Selim Cinek | d381bc3 | 2016-08-15 12:40:57 -0700 | [diff] [blame] | 2471 | top = Math.max(0, top); |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 2472 | } |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2473 | bottom = Math.max(bottom, top); |
| 2474 | |
| 2475 | setSectionBoundsByPriority(left, right, top, bottom, mSections[0], mSections[1]); |
| 2476 | } |
| 2477 | |
Gus Prevas | e83700cb | 2018-12-14 11:42:51 -0500 | [diff] [blame] | 2478 | private int getSectionTopOrFinalTop( |
| 2479 | @Nullable NotificationSection section, boolean alreadyAnimating) { |
| 2480 | int top = 0; |
| 2481 | if (section != null) { |
| 2482 | ActivatableNotificationView firstView = section.getFirstVisibleChild(); |
Gus Prevas | 7c7f8c2 | 2019-01-18 14:21:19 -0500 | [diff] [blame] | 2483 | if (firstView != null) { |
| 2484 | // Round Y up to avoid seeing the background during animation |
| 2485 | int finalTranslationY = (int) Math.ceil(ViewState.getFinalTranslationY(firstView)); |
| 2486 | if (alreadyAnimating || section.isTargetTop(finalTranslationY)) { |
| 2487 | // we're ending up at the same location as we are now, let's just skip the |
| 2488 | // animation |
| 2489 | top = finalTranslationY; |
| 2490 | } else { |
| 2491 | top = (int) Math.ceil(firstView.getTranslationY()); |
| 2492 | } |
Gus Prevas | e83700cb | 2018-12-14 11:42:51 -0500 | [diff] [blame] | 2493 | } |
| 2494 | } |
| 2495 | return top; |
| 2496 | } |
| 2497 | |
| 2498 | private int getSectionBottomOrFinalBottom( |
| 2499 | @Nullable NotificationSection section, boolean alreadyAnimating) { |
| 2500 | return section == null ? 0 |
| 2501 | : getSectionBottomOrFinalBottom( |
| 2502 | section, section.getLastVisibleChild(), alreadyAnimating); |
| 2503 | } |
| 2504 | |
| 2505 | private int getSectionBottomOrFinalBottom( |
| 2506 | NotificationSection section, |
| 2507 | ActivatableNotificationView lastView, |
| 2508 | boolean alreadyAnimating) { |
| 2509 | int bottom = 0; |
| 2510 | if (lastView != null) { |
| 2511 | float finalTranslationY; |
| 2512 | if (lastView == mShelf) { |
| 2513 | finalTranslationY = mShelf.getTranslationY(); |
| 2514 | } else { |
| 2515 | finalTranslationY = ViewState.getFinalTranslationY(lastView); |
| 2516 | } |
| 2517 | int finalHeight = ExpandableViewState.getFinalActualHeight(lastView); |
| 2518 | // Round Y down to avoid seeing the background during animation |
| 2519 | int finalBottom = (int) Math.floor( |
| 2520 | finalTranslationY + finalHeight - lastView.getClipBottomAmount()); |
| 2521 | if (alreadyAnimating || section.isTargetBottom(finalBottom)) { |
| 2522 | // we're ending up at the same location as we are now, lets just skip the animation |
| 2523 | bottom = finalBottom; |
| 2524 | } else { |
| 2525 | bottom = (int) (lastView.getTranslationY() + lastView.getActualHeight() |
| 2526 | - lastView.getClipBottomAmount()); |
| 2527 | } |
| 2528 | } |
| 2529 | return bottom; |
| 2530 | } |
| 2531 | |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2532 | private void setSectionBoundsByPriority(int left, int right, int top, int bottom, |
| 2533 | NotificationSection highPrioritySection, NotificationSection lowPrioritySection) { |
| 2534 | if (NotificationUtils.useNewInterruptionModel(mContext)) { |
| 2535 | // TODO(kprevas): can we use section boundary indices from mAmbientState instead? |
| 2536 | ActivatableNotificationView lastChildAboveGap = getLastHighPriorityChild(); |
| 2537 | ActivatableNotificationView firstChildBelowGap = getFirstLowPriorityChild(); |
| 2538 | if (lastChildAboveGap != null && firstChildBelowGap != null) { |
Gus Prevas | e83700cb | 2018-12-14 11:42:51 -0500 | [diff] [blame] | 2539 | int gapTop = getSectionBottomOrFinalBottom( |
| 2540 | highPrioritySection, mAnimateNextSectionBoundsChange); |
| 2541 | gapTop = Math.max(top, Math.min(gapTop, bottom)); |
| 2542 | |
| 2543 | int gapBottom = getSectionTopOrFinalTop( |
| 2544 | lowPrioritySection, mAnimateNextSectionBoundsChange); |
| 2545 | gapBottom = Math.max(top, Math.min(gapBottom, bottom)); |
| 2546 | |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2547 | highPrioritySection.getBounds().set(left, top, right, gapTop); |
| 2548 | lowPrioritySection.getBounds().set(left, gapBottom, right, bottom); |
| 2549 | } else if (lastChildAboveGap != null) { |
| 2550 | highPrioritySection.getBounds().set(left, top, right, bottom); |
| 2551 | lowPrioritySection.getBounds().set(left, bottom, right, bottom); |
| 2552 | } else { |
| 2553 | highPrioritySection.getBounds().set(left, top, right, top); |
| 2554 | lowPrioritySection.getBounds().set(left, top, right, bottom); |
| 2555 | } |
| 2556 | } else { |
| 2557 | highPrioritySection.getBounds().set(left, top, right, bottom); |
| 2558 | lowPrioritySection.getBounds().set(left, bottom, right, bottom); |
| 2559 | } |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 2560 | } |
| 2561 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2562 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 2563 | private ActivatableNotificationView getFirstPinnedHeadsUp() { |
| 2564 | int childCount = getChildCount(); |
| 2565 | for (int i = 0; i < childCount; i++) { |
| 2566 | View child = getChildAt(i); |
| 2567 | if (child.getVisibility() != View.GONE |
| 2568 | && child instanceof ExpandableNotificationRow) { |
| 2569 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 2570 | if (row.isPinned()) { |
| 2571 | return row; |
| 2572 | } |
| 2573 | } |
| 2574 | } |
| 2575 | return null; |
| 2576 | } |
| 2577 | |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2578 | private NotificationSection getFirstVisibleSection() { |
| 2579 | for (NotificationSection section : mSections) { |
| 2580 | if (section.getFirstVisibleChild() != null) { |
| 2581 | return section; |
| 2582 | } |
| 2583 | } |
| 2584 | return null; |
| 2585 | } |
| 2586 | |
| 2587 | private NotificationSection getLastVisibleSection() { |
| 2588 | for (int i = mSections.length - 1; i >= 0; i--) { |
| 2589 | NotificationSection section = mSections[i]; |
| 2590 | if (section.getLastVisibleChild() != null) { |
| 2591 | return section; |
| 2592 | } |
| 2593 | } |
| 2594 | return null; |
| 2595 | } |
| 2596 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2597 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 2598 | private ActivatableNotificationView getLastChildWithBackground() { |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 2599 | int childCount = getChildCount(); |
| 2600 | for (int i = childCount - 1; i >= 0; i--) { |
| 2601 | View child = getChildAt(i); |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 2602 | if (child.getVisibility() != View.GONE && child instanceof ActivatableNotificationView |
| 2603 | && child != mShelf) { |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 2604 | return (ActivatableNotificationView) child; |
| 2605 | } |
| 2606 | } |
| 2607 | return null; |
| 2608 | } |
| 2609 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2610 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 2611 | private ActivatableNotificationView getFirstChildWithBackground() { |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 2612 | int childCount = getChildCount(); |
| 2613 | for (int i = 0; i < childCount; i++) { |
| 2614 | View child = getChildAt(i); |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 2615 | if (child.getVisibility() != View.GONE && child instanceof ActivatableNotificationView |
| 2616 | && child != mShelf) { |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 2617 | return (ActivatableNotificationView) child; |
| 2618 | } |
| 2619 | } |
| 2620 | return null; |
| 2621 | } |
| 2622 | |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2623 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
| 2624 | @Nullable |
| 2625 | private ActivatableNotificationView getLastHighPriorityChild() { |
| 2626 | ActivatableNotificationView lastChildBeforeGap = null; |
| 2627 | int childCount = getChildCount(); |
| 2628 | for (int i = 0; i < childCount; i++) { |
| 2629 | View child = getChildAt(i); |
| 2630 | if (child.getVisibility() != View.GONE && child instanceof ExpandableNotificationRow) { |
| 2631 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
Gus Prevas | caed15c | 2019-01-18 14:19:51 -0500 | [diff] [blame] | 2632 | if (!row.getEntry().isHighPriority()) { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2633 | break; |
| 2634 | } else { |
| 2635 | lastChildBeforeGap = row; |
| 2636 | } |
| 2637 | } |
| 2638 | } |
| 2639 | return lastChildBeforeGap; |
| 2640 | } |
| 2641 | |
| 2642 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
| 2643 | @Nullable |
| 2644 | private ActivatableNotificationView getFirstLowPriorityChild() { |
| 2645 | int childCount = getChildCount(); |
| 2646 | for (int i = 0; i < childCount; i++) { |
| 2647 | View child = getChildAt(i); |
| 2648 | if (child.getVisibility() != View.GONE && child instanceof ExpandableNotificationRow) { |
| 2649 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
Gus Prevas | caed15c | 2019-01-18 14:19:51 -0500 | [diff] [blame] | 2650 | if (!row.getEntry().isHighPriority()) { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2651 | return row; |
| 2652 | } |
| 2653 | } |
| 2654 | } |
| 2655 | return null; |
| 2656 | } |
| 2657 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2658 | /** |
| 2659 | * Fling the scroll view |
| 2660 | * |
| 2661 | * @param velocityY The initial velocity in the Y direction. Positive |
| 2662 | * numbers mean that the finger/cursor is moving down the screen, |
| 2663 | * which means we want to scroll towards the top. |
| 2664 | */ |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 2665 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Muyuan Li | 26e30ae | 2016-04-11 17:31:42 -0700 | [diff] [blame] | 2666 | protected void fling(int velocityY) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2667 | if (getChildCount() > 0) { |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 2668 | float topAmount = getCurrentOverScrollAmount(true); |
| 2669 | float bottomAmount = getCurrentOverScrollAmount(false); |
| 2670 | if (velocityY < 0 && topAmount > 0) { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 2671 | if (ANCHOR_SCROLLING) { |
| 2672 | mScrollAnchorViewY += topAmount; |
| 2673 | } else { |
| 2674 | setOwnScrollY(mOwnScrollY - (int) topAmount); |
| 2675 | } |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 2676 | mDontReportNextOverScroll = true; |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 2677 | setOverScrollAmount(0, true, false); |
Selim Cinek | fed1ab6 | 2014-06-17 14:10:33 -0700 | [diff] [blame] | 2678 | mMaxOverScroll = Math.abs(velocityY) / 1000f * getRubberBandFactor(true /* onTop */) |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 2679 | * mOverflingDistance + topAmount; |
| 2680 | } else if (velocityY > 0 && bottomAmount > 0) { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 2681 | if (ANCHOR_SCROLLING) { |
| 2682 | mScrollAnchorViewY -= bottomAmount; |
| 2683 | } else { |
| 2684 | setOwnScrollY((int) (mOwnScrollY + bottomAmount)); |
| 2685 | } |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 2686 | setOverScrollAmount(0, false, false); |
Selim Cinek | fed1ab6 | 2014-06-17 14:10:33 -0700 | [diff] [blame] | 2687 | mMaxOverScroll = Math.abs(velocityY) / 1000f |
| 2688 | * getRubberBandFactor(false /* onTop */) * mOverflingDistance |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 2689 | + bottomAmount; |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 2690 | } else { |
| 2691 | // it will be set once we reach the boundary |
| 2692 | mMaxOverScroll = 0.0f; |
| 2693 | } |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 2694 | if (ANCHOR_SCROLLING) { |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 2695 | flingScroller(velocityY); |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 2696 | } else { |
| 2697 | int scrollRange = getScrollRange(); |
| 2698 | int minScrollY = Math.max(0, scrollRange); |
| 2699 | if (mExpandedInThisMotion) { |
| 2700 | minScrollY = Math.min(minScrollY, mMaxScrollAfterExpand); |
| 2701 | } |
| 2702 | mScroller.fling(mScrollX, mOwnScrollY, 1, velocityY, 0, 0, 0, minScrollY, 0, |
| 2703 | mExpandedInThisMotion && mOwnScrollY >= 0 ? 0 : Integer.MAX_VALUE / 2); |
Selim Cinek | 94ab18c | 2016-02-25 12:35:51 -0800 | [diff] [blame] | 2704 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2705 | |
Selim Cinek | 9212de8 | 2017-02-06 16:04:28 -0800 | [diff] [blame] | 2706 | animateScroll(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2707 | } |
| 2708 | } |
| 2709 | |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 2710 | /** |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 2711 | * Flings the overscroller with the given velocity (anchor-based scrolling). |
| 2712 | * |
| 2713 | * Because anchor-based scrolling can't track the current scroll position, the overscroller is |
| 2714 | * always started at startY = 0, and we interpret the positions it computes as relative to the |
| 2715 | * start of the scroll. |
| 2716 | */ |
| 2717 | private void flingScroller(int velocityY) { |
| 2718 | assert ANCHOR_SCROLLING; |
| 2719 | mIsScrollerBoundSet = false; |
| 2720 | maybeFlingScroller(velocityY, true /* always fling */); |
| 2721 | } |
| 2722 | |
| 2723 | private void maybeFlingScroller(int velocityY, boolean alwaysFling) { |
| 2724 | assert ANCHOR_SCROLLING; |
| 2725 | // Attempt to determine the maximum amount to scroll before we reach the end. |
| 2726 | // If the first view is not materialized (for an upwards scroll) or the last view is either |
| 2727 | // not materialized or is pinned to the shade (for a downwards scroll), we don't know this |
| 2728 | // amount, so we do an unbounded fling and rely on {@link #maybeReflingScroller()} to update |
| 2729 | // the scroller once we approach the start/end of the list. |
| 2730 | int minY = Integer.MIN_VALUE; |
| 2731 | int maxY = Integer.MAX_VALUE; |
| 2732 | if (velocityY < 0) { |
| 2733 | minY = getMaxNegativeScrollAmount(); |
| 2734 | if (minY > Integer.MIN_VALUE) { |
| 2735 | mIsScrollerBoundSet = true; |
| 2736 | } |
| 2737 | } else { |
| 2738 | maxY = getMaxPositiveScrollAmount(); |
| 2739 | if (maxY < Integer.MAX_VALUE) { |
| 2740 | mIsScrollerBoundSet = true; |
| 2741 | } |
| 2742 | } |
| 2743 | if (mIsScrollerBoundSet || alwaysFling) { |
| 2744 | mLastScrollerY = 0; |
| 2745 | // x velocity is set to 1 to avoid overscroller bug |
| 2746 | mScroller.fling(0, 0, 1, velocityY, 0, 0, minY, maxY, 0, |
| 2747 | mExpandedInThisMotion && !isScrolledToTop() ? 0 : Integer.MAX_VALUE / 2); |
| 2748 | } |
| 2749 | } |
| 2750 | |
| 2751 | /** |
| 2752 | * Returns the maximum number of pixels we can scroll in the positive direction (downwards) |
| 2753 | * before reaching the bottom of the list (discounting overscroll). |
| 2754 | * |
| 2755 | * If the return value is negative then we have overscrolled; this is a transient state which |
| 2756 | * should immediately be handled by adjusting the anchor position and adding the extra space to |
| 2757 | * the bottom overscroll amount. |
| 2758 | * |
| 2759 | * If we don't know how many pixels we have left to scroll (because the last row has not been |
| 2760 | * materialized, or it's in the shelf so it doesn't have its "natural" position), we return |
| 2761 | * {@link Integer#MAX_VALUE}. |
| 2762 | */ |
| 2763 | private int getMaxPositiveScrollAmount() { |
| 2764 | assert ANCHOR_SCROLLING; |
| 2765 | // TODO: once we're recycling we need to check the adapter position of the last child. |
| 2766 | ExpandableNotificationRow lastRow = getLastRowNotGone(); |
| 2767 | if (mScrollAnchorView != null && lastRow != null && !lastRow.isInShelf()) { |
| 2768 | // distance from bottom of last child to bottom of notifications area is: |
| 2769 | // distance from bottom of last child |
| 2770 | return (int) (lastRow.getTranslationY() + lastRow.getActualHeight() |
| 2771 | // to top of anchor view |
| 2772 | - mScrollAnchorView.getTranslationY() |
| 2773 | // plus distance from anchor view to top of notifications area |
| 2774 | + mScrollAnchorViewY |
| 2775 | // minus height of notifications area. |
| 2776 | - (mMaxLayoutHeight - getIntrinsicPadding() - mFooterView.getActualHeight())); |
| 2777 | } else { |
| 2778 | return Integer.MAX_VALUE; |
| 2779 | } |
| 2780 | } |
| 2781 | |
| 2782 | /** |
| 2783 | * Returns the maximum number of pixels (as a negative number) we can scroll in the negative |
| 2784 | * direction (upwards) before reaching the top of the list (discounting overscroll). |
| 2785 | * |
| 2786 | * If the return value is positive then we have overscrolled; this is a transient state which |
| 2787 | * should immediately be handled by adjusting the anchor position and adding the extra space to |
| 2788 | * the top overscroll amount. |
| 2789 | * |
| 2790 | * If we don't know how many pixels we have left to scroll (because the first row has not been |
| 2791 | * materialized), we return {@link Integer#MIN_VALUE}. |
| 2792 | */ |
| 2793 | private int getMaxNegativeScrollAmount() { |
| 2794 | assert ANCHOR_SCROLLING; |
| 2795 | // TODO: once we're recycling we need to check the adapter position of the first child. |
| 2796 | ExpandableView firstChild = getFirstChildNotGone(); |
| 2797 | if (mScrollAnchorView != null && firstChild != null) { |
| 2798 | // distance from top of first child to top of notifications area is: |
| 2799 | // distance from top of anchor view |
| 2800 | return (int) -(mScrollAnchorView.getTranslationY() |
| 2801 | // to top of first child |
| 2802 | - firstChild.getTranslationY() |
| 2803 | // minus distance from top of anchor view to top of notifications area. |
| 2804 | - mScrollAnchorViewY); |
| 2805 | } else { |
| 2806 | return Integer.MIN_VALUE; |
| 2807 | } |
| 2808 | } |
| 2809 | |
| 2810 | /** |
| 2811 | * During a fling, if we were unable to set the bounds of the fling due to the top/bottom view |
| 2812 | * not being materialized or being pinned to the shelf, we need to check on every frame if we're |
| 2813 | * able to set the bounds. If we are, we fling the scroller again with the newly computed |
| 2814 | * bounds. |
| 2815 | */ |
| 2816 | private void maybeReflingScroller() { |
| 2817 | if (!mIsScrollerBoundSet) { |
| 2818 | // Because mScroller is a flywheel scroller, we fling with the minimum possible |
| 2819 | // velocity to establish direction, so as not to perceptibly affect the velocity. |
| 2820 | maybeFlingScroller((int) Math.signum(mScroller.getCurrVelocity()), |
| 2821 | false /* alwaysFling */); |
| 2822 | } |
| 2823 | } |
| 2824 | |
| 2825 | /** |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 2826 | * @return Whether a fling performed on the top overscroll edge lead to the expanded |
| 2827 | * overScroll view (i.e QS). |
| 2828 | */ |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 2829 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 2830 | private boolean shouldOverScrollFling(int initialVelocity) { |
| 2831 | float topOverScroll = getCurrentOverScrollAmount(true); |
| 2832 | return mScrolledToTopOnFirstDown |
| 2833 | && !mExpandedInThisMotion |
| 2834 | && topOverScroll > mMinTopOverScrollToEscape |
| 2835 | && initialVelocity > 0; |
| 2836 | } |
| 2837 | |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 2838 | /** |
| 2839 | * Updates the top padding of the notifications, taking {@link #getIntrinsicPadding()} into |
| 2840 | * account. |
| 2841 | * |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 2842 | * @param qsHeight the top padding imposed by the quick settings panel |
| 2843 | * @param animate whether to animate the change |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 2844 | * @param ignoreIntrinsicPadding if true, {@link #getIntrinsicPadding()} is ignored and |
| 2845 | * {@code qsHeight} is the final top padding |
| 2846 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2847 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Jason Monk | 16ac377 | 2016-02-10 15:39:21 -0500 | [diff] [blame] | 2848 | public void updateTopPadding(float qsHeight, boolean animate, |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 2849 | boolean ignoreIntrinsicPadding) { |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 2850 | int topPadding = (int) qsHeight; |
Selim Cinek | d1ad9ab | 2016-03-01 17:52:20 -0800 | [diff] [blame] | 2851 | int minStackHeight = getLayoutMinHeight(); |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 2852 | if (topPadding + minStackHeight > getHeight()) { |
| 2853 | mTopPaddingOverflow = topPadding + minStackHeight - getHeight(); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 2854 | } else { |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 2855 | mTopPaddingOverflow = 0; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 2856 | } |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 2857 | setTopPadding(ignoreIntrinsicPadding ? topPadding : clampPadding(topPadding), |
Jorim Jaggi | 06a0c3a | 2014-10-29 17:17:21 +0100 | [diff] [blame] | 2858 | animate); |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 2859 | setExpandedHeight(mExpandedHeight); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 2860 | } |
| 2861 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2862 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 2863 | public void setMaxTopPadding(int maxTopPadding) { |
| 2864 | mMaxTopPadding = maxTopPadding; |
| 2865 | } |
| 2866 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2867 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | d1ad9ab | 2016-03-01 17:52:20 -0800 | [diff] [blame] | 2868 | public int getLayoutMinHeight() { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 2869 | if (isHeadsUpTransition()) { |
| 2870 | return getTopHeadsUpPinnedHeight(); |
| 2871 | } |
Anthony Chen | 9e05d46 | 2017-04-07 10:10:21 -0700 | [diff] [blame] | 2872 | return mShelf.getVisibility() == GONE ? 0 : mShelf.getIntrinsicHeight(); |
Selim Cinek | 94c2d82 | 2016-07-13 18:50:04 -0700 | [diff] [blame] | 2873 | } |
| 2874 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2875 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 2876 | public float getTopPaddingOverflow() { |
| 2877 | return mTopPaddingOverflow; |
| 2878 | } |
| 2879 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2880 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 2881 | public int getPeekHeight() { |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 2882 | final ExpandableView firstChild = getFirstChildNotGone(); |
Selim Cinek | 567e845 | 2016-03-24 10:54:56 -0700 | [diff] [blame] | 2883 | final int firstChildMinHeight = firstChild != null ? firstChild.getCollapsedHeight() |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 2884 | : mCollapsedSize; |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 2885 | int shelfHeight = 0; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 2886 | if (getLastVisibleSection() != null && mShelf.getVisibility() != GONE) { |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 2887 | shelfHeight = mShelf.getIntrinsicHeight(); |
| 2888 | } |
| 2889 | return mIntrinsicPadding + firstChildMinHeight + shelfHeight; |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 2890 | } |
| 2891 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2892 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 2893 | private int clampPadding(int desiredPadding) { |
| 2894 | return Math.max(desiredPadding, mIntrinsicPadding); |
| 2895 | } |
| 2896 | |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 2897 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | fed1ab6 | 2014-06-17 14:10:33 -0700 | [diff] [blame] | 2898 | private float getRubberBandFactor(boolean onTop) { |
| 2899 | if (!onTop) { |
| 2900 | return RUBBER_BAND_FACTOR_NORMAL; |
| 2901 | } |
Jorim Jaggi | 47c85a3 | 2014-06-05 17:25:40 +0200 | [diff] [blame] | 2902 | if (mExpandedInThisMotion) { |
| 2903 | return RUBBER_BAND_FACTOR_AFTER_EXPAND; |
Jorim Jaggi | e4b840d | 2015-06-30 16:19:17 -0700 | [diff] [blame] | 2904 | } else if (mIsExpansionChanging || mPanelTracking) { |
Jorim Jaggi | 47c85a3 | 2014-06-05 17:25:40 +0200 | [diff] [blame] | 2905 | return RUBBER_BAND_FACTOR_ON_PANEL_EXPAND; |
| 2906 | } else if (mScrolledToTopOnFirstDown) { |
| 2907 | return 1.0f; |
| 2908 | } |
| 2909 | return RUBBER_BAND_FACTOR_NORMAL; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 2910 | } |
| 2911 | |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 2912 | /** |
| 2913 | * Accompanying function for {@link #getRubberBandFactor}: Returns true if the overscroll is |
| 2914 | * rubberbanded, false if it is technically an overscroll but rather a motion to expand the |
| 2915 | * overscroll view (e.g. expand QS). |
| 2916 | */ |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 2917 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 2918 | private boolean isRubberbanded(boolean onTop) { |
Jorim Jaggi | e4b840d | 2015-06-30 16:19:17 -0700 | [diff] [blame] | 2919 | return !onTop || mExpandedInThisMotion || mIsExpansionChanging || mPanelTracking |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 2920 | || !mScrolledToTopOnFirstDown; |
| 2921 | } |
| 2922 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2923 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 2924 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2925 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 2926 | public void setChildTransferInProgress(boolean childTransferInProgress) { |
| 2927 | mChildTransferInProgress = childTransferInProgress; |
| 2928 | } |
| 2929 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2930 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Christoph Studer | 068f592 | 2014-04-08 17:43:07 -0400 | [diff] [blame] | 2931 | @Override |
Adam Powell | 6690d01 | 2015-06-17 16:41:56 -0700 | [diff] [blame] | 2932 | public void onViewRemoved(View child) { |
Christoph Studer | 068f592 | 2014-04-08 17:43:07 -0400 | [diff] [blame] | 2933 | super.onViewRemoved(child); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2934 | // we only call our internal methods if this is actually a removal and not just a |
| 2935 | // notification which becomes a child notification |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 2936 | if (!mChildTransferInProgress) { |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 2937 | onViewRemovedInternal((ExpandableView) child, this); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2938 | } |
| 2939 | } |
| 2940 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2941 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 2942 | @Override |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 2943 | public void cleanUpViewStateForEntry(NotificationEntry entry) { |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 2944 | View child = entry.getRow(); |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 2945 | if (child == mSwipeHelper.getTranslatingParentView()) { |
| 2946 | mSwipeHelper.clearTranslatingParentView(); |
Mady Mellor | 4c97b0a | 2017-02-15 11:16:13 -0800 | [diff] [blame] | 2947 | } |
Mady Mellor | 4c97b0a | 2017-02-15 11:16:13 -0800 | [diff] [blame] | 2948 | } |
| 2949 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2950 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 2951 | private void onViewRemovedInternal(ExpandableView child, ViewGroup container) { |
Selim Cinek | 159ffdb | 2014-06-04 22:24:18 +0200 | [diff] [blame] | 2952 | if (mChangePositionInProgress) { |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 2953 | // This is only a position change, don't do anything special |
| 2954 | return; |
| 2955 | } |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 2956 | child.setOnHeightChangedListener(null); |
| 2957 | updateScrollStateForRemovedChild(child); |
Selim Cinek | 2aab2fb | 2015-04-15 18:47:01 -0700 | [diff] [blame] | 2958 | boolean animationGenerated = generateRemoveAnimation(child); |
Selim Cinek | d139564 | 2016-04-28 12:22:42 -0700 | [diff] [blame] | 2959 | if (animationGenerated) { |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 2960 | if (!mSwipedOutViews.contains(child) |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 2961 | || Math.abs(child.getTranslation()) != child.getWidth()) { |
Selim Cinek | a570318 | 2016-05-11 21:23:16 -0400 | [diff] [blame] | 2962 | container.addTransientView(child, 0); |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 2963 | child.setTransientContainer(container); |
Selim Cinek | d139564 | 2016-04-28 12:22:42 -0700 | [diff] [blame] | 2964 | } |
| 2965 | } else { |
| 2966 | mSwipedOutViews.remove(child); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 2967 | } |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 2968 | updateAnimationState(false, child); |
Selim Cinek | c0f4c01 | 2014-08-25 15:45:33 +0200 | [diff] [blame] | 2969 | |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 2970 | focusNextViewIfFocused(child); |
| 2971 | } |
| 2972 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2973 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 2974 | private void focusNextViewIfFocused(View view) { |
| 2975 | if (view instanceof ExpandableNotificationRow) { |
| 2976 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
| 2977 | if (row.shouldRefocusOnDismiss()) { |
| 2978 | View nextView = row.getChildAfterViewWhenDismissed(); |
| 2979 | if (nextView == null) { |
| 2980 | View groupParentWhenDismissed = row.getGroupParentWhenDismissed(); |
| 2981 | nextView = getFirstChildBelowTranlsationY(groupParentWhenDismissed != null |
| 2982 | ? groupParentWhenDismissed.getTranslationY() |
Selim Cinek | ef8c225 | 2017-02-10 14:52:18 -0800 | [diff] [blame] | 2983 | : view.getTranslationY(), true /* ignoreChildren */); |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 2984 | } |
| 2985 | if (nextView != null) { |
| 2986 | nextView.requestAccessibilityFocus(); |
| 2987 | } |
| 2988 | } |
| 2989 | } |
| 2990 | |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 2991 | } |
| 2992 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 2993 | @ShadeViewRefactor(RefactorComponent.ADAPTER) |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2994 | private boolean isChildInGroup(View child) { |
| 2995 | return child instanceof ExpandableNotificationRow |
| 2996 | && mGroupManager.isChildInGroupWithSummary( |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 2997 | ((ExpandableNotificationRow) child).getStatusBarNotification()); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2998 | } |
| 2999 | |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 3000 | /** |
| 3001 | * Generate a remove animation for a child view. |
| 3002 | * |
| 3003 | * @param child The view to generate the remove animation for. |
| 3004 | * @return Whether an animation was generated. |
| 3005 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3006 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3007 | private boolean generateRemoveAnimation(ExpandableView child) { |
Selim Cinek | e0890e5 | 2015-06-17 11:17:08 -0700 | [diff] [blame] | 3008 | if (removeRemovedChildFromHeadsUpChangeAnimations(child)) { |
Selim Cinek | 233241f | 2015-06-01 06:11:19 -0700 | [diff] [blame] | 3009 | mAddedHeadsUpChildren.remove(child); |
| 3010 | return false; |
| 3011 | } |
Selim Cinek | 0fccc72 | 2015-07-29 17:04:36 -0700 | [diff] [blame] | 3012 | if (isClickedHeadsUp(child)) { |
Selim Cinek | 9dd0d04 | 2018-05-14 18:12:42 -0700 | [diff] [blame] | 3013 | // An animation is already running, add it transiently |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3014 | mClearTransientViewsWhenFinished.add(child); |
Selim Cinek | 0fccc72 | 2015-07-29 17:04:36 -0700 | [diff] [blame] | 3015 | return true; |
| 3016 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 3017 | if (mIsExpanded && mAnimationsEnabled && !isChildInInvisibleGroup(child)) { |
Selim Cinek | 233241f | 2015-06-01 06:11:19 -0700 | [diff] [blame] | 3018 | if (!mChildrenToAddAnimated.contains(child)) { |
Selim Cinek | f4c1996 | 2014-05-01 21:55:31 +0200 | [diff] [blame] | 3019 | // Generate Animations |
| 3020 | mChildrenToRemoveAnimated.add(child); |
Jorim Jaggi | 0dd6881 | 2014-05-01 19:17:37 +0200 | [diff] [blame] | 3021 | mNeedsAnimation = true; |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 3022 | return true; |
Selim Cinek | f4c1996 | 2014-05-01 21:55:31 +0200 | [diff] [blame] | 3023 | } else { |
| 3024 | mChildrenToAddAnimated.remove(child); |
Jorim Jaggi | ff9c9c4 | 2014-08-01 05:36:22 +0200 | [diff] [blame] | 3025 | mFromMoreCardAdditions.remove(child); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 3026 | return false; |
Selim Cinek | f4c1996 | 2014-05-01 21:55:31 +0200 | [diff] [blame] | 3027 | } |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3028 | } |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 3029 | return false; |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3030 | } |
| 3031 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3032 | @ShadeViewRefactor(RefactorComponent.ADAPTER) |
Selim Cinek | 0fccc72 | 2015-07-29 17:04:36 -0700 | [diff] [blame] | 3033 | private boolean isClickedHeadsUp(View child) { |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 3034 | return HeadsUpUtil.isClickedHeadsUpNotification(child); |
Selim Cinek | 0fccc72 | 2015-07-29 17:04:36 -0700 | [diff] [blame] | 3035 | } |
| 3036 | |
Selim Cinek | e0890e5 | 2015-06-17 11:17:08 -0700 | [diff] [blame] | 3037 | /** |
| 3038 | * Remove a removed child view from the heads up animations if it was just added there |
| 3039 | * |
| 3040 | * @return whether any child was removed from the list to animate |
| 3041 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3042 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | e0890e5 | 2015-06-17 11:17:08 -0700 | [diff] [blame] | 3043 | private boolean removeRemovedChildFromHeadsUpChangeAnimations(View child) { |
| 3044 | boolean hasAddEvent = false; |
Selim Cinek | ffa6eb8 | 2015-05-21 12:11:12 -0700 | [diff] [blame] | 3045 | for (Pair<ExpandableNotificationRow, Boolean> eventPair : mHeadsUpChangeAnimations) { |
| 3046 | ExpandableNotificationRow row = eventPair.first; |
Selim Cinek | e0890e5 | 2015-06-17 11:17:08 -0700 | [diff] [blame] | 3047 | boolean isHeadsUp = eventPair.second; |
Selim Cinek | ffa6eb8 | 2015-05-21 12:11:12 -0700 | [diff] [blame] | 3048 | if (child == row) { |
Selim Cinek | e0890e5 | 2015-06-17 11:17:08 -0700 | [diff] [blame] | 3049 | mTmpList.add(eventPair); |
| 3050 | hasAddEvent |= isHeadsUp; |
Selim Cinek | ffa6eb8 | 2015-05-21 12:11:12 -0700 | [diff] [blame] | 3051 | } |
| 3052 | } |
Selim Cinek | e0890e5 | 2015-06-17 11:17:08 -0700 | [diff] [blame] | 3053 | if (hasAddEvent) { |
| 3054 | // This child was just added lets remove all events. |
| 3055 | mHeadsUpChangeAnimations.removeAll(mTmpList); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 3056 | ((ExpandableNotificationRow) child).setHeadsUpAnimatingAway(false); |
Selim Cinek | e0890e5 | 2015-06-17 11:17:08 -0700 | [diff] [blame] | 3057 | } |
| 3058 | mTmpList.clear(); |
| 3059 | return hasAddEvent; |
Selim Cinek | ffa6eb8 | 2015-05-21 12:11:12 -0700 | [diff] [blame] | 3060 | } |
| 3061 | |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3062 | /** |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 3063 | * @param child the child to query |
| 3064 | * @return whether a view is not a top level child but a child notification and that group is |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 3065 | * not expanded |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 3066 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3067 | @ShadeViewRefactor(RefactorComponent.ADAPTER) |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 3068 | private boolean isChildInInvisibleGroup(View child) { |
| 3069 | if (child instanceof ExpandableNotificationRow) { |
| 3070 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 3071 | NotificationEntry groupSummary = |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 3072 | mGroupManager.getGroupSummary(row.getStatusBarNotification()); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 3073 | if (groupSummary != null && groupSummary.getRow() != row) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 3074 | return row.getVisibility() == View.INVISIBLE; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 3075 | } |
| 3076 | } |
| 3077 | return false; |
| 3078 | } |
| 3079 | |
| 3080 | /** |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3081 | * Updates the scroll position when a child was removed |
| 3082 | * |
| 3083 | * @param removedChild the removed child |
| 3084 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3085 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 61633a8 | 2016-01-25 15:54:10 -0800 | [diff] [blame] | 3086 | private void updateScrollStateForRemovedChild(ExpandableView removedChild) { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 3087 | if (ANCHOR_SCROLLING) { |
| 3088 | if (removedChild == mScrollAnchorView) { |
| 3089 | ExpandableView firstChild = getFirstChildNotGone(); |
| 3090 | if (firstChild != null) { |
| 3091 | mScrollAnchorView = firstChild; |
| 3092 | } else { |
| 3093 | mScrollAnchorView = mShelf; |
| 3094 | } |
| 3095 | // Adjust anchor view Y by the distance between the old and new anchors |
| 3096 | // so that there's no visible change. |
| 3097 | mScrollAnchorViewY += |
| 3098 | mScrollAnchorView.getTranslationY() - removedChild.getTranslationY(); |
| 3099 | } |
| 3100 | updateScrollAnchor(); |
| 3101 | // TODO: once we're recycling this will need to check the adapter position of the child |
| 3102 | if (mScrollAnchorView == getFirstChildNotGone() && mScrollAnchorViewY > 0) { |
| 3103 | mScrollAnchorViewY = 0; |
| 3104 | } |
| 3105 | updateOnScrollChange(); |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 3106 | } else { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 3107 | int startingPosition = getPositionInLinearLayout(removedChild); |
| 3108 | float increasedPaddingAmount = removedChild.getIncreasedPaddingAmount(); |
| 3109 | int padding; |
| 3110 | if (increasedPaddingAmount >= 0) { |
| 3111 | padding = (int) NotificationUtils.interpolate( |
| 3112 | mPaddingBetweenElements, |
| 3113 | mIncreasedPaddingBetweenElements, |
| 3114 | increasedPaddingAmount); |
| 3115 | } else { |
| 3116 | padding = (int) NotificationUtils.interpolate( |
| 3117 | 0, |
| 3118 | mPaddingBetweenElements, |
| 3119 | 1.0f + increasedPaddingAmount); |
| 3120 | } |
| 3121 | int childHeight = getIntrinsicHeight(removedChild) + padding; |
| 3122 | int endPosition = startingPosition + childHeight; |
| 3123 | if (endPosition <= mOwnScrollY) { |
| 3124 | // This child is fully scrolled of the top, so we have to deduct its height from the |
| 3125 | // scrollPosition |
| 3126 | setOwnScrollY(mOwnScrollY - childHeight); |
| 3127 | } else if (startingPosition < mOwnScrollY) { |
| 3128 | // This child is currently being scrolled into, set the scroll position to the |
| 3129 | // start of this child |
| 3130 | setOwnScrollY(startingPosition); |
| 3131 | } |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3132 | } |
| 3133 | } |
| 3134 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3135 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | d7c4e00 | 2014-07-04 18:36:42 +0200 | [diff] [blame] | 3136 | private int getIntrinsicHeight(View view) { |
| 3137 | if (view instanceof ExpandableView) { |
| 3138 | ExpandableView expandableView = (ExpandableView) view; |
| 3139 | return expandableView.getIntrinsicHeight(); |
| 3140 | } |
| 3141 | return view.getHeight(); |
| 3142 | } |
| 3143 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3144 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 1f62495 | 2017-06-08 19:11:50 -0700 | [diff] [blame] | 3145 | public int getPositionInLinearLayout(View requestedView) { |
Adrian Roos | 4a57967 | 2016-05-24 16:54:37 -0700 | [diff] [blame] | 3146 | ExpandableNotificationRow childInGroup = null; |
| 3147 | ExpandableNotificationRow requestedRow = null; |
| 3148 | if (isChildInGroup(requestedView)) { |
| 3149 | // We're asking for a child in a group. Calculate the position of the parent first, |
| 3150 | // then within the parent. |
| 3151 | childInGroup = (ExpandableNotificationRow) requestedView; |
| 3152 | requestedView = requestedRow = childInGroup.getNotificationParent(); |
| 3153 | } |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3154 | int position = 0; |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 3155 | float previousPaddingRequest = mPaddingBetweenElements; |
| 3156 | float previousPaddingAmount = 0.0f; |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3157 | for (int i = 0; i < getChildCount(); i++) { |
Selim Cinek | 61633a8 | 2016-01-25 15:54:10 -0800 | [diff] [blame] | 3158 | ExpandableView child = (ExpandableView) getChildAt(i); |
| 3159 | boolean notGone = child.getVisibility() != View.GONE; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 3160 | if (notGone && !child.hasNoContentHeight()) { |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 3161 | float increasedPaddingAmount = child.getIncreasedPaddingAmount(); |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 3162 | float padding; |
| 3163 | if (increasedPaddingAmount >= 0.0f) { |
| 3164 | padding = (int) NotificationUtils.interpolate( |
| 3165 | previousPaddingRequest, |
| 3166 | mIncreasedPaddingBetweenElements, |
| 3167 | increasedPaddingAmount); |
| 3168 | previousPaddingRequest = (int) NotificationUtils.interpolate( |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 3169 | mPaddingBetweenElements, |
| 3170 | mIncreasedPaddingBetweenElements, |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 3171 | increasedPaddingAmount); |
| 3172 | } else { |
| 3173 | int ownPadding = (int) NotificationUtils.interpolate( |
| 3174 | 0, |
| 3175 | mPaddingBetweenElements, |
| 3176 | 1.0f + increasedPaddingAmount); |
| 3177 | if (previousPaddingAmount > 0.0f) { |
| 3178 | padding = (int) NotificationUtils.interpolate( |
| 3179 | ownPadding, |
| 3180 | mIncreasedPaddingBetweenElements, |
| 3181 | previousPaddingAmount); |
| 3182 | } else { |
| 3183 | padding = ownPadding; |
| 3184 | } |
| 3185 | previousPaddingRequest = ownPadding; |
Selim Cinek | 61633a8 | 2016-01-25 15:54:10 -0800 | [diff] [blame] | 3186 | } |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 3187 | if (position != 0) { |
| 3188 | position += padding; |
| 3189 | } |
| 3190 | previousPaddingAmount = increasedPaddingAmount; |
Selim Cinek | 61633a8 | 2016-01-25 15:54:10 -0800 | [diff] [blame] | 3191 | } |
Adrian Roos | 4a57967 | 2016-05-24 16:54:37 -0700 | [diff] [blame] | 3192 | if (child == requestedView) { |
| 3193 | if (requestedRow != null) { |
| 3194 | position += requestedRow.getPositionOfChild(childInGroup); |
| 3195 | } |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3196 | return position; |
| 3197 | } |
Selim Cinek | 61633a8 | 2016-01-25 15:54:10 -0800 | [diff] [blame] | 3198 | if (notGone) { |
Selim Cinek | abdc5a0 | 2014-09-02 13:46:00 +0200 | [diff] [blame] | 3199 | position += getIntrinsicHeight(child); |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3200 | } |
| 3201 | } |
| 3202 | return 0; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 3203 | } |
| 3204 | |
| 3205 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3206 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Adam Powell | 6690d01 | 2015-06-17 16:41:56 -0700 | [diff] [blame] | 3207 | public void onViewAdded(View child) { |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 3208 | super.onViewAdded(child); |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3209 | onViewAddedInternal((ExpandableView) child); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 3210 | } |
| 3211 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3212 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 3213 | private void updateFirstAndLastBackgroundViews() { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 3214 | NotificationSection firstSection = getFirstVisibleSection(); |
| 3215 | NotificationSection lastSection = getLastVisibleSection(); |
Gus Prevas | da13cfa | 2018-11-20 14:58:48 -0500 | [diff] [blame] | 3216 | ActivatableNotificationView previousFirstChild = |
| 3217 | firstSection == null ? null : firstSection.getFirstVisibleChild(); |
| 3218 | ActivatableNotificationView previousLastChild = |
| 3219 | lastSection == null ? null : lastSection.getLastVisibleChild(); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 3220 | |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 3221 | ActivatableNotificationView firstChild = getFirstChildWithBackground(); |
| 3222 | ActivatableNotificationView lastChild = getLastChildWithBackground(); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 3223 | boolean sectionViewsChanged = updateFirstAndLastViewsInSectionsByPriority( |
| 3224 | mSections[0], mSections[1], firstChild, lastChild); |
| 3225 | |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 3226 | if (mAnimationsEnabled && mIsExpanded) { |
Gus Prevas | da13cfa | 2018-11-20 14:58:48 -0500 | [diff] [blame] | 3227 | mAnimateNextBackgroundTop = firstChild != previousFirstChild; |
| 3228 | mAnimateNextBackgroundBottom = lastChild != previousLastChild; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 3229 | mAnimateNextSectionBoundsChange = sectionViewsChanged; |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 3230 | } else { |
| 3231 | mAnimateNextBackgroundTop = false; |
| 3232 | mAnimateNextBackgroundBottom = false; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 3233 | mAnimateNextSectionBoundsChange = false; |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 3234 | } |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 3235 | mAmbientState.setLastVisibleBackgroundChild(lastChild); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 3236 | mRoundnessManager.updateRoundedChildren(mSections); |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 3237 | invalidate(); |
Selim Cinek | 614576e | 2016-01-20 10:54:09 -0800 | [diff] [blame] | 3238 | } |
| 3239 | |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 3240 | /** @return {@code true} if the last view in the top section changed (so we need to animate). */ |
| 3241 | private boolean updateFirstAndLastViewsInSectionsByPriority( |
| 3242 | final NotificationSection highPrioritySection, |
| 3243 | final NotificationSection lowPrioritySection, |
| 3244 | ActivatableNotificationView firstChild, |
| 3245 | ActivatableNotificationView lastChild) { |
| 3246 | if (NotificationUtils.useNewInterruptionModel(mContext)) { |
| 3247 | ActivatableNotificationView previousLastHighPriorityChild = |
| 3248 | highPrioritySection.getLastVisibleChild(); |
| 3249 | ActivatableNotificationView previousFirstLowPriorityChild = |
| 3250 | lowPrioritySection.getFirstVisibleChild(); |
| 3251 | ActivatableNotificationView lastHighPriorityChild = getLastHighPriorityChild(); |
| 3252 | ActivatableNotificationView firstLowPriorityChild = getFirstLowPriorityChild(); |
| 3253 | if (lastHighPriorityChild != null && firstLowPriorityChild != null) { |
| 3254 | highPrioritySection.setFirstVisibleChild(firstChild); |
| 3255 | highPrioritySection.setLastVisibleChild(lastHighPriorityChild); |
| 3256 | lowPrioritySection.setFirstVisibleChild(firstLowPriorityChild); |
| 3257 | lowPrioritySection.setLastVisibleChild(lastChild); |
| 3258 | } else if (lastHighPriorityChild != null) { |
| 3259 | highPrioritySection.setFirstVisibleChild(firstChild); |
| 3260 | highPrioritySection.setLastVisibleChild(lastChild); |
| 3261 | lowPrioritySection.setFirstVisibleChild(null); |
| 3262 | lowPrioritySection.setLastVisibleChild(null); |
| 3263 | } else { |
| 3264 | highPrioritySection.setFirstVisibleChild(null); |
| 3265 | highPrioritySection.setLastVisibleChild(null); |
| 3266 | lowPrioritySection.setFirstVisibleChild(firstChild); |
| 3267 | lowPrioritySection.setLastVisibleChild(lastChild); |
| 3268 | } |
| 3269 | return lastHighPriorityChild != previousLastHighPriorityChild |
| 3270 | || firstLowPriorityChild != previousFirstLowPriorityChild; |
| 3271 | } else { |
| 3272 | highPrioritySection.setFirstVisibleChild(firstChild); |
| 3273 | highPrioritySection.setLastVisibleChild(lastChild); |
| 3274 | return false; |
| 3275 | } |
| 3276 | } |
| 3277 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3278 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3279 | private void onViewAddedInternal(ExpandableView child) { |
Selim Cinek | d06c41c | 2015-07-06 14:51:36 -0700 | [diff] [blame] | 3280 | updateHideSensitiveForChild(child); |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3281 | child.setOnHeightChangedListener(this); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 3282 | generateAddAnimation(child, false /* fromMoreCard */); |
Selim Cinek | 51ae05d | 2014-09-09 15:51:38 +0200 | [diff] [blame] | 3283 | updateAnimationState(child); |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 3284 | updateChronometerForChild(child); |
Gus Prevas | a18dc57 | 2019-01-14 16:11:22 -0500 | [diff] [blame] | 3285 | if (child instanceof ExpandableNotificationRow) { |
| 3286 | ((ExpandableNotificationRow) child).setDismissRtl(mDismissRtl); |
| 3287 | } |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 3288 | if (ANCHOR_SCROLLING) { |
| 3289 | // TODO: once we're recycling this will need to check the adapter position of the child |
| 3290 | if (child == getFirstChildNotGone() && (isScrolledToTop() || !mIsExpanded)) { |
| 3291 | // New child was added at the top while we're scrolled to the top; |
| 3292 | // make it the new anchor view so that we stay at the top. |
| 3293 | mScrollAnchorView = child; |
| 3294 | } |
| 3295 | } |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3296 | } |
| 3297 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3298 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3299 | private void updateHideSensitiveForChild(ExpandableView child) { |
| 3300 | child.setHideSensitiveForIntrinsicHeight(mAmbientState.isHideSensitive()); |
Selim Cinek | d06c41c | 2015-07-06 14:51:36 -0700 | [diff] [blame] | 3301 | } |
| 3302 | |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 3303 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3304 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3305 | public void notifyGroupChildRemoved(ExpandableView row, ViewGroup childrenContainer) { |
Selim Cinek | d139564 | 2016-04-28 12:22:42 -0700 | [diff] [blame] | 3306 | onViewRemovedInternal(row, childrenContainer); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 3307 | } |
| 3308 | |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 3309 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3310 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3311 | public void notifyGroupChildAdded(ExpandableView row) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 3312 | onViewAddedInternal(row); |
| 3313 | } |
| 3314 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3315 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 3316 | public void setAnimationsEnabled(boolean animationsEnabled) { |
| 3317 | mAnimationsEnabled = animationsEnabled; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 3318 | updateNotificationAnimationStates(); |
Rohan Shah | 8ee5365 | 2018-04-05 11:13:50 -0700 | [diff] [blame] | 3319 | if (!animationsEnabled) { |
| 3320 | mSwipedOutViews.clear(); |
| 3321 | mChildrenToRemoveAnimated.clear(); |
| 3322 | clearTemporaryViewsInGroup(this); |
| 3323 | } |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 3324 | } |
| 3325 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3326 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 3327 | private void updateNotificationAnimationStates() { |
Selim Cinek | be2c443 | 2017-05-30 12:11:09 -0700 | [diff] [blame] | 3328 | boolean running = mAnimationsEnabled || hasPulsingNotifications(); |
Selim Cinek | 09bd29d | 2017-02-03 15:30:28 -0800 | [diff] [blame] | 3329 | mShelf.setAnimationsEnabled(running); |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 3330 | int childCount = getChildCount(); |
| 3331 | for (int i = 0; i < childCount; i++) { |
| 3332 | View child = getChildAt(i); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 3333 | running &= mIsExpanded || isPinnedHeadsUp(child); |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 3334 | updateAnimationState(running, child); |
| 3335 | } |
| 3336 | } |
| 3337 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3338 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 51ae05d | 2014-09-09 15:51:38 +0200 | [diff] [blame] | 3339 | private void updateAnimationState(View child) { |
Selim Cinek | be2c443 | 2017-05-30 12:11:09 -0700 | [diff] [blame] | 3340 | updateAnimationState((mAnimationsEnabled || hasPulsingNotifications()) |
Selim Cinek | cd5b22f | 2016-03-08 16:15:41 -0800 | [diff] [blame] | 3341 | && (mIsExpanded || isPinnedHeadsUp(child)), child); |
Selim Cinek | 51ae05d | 2014-09-09 15:51:38 +0200 | [diff] [blame] | 3342 | } |
| 3343 | |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 3344 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3345 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 3346 | public void setExpandingNotification(ExpandableNotificationRow row) { |
| 3347 | mAmbientState.setExpandingNotification(row); |
| 3348 | requestChildrenUpdate(); |
| 3349 | } |
| 3350 | |
| 3351 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3352 | @ShadeViewRefactor(RefactorComponent.ADAPTER) |
Selim Cinek | 8875de1 | 2018-03-22 10:14:32 -0700 | [diff] [blame] | 3353 | public void bindRow(ExpandableNotificationRow row) { |
Selim Cinek | f0c79e1 | 2018-05-14 17:17:31 -0700 | [diff] [blame] | 3354 | row.setHeadsUpAnimatingAwayListener(animatingAway -> { |
| 3355 | mRoundnessManager.onHeadsupAnimatingAwayChanged(row, animatingAway); |
| 3356 | mHeadsUpAppearanceController.updateHeader(row.getEntry()); |
| 3357 | }); |
Selim Cinek | 8875de1 | 2018-03-22 10:14:32 -0700 | [diff] [blame] | 3358 | } |
| 3359 | |
| 3360 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3361 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 3362 | public void applyExpandAnimationParams(ExpandAnimationParameters params) { |
| 3363 | mAmbientState.setExpandAnimationTopChange(params == null ? 0 : params.getTopChange()); |
| 3364 | requestChildrenUpdate(); |
| 3365 | } |
Selim Cinek | 51ae05d | 2014-09-09 15:51:38 +0200 | [diff] [blame] | 3366 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3367 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 3368 | private void updateAnimationState(boolean running, View child) { |
| 3369 | if (child instanceof ExpandableNotificationRow) { |
| 3370 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 3371 | row.setIconAnimationRunning(running); |
| 3372 | } |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 3373 | } |
| 3374 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3375 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 3376 | public boolean isAddOrRemoveAnimationPending() { |
| 3377 | return mNeedsAnimation |
| 3378 | && (!mChildrenToAddAnimated.isEmpty() || !mChildrenToRemoveAnimated.isEmpty()); |
| 3379 | } |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 3380 | |
| 3381 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3382 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3383 | public void generateAddAnimation(ExpandableView child, boolean fromMoreCard) { |
Selim Cinek | 159ffdb | 2014-06-04 22:24:18 +0200 | [diff] [blame] | 3384 | if (mIsExpanded && mAnimationsEnabled && !mChangePositionInProgress) { |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3385 | // Generate Animations |
| 3386 | mChildrenToAddAnimated.add(child); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 3387 | if (fromMoreCard) { |
| 3388 | mFromMoreCardAdditions.add(child); |
| 3389 | } |
Jorim Jaggi | 0dd6881 | 2014-05-01 19:17:37 +0200 | [diff] [blame] | 3390 | mNeedsAnimation = true; |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3391 | } |
Selim Cinek | f306d9b | 2017-02-21 11:45:13 -0800 | [diff] [blame] | 3392 | if (isHeadsUp(child) && mAnimationsEnabled && !mChangePositionInProgress) { |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 3393 | mAddedHeadsUpChildren.add(child); |
| 3394 | mChildrenToAddAnimated.remove(child); |
| 3395 | } |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3396 | } |
| 3397 | |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 3398 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3399 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3400 | public void changeViewPosition(ExpandableView child, int newIndex) { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 3401 | int currentIndex = indexOfChild(child); |
Rohan Shah | 8ee5365 | 2018-04-05 11:13:50 -0700 | [diff] [blame] | 3402 | |
| 3403 | if (currentIndex == -1) { |
| 3404 | boolean isTransient = false; |
| 3405 | if (child instanceof ExpandableNotificationRow |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 3406 | && ((ExpandableNotificationRow) child).getTransientContainer() != null) { |
Rohan Shah | 8ee5365 | 2018-04-05 11:13:50 -0700 | [diff] [blame] | 3407 | isTransient = true; |
| 3408 | } |
| 3409 | Log.e(TAG, "Attempting to re-position " |
| 3410 | + (isTransient ? "transient" : "") |
| 3411 | + " view {" |
| 3412 | + child |
| 3413 | + "}"); |
| 3414 | return; |
| 3415 | } |
| 3416 | |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 3417 | if (child != null && child.getParent() == this && currentIndex != newIndex) { |
Selim Cinek | 159ffdb | 2014-06-04 22:24:18 +0200 | [diff] [blame] | 3418 | mChangePositionInProgress = true; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 3419 | ((ExpandableView) child).setChangingPosition(true); |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 3420 | removeView(child); |
| 3421 | addView(child, newIndex); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 3422 | ((ExpandableView) child).setChangingPosition(false); |
Selim Cinek | 159ffdb | 2014-06-04 22:24:18 +0200 | [diff] [blame] | 3423 | mChangePositionInProgress = false; |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 3424 | if (mIsExpanded && mAnimationsEnabled && child.getVisibility() != View.GONE) { |
Selim Cinek | 159ffdb | 2014-06-04 22:24:18 +0200 | [diff] [blame] | 3425 | mChildrenChangingPositions.add(child); |
| 3426 | mNeedsAnimation = true; |
| 3427 | } |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3428 | } |
| 3429 | } |
| 3430 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3431 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | f4c1996 | 2014-05-01 21:55:31 +0200 | [diff] [blame] | 3432 | private void startAnimationToState() { |
Jorim Jaggi | 0dd6881 | 2014-05-01 19:17:37 +0200 | [diff] [blame] | 3433 | if (mNeedsAnimation) { |
Rohan Shah | b9d500a | 2018-06-25 16:27:16 -0700 | [diff] [blame] | 3434 | generateAllAnimationEvents(); |
Jorim Jaggi | 0dd6881 | 2014-05-01 19:17:37 +0200 | [diff] [blame] | 3435 | mNeedsAnimation = false; |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3436 | } |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 3437 | if (!mAnimationEvents.isEmpty() || isCurrentlyAnimating()) { |
Selim Cinek | ea66ca0 | 2016-05-24 13:33:47 -0700 | [diff] [blame] | 3438 | setAnimationRunning(true); |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3439 | mStateAnimator.startAnimationForEvents(mAnimationEvents, mGoToFullShadeDelay); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 3440 | mAnimationEvents.clear(); |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 3441 | updateBackground(); |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 3442 | updateViewShadows(); |
Selim Cinek | b0ee18f | 2017-12-21 16:15:53 -0800 | [diff] [blame] | 3443 | updateClippingToTopRoundedCorner(); |
Selim Cinek | f4c1996 | 2014-05-01 21:55:31 +0200 | [diff] [blame] | 3444 | } else { |
| 3445 | applyCurrentState(); |
| 3446 | } |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3447 | mGoToFullShadeDelay = 0; |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3448 | } |
| 3449 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3450 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Rohan Shah | b9d500a | 2018-06-25 16:27:16 -0700 | [diff] [blame] | 3451 | private void generateAllAnimationEvents() { |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 3452 | generateHeadsUpAnimationEvents(); |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3453 | generateChildRemovalEvents(); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 3454 | generateChildAdditionEvents(); |
| 3455 | generatePositionChangeEvents(); |
Jorim Jaggi | 0dd6881 | 2014-05-01 19:17:37 +0200 | [diff] [blame] | 3456 | generateTopPaddingEvent(); |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 3457 | generateActivateEvent(); |
| 3458 | generateDimmedEvent(); |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 3459 | generateHideSensitiveEvent(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 3460 | generateDarkEvent(); |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 3461 | generateGoToFullShadeEvent(); |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 3462 | generateViewResizeEvent(); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 3463 | generateGroupExpansionEvent(); |
Selim Cinek | d9acca5 | 2014-09-01 22:33:25 +0200 | [diff] [blame] | 3464 | generateAnimateEverythingEvent(); |
Lucas Dupin | 4e02381 | 2018-04-02 21:19:23 -0700 | [diff] [blame] | 3465 | generatePulsingAnimationEvent(); |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3466 | } |
| 3467 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3468 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 3469 | private void generateHeadsUpAnimationEvents() { |
| 3470 | for (Pair<ExpandableNotificationRow, Boolean> eventPair : mHeadsUpChangeAnimations) { |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 3471 | ExpandableNotificationRow row = eventPair.first; |
| 3472 | boolean isHeadsUp = eventPair.second; |
| 3473 | int type = AnimationEvent.ANIMATION_TYPE_HEADS_UP_OTHER; |
| 3474 | boolean onBottom = false; |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 3475 | boolean pinnedAndClosed = row.isPinned() && !mIsExpanded; |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 3476 | if (!mIsExpanded && !isHeadsUp) { |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 3477 | type = row.wasJustClicked() |
| 3478 | ? AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK |
| 3479 | : AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR; |
Selim Cinek | 76e813c | 2016-07-14 11:16:58 -0700 | [diff] [blame] | 3480 | if (row.isChildInGroup()) { |
| 3481 | // We can otherwise get stuck in there if it was just isolated |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 3482 | row.setHeadsUpAnimatingAway(false); |
Selim Cinek | f93bf3e | 2018-05-08 14:43:21 -0700 | [diff] [blame] | 3483 | continue; |
Selim Cinek | 76e813c | 2016-07-14 11:16:58 -0700 | [diff] [blame] | 3484 | } |
Selim Cinek | eaee9c0 | 2015-06-25 11:04:20 -0400 | [diff] [blame] | 3485 | } else { |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3486 | ExpandableViewState viewState = row.getViewState(); |
Selim Cinek | eaee9c0 | 2015-06-25 11:04:20 -0400 | [diff] [blame] | 3487 | if (viewState == null) { |
| 3488 | // A view state was never generated for this view, so we don't need to animate |
| 3489 | // this. This may happen with notification children. |
| 3490 | continue; |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 3491 | } |
Selim Cinek | eaee9c0 | 2015-06-25 11:04:20 -0400 | [diff] [blame] | 3492 | if (isHeadsUp && (mAddedHeadsUpChildren.contains(row) || pinnedAndClosed)) { |
| 3493 | if (pinnedAndClosed || shouldHunAppearFromBottom(viewState)) { |
| 3494 | // Our custom add animation |
| 3495 | type = AnimationEvent.ANIMATION_TYPE_HEADS_UP_APPEAR; |
| 3496 | } else { |
| 3497 | // Normal add animation |
| 3498 | type = AnimationEvent.ANIMATION_TYPE_ADD; |
| 3499 | } |
| 3500 | onBottom = !pinnedAndClosed; |
| 3501 | } |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 3502 | } |
| 3503 | AnimationEvent event = new AnimationEvent(row, type); |
| 3504 | event.headsUpFromBottom = onBottom; |
| 3505 | mAnimationEvents.add(event); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 3506 | } |
| 3507 | mHeadsUpChangeAnimations.clear(); |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 3508 | mAddedHeadsUpChildren.clear(); |
| 3509 | } |
| 3510 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3511 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 3512 | private boolean shouldHunAppearFromBottom(ExpandableViewState viewState) { |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 3513 | if (viewState.yTranslation + viewState.height < mAmbientState.getMaxHeadsUpTranslation()) { |
| 3514 | return false; |
| 3515 | } |
| 3516 | return true; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 3517 | } |
| 3518 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3519 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 3520 | private void generateGroupExpansionEvent() { |
| 3521 | // Generate a group expansion/collapsing event if there is such a group at all |
| 3522 | if (mExpandedGroupView != null) { |
| 3523 | mAnimationEvents.add(new AnimationEvent(mExpandedGroupView, |
| 3524 | AnimationEvent.ANIMATION_TYPE_GROUP_EXPANSION_CHANGED)); |
| 3525 | mExpandedGroupView = null; |
| 3526 | } |
| 3527 | } |
| 3528 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3529 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 3530 | private void generateViewResizeEvent() { |
| 3531 | if (mNeedViewResizeAnimation) { |
felkachang | d7835b0 | 2018-07-17 18:18:13 +0800 | [diff] [blame] | 3532 | boolean hasDisappearAnimation = false; |
| 3533 | for (AnimationEvent animationEvent : mAnimationEvents) { |
| 3534 | final int type = animationEvent.animationType; |
| 3535 | if (type == AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 3536 | || type == AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR) { |
felkachang | d7835b0 | 2018-07-17 18:18:13 +0800 | [diff] [blame] | 3537 | hasDisappearAnimation = true; |
| 3538 | break; |
| 3539 | } |
| 3540 | } |
| 3541 | |
| 3542 | if (!hasDisappearAnimation) { |
| 3543 | mAnimationEvents.add( |
| 3544 | new AnimationEvent(null, AnimationEvent.ANIMATION_TYPE_VIEW_RESIZE)); |
| 3545 | } |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 3546 | } |
| 3547 | mNeedViewResizeAnimation = false; |
| 3548 | } |
| 3549 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3550 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3551 | private void generateChildRemovalEvents() { |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3552 | for (ExpandableView child : mChildrenToRemoveAnimated) { |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3553 | boolean childWasSwipedOut = mSwipedOutViews.contains(child); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 3554 | |
| 3555 | // we need to know the view after this one |
Selim Cinek | ef8c225 | 2017-02-10 14:52:18 -0800 | [diff] [blame] | 3556 | float removedTranslation = child.getTranslationY(); |
| 3557 | boolean ignoreChildren = true; |
| 3558 | if (child instanceof ExpandableNotificationRow) { |
| 3559 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 3560 | if (row.isRemoved() && row.wasChildInGroupWhenRemoved()) { |
| 3561 | removedTranslation = row.getTranslationWhenRemoved(); |
| 3562 | ignoreChildren = false; |
| 3563 | } |
Selim Cinek | 5105204 | 2017-07-04 12:07:55 +0200 | [diff] [blame] | 3564 | childWasSwipedOut |= Math.abs(row.getTranslation()) == row.getWidth(); |
Selim Cinek | ef8c225 | 2017-02-10 14:52:18 -0800 | [diff] [blame] | 3565 | } |
Selim Cinek | 5105204 | 2017-07-04 12:07:55 +0200 | [diff] [blame] | 3566 | if (!childWasSwipedOut) { |
| 3567 | Rect clipBounds = child.getClipBounds(); |
Selim Cinek | e5832ee | 2017-11-06 14:46:48 -0800 | [diff] [blame] | 3568 | childWasSwipedOut = clipBounds != null && clipBounds.height() == 0; |
Rohan Shah | a759496 | 2018-05-22 10:59:30 -0700 | [diff] [blame] | 3569 | |
| 3570 | if (childWasSwipedOut && child instanceof ExpandableView) { |
| 3571 | // Clean up any potential transient views if the child has already been swiped |
| 3572 | // out, as we won't be animating it further (due to its height already being |
| 3573 | // clipped to 0. |
| 3574 | ViewGroup transientContainer = ((ExpandableView) child).getTransientContainer(); |
| 3575 | if (transientContainer != null) { |
| 3576 | transientContainer.removeTransientView(child); |
| 3577 | } |
| 3578 | } |
Selim Cinek | 5105204 | 2017-07-04 12:07:55 +0200 | [diff] [blame] | 3579 | } |
| 3580 | int animationType = childWasSwipedOut |
| 3581 | ? AnimationEvent.ANIMATION_TYPE_REMOVE_SWIPED_OUT |
| 3582 | : AnimationEvent.ANIMATION_TYPE_REMOVE; |
| 3583 | AnimationEvent event = new AnimationEvent(child, animationType); |
Selim Cinek | ef8c225 | 2017-02-10 14:52:18 -0800 | [diff] [blame] | 3584 | event.viewAfterChangingView = getFirstChildBelowTranlsationY(removedTranslation, |
| 3585 | ignoreChildren); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 3586 | mAnimationEvents.add(event); |
Selim Cinek | d139564 | 2016-04-28 12:22:42 -0700 | [diff] [blame] | 3587 | mSwipedOutViews.remove(child); |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3588 | } |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3589 | mChildrenToRemoveAnimated.clear(); |
| 3590 | } |
| 3591 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3592 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 3593 | private void generatePositionChangeEvents() { |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3594 | for (ExpandableView child : mChildrenChangingPositions) { |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 3595 | mAnimationEvents.add(new AnimationEvent(child, |
| 3596 | AnimationEvent.ANIMATION_TYPE_CHANGE_POSITION)); |
| 3597 | } |
| 3598 | mChildrenChangingPositions.clear(); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 3599 | if (mGenerateChildOrderChangedEvent) { |
| 3600 | mAnimationEvents.add(new AnimationEvent(null, |
| 3601 | AnimationEvent.ANIMATION_TYPE_CHANGE_POSITION)); |
| 3602 | mGenerateChildOrderChangedEvent = false; |
| 3603 | } |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 3604 | } |
| 3605 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3606 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3607 | private void generateChildAdditionEvents() { |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3608 | for (ExpandableView child : mChildrenToAddAnimated) { |
Jorim Jaggi | ff9c9c4 | 2014-08-01 05:36:22 +0200 | [diff] [blame] | 3609 | if (mFromMoreCardAdditions.contains(child)) { |
| 3610 | mAnimationEvents.add(new AnimationEvent(child, |
| 3611 | AnimationEvent.ANIMATION_TYPE_ADD, |
| 3612 | StackStateAnimator.ANIMATION_DURATION_STANDARD)); |
| 3613 | } else { |
| 3614 | mAnimationEvents.add(new AnimationEvent(child, |
| 3615 | AnimationEvent.ANIMATION_TYPE_ADD)); |
| 3616 | } |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 3617 | } |
| 3618 | mChildrenToAddAnimated.clear(); |
Jorim Jaggi | ff9c9c4 | 2014-08-01 05:36:22 +0200 | [diff] [blame] | 3619 | mFromMoreCardAdditions.clear(); |
Christoph Studer | 068f592 | 2014-04-08 17:43:07 -0400 | [diff] [blame] | 3620 | } |
| 3621 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3622 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Jorim Jaggi | 0dd6881 | 2014-05-01 19:17:37 +0200 | [diff] [blame] | 3623 | private void generateTopPaddingEvent() { |
Jorim Jaggi | 98fb09c | 2014-05-01 22:40:56 +0200 | [diff] [blame] | 3624 | if (mTopPaddingNeedsAnimation) { |
Lucas Dupin | c445dcc | 2018-05-07 16:00:11 -0700 | [diff] [blame] | 3625 | AnimationEvent event; |
| 3626 | if (mAmbientState.isDark()) { |
| 3627 | event = new AnimationEvent(null /* view */, |
| 3628 | AnimationEvent.ANIMATION_TYPE_TOP_PADDING_CHANGED, |
| 3629 | KeyguardSliceView.DEFAULT_ANIM_DURATION); |
| 3630 | } else { |
| 3631 | event = new AnimationEvent(null /* view */, |
| 3632 | AnimationEvent.ANIMATION_TYPE_TOP_PADDING_CHANGED); |
| 3633 | } |
| 3634 | mAnimationEvents.add(event); |
Jorim Jaggi | 98fb09c | 2014-05-01 22:40:56 +0200 | [diff] [blame] | 3635 | } |
Jorim Jaggi | 0dd6881 | 2014-05-01 19:17:37 +0200 | [diff] [blame] | 3636 | mTopPaddingNeedsAnimation = false; |
| 3637 | } |
| 3638 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3639 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 3640 | private void generateActivateEvent() { |
| 3641 | if (mActivateNeedsAnimation) { |
| 3642 | mAnimationEvents.add( |
| 3643 | new AnimationEvent(null, AnimationEvent.ANIMATION_TYPE_ACTIVATED_CHILD)); |
| 3644 | } |
| 3645 | mActivateNeedsAnimation = false; |
| 3646 | } |
| 3647 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3648 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | d9acca5 | 2014-09-01 22:33:25 +0200 | [diff] [blame] | 3649 | private void generateAnimateEverythingEvent() { |
| 3650 | if (mEverythingNeedsAnimation) { |
| 3651 | mAnimationEvents.add( |
| 3652 | new AnimationEvent(null, AnimationEvent.ANIMATION_TYPE_EVERYTHING)); |
| 3653 | } |
| 3654 | mEverythingNeedsAnimation = false; |
| 3655 | } |
| 3656 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3657 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 3658 | private void generateDimmedEvent() { |
| 3659 | if (mDimmedNeedsAnimation) { |
| 3660 | mAnimationEvents.add( |
| 3661 | new AnimationEvent(null, AnimationEvent.ANIMATION_TYPE_DIMMED)); |
| 3662 | } |
| 3663 | mDimmedNeedsAnimation = false; |
| 3664 | } |
| 3665 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3666 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 3667 | private void generateHideSensitiveEvent() { |
| 3668 | if (mHideSensitiveNeedsAnimation) { |
| 3669 | mAnimationEvents.add( |
| 3670 | new AnimationEvent(null, AnimationEvent.ANIMATION_TYPE_HIDE_SENSITIVE)); |
| 3671 | } |
| 3672 | mHideSensitiveNeedsAnimation = false; |
| 3673 | } |
| 3674 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3675 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 3676 | private void generateDarkEvent() { |
| 3677 | if (mDarkNeedsAnimation) { |
Adrian Roos | 28f90c7 | 2017-05-08 17:24:26 -0700 | [diff] [blame] | 3678 | AnimationEvent ev = new AnimationEvent(null, |
| 3679 | AnimationEvent.ANIMATION_TYPE_DARK, |
| 3680 | new AnimationFilter() |
| 3681 | .animateDark() |
| 3682 | .animateY(mShelf)); |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 3683 | ev.darkAnimationOriginIndex = mDarkAnimationOriginIndex; |
| 3684 | mAnimationEvents.add(ev); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 3685 | } |
| 3686 | mDarkNeedsAnimation = false; |
| 3687 | } |
| 3688 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 3689 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 3690 | private void generateGoToFullShadeEvent() { |
| 3691 | if (mGoToFullShadeNeedsAnimation) { |
| 3692 | mAnimationEvents.add( |
| 3693 | new AnimationEvent(null, AnimationEvent.ANIMATION_TYPE_GO_TO_FULL_SHADE)); |
| 3694 | } |
| 3695 | mGoToFullShadeNeedsAnimation = false; |
| 3696 | } |
| 3697 | |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 3698 | @ShadeViewRefactor(RefactorComponent.LAYOUT_ALGORITHM) |
| 3699 | protected StackScrollAlgorithm createStackScrollAlgorithm(Context context) { |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 3700 | return new StackScrollAlgorithm(context, this); |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 3701 | } |
| 3702 | |
| 3703 | /** |
| 3704 | * @return Whether a y coordinate is inside the content. |
| 3705 | */ |
| 3706 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
| 3707 | public boolean isInContentBounds(float y) { |
| 3708 | return y < getHeight() - getEmptyBottomMargin(); |
| 3709 | } |
| 3710 | |
| 3711 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 3712 | public void setLongPressListener(ExpandableNotificationRow.LongPressListener listener) { |
| 3713 | mLongPressListener = listener; |
| 3714 | } |
| 3715 | |
| 3716 | @Override |
| 3717 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 3718 | public boolean onTouchEvent(MotionEvent ev) { |
| 3719 | boolean isCancelOrUp = ev.getActionMasked() == MotionEvent.ACTION_CANCEL |
| 3720 | || ev.getActionMasked() == MotionEvent.ACTION_UP; |
| 3721 | handleEmptySpaceClick(ev); |
| 3722 | boolean expandWantsIt = false; |
Aaron Heuckroth | 9dc9d4f | 2018-11-15 11:04:01 -0500 | [diff] [blame] | 3723 | boolean swipingInProgress = mSwipingInProgress; |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 3724 | if (mIsExpanded && !swipingInProgress && !mOnlyScrollingInThisMotion) { |
| 3725 | if (isCancelOrUp) { |
| 3726 | mExpandHelper.onlyObserveMovements(false); |
| 3727 | } |
| 3728 | boolean wasExpandingBefore = mExpandingNotification; |
| 3729 | expandWantsIt = mExpandHelper.onTouchEvent(ev); |
| 3730 | if (mExpandedInThisMotion && !mExpandingNotification && wasExpandingBefore |
| 3731 | && !mDisallowScrollingInThisMotion) { |
| 3732 | dispatchDownEventToScroller(ev); |
| 3733 | } |
| 3734 | } |
| 3735 | boolean scrollerWantsIt = false; |
| 3736 | if (mIsExpanded && !swipingInProgress && !mExpandingNotification |
| 3737 | && !mDisallowScrollingInThisMotion) { |
| 3738 | scrollerWantsIt = onScrollTouch(ev); |
| 3739 | } |
| 3740 | boolean horizontalSwipeWantsIt = false; |
| 3741 | if (!mIsBeingDragged |
| 3742 | && !mExpandingNotification |
| 3743 | && !mExpandedInThisMotion |
| 3744 | && !mOnlyScrollingInThisMotion |
| 3745 | && !mDisallowDismissInThisMotion) { |
| 3746 | horizontalSwipeWantsIt = mSwipeHelper.onTouchEvent(ev); |
| 3747 | } |
| 3748 | |
| 3749 | // Check if we need to clear any snooze leavebehinds |
| 3750 | NotificationGuts guts = mNotificationGutsManager.getExposedGuts(); |
| 3751 | if (guts != null && !NotificationSwipeHelper.isTouchInView(ev, guts) |
| 3752 | && guts.getGutsContent() instanceof NotificationSnooze) { |
| 3753 | NotificationSnooze ns = (NotificationSnooze) guts.getGutsContent(); |
| 3754 | if ((ns.isExpanded() && isCancelOrUp) |
| 3755 | || (!horizontalSwipeWantsIt && scrollerWantsIt)) { |
| 3756 | // If the leavebehind is expanded we clear it on the next up event, otherwise we |
| 3757 | // clear it on the next non-horizontal swipe or expand event. |
| 3758 | checkSnoozeLeavebehind(); |
| 3759 | } |
| 3760 | } |
| 3761 | if (ev.getActionMasked() == MotionEvent.ACTION_UP) { |
| 3762 | mCheckForLeavebehind = true; |
| 3763 | } |
| 3764 | return horizontalSwipeWantsIt || scrollerWantsIt || expandWantsIt || super.onTouchEvent(ev); |
| 3765 | } |
| 3766 | |
| 3767 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 3768 | private void dispatchDownEventToScroller(MotionEvent ev) { |
| 3769 | MotionEvent downEvent = MotionEvent.obtain(ev); |
| 3770 | downEvent.setAction(MotionEvent.ACTION_DOWN); |
| 3771 | onScrollTouch(downEvent); |
| 3772 | downEvent.recycle(); |
| 3773 | } |
| 3774 | |
| 3775 | @Override |
| 3776 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 3777 | public boolean onGenericMotionEvent(MotionEvent event) { |
Aaron Heuckroth | 9dc9d4f | 2018-11-15 11:04:01 -0500 | [diff] [blame] | 3778 | if (!isScrollingEnabled() || !mIsExpanded || mSwipingInProgress || mExpandingNotification |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 3779 | || mDisallowScrollingInThisMotion) { |
| 3780 | return false; |
| 3781 | } |
| 3782 | if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
| 3783 | switch (event.getAction()) { |
| 3784 | case MotionEvent.ACTION_SCROLL: { |
| 3785 | if (!mIsBeingDragged) { |
| 3786 | final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); |
| 3787 | if (vscroll != 0) { |
| 3788 | final int delta = (int) (vscroll * getVerticalScrollFactor()); |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 3789 | if (ANCHOR_SCROLLING) { |
| 3790 | mScrollAnchorViewY -= delta; |
| 3791 | updateScrollAnchor(); |
| 3792 | clampScrollPosition(); |
| 3793 | updateOnScrollChange(); |
| 3794 | } else { |
| 3795 | final int range = getScrollRange(); |
| 3796 | int oldScrollY = mOwnScrollY; |
| 3797 | int newScrollY = oldScrollY - delta; |
| 3798 | if (newScrollY < 0) { |
| 3799 | newScrollY = 0; |
| 3800 | } else if (newScrollY > range) { |
| 3801 | newScrollY = range; |
| 3802 | } |
| 3803 | if (newScrollY != oldScrollY) { |
| 3804 | setOwnScrollY(newScrollY); |
| 3805 | return true; |
| 3806 | } |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 3807 | } |
| 3808 | } |
| 3809 | } |
| 3810 | } |
| 3811 | } |
| 3812 | } |
| 3813 | return super.onGenericMotionEvent(event); |
| 3814 | } |
| 3815 | |
| 3816 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 3817 | private boolean onScrollTouch(MotionEvent ev) { |
| 3818 | if (!isScrollingEnabled()) { |
| 3819 | return false; |
| 3820 | } |
| 3821 | if (isInsideQsContainer(ev) && !mIsBeingDragged) { |
| 3822 | return false; |
| 3823 | } |
| 3824 | mForcedScroll = null; |
| 3825 | initVelocityTrackerIfNotExists(); |
| 3826 | mVelocityTracker.addMovement(ev); |
| 3827 | |
| 3828 | final int action = ev.getAction(); |
| 3829 | |
| 3830 | switch (action & MotionEvent.ACTION_MASK) { |
| 3831 | case MotionEvent.ACTION_DOWN: { |
| 3832 | if (getChildCount() == 0 || !isInContentBounds(ev)) { |
| 3833 | return false; |
| 3834 | } |
| 3835 | boolean isBeingDragged = !mScroller.isFinished(); |
| 3836 | setIsBeingDragged(isBeingDragged); |
| 3837 | /* |
| 3838 | * If being flinged and user touches, stop the fling. isFinished |
| 3839 | * will be false if being flinged. |
| 3840 | */ |
| 3841 | if (!mScroller.isFinished()) { |
| 3842 | mScroller.forceFinished(true); |
| 3843 | } |
| 3844 | |
| 3845 | // Remember where the motion event started |
| 3846 | mLastMotionY = (int) ev.getY(); |
| 3847 | mDownX = (int) ev.getX(); |
| 3848 | mActivePointerId = ev.getPointerId(0); |
| 3849 | break; |
| 3850 | } |
| 3851 | case MotionEvent.ACTION_MOVE: |
| 3852 | final int activePointerIndex = ev.findPointerIndex(mActivePointerId); |
| 3853 | if (activePointerIndex == -1) { |
| 3854 | Log.e(TAG, "Invalid pointerId=" + mActivePointerId + " in onTouchEvent"); |
| 3855 | break; |
| 3856 | } |
| 3857 | |
| 3858 | final int y = (int) ev.getY(activePointerIndex); |
| 3859 | final int x = (int) ev.getX(activePointerIndex); |
| 3860 | int deltaY = mLastMotionY - y; |
| 3861 | final int xDiff = Math.abs(x - mDownX); |
| 3862 | final int yDiff = Math.abs(deltaY); |
| 3863 | if (!mIsBeingDragged && yDiff > mTouchSlop && yDiff > xDiff) { |
| 3864 | setIsBeingDragged(true); |
| 3865 | if (deltaY > 0) { |
| 3866 | deltaY -= mTouchSlop; |
| 3867 | } else { |
| 3868 | deltaY += mTouchSlop; |
| 3869 | } |
| 3870 | } |
| 3871 | if (mIsBeingDragged) { |
| 3872 | // Scroll to follow the motion event |
| 3873 | mLastMotionY = y; |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 3874 | float scrollAmount; |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 3875 | int range; |
| 3876 | if (ANCHOR_SCROLLING) { |
| 3877 | range = 0; // unused in the methods it's being passed to |
| 3878 | } else { |
| 3879 | range = getScrollRange(); |
| 3880 | if (mExpandedInThisMotion) { |
| 3881 | range = Math.min(range, mMaxScrollAfterExpand); |
| 3882 | } |
| 3883 | } |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 3884 | if (deltaY < 0) { |
| 3885 | scrollAmount = overScrollDown(deltaY); |
| 3886 | } else { |
| 3887 | scrollAmount = overScrollUp(deltaY, range); |
| 3888 | } |
| 3889 | |
| 3890 | // Calling customOverScrollBy will call onCustomOverScrolled, which |
| 3891 | // sets the scrolling if applicable. |
| 3892 | if (scrollAmount != 0.0f) { |
| 3893 | // The scrolling motion could not be compensated with the |
| 3894 | // existing overScroll, we have to scroll the view |
| 3895 | customOverScrollBy((int) scrollAmount, mOwnScrollY, |
| 3896 | range, getHeight() / 2); |
| 3897 | // If we're scrolling, leavebehinds should be dismissed |
| 3898 | checkSnoozeLeavebehind(); |
| 3899 | } |
| 3900 | } |
| 3901 | break; |
| 3902 | case MotionEvent.ACTION_UP: |
| 3903 | if (mIsBeingDragged) { |
| 3904 | final VelocityTracker velocityTracker = mVelocityTracker; |
| 3905 | velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); |
| 3906 | int initialVelocity = (int) velocityTracker.getYVelocity(mActivePointerId); |
| 3907 | |
| 3908 | if (shouldOverScrollFling(initialVelocity)) { |
| 3909 | onOverScrollFling(true, initialVelocity); |
| 3910 | } else { |
| 3911 | if (getChildCount() > 0) { |
| 3912 | if ((Math.abs(initialVelocity) > mMinimumVelocity)) { |
| 3913 | float currentOverScrollTop = getCurrentOverScrollAmount(true); |
| 3914 | if (currentOverScrollTop == 0.0f || initialVelocity > 0) { |
| 3915 | fling(-initialVelocity); |
| 3916 | } else { |
| 3917 | onOverScrollFling(false, initialVelocity); |
| 3918 | } |
| 3919 | } else { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 3920 | if (ANCHOR_SCROLLING) { |
| 3921 | // TODO |
| 3922 | } else { |
| 3923 | if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, |
| 3924 | getScrollRange())) { |
| 3925 | animateScroll(); |
| 3926 | } |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 3927 | } |
| 3928 | } |
| 3929 | } |
| 3930 | } |
| 3931 | mActivePointerId = INVALID_POINTER; |
| 3932 | endDrag(); |
| 3933 | } |
| 3934 | |
| 3935 | break; |
| 3936 | case MotionEvent.ACTION_CANCEL: |
| 3937 | if (mIsBeingDragged && getChildCount() > 0) { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 3938 | if (ANCHOR_SCROLLING) { |
| 3939 | // TODO |
| 3940 | } else { |
| 3941 | if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, |
| 3942 | getScrollRange())) { |
| 3943 | animateScroll(); |
| 3944 | } |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 3945 | } |
| 3946 | mActivePointerId = INVALID_POINTER; |
| 3947 | endDrag(); |
| 3948 | } |
| 3949 | break; |
| 3950 | case MotionEvent.ACTION_POINTER_DOWN: { |
| 3951 | final int index = ev.getActionIndex(); |
| 3952 | mLastMotionY = (int) ev.getY(index); |
| 3953 | mDownX = (int) ev.getX(index); |
| 3954 | mActivePointerId = ev.getPointerId(index); |
| 3955 | break; |
| 3956 | } |
| 3957 | case MotionEvent.ACTION_POINTER_UP: |
| 3958 | onSecondaryPointerUp(ev); |
| 3959 | mLastMotionY = (int) ev.getY(ev.findPointerIndex(mActivePointerId)); |
| 3960 | mDownX = (int) ev.getX(ev.findPointerIndex(mActivePointerId)); |
| 3961 | break; |
| 3962 | } |
| 3963 | return true; |
| 3964 | } |
| 3965 | |
| 3966 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 3967 | protected boolean isInsideQsContainer(MotionEvent ev) { |
| 3968 | return ev.getY() < mQsContainer.getBottom(); |
| 3969 | } |
| 3970 | |
| 3971 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 3972 | private void onOverScrollFling(boolean open, int initialVelocity) { |
| 3973 | if (mOverscrollTopChangedListener != null) { |
| 3974 | mOverscrollTopChangedListener.flingTopOverscroll(initialVelocity, open); |
| 3975 | } |
| 3976 | mDontReportNextOverScroll = true; |
| 3977 | setOverScrollAmount(0.0f, true, false); |
| 3978 | } |
| 3979 | |
| 3980 | |
| 3981 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 3982 | private void onSecondaryPointerUp(MotionEvent ev) { |
| 3983 | final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> |
| 3984 | MotionEvent.ACTION_POINTER_INDEX_SHIFT; |
| 3985 | final int pointerId = ev.getPointerId(pointerIndex); |
| 3986 | if (pointerId == mActivePointerId) { |
| 3987 | // This was our active pointer going up. Choose a new |
| 3988 | // active pointer and adjust accordingly. |
| 3989 | // TODO: Make this decision more intelligent. |
| 3990 | final int newPointerIndex = pointerIndex == 0 ? 1 : 0; |
| 3991 | mLastMotionY = (int) ev.getY(newPointerIndex); |
| 3992 | mActivePointerId = ev.getPointerId(newPointerIndex); |
| 3993 | if (mVelocityTracker != null) { |
| 3994 | mVelocityTracker.clear(); |
| 3995 | } |
| 3996 | } |
| 3997 | } |
| 3998 | |
| 3999 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 4000 | private void endDrag() { |
| 4001 | setIsBeingDragged(false); |
| 4002 | |
| 4003 | recycleVelocityTracker(); |
| 4004 | |
| 4005 | if (getCurrentOverScrollAmount(true /* onTop */) > 0) { |
| 4006 | setOverScrollAmount(0, true /* onTop */, true /* animate */); |
| 4007 | } |
| 4008 | if (getCurrentOverScrollAmount(false /* onTop */) > 0) { |
| 4009 | setOverScrollAmount(0, false /* onTop */, true /* animate */); |
| 4010 | } |
| 4011 | } |
| 4012 | |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 4013 | @Override |
| 4014 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 4015 | public boolean onInterceptTouchEvent(MotionEvent ev) { |
| 4016 | initDownStates(ev); |
| 4017 | handleEmptySpaceClick(ev); |
| 4018 | boolean expandWantsIt = false; |
Aaron Heuckroth | 9dc9d4f | 2018-11-15 11:04:01 -0500 | [diff] [blame] | 4019 | boolean swipingInProgress = mSwipingInProgress; |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 4020 | if (!swipingInProgress && !mOnlyScrollingInThisMotion) { |
| 4021 | expandWantsIt = mExpandHelper.onInterceptTouchEvent(ev); |
| 4022 | } |
| 4023 | boolean scrollWantsIt = false; |
| 4024 | if (!swipingInProgress && !mExpandingNotification) { |
| 4025 | scrollWantsIt = onInterceptTouchEventScroll(ev); |
| 4026 | } |
| 4027 | boolean swipeWantsIt = false; |
| 4028 | if (!mIsBeingDragged |
| 4029 | && !mExpandingNotification |
| 4030 | && !mExpandedInThisMotion |
| 4031 | && !mOnlyScrollingInThisMotion |
| 4032 | && !mDisallowDismissInThisMotion) { |
| 4033 | swipeWantsIt = mSwipeHelper.onInterceptTouchEvent(ev); |
| 4034 | } |
| 4035 | // Check if we need to clear any snooze leavebehinds |
| 4036 | boolean isUp = ev.getActionMasked() == MotionEvent.ACTION_UP; |
| 4037 | NotificationGuts guts = mNotificationGutsManager.getExposedGuts(); |
| 4038 | if (!NotificationSwipeHelper.isTouchInView(ev, guts) && isUp && !swipeWantsIt && |
| 4039 | !expandWantsIt && !scrollWantsIt) { |
| 4040 | mCheckForLeavebehind = false; |
| 4041 | mNotificationGutsManager.closeAndSaveGuts(true /* removeLeavebehind */, |
| 4042 | false /* force */, false /* removeControls */, -1 /* x */, -1 /* y */, |
| 4043 | false /* resetMenu */); |
| 4044 | } |
| 4045 | if (ev.getActionMasked() == MotionEvent.ACTION_UP) { |
| 4046 | mCheckForLeavebehind = true; |
| 4047 | } |
| 4048 | return swipeWantsIt || scrollWantsIt || expandWantsIt || super.onInterceptTouchEvent(ev); |
| 4049 | } |
| 4050 | |
| 4051 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 4052 | private void handleEmptySpaceClick(MotionEvent ev) { |
| 4053 | switch (ev.getActionMasked()) { |
| 4054 | case MotionEvent.ACTION_MOVE: |
| 4055 | if (mTouchIsClick && (Math.abs(ev.getY() - mInitialTouchY) > mTouchSlop |
| 4056 | || Math.abs(ev.getX() - mInitialTouchX) > mTouchSlop)) { |
| 4057 | mTouchIsClick = false; |
| 4058 | } |
| 4059 | break; |
| 4060 | case MotionEvent.ACTION_UP: |
| 4061 | if (mStatusBarState != StatusBarState.KEYGUARD && mTouchIsClick && |
| 4062 | isBelowLastNotification(mInitialTouchX, mInitialTouchY)) { |
| 4063 | mOnEmptySpaceClickListener.onEmptySpaceClicked(mInitialTouchX, mInitialTouchY); |
| 4064 | } |
| 4065 | break; |
| 4066 | } |
| 4067 | } |
| 4068 | |
| 4069 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 4070 | private void initDownStates(MotionEvent ev) { |
| 4071 | if (ev.getAction() == MotionEvent.ACTION_DOWN) { |
| 4072 | mExpandedInThisMotion = false; |
| 4073 | mOnlyScrollingInThisMotion = !mScroller.isFinished(); |
| 4074 | mDisallowScrollingInThisMotion = false; |
| 4075 | mDisallowDismissInThisMotion = false; |
| 4076 | mTouchIsClick = true; |
| 4077 | mInitialTouchX = ev.getX(); |
| 4078 | mInitialTouchY = ev.getY(); |
| 4079 | } |
| 4080 | } |
| 4081 | |
| 4082 | @Override |
| 4083 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 4084 | public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) { |
| 4085 | super.requestDisallowInterceptTouchEvent(disallowIntercept); |
| 4086 | if (disallowIntercept) { |
| 4087 | cancelLongPress(); |
| 4088 | } |
| 4089 | } |
| 4090 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4091 | @ShadeViewRefactor(RefactorComponent.INPUT) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4092 | private boolean onInterceptTouchEventScroll(MotionEvent ev) { |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4093 | if (!isScrollingEnabled()) { |
| 4094 | return false; |
| 4095 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4096 | /* |
| 4097 | * This method JUST determines whether we want to intercept the motion. |
| 4098 | * If we return true, onMotionEvent will be called and we do the actual |
| 4099 | * scrolling there. |
| 4100 | */ |
| 4101 | |
| 4102 | /* |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 4103 | * Shortcut the most recurring case: the user is in the dragging |
| 4104 | * state and is moving their finger. We want to intercept this |
| 4105 | * motion. |
| 4106 | */ |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4107 | final int action = ev.getAction(); |
| 4108 | if ((action == MotionEvent.ACTION_MOVE) && (mIsBeingDragged)) { |
| 4109 | return true; |
| 4110 | } |
| 4111 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4112 | switch (action & MotionEvent.ACTION_MASK) { |
| 4113 | case MotionEvent.ACTION_MOVE: { |
| 4114 | /* |
| 4115 | * mIsBeingDragged == false, otherwise the shortcut would have caught it. Check |
Chris Wren | 5d53df4 | 2015-06-26 11:26:03 -0400 | [diff] [blame] | 4116 | * whether the user has moved far enough from the original down touch. |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4117 | */ |
| 4118 | |
| 4119 | /* |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 4120 | * Locally do absolute value. mLastMotionY is set to the y value |
| 4121 | * of the down event. |
| 4122 | */ |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4123 | final int activePointerId = mActivePointerId; |
| 4124 | if (activePointerId == INVALID_POINTER) { |
| 4125 | // If we don't have a valid id, the touch down wasn't on content. |
| 4126 | break; |
| 4127 | } |
| 4128 | |
| 4129 | final int pointerIndex = ev.findPointerIndex(activePointerId); |
| 4130 | if (pointerIndex == -1) { |
| 4131 | Log.e(TAG, "Invalid pointerId=" + activePointerId |
| 4132 | + " in onInterceptTouchEvent"); |
| 4133 | break; |
| 4134 | } |
| 4135 | |
| 4136 | final int y = (int) ev.getY(pointerIndex); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4137 | final int x = (int) ev.getX(pointerIndex); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4138 | final int yDiff = Math.abs(y - mLastMotionY); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4139 | final int xDiff = Math.abs(x - mDownX); |
| 4140 | if (yDiff > mTouchSlop && yDiff > xDiff) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4141 | setIsBeingDragged(true); |
| 4142 | mLastMotionY = y; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4143 | mDownX = x; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4144 | initVelocityTrackerIfNotExists(); |
| 4145 | mVelocityTracker.addMovement(ev); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4146 | } |
| 4147 | break; |
| 4148 | } |
| 4149 | |
| 4150 | case MotionEvent.ACTION_DOWN: { |
| 4151 | final int y = (int) ev.getY(); |
Jayasri bhattacharyya | 5e55c89 | 2015-09-10 16:00:10 +0530 | [diff] [blame] | 4152 | mScrolledToTopOnFirstDown = isScrolledToTop(); |
Selim Cinek | 34ed7c0 | 2017-09-08 15:03:12 -0700 | [diff] [blame] | 4153 | if (getChildAtPosition(ev.getX(), y, false /* requireMinHeight */) == null) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4154 | setIsBeingDragged(false); |
| 4155 | recycleVelocityTracker(); |
| 4156 | break; |
| 4157 | } |
| 4158 | |
| 4159 | /* |
| 4160 | * Remember location of down touch. |
| 4161 | * ACTION_DOWN always refers to pointer index 0. |
| 4162 | */ |
| 4163 | mLastMotionY = y; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4164 | mDownX = (int) ev.getX(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4165 | mActivePointerId = ev.getPointerId(0); |
| 4166 | |
| 4167 | initOrResetVelocityTracker(); |
| 4168 | mVelocityTracker.addMovement(ev); |
| 4169 | /* |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 4170 | * If being flinged and user touches the screen, initiate drag; |
| 4171 | * otherwise don't. mScroller.isFinished should be false when |
| 4172 | * being flinged. |
| 4173 | */ |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4174 | boolean isBeingDragged = !mScroller.isFinished(); |
| 4175 | setIsBeingDragged(isBeingDragged); |
| 4176 | break; |
| 4177 | } |
| 4178 | |
| 4179 | case MotionEvent.ACTION_CANCEL: |
| 4180 | case MotionEvent.ACTION_UP: |
| 4181 | /* Release the drag */ |
| 4182 | setIsBeingDragged(false); |
| 4183 | mActivePointerId = INVALID_POINTER; |
| 4184 | recycleVelocityTracker(); |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 4185 | if (ANCHOR_SCROLLING) { |
| 4186 | // TODO |
| 4187 | } else { |
| 4188 | if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, getScrollRange())) { |
| 4189 | animateScroll(); |
| 4190 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4191 | } |
| 4192 | break; |
| 4193 | case MotionEvent.ACTION_POINTER_UP: |
| 4194 | onSecondaryPointerUp(ev); |
| 4195 | break; |
| 4196 | } |
| 4197 | |
| 4198 | /* |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 4199 | * The only time we want to intercept motion events is if we are in the |
| 4200 | * drag mode. |
| 4201 | */ |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4202 | return mIsBeingDragged; |
| 4203 | } |
| 4204 | |
Jorim Jaggi | fe6bfa6 | 2014-05-07 23:23:18 +0200 | [diff] [blame] | 4205 | /** |
| 4206 | * @return Whether the specified motion event is actually happening over the content. |
| 4207 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4208 | @ShadeViewRefactor(RefactorComponent.INPUT) |
Jorim Jaggi | fe6bfa6 | 2014-05-07 23:23:18 +0200 | [diff] [blame] | 4209 | private boolean isInContentBounds(MotionEvent event) { |
Selim Cinek | ab1dc95 | 2014-10-30 20:20:29 +0100 | [diff] [blame] | 4210 | return isInContentBounds(event.getY()); |
| 4211 | } |
| 4212 | |
Jorim Jaggi | fe6bfa6 | 2014-05-07 23:23:18 +0200 | [diff] [blame] | 4213 | |
Gus Prevas | 99ba4ba | 2018-10-01 16:40:23 -0400 | [diff] [blame] | 4214 | @VisibleForTesting |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4215 | @ShadeViewRefactor(RefactorComponent.INPUT) |
Gus Prevas | 99ba4ba | 2018-10-01 16:40:23 -0400 | [diff] [blame] | 4216 | void setIsBeingDragged(boolean isDragged) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4217 | mIsBeingDragged = isDragged; |
| 4218 | if (isDragged) { |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 4219 | requestDisallowInterceptTouchEvent(true); |
Geoffrey Pitsch | 409db27 | 2017-08-28 14:51:52 +0000 | [diff] [blame] | 4220 | cancelLongPress(); |
Gus Prevas | 99ba4ba | 2018-10-01 16:40:23 -0400 | [diff] [blame] | 4221 | resetExposedMenuView(true /* animate */, true /* force */); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4222 | } |
| 4223 | } |
| 4224 | |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 4225 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 4226 | public void requestDisallowLongPress() { |
| 4227 | cancelLongPress(); |
| 4228 | } |
| 4229 | |
| 4230 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 4231 | public void requestDisallowDismiss() { |
| 4232 | mDisallowDismissInThisMotion = true; |
| 4233 | } |
| 4234 | |
| 4235 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 4236 | public void cancelLongPress() { |
| 4237 | mSwipeHelper.cancelLongPress(); |
| 4238 | } |
| 4239 | |
| 4240 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 4241 | public void setOnEmptySpaceClickListener(OnEmptySpaceClickListener listener) { |
| 4242 | mOnEmptySpaceClickListener = listener; |
| 4243 | } |
| 4244 | |
| 4245 | /** @hide */ |
| 4246 | @Override |
| 4247 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 4248 | public boolean performAccessibilityActionInternal(int action, Bundle arguments) { |
| 4249 | if (super.performAccessibilityActionInternal(action, arguments)) { |
| 4250 | return true; |
| 4251 | } |
| 4252 | if (!isEnabled()) { |
| 4253 | return false; |
| 4254 | } |
| 4255 | int direction = -1; |
| 4256 | switch (action) { |
| 4257 | case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: |
| 4258 | // fall through |
| 4259 | case android.R.id.accessibilityActionScrollDown: |
| 4260 | direction = 1; |
| 4261 | // fall through |
| 4262 | case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: |
| 4263 | // fall through |
| 4264 | case android.R.id.accessibilityActionScrollUp: |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 4265 | if (ANCHOR_SCROLLING) { |
| 4266 | // TODO |
| 4267 | } else { |
| 4268 | final int viewportHeight = |
| 4269 | getHeight() - mPaddingBottom - mTopPadding - mPaddingTop |
| 4270 | - mShelf.getIntrinsicHeight(); |
| 4271 | final int targetScrollY = Math.max(0, |
| 4272 | Math.min(mOwnScrollY + direction * viewportHeight, getScrollRange())); |
| 4273 | if (targetScrollY != mOwnScrollY) { |
| 4274 | mScroller.startScroll(mScrollX, mOwnScrollY, 0, |
| 4275 | targetScrollY - mOwnScrollY); |
| 4276 | animateScroll(); |
| 4277 | return true; |
| 4278 | } |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 4279 | } |
| 4280 | break; |
| 4281 | } |
| 4282 | return false; |
| 4283 | } |
| 4284 | |
| 4285 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 4286 | public void closeControlsIfOutsideTouch(MotionEvent ev) { |
| 4287 | NotificationGuts guts = mNotificationGutsManager.getExposedGuts(); |
| 4288 | NotificationMenuRowPlugin menuRow = mSwipeHelper.getCurrentMenuRow(); |
| 4289 | View translatingParentView = mSwipeHelper.getTranslatingParentView(); |
| 4290 | View view = null; |
| 4291 | if (guts != null && !guts.getGutsContent().isLeavebehind()) { |
| 4292 | // Only close visible guts if they're not a leavebehind. |
| 4293 | view = guts; |
| 4294 | } else if (menuRow != null && menuRow.isMenuVisible() |
| 4295 | && translatingParentView != null) { |
| 4296 | // Checking menu |
| 4297 | view = translatingParentView; |
| 4298 | } |
| 4299 | if (view != null && !NotificationSwipeHelper.isTouchInView(ev, view)) { |
| 4300 | // Touch was outside visible guts / menu notification, close what's visible |
| 4301 | mNotificationGutsManager.closeAndSaveGuts(false /* removeLeavebehind */, |
| 4302 | false /* force */, true /* removeControls */, -1 /* x */, -1 /* y */, |
| 4303 | false /* resetMenu */); |
| 4304 | resetExposedMenuView(true /* animate */, true /* force */); |
| 4305 | } |
| 4306 | } |
| 4307 | |
Aaron Heuckroth | 9dc9d4f | 2018-11-15 11:04:01 -0500 | [diff] [blame] | 4308 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 4309 | private void setSwipingInProgress(boolean swiping) { |
| 4310 | mSwipingInProgress = swiping; |
| 4311 | if (swiping) { |
| 4312 | requestDisallowInterceptTouchEvent(true); |
| 4313 | } |
| 4314 | } |
| 4315 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4316 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4317 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4318 | public void onWindowFocusChanged(boolean hasWindowFocus) { |
| 4319 | super.onWindowFocusChanged(hasWindowFocus); |
| 4320 | if (!hasWindowFocus) { |
Geoffrey Pitsch | 409db27 | 2017-08-28 14:51:52 +0000 | [diff] [blame] | 4321 | cancelLongPress(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 4322 | } |
| 4323 | } |
Selim Cinek | fab078b | 2014-03-27 22:45:58 +0100 | [diff] [blame] | 4324 | |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 4325 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4326 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 4327 | public void clearChildFocus(View child) { |
| 4328 | super.clearChildFocus(child); |
| 4329 | if (mForcedScroll == child) { |
| 4330 | mForcedScroll = null; |
| 4331 | } |
| 4332 | } |
| 4333 | |
Selim Cinek | fab078b | 2014-03-27 22:45:58 +0100 | [diff] [blame] | 4334 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4335 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | fab078b | 2014-03-27 22:45:58 +0100 | [diff] [blame] | 4336 | public boolean isScrolledToTop() { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 4337 | if (ANCHOR_SCROLLING) { |
| 4338 | updateScrollAnchor(); |
| 4339 | // TODO: once we're recycling this will need to check the adapter position of the child |
| 4340 | return mScrollAnchorView == getFirstChildNotGone() && mScrollAnchorViewY >= 0; |
| 4341 | } else { |
| 4342 | return mOwnScrollY == 0; |
| 4343 | } |
Selim Cinek | fab078b | 2014-03-27 22:45:58 +0100 | [diff] [blame] | 4344 | } |
| 4345 | |
| 4346 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4347 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 4348 | public boolean isScrolledToBottom() { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 4349 | if (ANCHOR_SCROLLING) { |
Gus Prevas | cdc9834 | 2019-01-14 14:29:44 -0500 | [diff] [blame] | 4350 | return getMaxPositiveScrollAmount() <= 0; |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 4351 | } else { |
| 4352 | return mOwnScrollY >= getScrollRange(); |
| 4353 | } |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 4354 | } |
| 4355 | |
| 4356 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4357 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | fab078b | 2014-03-27 22:45:58 +0100 | [diff] [blame] | 4358 | public View getHostView() { |
| 4359 | return this; |
| 4360 | } |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 4361 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4362 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 4363 | public int getEmptyBottomMargin() { |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 4364 | return Math.max(mMaxLayoutHeight - mContentHeight, 0); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 4365 | } |
| 4366 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4367 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Mady Mellor | c2dbe49 | 2017-03-30 13:22:03 -0700 | [diff] [blame] | 4368 | public void checkSnoozeLeavebehind() { |
| 4369 | if (mCheckForLeavebehind) { |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 4370 | mNotificationGutsManager.closeAndSaveGuts(true /* removeLeavebehind */, |
Eliot Courtney | 47098cb | 2017-10-18 17:30:30 +0900 | [diff] [blame] | 4371 | false /* force */, false /* removeControls */, -1 /* x */, -1 /* y */, |
| 4372 | false /* resetMenu */); |
Mady Mellor | c2dbe49 | 2017-03-30 13:22:03 -0700 | [diff] [blame] | 4373 | mCheckForLeavebehind = false; |
| 4374 | } |
| 4375 | } |
| 4376 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4377 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Mady Mellor | c2dbe49 | 2017-03-30 13:22:03 -0700 | [diff] [blame] | 4378 | public void resetCheckSnoozeLeavebehind() { |
| 4379 | mCheckForLeavebehind = true; |
| 4380 | } |
| 4381 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4382 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 4383 | public void onExpansionStarted() { |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 4384 | mIsExpansionChanging = true; |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 4385 | mAmbientState.setExpansionChanging(true); |
Mady Mellor | c2dbe49 | 2017-03-30 13:22:03 -0700 | [diff] [blame] | 4386 | checkSnoozeLeavebehind(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 4387 | } |
| 4388 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4389 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 4390 | public void onExpansionStopped() { |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 4391 | mIsExpansionChanging = false; |
Mady Mellor | c2dbe49 | 2017-03-30 13:22:03 -0700 | [diff] [blame] | 4392 | resetCheckSnoozeLeavebehind(); |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 4393 | mAmbientState.setExpansionChanging(false); |
Selim Cinek | 4fe3e47 | 2014-07-03 16:32:54 +0200 | [diff] [blame] | 4394 | if (!mIsExpanded) { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 4395 | resetScrollPosition(); |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 4396 | mStatusBar.resetUserExpandedStates(); |
Selim Cinek | 5b1591a | 2017-07-03 17:05:01 +0200 | [diff] [blame] | 4397 | clearTemporaryViews(); |
| 4398 | clearUserLockedViews(); |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 4399 | ArrayList<ExpandableView> draggedViews = mAmbientState.getDraggedViews(); |
Selim Cinek | d4c3230 | 2018-11-19 19:43:14 -0800 | [diff] [blame] | 4400 | if (draggedViews.size() > 0) { |
| 4401 | draggedViews.clear(); |
| 4402 | updateContinuousShadowDrawing(); |
| 4403 | } |
Selim Cinek | 5b1591a | 2017-07-03 17:05:01 +0200 | [diff] [blame] | 4404 | } |
| 4405 | } |
Selim Cinek | f336f4c | 2014-11-12 16:58:16 +0100 | [diff] [blame] | 4406 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4407 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 5b1591a | 2017-07-03 17:05:01 +0200 | [diff] [blame] | 4408 | private void clearUserLockedViews() { |
| 4409 | for (int i = 0; i < getChildCount(); i++) { |
| 4410 | ExpandableView child = (ExpandableView) getChildAt(i); |
| 4411 | if (child instanceof ExpandableNotificationRow) { |
| 4412 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 4413 | row.setUserLocked(false); |
| 4414 | } |
| 4415 | } |
| 4416 | } |
| 4417 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4418 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 5b1591a | 2017-07-03 17:05:01 +0200 | [diff] [blame] | 4419 | private void clearTemporaryViews() { |
Selim Cinek | 9dd0d04 | 2018-05-14 18:12:42 -0700 | [diff] [blame] | 4420 | // lets make sure nothing is transient anymore |
Rohan Shah | 8ee5365 | 2018-04-05 11:13:50 -0700 | [diff] [blame] | 4421 | clearTemporaryViewsInGroup(this); |
Selim Cinek | 5b1591a | 2017-07-03 17:05:01 +0200 | [diff] [blame] | 4422 | for (int i = 0; i < getChildCount(); i++) { |
| 4423 | ExpandableView child = (ExpandableView) getChildAt(i); |
| 4424 | if (child instanceof ExpandableNotificationRow) { |
| 4425 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
Rohan Shah | 8ee5365 | 2018-04-05 11:13:50 -0700 | [diff] [blame] | 4426 | clearTemporaryViewsInGroup(row.getChildrenContainer()); |
Selim Cinek | d139564 | 2016-04-28 12:22:42 -0700 | [diff] [blame] | 4427 | } |
Selim Cinek | 4fe3e47 | 2014-07-03 16:32:54 +0200 | [diff] [blame] | 4428 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 4429 | } |
| 4430 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4431 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Rohan Shah | 8ee5365 | 2018-04-05 11:13:50 -0700 | [diff] [blame] | 4432 | private void clearTemporaryViewsInGroup(ViewGroup viewGroup) { |
Selim Cinek | d139564 | 2016-04-28 12:22:42 -0700 | [diff] [blame] | 4433 | while (viewGroup != null && viewGroup.getTransientViewCount() != 0) { |
Selim Cinek | 81f26d3 | 2016-05-09 18:54:10 -0400 | [diff] [blame] | 4434 | viewGroup.removeTransientView(viewGroup.getTransientView(0)); |
Selim Cinek | d139564 | 2016-04-28 12:22:42 -0700 | [diff] [blame] | 4435 | } |
| 4436 | } |
| 4437 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4438 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Jorim Jaggi | e4b840d | 2015-06-30 16:19:17 -0700 | [diff] [blame] | 4439 | public void onPanelTrackingStarted() { |
| 4440 | mPanelTracking = true; |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 4441 | mAmbientState.setPanelTracking(true); |
Gus Prevas | 99ba4ba | 2018-10-01 16:40:23 -0400 | [diff] [blame] | 4442 | resetExposedMenuView(true /* animate */, true /* force */); |
Jorim Jaggi | e4b840d | 2015-06-30 16:19:17 -0700 | [diff] [blame] | 4443 | } |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 4444 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4445 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Jorim Jaggi | e4b840d | 2015-06-30 16:19:17 -0700 | [diff] [blame] | 4446 | public void onPanelTrackingStopped() { |
| 4447 | mPanelTracking = false; |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 4448 | mAmbientState.setPanelTracking(false); |
Jorim Jaggi | e4b840d | 2015-06-30 16:19:17 -0700 | [diff] [blame] | 4449 | } |
| 4450 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4451 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | b24e0a9 | 2015-06-09 20:17:30 -0700 | [diff] [blame] | 4452 | public void resetScrollPosition() { |
| 4453 | mScroller.abortAnimation(); |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 4454 | if (ANCHOR_SCROLLING) { |
| 4455 | // TODO: once we're recycling this will need to modify the adapter position instead |
| 4456 | mScrollAnchorView = getFirstChildNotGone(); |
| 4457 | mScrollAnchorViewY = 0; |
| 4458 | updateOnScrollChange(); |
| 4459 | } else { |
| 4460 | setOwnScrollY(0); |
| 4461 | } |
Selim Cinek | b24e0a9 | 2015-06-09 20:17:30 -0700 | [diff] [blame] | 4462 | } |
| 4463 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4464 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 4465 | public void setIsExpanded(boolean isExpanded) { |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 4466 | boolean changed = isExpanded != mIsExpanded; |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 4467 | mIsExpanded = isExpanded; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 4468 | mStackScrollAlgorithm.setIsExpanded(isExpanded); |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 4469 | if (changed) { |
Selim Cinek | 9184f9c | 2016-02-02 17:36:53 -0800 | [diff] [blame] | 4470 | if (!mIsExpanded) { |
| 4471 | mGroupManager.collapseAllGroups(); |
Selim Cinek | 5b1591a | 2017-07-03 17:05:01 +0200 | [diff] [blame] | 4472 | mExpandHelper.cancelImmediately(); |
Selim Cinek | 9184f9c | 2016-02-02 17:36:53 -0800 | [diff] [blame] | 4473 | } |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 4474 | updateNotificationAnimationStates(); |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 4475 | updateChronometers(); |
Selim Cinek | f3fa685 | 2016-12-20 18:36:02 +0100 | [diff] [blame] | 4476 | requestChildrenUpdate(); |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 4477 | } |
| 4478 | } |
| 4479 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4480 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 4481 | private void updateChronometers() { |
| 4482 | int childCount = getChildCount(); |
| 4483 | for (int i = 0; i < childCount; i++) { |
| 4484 | updateChronometerForChild(getChildAt(i)); |
| 4485 | } |
| 4486 | } |
| 4487 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4488 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 4489 | private void updateChronometerForChild(View child) { |
| 4490 | if (child instanceof ExpandableNotificationRow) { |
| 4491 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 4492 | row.setChronometerRunning(mIsExpanded); |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 4493 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 4494 | } |
| 4495 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 4496 | @Override |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 4497 | public void onHeightChanged(ExpandableView view, boolean needsAnimation) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4498 | updateContentHeight(); |
Selim Cinek | f7a14c0 | 2014-07-07 14:01:46 +0200 | [diff] [blame] | 4499 | updateScrollPositionOnExpandInBottom(view); |
| 4500 | clampScrollPosition(); |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 4501 | notifyHeightChangeListener(view, needsAnimation); |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 4502 | ExpandableNotificationRow row = view instanceof ExpandableNotificationRow |
| 4503 | ? (ExpandableNotificationRow) view |
| 4504 | : null; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 4505 | NotificationSection firstSection = getFirstVisibleSection(); |
| 4506 | ActivatableNotificationView firstVisibleChild = |
| 4507 | firstSection == null ? null : firstSection.getFirstVisibleChild(); |
| 4508 | if (row != null) { |
| 4509 | if (row == firstVisibleChild |
| 4510 | || row.getNotificationParent() == firstVisibleChild) { |
| 4511 | updateAlgorithmLayoutMinHeight(); |
| 4512 | } |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 4513 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 4514 | if (needsAnimation) { |
Selim Cinek | 5bc852a | 2015-12-21 12:19:09 -0800 | [diff] [blame] | 4515 | requestAnimationOnViewResize(row); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 4516 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4517 | requestChildrenUpdate(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 4518 | } |
| 4519 | |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 4520 | @Override |
| 4521 | public void onReset(ExpandableView view) { |
Selim Cinek | 51ae05d | 2014-09-09 15:51:38 +0200 | [diff] [blame] | 4522 | updateAnimationState(view); |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 4523 | updateChronometerForChild(view); |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 4524 | } |
| 4525 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4526 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | f7a14c0 | 2014-07-07 14:01:46 +0200 | [diff] [blame] | 4527 | private void updateScrollPositionOnExpandInBottom(ExpandableView view) { |
Selim Cinek | 51d2197 | 2017-07-19 17:39:20 -0700 | [diff] [blame] | 4528 | if (view instanceof ExpandableNotificationRow && !onKeyguard()) { |
Selim Cinek | f7a14c0 | 2014-07-07 14:01:46 +0200 | [diff] [blame] | 4529 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 4530 | // TODO: once we're recycling this will need to check the adapter position of the child |
Selim Cinek | cb9400a | 2015-06-03 16:56:13 +0200 | [diff] [blame] | 4531 | if (row.isUserLocked() && row != getFirstChildNotGone()) { |
Selim Cinek | 4e4cac3 | 2016-03-11 16:45:52 -0800 | [diff] [blame] | 4532 | if (row.isSummaryWithChildren()) { |
| 4533 | return; |
| 4534 | } |
Selim Cinek | f7a14c0 | 2014-07-07 14:01:46 +0200 | [diff] [blame] | 4535 | // We are actually expanding this view |
Selim Cinek | 4e4cac3 | 2016-03-11 16:45:52 -0800 | [diff] [blame] | 4536 | float endPosition = row.getTranslationY() + row.getActualHeight(); |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 4537 | if (row.isChildInGroup()) { |
Selim Cinek | 4e4cac3 | 2016-03-11 16:45:52 -0800 | [diff] [blame] | 4538 | endPosition += row.getNotificationParent().getTranslationY(); |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 4539 | } |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 4540 | int layoutEnd = mMaxLayoutHeight + (int) mStackTranslation; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 4541 | NotificationSection lastSection = getLastVisibleSection(); |
| 4542 | ActivatableNotificationView lastVisibleChild = |
| 4543 | lastSection == null ? null : lastSection.getLastVisibleChild(); |
| 4544 | if (row != lastVisibleChild && mShelf.getVisibility() != GONE) { |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 4545 | layoutEnd -= mShelf.getIntrinsicHeight() + mPaddingBetweenElements; |
| 4546 | } |
| 4547 | if (endPosition > layoutEnd) { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 4548 | if (ANCHOR_SCROLLING) { |
| 4549 | mScrollAnchorViewY -= (endPosition - layoutEnd); |
| 4550 | updateScrollAnchor(); |
| 4551 | updateOnScrollChange(); |
| 4552 | } else { |
| 4553 | setOwnScrollY((int) (mOwnScrollY + endPosition - layoutEnd)); |
| 4554 | } |
Selim Cinek | f7a14c0 | 2014-07-07 14:01:46 +0200 | [diff] [blame] | 4555 | mDisallowScrollingInThisMotion = true; |
| 4556 | } |
| 4557 | } |
| 4558 | } |
| 4559 | } |
| 4560 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4561 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 4562 | public void setOnHeightChangedListener( |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 4563 | ExpandableView.OnHeightChangedListener onHeightChangedListener) { |
| 4564 | this.mOnHeightChangedListener = onHeightChangedListener; |
Selim Cinek | 3a9c10a | 2014-10-28 14:21:10 +0100 | [diff] [blame] | 4565 | } |
| 4566 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4567 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 4568 | public void onChildAnimationFinished() { |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 4569 | setAnimationRunning(false); |
Selim Cinek | 319bdc4 | 2014-05-01 23:01:58 +0200 | [diff] [blame] | 4570 | requestChildrenUpdate(); |
Selim Cinek | 32a59fd3 | 2015-06-10 13:54:42 -0700 | [diff] [blame] | 4571 | runAnimationFinishedRunnables(); |
Selim Cinek | 9dd0d04 | 2018-05-14 18:12:42 -0700 | [diff] [blame] | 4572 | clearTransient(); |
Selim Cinek | 8fc7875 | 2016-07-13 14:34:56 -0700 | [diff] [blame] | 4573 | clearHeadsUpDisappearRunning(); |
| 4574 | } |
| 4575 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4576 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 8fc7875 | 2016-07-13 14:34:56 -0700 | [diff] [blame] | 4577 | private void clearHeadsUpDisappearRunning() { |
| 4578 | for (int i = 0; i < getChildCount(); i++) { |
| 4579 | View view = getChildAt(i); |
| 4580 | if (view instanceof ExpandableNotificationRow) { |
Selim Cinek | 76e813c | 2016-07-14 11:16:58 -0700 | [diff] [blame] | 4581 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 4582 | row.setHeadsUpAnimatingAway(false); |
Selim Cinek | 76e813c | 2016-07-14 11:16:58 -0700 | [diff] [blame] | 4583 | if (row.isSummaryWithChildren()) { |
| 4584 | for (ExpandableNotificationRow child : row.getNotificationChildren()) { |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 4585 | child.setHeadsUpAnimatingAway(false); |
Selim Cinek | 76e813c | 2016-07-14 11:16:58 -0700 | [diff] [blame] | 4586 | } |
| 4587 | } |
Selim Cinek | 8fc7875 | 2016-07-13 14:34:56 -0700 | [diff] [blame] | 4588 | } |
| 4589 | } |
Selim Cinek | 0fccc72 | 2015-07-29 17:04:36 -0700 | [diff] [blame] | 4590 | } |
| 4591 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4592 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 9dd0d04 | 2018-05-14 18:12:42 -0700 | [diff] [blame] | 4593 | private void clearTransient() { |
| 4594 | for (ExpandableView view : mClearTransientViewsWhenFinished) { |
| 4595 | StackStateAnimator.removeTransientView(view); |
Selim Cinek | 0fccc72 | 2015-07-29 17:04:36 -0700 | [diff] [blame] | 4596 | } |
Selim Cinek | 9dd0d04 | 2018-05-14 18:12:42 -0700 | [diff] [blame] | 4597 | mClearTransientViewsWhenFinished.clear(); |
Selim Cinek | 32a59fd3 | 2015-06-10 13:54:42 -0700 | [diff] [blame] | 4598 | } |
| 4599 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4600 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 32a59fd3 | 2015-06-10 13:54:42 -0700 | [diff] [blame] | 4601 | private void runAnimationFinishedRunnables() { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 4602 | for (Runnable runnable : mAnimationFinishedRunnables) { |
| 4603 | runnable.run(); |
| 4604 | } |
| 4605 | mAnimationFinishedRunnables.clear(); |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 4606 | } |
| 4607 | |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4608 | /** |
| 4609 | * See {@link AmbientState#setDimmed}. |
| 4610 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4611 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4612 | public void setDimmed(boolean dimmed, boolean animate) { |
Selim Cinek | 8a9308d | 2017-08-24 09:31:08 -0700 | [diff] [blame] | 4613 | dimmed &= onKeyguard(); |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4614 | mAmbientState.setDimmed(dimmed); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4615 | if (animate && mAnimationsEnabled) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4616 | mDimmedNeedsAnimation = true; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 4617 | mNeedsAnimation = true; |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 4618 | animateDimmed(dimmed); |
| 4619 | } else { |
| 4620 | setDimAmount(dimmed ? 1.0f : 0.0f); |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4621 | } |
| 4622 | requestChildrenUpdate(); |
| 4623 | } |
| 4624 | |
Selim Cinek | 8a9308d | 2017-08-24 09:31:08 -0700 | [diff] [blame] | 4625 | @VisibleForTesting |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4626 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 8a9308d | 2017-08-24 09:31:08 -0700 | [diff] [blame] | 4627 | boolean isDimmed() { |
| 4628 | return mAmbientState.isDimmed(); |
| 4629 | } |
| 4630 | |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 4631 | @VisibleForTesting |
| 4632 | int getSectionBoundaryIndex(int boundaryNum) { |
| 4633 | return mAmbientState.getSectionBoundaryIndex(boundaryNum); |
| 4634 | } |
| 4635 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4636 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 4637 | private void setDimAmount(float dimAmount) { |
| 4638 | mDimAmount = dimAmount; |
| 4639 | updateBackgroundDimming(); |
| 4640 | } |
| 4641 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4642 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 4643 | private void animateDimmed(boolean dimmed) { |
| 4644 | if (mDimAnimator != null) { |
| 4645 | mDimAnimator.cancel(); |
| 4646 | } |
| 4647 | float target = dimmed ? 1.0f : 0.0f; |
| 4648 | if (target == mDimAmount) { |
| 4649 | return; |
| 4650 | } |
| 4651 | mDimAnimator = TimeAnimator.ofFloat(mDimAmount, target); |
| 4652 | mDimAnimator.setDuration(StackStateAnimator.ANIMATION_DURATION_DIMMED_ACTIVATED); |
| 4653 | mDimAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); |
| 4654 | mDimAnimator.addListener(mDimEndListener); |
| 4655 | mDimAnimator.addUpdateListener(mDimUpdateListener); |
| 4656 | mDimAnimator.start(); |
| 4657 | } |
Evan Laird | 91d0f10 | 2018-09-18 17:39:55 -0400 | [diff] [blame] | 4658 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4659 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Evan Laird | 91d0f10 | 2018-09-18 17:39:55 -0400 | [diff] [blame] | 4660 | private void setHideSensitive(boolean hideSensitive, boolean animate) { |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 4661 | if (hideSensitive != mAmbientState.isHideSensitive()) { |
| 4662 | int childCount = getChildCount(); |
| 4663 | for (int i = 0; i < childCount; i++) { |
| 4664 | ExpandableView v = (ExpandableView) getChildAt(i); |
| 4665 | v.setHideSensitiveForIntrinsicHeight(hideSensitive); |
| 4666 | } |
| 4667 | mAmbientState.setHideSensitive(hideSensitive); |
| 4668 | if (animate && mAnimationsEnabled) { |
| 4669 | mHideSensitiveNeedsAnimation = true; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 4670 | mNeedsAnimation = true; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 4671 | } |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 4672 | updateContentHeight(); |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 4673 | requestChildrenUpdate(); |
| 4674 | } |
| 4675 | } |
| 4676 | |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4677 | /** |
| 4678 | * See {@link AmbientState#setActivatedChild}. |
| 4679 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4680 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 4681 | public void setActivatedChild(ActivatableNotificationView activatedChild) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4682 | mAmbientState.setActivatedChild(activatedChild); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4683 | if (mAnimationsEnabled) { |
| 4684 | mActivateNeedsAnimation = true; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 4685 | mNeedsAnimation = true; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4686 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4687 | requestChildrenUpdate(); |
| 4688 | } |
| 4689 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4690 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 4691 | public ActivatableNotificationView getActivatedChild() { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4692 | return mAmbientState.getActivatedChild(); |
| 4693 | } |
| 4694 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4695 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 4696 | private void applyCurrentState() { |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 4697 | int numChildren = getChildCount(); |
| 4698 | for (int i = 0; i < numChildren; i++) { |
| 4699 | ExpandableView child = (ExpandableView) getChildAt(i); |
| 4700 | child.applyViewState(); |
| 4701 | } |
| 4702 | |
Selim Cinek | f4c1996 | 2014-05-01 21:55:31 +0200 | [diff] [blame] | 4703 | if (mListener != null) { |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 4704 | mListener.onChildLocationsChanged(); |
Selim Cinek | f4c1996 | 2014-05-01 21:55:31 +0200 | [diff] [blame] | 4705 | } |
Selim Cinek | 32a59fd3 | 2015-06-10 13:54:42 -0700 | [diff] [blame] | 4706 | runAnimationFinishedRunnables(); |
Selim Cinek | ea66ca0 | 2016-05-24 13:33:47 -0700 | [diff] [blame] | 4707 | setAnimationRunning(false); |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 4708 | updateBackground(); |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 4709 | updateViewShadows(); |
Selim Cinek | b0ee18f | 2017-12-21 16:15:53 -0800 | [diff] [blame] | 4710 | updateClippingToTopRoundedCorner(); |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 4711 | } |
| 4712 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4713 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 4714 | private void updateViewShadows() { |
| 4715 | // we need to work around an issue where the shadow would not cast between siblings when |
| 4716 | // their z difference is between 0 and 0.1 |
| 4717 | |
| 4718 | // Lefts first sort by Z difference |
| 4719 | for (int i = 0; i < getChildCount(); i++) { |
| 4720 | ExpandableView child = (ExpandableView) getChildAt(i); |
| 4721 | if (child.getVisibility() != GONE) { |
| 4722 | mTmpSortedChildren.add(child); |
| 4723 | } |
| 4724 | } |
| 4725 | Collections.sort(mTmpSortedChildren, mViewPositionComparator); |
| 4726 | |
| 4727 | // Now lets update the shadow for the views |
| 4728 | ExpandableView previous = null; |
| 4729 | for (int i = 0; i < mTmpSortedChildren.size(); i++) { |
| 4730 | ExpandableView expandableView = mTmpSortedChildren.get(i); |
| 4731 | float translationZ = expandableView.getTranslationZ(); |
| 4732 | float otherZ = previous == null ? translationZ : previous.getTranslationZ(); |
| 4733 | float diff = otherZ - translationZ; |
| 4734 | if (diff <= 0.0f || diff >= FakeShadowView.SHADOW_SIBLING_TRESHOLD) { |
| 4735 | // There is no fake shadow to be drawn |
| 4736 | expandableView.setFakeShadowIntensity(0.0f, 0.0f, 0, 0); |
| 4737 | } else { |
| 4738 | float yLocation = previous.getTranslationY() + previous.getActualHeight() - |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 4739 | expandableView.getTranslationY() - previous.getExtraBottomPadding(); |
| 4740 | expandableView.setFakeShadowIntensity( |
| 4741 | diff / FakeShadowView.SHADOW_SIBLING_TRESHOLD, |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 4742 | previous.getOutlineAlpha(), (int) yLocation, |
| 4743 | previous.getOutlineTranslation()); |
| 4744 | } |
| 4745 | previous = expandableView; |
| 4746 | } |
| 4747 | |
| 4748 | mTmpSortedChildren.clear(); |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 4749 | } |
| 4750 | |
Lucas Dupin | e17ce52 | 2017-07-17 15:45:06 -0700 | [diff] [blame] | 4751 | /** |
| 4752 | * Update colors of "dismiss" and "empty shade" views. |
| 4753 | * |
| 4754 | * @param lightTheme True if light theme should be used. |
| 4755 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4756 | @ShadeViewRefactor(RefactorComponent.DECORATOR) |
Lucas Dupin | e17ce52 | 2017-07-17 15:45:06 -0700 | [diff] [blame] | 4757 | public void updateDecorViews(boolean lightTheme) { |
| 4758 | if (lightTheme == mUsingLightTheme) { |
| 4759 | return; |
| 4760 | } |
| 4761 | mUsingLightTheme = lightTheme; |
| 4762 | Context context = new ContextThemeWrapper(mContext, |
| 4763 | lightTheme ? R.style.Theme_SystemUI_Light : R.style.Theme_SystemUI); |
Jason Chang | b4e879d | 2018-04-11 11:17:58 +0800 | [diff] [blame] | 4764 | final int textColor = Utils.getColorAttrDefaultColor(context, R.attr.wallpaperTextColor); |
Julia Reynolds | ed1c9af | 2018-03-21 15:21:09 -0400 | [diff] [blame] | 4765 | mFooterView.setTextColor(textColor); |
Lucas Dupin | e17ce52 | 2017-07-17 15:45:06 -0700 | [diff] [blame] | 4766 | mEmptyShadeView.setTextColor(textColor); |
| 4767 | } |
| 4768 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4769 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4770 | public void goToFullShade(long delay) { |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 4771 | mGoToFullShadeNeedsAnimation = true; |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4772 | mGoToFullShadeDelay = delay; |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 4773 | mNeedsAnimation = true; |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 4774 | requestChildrenUpdate(); |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 4775 | } |
| 4776 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4777 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4778 | public void cancelExpandHelper() { |
| 4779 | mExpandHelper.cancel(); |
| 4780 | } |
| 4781 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4782 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4783 | public void setIntrinsicPadding(int intrinsicPadding) { |
| 4784 | mIntrinsicPadding = intrinsicPadding; |
Selim Cinek | 1f62495 | 2017-06-08 19:11:50 -0700 | [diff] [blame] | 4785 | mAmbientState.setIntrinsicPadding(intrinsicPadding); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4786 | } |
| 4787 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4788 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Jorim Jaggi | 30c305c | 2014-07-01 23:34:41 +0200 | [diff] [blame] | 4789 | public int getIntrinsicPadding() { |
| 4790 | return mIntrinsicPadding; |
| 4791 | } |
| 4792 | |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 4793 | /** |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 4794 | * @return the y position of the first notification |
| 4795 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4796 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 4797 | public float getNotificationsTopY() { |
Selim Cinek | d228115 | 2015-04-10 14:37:46 -0700 | [diff] [blame] | 4798 | return mTopPadding + getStackTranslation(); |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 4799 | } |
| 4800 | |
Selim Cinek | c0ce82d | 2014-06-10 13:21:15 +0200 | [diff] [blame] | 4801 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4802 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | c0ce82d | 2014-06-10 13:21:15 +0200 | [diff] [blame] | 4803 | public boolean shouldDelayChildPressedState() { |
| 4804 | return true; |
| 4805 | } |
| 4806 | |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 4807 | /** |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4808 | * See {@link AmbientState#setDark}. |
| 4809 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4810 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 4811 | public void setDark(boolean dark, boolean animate, @Nullable PointF touchWakeUpScreenLocation) { |
Adrian Roos | 260c1f7 | 2017-08-07 15:52:26 +0200 | [diff] [blame] | 4812 | if (mAmbientState.isDark() == dark) { |
| 4813 | return; |
| 4814 | } |
Lucas Dupin | 7fc9dc1 | 2019-01-03 09:19:43 -0800 | [diff] [blame] | 4815 | if (!dark) { |
| 4816 | mShowDarkShelf = false; |
| 4817 | } |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4818 | mAmbientState.setDark(dark); |
| 4819 | if (animate && mAnimationsEnabled) { |
| 4820 | mDarkNeedsAnimation = true; |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 4821 | mDarkAnimationOriginIndex = findDarkAnimationOriginIndex(touchWakeUpScreenLocation); |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 4822 | mNeedsAnimation = true; |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 4823 | } else { |
Lucas Dupin | 8e9fa2d | 2018-01-29 15:36:35 -0800 | [diff] [blame] | 4824 | setDarkAmount(dark ? 1f : 0f); |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 4825 | updateBackground(); |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 4826 | } |
Lucas Dupin | 8e9fa2d | 2018-01-29 15:36:35 -0800 | [diff] [blame] | 4827 | requestChildrenUpdate(); |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 4828 | updateWillNotDraw(); |
Adrian Roos | 7a9551a | 2017-01-11 12:27:49 -0800 | [diff] [blame] | 4829 | notifyHeightChangeListener(mShelf); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4830 | } |
| 4831 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4832 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Bill Lin | e60aa1e | 2018-06-13 18:07:15 +0800 | [diff] [blame] | 4833 | private void updatePanelTranslation() { |
Lucas Dupin | b46d0a2 | 2019-01-11 16:57:16 -0800 | [diff] [blame] | 4834 | setTranslationX(mHorizontalPanelTranslation + mAntiBurnInOffsetX * mInterpolatedDarkAmount); |
Bill Lin | e60aa1e | 2018-06-13 18:07:15 +0800 | [diff] [blame] | 4835 | } |
| 4836 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4837 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Lucas Dupin | b46d0a2 | 2019-01-11 16:57:16 -0800 | [diff] [blame] | 4838 | public void setHorizontalPanelTranslation(float verticalPanelTranslation) { |
| 4839 | mHorizontalPanelTranslation = verticalPanelTranslation; |
Bill Lin | e60aa1e | 2018-06-13 18:07:15 +0800 | [diff] [blame] | 4840 | updatePanelTranslation(); |
Lucas Dupin | 0cd882f | 2018-01-30 12:19:49 -0800 | [diff] [blame] | 4841 | } |
| 4842 | |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 4843 | /** |
| 4844 | * Updates whether or not this Layout will perform its own custom drawing (i.e. whether or |
| 4845 | * not {@link #onDraw(Canvas)} is called). This method should be called whenever the |
| 4846 | * {@link #mAmbientState}'s dark mode is toggled. |
| 4847 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4848 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 4849 | private void updateWillNotDraw() { |
Lucas Dupin | d285cf0 | 2018-01-18 09:18:23 -0800 | [diff] [blame] | 4850 | boolean willDraw = mShouldDrawNotificationBackground || DEBUG; |
Adrian Roos | f0b4f96 | 2017-05-25 11:53:11 -0700 | [diff] [blame] | 4851 | setWillNotDraw(!willDraw); |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 4852 | } |
| 4853 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4854 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Lucas Dupin | d285cf0 | 2018-01-18 09:18:23 -0800 | [diff] [blame] | 4855 | private void setDarkAmount(float darkAmount) { |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 4856 | setDarkAmount(darkAmount, darkAmount); |
| 4857 | } |
| 4858 | |
| 4859 | /** |
| 4860 | * Sets the current dark amount. |
| 4861 | * |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 4862 | * @param linearDarkAmount The dark amount that follows linear interpoloation in the |
| 4863 | * animation, |
| 4864 | * i.e. animates from 0 to 1 or vice-versa in a linear manner. |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 4865 | * @param interpolatedDarkAmount The dark amount that follows the actual interpolation of the |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 4866 | * animation curve. |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 4867 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4868 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 4869 | public void setDarkAmount(float linearDarkAmount, float interpolatedDarkAmount) { |
| 4870 | mLinearDarkAmount = linearDarkAmount; |
| 4871 | mInterpolatedDarkAmount = interpolatedDarkAmount; |
Lucas Dupin | b561eda | 2018-04-09 17:25:04 -0700 | [diff] [blame] | 4872 | boolean wasFullyDark = mAmbientState.isFullyDark(); |
Gus Prevas | 99ba4ba | 2018-10-01 16:40:23 -0400 | [diff] [blame] | 4873 | boolean wasDarkAtAll = mAmbientState.isDarkAtAll(); |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 4874 | mAmbientState.setDarkAmount(interpolatedDarkAmount); |
Selim Cinek | 9bfc7a5 | 2018-06-11 16:09:00 -0700 | [diff] [blame] | 4875 | boolean nowFullyDark = mAmbientState.isFullyDark(); |
Gus Prevas | 99ba4ba | 2018-10-01 16:40:23 -0400 | [diff] [blame] | 4876 | boolean nowDarkAtAll = mAmbientState.isDarkAtAll(); |
Selim Cinek | 9bfc7a5 | 2018-06-11 16:09:00 -0700 | [diff] [blame] | 4877 | if (nowFullyDark != wasFullyDark) { |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 4878 | updateContentHeight(); |
Lucas Dupin | 7fc9dc1 | 2019-01-03 09:19:43 -0800 | [diff] [blame] | 4879 | if (nowFullyDark && mShowDarkShelf) { |
| 4880 | updateDarkShelfVisibility(); |
| 4881 | } |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 4882 | } |
Gus Prevas | 99ba4ba | 2018-10-01 16:40:23 -0400 | [diff] [blame] | 4883 | if (!wasDarkAtAll && nowDarkAtAll) { |
| 4884 | resetExposedMenuView(true /* animate */, true /* animate */); |
| 4885 | } |
Lucas Dupin | 60661a6 | 2018-04-12 10:50:13 -0700 | [diff] [blame] | 4886 | updateAlgorithmHeightAndPadding(); |
Selim Cinek | 972123d | 2016-05-03 14:25:58 -0700 | [diff] [blame] | 4887 | updateBackgroundDimming(); |
Bill Lin | e60aa1e | 2018-06-13 18:07:15 +0800 | [diff] [blame] | 4888 | updatePanelTranslation(); |
Lucas Dupin | b561eda | 2018-04-09 17:25:04 -0700 | [diff] [blame] | 4889 | requestChildrenUpdate(); |
Selim Cinek | 972123d | 2016-05-03 14:25:58 -0700 | [diff] [blame] | 4890 | } |
| 4891 | |
Lucas Dupin | 7fc9dc1 | 2019-01-03 09:19:43 -0800 | [diff] [blame] | 4892 | /** |
| 4893 | * If the shelf should be visible when the device is in ambient mode (dozing.) |
| 4894 | */ |
| 4895 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
| 4896 | public void setShowDarkShelf(boolean showDarkShelf) { |
| 4897 | mShowDarkShelf = showDarkShelf; |
| 4898 | } |
| 4899 | |
| 4900 | private void updateDarkShelfVisibility() { |
| 4901 | DozeParameters dozeParameters = DozeParameters.getInstance(mContext); |
| 4902 | if (dozeParameters.shouldControlScreenOff()) { |
| 4903 | mShelf.fadeInTranslating(); |
| 4904 | } |
| 4905 | updateClipping(); |
| 4906 | } |
| 4907 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4908 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Jorim Jaggi | c4cf07a | 2018-07-05 18:28:12 +0200 | [diff] [blame] | 4909 | public void notifyDarkAnimationStart(boolean dark) { |
| 4910 | // We only swap the scaling factor if we're fully dark or fully awake to avoid |
| 4911 | // interpolation issues when playing with the power button. |
| 4912 | if (mInterpolatedDarkAmount == 0 || mInterpolatedDarkAmount == 1) { |
| 4913 | mBackgroundXFactor = dark ? 1.8f : 1.5f; |
| 4914 | mDarkXInterpolator = dark |
| 4915 | ? Interpolators.FAST_OUT_SLOW_IN_REVERSE |
| 4916 | : Interpolators.FAST_OUT_SLOW_IN; |
| 4917 | } |
Selim Cinek | 972123d | 2016-05-03 14:25:58 -0700 | [diff] [blame] | 4918 | } |
| 4919 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4920 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 4921 | private int findDarkAnimationOriginIndex(@Nullable PointF screenLocation) { |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 4922 | if (screenLocation == null || screenLocation.y < mTopPadding) { |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 4923 | return AnimationEvent.DARK_ANIMATION_ORIGIN_INDEX_ABOVE; |
| 4924 | } |
| 4925 | if (screenLocation.y > getBottomMostNotificationBottom()) { |
| 4926 | return AnimationEvent.DARK_ANIMATION_ORIGIN_INDEX_BELOW; |
| 4927 | } |
| 4928 | View child = getClosestChildAtRawPosition(screenLocation.x, screenLocation.y); |
| 4929 | if (child != null) { |
| 4930 | return getNotGoneIndex(child); |
| 4931 | } else { |
| 4932 | return AnimationEvent.DARK_ANIMATION_ORIGIN_INDEX_ABOVE; |
| 4933 | } |
| 4934 | } |
| 4935 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4936 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 4937 | private int getNotGoneIndex(View child) { |
| 4938 | int count = getChildCount(); |
| 4939 | int notGoneIndex = 0; |
| 4940 | for (int i = 0; i < count; i++) { |
| 4941 | View v = getChildAt(i); |
| 4942 | if (child == v) { |
| 4943 | return notGoneIndex; |
| 4944 | } |
| 4945 | if (v.getVisibility() != View.GONE) { |
| 4946 | notGoneIndex++; |
| 4947 | } |
| 4948 | } |
| 4949 | return -1; |
| 4950 | } |
| 4951 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4952 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Julia Reynolds | ed1c9af | 2018-03-21 15:21:09 -0400 | [diff] [blame] | 4953 | public void setFooterView(@NonNull FooterView footerView) { |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 4954 | int index = -1; |
Julia Reynolds | ed1c9af | 2018-03-21 15:21:09 -0400 | [diff] [blame] | 4955 | if (mFooterView != null) { |
| 4956 | index = indexOfChild(mFooterView); |
| 4957 | removeView(mFooterView); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 4958 | } |
Julia Reynolds | ed1c9af | 2018-03-21 15:21:09 -0400 | [diff] [blame] | 4959 | mFooterView = footerView; |
| 4960 | addView(mFooterView, index); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 4961 | } |
| 4962 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4963 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 4964 | public void setEmptyShadeView(EmptyShadeView emptyShadeView) { |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 4965 | int index = -1; |
| 4966 | if (mEmptyShadeView != null) { |
| 4967 | index = indexOfChild(mEmptyShadeView); |
| 4968 | removeView(mEmptyShadeView); |
| 4969 | } |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 4970 | mEmptyShadeView = emptyShadeView; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 4971 | addView(mEmptyShadeView, index); |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 4972 | } |
| 4973 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4974 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 4975 | public void updateEmptyShadeView(boolean visible) { |
Selim Cinek | d60ef9e | 2018-05-16 16:01:05 -0700 | [diff] [blame] | 4976 | mEmptyShadeView.setVisible(visible, mIsExpanded && mAnimationsEnabled); |
Lucas Dupin | c9274ff | 2018-05-09 17:40:20 -0700 | [diff] [blame] | 4977 | |
| 4978 | int oldTextRes = mEmptyShadeView.getTextResource(); |
| 4979 | int newTextRes = mStatusBar.areNotificationsHidden() |
| 4980 | ? R.string.dnd_suppressing_shade_text : R.string.empty_shade_text; |
| 4981 | if (oldTextRes != newTextRes) { |
| 4982 | mEmptyShadeView.setText(newTextRes); |
| 4983 | } |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 4984 | } |
| 4985 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4986 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Julia Reynolds | ed1c9af | 2018-03-21 15:21:09 -0400 | [diff] [blame] | 4987 | public void updateFooterView(boolean visible, boolean showDismissView) { |
| 4988 | if (mFooterView == null) { |
Anthony Chen | 5e3742e | 2017-04-07 14:28:44 -0700 | [diff] [blame] | 4989 | return; |
| 4990 | } |
Selim Cinek | d60ef9e | 2018-05-16 16:01:05 -0700 | [diff] [blame] | 4991 | boolean animate = mIsExpanded && mAnimationsEnabled; |
| 4992 | mFooterView.setVisible(visible, animate); |
| 4993 | mFooterView.setSecondaryVisible(showDismissView, animate); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 4994 | } |
| 4995 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 4996 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 4997 | public void setDismissAllInProgress(boolean dismissAllInProgress) { |
| 4998 | mDismissAllInProgress = dismissAllInProgress; |
Selim Cinek | 9c17b77 | 2015-07-07 20:37:09 -0700 | [diff] [blame] | 4999 | mAmbientState.setDismissAllInProgress(dismissAllInProgress); |
Selim Cinek | 9c17b77 | 2015-07-07 20:37:09 -0700 | [diff] [blame] | 5000 | handleDismissAllClipping(); |
| 5001 | } |
| 5002 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5003 | @ShadeViewRefactor(RefactorComponent.ADAPTER) |
Selim Cinek | 9c17b77 | 2015-07-07 20:37:09 -0700 | [diff] [blame] | 5004 | private void handleDismissAllClipping() { |
| 5005 | final int count = getChildCount(); |
| 5006 | boolean previousChildWillBeDismissed = false; |
| 5007 | for (int i = 0; i < count; i++) { |
| 5008 | ExpandableView child = (ExpandableView) getChildAt(i); |
| 5009 | if (child.getVisibility() == GONE) { |
| 5010 | continue; |
| 5011 | } |
| 5012 | if (mDismissAllInProgress && previousChildWillBeDismissed) { |
| 5013 | child.setMinClipTopAmount(child.getClipTopAmount()); |
| 5014 | } else { |
| 5015 | child.setMinClipTopAmount(0); |
| 5016 | } |
| 5017 | previousChildWillBeDismissed = canChildBeDismissed(child); |
| 5018 | } |
Selim Cinek | a272dfe | 2015-02-20 18:12:28 +0100 | [diff] [blame] | 5019 | } |
| 5020 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5021 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Julia Reynolds | ed1c9af | 2018-03-21 15:21:09 -0400 | [diff] [blame] | 5022 | public boolean isFooterViewNotGone() { |
| 5023 | return mFooterView != null |
| 5024 | && mFooterView.getVisibility() != View.GONE |
| 5025 | && !mFooterView.willBeGone(); |
Jorim Jaggi | 4b04a3a | 2014-07-28 17:43:56 +0200 | [diff] [blame] | 5026 | } |
| 5027 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5028 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 3847544 | 2018-05-18 11:11:46 -0700 | [diff] [blame] | 5029 | public boolean isFooterViewContentVisible() { |
| 5030 | return mFooterView != null && mFooterView.isContentVisible(); |
Jorim Jaggi | 4b04a3a | 2014-07-28 17:43:56 +0200 | [diff] [blame] | 5031 | } |
| 5032 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5033 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Julia Reynolds | ed1c9af | 2018-03-21 15:21:09 -0400 | [diff] [blame] | 5034 | public int getFooterViewHeight() { |
| 5035 | return mFooterView == null ? 0 : mFooterView.getHeight() + mPaddingBetweenElements; |
Jorim Jaggi | 4b04a3a | 2014-07-28 17:43:56 +0200 | [diff] [blame] | 5036 | } |
| 5037 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5038 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jorim Jaggi | 0cce70c | 2014-11-04 16:13:41 +0100 | [diff] [blame] | 5039 | public int getEmptyShadeViewHeight() { |
| 5040 | return mEmptyShadeView.getHeight(); |
| 5041 | } |
| 5042 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5043 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Jorim Jaggi | e0640dd | 2014-08-05 23:12:40 +0200 | [diff] [blame] | 5044 | public float getBottomMostNotificationBottom() { |
| 5045 | final int count = getChildCount(); |
| 5046 | float max = 0; |
| 5047 | for (int childIdx = 0; childIdx < count; childIdx++) { |
| 5048 | ExpandableView child = (ExpandableView) getChildAt(childIdx); |
| 5049 | if (child.getVisibility() == GONE) { |
| 5050 | continue; |
| 5051 | } |
Selim Cinek | a686b2c | 2016-10-26 13:58:27 -0700 | [diff] [blame] | 5052 | float bottom = child.getTranslationY() + child.getActualHeight() |
| 5053 | - child.getClipBottomAmount(); |
Jorim Jaggi | e0640dd | 2014-08-05 23:12:40 +0200 | [diff] [blame] | 5054 | if (bottom > max) { |
| 5055 | max = bottom; |
| 5056 | } |
| 5057 | } |
Selim Cinek | d228115 | 2015-04-10 14:37:46 -0700 | [diff] [blame] | 5058 | return max + getStackTranslation(); |
Jorim Jaggi | e0640dd | 2014-08-05 23:12:40 +0200 | [diff] [blame] | 5059 | } |
| 5060 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5061 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 5062 | public void setStatusBar(StatusBar statusBar) { |
| 5063 | this.mStatusBar = statusBar; |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 5064 | } |
| 5065 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5066 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 5067 | public void setGroupManager(NotificationGroupManager groupManager) { |
| 5068 | this.mGroupManager = groupManager; |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 5069 | mGroupManager.addOnGroupChangeListener(mOnGroupChangeListener); |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 5070 | } |
| 5071 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5072 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 5073 | private void requestAnimateEverything() { |
Selim Cinek | d9acca5 | 2014-09-01 22:33:25 +0200 | [diff] [blame] | 5074 | if (mIsExpanded && mAnimationsEnabled) { |
| 5075 | mEverythingNeedsAnimation = true; |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 5076 | mNeedsAnimation = true; |
Selim Cinek | d9acca5 | 2014-09-01 22:33:25 +0200 | [diff] [blame] | 5077 | requestChildrenUpdate(); |
| 5078 | } |
| 5079 | } |
| 5080 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5081 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 04fb258 | 2015-06-02 19:58:09 +0200 | [diff] [blame] | 5082 | public boolean isBelowLastNotification(float touchX, float touchY) { |
Selim Cinek | abf60bb | 2015-02-20 17:36:10 +0100 | [diff] [blame] | 5083 | int childCount = getChildCount(); |
| 5084 | for (int i = childCount - 1; i >= 0; i--) { |
| 5085 | ExpandableView child = (ExpandableView) getChildAt(i); |
| 5086 | if (child.getVisibility() != View.GONE) { |
| 5087 | float childTop = child.getY(); |
| 5088 | if (childTop > touchY) { |
| 5089 | // we are above a notification entirely let's abort |
| 5090 | return false; |
| 5091 | } |
Selim Cinek | a686b2c | 2016-10-26 13:58:27 -0700 | [diff] [blame] | 5092 | boolean belowChild = touchY > childTop + child.getActualHeight() |
| 5093 | - child.getClipBottomAmount(); |
Julia Reynolds | ed1c9af | 2018-03-21 15:21:09 -0400 | [diff] [blame] | 5094 | if (child == mFooterView) { |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5095 | if (!belowChild && !mFooterView.isOnEmptySpace(touchX - mFooterView.getX(), |
| 5096 | touchY - childTop)) { |
Selim Cinek | abf60bb | 2015-02-20 17:36:10 +0100 | [diff] [blame] | 5097 | // We clicked on the dismiss button |
| 5098 | return false; |
| 5099 | } |
| 5100 | } else if (child == mEmptyShadeView) { |
| 5101 | // We arrived at the empty shade view, for which we accept all clicks |
| 5102 | return true; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5103 | } else if (!belowChild) { |
Selim Cinek | abf60bb | 2015-02-20 17:36:10 +0100 | [diff] [blame] | 5104 | // We are on a child |
| 5105 | return false; |
| 5106 | } |
| 5107 | } |
Selim Cinek | 3a9c10a | 2014-10-28 14:21:10 +0100 | [diff] [blame] | 5108 | } |
Selim Cinek | 04fb258 | 2015-06-02 19:58:09 +0200 | [diff] [blame] | 5109 | return touchY > mTopPadding + mStackTranslation; |
Selim Cinek | 3a9c10a | 2014-10-28 14:21:10 +0100 | [diff] [blame] | 5110 | } |
| 5111 | |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 5112 | /** @hide */ |
| 5113 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5114 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 5115 | public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { |
| 5116 | super.onInitializeAccessibilityEventInternal(event); |
| 5117 | event.setScrollable(mScrollable); |
| 5118 | event.setScrollX(mScrollX); |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 5119 | event.setMaxScrollX(mScrollX); |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 5120 | if (ANCHOR_SCROLLING) { |
| 5121 | // TODO |
| 5122 | } else { |
| 5123 | event.setScrollY(mOwnScrollY); |
| 5124 | event.setMaxScrollY(getScrollRange()); |
| 5125 | } |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 5126 | } |
| 5127 | |
| 5128 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5129 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 5130 | public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { |
| 5131 | super.onInitializeAccessibilityNodeInfoInternal(info); |
Selim Cinek | ef40606 | 2016-09-29 17:33:13 -0700 | [diff] [blame] | 5132 | if (mScrollable) { |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 5133 | info.setScrollable(true); |
Selim Cinek | ef40606 | 2016-09-29 17:33:13 -0700 | [diff] [blame] | 5134 | if (mBackwardScrollable) { |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 5135 | info.addAction( |
| 5136 | AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD); |
| 5137 | info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_UP); |
| 5138 | } |
Selim Cinek | ef40606 | 2016-09-29 17:33:13 -0700 | [diff] [blame] | 5139 | if (mForwardScrollable) { |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 5140 | info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD); |
| 5141 | info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_DOWN); |
| 5142 | } |
| 5143 | } |
Selim Cinek | 41fe89a | 2016-06-02 15:27:56 -0700 | [diff] [blame] | 5144 | // Talkback only listenes to scroll events of certain classes, let's make us a scrollview |
| 5145 | info.setClassName(ScrollView.class.getName()); |
Selim Cinek | c22fff6 | 2016-05-20 12:44:30 -0700 | [diff] [blame] | 5146 | } |
| 5147 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5148 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 5149 | public void generateChildOrderChangedEvent() { |
| 5150 | if (mIsExpanded && mAnimationsEnabled) { |
| 5151 | mGenerateChildOrderChangedEvent = true; |
| 5152 | mNeedsAnimation = true; |
| 5153 | requestChildrenUpdate(); |
| 5154 | } |
| 5155 | } |
| 5156 | |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 5157 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5158 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 5159 | public int getContainerChildCount() { |
| 5160 | return getChildCount(); |
| 5161 | } |
| 5162 | |
| 5163 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5164 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 5165 | public View getContainerChildAt(int i) { |
| 5166 | return getChildAt(i); |
| 5167 | } |
| 5168 | |
| 5169 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5170 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 5171 | public void removeContainerView(View v) { |
| 5172 | removeView(v); |
| 5173 | } |
| 5174 | |
| 5175 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5176 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 5177 | public void addContainerView(View v) { |
| 5178 | addView(v); |
| 5179 | } |
| 5180 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5181 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 5182 | public void runAfterAnimationFinished(Runnable runnable) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 5183 | mAnimationFinishedRunnables.add(runnable); |
| 5184 | } |
| 5185 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5186 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 5187 | public void setHeadsUpManager(HeadsUpManagerPhone headsUpManager) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 5188 | mHeadsUpManager = headsUpManager; |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 5189 | mHeadsUpManager.addListener(mRoundnessManager); |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 5190 | mHeadsUpManager.setAnimationStateHandler(this::setHeadsUpGoingAwayAnimationsAllowed); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 5191 | } |
| 5192 | |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 5193 | public void generateHeadsUpAnimation(NotificationEntry entry, boolean isHeadsUp) { |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 5194 | ExpandableNotificationRow row = entry.getHeadsUpAnimationView(); |
| 5195 | generateHeadsUpAnimation(row, isHeadsUp); |
| 5196 | } |
| 5197 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5198 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 5199 | public void generateHeadsUpAnimation(ExpandableNotificationRow row, boolean isHeadsUp) { |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 5200 | if (mAnimationsEnabled && (isHeadsUp || mHeadsUpGoingAwayAnimationsAllowed)) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 5201 | mHeadsUpChangeAnimations.add(new Pair<>(row, isHeadsUp)); |
| 5202 | mNeedsAnimation = true; |
Selim Cinek | 73cf02a | 2016-06-17 13:08:00 -0700 | [diff] [blame] | 5203 | if (!mIsExpanded && !isHeadsUp) { |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 5204 | row.setHeadsUpAnimatingAway(true); |
Selim Cinek | 73cf02a | 2016-06-17 13:08:00 -0700 | [diff] [blame] | 5205 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 5206 | requestChildrenUpdate(); |
| 5207 | } |
| 5208 | } |
| 5209 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5210 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 5211 | public void setShadeExpanded(boolean shadeExpanded) { |
| 5212 | mAmbientState.setShadeExpanded(shadeExpanded); |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 5213 | mStateAnimator.setShadeExpanded(shadeExpanded); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 5214 | } |
| 5215 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 5216 | /** |
| 5217 | * Set the boundary for the bottom heads up position. The heads up will always be above this |
| 5218 | * position. |
| 5219 | * |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5220 | * @param height the height of the screen |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 5221 | * @param bottomBarHeight the height of the bar on the bottom |
| 5222 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5223 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 5224 | public void setHeadsUpBoundaries(int height, int bottomBarHeight) { |
| 5225 | mAmbientState.setMaxHeadsUpTranslation(height - bottomBarHeight); |
| 5226 | mStateAnimator.setHeadsUpAppearHeightBottom(height); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 5227 | requestChildrenUpdate(); |
| 5228 | } |
| 5229 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5230 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 5231 | public void setTrackingHeadsUp(ExpandableNotificationRow row) { |
| 5232 | mTrackingHeadsUp = row != null; |
| 5233 | mRoundnessManager.setTrackingHeadsUp(row); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 5234 | } |
| 5235 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5236 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 5237 | public void setScrimController(ScrimController scrimController) { |
| 5238 | mScrimController = scrimController; |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 5239 | mScrimController.setScrimBehindChangeRunnable(this::updateBackgroundDimming); |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 5240 | } |
| 5241 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5242 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | bbc580b | 2015-06-03 14:11:03 +0200 | [diff] [blame] | 5243 | public void forceNoOverlappingRendering(boolean force) { |
| 5244 | mForceNoOverlappingRendering = force; |
| 5245 | } |
| 5246 | |
| 5247 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5248 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | bbc580b | 2015-06-03 14:11:03 +0200 | [diff] [blame] | 5249 | public boolean hasOverlappingRendering() { |
| 5250 | return !mForceNoOverlappingRendering && super.hasOverlappingRendering(); |
| 5251 | } |
| 5252 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5253 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 5254 | public void setAnimationRunning(boolean animationRunning) { |
| 5255 | if (animationRunning != mAnimationRunning) { |
| 5256 | if (animationRunning) { |
Selim Cinek | c383fd0 | 2016-10-21 15:31:26 -0700 | [diff] [blame] | 5257 | getViewTreeObserver().addOnPreDrawListener(mRunningAnimationUpdater); |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 5258 | } else { |
Selim Cinek | c383fd0 | 2016-10-21 15:31:26 -0700 | [diff] [blame] | 5259 | getViewTreeObserver().removeOnPreDrawListener(mRunningAnimationUpdater); |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 5260 | } |
| 5261 | mAnimationRunning = animationRunning; |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 5262 | updateContinuousShadowDrawing(); |
Selim Cinek | 6811d72 | 2016-01-19 17:53:12 -0800 | [diff] [blame] | 5263 | } |
| 5264 | } |
| 5265 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5266 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 5267 | public boolean isExpanded() { |
| 5268 | return mIsExpanded; |
| 5269 | } |
| 5270 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5271 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Lucas Dupin | 4e02381 | 2018-04-02 21:19:23 -0700 | [diff] [blame] | 5272 | public void setPulsing(boolean pulsing, boolean animated) { |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 5273 | if (!mPulsing && !pulsing) { |
Adrian Roos | b2a8729 | 2017-02-13 15:05:03 +0100 | [diff] [blame] | 5274 | return; |
| 5275 | } |
Selim Cinek | cd5b22f | 2016-03-08 16:15:41 -0800 | [diff] [blame] | 5276 | mPulsing = pulsing; |
Lucas Dupin | 4e02381 | 2018-04-02 21:19:23 -0700 | [diff] [blame] | 5277 | mNeedingPulseAnimation = animated ? getFirstChildNotGone() : null; |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 5278 | mAmbientState.setPulsing(pulsing); |
Selim Cinek | cd5b22f | 2016-03-08 16:15:41 -0800 | [diff] [blame] | 5279 | updateNotificationAnimationStates(); |
Lucas Dupin | 6bf7b64 | 2018-01-22 18:56:24 -0800 | [diff] [blame] | 5280 | updateAlgorithmHeightAndPadding(); |
Adrian Roos | 7a9551a | 2017-01-11 12:27:49 -0800 | [diff] [blame] | 5281 | updateContentHeight(); |
Adrian Roos | d83e999 | 2017-03-16 15:17:57 -0700 | [diff] [blame] | 5282 | requestChildrenUpdate(); |
Lucas Dupin | 4e02381 | 2018-04-02 21:19:23 -0700 | [diff] [blame] | 5283 | notifyHeightChangeListener(null, animated); |
| 5284 | mNeedsAnimation |= animated; |
| 5285 | } |
| 5286 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5287 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Lucas Dupin | 4e02381 | 2018-04-02 21:19:23 -0700 | [diff] [blame] | 5288 | private void generatePulsingAnimationEvent() { |
| 5289 | if (mNeedingPulseAnimation != null) { |
| 5290 | int type = mPulsing ? AnimationEvent.ANIMATION_TYPE_PULSE_APPEAR |
| 5291 | : AnimationEvent.ANIMATION_TYPE_PULSE_DISAPPEAR; |
| 5292 | mAnimationEvents.add(new AnimationEvent(mNeedingPulseAnimation, type)); |
| 5293 | mNeedingPulseAnimation = null; |
| 5294 | } |
Selim Cinek | cd5b22f | 2016-03-08 16:15:41 -0800 | [diff] [blame] | 5295 | } |
| 5296 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5297 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 5298 | public void setQsExpanded(boolean qsExpanded) { |
| 5299 | mQsExpanded = qsExpanded; |
| 5300 | updateAlgorithmLayoutMinHeight(); |
Riddle Hsu | 065c01c | 2018-05-10 23:14:19 +0800 | [diff] [blame] | 5301 | updateScrollability(); |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 5302 | } |
| 5303 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5304 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 5305 | public void setQsExpansionFraction(float qsExpansionFraction) { |
| 5306 | mQsExpansionFraction = qsExpansionFraction; |
| 5307 | } |
| 5308 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5309 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 5310 | private void setOwnScrollY(int ownScrollY) { |
| 5311 | assert !ANCHOR_SCROLLING; |
Selim Cinek | ef40606 | 2016-09-29 17:33:13 -0700 | [diff] [blame] | 5312 | if (ownScrollY != mOwnScrollY) { |
Selim Cinek | 9212de8 | 2017-02-06 16:04:28 -0800 | [diff] [blame] | 5313 | // We still want to call the normal scrolled changed for accessibility reasons |
| 5314 | onScrollChanged(mScrollX, ownScrollY, mScrollX, mOwnScrollY); |
Selim Cinek | ef40606 | 2016-09-29 17:33:13 -0700 | [diff] [blame] | 5315 | mOwnScrollY = ownScrollY; |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 5316 | updateOnScrollChange(); |
| 5317 | } |
| 5318 | } |
| 5319 | |
| 5320 | private void updateOnScrollChange() { |
| 5321 | updateForwardAndBackwardScrollability(); |
| 5322 | requestChildrenUpdate(); |
| 5323 | } |
| 5324 | |
| 5325 | private void updateScrollAnchor() { |
| 5326 | int anchorIndex = indexOfChild(mScrollAnchorView); |
| 5327 | // If the anchor view has been scrolled off the top, move to the next view. |
| 5328 | while (mScrollAnchorViewY < 0) { |
| 5329 | View nextAnchor = null; |
| 5330 | for (int i = anchorIndex + 1; i < getChildCount(); i++) { |
| 5331 | View child = getChildAt(i); |
| 5332 | if (child.getVisibility() != View.GONE |
| 5333 | && child instanceof ExpandableNotificationRow) { |
| 5334 | anchorIndex = i; |
| 5335 | nextAnchor = child; |
| 5336 | break; |
| 5337 | } |
| 5338 | } |
| 5339 | if (nextAnchor == null) { |
| 5340 | break; |
| 5341 | } |
| 5342 | mScrollAnchorViewY += |
| 5343 | (int) (nextAnchor.getTranslationY() - mScrollAnchorView.getTranslationY()); |
| 5344 | mScrollAnchorView = nextAnchor; |
| 5345 | } |
| 5346 | // If the view above the anchor view is fully visible, make it the anchor view. |
| 5347 | while (anchorIndex > 0 && mScrollAnchorViewY > 0) { |
| 5348 | View prevAnchor = null; |
| 5349 | for (int i = anchorIndex - 1; i >= 0; i--) { |
| 5350 | View child = getChildAt(i); |
| 5351 | if (child.getVisibility() != View.GONE |
| 5352 | && child instanceof ExpandableNotificationRow) { |
| 5353 | anchorIndex = i; |
| 5354 | prevAnchor = child; |
| 5355 | break; |
| 5356 | } |
| 5357 | } |
| 5358 | if (prevAnchor == null) { |
| 5359 | break; |
| 5360 | } |
| 5361 | float distanceToPreviousAnchor = |
| 5362 | mScrollAnchorView.getTranslationY() - prevAnchor.getTranslationY(); |
| 5363 | if (distanceToPreviousAnchor < mScrollAnchorViewY) { |
| 5364 | mScrollAnchorViewY -= (int) distanceToPreviousAnchor; |
| 5365 | mScrollAnchorView = prevAnchor; |
| 5366 | } |
Selim Cinek | ef40606 | 2016-09-29 17:33:13 -0700 | [diff] [blame] | 5367 | } |
| 5368 | } |
| 5369 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5370 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 5371 | public void setShelf(NotificationShelf shelf) { |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 5372 | int index = -1; |
| 5373 | if (mShelf != null) { |
| 5374 | index = indexOfChild(mShelf); |
| 5375 | removeView(mShelf); |
| 5376 | } |
Selim Cinek | 0e8d77e | 2016-11-29 10:35:42 -0800 | [diff] [blame] | 5377 | mShelf = shelf; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 5378 | addView(mShelf, index); |
| 5379 | mAmbientState.setShelf(shelf); |
Selim Cinek | eccb5de | 2016-10-28 15:04:05 -0700 | [diff] [blame] | 5380 | mStateAnimator.setShelf(shelf); |
Selim Cinek | c383fd0 | 2016-10-21 15:31:26 -0700 | [diff] [blame] | 5381 | shelf.bind(mAmbientState, this); |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 5382 | if (ANCHOR_SCROLLING) { |
| 5383 | mScrollAnchorView = mShelf; |
| 5384 | } |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 5385 | } |
| 5386 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5387 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 5388 | public NotificationShelf getNotificationShelf() { |
| 5389 | return mShelf; |
| 5390 | } |
| 5391 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5392 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | ad7fac0 | 2016-10-18 17:09:15 -0700 | [diff] [blame] | 5393 | public void setMaxDisplayedNotifications(int maxDisplayedNotifications) { |
| 5394 | if (mMaxDisplayedNotifications != maxDisplayedNotifications) { |
| 5395 | mMaxDisplayedNotifications = maxDisplayedNotifications; |
| 5396 | updateContentHeight(); |
| 5397 | notifyHeightChangeListener(mShelf); |
| 5398 | } |
| 5399 | } |
| 5400 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5401 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 5402 | public void setShouldShowShelfOnly(boolean shouldShowShelfOnly) { |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5403 | mShouldShowShelfOnly = shouldShowShelfOnly; |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 5404 | updateAlgorithmLayoutMinHeight(); |
| 5405 | } |
| 5406 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5407 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 5408 | public int getMinExpansionHeight() { |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 5409 | return mShelf.getIntrinsicHeight() - (mShelf.getIntrinsicHeight() - mStatusBarHeight) / 2; |
Selim Cinek | 48ff9b4 | 2016-11-09 19:31:51 -0800 | [diff] [blame] | 5410 | } |
| 5411 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5412 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 5413 | public void setInHeadsUpPinnedMode(boolean inHeadsUpPinnedMode) { |
| 5414 | mInHeadsUpPinnedMode = inHeadsUpPinnedMode; |
| 5415 | updateClipping(); |
| 5416 | } |
| 5417 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5418 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 5419 | public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) { |
| 5420 | mHeadsUpAnimatingAway = headsUpAnimatingAway; |
| 5421 | updateClipping(); |
| 5422 | } |
| 5423 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5424 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 5425 | @VisibleForTesting |
| 5426 | protected void setStatusBarState(int statusBarState) { |
Selim Cinek | 355652a | 2016-12-07 13:32:12 -0800 | [diff] [blame] | 5427 | mStatusBarState = statusBarState; |
| 5428 | mAmbientState.setStatusBarState(statusBarState); |
Evan Laird | 91d0f10 | 2018-09-18 17:39:55 -0400 | [diff] [blame] | 5429 | } |
| 5430 | |
| 5431 | private void onStatePostChange() { |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 5432 | boolean onKeyguard = onKeyguard(); |
| 5433 | boolean publicMode = mLockscreenUserManager.isAnyProfilePublicMode(); |
Evan Laird | 91d0f10 | 2018-09-18 17:39:55 -0400 | [diff] [blame] | 5434 | |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 5435 | if (mHeadsUpAppearanceController != null) { |
| 5436 | mHeadsUpAppearanceController.setPublicMode(publicMode); |
| 5437 | } |
| 5438 | |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 5439 | SysuiStatusBarStateController state = (SysuiStatusBarStateController) |
| 5440 | Dependency.get(StatusBarStateController.class); |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 5441 | setHideSensitive(publicMode, state.goingToFullShade() /* animate */); |
| 5442 | setDimmed(onKeyguard, state.fromShadeLocked() /* animate */); |
| 5443 | setExpandingEnabled(!onKeyguard); |
| 5444 | ActivatableNotificationView activatedChild = getActivatedChild(); |
| 5445 | setActivatedChild(null); |
| 5446 | if (activatedChild != null) { |
| 5447 | activatedChild.makeInactive(false /* animate */); |
| 5448 | } |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5449 | updateFooter(); |
Dave Mankoff | 5744580 | 2018-10-10 14:47:34 -0400 | [diff] [blame] | 5450 | requestChildrenUpdate(); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5451 | onUpdateRowStates(); |
Evan Laird | 91d0f10 | 2018-09-18 17:39:55 -0400 | [diff] [blame] | 5452 | |
| 5453 | mEntryManager.updateNotifications(); |
Selim Cinek | 355652a | 2016-12-07 13:32:12 -0800 | [diff] [blame] | 5454 | } |
| 5455 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5456 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 5457 | public void setExpandingVelocity(float expandingVelocity) { |
| 5458 | mAmbientState.setExpandingVelocity(expandingVelocity); |
| 5459 | } |
| 5460 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5461 | @ShadeViewRefactor(RefactorComponent.COORDINATOR) |
Selim Cinek | fcff4c6 | 2016-12-27 14:26:06 +0100 | [diff] [blame] | 5462 | public float getOpeningHeight() { |
| 5463 | if (mEmptyShadeView.getVisibility() == GONE) { |
| 5464 | return getMinExpansionHeight(); |
| 5465 | } else { |
| 5466 | return getAppearEndPosition(); |
| 5467 | } |
| 5468 | } |
| 5469 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5470 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | fcff4c6 | 2016-12-27 14:26:06 +0100 | [diff] [blame] | 5471 | public void setIsFullWidth(boolean isFullWidth) { |
| 5472 | mAmbientState.setPanelFullWidth(isFullWidth); |
| 5473 | } |
| 5474 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5475 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | ec29d34 | 2017-05-05 18:31:49 -0700 | [diff] [blame] | 5476 | public void setUnlockHintRunning(boolean running) { |
| 5477 | mAmbientState.setUnlockHintRunning(running); |
| 5478 | } |
| 5479 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5480 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 5481 | public void setQsCustomizerShowing(boolean isShowing) { |
| 5482 | mAmbientState.setQsCustomizerShowing(isShowing); |
| 5483 | requestChildrenUpdate(); |
| 5484 | } |
| 5485 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5486 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 5487 | public void setHeadsUpGoingAwayAnimationsAllowed(boolean headsUpGoingAwayAnimationsAllowed) { |
| 5488 | mHeadsUpGoingAwayAnimationsAllowed = headsUpGoingAwayAnimationsAllowed; |
| 5489 | } |
| 5490 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5491 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Lucas Dupin | 0cd882f | 2018-01-30 12:19:49 -0800 | [diff] [blame] | 5492 | public void setAntiBurnInOffsetX(int antiBurnInOffsetX) { |
| 5493 | mAntiBurnInOffsetX = antiBurnInOffsetX; |
Bill Lin | e60aa1e | 2018-06-13 18:07:15 +0800 | [diff] [blame] | 5494 | updatePanelTranslation(); |
Adrian Roos | dc747bd | 2017-06-01 16:09:15 -0700 | [diff] [blame] | 5495 | } |
| 5496 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5497 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 707e207 | 2017-06-30 18:32:40 +0200 | [diff] [blame] | 5498 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 5499 | pw.println(String.format("[%s: pulsing=%s qsCustomizerShowing=%s visibility=%s" |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 5500 | + " alpha:%f scrollY:%d maxTopPadding:%d showShelfOnly=%s" |
| 5501 | + " qsExpandFraction=%f]", |
Selim Cinek | 707e207 | 2017-06-30 18:32:40 +0200 | [diff] [blame] | 5502 | this.getClass().getSimpleName(), |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5503 | mPulsing ? "T" : "f", |
| 5504 | mAmbientState.isQsCustomizerShowing() ? "T" : "f", |
Selim Cinek | 707e207 | 2017-06-30 18:32:40 +0200 | [diff] [blame] | 5505 | getVisibility() == View.VISIBLE ? "visible" |
| 5506 | : getVisibility() == View.GONE ? "gone" |
| 5507 | : "invisible", |
| 5508 | getAlpha(), |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 5509 | mAmbientState.getScrollY(), |
| 5510 | mMaxTopPadding, |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5511 | mShouldShowShelfOnly ? "T" : "f", |
shawnlin | 8e4e92c | 2018-04-12 18:47:24 +0800 | [diff] [blame] | 5512 | mQsExpansionFraction)); |
Selim Cinek | 3088766 | 2018-10-15 17:37:21 -0700 | [diff] [blame] | 5513 | int childCount = getChildCount(); |
| 5514 | pw.println(" Number of children: " + childCount); |
| 5515 | pw.println(); |
| 5516 | |
| 5517 | for (int i = 0; i < childCount; i++) { |
| 5518 | ExpandableView child = (ExpandableView) getChildAt(i); |
| 5519 | child.dump(fd, pw, args); |
| 5520 | if (!(child instanceof ExpandableNotificationRow)) { |
| 5521 | pw.println(" " + child.getClass().getSimpleName()); |
| 5522 | // Notifications dump it's viewstate as part of their dump to support children |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 5523 | ExpandableViewState viewState = child.getViewState(); |
Selim Cinek | 3088766 | 2018-10-15 17:37:21 -0700 | [diff] [blame] | 5524 | if (viewState == null) { |
| 5525 | pw.println(" no viewState!!!"); |
| 5526 | } else { |
| 5527 | pw.print(" "); |
| 5528 | viewState.dump(fd, pw, args); |
| 5529 | pw.println(); |
| 5530 | pw.println(); |
| 5531 | } |
| 5532 | } |
| 5533 | } |
Selim Cinek | 3088766 | 2018-10-15 17:37:21 -0700 | [diff] [blame] | 5534 | int transientViewCount = getTransientViewCount(); |
Selim Cinek | d4c3230 | 2018-11-19 19:43:14 -0800 | [diff] [blame] | 5535 | pw.println(" Transient Views: " + transientViewCount); |
Selim Cinek | 3088766 | 2018-10-15 17:37:21 -0700 | [diff] [blame] | 5536 | for (int i = 0; i < transientViewCount; i++) { |
| 5537 | ExpandableView child = (ExpandableView) getTransientView(i); |
| 5538 | child.dump(fd, pw, args); |
| 5539 | } |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 5540 | ArrayList<ExpandableView> draggedViews = mAmbientState.getDraggedViews(); |
Selim Cinek | d4c3230 | 2018-11-19 19:43:14 -0800 | [diff] [blame] | 5541 | int draggedCount = draggedViews.size(); |
| 5542 | pw.println(" Dragged Views: " + draggedCount); |
| 5543 | for (int i = 0; i < draggedCount; i++) { |
| 5544 | ExpandableView child = (ExpandableView) draggedViews.get(i); |
| 5545 | child.dump(fd, pw, args); |
| 5546 | } |
Selim Cinek | 707e207 | 2017-06-30 18:32:40 +0200 | [diff] [blame] | 5547 | } |
| 5548 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5549 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 5550 | public boolean isFullyDark() { |
| 5551 | return mAmbientState.isFullyDark(); |
| 5552 | } |
| 5553 | |
Selim Cinek | 7103fd4 | 2016-05-09 22:22:33 -0400 | [diff] [blame] | 5554 | /** |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 5555 | * Add a listener whenever the expanded height changes. The first value passed as an argument |
| 5556 | * is the expanded height and the second one is the appearFraction. |
| 5557 | * |
| 5558 | * @param listener the listener to notify. |
| 5559 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5560 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 5561 | public void addOnExpandedHeightListener(BiConsumer<Float, Float> listener) { |
| 5562 | mExpandedHeightListeners.add(listener); |
| 5563 | } |
| 5564 | |
| 5565 | /** |
Selim Cinek | 60ffea6 | 2018-03-22 13:16:44 -0700 | [diff] [blame] | 5566 | * Stop a listener from listening to the expandedHeight. |
| 5567 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5568 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 60ffea6 | 2018-03-22 13:16:44 -0700 | [diff] [blame] | 5569 | public void removeOnExpandedHeightListener(BiConsumer<Float, Float> listener) { |
| 5570 | mExpandedHeightListeners.remove(listener); |
| 5571 | } |
| 5572 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5573 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | f0c79e1 | 2018-05-14 17:17:31 -0700 | [diff] [blame] | 5574 | public void setHeadsUpAppearanceController( |
| 5575 | HeadsUpAppearanceController headsUpAppearanceController) { |
| 5576 | mHeadsUpAppearanceController = headsUpAppearanceController; |
| 5577 | } |
| 5578 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5579 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 9bfc7a5 | 2018-06-11 16:09:00 -0700 | [diff] [blame] | 5580 | public void setIconAreaController(NotificationIconAreaController controller) { |
| 5581 | mIconAreaController = controller; |
| 5582 | } |
| 5583 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5584 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5585 | public void manageNotifications(View v) { |
| 5586 | Intent intent = new Intent(Settings.ACTION_ALL_APPS_NOTIFICATION_SETTINGS); |
| 5587 | mStatusBar.startActivity(intent, true, true, Intent.FLAG_ACTIVITY_SINGLE_TOP); |
| 5588 | } |
| 5589 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5590 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5591 | public void clearAllNotifications() { |
| 5592 | // animate-swipe all dismissable notifications, then animate the shade closed |
| 5593 | int numChildren = getChildCount(); |
| 5594 | |
| 5595 | final ArrayList<View> viewsToHide = new ArrayList<>(numChildren); |
| 5596 | final ArrayList<ExpandableNotificationRow> viewsToRemove = new ArrayList<>(numChildren); |
| 5597 | for (int i = 0; i < numChildren; i++) { |
| 5598 | final View child = getChildAt(i); |
| 5599 | if (child instanceof ExpandableNotificationRow) { |
| 5600 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 5601 | boolean parentVisible = false; |
| 5602 | boolean hasClipBounds = child.getClipBounds(mTmpRect); |
| 5603 | if (canChildBeDismissed(child)) { |
| 5604 | viewsToRemove.add(row); |
| 5605 | if (child.getVisibility() == View.VISIBLE |
| 5606 | && (!hasClipBounds || mTmpRect.height() > 0)) { |
| 5607 | viewsToHide.add(child); |
| 5608 | parentVisible = true; |
| 5609 | } |
| 5610 | } else if (child.getVisibility() == View.VISIBLE |
| 5611 | && (!hasClipBounds || mTmpRect.height() > 0)) { |
| 5612 | parentVisible = true; |
| 5613 | } |
| 5614 | List<ExpandableNotificationRow> children = row.getNotificationChildren(); |
| 5615 | if (children != null) { |
| 5616 | for (ExpandableNotificationRow childRow : children) { |
| 5617 | viewsToRemove.add(childRow); |
| 5618 | if (parentVisible && row.areChildrenExpanded() |
| 5619 | && canChildBeDismissed(childRow)) { |
| 5620 | hasClipBounds = childRow.getClipBounds(mTmpRect); |
| 5621 | if (childRow.getVisibility() == View.VISIBLE |
| 5622 | && (!hasClipBounds || mTmpRect.height() > 0)) { |
| 5623 | viewsToHide.add(childRow); |
| 5624 | } |
| 5625 | } |
| 5626 | } |
| 5627 | } |
| 5628 | } |
| 5629 | } |
| 5630 | if (viewsToRemove.isEmpty()) { |
| 5631 | mStatusBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
| 5632 | return; |
| 5633 | } |
| 5634 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 5635 | mShadeController.addPostCollapseAction(() -> { |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5636 | setDismissAllInProgress(false); |
| 5637 | for (ExpandableNotificationRow rowToRemove : viewsToRemove) { |
| 5638 | if (canChildBeDismissed(rowToRemove)) { |
| 5639 | mEntryManager.removeNotification(rowToRemove.getEntry().key, null); |
| 5640 | } else { |
| 5641 | rowToRemove.resetTranslation(); |
| 5642 | } |
| 5643 | } |
| 5644 | try { |
| 5645 | mBarService.onClearAllNotifications(mLockscreenUserManager.getCurrentUserId()); |
| 5646 | } catch (Exception ex) { |
| 5647 | } |
| 5648 | }); |
| 5649 | |
| 5650 | performDismissAllAnimations(viewsToHide); |
| 5651 | } |
| 5652 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5653 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5654 | public void performDismissAllAnimations(ArrayList<View> hideAnimatedList) { |
| 5655 | Runnable animationFinishAction = () -> { |
| 5656 | mStatusBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
| 5657 | }; |
| 5658 | |
| 5659 | if (hideAnimatedList.isEmpty()) { |
| 5660 | animationFinishAction.run(); |
| 5661 | return; |
| 5662 | } |
| 5663 | |
| 5664 | // let's disable our normal animations |
| 5665 | setDismissAllInProgress(true); |
| 5666 | |
| 5667 | // Decrease the delay for every row we animate to give the sense of |
| 5668 | // accelerating the swipes |
| 5669 | int rowDelayDecrement = 10; |
| 5670 | int currentDelay = 140; |
| 5671 | int totalDelay = 180; |
| 5672 | int numItems = hideAnimatedList.size(); |
| 5673 | for (int i = numItems - 1; i >= 0; i--) { |
| 5674 | View view = hideAnimatedList.get(i); |
| 5675 | Runnable endRunnable = null; |
| 5676 | if (i == 0) { |
| 5677 | endRunnable = animationFinishAction; |
| 5678 | } |
Lucas Dupin | fb8bdbb | 2018-12-02 15:09:37 -0800 | [diff] [blame] | 5679 | dismissViewAnimated(view, endRunnable, totalDelay, ANIMATION_DURATION_SWIPE); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5680 | currentDelay = Math.max(50, currentDelay - rowDelayDecrement); |
| 5681 | totalDelay += currentDelay; |
| 5682 | } |
| 5683 | } |
| 5684 | |
| 5685 | @VisibleForTesting |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5686 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5687 | protected void inflateFooterView() { |
| 5688 | FooterView footerView = (FooterView) LayoutInflater.from(mContext).inflate( |
| 5689 | R.layout.status_bar_notification_footer, this, false); |
| 5690 | footerView.setDismissButtonClickListener(v -> { |
| 5691 | mMetricsLogger.action(MetricsEvent.ACTION_DISMISS_ALL_NOTES); |
| 5692 | clearAllNotifications(); |
| 5693 | }); |
| 5694 | footerView.setManageButtonClickListener(this::manageNotifications); |
| 5695 | setFooterView(footerView); |
| 5696 | } |
| 5697 | |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 5698 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
| 5699 | private void inflateEmptyShadeView() { |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5700 | EmptyShadeView view = (EmptyShadeView) LayoutInflater.from(mContext).inflate( |
| 5701 | R.layout.status_bar_no_notifications, this, false); |
| 5702 | view.setText(R.string.empty_shade_text); |
| 5703 | setEmptyShadeView(view); |
| 5704 | } |
| 5705 | |
| 5706 | /** |
| 5707 | * Updates expanded, dimmed and locked states of notification rows. |
| 5708 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5709 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5710 | public void onUpdateRowStates() { |
| 5711 | changeViewPosition(mFooterView, -1); |
| 5712 | |
| 5713 | // The following views will be moved to the end of mStackScroller. This counter represents |
| 5714 | // the offset from the last child. Initialized to 1 for the very last position. It is post- |
| 5715 | // incremented in the following "changeViewPosition" calls so that its value is correct for |
| 5716 | // subsequent calls. |
| 5717 | int offsetFromEnd = 1; |
| 5718 | changeViewPosition(mEmptyShadeView, |
| 5719 | getChildCount() - offsetFromEnd++); |
| 5720 | |
| 5721 | // No post-increment for this call because it is the last one. Make sure to add one if |
| 5722 | // another "changeViewPosition" call is ever added. |
| 5723 | changeViewPosition(mShelf, |
| 5724 | getChildCount() - offsetFromEnd); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5725 | } |
| 5726 | |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 5727 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
| 5728 | public void setNotificationPanel(NotificationPanelView notificationPanelView) { |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5729 | mNotificationPanel = notificationPanelView; |
| 5730 | } |
| 5731 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 5732 | public void updateIconAreaViews() { |
| 5733 | mIconAreaController.updateNotificationIcons(); |
| 5734 | } |
| 5735 | |
Selim Cinek | 60ffea6 | 2018-03-22 13:16:44 -0700 | [diff] [blame] | 5736 | /** |
Selim Cinek | 3a9c10a | 2014-10-28 14:21:10 +0100 | [diff] [blame] | 5737 | * A listener that is notified when the empty space below the notifications is clicked on |
| 5738 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5739 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Selim Cinek | 3a9c10a | 2014-10-28 14:21:10 +0100 | [diff] [blame] | 5740 | public interface OnEmptySpaceClickListener { |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 5741 | void onEmptySpaceClicked(float x, float y); |
Selim Cinek | 3a9c10a | 2014-10-28 14:21:10 +0100 | [diff] [blame] | 5742 | } |
| 5743 | |
| 5744 | /** |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 5745 | * A listener that gets notified when the overscroll at the top has changed. |
| 5746 | */ |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5747 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 5748 | public interface OnOverscrollTopChangedListener { |
Jorim Jaggi | 475b21d | 2014-07-01 18:13:24 +0200 | [diff] [blame] | 5749 | |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 5750 | /** |
| 5751 | * Notifies a listener that the overscroll has changed. |
| 5752 | * |
| 5753 | * @param amount the amount of overscroll, in pixels |
| 5754 | * @param isRubberbanded if true, this is a rubberbanded overscroll; if false, this is an |
| 5755 | * unrubberbanded motion to directly expand overscroll view (e.g |
| 5756 | * expand |
| 5757 | * QS) |
| 5758 | */ |
| 5759 | void onOverscrollTopChanged(float amount, boolean isRubberbanded); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 5760 | |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 5761 | /** |
| 5762 | * Notify a listener that the scroller wants to escape from the scrolling motion and |
| 5763 | * start a fling animation to the expanded or collapsed overscroll view (e.g expand the QS) |
| 5764 | * |
| 5765 | * @param velocity The velocity that the Scroller had when over flinging |
| 5766 | * @param open Should the fling open or close the overscroll view. |
| 5767 | */ |
| 5768 | void flingTopOverscroll(float velocity, boolean open); |
| 5769 | } |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 5770 | |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 5771 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
| 5772 | public boolean hasActiveNotifications() { |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5773 | return !mEntryManager.getNotificationData().getActiveNotifications().isEmpty(); |
| 5774 | } |
| 5775 | |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 5776 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 5777 | public void updateSpeedBumpIndex() { |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5778 | int speedBumpIndex = 0; |
| 5779 | int currentIndex = 0; |
| 5780 | final int N = getChildCount(); |
| 5781 | for (int i = 0; i < N; i++) { |
| 5782 | View view = getChildAt(i); |
| 5783 | if (view.getVisibility() == View.GONE || !(view instanceof ExpandableNotificationRow)) { |
| 5784 | continue; |
| 5785 | } |
| 5786 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
| 5787 | currentIndex++; |
Gus Prevas | 33619af | 2018-10-26 15:40:27 -0400 | [diff] [blame] | 5788 | boolean beforeSpeedBump; |
| 5789 | if (mLowPriorityBeforeSpeedBump) { |
Gus Prevas | caed15c | 2019-01-18 14:19:51 -0500 | [diff] [blame] | 5790 | beforeSpeedBump = !row.getEntry().ambient; |
Gus Prevas | 33619af | 2018-10-26 15:40:27 -0400 | [diff] [blame] | 5791 | } else { |
Gus Prevas | caed15c | 2019-01-18 14:19:51 -0500 | [diff] [blame] | 5792 | beforeSpeedBump = row.getEntry().isHighPriority(); |
Gus Prevas | 33619af | 2018-10-26 15:40:27 -0400 | [diff] [blame] | 5793 | } |
| 5794 | if (beforeSpeedBump) { |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5795 | speedBumpIndex = currentIndex; |
| 5796 | } |
| 5797 | } |
| 5798 | boolean noAmbient = speedBumpIndex == N; |
| 5799 | updateSpeedBumpIndex(speedBumpIndex, noAmbient); |
| 5800 | } |
| 5801 | |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 5802 | /** Updates the indices of the boundaries between sections. */ |
| 5803 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 5804 | public void updateSectionBoundaries() { |
| 5805 | int gapIndex = -1; |
| 5806 | if (NotificationUtils.useNewInterruptionModel(mContext)) { |
| 5807 | int currentIndex = 0; |
| 5808 | final int n = getChildCount(); |
| 5809 | for (int i = 0; i < n; i++) { |
| 5810 | View view = getChildAt(i); |
| 5811 | if (view.getVisibility() == View.GONE |
| 5812 | || !(view instanceof ExpandableNotificationRow)) { |
| 5813 | continue; |
| 5814 | } |
| 5815 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
Gus Prevas | caed15c | 2019-01-18 14:19:51 -0500 | [diff] [blame] | 5816 | if (!row.getEntry().isHighPriority()) { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 5817 | if (currentIndex > 0) { |
| 5818 | gapIndex = currentIndex; |
| 5819 | } |
| 5820 | break; |
| 5821 | } |
| 5822 | currentIndex++; |
| 5823 | } |
| 5824 | } |
| 5825 | mAmbientState.setSectionBoundaryIndex(0, gapIndex); |
| 5826 | } |
| 5827 | |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5828 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 5829 | private void updateContinuousShadowDrawing() { |
| 5830 | boolean continuousShadowUpdate = mAnimationRunning |
| 5831 | || !mAmbientState.getDraggedViews().isEmpty(); |
| 5832 | if (continuousShadowUpdate != mContinuousShadowUpdate) { |
| 5833 | if (continuousShadowUpdate) { |
| 5834 | getViewTreeObserver().addOnPreDrawListener(mShadowUpdater); |
| 5835 | } else { |
| 5836 | getViewTreeObserver().removeOnPreDrawListener(mShadowUpdater); |
| 5837 | } |
Jorim Jaggi | 38b5ec9 | 2016-04-12 01:39:49 -0700 | [diff] [blame] | 5838 | mContinuousShadowUpdate = continuousShadowUpdate; |
Selim Cinek | 3322357 | 2016-02-19 19:32:22 -0800 | [diff] [blame] | 5839 | } |
| 5840 | } |
| 5841 | |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 5842 | @Override |
Aaron Heuckroth | 441b7dd | 2018-08-24 15:52:49 -0400 | [diff] [blame] | 5843 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 5844 | public void resetExposedMenuView(boolean animate, boolean force) { |
| 5845 | mSwipeHelper.resetExposedMenuView(animate, force); |
Mady Mellor | 7a9b2a6 | 2016-03-23 07:41:47 -0700 | [diff] [blame] | 5846 | } |
| 5847 | |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 5848 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
| 5849 | static class AnimationEvent { |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 5850 | |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5851 | static AnimationFilter[] FILTERS = new AnimationFilter[]{ |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5852 | |
| 5853 | // ANIMATION_TYPE_ADD |
| 5854 | new AnimationFilter() |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5855 | .animateHeight() |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 5856 | .animateTopInset() |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5857 | .animateY() |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 5858 | .animateZ() |
| 5859 | .hasDelays(), |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5860 | |
| 5861 | // ANIMATION_TYPE_REMOVE |
| 5862 | new AnimationFilter() |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5863 | .animateHeight() |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 5864 | .animateTopInset() |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5865 | .animateY() |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 5866 | .animateZ() |
| 5867 | .hasDelays(), |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5868 | |
| 5869 | // ANIMATION_TYPE_REMOVE_SWIPED_OUT |
| 5870 | new AnimationFilter() |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5871 | .animateHeight() |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 5872 | .animateTopInset() |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5873 | .animateY() |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 5874 | .animateZ() |
| 5875 | .hasDelays(), |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5876 | |
| 5877 | // ANIMATION_TYPE_TOP_PADDING_CHANGED |
| 5878 | new AnimationFilter() |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5879 | .animateHeight() |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 5880 | .animateTopInset() |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5881 | .animateY() |
| 5882 | .animateDimmed() |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5883 | .animateZ(), |
| 5884 | |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5885 | // ANIMATION_TYPE_ACTIVATED_CHILD |
| 5886 | new AnimationFilter() |
Selim Cinek | 277a8aa | 2016-01-22 12:12:37 -0800 | [diff] [blame] | 5887 | .animateZ(), |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5888 | |
| 5889 | // ANIMATION_TYPE_DIMMED |
| 5890 | new AnimationFilter() |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 5891 | .animateDimmed(), |
| 5892 | |
| 5893 | // ANIMATION_TYPE_CHANGE_POSITION |
| 5894 | new AnimationFilter() |
Selim Cinek | 277a8aa | 2016-01-22 12:12:37 -0800 | [diff] [blame] | 5895 | .animateAlpha() // maybe the children change positions |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 5896 | .animateHeight() |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 5897 | .animateTopInset() |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 5898 | .animateY() |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5899 | .animateZ(), |
| 5900 | |
| 5901 | // ANIMATION_TYPE_DARK |
Adrian Roos | 28f90c7 | 2017-05-08 17:24:26 -0700 | [diff] [blame] | 5902 | null, // Unused |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 5903 | |
| 5904 | // ANIMATION_TYPE_GO_TO_FULL_SHADE |
| 5905 | new AnimationFilter() |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 5906 | .animateHeight() |
| 5907 | .animateTopInset() |
| 5908 | .animateY() |
| 5909 | .animateDimmed() |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 5910 | .animateZ() |
| 5911 | .hasDelays(), |
| 5912 | |
| 5913 | // ANIMATION_TYPE_HIDE_SENSITIVE |
| 5914 | new AnimationFilter() |
| 5915 | .animateHideSensitive(), |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 5916 | |
| 5917 | // ANIMATION_TYPE_VIEW_RESIZE |
| 5918 | new AnimationFilter() |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 5919 | .animateHeight() |
| 5920 | .animateTopInset() |
| 5921 | .animateY() |
| 5922 | .animateZ(), |
Selim Cinek | d9acca5 | 2014-09-01 22:33:25 +0200 | [diff] [blame] | 5923 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 5924 | // ANIMATION_TYPE_GROUP_EXPANSION_CHANGED |
| 5925 | new AnimationFilter() |
| 5926 | .animateAlpha() |
| 5927 | .animateHeight() |
| 5928 | .animateTopInset() |
| 5929 | .animateY() |
| 5930 | .animateZ(), |
| 5931 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 5932 | // ANIMATION_TYPE_HEADS_UP_APPEAR |
| 5933 | new AnimationFilter() |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 5934 | .animateHeight() |
| 5935 | .animateTopInset() |
| 5936 | .animateY() |
| 5937 | .animateZ(), |
| 5938 | |
| 5939 | // ANIMATION_TYPE_HEADS_UP_DISAPPEAR |
| 5940 | new AnimationFilter() |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 5941 | .animateHeight() |
| 5942 | .animateTopInset() |
| 5943 | .animateY() |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 5944 | .animateZ() |
| 5945 | .hasDelays(), |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 5946 | |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 5947 | // ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK |
| 5948 | new AnimationFilter() |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 5949 | .animateHeight() |
| 5950 | .animateTopInset() |
| 5951 | .animateY() |
| 5952 | .animateZ() |
| 5953 | .hasDelays(), |
| 5954 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 5955 | // ANIMATION_TYPE_HEADS_UP_OTHER |
| 5956 | new AnimationFilter() |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 5957 | .animateHeight() |
| 5958 | .animateTopInset() |
| 5959 | .animateY() |
| 5960 | .animateZ(), |
| 5961 | |
Selim Cinek | d9acca5 | 2014-09-01 22:33:25 +0200 | [diff] [blame] | 5962 | // ANIMATION_TYPE_EVERYTHING |
| 5963 | new AnimationFilter() |
| 5964 | .animateAlpha() |
| 5965 | .animateDark() |
Selim Cinek | d9acca5 | 2014-09-01 22:33:25 +0200 | [diff] [blame] | 5966 | .animateDimmed() |
| 5967 | .animateHideSensitive() |
| 5968 | .animateHeight() |
| 5969 | .animateTopInset() |
| 5970 | .animateY() |
| 5971 | .animateZ(), |
Lucas Dupin | 4e02381 | 2018-04-02 21:19:23 -0700 | [diff] [blame] | 5972 | |
| 5973 | // ANIMATION_TYPE_PULSE_APPEAR |
| 5974 | new AnimationFilter() |
| 5975 | .animateAlpha() |
Lucas Dupin | 2a6bdfd | 2018-06-12 17:45:21 -0700 | [diff] [blame] | 5976 | .hasDelays() |
Lucas Dupin | 4e02381 | 2018-04-02 21:19:23 -0700 | [diff] [blame] | 5977 | .animateY(), |
| 5978 | |
| 5979 | // ANIMATION_TYPE_PULSE_DISAPPEAR |
| 5980 | new AnimationFilter() |
| 5981 | .animateAlpha() |
Lucas Dupin | 2a6bdfd | 2018-06-12 17:45:21 -0700 | [diff] [blame] | 5982 | .hasDelays() |
Lucas Dupin | 4e02381 | 2018-04-02 21:19:23 -0700 | [diff] [blame] | 5983 | .animateY(), |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 5984 | }; |
| 5985 | |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 5986 | static int[] LENGTHS = new int[]{ |
Jorim Jaggi | 5aa045c | 2014-05-07 21:42:40 +0200 | [diff] [blame] | 5987 | |
| 5988 | // ANIMATION_TYPE_ADD |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 5989 | StackStateAnimator.ANIMATION_DURATION_APPEAR_DISAPPEAR, |
Jorim Jaggi | 5aa045c | 2014-05-07 21:42:40 +0200 | [diff] [blame] | 5990 | |
| 5991 | // ANIMATION_TYPE_REMOVE |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 5992 | StackStateAnimator.ANIMATION_DURATION_APPEAR_DISAPPEAR, |
Jorim Jaggi | 5aa045c | 2014-05-07 21:42:40 +0200 | [diff] [blame] | 5993 | |
| 5994 | // ANIMATION_TYPE_REMOVE_SWIPED_OUT |
| 5995 | StackStateAnimator.ANIMATION_DURATION_STANDARD, |
| 5996 | |
| 5997 | // ANIMATION_TYPE_TOP_PADDING_CHANGED |
| 5998 | StackStateAnimator.ANIMATION_DURATION_STANDARD, |
| 5999 | |
Jorim Jaggi | 5aa045c | 2014-05-07 21:42:40 +0200 | [diff] [blame] | 6000 | // ANIMATION_TYPE_ACTIVATED_CHILD |
| 6001 | StackStateAnimator.ANIMATION_DURATION_DIMMED_ACTIVATED, |
| 6002 | |
| 6003 | // ANIMATION_TYPE_DIMMED |
| 6004 | StackStateAnimator.ANIMATION_DURATION_DIMMED_ACTIVATED, |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 6005 | |
| 6006 | // ANIMATION_TYPE_CHANGE_POSITION |
| 6007 | StackStateAnimator.ANIMATION_DURATION_STANDARD, |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 6008 | |
| 6009 | // ANIMATION_TYPE_DARK |
Adrian Roos | 28f90c7 | 2017-05-08 17:24:26 -0700 | [diff] [blame] | 6010 | StackStateAnimator.ANIMATION_DURATION_WAKEUP, |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 6011 | |
| 6012 | // ANIMATION_TYPE_GO_TO_FULL_SHADE |
| 6013 | StackStateAnimator.ANIMATION_DURATION_GO_TO_FULL_SHADE, |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 6014 | |
| 6015 | // ANIMATION_TYPE_HIDE_SENSITIVE |
| 6016 | StackStateAnimator.ANIMATION_DURATION_STANDARD, |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 6017 | |
| 6018 | // ANIMATION_TYPE_VIEW_RESIZE |
| 6019 | StackStateAnimator.ANIMATION_DURATION_STANDARD, |
Selim Cinek | d9acca5 | 2014-09-01 22:33:25 +0200 | [diff] [blame] | 6020 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 6021 | // ANIMATION_TYPE_GROUP_EXPANSION_CHANGED |
Selim Cinek | 9969559 | 2016-01-12 17:51:35 -0800 | [diff] [blame] | 6022 | StackStateAnimator.ANIMATION_DURATION_STANDARD, |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 6023 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 6024 | // ANIMATION_TYPE_HEADS_UP_APPEAR |
| 6025 | StackStateAnimator.ANIMATION_DURATION_HEADS_UP_APPEAR, |
| 6026 | |
| 6027 | // ANIMATION_TYPE_HEADS_UP_DISAPPEAR |
| 6028 | StackStateAnimator.ANIMATION_DURATION_HEADS_UP_DISAPPEAR, |
| 6029 | |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 6030 | // ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK |
| 6031 | StackStateAnimator.ANIMATION_DURATION_HEADS_UP_DISAPPEAR, |
| 6032 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 6033 | // ANIMATION_TYPE_HEADS_UP_OTHER |
| 6034 | StackStateAnimator.ANIMATION_DURATION_STANDARD, |
| 6035 | |
Selim Cinek | d9acca5 | 2014-09-01 22:33:25 +0200 | [diff] [blame] | 6036 | // ANIMATION_TYPE_EVERYTHING |
| 6037 | StackStateAnimator.ANIMATION_DURATION_STANDARD, |
Lucas Dupin | 4e02381 | 2018-04-02 21:19:23 -0700 | [diff] [blame] | 6038 | |
| 6039 | // ANIMATION_TYPE_PULSE_APPEAR |
Lucas Dupin | 2a6bdfd | 2018-06-12 17:45:21 -0700 | [diff] [blame] | 6040 | StackStateAnimator.ANIMATION_DURATION_PULSE_APPEAR, |
Lucas Dupin | 4e02381 | 2018-04-02 21:19:23 -0700 | [diff] [blame] | 6041 | |
| 6042 | // ANIMATION_TYPE_PULSE_DISAPPEAR |
Lucas Dupin | 2a6bdfd | 2018-06-12 17:45:21 -0700 | [diff] [blame] | 6043 | StackStateAnimator.ANIMATION_DURATION_PULSE_APPEAR / 2, |
Jorim Jaggi | 5aa045c | 2014-05-07 21:42:40 +0200 | [diff] [blame] | 6044 | }; |
| 6045 | |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 6046 | static final int ANIMATION_TYPE_ADD = 0; |
| 6047 | static final int ANIMATION_TYPE_REMOVE = 1; |
| 6048 | static final int ANIMATION_TYPE_REMOVE_SWIPED_OUT = 2; |
| 6049 | static final int ANIMATION_TYPE_TOP_PADDING_CHANGED = 3; |
Selim Cinek | ff2ffec | 2018-11-19 18:52:01 -0800 | [diff] [blame] | 6050 | static final int ANIMATION_TYPE_ACTIVATED_CHILD = 4; |
| 6051 | static final int ANIMATION_TYPE_DIMMED = 5; |
| 6052 | static final int ANIMATION_TYPE_CHANGE_POSITION = 6; |
| 6053 | static final int ANIMATION_TYPE_DARK = 7; |
| 6054 | static final int ANIMATION_TYPE_GO_TO_FULL_SHADE = 8; |
| 6055 | static final int ANIMATION_TYPE_HIDE_SENSITIVE = 9; |
| 6056 | static final int ANIMATION_TYPE_VIEW_RESIZE = 10; |
| 6057 | static final int ANIMATION_TYPE_GROUP_EXPANSION_CHANGED = 11; |
| 6058 | static final int ANIMATION_TYPE_HEADS_UP_APPEAR = 12; |
| 6059 | static final int ANIMATION_TYPE_HEADS_UP_DISAPPEAR = 13; |
| 6060 | static final int ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK = 14; |
| 6061 | static final int ANIMATION_TYPE_HEADS_UP_OTHER = 15; |
| 6062 | static final int ANIMATION_TYPE_EVERYTHING = 16; |
| 6063 | static final int ANIMATION_TYPE_PULSE_APPEAR = 17; |
| 6064 | static final int ANIMATION_TYPE_PULSE_DISAPPEAR = 18; |
Jorim Jaggi | 0dd6881 | 2014-05-01 19:17:37 +0200 | [diff] [blame] | 6065 | |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 6066 | static final int DARK_ANIMATION_ORIGIN_INDEX_ABOVE = -1; |
| 6067 | static final int DARK_ANIMATION_ORIGIN_INDEX_BELOW = -2; |
| 6068 | |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 6069 | final long eventStartTime; |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 6070 | final ExpandableView mChangingView; |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 6071 | final int animationType; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 6072 | final AnimationFilter filter; |
Jorim Jaggi | 5aa045c | 2014-05-07 21:42:40 +0200 | [diff] [blame] | 6073 | final long length; |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 6074 | View viewAfterChangingView; |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 6075 | int darkAnimationOriginIndex; |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 6076 | boolean headsUpFromBottom; |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 6077 | |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 6078 | AnimationEvent(ExpandableView view, int type) { |
Jorim Jaggi | ff9c9c4 | 2014-08-01 05:36:22 +0200 | [diff] [blame] | 6079 | this(view, type, LENGTHS[type]); |
| 6080 | } |
| 6081 | |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 6082 | AnimationEvent(ExpandableView view, int type, AnimationFilter filter) { |
Adrian Roos | 28f90c7 | 2017-05-08 17:24:26 -0700 | [diff] [blame] | 6083 | this(view, type, LENGTHS[type], filter); |
| 6084 | } |
| 6085 | |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 6086 | AnimationEvent(ExpandableView view, int type, long length) { |
Adrian Roos | 28f90c7 | 2017-05-08 17:24:26 -0700 | [diff] [blame] | 6087 | this(view, type, length, FILTERS[type]); |
| 6088 | } |
| 6089 | |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 6090 | AnimationEvent(ExpandableView view, int type, long length, AnimationFilter filter) { |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 6091 | eventStartTime = AnimationUtils.currentAnimationTimeMillis(); |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 6092 | mChangingView = view; |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 6093 | animationType = type; |
Jorim Jaggi | ff9c9c4 | 2014-08-01 05:36:22 +0200 | [diff] [blame] | 6094 | this.length = length; |
Adrian Roos | 28f90c7 | 2017-05-08 17:24:26 -0700 | [diff] [blame] | 6095 | this.filter = filter; |
Jorim Jaggi | 5aa045c | 2014-05-07 21:42:40 +0200 | [diff] [blame] | 6096 | } |
| 6097 | |
| 6098 | /** |
| 6099 | * Combines the length of several animation events into a single value. |
| 6100 | * |
| 6101 | * @param events The events of the lengths to combine. |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 6102 | * @return The combined length. Depending on the event types, this might be the maximum of |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 6103 | * all events or the length of a specific event. |
Jorim Jaggi | 5aa045c | 2014-05-07 21:42:40 +0200 | [diff] [blame] | 6104 | */ |
| 6105 | static long combineLength(ArrayList<AnimationEvent> events) { |
| 6106 | long length = 0; |
| 6107 | int size = events.size(); |
| 6108 | for (int i = 0; i < size; i++) { |
Jorim Jaggi | 60d07c5 | 2014-07-31 15:38:21 +0200 | [diff] [blame] | 6109 | AnimationEvent event = events.get(i); |
| 6110 | length = Math.max(length, event.length); |
| 6111 | if (event.animationType == ANIMATION_TYPE_GO_TO_FULL_SHADE) { |
| 6112 | return event.length; |
| 6113 | } |
Jorim Jaggi | 5aa045c | 2014-05-07 21:42:40 +0200 | [diff] [blame] | 6114 | } |
| 6115 | return length; |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 6116 | } |
| 6117 | } |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 6118 | |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6119 | @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) |
| 6120 | private final StateListener mStateListener = new StateListener() { |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 6121 | @Override |
| 6122 | public void onStatePreChange(int oldState, int newState) { |
| 6123 | if (oldState == StatusBarState.SHADE_LOCKED && newState == StatusBarState.KEYGUARD) { |
| 6124 | requestAnimateEverything(); |
| 6125 | } |
| 6126 | } |
| 6127 | |
| 6128 | @Override |
| 6129 | public void onStateChanged(int newState) { |
| 6130 | setStatusBarState(newState); |
| 6131 | } |
Evan Laird | 91d0f10 | 2018-09-18 17:39:55 -0400 | [diff] [blame] | 6132 | |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6133 | @Override |
| 6134 | public void onStatePostChange() { |
Evan Laird | 91d0f10 | 2018-09-18 17:39:55 -0400 | [diff] [blame] | 6135 | NotificationStackScrollLayout.this.onStatePostChange(); |
| 6136 | } |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6137 | }; |
| 6138 | |
Will Brockman | e718d58 | 2019-01-17 16:38:38 -0500 | [diff] [blame] | 6139 | @VisibleForTesting |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 6140 | @ShadeViewRefactor(RefactorComponent.INPUT) |
Will Brockman | e718d58 | 2019-01-17 16:38:38 -0500 | [diff] [blame] | 6141 | protected final OnMenuEventListener mMenuEventListener = new OnMenuEventListener() { |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6142 | @Override |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6143 | public void onMenuClicked(View view, int x, int y, MenuItem item) { |
| 6144 | if (mLongPressListener == null) { |
| 6145 | return; |
| 6146 | } |
| 6147 | if (view instanceof ExpandableNotificationRow) { |
| 6148 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
Will Brockman | e718d58 | 2019-01-17 16:38:38 -0500 | [diff] [blame] | 6149 | mMetricsLogger.write(row.getStatusBarNotification().getLogMaker() |
| 6150 | .setCategory(MetricsEvent.ACTION_TOUCH_GEAR) |
| 6151 | .setType(MetricsEvent.TYPE_ACTION) |
| 6152 | ); |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6153 | } |
| 6154 | mLongPressListener.onLongPress(view, x, y, item); |
| 6155 | } |
| 6156 | |
| 6157 | @Override |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6158 | public void onMenuReset(View row) { |
| 6159 | View translatingParentView = mSwipeHelper.getTranslatingParentView(); |
| 6160 | if (translatingParentView != null && row == translatingParentView) { |
| 6161 | mSwipeHelper.clearExposedMenuView(); |
| 6162 | mSwipeHelper.clearTranslatingParentView(); |
Gus Prevas | 21118153 | 2018-12-13 14:49:33 -0500 | [diff] [blame] | 6163 | if (row instanceof ExpandableNotificationRow) { |
| 6164 | mHeadsUpManager.setMenuShown( |
| 6165 | ((ExpandableNotificationRow) row).getEntry(), false); |
| 6166 | |
| 6167 | } |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6168 | } |
| 6169 | } |
| 6170 | |
| 6171 | @Override |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6172 | public void onMenuShown(View row) { |
| 6173 | if (row instanceof ExpandableNotificationRow) { |
Gus Prevas | 21118153 | 2018-12-13 14:49:33 -0500 | [diff] [blame] | 6174 | ExpandableNotificationRow notificationRow = (ExpandableNotificationRow) row; |
Will Brockman | e718d58 | 2019-01-17 16:38:38 -0500 | [diff] [blame] | 6175 | mMetricsLogger.write(notificationRow.getStatusBarNotification().getLogMaker() |
| 6176 | .setCategory(MetricsEvent.ACTION_REVEAL_GEAR) |
| 6177 | .setType(MetricsEvent.TYPE_ACTION)); |
Gus Prevas | 21118153 | 2018-12-13 14:49:33 -0500 | [diff] [blame] | 6178 | mHeadsUpManager.setMenuShown(notificationRow.getEntry(), true); |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6179 | } |
| 6180 | mSwipeHelper.onMenuShown(row); |
| 6181 | } |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 6182 | }; |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6183 | |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 6184 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 6185 | private final NotificationSwipeHelper.NotificationCallback mNotificationCallback = |
| 6186 | new NotificationSwipeHelper.NotificationCallback() { |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6187 | @Override |
| 6188 | public void onDismiss() { |
| 6189 | mNotificationGutsManager.closeAndSaveGuts(true /* removeLeavebehind */, |
| 6190 | false /* force */, false /* removeControls */, -1 /* x */, -1 /* y */, |
| 6191 | false /* resetMenu */); |
| 6192 | } |
| 6193 | |
| 6194 | @Override |
| 6195 | public void onSnooze(StatusBarNotification sbn, |
| 6196 | NotificationSwipeActionHelper.SnoozeOption snoozeOption) { |
| 6197 | mStatusBar.setNotificationSnoozed(sbn, snoozeOption); |
| 6198 | } |
| 6199 | |
| 6200 | @Override |
| 6201 | public boolean isExpanded() { |
| 6202 | return NotificationStackScrollLayout.this.isExpanded(); |
| 6203 | } |
| 6204 | |
| 6205 | @Override |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6206 | public void onDragCancelled(View v) { |
Aaron Heuckroth | 9dc9d4f | 2018-11-15 11:04:01 -0500 | [diff] [blame] | 6207 | setSwipingInProgress(false); |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6208 | mFalsingManager.onNotificatonStopDismissing(); |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6209 | } |
| 6210 | |
| 6211 | /** |
| 6212 | * Handles cleanup after the given {@code view} has been fully swiped out (including |
| 6213 | * re-invoking dismiss logic in case the notification has not made its way out yet). |
| 6214 | */ |
| 6215 | @Override |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6216 | public void onChildDismissed(View view) { |
| 6217 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
| 6218 | if (!row.isDismissed()) { |
| 6219 | handleChildViewDismissed(view); |
| 6220 | } |
| 6221 | ViewGroup transientContainer = row.getTransientContainer(); |
| 6222 | if (transientContainer != null) { |
| 6223 | transientContainer.removeTransientView(view); |
| 6224 | } |
| 6225 | } |
| 6226 | |
| 6227 | /** |
| 6228 | * Starts up notification dismiss and tells the notification, if any, to remove itself from |
| 6229 | * layout. |
| 6230 | * |
| 6231 | * @param view view (e.g. notification) to dismiss from the layout |
| 6232 | */ |
| 6233 | |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6234 | public void handleChildViewDismissed(View view) { |
Aaron Heuckroth | 9dc9d4f | 2018-11-15 11:04:01 -0500 | [diff] [blame] | 6235 | setSwipingInProgress(false); |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6236 | if (mDismissAllInProgress) { |
| 6237 | return; |
| 6238 | } |
| 6239 | |
| 6240 | boolean isBlockingHelperShown = false; |
| 6241 | |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6242 | mAmbientState.onDragFinished(view); |
| 6243 | updateContinuousShadowDrawing(); |
| 6244 | |
| 6245 | if (view instanceof ExpandableNotificationRow) { |
| 6246 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
| 6247 | if (row.isHeadsUp()) { |
| 6248 | mHeadsUpManager.addSwipedOutNotification( |
| 6249 | row.getStatusBarNotification().getKey()); |
| 6250 | } |
| 6251 | isBlockingHelperShown = |
| 6252 | row.performDismissWithBlockingHelper(false /* fromAccessibility */); |
| 6253 | } |
| 6254 | |
| 6255 | if (!isBlockingHelperShown) { |
| 6256 | mSwipedOutViews.add(view); |
| 6257 | } |
| 6258 | mFalsingManager.onNotificationDismissed(); |
| 6259 | if (mFalsingManager.shouldEnforceBouncer()) { |
| 6260 | mStatusBar.executeRunnableDismissingKeyguard( |
| 6261 | null, |
| 6262 | null /* cancelAction */, |
| 6263 | false /* dismissShade */, |
| 6264 | true /* afterKeyguardGone */, |
| 6265 | false /* deferred */); |
| 6266 | } |
| 6267 | } |
| 6268 | |
| 6269 | @Override |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6270 | public boolean isAntiFalsingNeeded() { |
| 6271 | return onKeyguard(); |
| 6272 | } |
| 6273 | |
| 6274 | @Override |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6275 | public View getChildAtPosition(MotionEvent ev) { |
| 6276 | View child = NotificationStackScrollLayout.this.getChildAtPosition(ev.getX(), |
| 6277 | ev.getY()); |
| 6278 | if (child instanceof ExpandableNotificationRow) { |
| 6279 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 6280 | ExpandableNotificationRow parent = row.getNotificationParent(); |
| 6281 | if (parent != null && parent.areChildrenExpanded() |
| 6282 | && (parent.areGutsExposed() |
| 6283 | || mSwipeHelper.getExposedMenuView() == parent |
| 6284 | || (parent.getNotificationChildren().size() == 1 |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 6285 | && parent.getEntry().isClearable()))) { |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6286 | // In this case the group is expanded and showing the menu for the |
| 6287 | // group, further interaction should apply to the group, not any |
| 6288 | // child notifications so we use the parent of the child. We also do the same |
| 6289 | // if we only have a single child. |
| 6290 | child = parent; |
| 6291 | } |
| 6292 | } |
| 6293 | return child; |
| 6294 | } |
| 6295 | |
| 6296 | @Override |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6297 | public void onBeginDrag(View v) { |
| 6298 | mFalsingManager.onNotificatonStartDismissing(); |
Aaron Heuckroth | 9dc9d4f | 2018-11-15 11:04:01 -0500 | [diff] [blame] | 6299 | setSwipingInProgress(true); |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 6300 | mAmbientState.onBeginDrag((ExpandableView) v); |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6301 | updateContinuousShadowDrawing(); |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6302 | requestChildrenUpdate(); |
| 6303 | } |
| 6304 | |
| 6305 | @Override |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6306 | public void onChildSnappedBack(View animView, float targetLeft) { |
| 6307 | mAmbientState.onDragFinished(animView); |
| 6308 | updateContinuousShadowDrawing(); |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6309 | NotificationMenuRowPlugin menuRow = mSwipeHelper.getCurrentMenuRow(); |
| 6310 | if (menuRow != null && targetLeft == 0) { |
| 6311 | menuRow.resetMenu(); |
| 6312 | mSwipeHelper.clearCurrentMenuRow(); |
| 6313 | } |
| 6314 | } |
| 6315 | |
| 6316 | @Override |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6317 | public boolean updateSwipeProgress(View animView, boolean dismissable, |
| 6318 | float swipeProgress) { |
| 6319 | // Returning true prevents alpha fading. |
| 6320 | return !mFadeNotificationsOnDismiss; |
| 6321 | } |
| 6322 | |
| 6323 | @Override |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6324 | public float getFalsingThresholdFactor() { |
| 6325 | return mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f; |
| 6326 | } |
| 6327 | |
| 6328 | @Override |
Gus Prevas | c4e68d4 | 2019-01-17 15:45:21 -0500 | [diff] [blame] | 6329 | public int getConstrainSwipeStartPosition() { |
| 6330 | NotificationMenuRowPlugin menuRow = mSwipeHelper.getCurrentMenuRow(); |
| 6331 | if (menuRow != null) { |
| 6332 | return Math.abs(menuRow.getMenuSnapTarget()); |
| 6333 | } |
| 6334 | return 0; |
| 6335 | } |
| 6336 | |
| 6337 | @Override |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6338 | public boolean canChildBeDismissed(View v) { |
| 6339 | return NotificationStackScrollLayout.this.canChildBeDismissed(v); |
| 6340 | } |
Gus Prevas | 37d67e2 | 2018-11-02 14:48:55 -0400 | [diff] [blame] | 6341 | |
| 6342 | @Override |
| 6343 | public boolean canChildBeDismissedInDirection(View v, boolean isRightOrDown) { |
Gus Prevas | 50e3899 | 2018-11-14 10:33:44 -0500 | [diff] [blame] | 6344 | boolean isValidDirection; |
| 6345 | if (NotificationUtils.useNewInterruptionModel(mContext)) { |
Gus Prevas | a18dc57 | 2019-01-14 16:11:22 -0500 | [diff] [blame] | 6346 | isValidDirection = mDismissRtl ? !isRightOrDown : isRightOrDown; |
Gus Prevas | 50e3899 | 2018-11-14 10:33:44 -0500 | [diff] [blame] | 6347 | } else { |
| 6348 | isValidDirection = true; |
| 6349 | } |
| 6350 | return isValidDirection && canChildBeDismissed(v); |
Gus Prevas | 37d67e2 | 2018-11-02 14:48:55 -0400 | [diff] [blame] | 6351 | } |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 6352 | }; |
| 6353 | |
| 6354 | // ---------------------- DragDownHelper.OnDragDownListener ------------------------------------ |
| 6355 | |
| 6356 | @ShadeViewRefactor(RefactorComponent.INPUT) |
| 6357 | private final DragDownCallback mDragDownCallback = new DragDownCallback() { |
| 6358 | |
| 6359 | /* Only ever called as a consequence of a lockscreen expansion gesture. */ |
| 6360 | @Override |
| 6361 | public boolean onDraggedDown(View startingChild, int dragLengthY) { |
| 6362 | if (mStatusBarState == StatusBarState.KEYGUARD |
Lucas Dupin | 55c6e80 | 2018-09-27 18:07:36 -0700 | [diff] [blame] | 6363 | && hasActiveNotifications()) { |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 6364 | mLockscreenGestureLogger.write( |
| 6365 | MetricsEvent.ACTION_LS_SHADE, |
| 6366 | (int) (dragLengthY / mDisplayMetrics.density), |
| 6367 | 0 /* velocityDp - N/A */); |
| 6368 | |
Lucas Dupin | c780404 | 2018-12-21 12:26:33 -0800 | [diff] [blame] | 6369 | if (!mAmbientState.isDark() || startingChild != null) { |
Lucas Dupin | 55c6e80 | 2018-09-27 18:07:36 -0700 | [diff] [blame] | 6370 | // We have notifications, go to locked shade. |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 6371 | mShadeController.goToLockedShade(startingChild); |
Lucas Dupin | 55c6e80 | 2018-09-27 18:07:36 -0700 | [diff] [blame] | 6372 | if (startingChild instanceof ExpandableNotificationRow) { |
| 6373 | ExpandableNotificationRow row = (ExpandableNotificationRow) startingChild; |
| 6374 | row.onExpandedByGesture(true /* drag down is always an open */); |
| 6375 | } |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 6376 | } |
Lucas Dupin | 55c6e80 | 2018-09-27 18:07:36 -0700 | [diff] [blame] | 6377 | |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 6378 | return true; |
| 6379 | } else { |
| 6380 | // abort gesture. |
| 6381 | return false; |
| 6382 | } |
| 6383 | } |
| 6384 | |
| 6385 | @Override |
| 6386 | public void onDragDownReset() { |
| 6387 | setDimmed(true /* dimmed */, true /* animated */); |
| 6388 | resetScrollPosition(); |
| 6389 | resetCheckSnoozeLeavebehind(); |
| 6390 | } |
| 6391 | |
| 6392 | @Override |
| 6393 | public void onCrossedThreshold(boolean above) { |
| 6394 | setDimmed(!above /* dimmed */, true /* animate */); |
| 6395 | } |
| 6396 | |
| 6397 | @Override |
| 6398 | public void onTouchSlopExceeded() { |
| 6399 | cancelLongPress(); |
| 6400 | checkSnoozeLeavebehind(); |
| 6401 | } |
| 6402 | |
| 6403 | @Override |
| 6404 | public void setEmptyDragAmount(float amount) { |
| 6405 | mNotificationPanel.setEmptyDragAmount(amount); |
| 6406 | } |
| 6407 | |
| 6408 | @Override |
| 6409 | public boolean isFalsingCheckNeeded() { |
| 6410 | return mStatusBarState == StatusBarState.KEYGUARD; |
| 6411 | } |
| 6412 | }; |
| 6413 | |
| 6414 | public DragDownCallback getDragDownCallback() { return mDragDownCallback; } |
| 6415 | |
| 6416 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
| 6417 | private final HeadsUpTouchHelper.Callback mHeadsUpCallback = new HeadsUpTouchHelper.Callback() { |
| 6418 | @Override |
| 6419 | public ExpandableView getChildAtRawPosition(float touchX, float touchY) { |
| 6420 | return NotificationStackScrollLayout.this.getChildAtRawPosition(touchX, touchY); |
| 6421 | } |
| 6422 | |
| 6423 | @Override |
| 6424 | public boolean isExpanded() { |
| 6425 | return mIsExpanded; |
| 6426 | } |
| 6427 | |
| 6428 | @Override |
| 6429 | public Context getContext() { |
| 6430 | return mContext; |
| 6431 | } |
| 6432 | }; |
| 6433 | |
| 6434 | public HeadsUpTouchHelper.Callback getHeadsUpCallback() { return mHeadsUpCallback; } |
| 6435 | |
| 6436 | |
| 6437 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
| 6438 | private final OnGroupChangeListener mOnGroupChangeListener = new OnGroupChangeListener() { |
| 6439 | @Override |
| 6440 | public void onGroupExpansionChanged(ExpandableNotificationRow changedRow, boolean expanded) { |
| 6441 | boolean animated = !mGroupExpandedForMeasure && mAnimationsEnabled |
| 6442 | && (mIsExpanded || changedRow.isPinned()); |
| 6443 | if (animated) { |
| 6444 | mExpandedGroupView = changedRow; |
| 6445 | mNeedsAnimation = true; |
| 6446 | } |
| 6447 | changedRow.setChildrenExpanded(expanded, animated); |
| 6448 | if (!mGroupExpandedForMeasure) { |
| 6449 | onHeightChanged(changedRow, false /* needsAnimation */); |
| 6450 | } |
| 6451 | runAfterAnimationFinished(new Runnable() { |
| 6452 | @Override |
| 6453 | public void run() { |
| 6454 | changedRow.onFinishedExpansionChange(); |
| 6455 | } |
| 6456 | }); |
| 6457 | } |
| 6458 | |
| 6459 | @Override |
| 6460 | public void onGroupCreatedFromChildren(NotificationGroupManager.NotificationGroup group) { |
| 6461 | mStatusBar.requestNotificationUpdate(); |
| 6462 | } |
| 6463 | |
| 6464 | @Override |
| 6465 | public void onGroupsChanged() { |
| 6466 | mStatusBar.requestNotificationUpdate(); |
| 6467 | } |
| 6468 | }; |
| 6469 | |
| 6470 | @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) |
| 6471 | private ExpandHelper.Callback mExpandHelperCallback = new ExpandHelper.Callback() { |
| 6472 | @Override |
| 6473 | public ExpandableView getChildAtPosition(float touchX, float touchY) { |
| 6474 | return NotificationStackScrollLayout.this.getChildAtPosition(touchX, touchY); |
| 6475 | } |
| 6476 | |
| 6477 | @Override |
| 6478 | public ExpandableView getChildAtRawPosition(float touchX, float touchY) { |
| 6479 | return NotificationStackScrollLayout.this.getChildAtRawPosition(touchX, touchY); |
| 6480 | } |
| 6481 | |
| 6482 | @Override |
| 6483 | public boolean canChildBeExpanded(View v) { |
| 6484 | return v instanceof ExpandableNotificationRow |
| 6485 | && ((ExpandableNotificationRow) v).isExpandable() |
| 6486 | && !((ExpandableNotificationRow) v).areGutsExposed() |
| 6487 | && (mIsExpanded || !((ExpandableNotificationRow) v).isPinned()); |
| 6488 | } |
| 6489 | |
| 6490 | /* Only ever called as a consequence of an expansion gesture in the shade. */ |
| 6491 | @Override |
| 6492 | public void setUserExpandedChild(View v, boolean userExpanded) { |
| 6493 | if (v instanceof ExpandableNotificationRow) { |
| 6494 | ExpandableNotificationRow row = (ExpandableNotificationRow) v; |
| 6495 | if (userExpanded && onKeyguard()) { |
| 6496 | // Due to a race when locking the screen while touching, a notification may be |
| 6497 | // expanded even after we went back to keyguard. An example of this happens if |
| 6498 | // you click in the empty space while expanding a group. |
| 6499 | |
| 6500 | // We also need to un-user lock it here, since otherwise the content height |
| 6501 | // calculated might be wrong. We also can't invert the two calls since |
| 6502 | // un-userlocking it will trigger a layout switch in the content view. |
| 6503 | row.setUserLocked(false); |
| 6504 | updateContentHeight(); |
| 6505 | notifyHeightChangeListener(row); |
| 6506 | return; |
| 6507 | } |
| 6508 | row.setUserExpanded(userExpanded, true /* allowChildrenExpansion */); |
| 6509 | row.onExpandedByGesture(userExpanded); |
| 6510 | } |
| 6511 | } |
| 6512 | |
| 6513 | @Override |
| 6514 | public void setExpansionCancelled(View v) { |
| 6515 | if (v instanceof ExpandableNotificationRow) { |
| 6516 | ((ExpandableNotificationRow) v).setGroupExpansionChanging(false); |
| 6517 | } |
| 6518 | } |
| 6519 | |
| 6520 | @Override |
| 6521 | public void setUserLockedChild(View v, boolean userLocked) { |
| 6522 | if (v instanceof ExpandableNotificationRow) { |
| 6523 | ((ExpandableNotificationRow) v).setUserLocked(userLocked); |
| 6524 | } |
| 6525 | cancelLongPress(); |
| 6526 | requestDisallowInterceptTouchEvent(true); |
| 6527 | } |
| 6528 | |
| 6529 | @Override |
| 6530 | public void expansionStateChanged(boolean isExpanding) { |
| 6531 | mExpandingNotification = isExpanding; |
| 6532 | if (!mExpandedInThisMotion) { |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 6533 | if (ANCHOR_SCROLLING) { |
| 6534 | // TODO |
| 6535 | } else { |
| 6536 | mMaxScrollAfterExpand = mOwnScrollY; |
| 6537 | } |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 6538 | mExpandedInThisMotion = true; |
| 6539 | } |
| 6540 | } |
| 6541 | |
| 6542 | @Override |
| 6543 | public int getMaxExpandHeight(ExpandableView view) { |
| 6544 | return view.getMaxContentHeight(); |
| 6545 | } |
| 6546 | }; |
| 6547 | |
| 6548 | public ExpandHelper.Callback getExpandHelperCallback() { |
| 6549 | return mExpandHelperCallback; |
Aaron Heuckroth | 45d20be | 2018-09-18 13:47:26 -0400 | [diff] [blame] | 6550 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 6551 | } |