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