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