Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.statusbar; |
| 18 | |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 19 | import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator.ExpandAnimationParameters; |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 20 | import static com.android.systemui.statusbar.notification.NotificationInflater.InflationCallback; |
Selim Cinek | c478f90 | 2017-02-22 20:55:44 -0800 | [diff] [blame] | 21 | |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 22 | import android.animation.Animator; |
| 23 | import android.animation.AnimatorListenerAdapter; |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 24 | import android.animation.ObjectAnimator; |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 25 | import android.animation.ValueAnimator.AnimatorUpdateListener; |
Selim Cinek | ddf1b39 | 2016-05-27 16:33:10 -0700 | [diff] [blame] | 26 | import android.annotation.Nullable; |
Rohan Shah | 63411fc | 2018-03-28 19:05:52 -0700 | [diff] [blame] | 27 | import android.app.NotificationChannel; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 28 | import android.content.Context; |
Rohan Shah | 63411fc | 2018-03-28 19:05:52 -0700 | [diff] [blame] | 29 | import android.content.pm.PackageInfo; |
| 30 | import android.content.pm.PackageManager; |
Mady Mellor | 9d03a52 | 2017-04-04 18:45:30 -0700 | [diff] [blame] | 31 | import android.content.res.Configuration; |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 32 | import android.content.res.Resources; |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 33 | import android.graphics.Path; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 34 | import android.graphics.drawable.AnimatedVectorDrawable; |
| 35 | import android.graphics.drawable.AnimationDrawable; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 36 | import android.graphics.drawable.ColorDrawable; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 37 | import android.graphics.drawable.Drawable; |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 38 | import android.os.AsyncTask; |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 39 | import android.os.Build; |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 40 | import android.os.Bundle; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 41 | import android.service.notification.StatusBarNotification; |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 42 | import android.util.ArraySet; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 43 | import android.util.AttributeSet; |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 44 | import android.util.FloatProperty; |
Rohan Shah | 63411fc | 2018-03-28 19:05:52 -0700 | [diff] [blame] | 45 | import android.util.Log; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 46 | import android.util.MathUtils; |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 47 | import android.util.Property; |
Geoffrey Pitsch | 409db27 | 2017-08-28 14:51:52 +0000 | [diff] [blame] | 48 | import android.view.KeyEvent; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 49 | import android.view.LayoutInflater; |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 50 | import android.view.MotionEvent; |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 51 | import android.view.NotificationHeaderView; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 52 | import android.view.View; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 53 | import android.view.ViewGroup; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 54 | import android.view.ViewStub; |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 55 | import android.view.accessibility.AccessibilityEvent; |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 56 | import android.view.accessibility.AccessibilityNodeInfo; |
Mady Mellor | b3a6aed | 2018-05-11 13:24:07 -0700 | [diff] [blame] | 57 | import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 58 | import android.widget.Chronometer; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 59 | import android.widget.FrameLayout; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 60 | import android.widget.ImageView; |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 61 | import android.widget.RemoteViews; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 62 | |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 63 | import com.android.internal.annotations.VisibleForTesting; |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame] | 64 | import com.android.internal.logging.MetricsLogger; |
Tamas Berghammer | 383db5eb | 2016-06-22 15:21:38 +0100 | [diff] [blame] | 65 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Selim Cinek | 4bb5934 | 2016-04-08 19:29:35 -0700 | [diff] [blame] | 66 | import com.android.internal.util.NotificationColorUtil; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 67 | import com.android.internal.widget.CachingIconView; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 68 | import com.android.systemui.Dependency; |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 69 | import com.android.systemui.Interpolators; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 70 | import com.android.systemui.R; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 71 | import com.android.systemui.classifier.FalsingManager; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 72 | import com.android.systemui.plugins.PluginListener; |
| 73 | import com.android.systemui.plugins.PluginManager; |
| 74 | import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; |
| 75 | import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem; |
| 76 | import com.android.systemui.statusbar.NotificationGuts.GutsContent; |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 77 | import com.android.systemui.statusbar.notification.AboveShelfChangedListener; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 78 | import com.android.systemui.statusbar.notification.ActivityLaunchAnimator; |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 79 | import com.android.systemui.statusbar.notification.HybridNotificationView; |
Rohan Shah | da5dcdd | 2018-04-27 17:21:50 -0700 | [diff] [blame] | 80 | import com.android.systemui.statusbar.notification.NotificationCounters; |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 81 | import com.android.systemui.statusbar.notification.NotificationInflater; |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 82 | import com.android.systemui.statusbar.notification.NotificationUtils; |
Selim Cinek | e62255c | 2017-09-28 18:23:23 -0700 | [diff] [blame] | 83 | import com.android.systemui.statusbar.notification.NotificationViewWrapper; |
Selim Cinek | a7d4f82 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 84 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 85 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 86 | import com.android.systemui.statusbar.phone.StatusBar; |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 87 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 88 | import com.android.systemui.statusbar.stack.AmbientState; |
Selim Cinek | 0cfbef4 | 2016-11-09 19:06:36 -0800 | [diff] [blame] | 89 | import com.android.systemui.statusbar.stack.AnimationProperties; |
| 90 | import com.android.systemui.statusbar.stack.ExpandableViewState; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 91 | import com.android.systemui.statusbar.stack.NotificationChildrenContainer; |
| 92 | import com.android.systemui.statusbar.stack.StackScrollState; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 93 | |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 94 | import java.util.ArrayList; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 95 | import java.util.List; |
Lucas Dupin | cecc7c2 | 2017-09-12 16:02:45 -0700 | [diff] [blame] | 96 | import java.util.function.BooleanSupplier; |
Selim Cinek | 8875de1 | 2018-03-22 10:14:32 -0700 | [diff] [blame] | 97 | import java.util.function.Consumer; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 98 | |
Rohan Shah | 63411fc | 2018-03-28 19:05:52 -0700 | [diff] [blame] | 99 | /** |
| 100 | * View representing a notification item - this can be either the individual child notification or |
| 101 | * the group summary (which contains 1 or more child notifications). |
| 102 | */ |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 103 | public class ExpandableNotificationRow extends ActivatableNotificationView |
| 104 | implements PluginListener<NotificationMenuRowPlugin> { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 105 | |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 106 | private static final boolean DEBUG = false; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 107 | private static final int DEFAULT_DIVIDER_ALPHA = 0x29; |
| 108 | private static final int COLORED_DIVIDER_ALPHA = 0x7B; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 109 | private static final int MENU_VIEW_INDEX = 0; |
Rohan Shah | 63411fc | 2018-03-28 19:05:52 -0700 | [diff] [blame] | 110 | private static final String TAG = "ExpandableNotifRow"; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 111 | |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 112 | /** |
| 113 | * Listener for when {@link ExpandableNotificationRow} is laid out. |
| 114 | */ |
Mady Mellor | 035badd | 2017-04-04 18:45:30 -0700 | [diff] [blame] | 115 | public interface LayoutListener { |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 116 | void onLayout(); |
Mady Mellor | 035badd | 2017-04-04 18:45:30 -0700 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | private LayoutListener mLayoutListener; |
Lucas Dupin | cecc7c2 | 2017-09-12 16:02:45 -0700 | [diff] [blame] | 120 | private boolean mDark; |
Selim Cinek | 55a3e73 | 2017-05-25 18:30:10 -0700 | [diff] [blame] | 121 | private boolean mLowPriorityStateUpdated; |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 122 | private final NotificationInflater mNotificationInflater; |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 123 | private int mIconTransformContentShift; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 124 | private int mIconTransformContentShiftNoIcon; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 125 | private int mNotificationMinHeightLegacy; |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 126 | private int mNotificationMinHeightBeforeP; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 127 | private int mMaxHeadsUpHeightLegacy; |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 128 | private int mMaxHeadsUpHeightBeforeP; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 129 | private int mMaxHeadsUpHeight; |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 130 | private int mMaxHeadsUpHeightIncreased; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 131 | private int mNotificationMinHeight; |
Selim Cinek | 7d1009b | 2017-01-25 15:28:28 -0800 | [diff] [blame] | 132 | private int mNotificationMinHeightLarge; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 133 | private int mNotificationMaxHeight; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 134 | private int mNotificationAmbientHeight; |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 135 | private int mIncreasedPaddingBetweenElements; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 136 | private int mNotificationLaunchHeight; |
Selim Cinek | 9b9d6e1 | 2017-11-30 12:29:47 +0100 | [diff] [blame] | 137 | private boolean mMustStayOnScreen; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 138 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 139 | /** Does this row contain layouts that can adapt to row expansion */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 140 | private boolean mExpandable; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 141 | /** Has the user actively changed the expansion state of this row */ |
| 142 | private boolean mHasUserChangedExpansion; |
| 143 | /** If {@link #mHasUserChangedExpansion}, has the user expanded this row */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 144 | private boolean mUserExpanded; |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 145 | /** Whether the blocking helper is showing on this notification (even if dismissed) */ |
| 146 | private boolean mIsBlockingHelperShowing; |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 147 | |
| 148 | /** |
| 149 | * Has this notification been expanded while it was pinned |
| 150 | */ |
| 151 | private boolean mExpandedWhenPinned; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 152 | /** Is the user touching this row */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 153 | private boolean mUserLocked; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 154 | /** Are we showing the "public" version */ |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 155 | private boolean mShowingPublic; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 156 | private boolean mSensitive; |
Selim Cinek | 3c76d50 | 2016-02-19 15:16:33 -0800 | [diff] [blame] | 157 | private boolean mSensitiveHiddenInGeneral; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 158 | private boolean mShowingPublicInitialized; |
Selim Cinek | 60122be | 2015-04-15 18:16:50 -0700 | [diff] [blame] | 159 | private boolean mHideSensitiveForIntrinsicHeight; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 160 | private float mHeaderVisibleAmount = 1.0f; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 161 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 162 | /** |
| 163 | * Is this notification expanded by the system. The expansion state can be overridden by the |
| 164 | * user expansion. |
| 165 | */ |
| 166 | private boolean mIsSystemExpanded; |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 167 | |
| 168 | /** |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 169 | * Whether the notification is on the keyguard and the expansion is disabled. |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 170 | */ |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 171 | private boolean mOnKeyguard; |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 172 | |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 173 | private Animator mTranslateAnim; |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 174 | private ArrayList<View> mTranslateableViews; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 175 | private NotificationContentView mPublicLayout; |
| 176 | private NotificationContentView mPrivateLayout; |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 177 | private NotificationContentView[] mLayouts; |
Selim Cinek | 4bb5934 | 2016-04-08 19:29:35 -0700 | [diff] [blame] | 178 | private int mNotificationColor; |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 179 | private ExpansionLogger mLogger; |
| 180 | private String mLoggingKey; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 181 | private NotificationGuts mGuts; |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 182 | private NotificationData.Entry mEntry; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 183 | private StatusBarNotification mStatusBarNotification; |
Mady Mellor | 3fd273e | 2016-03-15 21:08:14 -0700 | [diff] [blame] | 184 | private String mAppName; |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 185 | private boolean mIsHeadsUp; |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 186 | private boolean mLastChronometerRunning = true; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 187 | private ViewStub mChildrenContainerStub; |
| 188 | private NotificationGroupManager mGroupManager; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 189 | private boolean mChildrenExpanded; |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 190 | private boolean mIsSummaryWithChildren; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 191 | private NotificationChildrenContainer mChildrenContainer; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 192 | private NotificationMenuRowPlugin mMenuRow; |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 193 | private ViewStub mGutsStub; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 194 | private boolean mIsSystemChildExpanded; |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 195 | private boolean mIsPinned; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 196 | private FalsingManager mFalsingManager; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 197 | private boolean mExpandAnimationRunning; |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 198 | private AboveShelfChangedListener mAboveShelfChangedListener; |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 199 | private HeadsUpManager mHeadsUpManager; |
Selim Cinek | 8875de1 | 2018-03-22 10:14:32 -0700 | [diff] [blame] | 200 | private Consumer<Boolean> mHeadsUpAnimatingAwayListener; |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 201 | private boolean mChildIsExpanding; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 202 | |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 203 | private boolean mJustClicked; |
Selim Cinek | 5a175d9 | 2015-11-23 18:01:33 -0800 | [diff] [blame] | 204 | private boolean mIconAnimationRunning; |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 205 | private boolean mShowNoBackground; |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 206 | private ExpandableNotificationRow mNotificationParent; |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 207 | private OnExpandClickListener mOnExpandClickListener; |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 208 | private View.OnClickListener mOnAppOpsClickListener; |
Geoffrey Pitsch | 409db27 | 2017-08-28 14:51:52 +0000 | [diff] [blame] | 209 | |
| 210 | // Listener will be called when receiving a long click event. |
| 211 | // Use #setLongPressPosition to optionally assign positional data with the long press. |
| 212 | private LongPressListener mLongPressListener; |
| 213 | |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 214 | private boolean mGroupExpansionChanging; |
| 215 | |
Anthony Chen | 6bf88a0 | 2017-04-10 14:41:44 -0700 | [diff] [blame] | 216 | /** |
Lucas Dupin | cecc7c2 | 2017-09-12 16:02:45 -0700 | [diff] [blame] | 217 | * A supplier that returns true if keyguard is secure. |
| 218 | */ |
| 219 | private BooleanSupplier mSecureStateProvider; |
| 220 | |
| 221 | /** |
Anthony Chen | 6bf88a0 | 2017-04-10 14:41:44 -0700 | [diff] [blame] | 222 | * Whether or not a notification that is not part of a group of notifications can be manually |
| 223 | * expanded by the user. |
| 224 | */ |
| 225 | private boolean mEnableNonGroupedNotificationExpand; |
| 226 | |
| 227 | /** |
| 228 | * Whether or not to update the background of the header of the notification when its expanded. |
| 229 | * If {@code true}, the header background will disappear when expanded. |
| 230 | */ |
| 231 | private boolean mShowGroupBackgroundWhenExpanded; |
| 232 | |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 233 | private OnClickListener mExpandClickListener = new OnClickListener() { |
| 234 | @Override |
| 235 | public void onClick(View v) { |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 236 | if (!shouldShowPublic() && (!mIsLowPriority || isExpanded()) |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 237 | && mGroupManager.isSummaryOfGroup(mStatusBarNotification)) { |
Mady Mellor | 1a5d8ea | 2016-06-09 10:42:42 -0700 | [diff] [blame] | 238 | mGroupExpansionChanging = true; |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame] | 239 | final boolean wasExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification); |
| 240 | boolean nowExpanded = mGroupManager.toggleGroupExpansion(mStatusBarNotification); |
| 241 | mOnExpandClickListener.onExpandClicked(mEntry, nowExpanded); |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame] | 242 | MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTIFICATION_GROUP_EXPANDER, |
| 243 | nowExpanded); |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 244 | onExpansionChanged(true /* userAction */, wasExpanded); |
Anthony Chen | 6bf88a0 | 2017-04-10 14:41:44 -0700 | [diff] [blame] | 245 | } else if (mEnableNonGroupedNotificationExpand) { |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 246 | if (v.isAccessibilityFocused()) { |
| 247 | mPrivateLayout.setFocusOnVisibilityChange(); |
| 248 | } |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 249 | boolean nowExpanded; |
| 250 | if (isPinned()) { |
| 251 | nowExpanded = !mExpandedWhenPinned; |
| 252 | mExpandedWhenPinned = nowExpanded; |
| 253 | } else { |
| 254 | nowExpanded = !isExpanded(); |
| 255 | setUserExpanded(nowExpanded); |
| 256 | } |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 257 | notifyHeightChanged(true); |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 258 | mOnExpandClickListener.onExpandClicked(mEntry, nowExpanded); |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame] | 259 | MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTIFICATION_EXPANDER, |
| 260 | nowExpanded); |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 261 | } |
| 262 | } |
| 263 | }; |
Selim Cinek | 1b2a05e | 2016-04-28 14:20:39 -0700 | [diff] [blame] | 264 | private boolean mForceUnlocked; |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 265 | private boolean mDismissed; |
| 266 | private boolean mKeepInParent; |
| 267 | private boolean mRemoved; |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 268 | private static final Property<ExpandableNotificationRow, Float> TRANSLATE_CONTENT = |
| 269 | new FloatProperty<ExpandableNotificationRow>("translate") { |
| 270 | @Override |
| 271 | public void setValue(ExpandableNotificationRow object, float value) { |
| 272 | object.setTranslation(value); |
| 273 | } |
| 274 | |
| 275 | @Override |
| 276 | public Float get(ExpandableNotificationRow object) { |
| 277 | return object.getTranslation(); |
| 278 | } |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 279 | }; |
Selim Cinek | ddf1b39 | 2016-05-27 16:33:10 -0700 | [diff] [blame] | 280 | private OnClickListener mOnClickListener; |
Selim Cinek | 73cf02a | 2016-06-17 13:08:00 -0700 | [diff] [blame] | 281 | private boolean mHeadsupDisappearRunning; |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 282 | private View mChildAfterViewWhenDismissed; |
| 283 | private View mGroupParentWhenDismissed; |
| 284 | private boolean mRefocusOnDismiss; |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 285 | private float mContentTransformationAmount; |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 286 | private boolean mIconsVisible = true; |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 287 | private boolean mAboveShelf; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 288 | private boolean mShowAmbient; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 289 | private boolean mIsLastChild; |
Selim Cinek | e907911 | 2016-12-14 14:41:01 -0800 | [diff] [blame] | 290 | private Runnable mOnDismissRunnable; |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 291 | private boolean mIsLowPriority; |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 292 | private boolean mIsColorized; |
Selim Cinek | 7d1009b | 2017-01-25 15:28:28 -0800 | [diff] [blame] | 293 | private boolean mUseIncreasedCollapsedHeight; |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 294 | private boolean mUseIncreasedHeadsUpHeight; |
Selim Cinek | ef8c225 | 2017-02-10 14:52:18 -0800 | [diff] [blame] | 295 | private float mTranslationWhenRemoved; |
| 296 | private boolean mWasChildInGroupWhenRemoved; |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 297 | private int mNotificationColorAmbient; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 298 | private NotificationViewState mNotificationViewState; |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 299 | |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 300 | private SystemNotificationAsyncTask mSystemNotificationAsyncTask = |
| 301 | new SystemNotificationAsyncTask(); |
| 302 | |
| 303 | /** |
| 304 | * Returns whether the given {@code statusBarNotification} is a system notification. |
| 305 | * <b>Note</b>, this should be run in the background thread if possible as it makes multiple IPC |
| 306 | * calls. |
| 307 | */ |
| 308 | private static Boolean isSystemNotification( |
| 309 | Context context, StatusBarNotification statusBarNotification) { |
| 310 | PackageManager packageManager = StatusBar.getPackageManagerForUser( |
| 311 | context, statusBarNotification.getUser().getIdentifier()); |
| 312 | Boolean isSystemNotification = null; |
| 313 | |
| 314 | try { |
| 315 | PackageInfo packageInfo = packageManager.getPackageInfo( |
| 316 | statusBarNotification.getPackageName(), PackageManager.GET_SIGNATURES); |
| 317 | |
| 318 | isSystemNotification = |
| 319 | com.android.settingslib.Utils.isSystemPackage( |
| 320 | context.getResources(), packageManager, packageInfo); |
| 321 | } catch (PackageManager.NameNotFoundException e) { |
| 322 | Log.e(TAG, "cacheIsSystemNotification: Could not find package info"); |
| 323 | } |
| 324 | return isSystemNotification; |
| 325 | } |
| 326 | |
Mady Mellor | 43c2cd1 | 2016-12-12 21:05:13 -0800 | [diff] [blame] | 327 | @Override |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 328 | public boolean isGroupExpansionChanging() { |
| 329 | if (isChildInGroup()) { |
| 330 | return mNotificationParent.isGroupExpansionChanging(); |
| 331 | } |
| 332 | return mGroupExpansionChanging; |
| 333 | } |
| 334 | |
| 335 | public void setGroupExpansionChanging(boolean changing) { |
| 336 | mGroupExpansionChanging = changing; |
| 337 | } |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 338 | |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 339 | @Override |
| 340 | public void setActualHeightAnimating(boolean animating) { |
| 341 | if (mPrivateLayout != null) { |
| 342 | mPrivateLayout.setContentHeightAnimating(animating); |
| 343 | } |
| 344 | } |
| 345 | |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 346 | public NotificationContentView getPrivateLayout() { |
| 347 | return mPrivateLayout; |
| 348 | } |
| 349 | |
| 350 | public NotificationContentView getPublicLayout() { |
| 351 | return mPublicLayout; |
| 352 | } |
| 353 | |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 354 | public void setIconAnimationRunning(boolean running) { |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 355 | for (NotificationContentView l : mLayouts) { |
| 356 | setIconAnimationRunning(running, l); |
| 357 | } |
Selim Cinek | 5a175d9 | 2015-11-23 18:01:33 -0800 | [diff] [blame] | 358 | if (mIsSummaryWithChildren) { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 359 | setIconAnimationRunningForChild(running, mChildrenContainer.getHeaderView()); |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 360 | setIconAnimationRunningForChild(running, mChildrenContainer.getLowPriorityHeaderView()); |
Selim Cinek | 5a175d9 | 2015-11-23 18:01:33 -0800 | [diff] [blame] | 361 | List<ExpandableNotificationRow> notificationChildren = |
| 362 | mChildrenContainer.getNotificationChildren(); |
| 363 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 364 | ExpandableNotificationRow child = notificationChildren.get(i); |
| 365 | child.setIconAnimationRunning(running); |
| 366 | } |
| 367 | } |
| 368 | mIconAnimationRunning = running; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | private void setIconAnimationRunning(boolean running, NotificationContentView layout) { |
| 372 | if (layout != null) { |
| 373 | View contractedChild = layout.getContractedChild(); |
| 374 | View expandedChild = layout.getExpandedChild(); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 375 | View headsUpChild = layout.getHeadsUpChild(); |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 376 | setIconAnimationRunningForChild(running, contractedChild); |
| 377 | setIconAnimationRunningForChild(running, expandedChild); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 378 | setIconAnimationRunningForChild(running, headsUpChild); |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 379 | } |
| 380 | } |
| 381 | |
| 382 | private void setIconAnimationRunningForChild(boolean running, View child) { |
| 383 | if (child != null) { |
| 384 | ImageView icon = (ImageView) child.findViewById(com.android.internal.R.id.icon); |
| 385 | setIconRunning(icon, running); |
| 386 | ImageView rightIcon = (ImageView) child.findViewById( |
| 387 | com.android.internal.R.id.right_icon); |
| 388 | setIconRunning(rightIcon, running); |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | private void setIconRunning(ImageView imageView, boolean running) { |
| 393 | if (imageView != null) { |
| 394 | Drawable drawable = imageView.getDrawable(); |
| 395 | if (drawable instanceof AnimationDrawable) { |
| 396 | AnimationDrawable animationDrawable = (AnimationDrawable) drawable; |
| 397 | if (running) { |
| 398 | animationDrawable.start(); |
| 399 | } else { |
| 400 | animationDrawable.stop(); |
| 401 | } |
| 402 | } else if (drawable instanceof AnimatedVectorDrawable) { |
| 403 | AnimatedVectorDrawable animationDrawable = (AnimatedVectorDrawable) drawable; |
| 404 | if (running) { |
| 405 | animationDrawable.start(); |
| 406 | } else { |
| 407 | animationDrawable.stop(); |
| 408 | } |
| 409 | } |
| 410 | } |
| 411 | } |
| 412 | |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 413 | public void updateNotification(NotificationData.Entry entry) { |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 414 | mEntry = entry; |
| 415 | mStatusBarNotification = entry.notification; |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 416 | mNotificationInflater.inflateNotificationViews(); |
Rohan Shah | 63411fc | 2018-03-28 19:05:52 -0700 | [diff] [blame] | 417 | |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 418 | cacheIsSystemNotification(); |
Rohan Shah | 63411fc | 2018-03-28 19:05:52 -0700 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | /** |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 422 | * Caches whether or not this row contains a system notification. Note, this is only cached |
| 423 | * once per notification as the packageInfo can't technically change for a notification row. |
Rohan Shah | 63411fc | 2018-03-28 19:05:52 -0700 | [diff] [blame] | 424 | */ |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 425 | private void cacheIsSystemNotification() { |
Julia Reynolds | aa96cf3 | 2018-04-17 09:09:04 -0400 | [diff] [blame] | 426 | if (mEntry != null && mEntry.mIsSystemNotification == null) { |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 427 | if (mSystemNotificationAsyncTask.getStatus() == AsyncTask.Status.PENDING) { |
| 428 | // Run async task once, only if it hasn't already been executed. Note this is |
| 429 | // executed in serial - no need to parallelize this small task. |
| 430 | mSystemNotificationAsyncTask.execute(); |
Rohan Shah | 63411fc | 2018-03-28 19:05:52 -0700 | [diff] [blame] | 431 | } |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | /** |
Rohan Shah | ca0447e | 2018-03-30 15:18:27 -0700 | [diff] [blame] | 436 | * Returns whether this row is considered non-blockable (i.e. it's a non-blockable system notif |
| 437 | * or is in a whitelist). |
Rohan Shah | 63411fc | 2018-03-28 19:05:52 -0700 | [diff] [blame] | 438 | */ |
| 439 | public boolean getIsNonblockable() { |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 440 | boolean isNonblockable = Dependency.get(NotificationBlockingHelperManager.class) |
Rohan Shah | 63411fc | 2018-03-28 19:05:52 -0700 | [diff] [blame] | 441 | .isNonblockablePackage(mStatusBarNotification.getPackageName()); |
| 442 | |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 443 | // If the SystemNotifAsyncTask hasn't finished running or retrieved a value, we'll try once |
| 444 | // again, but in-place on the main thread this time. This should rarely ever get called. |
Julia Reynolds | aa96cf3 | 2018-04-17 09:09:04 -0400 | [diff] [blame] | 445 | if (mEntry != null && mEntry.mIsSystemNotification == null) { |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 446 | if (DEBUG) { |
| 447 | Log.d(TAG, "Retrieving isSystemNotification on main thread"); |
| 448 | } |
| 449 | mSystemNotificationAsyncTask.cancel(true /* mayInterruptIfRunning */); |
Julia Reynolds | aa96cf3 | 2018-04-17 09:09:04 -0400 | [diff] [blame] | 450 | mEntry.mIsSystemNotification = isSystemNotification(mContext, mStatusBarNotification); |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 451 | } |
| 452 | |
Julia Reynolds | aa96cf3 | 2018-04-17 09:09:04 -0400 | [diff] [blame] | 453 | if (!isNonblockable && mEntry != null && mEntry.mIsSystemNotification != null) { |
| 454 | if (mEntry.mIsSystemNotification) { |
Rohan Shah | 63411fc | 2018-03-28 19:05:52 -0700 | [diff] [blame] | 455 | if (mEntry.channel != null |
| 456 | && !mEntry.channel.isBlockableSystem()) { |
| 457 | isNonblockable = true; |
| 458 | } |
| 459 | } |
| 460 | } |
| 461 | return isNonblockable; |
Selim Cinek | c478f90 | 2017-02-22 20:55:44 -0800 | [diff] [blame] | 462 | } |
| 463 | |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 464 | public void onNotificationUpdated() { |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 465 | for (NotificationContentView l : mLayouts) { |
Selim Cinek | c478f90 | 2017-02-22 20:55:44 -0800 | [diff] [blame] | 466 | l.onNotificationUpdated(mEntry); |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 467 | } |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 468 | mIsColorized = mStatusBarNotification.getNotification().isColorized(); |
Selim Cinek | 757d879 | 2016-01-28 16:21:08 -0800 | [diff] [blame] | 469 | mShowingPublicInitialized = false; |
Selim Cinek | 4bb5934 | 2016-04-08 19:29:35 -0700 | [diff] [blame] | 470 | updateNotificationColor(); |
Mady Mellor | 4c19760 | 2017-04-10 17:57:52 -0700 | [diff] [blame] | 471 | if (mMenuRow != null) { |
Mady Mellor | 4ab2820 | 2017-06-06 11:42:50 -0700 | [diff] [blame] | 472 | mMenuRow.onNotificationUpdated(mStatusBarNotification); |
Beverly | 3f56f05 | 2018-05-08 14:56:03 -0400 | [diff] [blame] | 473 | mMenuRow.setAppName(mAppName); |
Mady Mellor | 4c19760 | 2017-04-10 17:57:52 -0700 | [diff] [blame] | 474 | } |
Selim Cinek | 8fc93c9 | 2015-11-23 17:48:07 -0800 | [diff] [blame] | 475 | if (mIsSummaryWithChildren) { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 476 | mChildrenContainer.recreateNotificationHeader(mExpandClickListener); |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 477 | mChildrenContainer.onNotificationUpdated(); |
Selim Cinek | 8fc93c9 | 2015-11-23 17:48:07 -0800 | [diff] [blame] | 478 | } |
Selim Cinek | 5a175d9 | 2015-11-23 18:01:33 -0800 | [diff] [blame] | 479 | if (mIconAnimationRunning) { |
| 480 | setIconAnimationRunning(true); |
| 481 | } |
Selim Cinek | ea4bef7 | 2015-12-02 15:51:10 -0800 | [diff] [blame] | 482 | if (mNotificationParent != null) { |
| 483 | mNotificationParent.updateChildrenHeaderAppearance(); |
| 484 | } |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 485 | onChildrenCountChanged(); |
Selim Cinek | 624c02db | 2015-12-14 21:00:02 -0800 | [diff] [blame] | 486 | // The public layouts expand button is always visible |
| 487 | mPublicLayout.updateExpandButtons(true); |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 488 | updateLimits(); |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 489 | updateIconVisibilities(); |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 490 | updateShelfIconColor(); |
Selim Cinek | fe24fb7 | 2018-02-13 14:34:55 -0800 | [diff] [blame] | 491 | updateRippleAllowed(); |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 492 | } |
| 493 | |
Lucas Dupin | b6ed63b | 2017-05-30 16:17:42 -0700 | [diff] [blame] | 494 | @VisibleForTesting |
| 495 | void updateShelfIconColor() { |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 496 | StatusBarIconView expandedIcon = mEntry.expandedIcon; |
| 497 | boolean isPreL = Boolean.TRUE.equals(expandedIcon.getTag(R.id.icon_is_pre_L)); |
| 498 | boolean colorize = !isPreL || NotificationUtils.isGrayscale(expandedIcon, |
| 499 | NotificationColorUtil.getInstance(mContext)); |
Selim Cinek | 875ba9b | 2017-02-13 16:20:17 -0800 | [diff] [blame] | 500 | int color = StatusBarIconView.NO_COLOR; |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 501 | if (colorize) { |
Lucas Dupin | b6ed63b | 2017-05-30 16:17:42 -0700 | [diff] [blame] | 502 | NotificationHeaderView header = getVisibleNotificationHeader(); |
| 503 | if (header != null) { |
| 504 | color = header.getOriginalIconColor(); |
| 505 | } else { |
| 506 | color = mEntry.getContrastedColor(mContext, mIsLowPriority && !isExpanded(), |
| 507 | getBackgroundColorWithoutTint()); |
| 508 | } |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 509 | } |
Selim Cinek | 875ba9b | 2017-02-13 16:20:17 -0800 | [diff] [blame] | 510 | expandedIcon.setStaticDrawableColor(color); |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 511 | } |
| 512 | |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 513 | public void setAboveShelfChangedListener(AboveShelfChangedListener aboveShelfChangedListener) { |
| 514 | mAboveShelfChangedListener = aboveShelfChangedListener; |
| 515 | } |
| 516 | |
Lucas Dupin | cecc7c2 | 2017-09-12 16:02:45 -0700 | [diff] [blame] | 517 | /** |
| 518 | * Sets a supplier that can determine whether the keyguard is secure or not. |
| 519 | * @param secureStateProvider A function that returns true if keyguard is secure. |
| 520 | */ |
| 521 | public void setSecureStateProvider(BooleanSupplier secureStateProvider) { |
| 522 | mSecureStateProvider = secureStateProvider; |
| 523 | } |
| 524 | |
Selim Cinek | 4705f29 | 2017-04-24 22:18:48 -0700 | [diff] [blame] | 525 | @Override |
| 526 | public boolean isDimmable() { |
| 527 | if (!getShowingLayout().isDimmable()) { |
| 528 | return false; |
| 529 | } |
| 530 | return super.isDimmable(); |
| 531 | } |
| 532 | |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 533 | private void updateLimits() { |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 534 | for (NotificationContentView l : mLayouts) { |
| 535 | updateLimitsForView(l); |
| 536 | } |
Selim Cinek | a174487 | 2016-03-11 15:36:06 -0800 | [diff] [blame] | 537 | } |
| 538 | |
| 539 | private void updateLimitsForView(NotificationContentView layout) { |
| 540 | boolean customView = layout.getContractedChild().getId() |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 541 | != com.android.internal.R.id.status_bar_latest_event_content; |
| 542 | boolean beforeN = mEntry.targetSdk < Build.VERSION_CODES.N; |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 543 | boolean beforeP = mEntry.targetSdk < Build.VERSION_CODES.P; |
Selim Cinek | 7d1009b | 2017-01-25 15:28:28 -0800 | [diff] [blame] | 544 | int minHeight; |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 545 | if (customView && beforeP && !mIsSummaryWithChildren) { |
| 546 | minHeight = beforeN ? mNotificationMinHeightLegacy : mNotificationMinHeightBeforeP; |
Selim Cinek | 7d1009b | 2017-01-25 15:28:28 -0800 | [diff] [blame] | 547 | } else if (mUseIncreasedCollapsedHeight && layout == mPrivateLayout) { |
| 548 | minHeight = mNotificationMinHeightLarge; |
| 549 | } else { |
| 550 | minHeight = mNotificationMinHeight; |
| 551 | } |
Selim Cinek | a174487 | 2016-03-11 15:36:06 -0800 | [diff] [blame] | 552 | boolean headsUpCustom = layout.getHeadsUpChild() != null && |
| 553 | layout.getHeadsUpChild().getId() |
| 554 | != com.android.internal.R.id.status_bar_latest_event_content; |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 555 | int headsUpheight; |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 556 | if (headsUpCustom && beforeP) { |
| 557 | headsUpheight = beforeN ? mMaxHeadsUpHeightLegacy : mMaxHeadsUpHeightBeforeP; |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 558 | } else if (mUseIncreasedHeadsUpHeight && layout == mPrivateLayout) { |
| 559 | headsUpheight = mMaxHeadsUpHeightIncreased; |
| 560 | } else { |
| 561 | headsUpheight = mMaxHeadsUpHeight; |
| 562 | } |
Selim Cinek | e62255c | 2017-09-28 18:23:23 -0700 | [diff] [blame] | 563 | NotificationViewWrapper headsUpWrapper = layout.getVisibleWrapper( |
| 564 | NotificationContentView.VISIBLE_TYPE_HEADSUP); |
| 565 | if (headsUpWrapper != null) { |
| 566 | headsUpheight = Math.max(headsUpheight, headsUpWrapper.getMinLayoutHeight()); |
| 567 | } |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 568 | layout.setHeights(minHeight, headsUpheight, mNotificationMaxHeight, |
| 569 | mNotificationAmbientHeight); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | public StatusBarNotification getStatusBarNotification() { |
| 573 | return mStatusBarNotification; |
| 574 | } |
| 575 | |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 576 | public NotificationData.Entry getEntry() { |
| 577 | return mEntry; |
| 578 | } |
| 579 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 580 | public boolean isHeadsUp() { |
| 581 | return mIsHeadsUp; |
| 582 | } |
| 583 | |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 584 | public void setHeadsUp(boolean isHeadsUp) { |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 585 | boolean wasAboveShelf = isAboveShelf(); |
Selim Cinek | c80fdb1 | 2015-04-13 15:09:08 -0700 | [diff] [blame] | 586 | int intrinsicBefore = getIntrinsicHeight(); |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 587 | mIsHeadsUp = isHeadsUp; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 588 | mPrivateLayout.setHeadsUp(isHeadsUp); |
Selim Cinek | b41b2f6 | 2016-04-26 14:03:29 -0700 | [diff] [blame] | 589 | if (mIsSummaryWithChildren) { |
| 590 | // The overflow might change since we allow more lines as HUN. |
| 591 | mChildrenContainer.updateGroupOverflow(); |
| 592 | } |
Selim Cinek | c80fdb1 | 2015-04-13 15:09:08 -0700 | [diff] [blame] | 593 | if (intrinsicBefore != getIntrinsicHeight()) { |
| 594 | notifyHeightChanged(false /* needsAnimation */); |
| 595 | } |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 596 | if (isHeadsUp) { |
Selim Cinek | 9b9d6e1 | 2017-11-30 12:29:47 +0100 | [diff] [blame] | 597 | mMustStayOnScreen = true; |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 598 | setAboveShelf(true); |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 599 | } else if (isAboveShelf() != wasAboveShelf) { |
| 600 | mAboveShelfChangedListener.onAboveShelfStateChanged(!wasAboveShelf); |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 601 | } |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 602 | } |
| 603 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 604 | public void setGroupManager(NotificationGroupManager groupManager) { |
| 605 | mGroupManager = groupManager; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 606 | mPrivateLayout.setGroupManager(groupManager); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 607 | } |
| 608 | |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 609 | public void setRemoteInputController(RemoteInputController r) { |
| 610 | mPrivateLayout.setRemoteInputController(r); |
| 611 | } |
| 612 | |
Mady Mellor | 3fd273e | 2016-03-15 21:08:14 -0700 | [diff] [blame] | 613 | public void setAppName(String appName) { |
| 614 | mAppName = appName; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 615 | if (mMenuRow != null && mMenuRow.getMenuView() != null) { |
Mady Mellor | 761cde1 | 2017-01-10 11:36:39 -0800 | [diff] [blame] | 616 | mMenuRow.setAppName(mAppName); |
Mady Mellor | 3fd273e | 2016-03-15 21:08:14 -0700 | [diff] [blame] | 617 | } |
| 618 | } |
| 619 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 620 | public void addChildNotification(ExpandableNotificationRow row) { |
| 621 | addChildNotification(row, -1); |
| 622 | } |
| 623 | |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 624 | /** |
| 625 | * Set the how much the header should be visible. A value of 0 will make the header fully gone |
| 626 | * and a value of 1 will make the notification look just like normal. |
| 627 | * This is being used for heads up notifications, when they are pinned to the top of the screen |
| 628 | * and the header content is extracted to the statusbar. |
| 629 | * |
| 630 | * @param headerVisibleAmount the amount the header should be visible. |
| 631 | */ |
| 632 | public void setHeaderVisibleAmount(float headerVisibleAmount) { |
| 633 | if (mHeaderVisibleAmount != headerVisibleAmount) { |
| 634 | mHeaderVisibleAmount = headerVisibleAmount; |
| 635 | mPrivateLayout.setHeaderVisibleAmount(headerVisibleAmount); |
| 636 | if (mChildrenContainer != null) { |
| 637 | mChildrenContainer.setHeaderVisibleAmount(headerVisibleAmount); |
| 638 | } |
| 639 | notifyHeightChanged(false /* needsAnimation */); |
| 640 | } |
| 641 | } |
| 642 | |
Selim Cinek | 99e9adf | 2018-03-15 09:17:47 -0700 | [diff] [blame] | 643 | @Override |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 644 | public float getHeaderVisibleAmount() { |
| 645 | return mHeaderVisibleAmount; |
| 646 | } |
| 647 | |
Selim Cinek | 9b9d6e1 | 2017-11-30 12:29:47 +0100 | [diff] [blame] | 648 | @Override |
| 649 | public void setHeadsUpIsVisible() { |
| 650 | super.setHeadsUpIsVisible(); |
| 651 | mMustStayOnScreen = false; |
| 652 | } |
| 653 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 654 | /** |
| 655 | * Add a child notification to this view. |
| 656 | * |
| 657 | * @param row the row to add |
| 658 | * @param childIndex the index to add it at, if -1 it will be added at the end |
| 659 | */ |
| 660 | public void addChildNotification(ExpandableNotificationRow row, int childIndex) { |
| 661 | if (mChildrenContainer == null) { |
| 662 | mChildrenContainerStub.inflate(); |
| 663 | } |
| 664 | mChildrenContainer.addNotification(row, childIndex); |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 665 | onChildrenCountChanged(); |
| 666 | row.setIsChildInGroup(true, this); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | public void removeChildNotification(ExpandableNotificationRow row) { |
| 670 | if (mChildrenContainer != null) { |
| 671 | mChildrenContainer.removeNotification(row); |
| 672 | } |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 673 | onChildrenCountChanged(); |
| 674 | row.setIsChildInGroup(false, null); |
Selim Cinek | 2871bef | 2017-11-22 08:40:00 -0800 | [diff] [blame] | 675 | row.setBottomRoundness(0.0f, false /* animate */); |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 676 | } |
| 677 | |
Mady Mellor | 43c2cd1 | 2016-12-12 21:05:13 -0800 | [diff] [blame] | 678 | @Override |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 679 | public boolean isChildInGroup() { |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 680 | return mNotificationParent != null; |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 681 | } |
| 682 | |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 683 | /** |
| 684 | * @return whether this notification is the only child in the group summary |
| 685 | */ |
| 686 | public boolean isOnlyChildInGroup() { |
| 687 | return mGroupManager.isOnlyChildInGroup(getStatusBarNotification()); |
| 688 | } |
| 689 | |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 690 | public ExpandableNotificationRow getNotificationParent() { |
| 691 | return mNotificationParent; |
| 692 | } |
| 693 | |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 694 | /** |
| 695 | * @param isChildInGroup Is this notification now in a group |
| 696 | * @param parent the new parent notification |
| 697 | */ |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 698 | public void setIsChildInGroup(boolean isChildInGroup, ExpandableNotificationRow parent) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 699 | boolean childInGroup = StatusBar.ENABLE_CHILD_NOTIFICATIONS && isChildInGroup; |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 700 | if (mExpandAnimationRunning && !isChildInGroup && mNotificationParent != null) { |
| 701 | mNotificationParent.setChildIsExpanding(false); |
| 702 | mNotificationParent.setExtraWidthForClipping(0.0f); |
| 703 | mNotificationParent.setMinimumHeightForClipping(0); |
| 704 | } |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 705 | mNotificationParent = childInGroup ? parent : null; |
| 706 | mPrivateLayout.setIsChildInGroup(childInGroup); |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 707 | mNotificationInflater.setIsChildInGroup(childInGroup); |
Mady Mellor | c7d65b4 | 2016-05-04 11:44:57 -0400 | [diff] [blame] | 708 | resetBackgroundAlpha(); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 709 | updateBackgroundForGroupState(); |
Selim Cinek | ddf1b39 | 2016-05-27 16:33:10 -0700 | [diff] [blame] | 710 | updateClickAndFocus(); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 711 | if (mNotificationParent != null) { |
Selim Cinek | 9ce3285 | 2017-02-15 16:21:10 -0800 | [diff] [blame] | 712 | setOverrideTintColor(NO_COLOR, 0.0f); |
Selim Cinek | eccf494 | 2018-05-30 09:55:36 -0700 | [diff] [blame] | 713 | // Let's reset the distance to top roundness, as this isn't applied to group children |
| 714 | setDistanceToTopRoundness(NO_ROUNDNESS); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 715 | mNotificationParent.updateBackgroundForGroupState(); |
| 716 | } |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 717 | updateIconVisibilities(); |
Selim Cinek | 2871bef | 2017-11-22 08:40:00 -0800 | [diff] [blame] | 718 | updateBackgroundClipping(); |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | @Override |
Selim Cinek | 7210947 | 2016-01-15 16:33:22 -0800 | [diff] [blame] | 722 | public boolean onTouchEvent(MotionEvent event) { |
| 723 | if (event.getActionMasked() != MotionEvent.ACTION_DOWN |
| 724 | || !isChildInGroup() || isGroupExpanded()) { |
| 725 | return super.onTouchEvent(event); |
| 726 | } else { |
| 727 | return false; |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | @Override |
Mady Mellor | f062580 | 2016-02-11 18:03:48 -0800 | [diff] [blame] | 732 | protected boolean handleSlideBack() { |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 733 | if (mMenuRow != null && mMenuRow.isMenuVisible()) { |
Mady Mellor | f062580 | 2016-02-11 18:03:48 -0800 | [diff] [blame] | 734 | animateTranslateNotification(0 /* targetLeft */); |
| 735 | return true; |
| 736 | } |
| 737 | return false; |
| 738 | } |
| 739 | |
| 740 | @Override |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 741 | protected boolean shouldHideBackground() { |
| 742 | return super.shouldHideBackground() || mShowNoBackground; |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 743 | } |
| 744 | |
| 745 | @Override |
| 746 | public boolean isSummaryWithChildren() { |
| 747 | return mIsSummaryWithChildren; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 748 | } |
| 749 | |
| 750 | @Override |
| 751 | public boolean areChildrenExpanded() { |
| 752 | return mChildrenExpanded; |
| 753 | } |
| 754 | |
| 755 | public List<ExpandableNotificationRow> getNotificationChildren() { |
| 756 | return mChildrenContainer == null ? null : mChildrenContainer.getNotificationChildren(); |
| 757 | } |
| 758 | |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 759 | public int getNumberOfNotificationChildren() { |
| 760 | if (mChildrenContainer == null) { |
| 761 | return 0; |
| 762 | } |
| 763 | return mChildrenContainer.getNotificationChildren().size(); |
| 764 | } |
| 765 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 766 | /** |
| 767 | * Apply the order given in the list to the children. |
| 768 | * |
| 769 | * @param childOrder the new list order |
Selim Cinek | a7d4f82 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 770 | * @param visualStabilityManager |
| 771 | * @param callback the callback to invoked in case it is not allowed |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 772 | * @return whether the list order has changed |
| 773 | */ |
Selim Cinek | a7d4f82 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 774 | public boolean applyChildOrder(List<ExpandableNotificationRow> childOrder, |
| 775 | VisualStabilityManager visualStabilityManager, |
| 776 | VisualStabilityManager.Callback callback) { |
| 777 | return mChildrenContainer != null && mChildrenContainer.applyChildOrder(childOrder, |
| 778 | visualStabilityManager, callback); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 779 | } |
| 780 | |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 781 | public void getChildrenStates(StackScrollState resultState, |
| 782 | AmbientState ambientState) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 783 | if (mIsSummaryWithChildren) { |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 784 | ExpandableViewState parentState = resultState.getViewStateForView(this); |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 785 | mChildrenContainer.getState(resultState, parentState, ambientState); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 786 | } |
| 787 | } |
| 788 | |
| 789 | public void applyChildrenState(StackScrollState state) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 790 | if (mIsSummaryWithChildren) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 791 | mChildrenContainer.applyState(state); |
| 792 | } |
| 793 | } |
| 794 | |
| 795 | public void prepareExpansionChanged(StackScrollState state) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 796 | if (mIsSummaryWithChildren) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 797 | mChildrenContainer.prepareExpansionChanged(state); |
| 798 | } |
| 799 | } |
| 800 | |
Selim Cinek | 0cfbef4 | 2016-11-09 19:06:36 -0800 | [diff] [blame] | 801 | public void startChildAnimation(StackScrollState finalState, AnimationProperties properties) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 802 | if (mIsSummaryWithChildren) { |
Selim Cinek | 0cfbef4 | 2016-11-09 19:06:36 -0800 | [diff] [blame] | 803 | mChildrenContainer.startAnimationToState(finalState, properties); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 804 | } |
| 805 | } |
| 806 | |
| 807 | public ExpandableNotificationRow getViewAtPosition(float y) { |
Selim Cinek | 43d30f0 | 2016-03-04 10:51:32 -0800 | [diff] [blame] | 808 | if (!mIsSummaryWithChildren || !mChildrenExpanded) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 809 | return this; |
| 810 | } else { |
| 811 | ExpandableNotificationRow view = mChildrenContainer.getViewAtPosition(y); |
| 812 | return view == null ? this : view; |
| 813 | } |
| 814 | } |
| 815 | |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 816 | public NotificationGuts getGuts() { |
| 817 | return mGuts; |
| 818 | } |
| 819 | |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 820 | /** |
| 821 | * Set this notification to be pinned to the top if {@link #isHeadsUp()} is true. By doing this |
| 822 | * the notification will be rendered on top of the screen. |
| 823 | * |
| 824 | * @param pinned whether it is pinned |
| 825 | */ |
| 826 | public void setPinned(boolean pinned) { |
Selim Cinek | def35a8 | 2016-05-03 15:52:51 -0700 | [diff] [blame] | 827 | int intrinsicHeight = getIntrinsicHeight(); |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 828 | boolean wasAboveShelf = isAboveShelf(); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 829 | mIsPinned = pinned; |
Selim Cinek | def35a8 | 2016-05-03 15:52:51 -0700 | [diff] [blame] | 830 | if (intrinsicHeight != getIntrinsicHeight()) { |
Selim Cinek | bb42b7d | 2016-08-10 13:02:38 -0700 | [diff] [blame] | 831 | notifyHeightChanged(false /* needsAnimation */); |
Selim Cinek | def35a8 | 2016-05-03 15:52:51 -0700 | [diff] [blame] | 832 | } |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 833 | if (pinned) { |
| 834 | setIconAnimationRunning(true); |
| 835 | mExpandedWhenPinned = false; |
| 836 | } else if (mExpandedWhenPinned) { |
| 837 | setUserExpanded(true); |
| 838 | } |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 839 | setChronometerRunning(mLastChronometerRunning); |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 840 | if (isAboveShelf() != wasAboveShelf) { |
| 841 | mAboveShelfChangedListener.onAboveShelfStateChanged(!wasAboveShelf); |
| 842 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 843 | } |
| 844 | |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 845 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 846 | public boolean isPinned() { |
| 847 | return mIsPinned; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 848 | } |
| 849 | |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 850 | @Override |
| 851 | public int getPinnedHeadsUpHeight() { |
| 852 | return getPinnedHeadsUpHeight(true /* atLeastMinHeight */); |
| 853 | } |
| 854 | |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 855 | /** |
| 856 | * @param atLeastMinHeight should the value returned be at least the minimum height. |
| 857 | * Used to avoid cyclic calls |
| 858 | * @return the height of the heads up notification when pinned |
| 859 | */ |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 860 | private int getPinnedHeadsUpHeight(boolean atLeastMinHeight) { |
Selim Cinek | 77019c7 | 2015-12-09 10:18:02 -0800 | [diff] [blame] | 861 | if (mIsSummaryWithChildren) { |
| 862 | return mChildrenContainer.getIntrinsicHeight(); |
| 863 | } |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 864 | if(mExpandedWhenPinned) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 865 | return Math.max(getMaxExpandHeight(), getHeadsUpHeight()); |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 866 | } else if (atLeastMinHeight) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 867 | return Math.max(getCollapsedHeight(), getHeadsUpHeight()); |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 868 | } else { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 869 | return getHeadsUpHeight(); |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 870 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 871 | } |
| 872 | |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 873 | /** |
| 874 | * Mark whether this notification was just clicked, i.e. the user has just clicked this |
| 875 | * notification in this frame. |
| 876 | */ |
| 877 | public void setJustClicked(boolean justClicked) { |
| 878 | mJustClicked = justClicked; |
| 879 | } |
| 880 | |
| 881 | /** |
| 882 | * @return true if this notification has been clicked in this frame, false otherwise |
| 883 | */ |
| 884 | public boolean wasJustClicked() { |
| 885 | return mJustClicked; |
| 886 | } |
| 887 | |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 888 | public void setChronometerRunning(boolean running) { |
| 889 | mLastChronometerRunning = running; |
| 890 | setChronometerRunning(running, mPrivateLayout); |
| 891 | setChronometerRunning(running, mPublicLayout); |
| 892 | if (mChildrenContainer != null) { |
| 893 | List<ExpandableNotificationRow> notificationChildren = |
| 894 | mChildrenContainer.getNotificationChildren(); |
| 895 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 896 | ExpandableNotificationRow child = notificationChildren.get(i); |
| 897 | child.setChronometerRunning(running); |
| 898 | } |
| 899 | } |
| 900 | } |
| 901 | |
| 902 | private void setChronometerRunning(boolean running, NotificationContentView layout) { |
| 903 | if (layout != null) { |
| 904 | running = running || isPinned(); |
| 905 | View contractedChild = layout.getContractedChild(); |
| 906 | View expandedChild = layout.getExpandedChild(); |
| 907 | View headsUpChild = layout.getHeadsUpChild(); |
| 908 | setChronometerRunningForChild(running, contractedChild); |
| 909 | setChronometerRunningForChild(running, expandedChild); |
| 910 | setChronometerRunningForChild(running, headsUpChild); |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | private void setChronometerRunningForChild(boolean running, View child) { |
| 915 | if (child != null) { |
| 916 | View chronometer = child.findViewById(com.android.internal.R.id.chronometer); |
| 917 | if (chronometer instanceof Chronometer) { |
| 918 | ((Chronometer) chronometer).setStarted(running); |
| 919 | } |
| 920 | } |
| 921 | } |
| 922 | |
Selim Cinek | ea4bef7 | 2015-12-02 15:51:10 -0800 | [diff] [blame] | 923 | public NotificationHeaderView getNotificationHeader() { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 924 | if (mIsSummaryWithChildren) { |
| 925 | return mChildrenContainer.getHeaderView(); |
Selim Cinek | 8d6440d | 2015-10-22 13:00:05 -0700 | [diff] [blame] | 926 | } |
Selim Cinek | ea4bef7 | 2015-12-02 15:51:10 -0800 | [diff] [blame] | 927 | return mPrivateLayout.getNotificationHeader(); |
Selim Cinek | 8d6440d | 2015-10-22 13:00:05 -0700 | [diff] [blame] | 928 | } |
| 929 | |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 930 | /** |
| 931 | * @return the currently visible notification header. This can be different from |
| 932 | * {@link #getNotificationHeader()} in case it is a low-priority group. |
| 933 | */ |
| 934 | public NotificationHeaderView getVisibleNotificationHeader() { |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 935 | if (mIsSummaryWithChildren && !shouldShowPublic()) { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 936 | return mChildrenContainer.getVisibleHeader(); |
Selim Cinek | 34eda5e | 2016-02-18 17:10:43 -0800 | [diff] [blame] | 937 | } |
| 938 | return getShowingLayout().getVisibleNotificationHeader(); |
| 939 | } |
| 940 | |
Selim Cinek | b26afa3 | 2017-06-29 10:28:17 +0200 | [diff] [blame] | 941 | |
| 942 | /** |
| 943 | * @return the contracted notification header. This can be different from |
| 944 | * {@link #getNotificationHeader()} and also {@link #getVisibleNotificationHeader()} and only |
| 945 | * returns the contracted version. |
| 946 | */ |
| 947 | public NotificationHeaderView getContractedNotificationHeader() { |
| 948 | if (mIsSummaryWithChildren) { |
| 949 | return mChildrenContainer.getHeaderView(); |
| 950 | } |
| 951 | return mPrivateLayout.getContractedNotificationHeader(); |
| 952 | } |
| 953 | |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 954 | public void setOnExpandClickListener(OnExpandClickListener onExpandClickListener) { |
| 955 | mOnExpandClickListener = onExpandClickListener; |
| 956 | } |
| 957 | |
Geoffrey Pitsch | 409db27 | 2017-08-28 14:51:52 +0000 | [diff] [blame] | 958 | public void setLongPressListener(LongPressListener longPressListener) { |
| 959 | mLongPressListener = longPressListener; |
| 960 | } |
| 961 | |
Selim Cinek | ddf1b39 | 2016-05-27 16:33:10 -0700 | [diff] [blame] | 962 | @Override |
| 963 | public void setOnClickListener(@Nullable OnClickListener l) { |
| 964 | super.setOnClickListener(l); |
| 965 | mOnClickListener = l; |
| 966 | updateClickAndFocus(); |
| 967 | } |
| 968 | |
| 969 | private void updateClickAndFocus() { |
| 970 | boolean normalChild = !isChildInGroup() || isGroupExpanded(); |
| 971 | boolean clickable = mOnClickListener != null && normalChild; |
| 972 | if (isFocusable() != normalChild) { |
| 973 | setFocusable(normalChild); |
| 974 | } |
| 975 | if (isClickable() != clickable) { |
| 976 | setClickable(clickable); |
| 977 | } |
| 978 | } |
| 979 | |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 980 | public void setHeadsUpManager(HeadsUpManager headsUpManager) { |
| 981 | mHeadsUpManager = headsUpManager; |
| 982 | } |
| 983 | |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 984 | public void setGutsView(MenuItem item) { |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 985 | if (mGuts != null && item.getGutsView() instanceof GutsContent) { |
| 986 | ((GutsContent) item.getGutsView()).setGutsParent(mGuts); |
| 987 | mGuts.setGutsContent((GutsContent) item.getGutsView()); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 988 | } |
| 989 | } |
| 990 | |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 991 | @Override |
| 992 | protected void onAttachedToWindow() { |
| 993 | super.onAttachedToWindow(); |
| 994 | Dependency.get(PluginManager.class).addPluginListener(this, |
| 995 | NotificationMenuRowPlugin.class, false /* Allow multiple */); |
| 996 | } |
| 997 | |
| 998 | @Override |
| 999 | protected void onDetachedFromWindow() { |
| 1000 | super.onDetachedFromWindow(); |
| 1001 | Dependency.get(PluginManager.class).removePluginListener(this); |
| 1002 | } |
| 1003 | |
| 1004 | @Override |
| 1005 | public void onPluginConnected(NotificationMenuRowPlugin plugin, Context pluginContext) { |
| 1006 | boolean existed = mMenuRow.getMenuView() != null; |
| 1007 | if (existed) { |
| 1008 | removeView(mMenuRow.getMenuView()); |
| 1009 | } |
| 1010 | mMenuRow = plugin; |
| 1011 | if (mMenuRow.useDefaultMenuItems()) { |
Mady Mellor | 4c19760 | 2017-04-10 17:57:52 -0700 | [diff] [blame] | 1012 | ArrayList<MenuItem> items = new ArrayList<>(); |
| 1013 | items.add(NotificationMenuRow.createInfoItem(mContext)); |
| 1014 | items.add(NotificationMenuRow.createSnoozeItem(mContext)); |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 1015 | items.add(NotificationMenuRow.createAppOpsItem(mContext)); |
Mady Mellor | 4c19760 | 2017-04-10 17:57:52 -0700 | [diff] [blame] | 1016 | mMenuRow.setMenuItems(items); |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 1017 | } |
| 1018 | if (existed) { |
| 1019 | createMenu(); |
| 1020 | } |
| 1021 | } |
| 1022 | |
| 1023 | @Override |
| 1024 | public void onPluginDisconnected(NotificationMenuRowPlugin plugin) { |
| 1025 | boolean existed = mMenuRow.getMenuView() != null; |
| 1026 | mMenuRow = new NotificationMenuRow(mContext); // Back to default |
| 1027 | if (existed) { |
| 1028 | createMenu(); |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | public NotificationMenuRowPlugin createMenu() { |
| 1033 | if (mMenuRow.getMenuView() == null) { |
Mady Mellor | 4ab2820 | 2017-06-06 11:42:50 -0700 | [diff] [blame] | 1034 | mMenuRow.createMenu(this, mStatusBarNotification); |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 1035 | mMenuRow.setAppName(mAppName); |
| 1036 | FrameLayout.LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, |
| 1037 | LayoutParams.MATCH_PARENT); |
| 1038 | addView(mMenuRow.getMenuView(), MENU_VIEW_INDEX, lp); |
| 1039 | } |
| 1040 | return mMenuRow; |
| 1041 | } |
| 1042 | |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 1043 | public NotificationMenuRowPlugin getProvider() { |
| 1044 | return mMenuRow; |
| 1045 | } |
| 1046 | |
Anthony Chen | 9fe1ee7 | 2017-04-07 13:53:37 -0700 | [diff] [blame] | 1047 | @Override |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1048 | public void onDensityOrFontScaleChanged() { |
Anthony Chen | 9fe1ee7 | 2017-04-07 13:53:37 -0700 | [diff] [blame] | 1049 | super.onDensityOrFontScaleChanged(); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 1050 | initDimens(); |
Anthony Chen | ad4d158 | 2017-04-10 16:07:58 -0700 | [diff] [blame] | 1051 | initBackground(); |
Selim Cinek | 817abe7 | 2017-05-24 11:08:55 -0700 | [diff] [blame] | 1052 | // Let's update our childrencontainer. This is intentionally not guarded with |
| 1053 | // mIsSummaryWithChildren since we might have had children but not anymore. |
| 1054 | if (mChildrenContainer != null) { |
| 1055 | mChildrenContainer.reInflateViews(mExpandClickListener, mEntry.notification); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 1056 | } |
| 1057 | if (mGuts != null) { |
| 1058 | View oldGuts = mGuts; |
| 1059 | int index = indexOfChild(oldGuts); |
| 1060 | removeView(oldGuts); |
| 1061 | mGuts = (NotificationGuts) LayoutInflater.from(mContext).inflate( |
| 1062 | R.layout.notification_guts, this, false); |
| 1063 | mGuts.setVisibility(oldGuts.getVisibility()); |
| 1064 | addView(mGuts, index); |
| 1065 | } |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 1066 | View oldMenu = mMenuRow.getMenuView(); |
| 1067 | if (oldMenu != null) { |
Mady Mellor | 761cde1 | 2017-01-10 11:36:39 -0800 | [diff] [blame] | 1068 | int menuIndex = indexOfChild(oldMenu); |
| 1069 | removeView(oldMenu); |
Mady Mellor | 4ab2820 | 2017-06-06 11:42:50 -0700 | [diff] [blame] | 1070 | mMenuRow.createMenu(ExpandableNotificationRow.this, mStatusBarNotification); |
Mady Mellor | 761cde1 | 2017-01-10 11:36:39 -0800 | [diff] [blame] | 1071 | mMenuRow.setAppName(mAppName); |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 1072 | addView(mMenuRow.getMenuView(), menuIndex); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1073 | } |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1074 | for (NotificationContentView l : mLayouts) { |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 1075 | l.initView(); |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1076 | l.reInflateViews(); |
| 1077 | } |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1078 | mNotificationInflater.onDensityOrFontScaleChanged(); |
| 1079 | onNotificationUpdated(); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 1080 | } |
| 1081 | |
Mady Mellor | 9d03a52 | 2017-04-04 18:45:30 -0700 | [diff] [blame] | 1082 | @Override |
| 1083 | public void onConfigurationChanged(Configuration newConfig) { |
| 1084 | if (mMenuRow.getMenuView() != null) { |
| 1085 | mMenuRow.onConfigurationChanged(); |
| 1086 | } |
| 1087 | } |
| 1088 | |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 1089 | public void setContentBackground(int customBackgroundColor, boolean animate, |
| 1090 | NotificationContentView notificationContentView) { |
| 1091 | if (getShowingLayout() == notificationContentView) { |
| 1092 | setTintColor(customBackgroundColor, animate); |
| 1093 | } |
| 1094 | } |
| 1095 | |
Kenny Guy | 14d035c | 2018-05-02 19:10:36 +0100 | [diff] [blame] | 1096 | @Override |
| 1097 | protected void setBackgroundTintColor(int color) { |
| 1098 | super.setBackgroundTintColor(color); |
| 1099 | NotificationContentView view = getShowingLayout(); |
| 1100 | if (view != null) { |
| 1101 | view.setBackgroundTintColor(color); |
| 1102 | } |
| 1103 | } |
| 1104 | |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 1105 | public void closeRemoteInput() { |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1106 | for (NotificationContentView l : mLayouts) { |
| 1107 | l.closeRemoteInput(); |
| 1108 | } |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 1109 | } |
| 1110 | |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 1111 | /** |
| 1112 | * Set by how much the single line view should be indented. |
| 1113 | */ |
| 1114 | public void setSingleLineWidthIndention(int indention) { |
| 1115 | mPrivateLayout.setSingleLineWidthIndention(indention); |
| 1116 | } |
| 1117 | |
| 1118 | public int getNotificationColor() { |
Selim Cinek | 4bb5934 | 2016-04-08 19:29:35 -0700 | [diff] [blame] | 1119 | return mNotificationColor; |
| 1120 | } |
| 1121 | |
| 1122 | private void updateNotificationColor() { |
| 1123 | mNotificationColor = NotificationColorUtil.resolveContrastColor(mContext, |
Selim Cinek | ac5f027 | 2017-05-02 16:05:41 -0700 | [diff] [blame] | 1124 | getStatusBarNotification().getNotification().color, |
| 1125 | getBackgroundColorWithoutTint()); |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 1126 | mNotificationColorAmbient = NotificationColorUtil.resolveAmbientColor(mContext, |
| 1127 | getStatusBarNotification().getNotification().color); |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 1128 | } |
| 1129 | |
| 1130 | public HybridNotificationView getSingleLineView() { |
| 1131 | return mPrivateLayout.getSingleLineView(); |
| 1132 | } |
| 1133 | |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 1134 | public HybridNotificationView getAmbientSingleLineView() { |
| 1135 | return getShowingLayout().getAmbientSingleLineChild(); |
| 1136 | } |
| 1137 | |
Selim Cinek | f07d062 | 2016-03-21 19:52:52 -0700 | [diff] [blame] | 1138 | public boolean isOnKeyguard() { |
| 1139 | return mOnKeyguard; |
| 1140 | } |
| 1141 | |
Selim Cinek | c1e389d | 2016-04-07 11:02:57 -0700 | [diff] [blame] | 1142 | public void removeAllChildren() { |
| 1143 | List<ExpandableNotificationRow> notificationChildren |
| 1144 | = mChildrenContainer.getNotificationChildren(); |
| 1145 | ArrayList<ExpandableNotificationRow> clonedList = new ArrayList<>(notificationChildren); |
| 1146 | for (int i = 0; i < clonedList.size(); i++) { |
| 1147 | ExpandableNotificationRow row = clonedList.get(i); |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1148 | if (row.keepInParent()) { |
| 1149 | continue; |
| 1150 | } |
Selim Cinek | c1e389d | 2016-04-07 11:02:57 -0700 | [diff] [blame] | 1151 | mChildrenContainer.removeNotification(row); |
Selim Cinek | c1e389d | 2016-04-07 11:02:57 -0700 | [diff] [blame] | 1152 | row.setIsChildInGroup(false, null); |
| 1153 | } |
| 1154 | onChildrenCountChanged(); |
| 1155 | } |
| 1156 | |
Selim Cinek | 1b2a05e | 2016-04-28 14:20:39 -0700 | [diff] [blame] | 1157 | public void setForceUnlocked(boolean forceUnlocked) { |
| 1158 | mForceUnlocked = forceUnlocked; |
| 1159 | if (mIsSummaryWithChildren) { |
| 1160 | List<ExpandableNotificationRow> notificationChildren = getNotificationChildren(); |
| 1161 | for (ExpandableNotificationRow child : notificationChildren) { |
| 1162 | child.setForceUnlocked(forceUnlocked); |
| 1163 | } |
| 1164 | } |
| 1165 | } |
| 1166 | |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 1167 | public void setDismissed(boolean fromAccessibility) { |
Rohan Shah | c6990a0 | 2018-03-23 17:24:17 -0700 | [diff] [blame] | 1168 | setLongPressListener(null); |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 1169 | mDismissed = true; |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 1170 | mGroupParentWhenDismissed = mNotificationParent; |
| 1171 | mRefocusOnDismiss = fromAccessibility; |
| 1172 | mChildAfterViewWhenDismissed = null; |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 1173 | mEntry.icon.setDismissed(); |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 1174 | if (isChildInGroup()) { |
| 1175 | List<ExpandableNotificationRow> notificationChildren = |
| 1176 | mNotificationParent.getNotificationChildren(); |
| 1177 | int i = notificationChildren.indexOf(this); |
| 1178 | if (i != -1 && i < notificationChildren.size() - 1) { |
| 1179 | mChildAfterViewWhenDismissed = notificationChildren.get(i + 1); |
| 1180 | } |
| 1181 | } |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1182 | } |
| 1183 | |
| 1184 | public boolean isDismissed() { |
| 1185 | return mDismissed; |
| 1186 | } |
| 1187 | |
| 1188 | public boolean keepInParent() { |
| 1189 | return mKeepInParent; |
| 1190 | } |
| 1191 | |
| 1192 | public void setKeepInParent(boolean keepInParent) { |
| 1193 | mKeepInParent = keepInParent; |
| 1194 | } |
| 1195 | |
Selim Cinek | d9b7dd4 | 2017-11-10 17:53:47 -0800 | [diff] [blame] | 1196 | @Override |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1197 | public boolean isRemoved() { |
| 1198 | return mRemoved; |
| 1199 | } |
| 1200 | |
Adrian Roos | d009ab1 | 2016-05-20 17:58:53 -0700 | [diff] [blame] | 1201 | public void setRemoved() { |
| 1202 | mRemoved = true; |
Selim Cinek | ef8c225 | 2017-02-10 14:52:18 -0800 | [diff] [blame] | 1203 | mTranslationWhenRemoved = getTranslationY(); |
| 1204 | mWasChildInGroupWhenRemoved = isChildInGroup(); |
| 1205 | if (isChildInGroup()) { |
| 1206 | mTranslationWhenRemoved += getNotificationParent().getTranslationY(); |
| 1207 | } |
Adrian Roos | d009ab1 | 2016-05-20 17:58:53 -0700 | [diff] [blame] | 1208 | mPrivateLayout.setRemoved(); |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1209 | } |
| 1210 | |
Selim Cinek | ef8c225 | 2017-02-10 14:52:18 -0800 | [diff] [blame] | 1211 | public boolean wasChildInGroupWhenRemoved() { |
| 1212 | return mWasChildInGroupWhenRemoved; |
| 1213 | } |
| 1214 | |
| 1215 | public float getTranslationWhenRemoved() { |
| 1216 | return mTranslationWhenRemoved; |
| 1217 | } |
| 1218 | |
Selim Cinek | d139564 | 2016-04-28 12:22:42 -0700 | [diff] [blame] | 1219 | public NotificationChildrenContainer getChildrenContainer() { |
| 1220 | return mChildrenContainer; |
| 1221 | } |
| 1222 | |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 1223 | public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) { |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 1224 | boolean wasAboveShelf = isAboveShelf(); |
Selim Cinek | 8875de1 | 2018-03-22 10:14:32 -0700 | [diff] [blame] | 1225 | boolean changed = headsUpAnimatingAway != mHeadsupDisappearRunning; |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 1226 | mHeadsupDisappearRunning = headsUpAnimatingAway; |
| 1227 | mPrivateLayout.setHeadsUpAnimatingAway(headsUpAnimatingAway); |
Selim Cinek | 8875de1 | 2018-03-22 10:14:32 -0700 | [diff] [blame] | 1228 | if (changed && mHeadsUpAnimatingAwayListener != null) { |
| 1229 | mHeadsUpAnimatingAwayListener.accept(headsUpAnimatingAway); |
| 1230 | } |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 1231 | if (isAboveShelf() != wasAboveShelf) { |
| 1232 | mAboveShelfChangedListener.onAboveShelfStateChanged(!wasAboveShelf); |
| 1233 | } |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 1234 | } |
| 1235 | |
Selim Cinek | 8875de1 | 2018-03-22 10:14:32 -0700 | [diff] [blame] | 1236 | public void setHeadsUpAnimatingAwayListener(Consumer<Boolean> listener) { |
| 1237 | mHeadsUpAnimatingAwayListener = listener; |
| 1238 | } |
| 1239 | |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 1240 | /** |
| 1241 | * @return if the view was just heads upped and is now animating away. During such a time the |
| 1242 | * layout needs to be kept consistent |
| 1243 | */ |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 1244 | @Override |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 1245 | public boolean isHeadsUpAnimatingAway() { |
| 1246 | return mHeadsupDisappearRunning; |
Selim Cinek | 73cf02a | 2016-06-17 13:08:00 -0700 | [diff] [blame] | 1247 | } |
| 1248 | |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 1249 | public View getChildAfterViewWhenDismissed() { |
| 1250 | return mChildAfterViewWhenDismissed; |
| 1251 | } |
| 1252 | |
| 1253 | public View getGroupParentWhenDismissed() { |
| 1254 | return mGroupParentWhenDismissed; |
| 1255 | } |
| 1256 | |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 1257 | /** |
| 1258 | * Dismisses the notification with the option of showing the blocking helper in-place if we have |
| 1259 | * a negative user sentiment. |
| 1260 | * |
| 1261 | * @param fromAccessibility whether this dismiss is coming from an accessibility action |
| 1262 | * @return whether a blocking helper is shown in this row |
| 1263 | */ |
| 1264 | public boolean performDismissWithBlockingHelper(boolean fromAccessibility) { |
| 1265 | NotificationBlockingHelperManager manager = |
| 1266 | Dependency.get(NotificationBlockingHelperManager.class); |
| 1267 | boolean isBlockingHelperShown = manager.perhapsShowBlockingHelper(this, mMenuRow); |
| 1268 | |
Rohan Shah | da5dcdd | 2018-04-27 17:21:50 -0700 | [diff] [blame] | 1269 | Dependency.get(MetricsLogger.class).count(NotificationCounters.NOTIFICATION_DISMISSED, 1); |
| 1270 | |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 1271 | // Continue with dismiss since we don't want the blocking helper to be directly associated |
| 1272 | // with a certain notification. |
| 1273 | performDismiss(fromAccessibility); |
| 1274 | return isBlockingHelperShown; |
| 1275 | } |
| 1276 | |
yoshiki iguchi | 85ccbbc | 2018-01-22 12:33:21 +0900 | [diff] [blame] | 1277 | public void performDismiss(boolean fromAccessibility) { |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 1278 | if (isOnlyChildInGroup()) { |
yoshiki iguchi | 85ccbbc | 2018-01-22 12:33:21 +0900 | [diff] [blame] | 1279 | ExpandableNotificationRow groupSummary = |
| 1280 | mGroupManager.getLogicalGroupSummary(getStatusBarNotification()); |
| 1281 | if (groupSummary.isClearable()) { |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 1282 | // If this is the only child in the group, dismiss the group, but don't try to show |
| 1283 | // the blocking helper affordance! |
yoshiki iguchi | 85ccbbc | 2018-01-22 12:33:21 +0900 | [diff] [blame] | 1284 | groupSummary.performDismiss(fromAccessibility); |
| 1285 | } |
| 1286 | } |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 1287 | setDismissed(fromAccessibility); |
yoshiki iguchi | 85ccbbc | 2018-01-22 12:33:21 +0900 | [diff] [blame] | 1288 | if (isClearable()) { |
| 1289 | if (mOnDismissRunnable != null) { |
| 1290 | mOnDismissRunnable.run(); |
| 1291 | } |
Selim Cinek | e907911 | 2016-12-14 14:41:01 -0800 | [diff] [blame] | 1292 | } |
Selim Cinek | 9e624e7 | 2016-07-20 13:46:49 -0700 | [diff] [blame] | 1293 | } |
| 1294 | |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 1295 | public void setBlockingHelperShowing(boolean isBlockingHelperShowing) { |
| 1296 | mIsBlockingHelperShowing = isBlockingHelperShowing; |
| 1297 | } |
| 1298 | |
| 1299 | public boolean isBlockingHelperShowing() { |
| 1300 | return mIsBlockingHelperShowing; |
| 1301 | } |
| 1302 | |
Selim Cinek | e907911 | 2016-12-14 14:41:01 -0800 | [diff] [blame] | 1303 | public void setOnDismissRunnable(Runnable onDismissRunnable) { |
| 1304 | mOnDismissRunnable = onDismissRunnable; |
Selim Cinek | 9e624e7 | 2016-07-20 13:46:49 -0700 | [diff] [blame] | 1305 | } |
| 1306 | |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 1307 | public View getNotificationIcon() { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1308 | NotificationHeaderView notificationHeader = getVisibleNotificationHeader(); |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 1309 | if (notificationHeader != null) { |
| 1310 | return notificationHeader.getIcon(); |
| 1311 | } |
| 1312 | return null; |
| 1313 | } |
| 1314 | |
| 1315 | /** |
| 1316 | * @return whether the notification is currently showing a view with an icon. |
| 1317 | */ |
| 1318 | public boolean isShowingIcon() { |
Mady Mellor | 434180c | 2017-02-13 11:29:42 -0800 | [diff] [blame] | 1319 | if (areGutsExposed()) { |
| 1320 | return false; |
| 1321 | } |
Selim Cinek | 2ffa02f | 2017-03-06 15:56:37 -0800 | [diff] [blame] | 1322 | return getVisibleNotificationHeader() != null; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 1323 | } |
| 1324 | |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 1325 | /** |
| 1326 | * Set how much this notification is transformed into an icon. |
| 1327 | * |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 1328 | * @param contentTransformationAmount A value from 0 to 1 indicating how much we are transformed |
| 1329 | * to the content away |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1330 | * @param isLastChild is this the last child in the list. If true, then the transformation is |
| 1331 | * different since it's content fades out. |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 1332 | */ |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 1333 | public void setContentTransformationAmount(float contentTransformationAmount, |
| 1334 | boolean isLastChild) { |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1335 | boolean changeTransformation = isLastChild != mIsLastChild; |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 1336 | changeTransformation |= mContentTransformationAmount != contentTransformationAmount; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1337 | mIsLastChild = isLastChild; |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 1338 | mContentTransformationAmount = contentTransformationAmount; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1339 | if (changeTransformation) { |
| 1340 | updateContentTransformation(); |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 1341 | } |
| 1342 | } |
| 1343 | |
| 1344 | /** |
| 1345 | * Set the icons to be visible of this notification. |
| 1346 | */ |
| 1347 | public void setIconsVisible(boolean iconsVisible) { |
| 1348 | if (iconsVisible != mIconsVisible) { |
| 1349 | mIconsVisible = iconsVisible; |
| 1350 | updateIconVisibilities(); |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 1351 | } |
| 1352 | } |
| 1353 | |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 1354 | @Override |
| 1355 | protected void onBelowSpeedBumpChanged() { |
| 1356 | updateIconVisibilities(); |
| 1357 | } |
| 1358 | |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1359 | private void updateContentTransformation() { |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 1360 | if (mExpandAnimationRunning) { |
| 1361 | return; |
| 1362 | } |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1363 | float contentAlpha; |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 1364 | float translationY = -mContentTransformationAmount * mIconTransformContentShift; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1365 | if (mIsLastChild) { |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 1366 | contentAlpha = 1.0f - mContentTransformationAmount; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1367 | contentAlpha = Math.min(contentAlpha / 0.5f, 1.0f); |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 1368 | contentAlpha = Interpolators.ALPHA_OUT.getInterpolation(contentAlpha); |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1369 | translationY *= 0.4f; |
| 1370 | } else { |
| 1371 | contentAlpha = 1.0f; |
| 1372 | } |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1373 | for (NotificationContentView l : mLayouts) { |
| 1374 | l.setAlpha(contentAlpha); |
| 1375 | l.setTranslationY(translationY); |
| 1376 | } |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1377 | if (mChildrenContainer != null) { |
| 1378 | mChildrenContainer.setAlpha(contentAlpha); |
| 1379 | mChildrenContainer.setTranslationY(translationY); |
| 1380 | // TODO: handle children fade out better |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 1381 | } |
| 1382 | } |
| 1383 | |
| 1384 | private void updateIconVisibilities() { |
Selim Cinek | 17e1b69 | 2016-12-02 18:19:11 -0800 | [diff] [blame] | 1385 | boolean visible = isChildInGroup() |
| 1386 | || (isBelowSpeedBump() && !NotificationShelf.SHOW_AMBIENT_ICONS) |
| 1387 | || mIconsVisible; |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1388 | for (NotificationContentView l : mLayouts) { |
| 1389 | l.setIconsVisible(visible); |
| 1390 | } |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 1391 | if (mChildrenContainer != null) { |
| 1392 | mChildrenContainer.setIconsVisible(visible); |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 1393 | } |
| 1394 | } |
| 1395 | |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1396 | /** |
| 1397 | * Get the relative top padding of a view relative to this view. This recursively walks up the |
| 1398 | * hierarchy and does the corresponding measuring. |
| 1399 | * |
| 1400 | * @param view the view to the the padding for. The requested view has to be a child of this |
| 1401 | * notification. |
| 1402 | * @return the toppadding |
| 1403 | */ |
| 1404 | public int getRelativeTopPadding(View view) { |
| 1405 | int topPadding = 0; |
| 1406 | while (view.getParent() instanceof ViewGroup) { |
| 1407 | topPadding += view.getTop(); |
| 1408 | view = (View) view.getParent(); |
| 1409 | if (view instanceof ExpandableNotificationRow) { |
| 1410 | return topPadding; |
| 1411 | } |
| 1412 | } |
| 1413 | return topPadding; |
| 1414 | } |
| 1415 | |
Selim Cinek | a1d9790 | 2016-12-14 16:31:40 -0800 | [diff] [blame] | 1416 | public float getContentTranslation() { |
| 1417 | return mPrivateLayout.getTranslationY(); |
| 1418 | } |
| 1419 | |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 1420 | public void setIsLowPriority(boolean isLowPriority) { |
| 1421 | mIsLowPriority = isLowPriority; |
| 1422 | mPrivateLayout.setIsLowPriority(isLowPriority); |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1423 | mNotificationInflater.setIsLowPriority(mIsLowPriority); |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 1424 | if (mChildrenContainer != null) { |
| 1425 | mChildrenContainer.setIsLowPriority(isLowPriority); |
| 1426 | } |
| 1427 | } |
| 1428 | |
Selim Cinek | 55a3e73 | 2017-05-25 18:30:10 -0700 | [diff] [blame] | 1429 | |
| 1430 | public void setLowPriorityStateUpdated(boolean lowPriorityStateUpdated) { |
| 1431 | mLowPriorityStateUpdated = lowPriorityStateUpdated; |
| 1432 | } |
| 1433 | |
| 1434 | public boolean hasLowPriorityStateUpdated() { |
| 1435 | return mLowPriorityStateUpdated; |
| 1436 | } |
| 1437 | |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1438 | public boolean isLowPriority() { |
| 1439 | return mIsLowPriority; |
| 1440 | } |
| 1441 | |
Selim Cinek | 7d1009b | 2017-01-25 15:28:28 -0800 | [diff] [blame] | 1442 | public void setUseIncreasedCollapsedHeight(boolean use) { |
| 1443 | mUseIncreasedCollapsedHeight = use; |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1444 | mNotificationInflater.setUsesIncreasedHeight(use); |
Selim Cinek | 7d1009b | 2017-01-25 15:28:28 -0800 | [diff] [blame] | 1445 | } |
| 1446 | |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 1447 | public void setUseIncreasedHeadsUpHeight(boolean use) { |
| 1448 | mUseIncreasedHeadsUpHeight = use; |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1449 | mNotificationInflater.setUsesIncreasedHeadsUpHeight(use); |
| 1450 | } |
| 1451 | |
| 1452 | public void setRemoteViewClickHandler(RemoteViews.OnClickHandler remoteViewClickHandler) { |
| 1453 | mNotificationInflater.setRemoteViewClickHandler(remoteViewClickHandler); |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 1454 | } |
| 1455 | |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 1456 | public void setInflationCallback(InflationCallback callback) { |
| 1457 | mNotificationInflater.setInflationCallback(callback); |
Selim Cinek | c478f90 | 2017-02-22 20:55:44 -0800 | [diff] [blame] | 1458 | } |
| 1459 | |
Adrian Roos | 1a1ecfc | 2017-04-17 11:17:59 -0700 | [diff] [blame] | 1460 | public void setNeedsRedaction(boolean needsRedaction) { |
| 1461 | mNotificationInflater.setRedactAmbient(needsRedaction); |
| 1462 | } |
| 1463 | |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 1464 | @VisibleForTesting |
| 1465 | public NotificationInflater getNotificationInflater() { |
| 1466 | return mNotificationInflater; |
| 1467 | } |
| 1468 | |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 1469 | public int getNotificationColorAmbient() { |
| 1470 | return mNotificationColorAmbient; |
| 1471 | } |
| 1472 | |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1473 | public interface ExpansionLogger { |
Anthony Chen | 6bf88a0 | 2017-04-10 14:41:44 -0700 | [diff] [blame] | 1474 | void logNotificationExpansion(String key, boolean userAction, boolean expanded); |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1475 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1476 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1477 | public ExpandableNotificationRow(Context context, AttributeSet attrs) { |
| 1478 | super(context, attrs); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 1479 | mFalsingManager = FalsingManager.getInstance(context); |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1480 | mNotificationInflater = new NotificationInflater(this); |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 1481 | mMenuRow = new NotificationMenuRow(mContext); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 1482 | initDimens(); |
| 1483 | } |
| 1484 | |
| 1485 | private void initDimens() { |
Selim Cinek | e62255c | 2017-09-28 18:23:23 -0700 | [diff] [blame] | 1486 | mNotificationMinHeightLegacy = NotificationUtils.getFontScaledHeight(mContext, |
| 1487 | R.dimen.notification_min_height_legacy); |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 1488 | mNotificationMinHeightBeforeP = NotificationUtils.getFontScaledHeight(mContext, |
| 1489 | R.dimen.notification_min_height_before_p); |
Selim Cinek | e62255c | 2017-09-28 18:23:23 -0700 | [diff] [blame] | 1490 | mNotificationMinHeight = NotificationUtils.getFontScaledHeight(mContext, |
| 1491 | R.dimen.notification_min_height); |
| 1492 | mNotificationMinHeightLarge = NotificationUtils.getFontScaledHeight(mContext, |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 1493 | R.dimen.notification_min_height_increased); |
Selim Cinek | e62255c | 2017-09-28 18:23:23 -0700 | [diff] [blame] | 1494 | mNotificationMaxHeight = NotificationUtils.getFontScaledHeight(mContext, |
| 1495 | R.dimen.notification_max_height); |
| 1496 | mNotificationAmbientHeight = NotificationUtils.getFontScaledHeight(mContext, |
| 1497 | R.dimen.notification_ambient_height); |
| 1498 | mMaxHeadsUpHeightLegacy = NotificationUtils.getFontScaledHeight(mContext, |
Selim Cinek | 77019c7 | 2015-12-09 10:18:02 -0800 | [diff] [blame] | 1499 | R.dimen.notification_max_heads_up_height_legacy); |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 1500 | mMaxHeadsUpHeightBeforeP = NotificationUtils.getFontScaledHeight(mContext, |
| 1501 | R.dimen.notification_max_heads_up_height_before_p); |
Selim Cinek | e62255c | 2017-09-28 18:23:23 -0700 | [diff] [blame] | 1502 | mMaxHeadsUpHeight = NotificationUtils.getFontScaledHeight(mContext, |
| 1503 | R.dimen.notification_max_heads_up_height); |
| 1504 | mMaxHeadsUpHeightIncreased = NotificationUtils.getFontScaledHeight(mContext, |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 1505 | R.dimen.notification_max_heads_up_height_increased); |
Anthony Chen | 6bf88a0 | 2017-04-10 14:41:44 -0700 | [diff] [blame] | 1506 | |
Anthony Chen | 7acbb77 | 2017-04-07 16:45:25 -0700 | [diff] [blame] | 1507 | Resources res = getResources(); |
| 1508 | mIncreasedPaddingBetweenElements = res.getDimensionPixelSize( |
| 1509 | R.dimen.notification_divider_height_increased); |
| 1510 | mIconTransformContentShiftNoIcon = res.getDimensionPixelSize( |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 1511 | R.dimen.notification_icon_transform_content_shift); |
Anthony Chen | 6bf88a0 | 2017-04-10 14:41:44 -0700 | [diff] [blame] | 1512 | mEnableNonGroupedNotificationExpand = |
| 1513 | res.getBoolean(R.bool.config_enableNonGroupedNotificationExpand); |
| 1514 | mShowGroupBackgroundWhenExpanded = |
| 1515 | res.getBoolean(R.bool.config_showGroupNotificationBgWhenExpanded); |
Selim Cinek | f619ffc | 2016-02-17 14:53:05 -0800 | [diff] [blame] | 1516 | } |
| 1517 | |
| 1518 | /** |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 1519 | * Resets this view so it can be re-used for an updated notification. |
| 1520 | */ |
| 1521 | public void reset() { |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1522 | mShowingPublicInitialized = false; |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1523 | onHeightReset(); |
Selim Cinek | 6e28a67 | 2014-09-05 14:43:28 +0200 | [diff] [blame] | 1524 | requestLayout(); |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 1525 | } |
| 1526 | |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 1527 | public void showAppOpsIcons(ArraySet<Integer> activeOps) { |
| 1528 | if (mIsSummaryWithChildren && mChildrenContainer.getHeaderView() != null) { |
| 1529 | mChildrenContainer.getHeaderView().showAppOpsIcons(activeOps); |
| 1530 | } |
| 1531 | mPrivateLayout.showAppOpsIcons(activeOps); |
| 1532 | mPublicLayout.showAppOpsIcons(activeOps); |
| 1533 | } |
| 1534 | |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 1535 | public View.OnClickListener getAppOpsOnClickListener() { |
| 1536 | return mOnAppOpsClickListener; |
| 1537 | } |
| 1538 | |
| 1539 | protected void setAppOpsOnClickListener(ExpandableNotificationRow.OnAppOpsClickListener l) { |
| 1540 | mOnAppOpsClickListener = v -> { |
| 1541 | createMenu(); |
| 1542 | MenuItem menuItem = getProvider().getAppOpsMenuItem(mContext); |
| 1543 | if (menuItem != null) { |
| 1544 | l.onClick(this, v.getWidth() / 2, v.getHeight() / 2, menuItem); |
| 1545 | } |
| 1546 | }; |
| 1547 | } |
| 1548 | |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 1549 | @Override |
| 1550 | protected void onFinishInflate() { |
| 1551 | super.onFinishInflate(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1552 | mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic); |
| 1553 | mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded); |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1554 | mLayouts = new NotificationContentView[] {mPrivateLayout, mPublicLayout}; |
| 1555 | |
| 1556 | for (NotificationContentView l : mLayouts) { |
| 1557 | l.setExpandClickListener(mExpandClickListener); |
| 1558 | l.setContainingNotification(this); |
| 1559 | } |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 1560 | mGutsStub = (ViewStub) findViewById(R.id.notification_guts_stub); |
| 1561 | mGutsStub.setOnInflateListener(new ViewStub.OnInflateListener() { |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1562 | @Override |
| 1563 | public void onInflate(ViewStub stub, View inflated) { |
| 1564 | mGuts = (NotificationGuts) inflated; |
| 1565 | mGuts.setClipTopAmount(getClipTopAmount()); |
| 1566 | mGuts.setActualHeight(getActualHeight()); |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 1567 | mGutsStub = null; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1568 | } |
| 1569 | }); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1570 | mChildrenContainerStub = (ViewStub) findViewById(R.id.child_container_stub); |
| 1571 | mChildrenContainerStub.setOnInflateListener(new ViewStub.OnInflateListener() { |
| 1572 | |
| 1573 | @Override |
| 1574 | public void onInflate(ViewStub stub, View inflated) { |
| 1575 | mChildrenContainer = (NotificationChildrenContainer) inflated; |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 1576 | mChildrenContainer.setIsLowPriority(mIsLowPriority); |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1577 | mChildrenContainer.setContainingNotification(ExpandableNotificationRow.this); |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 1578 | mChildrenContainer.onNotificationUpdated(); |
Anthony Chen | 7acbb77 | 2017-04-07 16:45:25 -0700 | [diff] [blame] | 1579 | |
| 1580 | if (mShouldTranslateContents) { |
| 1581 | mTranslateableViews.add(mChildrenContainer); |
| 1582 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1583 | } |
| 1584 | }); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1585 | |
Anthony Chen | 7acbb77 | 2017-04-07 16:45:25 -0700 | [diff] [blame] | 1586 | if (mShouldTranslateContents) { |
| 1587 | // Add the views that we translate to reveal the menu |
| 1588 | mTranslateableViews = new ArrayList<>(); |
| 1589 | for (int i = 0; i < getChildCount(); i++) { |
| 1590 | mTranslateableViews.add(getChildAt(i)); |
| 1591 | } |
| 1592 | // Remove views that don't translate |
| 1593 | mTranslateableViews.remove(mChildrenContainerStub); |
| 1594 | mTranslateableViews.remove(mGutsStub); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1595 | } |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1596 | } |
| 1597 | |
Geoffrey Pitsch | 409db27 | 2017-08-28 14:51:52 +0000 | [diff] [blame] | 1598 | private void doLongClickCallback() { |
| 1599 | doLongClickCallback(getWidth() / 2, getHeight() / 2); |
| 1600 | } |
| 1601 | |
| 1602 | public void doLongClickCallback(int x, int y) { |
| 1603 | createMenu(); |
| 1604 | MenuItem menuItem = getProvider().getLongpressMenuItem(mContext); |
Mady Mellor | b3a6aed | 2018-05-11 13:24:07 -0700 | [diff] [blame] | 1605 | doLongClickCallback(x, y, menuItem); |
| 1606 | } |
| 1607 | |
| 1608 | private void doLongClickCallback(int x, int y, MenuItem menuItem) { |
Geoffrey Pitsch | 409db27 | 2017-08-28 14:51:52 +0000 | [diff] [blame] | 1609 | if (mLongPressListener != null && menuItem != null) { |
| 1610 | mLongPressListener.onLongPress(this, x, y, menuItem); |
| 1611 | } |
| 1612 | } |
| 1613 | |
| 1614 | @Override |
| 1615 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
| 1616 | if (KeyEvent.isConfirmKey(keyCode)) { |
| 1617 | event.startTracking(); |
| 1618 | return true; |
| 1619 | } |
| 1620 | return super.onKeyDown(keyCode, event); |
| 1621 | } |
| 1622 | |
| 1623 | @Override |
| 1624 | public boolean onKeyUp(int keyCode, KeyEvent event) { |
| 1625 | if (KeyEvent.isConfirmKey(keyCode)) { |
| 1626 | if (!event.isCanceled()) { |
| 1627 | performClick(); |
| 1628 | } |
| 1629 | return true; |
| 1630 | } |
| 1631 | return super.onKeyUp(keyCode, event); |
| 1632 | } |
| 1633 | |
| 1634 | @Override |
| 1635 | public boolean onKeyLongPress(int keyCode, KeyEvent event) { |
| 1636 | if (KeyEvent.isConfirmKey(keyCode)) { |
| 1637 | doLongClickCallback(); |
| 1638 | return true; |
| 1639 | } |
| 1640 | return false; |
| 1641 | } |
| 1642 | |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1643 | public void resetTranslation() { |
Mady Mellor | 32c638a | 2016-09-14 08:58:25 -0700 | [diff] [blame] | 1644 | if (mTranslateAnim != null) { |
| 1645 | mTranslateAnim.cancel(); |
| 1646 | } |
Anthony Chen | 7acbb77 | 2017-04-07 16:45:25 -0700 | [diff] [blame] | 1647 | |
| 1648 | if (!mShouldTranslateContents) { |
| 1649 | setTranslationX(0); |
| 1650 | } else if (mTranslateableViews != null) { |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1651 | for (int i = 0; i < mTranslateableViews.size(); i++) { |
| 1652 | mTranslateableViews.get(i).setTranslationX(0); |
| 1653 | } |
Anthony Chen | 7acbb77 | 2017-04-07 16:45:25 -0700 | [diff] [blame] | 1654 | invalidateOutline(); |
shawnlin | 4fbeac4 | 2018-04-30 20:32:40 +0800 | [diff] [blame] | 1655 | getEntry().expandedIcon.setScrollX(0); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1656 | } |
Anthony Chen | 7acbb77 | 2017-04-07 16:45:25 -0700 | [diff] [blame] | 1657 | |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 1658 | mMenuRow.resetMenu(); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1659 | } |
| 1660 | |
Rohan Shah | 56eb091 | 2018-05-10 21:49:04 -0700 | [diff] [blame] | 1661 | void onGutsOpened() { |
| 1662 | resetTranslation(); |
| 1663 | updateContentAccessibilityImportanceForGuts(false /* isEnabled */); |
| 1664 | } |
| 1665 | |
| 1666 | void onGutsClosed() { |
| 1667 | updateContentAccessibilityImportanceForGuts(true /* isEnabled */); |
| 1668 | } |
| 1669 | |
| 1670 | /** |
| 1671 | * Updates whether all the non-guts content inside this row is important for accessibility. |
| 1672 | * |
| 1673 | * @param isEnabled whether the content views should be enabled for accessibility |
| 1674 | */ |
| 1675 | private void updateContentAccessibilityImportanceForGuts(boolean isEnabled) { |
| 1676 | if (mChildrenContainer != null) { |
| 1677 | updateChildAccessibilityImportance(mChildrenContainer, isEnabled); |
| 1678 | } |
| 1679 | if (mLayouts != null) { |
| 1680 | for (View view : mLayouts) { |
| 1681 | updateChildAccessibilityImportance(view, isEnabled); |
| 1682 | } |
| 1683 | } |
| 1684 | |
| 1685 | if (isEnabled) { |
| 1686 | this.requestAccessibilityFocus(); |
| 1687 | } |
| 1688 | } |
| 1689 | |
| 1690 | /** |
| 1691 | * Updates whether the given childView is important for accessibility based on |
| 1692 | * {@code isEnabled}. |
| 1693 | */ |
| 1694 | private void updateChildAccessibilityImportance(View childView, boolean isEnabled) { |
| 1695 | childView.setImportantForAccessibility(isEnabled |
| 1696 | ? View.IMPORTANT_FOR_ACCESSIBILITY_AUTO |
| 1697 | : View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); |
| 1698 | } |
| 1699 | |
Selim Cinek | de4de0e | 2018-01-24 16:21:07 -0800 | [diff] [blame] | 1700 | public CharSequence getActiveRemoteInputText() { |
| 1701 | return mPrivateLayout.getActiveRemoteInputText(); |
| 1702 | } |
| 1703 | |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1704 | public void animateTranslateNotification(final float leftTarget) { |
| 1705 | if (mTranslateAnim != null) { |
| 1706 | mTranslateAnim.cancel(); |
| 1707 | } |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1708 | mTranslateAnim = getTranslateViewAnimator(leftTarget, null /* updateListener */); |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 1709 | if (mTranslateAnim != null) { |
| 1710 | mTranslateAnim.start(); |
| 1711 | } |
| 1712 | } |
| 1713 | |
| 1714 | @Override |
| 1715 | public void setTranslation(float translationX) { |
| 1716 | if (areGutsExposed()) { |
| 1717 | // Don't translate if guts are showing. |
| 1718 | return; |
| 1719 | } |
Anthony Chen | 7acbb77 | 2017-04-07 16:45:25 -0700 | [diff] [blame] | 1720 | if (!mShouldTranslateContents) { |
| 1721 | setTranslationX(translationX); |
| 1722 | } else if (mTranslateableViews != null) { |
| 1723 | // Translate the group of views |
| 1724 | for (int i = 0; i < mTranslateableViews.size(); i++) { |
| 1725 | if (mTranslateableViews.get(i) != null) { |
| 1726 | mTranslateableViews.get(i).setTranslationX(translationX); |
| 1727 | } |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 1728 | } |
Anthony Chen | 7acbb77 | 2017-04-07 16:45:25 -0700 | [diff] [blame] | 1729 | invalidateOutline(); |
Selim Cinek | 143672c | 2018-03-23 20:04:32 -0700 | [diff] [blame] | 1730 | |
| 1731 | // In order to keep the shelf in sync with this swiping, we're simply translating |
| 1732 | // it's icon by the same amount. The translation is already being used for the normal |
| 1733 | // positioning, so we can use the scrollX instead. |
| 1734 | getEntry().expandedIcon.setScrollX((int) -translationX); |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 1735 | } |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 1736 | if (mMenuRow.getMenuView() != null) { |
| 1737 | mMenuRow.onTranslationUpdate(translationX); |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 1738 | } |
| 1739 | } |
| 1740 | |
| 1741 | @Override |
| 1742 | public float getTranslation() { |
Anthony Chen | e04afcb | 2017-04-21 13:51:32 -0700 | [diff] [blame] | 1743 | if (!mShouldTranslateContents) { |
Anthony Chen | 7acbb77 | 2017-04-07 16:45:25 -0700 | [diff] [blame] | 1744 | return getTranslationX(); |
| 1745 | } |
| 1746 | |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 1747 | if (mTranslateableViews != null && mTranslateableViews.size() > 0) { |
| 1748 | // All of the views in the list should have same translation, just use first one. |
| 1749 | return mTranslateableViews.get(0).getTranslationX(); |
| 1750 | } |
Anthony Chen | 7acbb77 | 2017-04-07 16:45:25 -0700 | [diff] [blame] | 1751 | |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 1752 | return 0; |
| 1753 | } |
| 1754 | |
| 1755 | public Animator getTranslateViewAnimator(final float leftTarget, |
| 1756 | AnimatorUpdateListener listener) { |
Mady Mellor | 723f1f9 | 2016-03-13 15:54:06 -0700 | [diff] [blame] | 1757 | if (mTranslateAnim != null) { |
| 1758 | mTranslateAnim.cancel(); |
| 1759 | } |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 1760 | if (areGutsExposed()) { |
| 1761 | // No translation if guts are exposed. |
| 1762 | return null; |
| 1763 | } |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1764 | final ObjectAnimator translateAnim = ObjectAnimator.ofFloat(this, TRANSLATE_CONTENT, |
| 1765 | leftTarget); |
| 1766 | if (listener != null) { |
| 1767 | translateAnim.addUpdateListener(listener); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1768 | } |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1769 | translateAnim.addListener(new AnimatorListenerAdapter() { |
| 1770 | boolean cancelled = false; |
| 1771 | |
| 1772 | @Override |
| 1773 | public void onAnimationCancel(Animator anim) { |
| 1774 | cancelled = true; |
| 1775 | } |
| 1776 | |
| 1777 | @Override |
| 1778 | public void onAnimationEnd(Animator anim) { |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 1779 | if (!cancelled && leftTarget == 0) { |
| 1780 | mMenuRow.resetMenu(); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1781 | mTranslateAnim = null; |
| 1782 | } |
| 1783 | } |
| 1784 | }); |
| 1785 | mTranslateAnim = translateAnim; |
| 1786 | return translateAnim; |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1787 | } |
| 1788 | |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 1789 | public void inflateGuts() { |
| 1790 | if (mGuts == null) { |
| 1791 | mGutsStub.inflate(); |
| 1792 | } |
| 1793 | } |
| 1794 | |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 1795 | private void updateChildrenVisibility() { |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 1796 | boolean hideContentWhileLaunching = mExpandAnimationRunning && mGuts != null |
| 1797 | && mGuts.isExposed(); |
| 1798 | mPrivateLayout.setVisibility(!shouldShowPublic() && !mIsSummaryWithChildren |
| 1799 | && !hideContentWhileLaunching ? VISIBLE : INVISIBLE); |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1800 | if (mChildrenContainer != null) { |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 1801 | mChildrenContainer.setVisibility(!shouldShowPublic() && mIsSummaryWithChildren |
| 1802 | && !hideContentWhileLaunching ? VISIBLE |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1803 | : INVISIBLE); |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1804 | } |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 1805 | // The limits might have changed if the view suddenly became a group or vice versa |
| 1806 | updateLimits(); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1807 | } |
| 1808 | |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 1809 | @Override |
Alan Viverette | a54956a | 2015-01-07 16:05:02 -0800 | [diff] [blame] | 1810 | public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event) { |
| 1811 | if (super.onRequestSendAccessibilityEventInternal(child, event)) { |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 1812 | // Add a record for the entire layout since its content is somehow small. |
| 1813 | // The event comes from a leaf view that is interacted with. |
| 1814 | AccessibilityEvent record = AccessibilityEvent.obtain(); |
| 1815 | onInitializeAccessibilityEvent(record); |
| 1816 | dispatchPopulateAccessibilityEvent(record); |
| 1817 | event.appendRecord(record); |
| 1818 | return true; |
| 1819 | } |
| 1820 | return false; |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 1821 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1822 | |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 1823 | @Override |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 1824 | public void setDark(boolean dark, boolean fade, long delay) { |
| 1825 | super.setDark(dark, fade, delay); |
Lucas Dupin | cecc7c2 | 2017-09-12 16:02:45 -0700 | [diff] [blame] | 1826 | mDark = dark; |
Adrian Roos | 28f90c7 | 2017-05-08 17:24:26 -0700 | [diff] [blame] | 1827 | if (!mIsHeadsUp) { |
| 1828 | // Only fade the showing view of the pulsing notification. |
| 1829 | fade = false; |
| 1830 | } |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 1831 | final NotificationContentView showing = getShowingLayout(); |
| 1832 | if (showing != null) { |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 1833 | showing.setDark(dark, fade, delay); |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 1834 | } |
Selim Cinek | 9c7712d | 2015-12-08 19:19:48 -0800 | [diff] [blame] | 1835 | if (mIsSummaryWithChildren) { |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 1836 | mChildrenContainer.setDark(dark, fade, delay); |
Selim Cinek | 9c7712d | 2015-12-08 19:19:48 -0800 | [diff] [blame] | 1837 | } |
Selim Cinek | a7c6963 | 2017-06-07 15:51:29 -0700 | [diff] [blame] | 1838 | updateShelfIconColor(); |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 1839 | } |
| 1840 | |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 1841 | public void applyExpandAnimationParams(ExpandAnimationParameters params) { |
| 1842 | if (params == null) { |
| 1843 | return; |
| 1844 | } |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 1845 | float zProgress = Interpolators.FAST_OUT_SLOW_IN.getInterpolation( |
| 1846 | params.getProgress(0, 50)); |
| 1847 | float translationZ = MathUtils.lerp(params.getStartTranslationZ(), |
| 1848 | mNotificationLaunchHeight, |
| 1849 | zProgress); |
| 1850 | setTranslationZ(translationZ); |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 1851 | float extraWidthForClipping = params.getWidth() - getWidth() |
| 1852 | + MathUtils.lerp(0, mOutlineRadius * 2, params.getProgress()); |
| 1853 | setExtraWidthForClipping(extraWidthForClipping); |
| 1854 | int top = params.getTop(); |
| 1855 | float interpolation = Interpolators.FAST_OUT_SLOW_IN.getInterpolation(params.getProgress()); |
| 1856 | int startClipTopAmount = params.getStartClipTopAmount(); |
| 1857 | if (mNotificationParent != null) { |
| 1858 | top -= mNotificationParent.getTranslationY(); |
| 1859 | mNotificationParent.setTranslationZ(translationZ); |
| 1860 | int parentStartClipTopAmount = params.getParentStartClipTopAmount(); |
| 1861 | if (startClipTopAmount != 0) { |
| 1862 | int clipTopAmount = (int) MathUtils.lerp(parentStartClipTopAmount, |
| 1863 | parentStartClipTopAmount - startClipTopAmount, |
| 1864 | interpolation); |
| 1865 | mNotificationParent.setClipTopAmount(clipTopAmount); |
| 1866 | } |
| 1867 | mNotificationParent.setExtraWidthForClipping(extraWidthForClipping); |
| 1868 | mNotificationParent.setMinimumHeightForClipping(params.getHeight() |
| 1869 | + mNotificationParent.getActualHeight()); |
| 1870 | } else if (startClipTopAmount != 0) { |
| 1871 | int clipTopAmount = (int) MathUtils.lerp(startClipTopAmount, 0, interpolation); |
| 1872 | setClipTopAmount(clipTopAmount); |
| 1873 | } |
| 1874 | setTranslationY(top); |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 1875 | setActualHeight(params.getHeight()); |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 1876 | |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 1877 | mBackgroundNormal.setExpandAnimationParams(params); |
| 1878 | } |
| 1879 | |
| 1880 | public void setExpandAnimationRunning(boolean expandAnimationRunning) { |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 1881 | View contentView; |
| 1882 | if (mIsSummaryWithChildren) { |
| 1883 | contentView = mChildrenContainer; |
| 1884 | } else { |
| 1885 | contentView = getShowingLayout(); |
| 1886 | } |
| 1887 | if (mGuts != null && mGuts.isExposed()) { |
| 1888 | contentView = mGuts; |
| 1889 | } |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 1890 | if (expandAnimationRunning) { |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 1891 | contentView.animate() |
| 1892 | .alpha(0f) |
| 1893 | .setDuration(ActivityLaunchAnimator.ANIMATION_DURATION_FADE_CONTENT) |
| 1894 | .setInterpolator(Interpolators.ALPHA_OUT); |
| 1895 | setAboveShelf(true); |
| 1896 | mExpandAnimationRunning = true; |
| 1897 | mNotificationViewState.cancelAnimations(this); |
| 1898 | mNotificationLaunchHeight = AmbientState.getNotificationLaunchHeight(getContext()); |
| 1899 | } else { |
| 1900 | mExpandAnimationRunning = false; |
| 1901 | setAboveShelf(isAboveShelf()); |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 1902 | if (mGuts != null) { |
| 1903 | mGuts.setAlpha(1.0f); |
| 1904 | } |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 1905 | if (contentView != null) { |
| 1906 | contentView.setAlpha(1.0f); |
| 1907 | } |
| 1908 | setExtraWidthForClipping(0.0f); |
| 1909 | if (mNotificationParent != null) { |
| 1910 | mNotificationParent.setExtraWidthForClipping(0.0f); |
| 1911 | mNotificationParent.setMinimumHeightForClipping(0); |
| 1912 | } |
| 1913 | } |
| 1914 | if (mNotificationParent != null) { |
| 1915 | mNotificationParent.setChildIsExpanding(mExpandAnimationRunning); |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 1916 | } |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 1917 | updateChildrenVisibility(); |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 1918 | updateClipping(); |
| 1919 | mBackgroundNormal.setExpandAnimationRunning(expandAnimationRunning); |
| 1920 | } |
| 1921 | |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 1922 | private void setChildIsExpanding(boolean isExpanding) { |
| 1923 | mChildIsExpanding = isExpanding; |
| 1924 | } |
| 1925 | |
| 1926 | @Override |
| 1927 | public boolean hasExpandingChild() { |
| 1928 | return mChildIsExpanding; |
| 1929 | } |
| 1930 | |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 1931 | @Override |
| 1932 | protected boolean shouldClipToActualHeight() { |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 1933 | return super.shouldClipToActualHeight() && !mExpandAnimationRunning && !mChildIsExpanding; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 1934 | } |
| 1935 | |
| 1936 | @Override |
| 1937 | public boolean isExpandAnimationRunning() { |
| 1938 | return mExpandAnimationRunning; |
| 1939 | } |
| 1940 | |
Lucas Dupin | cecc7c2 | 2017-09-12 16:02:45 -0700 | [diff] [blame] | 1941 | /** |
| 1942 | * Tap sounds should not be played when we're unlocking. |
| 1943 | * Doing so would cause audio collision and the system would feel unpolished. |
| 1944 | */ |
| 1945 | @Override |
| 1946 | public boolean isSoundEffectsEnabled() { |
| 1947 | final boolean mute = mDark && mSecureStateProvider != null && |
| 1948 | !mSecureStateProvider.getAsBoolean(); |
| 1949 | return !mute && super.isSoundEffectsEnabled(); |
| 1950 | } |
| 1951 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1952 | public boolean isExpandable() { |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 1953 | if (mIsSummaryWithChildren && !shouldShowPublic()) { |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 1954 | return !mChildrenExpanded; |
| 1955 | } |
Anthony Chen | 6bf88a0 | 2017-04-10 14:41:44 -0700 | [diff] [blame] | 1956 | return mEnableNonGroupedNotificationExpand && mExpandable; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1957 | } |
| 1958 | |
| 1959 | public void setExpandable(boolean expandable) { |
| 1960 | mExpandable = expandable; |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 1961 | mPrivateLayout.updateExpandButtons(isExpandable()); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1962 | } |
| 1963 | |
Selim Cinek | 4ffd636 | 2015-12-29 15:12:23 +0100 | [diff] [blame] | 1964 | @Override |
| 1965 | public void setClipToActualHeight(boolean clipToActualHeight) { |
Selim Cinek | 084c16b | 2016-01-22 17:48:22 -0800 | [diff] [blame] | 1966 | super.setClipToActualHeight(clipToActualHeight || isUserLocked()); |
| 1967 | getShowingLayout().setClipToActualHeight(clipToActualHeight || isUserLocked()); |
Selim Cinek | 4ffd636 | 2015-12-29 15:12:23 +0100 | [diff] [blame] | 1968 | } |
| 1969 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1970 | /** |
| 1971 | * @return whether the user has changed the expansion state |
| 1972 | */ |
| 1973 | public boolean hasUserChangedExpansion() { |
| 1974 | return mHasUserChangedExpansion; |
| 1975 | } |
| 1976 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1977 | public boolean isUserExpanded() { |
| 1978 | return mUserExpanded; |
| 1979 | } |
| 1980 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1981 | /** |
| 1982 | * Set this notification to be expanded by the user |
| 1983 | * |
| 1984 | * @param userExpanded whether the user wants this notification to be expanded |
| 1985 | */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1986 | public void setUserExpanded(boolean userExpanded) { |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 1987 | setUserExpanded(userExpanded, false /* allowChildExpansion */); |
| 1988 | } |
| 1989 | |
| 1990 | /** |
| 1991 | * Set this notification to be expanded by the user |
| 1992 | * |
| 1993 | * @param userExpanded whether the user wants this notification to be expanded |
| 1994 | * @param allowChildExpansion whether a call to this method allows expanding children |
| 1995 | */ |
| 1996 | public void setUserExpanded(boolean userExpanded, boolean allowChildExpansion) { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 1997 | mFalsingManager.setNotificationExpanded(); |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 1998 | if (mIsSummaryWithChildren && !shouldShowPublic() && allowChildExpansion |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1999 | && !mChildrenContainer.showingAsLowPriority()) { |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame] | 2000 | final boolean wasExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification); |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 2001 | mGroupManager.setGroupExpanded(mStatusBarNotification, userExpanded); |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 2002 | onExpansionChanged(true /* userAction */, wasExpanded); |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 2003 | return; |
| 2004 | } |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 2005 | if (userExpanded && !mExpandable) return; |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 2006 | final boolean wasExpanded = isExpanded(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 2007 | mHasUserChangedExpansion = true; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 2008 | mUserExpanded = userExpanded; |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 2009 | onExpansionChanged(true /* userAction */, wasExpanded); |
Selim Cinek | 5d6ef8d | 2017-05-18 22:16:00 -0700 | [diff] [blame] | 2010 | if (!wasExpanded && isExpanded() |
| 2011 | && getActualHeight() != getIntrinsicHeight()) { |
| 2012 | notifyHeightChanged(true /* needsAnimation */); |
| 2013 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 2014 | } |
| 2015 | |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 2016 | public void resetUserExpansion() { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 2017 | boolean changed = mUserExpanded; |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 2018 | mHasUserChangedExpansion = false; |
| 2019 | mUserExpanded = false; |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 2020 | if (changed && mIsSummaryWithChildren) { |
| 2021 | mChildrenContainer.onExpansionChanged(); |
| 2022 | } |
| 2023 | updateShelfIconColor(); |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 2024 | } |
| 2025 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 2026 | public boolean isUserLocked() { |
Selim Cinek | 1b2a05e | 2016-04-28 14:20:39 -0700 | [diff] [blame] | 2027 | return mUserLocked && !mForceUnlocked; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 2028 | } |
| 2029 | |
| 2030 | public void setUserLocked(boolean userLocked) { |
| 2031 | mUserLocked = userLocked; |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 2032 | mPrivateLayout.setUserExpanding(userLocked); |
Selim Cinek | 817abe7 | 2017-05-24 11:08:55 -0700 | [diff] [blame] | 2033 | // This is intentionally not guarded with mIsSummaryWithChildren since we might have had |
| 2034 | // children but not anymore. |
| 2035 | if (mChildrenContainer != null) { |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 2036 | mChildrenContainer.setUserLocked(userLocked); |
Selim Cinek | 817abe7 | 2017-05-24 11:08:55 -0700 | [diff] [blame] | 2037 | if (mIsSummaryWithChildren && (userLocked || !isGroupExpanded())) { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 2038 | updateBackgroundForGroupState(); |
| 2039 | } |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 2040 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 2041 | } |
| 2042 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 2043 | /** |
| 2044 | * @return has the system set this notification to be expanded |
| 2045 | */ |
| 2046 | public boolean isSystemExpanded() { |
| 2047 | return mIsSystemExpanded; |
| 2048 | } |
| 2049 | |
| 2050 | /** |
| 2051 | * Set this notification to be expanded by the system. |
| 2052 | * |
| 2053 | * @param expand whether the system wants this notification to be expanded. |
| 2054 | */ |
| 2055 | public void setSystemExpanded(boolean expand) { |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 2056 | if (expand != mIsSystemExpanded) { |
| 2057 | final boolean wasExpanded = isExpanded(); |
| 2058 | mIsSystemExpanded = expand; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2059 | notifyHeightChanged(false /* needsAnimation */); |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 2060 | onExpansionChanged(false /* userAction */, wasExpanded); |
Selim Cinek | ed6913b | 2016-06-01 12:01:17 -0700 | [diff] [blame] | 2061 | if (mIsSummaryWithChildren) { |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 2062 | mChildrenContainer.updateGroupOverflow(); |
| 2063 | } |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 2064 | } |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 2065 | } |
| 2066 | |
| 2067 | /** |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 2068 | * @param onKeyguard whether to prevent notification expansion |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 2069 | */ |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 2070 | public void setOnKeyguard(boolean onKeyguard) { |
| 2071 | if (onKeyguard != mOnKeyguard) { |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 2072 | boolean wasAboveShelf = isAboveShelf(); |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 2073 | final boolean wasExpanded = isExpanded(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 2074 | mOnKeyguard = onKeyguard; |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 2075 | onExpansionChanged(false /* userAction */, wasExpanded); |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 2076 | if (wasExpanded != isExpanded()) { |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 2077 | if (mIsSummaryWithChildren) { |
| 2078 | mChildrenContainer.updateGroupOverflow(); |
| 2079 | } |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 2080 | notifyHeightChanged(false /* needsAnimation */); |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 2081 | } |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 2082 | if (isAboveShelf() != wasAboveShelf) { |
| 2083 | mAboveShelfChangedListener.onAboveShelfStateChanged(!wasAboveShelf); |
| 2084 | } |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 2085 | } |
Selim Cinek | fe24fb7 | 2018-02-13 14:34:55 -0800 | [diff] [blame] | 2086 | updateRippleAllowed(); |
| 2087 | } |
| 2088 | |
| 2089 | private void updateRippleAllowed() { |
| 2090 | boolean allowed = isOnKeyguard() |
| 2091 | || mEntry.notification.getNotification().contentIntent == null; |
| 2092 | setRippleAllowed(allowed); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 2093 | } |
| 2094 | |
| 2095 | /** |
Selim Cinek | 9e624e7 | 2016-07-20 13:46:49 -0700 | [diff] [blame] | 2096 | * @return Can the underlying notification be cleared? This can be different from whether the |
| 2097 | * notification can be dismissed in case notifications are sensitive on the lockscreen. |
| 2098 | * @see #canViewBeDismissed() |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 2099 | */ |
| 2100 | public boolean isClearable() { |
Selim Cinek | 506deb6 | 2016-07-20 15:43:59 -0700 | [diff] [blame] | 2101 | if (mStatusBarNotification == null || !mStatusBarNotification.isClearable()) { |
| 2102 | return false; |
| 2103 | } |
| 2104 | if (mIsSummaryWithChildren) { |
| 2105 | List<ExpandableNotificationRow> notificationChildren = |
| 2106 | mChildrenContainer.getNotificationChildren(); |
| 2107 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 2108 | ExpandableNotificationRow child = notificationChildren.get(i); |
| 2109 | if (!child.isClearable()) { |
| 2110 | return false; |
| 2111 | } |
| 2112 | } |
| 2113 | } |
| 2114 | return true; |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 2115 | } |
| 2116 | |
Jorim Jaggi | 9cbadd3 | 2014-05-01 20:18:31 +0200 | [diff] [blame] | 2117 | @Override |
| 2118 | public int getIntrinsicHeight() { |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 2119 | if (isUserLocked()) { |
| 2120 | return getActualHeight(); |
| 2121 | } |
Geoffrey Pitsch | 4dd5006 | 2016-12-06 16:41:22 -0500 | [diff] [blame] | 2122 | if (mGuts != null && mGuts.isExposed()) { |
Mady Mellor | e09fb70 | 2017-03-30 13:23:29 -0700 | [diff] [blame] | 2123 | return mGuts.getIntrinsicHeight(); |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 2124 | } else if ((isChildInGroup() && !isGroupExpanded())) { |
| 2125 | return mPrivateLayout.getMinHeight(); |
| 2126 | } else if (mSensitive && mHideSensitiveForIntrinsicHeight) { |
| 2127 | return getMinHeight(); |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 2128 | } else if (mIsSummaryWithChildren && (!mOnKeyguard || mShowAmbient)) { |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 2129 | return mChildrenContainer.getIntrinsicHeight(); |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 2130 | } else if (isHeadsUpAllowed() && (mIsHeadsUp || mHeadsupDisappearRunning)) { |
Selim Cinek | 73cf02a | 2016-06-17 13:08:00 -0700 | [diff] [blame] | 2131 | if (isPinned() || mHeadsupDisappearRunning) { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 2132 | return getPinnedHeadsUpHeight(true /* atLeastMinHeight */); |
| 2133 | } else if (isExpanded()) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 2134 | return Math.max(getMaxExpandHeight(), getHeadsUpHeight()); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 2135 | } else { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 2136 | return Math.max(getCollapsedHeight(), getHeadsUpHeight()); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 2137 | } |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 2138 | } else if (isExpanded()) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 2139 | return getMaxExpandHeight(); |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 2140 | } else { |
Selim Cinek | 567e845 | 2016-03-24 10:54:56 -0700 | [diff] [blame] | 2141 | return getCollapsedHeight(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 2142 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2143 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 2144 | |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 2145 | private boolean isHeadsUpAllowed() { |
| 2146 | return !mOnKeyguard && !mShowAmbient; |
| 2147 | } |
| 2148 | |
Mady Mellor | 43c2cd1 | 2016-12-12 21:05:13 -0800 | [diff] [blame] | 2149 | @Override |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 2150 | public boolean isGroupExpanded() { |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 2151 | return mGroupManager.isGroupExpanded(mStatusBarNotification); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2152 | } |
| 2153 | |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 2154 | private void onChildrenCountChanged() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 2155 | mIsSummaryWithChildren = StatusBar.ENABLE_CHILD_NOTIFICATIONS |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 2156 | && mChildrenContainer != null && mChildrenContainer.getNotificationChildCount() > 0; |
| 2157 | if (mIsSummaryWithChildren && mChildrenContainer.getHeaderView() == null) { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 2158 | mChildrenContainer.recreateNotificationHeader(mExpandClickListener |
| 2159 | ); |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 2160 | } |
Mady Mellor | 6baed9e | 2016-05-25 16:05:09 -0700 | [diff] [blame] | 2161 | getShowingLayout().updateBackgroundColor(false /* animate */); |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 2162 | mPrivateLayout.updateExpandButtons(isExpandable()); |
Selim Cinek | ea4bef7 | 2015-12-02 15:51:10 -0800 | [diff] [blame] | 2163 | updateChildrenHeaderAppearance(); |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 2164 | updateChildrenVisibility(); |
Selim Cinek | 2871bef | 2017-11-22 08:40:00 -0800 | [diff] [blame] | 2165 | applyChildrenRoundness(); |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 2166 | } |
Rohan Shah | 63411fc | 2018-03-28 19:05:52 -0700 | [diff] [blame] | 2167 | /** |
| 2168 | * Returns the number of channels covered by the notification row (including its children if |
| 2169 | * it's a summary notification). |
| 2170 | */ |
| 2171 | public int getNumUniqueChannels() { |
| 2172 | ArraySet<NotificationChannel> channels = new ArraySet<>(); |
| 2173 | |
| 2174 | channels.add(mEntry.channel); |
| 2175 | |
| 2176 | // If this is a summary, then add in the children notification channels for the |
| 2177 | // same user and pkg. |
| 2178 | if (mIsSummaryWithChildren) { |
| 2179 | final List<ExpandableNotificationRow> childrenRows = getNotificationChildren(); |
| 2180 | final int numChildren = childrenRows.size(); |
| 2181 | for (int i = 0; i < numChildren; i++) { |
| 2182 | final ExpandableNotificationRow childRow = childrenRows.get(i); |
| 2183 | final NotificationChannel childChannel = childRow.getEntry().channel; |
| 2184 | final StatusBarNotification childSbn = childRow.getStatusBarNotification(); |
| 2185 | if (childSbn.getUser().equals(mStatusBarNotification.getUser()) && |
| 2186 | childSbn.getPackageName().equals(mStatusBarNotification.getPackageName())) { |
| 2187 | channels.add(childChannel); |
| 2188 | } |
| 2189 | } |
| 2190 | } |
| 2191 | return channels.size(); |
| 2192 | } |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 2193 | |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 2194 | public void updateChildrenHeaderAppearance() { |
Selim Cinek | ed6913b | 2016-06-01 12:01:17 -0700 | [diff] [blame] | 2195 | if (mIsSummaryWithChildren) { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 2196 | mChildrenContainer.updateChildrenHeaderAppearance(); |
| 2197 | } |
| 2198 | } |
| 2199 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 2200 | /** |
| 2201 | * Check whether the view state is currently expanded. This is given by the system in {@link |
| 2202 | * #setSystemExpanded(boolean)} and can be overridden by user expansion or |
| 2203 | * collapsing in {@link #setUserExpanded(boolean)}. Note that the visual appearance of this |
| 2204 | * view can differ from this state, if layout params are modified from outside. |
| 2205 | * |
| 2206 | * @return whether the view state is currently expanded. |
| 2207 | */ |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 2208 | public boolean isExpanded() { |
Selim Cinek | e81b82b | 2016-03-04 11:22:28 -0800 | [diff] [blame] | 2209 | return isExpanded(false /* allowOnKeyguard */); |
| 2210 | } |
| 2211 | |
| 2212 | public boolean isExpanded(boolean allowOnKeyguard) { |
| 2213 | return (!mOnKeyguard || allowOnKeyguard) |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2214 | && (!hasUserChangedExpansion() && (isSystemExpanded() || isSystemChildExpanded()) |
| 2215 | || isUserExpanded()); |
| 2216 | } |
| 2217 | |
| 2218 | private boolean isSystemChildExpanded() { |
| 2219 | return mIsSystemChildExpanded; |
| 2220 | } |
| 2221 | |
| 2222 | public void setSystemChildExpanded(boolean expanded) { |
| 2223 | mIsSystemChildExpanded = expanded; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 2224 | } |
| 2225 | |
Mady Mellor | 035badd | 2017-04-04 18:45:30 -0700 | [diff] [blame] | 2226 | public void setLayoutListener(LayoutListener listener) { |
| 2227 | mLayoutListener = listener; |
| 2228 | } |
| 2229 | |
| 2230 | public void removeListener() { |
| 2231 | mLayoutListener = null; |
| 2232 | } |
| 2233 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 2234 | @Override |
| 2235 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 2236 | int intrinsicBefore = getIntrinsicHeight(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 2237 | super.onLayout(changed, left, top, right, bottom); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 2238 | if (intrinsicBefore != getIntrinsicHeight()) { |
| 2239 | notifyHeightChanged(true /* needsAnimation */); |
| 2240 | } |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame] | 2241 | if (mMenuRow.getMenuView() != null) { |
| 2242 | mMenuRow.onHeightUpdate(); |
Mady Mellor | a6edc87 | 2016-04-26 11:01:03 -0700 | [diff] [blame] | 2243 | } |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 2244 | updateContentShiftHeight(); |
Mady Mellor | 035badd | 2017-04-04 18:45:30 -0700 | [diff] [blame] | 2245 | if (mLayoutListener != null) { |
| 2246 | mLayoutListener.onLayout(); |
| 2247 | } |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 2248 | } |
| 2249 | |
| 2250 | /** |
| 2251 | * Updates the content shift height such that the header is completely hidden when coming from |
| 2252 | * the top. |
| 2253 | */ |
| 2254 | private void updateContentShiftHeight() { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 2255 | NotificationHeaderView notificationHeader = getVisibleNotificationHeader(); |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 2256 | if (notificationHeader != null) { |
| 2257 | CachingIconView icon = notificationHeader.getIcon(); |
| 2258 | mIconTransformContentShift = getRelativeTopPadding(icon) + icon.getHeight(); |
| 2259 | } else { |
| 2260 | mIconTransformContentShift = mIconTransformContentShiftNoIcon; |
| 2261 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 2262 | } |
| 2263 | |
Selim Cinek | fa0a2d3 | 2016-01-14 13:02:21 -0800 | [diff] [blame] | 2264 | @Override |
| 2265 | public void notifyHeightChanged(boolean needsAnimation) { |
| 2266 | super.notifyHeightChanged(needsAnimation); |
| 2267 | getShowingLayout().requestSelectLayout(needsAnimation || isUserLocked()); |
| 2268 | } |
| 2269 | |
Selim Cinek | 3c76d50 | 2016-02-19 15:16:33 -0800 | [diff] [blame] | 2270 | public void setSensitive(boolean sensitive, boolean hideSensitive) { |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 2271 | mSensitive = sensitive; |
Selim Cinek | 3c76d50 | 2016-02-19 15:16:33 -0800 | [diff] [blame] | 2272 | mSensitiveHiddenInGeneral = hideSensitive; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 2273 | } |
| 2274 | |
Mady Mellor | 43c2cd1 | 2016-12-12 21:05:13 -0800 | [diff] [blame] | 2275 | @Override |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 2276 | public void setHideSensitiveForIntrinsicHeight(boolean hideSensitive) { |
Selim Cinek | 60122be | 2015-04-15 18:16:50 -0700 | [diff] [blame] | 2277 | mHideSensitiveForIntrinsicHeight = hideSensitive; |
Selim Cinek | a52f6a1 | 2016-02-29 15:35:58 -0800 | [diff] [blame] | 2278 | if (mIsSummaryWithChildren) { |
| 2279 | List<ExpandableNotificationRow> notificationChildren = |
| 2280 | mChildrenContainer.getNotificationChildren(); |
| 2281 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 2282 | ExpandableNotificationRow child = notificationChildren.get(i); |
| 2283 | child.setHideSensitiveForIntrinsicHeight(hideSensitive); |
| 2284 | } |
| 2285 | } |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 2286 | } |
| 2287 | |
Mady Mellor | 43c2cd1 | 2016-12-12 21:05:13 -0800 | [diff] [blame] | 2288 | @Override |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 2289 | public void setHideSensitive(boolean hideSensitive, boolean animated, long delay, |
| 2290 | long duration) { |
Selim Cinek | 69594fb | 2018-05-18 12:06:10 -0700 | [diff] [blame] | 2291 | if (getVisibility() == GONE) { |
| 2292 | // If we are GONE, the hideSensitive parameter will not be calculated and always be |
| 2293 | // false, which is incorrect, let's wait until a real call comes in later. |
| 2294 | return; |
| 2295 | } |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 2296 | boolean oldShowingPublic = mShowingPublic; |
| 2297 | mShowingPublic = mSensitive && hideSensitive; |
| 2298 | if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) { |
| 2299 | return; |
| 2300 | } |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 2301 | |
| 2302 | // bail out if no public version |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 2303 | if (mPublicLayout.getChildCount() == 0) return; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 2304 | |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 2305 | if (!animated) { |
| 2306 | mPublicLayout.animate().cancel(); |
| 2307 | mPrivateLayout.animate().cancel(); |
Selim Cinek | a554c70 | 2016-06-17 18:02:12 -0700 | [diff] [blame] | 2308 | if (mChildrenContainer != null) { |
| 2309 | mChildrenContainer.animate().cancel(); |
| 2310 | mChildrenContainer.setAlpha(1f); |
| 2311 | } |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 2312 | mPublicLayout.setAlpha(1f); |
| 2313 | mPrivateLayout.setAlpha(1f); |
| 2314 | mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE); |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 2315 | updateChildrenVisibility(); |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 2316 | } else { |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 2317 | animateShowingPublic(delay, duration, mShowingPublic); |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 2318 | } |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 2319 | NotificationContentView showingLayout = getShowingLayout(); |
| 2320 | showingLayout.updateBackgroundColor(animated); |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 2321 | mPrivateLayout.updateExpandButtons(isExpandable()); |
Lucas Dupin | b6ed63b | 2017-05-30 16:17:42 -0700 | [diff] [blame] | 2322 | updateShelfIconColor(); |
Adrian Roos | e5726a2 | 2016-12-19 14:26:51 -0800 | [diff] [blame] | 2323 | showingLayout.setDark(isDark(), false /* animate */, 0 /* delay */); |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 2324 | mShowingPublicInitialized = true; |
| 2325 | } |
| 2326 | |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 2327 | private void animateShowingPublic(long delay, long duration, boolean showingPublic) { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 2328 | View[] privateViews = mIsSummaryWithChildren |
| 2329 | ? new View[] {mChildrenContainer} |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 2330 | : new View[] {mPrivateLayout}; |
| 2331 | View[] publicViews = new View[] {mPublicLayout}; |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 2332 | View[] hiddenChildren = showingPublic ? privateViews : publicViews; |
| 2333 | View[] shownChildren = showingPublic ? publicViews : privateViews; |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 2334 | for (final View hiddenView : hiddenChildren) { |
| 2335 | hiddenView.setVisibility(View.VISIBLE); |
| 2336 | hiddenView.animate().cancel(); |
| 2337 | hiddenView.animate() |
| 2338 | .alpha(0f) |
| 2339 | .setStartDelay(delay) |
| 2340 | .setDuration(duration) |
| 2341 | .withEndAction(new Runnable() { |
| 2342 | @Override |
| 2343 | public void run() { |
| 2344 | hiddenView.setVisibility(View.INVISIBLE); |
| 2345 | } |
| 2346 | }); |
| 2347 | } |
| 2348 | for (View showView : shownChildren) { |
| 2349 | showView.setVisibility(View.VISIBLE); |
| 2350 | showView.setAlpha(0f); |
| 2351 | showView.animate().cancel(); |
| 2352 | showView.animate() |
| 2353 | .alpha(1f) |
| 2354 | .setStartDelay(delay) |
| 2355 | .setDuration(duration); |
| 2356 | } |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 2357 | } |
| 2358 | |
Mady Mellor | 43c2cd1 | 2016-12-12 21:05:13 -0800 | [diff] [blame] | 2359 | @Override |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 2360 | public boolean mustStayOnScreen() { |
Selim Cinek | 9b9d6e1 | 2017-11-30 12:29:47 +0100 | [diff] [blame] | 2361 | return mIsHeadsUp && mMustStayOnScreen; |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 2362 | } |
| 2363 | |
Selim Cinek | 9e624e7 | 2016-07-20 13:46:49 -0700 | [diff] [blame] | 2364 | /** |
| 2365 | * @return Whether this view is allowed to be dismissed. Only valid for visible notifications as |
| 2366 | * otherwise some state might not be updated. To request about the general clearability |
| 2367 | * see {@link #isClearable()}. |
| 2368 | */ |
| 2369 | public boolean canViewBeDismissed() { |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 2370 | return isClearable() && (!shouldShowPublic() || !mSensitiveHiddenInGeneral); |
| 2371 | } |
| 2372 | |
| 2373 | private boolean shouldShowPublic() { |
| 2374 | return mSensitive && mHideSensitiveForIntrinsicHeight; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 2375 | } |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 2376 | |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 2377 | public void makeActionsVisibile() { |
| 2378 | setUserExpanded(true, true); |
| 2379 | if (isChildInGroup()) { |
| 2380 | mGroupManager.setGroupExpanded(mStatusBarNotification, true); |
| 2381 | } |
Selim Cinek | bb42b7d | 2016-08-10 13:02:38 -0700 | [diff] [blame] | 2382 | notifyHeightChanged(false /* needsAnimation */); |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 2383 | } |
| 2384 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2385 | public void setChildrenExpanded(boolean expanded, boolean animate) { |
| 2386 | mChildrenExpanded = expanded; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 2387 | if (mChildrenContainer != null) { |
| 2388 | mChildrenContainer.setChildrenExpanded(expanded); |
| 2389 | } |
Mady Mellor | 1a5d8ea | 2016-06-09 10:42:42 -0700 | [diff] [blame] | 2390 | updateBackgroundForGroupState(); |
Selim Cinek | ddf1b39 | 2016-05-27 16:33:10 -0700 | [diff] [blame] | 2391 | updateClickAndFocus(); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2392 | } |
| 2393 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2394 | public static void applyTint(View v, int color) { |
| 2395 | int alpha; |
| 2396 | if (color != 0) { |
| 2397 | alpha = COLORED_DIVIDER_ALPHA; |
| 2398 | } else { |
| 2399 | color = 0xff000000; |
| 2400 | alpha = DEFAULT_DIVIDER_ALPHA; |
| 2401 | } |
| 2402 | if (v.getBackground() instanceof ColorDrawable) { |
| 2403 | ColorDrawable background = (ColorDrawable) v.getBackground(); |
| 2404 | background.mutate(); |
| 2405 | background.setColor(color); |
| 2406 | background.setAlpha(alpha); |
| 2407 | } |
| 2408 | } |
| 2409 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 2410 | public int getMaxExpandHeight() { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 2411 | return mPrivateLayout.getExpandHeight(); |
| 2412 | } |
| 2413 | |
| 2414 | |
| 2415 | private int getHeadsUpHeight() { |
| 2416 | return mPrivateLayout.getHeadsUpHeight(); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 2417 | } |
Jorim Jaggi | 584a7aa | 2014-04-10 23:26:13 +0200 | [diff] [blame] | 2418 | |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 2419 | public boolean areGutsExposed() { |
Geoffrey Pitsch | 4dd5006 | 2016-12-06 16:41:22 -0500 | [diff] [blame] | 2420 | return (mGuts != null && mGuts.isExposed()); |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 2421 | } |
| 2422 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 2423 | @Override |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 2424 | public boolean isContentExpandable() { |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 2425 | if (mIsSummaryWithChildren && !shouldShowPublic()) { |
Selim Cinek | c0ac4af | 2017-03-03 15:13:48 -0800 | [diff] [blame] | 2426 | return true; |
| 2427 | } |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 2428 | NotificationContentView showingLayout = getShowingLayout(); |
| 2429 | return showingLayout.isContentExpandable(); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 2430 | } |
| 2431 | |
| 2432 | @Override |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 2433 | protected View getContentView() { |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 2434 | if (mIsSummaryWithChildren && !shouldShowPublic()) { |
Selim Cinek | a570318 | 2016-05-11 21:23:16 -0400 | [diff] [blame] | 2435 | return mChildrenContainer; |
| 2436 | } |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 2437 | return getShowingLayout(); |
| 2438 | } |
| 2439 | |
| 2440 | @Override |
Selim Cinek | aa3901a | 2016-08-05 11:04:37 -0700 | [diff] [blame] | 2441 | protected void onAppearAnimationFinished(boolean wasAppearing) { |
| 2442 | super.onAppearAnimationFinished(wasAppearing); |
| 2443 | if (wasAppearing) { |
| 2444 | // During the animation the visible view might have changed, so let's make sure all |
| 2445 | // alphas are reset |
| 2446 | if (mChildrenContainer != null) { |
| 2447 | mChildrenContainer.setAlpha(1.0f); |
| 2448 | mChildrenContainer.setLayerType(LAYER_TYPE_NONE, null); |
| 2449 | } |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 2450 | for (NotificationContentView l : mLayouts) { |
| 2451 | l.setAlpha(1.0f); |
| 2452 | l.setLayerType(LAYER_TYPE_NONE, null); |
| 2453 | } |
Selim Cinek | aa3901a | 2016-08-05 11:04:37 -0700 | [diff] [blame] | 2454 | } |
| 2455 | } |
| 2456 | |
| 2457 | @Override |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 2458 | public int getExtraBottomPadding() { |
| 2459 | if (mIsSummaryWithChildren && isGroupExpanded()) { |
| 2460 | return mIncreasedPaddingBetweenElements; |
| 2461 | } |
| 2462 | return 0; |
| 2463 | } |
| 2464 | |
| 2465 | @Override |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 2466 | public void setActualHeight(int height, boolean notifyListeners) { |
Selim Cinek | 4ca6c63 | 2017-02-23 18:03:37 -0800 | [diff] [blame] | 2467 | boolean changed = height != getActualHeight(); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2468 | super.setActualHeight(height, notifyListeners); |
Selim Cinek | 4ca6c63 | 2017-02-23 18:03:37 -0800 | [diff] [blame] | 2469 | if (changed && isRemoved()) { |
| 2470 | // TODO: remove this once we found the gfx bug for this. |
| 2471 | // This is a hack since a removed view sometimes would just stay blank. it occured |
| 2472 | // when sending yourself a message and then clicking on it. |
| 2473 | ViewGroup parent = (ViewGroup) getParent(); |
| 2474 | if (parent != null) { |
| 2475 | parent.invalidate(); |
| 2476 | } |
| 2477 | } |
Geoffrey Pitsch | 4dd5006 | 2016-12-06 16:41:22 -0500 | [diff] [blame] | 2478 | if (mGuts != null && mGuts.isExposed()) { |
Mady Mellor | b53bc27 | 2016-02-11 18:28:23 -0800 | [diff] [blame] | 2479 | mGuts.setActualHeight(height); |
| 2480 | return; |
| 2481 | } |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 2482 | int contentHeight = Math.max(getMinHeight(), height); |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 2483 | for (NotificationContentView l : mLayouts) { |
| 2484 | l.setContentHeight(contentHeight); |
| 2485 | } |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 2486 | if (mIsSummaryWithChildren) { |
| 2487 | mChildrenContainer.setActualHeight(height); |
| 2488 | } |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 2489 | if (mGuts != null) { |
| 2490 | mGuts.setActualHeight(height); |
| 2491 | } |
Mady Mellor | 5454097 | 2017-06-07 11:55:36 -0700 | [diff] [blame] | 2492 | if (mMenuRow.getMenuView() != null) { |
| 2493 | mMenuRow.onHeightUpdate(); |
| 2494 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 2495 | } |
| 2496 | |
| 2497 | @Override |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2498 | public int getMaxContentHeight() { |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 2499 | if (mIsSummaryWithChildren && !shouldShowPublic()) { |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 2500 | return mChildrenContainer.getMaxContentHeight(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 2501 | } |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 2502 | NotificationContentView showingLayout = getShowingLayout(); |
| 2503 | return showingLayout.getMaxHeight(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 2504 | } |
| 2505 | |
| 2506 | @Override |
Selim Cinek | eb3fc3d | 2017-09-15 13:37:14 -0700 | [diff] [blame] | 2507 | public int getMinHeight(boolean ignoreTemporaryStates) { |
| 2508 | if (!ignoreTemporaryStates && mGuts != null && mGuts.isExposed()) { |
Mady Mellor | e09fb70 | 2017-03-30 13:23:29 -0700 | [diff] [blame] | 2509 | return mGuts.getIntrinsicHeight(); |
Selim Cinek | eb3fc3d | 2017-09-15 13:37:14 -0700 | [diff] [blame] | 2510 | } else if (!ignoreTemporaryStates && isHeadsUpAllowed() && mIsHeadsUp |
| 2511 | && mHeadsUpManager.isTrackingHeadsUp()) { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 2512 | return getPinnedHeadsUpHeight(false /* atLeastMinHeight */); |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 2513 | } else if (mIsSummaryWithChildren && !isGroupExpanded() && !shouldShowPublic()) { |
Selim Cinek | b55386d | 2015-12-16 17:26:49 -0800 | [diff] [blame] | 2514 | return mChildrenContainer.getMinHeight(); |
Selim Cinek | eb3fc3d | 2017-09-15 13:37:14 -0700 | [diff] [blame] | 2515 | } else if (!ignoreTemporaryStates && isHeadsUpAllowed() && mIsHeadsUp) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 2516 | return getHeadsUpHeight(); |
Selim Cinek | b55386d | 2015-12-16 17:26:49 -0800 | [diff] [blame] | 2517 | } |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 2518 | NotificationContentView showingLayout = getShowingLayout(); |
| 2519 | return showingLayout.getMinHeight(); |
| 2520 | } |
| 2521 | |
| 2522 | @Override |
Selim Cinek | 567e845 | 2016-03-24 10:54:56 -0700 | [diff] [blame] | 2523 | public int getCollapsedHeight() { |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 2524 | if (mIsSummaryWithChildren && !shouldShowPublic()) { |
Selim Cinek | 567e845 | 2016-03-24 10:54:56 -0700 | [diff] [blame] | 2525 | return mChildrenContainer.getCollapsedHeight(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 2526 | } |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 2527 | return getMinHeight(); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 2528 | } |
| 2529 | |
| 2530 | @Override |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 2531 | public void setClipTopAmount(int clipTopAmount) { |
| 2532 | super.setClipTopAmount(clipTopAmount); |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 2533 | for (NotificationContentView l : mLayouts) { |
| 2534 | l.setClipTopAmount(clipTopAmount); |
| 2535 | } |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 2536 | if (mGuts != null) { |
| 2537 | mGuts.setClipTopAmount(clipTopAmount); |
| 2538 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 2539 | } |
| 2540 | |
Selim Cinek | a686b2c | 2016-10-26 13:58:27 -0700 | [diff] [blame] | 2541 | @Override |
| 2542 | public void setClipBottomAmount(int clipBottomAmount) { |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 2543 | if (mExpandAnimationRunning) { |
| 2544 | return; |
| 2545 | } |
Selim Cinek | 65d418e | 2016-11-29 15:42:34 -0800 | [diff] [blame] | 2546 | if (clipBottomAmount != mClipBottomAmount) { |
| 2547 | super.setClipBottomAmount(clipBottomAmount); |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 2548 | for (NotificationContentView l : mLayouts) { |
| 2549 | l.setClipBottomAmount(clipBottomAmount); |
| 2550 | } |
Selim Cinek | 65d418e | 2016-11-29 15:42:34 -0800 | [diff] [blame] | 2551 | if (mGuts != null) { |
| 2552 | mGuts.setClipBottomAmount(clipBottomAmount); |
| 2553 | } |
Selim Cinek | a686b2c | 2016-10-26 13:58:27 -0700 | [diff] [blame] | 2554 | } |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 2555 | if (mChildrenContainer != null && !mChildIsExpanding) { |
Selim Cinek | 65d418e | 2016-11-29 15:42:34 -0800 | [diff] [blame] | 2556 | // We have to update this even if it hasn't changed, since the children locations can |
| 2557 | // have changed |
Selim Cinek | b3dadcc | 2016-11-21 17:21:13 -0800 | [diff] [blame] | 2558 | mChildrenContainer.setClipBottomAmount(clipBottomAmount); |
| 2559 | } |
Selim Cinek | a686b2c | 2016-10-26 13:58:27 -0700 | [diff] [blame] | 2560 | } |
| 2561 | |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 2562 | public NotificationContentView getShowingLayout() { |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 2563 | return shouldShowPublic() ? mPublicLayout : mPrivateLayout; |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 2564 | } |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 2565 | |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 2566 | public void setLegacy(boolean legacy) { |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 2567 | for (NotificationContentView l : mLayouts) { |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 2568 | l.setLegacy(legacy); |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 2569 | } |
Jorim Jaggi | 59ec304 | 2015-06-05 15:18:43 -0700 | [diff] [blame] | 2570 | } |
| 2571 | |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 2572 | @Override |
| 2573 | protected void updateBackgroundTint() { |
| 2574 | super.updateBackgroundTint(); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 2575 | updateBackgroundForGroupState(); |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 2576 | if (mIsSummaryWithChildren) { |
| 2577 | List<ExpandableNotificationRow> notificationChildren = |
| 2578 | mChildrenContainer.getNotificationChildren(); |
| 2579 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 2580 | ExpandableNotificationRow child = notificationChildren.get(i); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 2581 | child.updateBackgroundForGroupState(); |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 2582 | } |
| 2583 | } |
| 2584 | } |
| 2585 | |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 2586 | /** |
| 2587 | * Called when a group has finished animating from collapsed or expanded state. |
| 2588 | */ |
| 2589 | public void onFinishedExpansionChange() { |
| 2590 | mGroupExpansionChanging = false; |
| 2591 | updateBackgroundForGroupState(); |
| 2592 | } |
| 2593 | |
| 2594 | /** |
| 2595 | * Updates the parent and children backgrounds in a group based on the expansion state. |
| 2596 | */ |
| 2597 | public void updateBackgroundForGroupState() { |
| 2598 | if (mIsSummaryWithChildren) { |
| 2599 | // Only when the group has finished expanding do we hide its background. |
Anthony Chen | 6bf88a0 | 2017-04-10 14:41:44 -0700 | [diff] [blame] | 2600 | mShowNoBackground = !mShowGroupBackgroundWhenExpanded && isGroupExpanded() |
| 2601 | && !isGroupExpansionChanging() && !isUserLocked(); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 2602 | mChildrenContainer.updateHeaderForExpansion(mShowNoBackground); |
| 2603 | List<ExpandableNotificationRow> children = mChildrenContainer.getNotificationChildren(); |
| 2604 | for (int i = 0; i < children.size(); i++) { |
| 2605 | children.get(i).updateBackgroundForGroupState(); |
| 2606 | } |
| 2607 | } else if (isChildInGroup()) { |
| 2608 | final int childColor = getShowingLayout().getBackgroundColorForExpansionState(); |
| 2609 | // Only show a background if the group is expanded OR if it is expanding / collapsing |
Anthony Chen | 6bf88a0 | 2017-04-10 14:41:44 -0700 | [diff] [blame] | 2610 | // and has a custom background color. |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 2611 | final boolean showBackground = isGroupExpanded() |
| 2612 | || ((mNotificationParent.isGroupExpansionChanging() |
Anthony Chen | 6bf88a0 | 2017-04-10 14:41:44 -0700 | [diff] [blame] | 2613 | || mNotificationParent.isUserLocked()) && childColor != 0); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 2614 | mShowNoBackground = !showBackground; |
| 2615 | } else { |
| 2616 | // Only children or parents ever need no background. |
| 2617 | mShowNoBackground = false; |
| 2618 | } |
| 2619 | updateOutline(); |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 2620 | updateBackground(); |
| 2621 | } |
| 2622 | |
Adrian Roos | 4a57967 | 2016-05-24 16:54:37 -0700 | [diff] [blame] | 2623 | public int getPositionOfChild(ExpandableNotificationRow childRow) { |
| 2624 | if (mIsSummaryWithChildren) { |
| 2625 | return mChildrenContainer.getPositionInLinearLayout(childRow); |
| 2626 | } |
| 2627 | return 0; |
| 2628 | } |
| 2629 | |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 2630 | public void setExpansionLogger(ExpansionLogger logger, String key) { |
| 2631 | mLogger = logger; |
| 2632 | mLoggingKey = key; |
| 2633 | } |
| 2634 | |
Chris Wren | 6abeeb9 | 2016-05-26 14:44:38 -0400 | [diff] [blame] | 2635 | public void onExpandedByGesture(boolean userExpanded) { |
| 2636 | int event = MetricsEvent.ACTION_NOTIFICATION_GESTURE_EXPANDER; |
| 2637 | if (mGroupManager.isSummaryOfGroup(getStatusBarNotification())) { |
| 2638 | event = MetricsEvent.ACTION_NOTIFICATION_GROUP_GESTURE_EXPANDER; |
| 2639 | } |
| 2640 | MetricsLogger.action(mContext, event, userExpanded); |
| 2641 | } |
| 2642 | |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 2643 | @Override |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 2644 | public float getIncreasedPaddingAmount() { |
| 2645 | if (mIsSummaryWithChildren) { |
| 2646 | if (isGroupExpanded()) { |
| 2647 | return 1.0f; |
| 2648 | } else if (isUserLocked()) { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 2649 | return mChildrenContainer.getIncreasedPaddingAmount(); |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 2650 | } |
Selim Cinek | 9910483 | 2017-01-25 14:47:33 -0800 | [diff] [blame] | 2651 | } else if (isColorized() && (!mIsLowPriority || isExpanded())) { |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 2652 | return -1.0f; |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 2653 | } |
| 2654 | return 0.0f; |
Selim Cinek | 61633a8 | 2016-01-25 15:54:10 -0800 | [diff] [blame] | 2655 | } |
| 2656 | |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 2657 | private boolean isColorized() { |
Selim Cinek | 9910483 | 2017-01-25 14:47:33 -0800 | [diff] [blame] | 2658 | return mIsColorized && mBgTint != NO_COLOR; |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 2659 | } |
| 2660 | |
Selim Cinek | 61633a8 | 2016-01-25 15:54:10 -0800 | [diff] [blame] | 2661 | @Override |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 2662 | protected boolean disallowSingleClick(MotionEvent event) { |
dongwan0605.kim | c4ddef4 | 2018-05-06 17:40:23 +0900 | [diff] [blame] | 2663 | if (areGutsExposed()) { |
| 2664 | return false; |
| 2665 | } |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 2666 | float x = event.getX(); |
| 2667 | float y = event.getY(); |
Selim Cinek | 34eda5e | 2016-02-18 17:10:43 -0800 | [diff] [blame] | 2668 | NotificationHeaderView header = getVisibleNotificationHeader(); |
Selim Cinek | 5d6ef8d | 2017-05-18 22:16:00 -0700 | [diff] [blame] | 2669 | if (header != null && header.isInTouchRect(x - getTranslation(), y)) { |
| 2670 | return true; |
| 2671 | } |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 2672 | if ((!mIsSummaryWithChildren || shouldShowPublic()) |
Selim Cinek | 5d6ef8d | 2017-05-18 22:16:00 -0700 | [diff] [blame] | 2673 | && getShowingLayout().disallowSingleClick(x, y)) { |
| 2674 | return true; |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 2675 | } |
| 2676 | return super.disallowSingleClick(event); |
| 2677 | } |
| 2678 | |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 2679 | private void onExpansionChanged(boolean userAction, boolean wasExpanded) { |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame] | 2680 | boolean nowExpanded = isExpanded(); |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 2681 | if (mIsSummaryWithChildren && (!mIsLowPriority || wasExpanded)) { |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame] | 2682 | nowExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification); |
| 2683 | } |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 2684 | if (nowExpanded != wasExpanded) { |
| 2685 | updateShelfIconColor(); |
| 2686 | if (mLogger != null) { |
| 2687 | mLogger.logNotificationExpansion(mLoggingKey, userAction, nowExpanded); |
| 2688 | } |
| 2689 | if (mIsSummaryWithChildren) { |
| 2690 | mChildrenContainer.onExpansionChanged(); |
| 2691 | } |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 2692 | } |
| 2693 | } |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 2694 | |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 2695 | @Override |
| 2696 | public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { |
| 2697 | super.onInitializeAccessibilityNodeInfoInternal(info); |
Geoffrey Pitsch | 409db27 | 2017-08-28 14:51:52 +0000 | [diff] [blame] | 2698 | info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK); |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 2699 | if (canViewBeDismissed()) { |
| 2700 | info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_DISMISS); |
| 2701 | } |
Selim Cinek | 0b9cf46 | 2017-12-07 16:31:03 -0800 | [diff] [blame] | 2702 | boolean expandable = shouldShowPublic(); |
Selim Cinek | c0ac4af | 2017-03-03 15:13:48 -0800 | [diff] [blame] | 2703 | boolean isExpanded = false; |
| 2704 | if (!expandable) { |
| 2705 | if (mIsSummaryWithChildren) { |
| 2706 | expandable = true; |
| 2707 | if (!mIsLowPriority || isExpanded()) { |
| 2708 | isExpanded = isGroupExpanded(); |
| 2709 | } |
| 2710 | } else { |
| 2711 | expandable = mPrivateLayout.isContentExpandable(); |
| 2712 | isExpanded = isExpanded(); |
| 2713 | } |
| 2714 | } |
| 2715 | if (expandable) { |
| 2716 | if (isExpanded) { |
| 2717 | info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_COLLAPSE); |
| 2718 | } else { |
| 2719 | info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND); |
| 2720 | } |
| 2721 | } |
Mady Mellor | b3a6aed | 2018-05-11 13:24:07 -0700 | [diff] [blame] | 2722 | NotificationMenuRowPlugin provider = getProvider(); |
| 2723 | if (provider != null) { |
| 2724 | MenuItem snoozeMenu = provider.getSnoozeMenuItem(getContext()); |
| 2725 | if (snoozeMenu != null) { |
| 2726 | AccessibilityAction action = new AccessibilityAction(R.id.action_snooze, |
| 2727 | getContext().getResources() |
| 2728 | .getString(R.string.notification_menu_snooze_action)); |
| 2729 | info.addAction(action); |
| 2730 | } |
| 2731 | } |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 2732 | } |
| 2733 | |
| 2734 | @Override |
| 2735 | public boolean performAccessibilityActionInternal(int action, Bundle arguments) { |
| 2736 | if (super.performAccessibilityActionInternal(action, arguments)) { |
| 2737 | return true; |
| 2738 | } |
| 2739 | switch (action) { |
| 2740 | case AccessibilityNodeInfo.ACTION_DISMISS: |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 2741 | performDismissWithBlockingHelper(true /* fromAccessibility */); |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 2742 | return true; |
Selim Cinek | c0ac4af | 2017-03-03 15:13:48 -0800 | [diff] [blame] | 2743 | case AccessibilityNodeInfo.ACTION_COLLAPSE: |
| 2744 | case AccessibilityNodeInfo.ACTION_EXPAND: |
| 2745 | mExpandClickListener.onClick(this); |
| 2746 | return true; |
Geoffrey Pitsch | 409db27 | 2017-08-28 14:51:52 +0000 | [diff] [blame] | 2747 | case AccessibilityNodeInfo.ACTION_LONG_CLICK: |
| 2748 | doLongClickCallback(); |
| 2749 | return true; |
Jason Monk | 4c9d66e | 2018-08-09 09:38:21 -0400 | [diff] [blame] | 2750 | default: |
| 2751 | if (action == R.id.action_snooze) { |
| 2752 | NotificationMenuRowPlugin provider = getProvider(); |
| 2753 | if (provider == null) { |
| 2754 | provider = createMenu(); |
| 2755 | } |
| 2756 | MenuItem snoozeMenu = provider.getSnoozeMenuItem(getContext()); |
| 2757 | if (snoozeMenu != null) { |
| 2758 | doLongClickCallback(getWidth() / 2, getHeight() / 2, snoozeMenu); |
| 2759 | } |
| 2760 | return true; |
Mady Mellor | b3a6aed | 2018-05-11 13:24:07 -0700 | [diff] [blame] | 2761 | } |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 2762 | } |
| 2763 | return false; |
| 2764 | } |
| 2765 | |
| 2766 | public boolean shouldRefocusOnDismiss() { |
| 2767 | return mRefocusOnDismiss || isAccessibilityFocused(); |
| 2768 | } |
| 2769 | |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 2770 | public interface OnExpandClickListener { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 2771 | void onExpandClicked(NotificationData.Entry clickedEntry, boolean nowExpanded); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 2772 | } |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 2773 | |
| 2774 | @Override |
| 2775 | public ExpandableViewState createNewViewState(StackScrollState stackScrollState) { |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 2776 | mNotificationViewState = new NotificationViewState(stackScrollState); |
| 2777 | return mNotificationViewState; |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 2778 | } |
| 2779 | |
Selim Cinek | f93bf3e | 2018-05-08 14:43:21 -0700 | [diff] [blame] | 2780 | public NotificationViewState getViewState() { |
| 2781 | return mNotificationViewState; |
| 2782 | } |
| 2783 | |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 2784 | @Override |
| 2785 | public boolean isAboveShelf() { |
Selim Cinek | c8007c5 | 2017-02-28 16:09:56 -0800 | [diff] [blame] | 2786 | return !isOnKeyguard() |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 2787 | && (mIsPinned || mHeadsupDisappearRunning || (mIsHeadsUp && mAboveShelf) |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 2788 | || mExpandAnimationRunning || mChildIsExpanding); |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 2789 | } |
| 2790 | |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 2791 | public void setShowAmbient(boolean showAmbient) { |
| 2792 | if (showAmbient != mShowAmbient) { |
| 2793 | mShowAmbient = showAmbient; |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 2794 | if (mChildrenContainer != null) { |
| 2795 | mChildrenContainer.notifyShowAmbientChanged(); |
| 2796 | } |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 2797 | notifyHeightChanged(false /* needsAnimation */); |
| 2798 | } |
| 2799 | } |
| 2800 | |
Selim Cinek | 0fe0739 | 2017-11-09 13:26:34 -0800 | [diff] [blame] | 2801 | @Override |
Tony Huang | c092c43 | 2018-05-18 17:38:54 +0800 | [diff] [blame] | 2802 | public boolean topAmountNeedsClipping() { |
| 2803 | if (isGroupExpanded()) { |
| 2804 | return true; |
| 2805 | } |
| 2806 | if (isGroupExpansionChanging()) { |
| 2807 | return true; |
| 2808 | } |
| 2809 | if (getShowingLayout().shouldClipToRounding(true /* topRounded */, |
| 2810 | false /* bottomRounded */)) { |
| 2811 | return true; |
| 2812 | } |
| 2813 | if (mGuts != null && mGuts.getAlpha() != 0.0f) { |
| 2814 | return true; |
| 2815 | } |
| 2816 | return false; |
| 2817 | } |
| 2818 | |
| 2819 | @Override |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 2820 | protected boolean childNeedsClipping(View child) { |
| 2821 | if (child instanceof NotificationContentView) { |
| 2822 | NotificationContentView contentView = (NotificationContentView) child; |
| 2823 | if (isClippingNeeded()) { |
| 2824 | return true; |
Selim Cinek | 86bfcee | 2018-01-17 11:00:47 -0800 | [diff] [blame] | 2825 | } else if (!hasNoRounding() |
| 2826 | && contentView.shouldClipToRounding(getCurrentTopRoundness() != 0.0f, |
| 2827 | getCurrentBottomRoundness() != 0.0f)) { |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 2828 | return true; |
| 2829 | } |
| 2830 | } else if (child == mChildrenContainer) { |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 2831 | if (!mChildIsExpanding && (isClippingNeeded() || !hasNoRounding())) { |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 2832 | return true; |
| 2833 | } |
| 2834 | } else if (child instanceof NotificationGuts) { |
Selim Cinek | b95fd18 | 2017-12-21 13:03:32 -0800 | [diff] [blame] | 2835 | return !hasNoRounding(); |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 2836 | } |
| 2837 | return super.childNeedsClipping(child); |
| 2838 | } |
| 2839 | |
| 2840 | @Override |
Selim Cinek | 2871bef | 2017-11-22 08:40:00 -0800 | [diff] [blame] | 2841 | protected void applyRoundness() { |
| 2842 | super.applyRoundness(); |
| 2843 | applyChildrenRoundness(); |
| 2844 | } |
| 2845 | |
| 2846 | private void applyChildrenRoundness() { |
| 2847 | if (mIsSummaryWithChildren) { |
| 2848 | mChildrenContainer.setCurrentBottomRoundness(getCurrentBottomRoundness()); |
| 2849 | } |
| 2850 | } |
| 2851 | |
| 2852 | @Override |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 2853 | public Path getCustomClipPath(View child) { |
| 2854 | if (child instanceof NotificationGuts) { |
Selim Cinek | 2871bef | 2017-11-22 08:40:00 -0800 | [diff] [blame] | 2855 | return getClipPath(true, /* ignoreTranslation */ |
| 2856 | false /* clipRoundedToBottom */); |
| 2857 | } |
| 2858 | if (child instanceof NotificationChildrenContainer) { |
| 2859 | return getClipPath(false, /* ignoreTranslation */ |
| 2860 | true /* clipRoundedToBottom */); |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 2861 | } |
| 2862 | return super.getCustomClipPath(child); |
| 2863 | } |
| 2864 | |
Selim Cinek | b95fd18 | 2017-12-21 13:03:32 -0800 | [diff] [blame] | 2865 | private boolean hasNoRounding() { |
| 2866 | return getCurrentBottomRoundness() == 0.0f && getCurrentTopRoundness() == 0.0f; |
Selim Cinek | 0fe0739 | 2017-11-09 13:26:34 -0800 | [diff] [blame] | 2867 | } |
| 2868 | |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 2869 | public boolean isShowingAmbient() { |
| 2870 | return mShowAmbient; |
| 2871 | } |
| 2872 | |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 2873 | public void setAboveShelf(boolean aboveShelf) { |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 2874 | boolean wasAboveShelf = isAboveShelf(); |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 2875 | mAboveShelf = aboveShelf; |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 2876 | if (isAboveShelf() != wasAboveShelf) { |
| 2877 | mAboveShelfChangedListener.onAboveShelfStateChanged(!wasAboveShelf); |
| 2878 | } |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 2879 | } |
| 2880 | |
Selim Cinek | d4776a5 | 2017-02-14 18:50:16 -0800 | [diff] [blame] | 2881 | public static class NotificationViewState extends ExpandableViewState { |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 2882 | |
| 2883 | private final StackScrollState mOverallState; |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 2884 | |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 2885 | |
| 2886 | private NotificationViewState(StackScrollState stackScrollState) { |
| 2887 | mOverallState = stackScrollState; |
| 2888 | } |
| 2889 | |
| 2890 | @Override |
| 2891 | public void applyToView(View view) { |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 2892 | if (view instanceof ExpandableNotificationRow) { |
| 2893 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 2894 | if (row.isExpandAnimationRunning()) { |
| 2895 | return; |
| 2896 | } |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 2897 | handleFixedTranslationZ(row); |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 2898 | super.applyToView(view); |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 2899 | row.applyChildrenState(mOverallState); |
| 2900 | } |
| 2901 | } |
Selim Cinek | 0cfbef4 | 2016-11-09 19:06:36 -0800 | [diff] [blame] | 2902 | |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 2903 | private void handleFixedTranslationZ(ExpandableNotificationRow row) { |
| 2904 | if (row.hasExpandingChild()) { |
| 2905 | zTranslation = row.getTranslationZ(); |
| 2906 | clipTopAmount = row.getClipTopAmount(); |
| 2907 | } |
| 2908 | } |
| 2909 | |
Selim Cinek | 0cfbef4 | 2016-11-09 19:06:36 -0800 | [diff] [blame] | 2910 | @Override |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 2911 | protected void onYTranslationAnimationFinished(View view) { |
| 2912 | super.onYTranslationAnimationFinished(view); |
Selim Cinek | d4776a5 | 2017-02-14 18:50:16 -0800 | [diff] [blame] | 2913 | if (view instanceof ExpandableNotificationRow) { |
| 2914 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
| 2915 | if (row.isHeadsUpAnimatingAway()) { |
| 2916 | row.setHeadsUpAnimatingAway(false); |
| 2917 | } |
Selim Cinek | 0cfbef4 | 2016-11-09 19:06:36 -0800 | [diff] [blame] | 2918 | } |
| 2919 | } |
| 2920 | |
| 2921 | @Override |
| 2922 | public void animateTo(View child, AnimationProperties properties) { |
Selim Cinek | 0cfbef4 | 2016-11-09 19:06:36 -0800 | [diff] [blame] | 2923 | if (child instanceof ExpandableNotificationRow) { |
| 2924 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 2925 | if (row.isExpandAnimationRunning()) { |
| 2926 | return; |
| 2927 | } |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 2928 | handleFixedTranslationZ(row); |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 2929 | super.animateTo(child, properties); |
Selim Cinek | 0cfbef4 | 2016-11-09 19:06:36 -0800 | [diff] [blame] | 2930 | row.startChildAnimation(mOverallState, properties); |
| 2931 | } |
| 2932 | } |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 2933 | } |
Selim Cinek | 817abe7 | 2017-05-24 11:08:55 -0700 | [diff] [blame] | 2934 | |
| 2935 | @VisibleForTesting |
| 2936 | protected void setChildrenContainer(NotificationChildrenContainer childrenContainer) { |
| 2937 | mChildrenContainer = childrenContainer; |
| 2938 | } |
Geoffrey Pitsch | 409db27 | 2017-08-28 14:51:52 +0000 | [diff] [blame] | 2939 | |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 2940 | @VisibleForTesting |
| 2941 | protected void setPrivateLayout(NotificationContentView privateLayout) { |
| 2942 | mPrivateLayout = privateLayout; |
| 2943 | } |
| 2944 | |
| 2945 | @VisibleForTesting |
| 2946 | protected void setPublicLayout(NotificationContentView publicLayout) { |
| 2947 | mPublicLayout = publicLayout; |
| 2948 | } |
| 2949 | |
Geoffrey Pitsch | 409db27 | 2017-08-28 14:51:52 +0000 | [diff] [blame] | 2950 | /** |
| 2951 | * Equivalent to View.OnLongClickListener with coordinates |
| 2952 | */ |
| 2953 | public interface LongPressListener { |
| 2954 | /** |
| 2955 | * Equivalent to {@link View.OnLongClickListener#onLongClick(View)} with coordinates |
| 2956 | * @return whether the longpress was handled |
| 2957 | */ |
| 2958 | boolean onLongPress(View v, int x, int y, MenuItem item); |
| 2959 | } |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 2960 | |
| 2961 | /** |
| 2962 | * Equivalent to View.OnClickListener with coordinates |
| 2963 | */ |
| 2964 | public interface OnAppOpsClickListener { |
| 2965 | /** |
| 2966 | * Equivalent to {@link View.OnClickListener#onClick(View)} with coordinates |
| 2967 | * @return whether the click was handled |
| 2968 | */ |
| 2969 | boolean onClick(View v, int x, int y, MenuItem item); |
| 2970 | } |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 2971 | |
| 2972 | /** |
| 2973 | * Background task for executing IPCs to check if the notification is a system notification. The |
| 2974 | * output is used for both the blocking helper and the notification info. |
| 2975 | */ |
| 2976 | private class SystemNotificationAsyncTask extends AsyncTask<Void, Void, Boolean> { |
| 2977 | |
| 2978 | @Override |
| 2979 | protected Boolean doInBackground(Void... voids) { |
| 2980 | return isSystemNotification(mContext, mStatusBarNotification); |
| 2981 | } |
| 2982 | |
| 2983 | @Override |
| 2984 | protected void onPostExecute(Boolean result) { |
Julia Reynolds | aa96cf3 | 2018-04-17 09:09:04 -0400 | [diff] [blame] | 2985 | if (mEntry != null) { |
| 2986 | mEntry.mIsSystemNotification = result; |
| 2987 | } |
Rohan Shah | 4ed1b2a | 2018-03-30 13:26:01 -0700 | [diff] [blame] | 2988 | } |
| 2989 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 2990 | } |