Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.statusbar; |
| 18 | |
Selim Cinek | c478f90 | 2017-02-22 20:55:44 -0800 | [diff] [blame] | 19 | import static com.android.systemui.statusbar.notification.NotificationInflater.InflationExceptionHandler; |
| 20 | |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 21 | import android.animation.Animator; |
| 22 | import android.animation.AnimatorListenerAdapter; |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 23 | import android.animation.ObjectAnimator; |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 24 | import android.animation.ValueAnimator.AnimatorUpdateListener; |
Selim Cinek | ddf1b39 | 2016-05-27 16:33:10 -0700 | [diff] [blame] | 25 | import android.annotation.Nullable; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 26 | import android.content.Context; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 27 | import android.graphics.drawable.AnimatedVectorDrawable; |
| 28 | import android.graphics.drawable.AnimationDrawable; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 29 | import android.graphics.drawable.ColorDrawable; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 30 | import android.graphics.drawable.Drawable; |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 31 | import android.os.Build; |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 32 | import android.os.Bundle; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 33 | import android.service.notification.StatusBarNotification; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 34 | import android.util.AttributeSet; |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 35 | import android.util.FloatProperty; |
| 36 | import android.util.Property; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 37 | import android.view.LayoutInflater; |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 38 | import android.view.MotionEvent; |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 39 | import android.view.NotificationHeaderView; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 40 | import android.view.View; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 41 | import android.view.ViewGroup; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 42 | import android.view.ViewStub; |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 43 | import android.view.accessibility.AccessibilityEvent; |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 44 | import android.view.accessibility.AccessibilityNodeInfo; |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 45 | import android.widget.Chronometer; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 46 | import android.widget.FrameLayout; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 47 | import android.widget.ImageView; |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 48 | import android.widget.RemoteViews; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 49 | |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame] | 50 | import com.android.internal.logging.MetricsLogger; |
Tamas Berghammer | 383db5eb | 2016-06-22 15:21:38 +0100 | [diff] [blame] | 51 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Selim Cinek | 4bb5934 | 2016-04-08 19:29:35 -0700 | [diff] [blame] | 52 | import com.android.internal.util.NotificationColorUtil; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 53 | import com.android.internal.widget.CachingIconView; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 54 | import com.android.systemui.Dependency; |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 55 | import com.android.systemui.Interpolators; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 56 | import com.android.systemui.R; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 57 | import com.android.systemui.classifier.FalsingManager; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 58 | import com.android.systemui.plugins.PluginListener; |
| 59 | import com.android.systemui.plugins.PluginManager; |
| 60 | import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; |
| 61 | import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem; |
| 62 | import com.android.systemui.statusbar.NotificationGuts.GutsContent; |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 63 | import com.android.systemui.statusbar.notification.HybridNotificationView; |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 64 | import com.android.systemui.statusbar.notification.InflationException; |
| 65 | import com.android.systemui.statusbar.notification.NotificationInflater; |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 66 | import com.android.systemui.statusbar.notification.NotificationUtils; |
Selim Cinek | a7d4f82 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 67 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 68 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 69 | import com.android.systemui.statusbar.phone.StatusBar; |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 70 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
Selim Cinek | 0cfbef4 | 2016-11-09 19:06:36 -0800 | [diff] [blame] | 71 | import com.android.systemui.statusbar.stack.AnimationProperties; |
| 72 | import com.android.systemui.statusbar.stack.ExpandableViewState; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 73 | import com.android.systemui.statusbar.stack.NotificationChildrenContainer; |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 74 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 75 | import com.android.systemui.statusbar.stack.StackScrollState; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 76 | |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 77 | import java.util.ArrayList; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 78 | import java.util.List; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 79 | |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 80 | public class ExpandableNotificationRow extends ActivatableNotificationView |
| 81 | implements PluginListener<NotificationMenuRowPlugin> { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 82 | |
| 83 | private static final int DEFAULT_DIVIDER_ALPHA = 0x29; |
| 84 | private static final int COLORED_DIVIDER_ALPHA = 0x7B; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 85 | private static final int MENU_VIEW_INDEX = 0; |
| 86 | |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 87 | private final NotificationInflater mNotificationInflater; |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 88 | private int mIconTransformContentShift; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 89 | private int mIconTransformContentShiftNoIcon; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 90 | private int mNotificationMinHeightLegacy; |
| 91 | private int mMaxHeadsUpHeightLegacy; |
| 92 | private int mMaxHeadsUpHeight; |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 93 | private int mMaxHeadsUpHeightIncreased; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 94 | private int mNotificationMinHeight; |
Selim Cinek | 7d1009b | 2017-01-25 15:28:28 -0800 | [diff] [blame] | 95 | private int mNotificationMinHeightLarge; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 96 | private int mNotificationMaxHeight; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 97 | private int mNotificationAmbientHeight; |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 98 | private int mIncreasedPaddingBetweenElements; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 99 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 100 | /** Does this row contain layouts that can adapt to row expansion */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 101 | private boolean mExpandable; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 102 | /** Has the user actively changed the expansion state of this row */ |
| 103 | private boolean mHasUserChangedExpansion; |
| 104 | /** If {@link #mHasUserChangedExpansion}, has the user expanded this row */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 105 | private boolean mUserExpanded; |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 106 | |
| 107 | /** |
| 108 | * Has this notification been expanded while it was pinned |
| 109 | */ |
| 110 | private boolean mExpandedWhenPinned; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 111 | /** Is the user touching this row */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 112 | private boolean mUserLocked; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 113 | /** Are we showing the "public" version */ |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 114 | private boolean mShowingPublic; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 115 | private boolean mSensitive; |
Selim Cinek | 3c76d50 | 2016-02-19 15:16:33 -0800 | [diff] [blame] | 116 | private boolean mSensitiveHiddenInGeneral; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 117 | private boolean mShowingPublicInitialized; |
Selim Cinek | 60122be | 2015-04-15 18:16:50 -0700 | [diff] [blame] | 118 | private boolean mHideSensitiveForIntrinsicHeight; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 119 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 120 | /** |
| 121 | * Is this notification expanded by the system. The expansion state can be overridden by the |
| 122 | * user expansion. |
| 123 | */ |
| 124 | private boolean mIsSystemExpanded; |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 125 | |
| 126 | /** |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 127 | * Whether the notification is on the keyguard and the expansion is disabled. |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 128 | */ |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 129 | private boolean mOnKeyguard; |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 130 | |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 131 | private Animator mTranslateAnim; |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 132 | private ArrayList<View> mTranslateableViews; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 133 | private NotificationContentView mPublicLayout; |
| 134 | private NotificationContentView mPrivateLayout; |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 135 | private NotificationContentView[] mLayouts; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 136 | private int mMaxExpandHeight; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 137 | private int mHeadsUpHeight; |
Selim Cinek | 4bb5934 | 2016-04-08 19:29:35 -0700 | [diff] [blame] | 138 | private int mNotificationColor; |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 139 | private ExpansionLogger mLogger; |
| 140 | private String mLoggingKey; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 141 | private NotificationGuts mGuts; |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 142 | private NotificationData.Entry mEntry; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 143 | private StatusBarNotification mStatusBarNotification; |
Mady Mellor | 3fd273e | 2016-03-15 21:08:14 -0700 | [diff] [blame] | 144 | private String mAppName; |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 145 | private boolean mIsHeadsUp; |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 146 | private boolean mLastChronometerRunning = true; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 147 | private ViewStub mChildrenContainerStub; |
| 148 | private NotificationGroupManager mGroupManager; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 149 | private boolean mChildrenExpanded; |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 150 | private boolean mIsSummaryWithChildren; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 151 | private NotificationChildrenContainer mChildrenContainer; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 152 | private NotificationMenuRowPlugin mMenuRow; |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 153 | private ViewStub mGutsStub; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 154 | private boolean mIsSystemChildExpanded; |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 155 | private boolean mIsPinned; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 156 | private FalsingManager mFalsingManager; |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 157 | private HeadsUpManager mHeadsUpManager; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 158 | |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 159 | private boolean mJustClicked; |
Selim Cinek | 5a175d9 | 2015-11-23 18:01:33 -0800 | [diff] [blame] | 160 | private boolean mIconAnimationRunning; |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 161 | private boolean mShowNoBackground; |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 162 | private ExpandableNotificationRow mNotificationParent; |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 163 | private OnExpandClickListener mOnExpandClickListener; |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 164 | private boolean mGroupExpansionChanging; |
| 165 | |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 166 | private OnClickListener mExpandClickListener = new OnClickListener() { |
| 167 | @Override |
| 168 | public void onClick(View v) { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 169 | if (!mShowingPublic && (!mIsLowPriority || isExpanded()) |
| 170 | && mGroupManager.isSummaryOfGroup(mStatusBarNotification)) { |
Mady Mellor | 1a5d8ea | 2016-06-09 10:42:42 -0700 | [diff] [blame] | 171 | mGroupExpansionChanging = true; |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame] | 172 | final boolean wasExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification); |
| 173 | boolean nowExpanded = mGroupManager.toggleGroupExpansion(mStatusBarNotification); |
| 174 | mOnExpandClickListener.onExpandClicked(mEntry, nowExpanded); |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame] | 175 | MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTIFICATION_GROUP_EXPANDER, |
| 176 | nowExpanded); |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 177 | onExpansionChanged(true /* userAction */, wasExpanded); |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 178 | } else { |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 179 | if (v.isAccessibilityFocused()) { |
| 180 | mPrivateLayout.setFocusOnVisibilityChange(); |
| 181 | } |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 182 | boolean nowExpanded; |
| 183 | if (isPinned()) { |
| 184 | nowExpanded = !mExpandedWhenPinned; |
| 185 | mExpandedWhenPinned = nowExpanded; |
| 186 | } else { |
| 187 | nowExpanded = !isExpanded(); |
| 188 | setUserExpanded(nowExpanded); |
| 189 | } |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 190 | notifyHeightChanged(true); |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 191 | mOnExpandClickListener.onExpandClicked(mEntry, nowExpanded); |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame] | 192 | MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTIFICATION_EXPANDER, |
| 193 | nowExpanded); |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 194 | } |
| 195 | } |
| 196 | }; |
Selim Cinek | 1b2a05e | 2016-04-28 14:20:39 -0700 | [diff] [blame] | 197 | private boolean mForceUnlocked; |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 198 | private boolean mDismissed; |
| 199 | private boolean mKeepInParent; |
| 200 | private boolean mRemoved; |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 201 | private static final Property<ExpandableNotificationRow, Float> TRANSLATE_CONTENT = |
| 202 | new FloatProperty<ExpandableNotificationRow>("translate") { |
| 203 | @Override |
| 204 | public void setValue(ExpandableNotificationRow object, float value) { |
| 205 | object.setTranslation(value); |
| 206 | } |
| 207 | |
| 208 | @Override |
| 209 | public Float get(ExpandableNotificationRow object) { |
| 210 | return object.getTranslation(); |
| 211 | } |
| 212 | }; |
Selim Cinek | ddf1b39 | 2016-05-27 16:33:10 -0700 | [diff] [blame] | 213 | private OnClickListener mOnClickListener; |
Selim Cinek | 73cf02a | 2016-06-17 13:08:00 -0700 | [diff] [blame] | 214 | private boolean mHeadsupDisappearRunning; |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 215 | private View mChildAfterViewWhenDismissed; |
| 216 | private View mGroupParentWhenDismissed; |
| 217 | private boolean mRefocusOnDismiss; |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 218 | private float mContentTransformationAmount; |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 219 | private boolean mIconsVisible = true; |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 220 | private boolean mAboveShelf; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 221 | private boolean mShowAmbient; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 222 | private boolean mIsLastChild; |
Selim Cinek | e907911 | 2016-12-14 14:41:01 -0800 | [diff] [blame] | 223 | private Runnable mOnDismissRunnable; |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 224 | private boolean mIsLowPriority; |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 225 | private boolean mIsColorized; |
Selim Cinek | 7d1009b | 2017-01-25 15:28:28 -0800 | [diff] [blame] | 226 | private boolean mUseIncreasedCollapsedHeight; |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 227 | private boolean mUseIncreasedHeadsUpHeight; |
Selim Cinek | ef8c225 | 2017-02-10 14:52:18 -0800 | [diff] [blame] | 228 | private float mTranslationWhenRemoved; |
| 229 | private boolean mWasChildInGroupWhenRemoved; |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 230 | |
Mady Mellor | 43c2cd1 | 2016-12-12 21:05:13 -0800 | [diff] [blame] | 231 | @Override |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 232 | public boolean isGroupExpansionChanging() { |
| 233 | if (isChildInGroup()) { |
| 234 | return mNotificationParent.isGroupExpansionChanging(); |
| 235 | } |
| 236 | return mGroupExpansionChanging; |
| 237 | } |
| 238 | |
| 239 | public void setGroupExpansionChanging(boolean changing) { |
| 240 | mGroupExpansionChanging = changing; |
| 241 | } |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 242 | |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 243 | @Override |
| 244 | public void setActualHeightAnimating(boolean animating) { |
| 245 | if (mPrivateLayout != null) { |
| 246 | mPrivateLayout.setContentHeightAnimating(animating); |
| 247 | } |
| 248 | } |
| 249 | |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 250 | public NotificationContentView getPrivateLayout() { |
| 251 | return mPrivateLayout; |
| 252 | } |
| 253 | |
| 254 | public NotificationContentView getPublicLayout() { |
| 255 | return mPublicLayout; |
| 256 | } |
| 257 | |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 258 | public void setIconAnimationRunning(boolean running) { |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 259 | for (NotificationContentView l : mLayouts) { |
| 260 | setIconAnimationRunning(running, l); |
| 261 | } |
Selim Cinek | 5a175d9 | 2015-11-23 18:01:33 -0800 | [diff] [blame] | 262 | if (mIsSummaryWithChildren) { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 263 | setIconAnimationRunningForChild(running, mChildrenContainer.getHeaderView()); |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 264 | setIconAnimationRunningForChild(running, mChildrenContainer.getLowPriorityHeaderView()); |
Selim Cinek | 5a175d9 | 2015-11-23 18:01:33 -0800 | [diff] [blame] | 265 | List<ExpandableNotificationRow> notificationChildren = |
| 266 | mChildrenContainer.getNotificationChildren(); |
| 267 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 268 | ExpandableNotificationRow child = notificationChildren.get(i); |
| 269 | child.setIconAnimationRunning(running); |
| 270 | } |
| 271 | } |
| 272 | mIconAnimationRunning = running; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | private void setIconAnimationRunning(boolean running, NotificationContentView layout) { |
| 276 | if (layout != null) { |
| 277 | View contractedChild = layout.getContractedChild(); |
| 278 | View expandedChild = layout.getExpandedChild(); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 279 | View headsUpChild = layout.getHeadsUpChild(); |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 280 | setIconAnimationRunningForChild(running, contractedChild); |
| 281 | setIconAnimationRunningForChild(running, expandedChild); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 282 | setIconAnimationRunningForChild(running, headsUpChild); |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 283 | } |
| 284 | } |
| 285 | |
| 286 | private void setIconAnimationRunningForChild(boolean running, View child) { |
| 287 | if (child != null) { |
| 288 | ImageView icon = (ImageView) child.findViewById(com.android.internal.R.id.icon); |
| 289 | setIconRunning(icon, running); |
| 290 | ImageView rightIcon = (ImageView) child.findViewById( |
| 291 | com.android.internal.R.id.right_icon); |
| 292 | setIconRunning(rightIcon, running); |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | private void setIconRunning(ImageView imageView, boolean running) { |
| 297 | if (imageView != null) { |
| 298 | Drawable drawable = imageView.getDrawable(); |
| 299 | if (drawable instanceof AnimationDrawable) { |
| 300 | AnimationDrawable animationDrawable = (AnimationDrawable) drawable; |
| 301 | if (running) { |
| 302 | animationDrawable.start(); |
| 303 | } else { |
| 304 | animationDrawable.stop(); |
| 305 | } |
| 306 | } else if (drawable instanceof AnimatedVectorDrawable) { |
| 307 | AnimatedVectorDrawable animationDrawable = (AnimatedVectorDrawable) drawable; |
| 308 | if (running) { |
| 309 | animationDrawable.start(); |
| 310 | } else { |
| 311 | animationDrawable.stop(); |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 317 | public void updateNotification(NotificationData.Entry entry) throws InflationException { |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 318 | mEntry = entry; |
| 319 | mStatusBarNotification = entry.notification; |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 320 | mNotificationInflater.inflateNotificationViews(); |
Selim Cinek | c478f90 | 2017-02-22 20:55:44 -0800 | [diff] [blame] | 321 | onNotificationUpdated(); |
| 322 | } |
| 323 | |
| 324 | private void onNotificationUpdated() { |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 325 | for (NotificationContentView l : mLayouts) { |
Selim Cinek | c478f90 | 2017-02-22 20:55:44 -0800 | [diff] [blame] | 326 | l.onNotificationUpdated(mEntry); |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 327 | } |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 328 | mIsColorized = mStatusBarNotification.getNotification().isColorized(); |
Selim Cinek | 757d879 | 2016-01-28 16:21:08 -0800 | [diff] [blame] | 329 | mShowingPublicInitialized = false; |
Selim Cinek | 4bb5934 | 2016-04-08 19:29:35 -0700 | [diff] [blame] | 330 | updateNotificationColor(); |
Selim Cinek | 8fc93c9 | 2015-11-23 17:48:07 -0800 | [diff] [blame] | 331 | if (mIsSummaryWithChildren) { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 332 | mChildrenContainer.recreateNotificationHeader(mExpandClickListener); |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 333 | mChildrenContainer.onNotificationUpdated(); |
Selim Cinek | 8fc93c9 | 2015-11-23 17:48:07 -0800 | [diff] [blame] | 334 | } |
Selim Cinek | 5a175d9 | 2015-11-23 18:01:33 -0800 | [diff] [blame] | 335 | if (mIconAnimationRunning) { |
| 336 | setIconAnimationRunning(true); |
| 337 | } |
Selim Cinek | ea4bef7 | 2015-12-02 15:51:10 -0800 | [diff] [blame] | 338 | if (mNotificationParent != null) { |
| 339 | mNotificationParent.updateChildrenHeaderAppearance(); |
| 340 | } |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 341 | onChildrenCountChanged(); |
Selim Cinek | 624c02db | 2015-12-14 21:00:02 -0800 | [diff] [blame] | 342 | // The public layouts expand button is always visible |
| 343 | mPublicLayout.updateExpandButtons(true); |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 344 | updateLimits(); |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 345 | updateIconVisibilities(); |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 346 | updateShelfIconColor(); |
| 347 | } |
| 348 | |
| 349 | private void updateShelfIconColor() { |
| 350 | StatusBarIconView expandedIcon = mEntry.expandedIcon; |
| 351 | boolean isPreL = Boolean.TRUE.equals(expandedIcon.getTag(R.id.icon_is_pre_L)); |
| 352 | boolean colorize = !isPreL || NotificationUtils.isGrayscale(expandedIcon, |
| 353 | NotificationColorUtil.getInstance(mContext)); |
Selim Cinek | 875ba9b | 2017-02-13 16:20:17 -0800 | [diff] [blame] | 354 | int color = StatusBarIconView.NO_COLOR; |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 355 | if (colorize) { |
Selim Cinek | 875ba9b | 2017-02-13 16:20:17 -0800 | [diff] [blame] | 356 | color = mEntry.getContrastedColor(mContext, mIsLowPriority && !isExpanded()); |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 357 | } |
Selim Cinek | 875ba9b | 2017-02-13 16:20:17 -0800 | [diff] [blame] | 358 | expandedIcon.setStaticDrawableColor(color); |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | private void updateLimits() { |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 362 | for (NotificationContentView l : mLayouts) { |
| 363 | updateLimitsForView(l); |
| 364 | } |
Selim Cinek | a174487 | 2016-03-11 15:36:06 -0800 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | private void updateLimitsForView(NotificationContentView layout) { |
| 368 | boolean customView = layout.getContractedChild().getId() |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 369 | != com.android.internal.R.id.status_bar_latest_event_content; |
| 370 | boolean beforeN = mEntry.targetSdk < Build.VERSION_CODES.N; |
Selim Cinek | 7d1009b | 2017-01-25 15:28:28 -0800 | [diff] [blame] | 371 | int minHeight; |
| 372 | if (customView && beforeN && !mIsSummaryWithChildren) { |
| 373 | minHeight = mNotificationMinHeightLegacy; |
| 374 | } else if (mUseIncreasedCollapsedHeight && layout == mPrivateLayout) { |
| 375 | minHeight = mNotificationMinHeightLarge; |
| 376 | } else { |
| 377 | minHeight = mNotificationMinHeight; |
| 378 | } |
Selim Cinek | a174487 | 2016-03-11 15:36:06 -0800 | [diff] [blame] | 379 | boolean headsUpCustom = layout.getHeadsUpChild() != null && |
| 380 | layout.getHeadsUpChild().getId() |
| 381 | != com.android.internal.R.id.status_bar_latest_event_content; |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 382 | int headsUpheight; |
| 383 | if (headsUpCustom && beforeN) { |
| 384 | headsUpheight = mMaxHeadsUpHeightLegacy; |
| 385 | } else if (mUseIncreasedHeadsUpHeight && layout == mPrivateLayout) { |
| 386 | headsUpheight = mMaxHeadsUpHeightIncreased; |
| 387 | } else { |
| 388 | headsUpheight = mMaxHeadsUpHeight; |
| 389 | } |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 390 | layout.setHeights(minHeight, headsUpheight, mNotificationMaxHeight, |
| 391 | mNotificationAmbientHeight); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | public StatusBarNotification getStatusBarNotification() { |
| 395 | return mStatusBarNotification; |
| 396 | } |
| 397 | |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 398 | public NotificationData.Entry getEntry() { |
| 399 | return mEntry; |
| 400 | } |
| 401 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 402 | public boolean isHeadsUp() { |
| 403 | return mIsHeadsUp; |
| 404 | } |
| 405 | |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 406 | public void setHeadsUp(boolean isHeadsUp) { |
Selim Cinek | c80fdb1 | 2015-04-13 15:09:08 -0700 | [diff] [blame] | 407 | int intrinsicBefore = getIntrinsicHeight(); |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 408 | mIsHeadsUp = isHeadsUp; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 409 | mPrivateLayout.setHeadsUp(isHeadsUp); |
Selim Cinek | b41b2f6 | 2016-04-26 14:03:29 -0700 | [diff] [blame] | 410 | if (mIsSummaryWithChildren) { |
| 411 | // The overflow might change since we allow more lines as HUN. |
| 412 | mChildrenContainer.updateGroupOverflow(); |
| 413 | } |
Selim Cinek | c80fdb1 | 2015-04-13 15:09:08 -0700 | [diff] [blame] | 414 | if (intrinsicBefore != getIntrinsicHeight()) { |
| 415 | notifyHeightChanged(false /* needsAnimation */); |
| 416 | } |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 417 | if (isHeadsUp) { |
| 418 | setAboveShelf(true); |
| 419 | } |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 420 | } |
| 421 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 422 | public void setGroupManager(NotificationGroupManager groupManager) { |
| 423 | mGroupManager = groupManager; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 424 | mPrivateLayout.setGroupManager(groupManager); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 425 | } |
| 426 | |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 427 | public void setRemoteInputController(RemoteInputController r) { |
| 428 | mPrivateLayout.setRemoteInputController(r); |
| 429 | } |
| 430 | |
Mady Mellor | 3fd273e | 2016-03-15 21:08:14 -0700 | [diff] [blame] | 431 | public void setAppName(String appName) { |
| 432 | mAppName = appName; |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 433 | if (mMenuRow != null && mMenuRow.getMenuView() != null) { |
Mady Mellor | 761cde1 | 2017-01-10 11:36:39 -0800 | [diff] [blame] | 434 | mMenuRow.setAppName(mAppName); |
Mady Mellor | 3fd273e | 2016-03-15 21:08:14 -0700 | [diff] [blame] | 435 | } |
| 436 | } |
| 437 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 438 | public void addChildNotification(ExpandableNotificationRow row) { |
| 439 | addChildNotification(row, -1); |
| 440 | } |
| 441 | |
| 442 | /** |
| 443 | * Add a child notification to this view. |
| 444 | * |
| 445 | * @param row the row to add |
| 446 | * @param childIndex the index to add it at, if -1 it will be added at the end |
| 447 | */ |
| 448 | public void addChildNotification(ExpandableNotificationRow row, int childIndex) { |
| 449 | if (mChildrenContainer == null) { |
| 450 | mChildrenContainerStub.inflate(); |
| 451 | } |
| 452 | mChildrenContainer.addNotification(row, childIndex); |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 453 | onChildrenCountChanged(); |
| 454 | row.setIsChildInGroup(true, this); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | public void removeChildNotification(ExpandableNotificationRow row) { |
| 458 | if (mChildrenContainer != null) { |
| 459 | mChildrenContainer.removeNotification(row); |
| 460 | } |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 461 | onChildrenCountChanged(); |
| 462 | row.setIsChildInGroup(false, null); |
| 463 | } |
| 464 | |
Mady Mellor | 43c2cd1 | 2016-12-12 21:05:13 -0800 | [diff] [blame] | 465 | @Override |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 466 | public boolean isChildInGroup() { |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 467 | return mNotificationParent != null; |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 468 | } |
| 469 | |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 470 | public ExpandableNotificationRow getNotificationParent() { |
| 471 | return mNotificationParent; |
| 472 | } |
| 473 | |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 474 | /** |
| 475 | * @param isChildInGroup Is this notification now in a group |
| 476 | * @param parent the new parent notification |
| 477 | */ |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 478 | public void setIsChildInGroup(boolean isChildInGroup, ExpandableNotificationRow parent) {; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 479 | boolean childInGroup = StatusBar.ENABLE_CHILD_NOTIFICATIONS && isChildInGroup; |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 480 | mNotificationParent = childInGroup ? parent : null; |
| 481 | mPrivateLayout.setIsChildInGroup(childInGroup); |
Selim Cinek | c478f90 | 2017-02-22 20:55:44 -0800 | [diff] [blame] | 482 | if (mNotificationInflater.setIsChildInGroup(childInGroup)) { |
| 483 | onNotificationUpdated(); |
| 484 | } |
Mady Mellor | c7d65b4 | 2016-05-04 11:44:57 -0400 | [diff] [blame] | 485 | resetBackgroundAlpha(); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 486 | updateBackgroundForGroupState(); |
Selim Cinek | ddf1b39 | 2016-05-27 16:33:10 -0700 | [diff] [blame] | 487 | updateClickAndFocus(); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 488 | if (mNotificationParent != null) { |
Selim Cinek | 9ce3285 | 2017-02-15 16:21:10 -0800 | [diff] [blame] | 489 | setOverrideTintColor(NO_COLOR, 0.0f); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 490 | mNotificationParent.updateBackgroundForGroupState(); |
| 491 | } |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 492 | updateIconVisibilities(); |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | @Override |
Selim Cinek | 7210947 | 2016-01-15 16:33:22 -0800 | [diff] [blame] | 496 | public boolean onTouchEvent(MotionEvent event) { |
| 497 | if (event.getActionMasked() != MotionEvent.ACTION_DOWN |
| 498 | || !isChildInGroup() || isGroupExpanded()) { |
| 499 | return super.onTouchEvent(event); |
| 500 | } else { |
| 501 | return false; |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | @Override |
Mady Mellor | f062580 | 2016-02-11 18:03:48 -0800 | [diff] [blame] | 506 | protected boolean handleSlideBack() { |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 507 | if (mMenuRow != null && mMenuRow.isMenuVisible()) { |
Mady Mellor | f062580 | 2016-02-11 18:03:48 -0800 | [diff] [blame] | 508 | animateTranslateNotification(0 /* targetLeft */); |
| 509 | return true; |
| 510 | } |
| 511 | return false; |
| 512 | } |
| 513 | |
| 514 | @Override |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 515 | protected boolean shouldHideBackground() { |
| 516 | return super.shouldHideBackground() || mShowNoBackground; |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | @Override |
| 520 | public boolean isSummaryWithChildren() { |
| 521 | return mIsSummaryWithChildren; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | @Override |
| 525 | public boolean areChildrenExpanded() { |
| 526 | return mChildrenExpanded; |
| 527 | } |
| 528 | |
| 529 | public List<ExpandableNotificationRow> getNotificationChildren() { |
| 530 | return mChildrenContainer == null ? null : mChildrenContainer.getNotificationChildren(); |
| 531 | } |
| 532 | |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 533 | public int getNumberOfNotificationChildren() { |
| 534 | if (mChildrenContainer == null) { |
| 535 | return 0; |
| 536 | } |
| 537 | return mChildrenContainer.getNotificationChildren().size(); |
| 538 | } |
| 539 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 540 | /** |
| 541 | * Apply the order given in the list to the children. |
| 542 | * |
| 543 | * @param childOrder the new list order |
Selim Cinek | a7d4f82 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 544 | * @param visualStabilityManager |
| 545 | * @param callback the callback to invoked in case it is not allowed |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 546 | * @return whether the list order has changed |
| 547 | */ |
Selim Cinek | a7d4f82 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 548 | public boolean applyChildOrder(List<ExpandableNotificationRow> childOrder, |
| 549 | VisualStabilityManager visualStabilityManager, |
| 550 | VisualStabilityManager.Callback callback) { |
| 551 | return mChildrenContainer != null && mChildrenContainer.applyChildOrder(childOrder, |
| 552 | visualStabilityManager, callback); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | public void getChildrenStates(StackScrollState resultState) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 556 | if (mIsSummaryWithChildren) { |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 557 | ExpandableViewState parentState = resultState.getViewStateForView(this); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 558 | mChildrenContainer.getState(resultState, parentState); |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | public void applyChildrenState(StackScrollState state) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 563 | if (mIsSummaryWithChildren) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 564 | mChildrenContainer.applyState(state); |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | public void prepareExpansionChanged(StackScrollState state) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 569 | if (mIsSummaryWithChildren) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 570 | mChildrenContainer.prepareExpansionChanged(state); |
| 571 | } |
| 572 | } |
| 573 | |
Selim Cinek | 0cfbef4 | 2016-11-09 19:06:36 -0800 | [diff] [blame] | 574 | public void startChildAnimation(StackScrollState finalState, AnimationProperties properties) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 575 | if (mIsSummaryWithChildren) { |
Selim Cinek | 0cfbef4 | 2016-11-09 19:06:36 -0800 | [diff] [blame] | 576 | mChildrenContainer.startAnimationToState(finalState, properties); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 577 | } |
| 578 | } |
| 579 | |
| 580 | public ExpandableNotificationRow getViewAtPosition(float y) { |
Selim Cinek | 43d30f0 | 2016-03-04 10:51:32 -0800 | [diff] [blame] | 581 | if (!mIsSummaryWithChildren || !mChildrenExpanded) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 582 | return this; |
| 583 | } else { |
| 584 | ExpandableNotificationRow view = mChildrenContainer.getViewAtPosition(y); |
| 585 | return view == null ? this : view; |
| 586 | } |
| 587 | } |
| 588 | |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 589 | public NotificationGuts getGuts() { |
| 590 | return mGuts; |
| 591 | } |
| 592 | |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 593 | /** |
| 594 | * Set this notification to be pinned to the top if {@link #isHeadsUp()} is true. By doing this |
| 595 | * the notification will be rendered on top of the screen. |
| 596 | * |
| 597 | * @param pinned whether it is pinned |
| 598 | */ |
| 599 | public void setPinned(boolean pinned) { |
Selim Cinek | def35a8 | 2016-05-03 15:52:51 -0700 | [diff] [blame] | 600 | int intrinsicHeight = getIntrinsicHeight(); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 601 | mIsPinned = pinned; |
Selim Cinek | def35a8 | 2016-05-03 15:52:51 -0700 | [diff] [blame] | 602 | if (intrinsicHeight != getIntrinsicHeight()) { |
Selim Cinek | bb42b7d | 2016-08-10 13:02:38 -0700 | [diff] [blame] | 603 | notifyHeightChanged(false /* needsAnimation */); |
Selim Cinek | def35a8 | 2016-05-03 15:52:51 -0700 | [diff] [blame] | 604 | } |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 605 | if (pinned) { |
| 606 | setIconAnimationRunning(true); |
| 607 | mExpandedWhenPinned = false; |
| 608 | } else if (mExpandedWhenPinned) { |
| 609 | setUserExpanded(true); |
| 610 | } |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 611 | setChronometerRunning(mLastChronometerRunning); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 612 | } |
| 613 | |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 614 | public boolean isPinned() { |
| 615 | return mIsPinned; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 616 | } |
| 617 | |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 618 | @Override |
| 619 | public int getPinnedHeadsUpHeight() { |
| 620 | return getPinnedHeadsUpHeight(true /* atLeastMinHeight */); |
| 621 | } |
| 622 | |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 623 | /** |
| 624 | * @param atLeastMinHeight should the value returned be at least the minimum height. |
| 625 | * Used to avoid cyclic calls |
| 626 | * @return the height of the heads up notification when pinned |
| 627 | */ |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 628 | private int getPinnedHeadsUpHeight(boolean atLeastMinHeight) { |
Selim Cinek | 77019c7 | 2015-12-09 10:18:02 -0800 | [diff] [blame] | 629 | if (mIsSummaryWithChildren) { |
| 630 | return mChildrenContainer.getIntrinsicHeight(); |
| 631 | } |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 632 | if(mExpandedWhenPinned) { |
| 633 | return Math.max(getMaxExpandHeight(), mHeadsUpHeight); |
| 634 | } else if (atLeastMinHeight) { |
Selim Cinek | 567e845 | 2016-03-24 10:54:56 -0700 | [diff] [blame] | 635 | return Math.max(getCollapsedHeight(), mHeadsUpHeight); |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 636 | } else { |
| 637 | return mHeadsUpHeight; |
| 638 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 639 | } |
| 640 | |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 641 | /** |
| 642 | * Mark whether this notification was just clicked, i.e. the user has just clicked this |
| 643 | * notification in this frame. |
| 644 | */ |
| 645 | public void setJustClicked(boolean justClicked) { |
| 646 | mJustClicked = justClicked; |
| 647 | } |
| 648 | |
| 649 | /** |
| 650 | * @return true if this notification has been clicked in this frame, false otherwise |
| 651 | */ |
| 652 | public boolean wasJustClicked() { |
| 653 | return mJustClicked; |
| 654 | } |
| 655 | |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 656 | public void setChronometerRunning(boolean running) { |
| 657 | mLastChronometerRunning = running; |
| 658 | setChronometerRunning(running, mPrivateLayout); |
| 659 | setChronometerRunning(running, mPublicLayout); |
| 660 | if (mChildrenContainer != null) { |
| 661 | List<ExpandableNotificationRow> notificationChildren = |
| 662 | mChildrenContainer.getNotificationChildren(); |
| 663 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 664 | ExpandableNotificationRow child = notificationChildren.get(i); |
| 665 | child.setChronometerRunning(running); |
| 666 | } |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | private void setChronometerRunning(boolean running, NotificationContentView layout) { |
| 671 | if (layout != null) { |
| 672 | running = running || isPinned(); |
| 673 | View contractedChild = layout.getContractedChild(); |
| 674 | View expandedChild = layout.getExpandedChild(); |
| 675 | View headsUpChild = layout.getHeadsUpChild(); |
| 676 | setChronometerRunningForChild(running, contractedChild); |
| 677 | setChronometerRunningForChild(running, expandedChild); |
| 678 | setChronometerRunningForChild(running, headsUpChild); |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | private void setChronometerRunningForChild(boolean running, View child) { |
| 683 | if (child != null) { |
| 684 | View chronometer = child.findViewById(com.android.internal.R.id.chronometer); |
| 685 | if (chronometer instanceof Chronometer) { |
| 686 | ((Chronometer) chronometer).setStarted(running); |
| 687 | } |
| 688 | } |
| 689 | } |
| 690 | |
Selim Cinek | ea4bef7 | 2015-12-02 15:51:10 -0800 | [diff] [blame] | 691 | public NotificationHeaderView getNotificationHeader() { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 692 | if (mIsSummaryWithChildren) { |
| 693 | return mChildrenContainer.getHeaderView(); |
Selim Cinek | 8d6440d | 2015-10-22 13:00:05 -0700 | [diff] [blame] | 694 | } |
Selim Cinek | ea4bef7 | 2015-12-02 15:51:10 -0800 | [diff] [blame] | 695 | return mPrivateLayout.getNotificationHeader(); |
Selim Cinek | 8d6440d | 2015-10-22 13:00:05 -0700 | [diff] [blame] | 696 | } |
| 697 | |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 698 | /** |
| 699 | * @return the currently visible notification header. This can be different from |
| 700 | * {@link #getNotificationHeader()} in case it is a low-priority group. |
| 701 | */ |
| 702 | public NotificationHeaderView getVisibleNotificationHeader() { |
Selim Cinek | aa3901a | 2016-08-05 11:04:37 -0700 | [diff] [blame] | 703 | if (mIsSummaryWithChildren && !mShowingPublic) { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 704 | return mChildrenContainer.getVisibleHeader(); |
Selim Cinek | 34eda5e | 2016-02-18 17:10:43 -0800 | [diff] [blame] | 705 | } |
| 706 | return getShowingLayout().getVisibleNotificationHeader(); |
| 707 | } |
| 708 | |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 709 | public void setOnExpandClickListener(OnExpandClickListener onExpandClickListener) { |
| 710 | mOnExpandClickListener = onExpandClickListener; |
| 711 | } |
| 712 | |
Selim Cinek | ddf1b39 | 2016-05-27 16:33:10 -0700 | [diff] [blame] | 713 | @Override |
| 714 | public void setOnClickListener(@Nullable OnClickListener l) { |
| 715 | super.setOnClickListener(l); |
| 716 | mOnClickListener = l; |
| 717 | updateClickAndFocus(); |
| 718 | } |
| 719 | |
| 720 | private void updateClickAndFocus() { |
| 721 | boolean normalChild = !isChildInGroup() || isGroupExpanded(); |
| 722 | boolean clickable = mOnClickListener != null && normalChild; |
| 723 | if (isFocusable() != normalChild) { |
| 724 | setFocusable(normalChild); |
| 725 | } |
| 726 | if (isClickable() != clickable) { |
| 727 | setClickable(clickable); |
| 728 | } |
| 729 | } |
| 730 | |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 731 | public void setHeadsUpManager(HeadsUpManager headsUpManager) { |
| 732 | mHeadsUpManager = headsUpManager; |
| 733 | } |
| 734 | |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 735 | public void setGutsView(MenuItem item) { |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 736 | if (mGuts != null && item.getGutsView() instanceof GutsContent) { |
| 737 | ((GutsContent) item.getGutsView()).setGutsParent(mGuts); |
| 738 | mGuts.setGutsContent((GutsContent) item.getGutsView()); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 739 | } |
| 740 | } |
| 741 | |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 742 | @Override |
| 743 | protected void onAttachedToWindow() { |
| 744 | super.onAttachedToWindow(); |
| 745 | Dependency.get(PluginManager.class).addPluginListener(this, |
| 746 | NotificationMenuRowPlugin.class, false /* Allow multiple */); |
| 747 | } |
| 748 | |
| 749 | @Override |
| 750 | protected void onDetachedFromWindow() { |
| 751 | super.onDetachedFromWindow(); |
| 752 | Dependency.get(PluginManager.class).removePluginListener(this); |
| 753 | } |
| 754 | |
| 755 | @Override |
| 756 | public void onPluginConnected(NotificationMenuRowPlugin plugin, Context pluginContext) { |
| 757 | boolean existed = mMenuRow.getMenuView() != null; |
| 758 | if (existed) { |
| 759 | removeView(mMenuRow.getMenuView()); |
| 760 | } |
| 761 | mMenuRow = plugin; |
| 762 | if (mMenuRow.useDefaultMenuItems()) { |
| 763 | mMenuRow.setMenuItems(NotificationMenuRow.getDefaultMenuItems(mContext)); |
| 764 | } |
| 765 | if (existed) { |
| 766 | createMenu(); |
| 767 | } |
| 768 | } |
| 769 | |
| 770 | @Override |
| 771 | public void onPluginDisconnected(NotificationMenuRowPlugin plugin) { |
| 772 | boolean existed = mMenuRow.getMenuView() != null; |
| 773 | mMenuRow = new NotificationMenuRow(mContext); // Back to default |
| 774 | if (existed) { |
| 775 | createMenu(); |
| 776 | } |
| 777 | } |
| 778 | |
| 779 | public NotificationMenuRowPlugin createMenu() { |
| 780 | if (mMenuRow.getMenuView() == null) { |
| 781 | mMenuRow.createMenu(this); |
| 782 | mMenuRow.setAppName(mAppName); |
| 783 | FrameLayout.LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, |
| 784 | LayoutParams.MATCH_PARENT); |
| 785 | addView(mMenuRow.getMenuView(), MENU_VIEW_INDEX, lp); |
| 786 | } |
| 787 | return mMenuRow; |
| 788 | } |
| 789 | |
| 790 | |
| 791 | public NotificationMenuRowPlugin getProvider() { |
| 792 | return mMenuRow; |
| 793 | } |
| 794 | |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 795 | public void onDensityOrFontScaleChanged() { |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 796 | initDimens(); |
| 797 | if (mIsSummaryWithChildren) { |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 798 | if (mChildrenContainer != null) { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 799 | mChildrenContainer.reInflateViews(mExpandClickListener, mEntry.notification); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 800 | } |
| 801 | } |
| 802 | if (mGuts != null) { |
| 803 | View oldGuts = mGuts; |
| 804 | int index = indexOfChild(oldGuts); |
| 805 | removeView(oldGuts); |
| 806 | mGuts = (NotificationGuts) LayoutInflater.from(mContext).inflate( |
| 807 | R.layout.notification_guts, this, false); |
| 808 | mGuts.setVisibility(oldGuts.getVisibility()); |
| 809 | addView(mGuts, index); |
| 810 | } |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 811 | View oldMenu = mMenuRow.getMenuView(); |
| 812 | if (oldMenu != null) { |
Mady Mellor | 761cde1 | 2017-01-10 11:36:39 -0800 | [diff] [blame] | 813 | int menuIndex = indexOfChild(oldMenu); |
| 814 | removeView(oldMenu); |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 815 | mMenuRow.createMenu(ExpandableNotificationRow.this); |
Mady Mellor | 761cde1 | 2017-01-10 11:36:39 -0800 | [diff] [blame] | 816 | mMenuRow.setAppName(mAppName); |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 817 | addView(mMenuRow.getMenuView(), menuIndex); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 818 | } |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 819 | for (NotificationContentView l : mLayouts) { |
| 820 | l.reInflateViews(); |
| 821 | } |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 822 | mNotificationInflater.onDensityOrFontScaleChanged(); |
| 823 | onNotificationUpdated(); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 824 | } |
| 825 | |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 826 | public void setContentBackground(int customBackgroundColor, boolean animate, |
| 827 | NotificationContentView notificationContentView) { |
| 828 | if (getShowingLayout() == notificationContentView) { |
| 829 | setTintColor(customBackgroundColor, animate); |
| 830 | } |
| 831 | } |
| 832 | |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 833 | public void closeRemoteInput() { |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 834 | for (NotificationContentView l : mLayouts) { |
| 835 | l.closeRemoteInput(); |
| 836 | } |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 837 | } |
| 838 | |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 839 | /** |
| 840 | * Set by how much the single line view should be indented. |
| 841 | */ |
| 842 | public void setSingleLineWidthIndention(int indention) { |
| 843 | mPrivateLayout.setSingleLineWidthIndention(indention); |
| 844 | } |
| 845 | |
| 846 | public int getNotificationColor() { |
Selim Cinek | 4bb5934 | 2016-04-08 19:29:35 -0700 | [diff] [blame] | 847 | return mNotificationColor; |
| 848 | } |
| 849 | |
| 850 | private void updateNotificationColor() { |
| 851 | mNotificationColor = NotificationColorUtil.resolveContrastColor(mContext, |
| 852 | getStatusBarNotification().getNotification().color); |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 853 | } |
| 854 | |
| 855 | public HybridNotificationView getSingleLineView() { |
| 856 | return mPrivateLayout.getSingleLineView(); |
| 857 | } |
| 858 | |
Selim Cinek | f07d062 | 2016-03-21 19:52:52 -0700 | [diff] [blame] | 859 | public boolean isOnKeyguard() { |
| 860 | return mOnKeyguard; |
| 861 | } |
| 862 | |
Selim Cinek | c1e389d | 2016-04-07 11:02:57 -0700 | [diff] [blame] | 863 | public void removeAllChildren() { |
| 864 | List<ExpandableNotificationRow> notificationChildren |
| 865 | = mChildrenContainer.getNotificationChildren(); |
| 866 | ArrayList<ExpandableNotificationRow> clonedList = new ArrayList<>(notificationChildren); |
| 867 | for (int i = 0; i < clonedList.size(); i++) { |
| 868 | ExpandableNotificationRow row = clonedList.get(i); |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 869 | if (row.keepInParent()) { |
| 870 | continue; |
| 871 | } |
Selim Cinek | c1e389d | 2016-04-07 11:02:57 -0700 | [diff] [blame] | 872 | mChildrenContainer.removeNotification(row); |
Selim Cinek | c1e389d | 2016-04-07 11:02:57 -0700 | [diff] [blame] | 873 | row.setIsChildInGroup(false, null); |
| 874 | } |
| 875 | onChildrenCountChanged(); |
| 876 | } |
| 877 | |
Selim Cinek | 1b2a05e | 2016-04-28 14:20:39 -0700 | [diff] [blame] | 878 | public void setForceUnlocked(boolean forceUnlocked) { |
| 879 | mForceUnlocked = forceUnlocked; |
| 880 | if (mIsSummaryWithChildren) { |
| 881 | List<ExpandableNotificationRow> notificationChildren = getNotificationChildren(); |
| 882 | for (ExpandableNotificationRow child : notificationChildren) { |
| 883 | child.setForceUnlocked(forceUnlocked); |
| 884 | } |
| 885 | } |
| 886 | } |
| 887 | |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 888 | public void setDismissed(boolean dismissed, boolean fromAccessibility) { |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 889 | mDismissed = dismissed; |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 890 | mGroupParentWhenDismissed = mNotificationParent; |
| 891 | mRefocusOnDismiss = fromAccessibility; |
| 892 | mChildAfterViewWhenDismissed = null; |
| 893 | if (isChildInGroup()) { |
| 894 | List<ExpandableNotificationRow> notificationChildren = |
| 895 | mNotificationParent.getNotificationChildren(); |
| 896 | int i = notificationChildren.indexOf(this); |
| 897 | if (i != -1 && i < notificationChildren.size() - 1) { |
| 898 | mChildAfterViewWhenDismissed = notificationChildren.get(i + 1); |
| 899 | } |
| 900 | } |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | public boolean isDismissed() { |
| 904 | return mDismissed; |
| 905 | } |
| 906 | |
| 907 | public boolean keepInParent() { |
| 908 | return mKeepInParent; |
| 909 | } |
| 910 | |
| 911 | public void setKeepInParent(boolean keepInParent) { |
| 912 | mKeepInParent = keepInParent; |
| 913 | } |
| 914 | |
| 915 | public boolean isRemoved() { |
| 916 | return mRemoved; |
| 917 | } |
| 918 | |
Adrian Roos | d009ab1 | 2016-05-20 17:58:53 -0700 | [diff] [blame] | 919 | public void setRemoved() { |
| 920 | mRemoved = true; |
Selim Cinek | ef8c225 | 2017-02-10 14:52:18 -0800 | [diff] [blame] | 921 | mTranslationWhenRemoved = getTranslationY(); |
| 922 | mWasChildInGroupWhenRemoved = isChildInGroup(); |
| 923 | if (isChildInGroup()) { |
| 924 | mTranslationWhenRemoved += getNotificationParent().getTranslationY(); |
| 925 | } |
Adrian Roos | d009ab1 | 2016-05-20 17:58:53 -0700 | [diff] [blame] | 926 | mPrivateLayout.setRemoved(); |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 927 | } |
| 928 | |
Selim Cinek | ef8c225 | 2017-02-10 14:52:18 -0800 | [diff] [blame] | 929 | public boolean wasChildInGroupWhenRemoved() { |
| 930 | return mWasChildInGroupWhenRemoved; |
| 931 | } |
| 932 | |
| 933 | public float getTranslationWhenRemoved() { |
| 934 | return mTranslationWhenRemoved; |
| 935 | } |
| 936 | |
Selim Cinek | d139564 | 2016-04-28 12:22:42 -0700 | [diff] [blame] | 937 | public NotificationChildrenContainer getChildrenContainer() { |
| 938 | return mChildrenContainer; |
| 939 | } |
| 940 | |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 941 | public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) { |
| 942 | mHeadsupDisappearRunning = headsUpAnimatingAway; |
| 943 | mPrivateLayout.setHeadsUpAnimatingAway(headsUpAnimatingAway); |
| 944 | } |
| 945 | |
| 946 | /** |
| 947 | * @return if the view was just heads upped and is now animating away. During such a time the |
| 948 | * layout needs to be kept consistent |
| 949 | */ |
| 950 | public boolean isHeadsUpAnimatingAway() { |
| 951 | return mHeadsupDisappearRunning; |
Selim Cinek | 73cf02a | 2016-06-17 13:08:00 -0700 | [diff] [blame] | 952 | } |
| 953 | |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 954 | public View getChildAfterViewWhenDismissed() { |
| 955 | return mChildAfterViewWhenDismissed; |
| 956 | } |
| 957 | |
| 958 | public View getGroupParentWhenDismissed() { |
| 959 | return mGroupParentWhenDismissed; |
| 960 | } |
| 961 | |
Selim Cinek | 9e624e7 | 2016-07-20 13:46:49 -0700 | [diff] [blame] | 962 | public void performDismiss() { |
Selim Cinek | e907911 | 2016-12-14 14:41:01 -0800 | [diff] [blame] | 963 | if (mOnDismissRunnable != null) { |
| 964 | mOnDismissRunnable.run(); |
| 965 | } |
Selim Cinek | 9e624e7 | 2016-07-20 13:46:49 -0700 | [diff] [blame] | 966 | } |
| 967 | |
Selim Cinek | e907911 | 2016-12-14 14:41:01 -0800 | [diff] [blame] | 968 | public void setOnDismissRunnable(Runnable onDismissRunnable) { |
| 969 | mOnDismissRunnable = onDismissRunnable; |
Selim Cinek | 9e624e7 | 2016-07-20 13:46:49 -0700 | [diff] [blame] | 970 | } |
| 971 | |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 972 | public View getNotificationIcon() { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 973 | NotificationHeaderView notificationHeader = getVisibleNotificationHeader(); |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 974 | if (notificationHeader != null) { |
| 975 | return notificationHeader.getIcon(); |
| 976 | } |
| 977 | return null; |
| 978 | } |
| 979 | |
| 980 | /** |
| 981 | * @return whether the notification is currently showing a view with an icon. |
| 982 | */ |
| 983 | public boolean isShowingIcon() { |
Mady Mellor | 434180c | 2017-02-13 11:29:42 -0800 | [diff] [blame] | 984 | if (areGutsExposed()) { |
| 985 | return false; |
| 986 | } |
Selim Cinek | 2ffa02f | 2017-03-06 15:56:37 -0800 | [diff] [blame] | 987 | return getVisibleNotificationHeader() != null; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 988 | } |
| 989 | |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 990 | /** |
| 991 | * Set how much this notification is transformed into an icon. |
| 992 | * |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 993 | * @param contentTransformationAmount A value from 0 to 1 indicating how much we are transformed |
| 994 | * to the content away |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 995 | * @param isLastChild is this the last child in the list. If true, then the transformation is |
| 996 | * different since it's content fades out. |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 997 | */ |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 998 | public void setContentTransformationAmount(float contentTransformationAmount, |
| 999 | boolean isLastChild) { |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1000 | boolean changeTransformation = isLastChild != mIsLastChild; |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 1001 | changeTransformation |= mContentTransformationAmount != contentTransformationAmount; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1002 | mIsLastChild = isLastChild; |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 1003 | mContentTransformationAmount = contentTransformationAmount; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1004 | if (changeTransformation) { |
| 1005 | updateContentTransformation(); |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 1006 | } |
| 1007 | } |
| 1008 | |
| 1009 | /** |
| 1010 | * Set the icons to be visible of this notification. |
| 1011 | */ |
| 1012 | public void setIconsVisible(boolean iconsVisible) { |
| 1013 | if (iconsVisible != mIconsVisible) { |
| 1014 | mIconsVisible = iconsVisible; |
| 1015 | updateIconVisibilities(); |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 1016 | } |
| 1017 | } |
| 1018 | |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 1019 | @Override |
| 1020 | protected void onBelowSpeedBumpChanged() { |
| 1021 | updateIconVisibilities(); |
| 1022 | } |
| 1023 | |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1024 | private void updateContentTransformation() { |
| 1025 | float contentAlpha; |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 1026 | float translationY = -mContentTransformationAmount * mIconTransformContentShift; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1027 | if (mIsLastChild) { |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 1028 | contentAlpha = 1.0f - mContentTransformationAmount; |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1029 | contentAlpha = Math.min(contentAlpha / 0.5f, 1.0f); |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 1030 | contentAlpha = Interpolators.ALPHA_OUT.getInterpolation(contentAlpha); |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1031 | translationY *= 0.4f; |
| 1032 | } else { |
| 1033 | contentAlpha = 1.0f; |
| 1034 | } |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1035 | for (NotificationContentView l : mLayouts) { |
| 1036 | l.setAlpha(contentAlpha); |
| 1037 | l.setTranslationY(translationY); |
| 1038 | } |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1039 | if (mChildrenContainer != null) { |
| 1040 | mChildrenContainer.setAlpha(contentAlpha); |
| 1041 | mChildrenContainer.setTranslationY(translationY); |
| 1042 | // TODO: handle children fade out better |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 1043 | } |
| 1044 | } |
| 1045 | |
| 1046 | private void updateIconVisibilities() { |
Selim Cinek | 17e1b69 | 2016-12-02 18:19:11 -0800 | [diff] [blame] | 1047 | boolean visible = isChildInGroup() |
| 1048 | || (isBelowSpeedBump() && !NotificationShelf.SHOW_AMBIENT_ICONS) |
| 1049 | || mIconsVisible; |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1050 | for (NotificationContentView l : mLayouts) { |
| 1051 | l.setIconsVisible(visible); |
| 1052 | } |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 1053 | if (mChildrenContainer != null) { |
| 1054 | mChildrenContainer.setIconsVisible(visible); |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 1055 | } |
| 1056 | } |
| 1057 | |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1058 | /** |
| 1059 | * Get the relative top padding of a view relative to this view. This recursively walks up the |
| 1060 | * hierarchy and does the corresponding measuring. |
| 1061 | * |
| 1062 | * @param view the view to the the padding for. The requested view has to be a child of this |
| 1063 | * notification. |
| 1064 | * @return the toppadding |
| 1065 | */ |
| 1066 | public int getRelativeTopPadding(View view) { |
| 1067 | int topPadding = 0; |
| 1068 | while (view.getParent() instanceof ViewGroup) { |
| 1069 | topPadding += view.getTop(); |
| 1070 | view = (View) view.getParent(); |
| 1071 | if (view instanceof ExpandableNotificationRow) { |
| 1072 | return topPadding; |
| 1073 | } |
| 1074 | } |
| 1075 | return topPadding; |
| 1076 | } |
| 1077 | |
Selim Cinek | a1d9790 | 2016-12-14 16:31:40 -0800 | [diff] [blame] | 1078 | public float getContentTranslation() { |
| 1079 | return mPrivateLayout.getTranslationY(); |
| 1080 | } |
| 1081 | |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 1082 | public void setIsLowPriority(boolean isLowPriority) { |
| 1083 | mIsLowPriority = isLowPriority; |
| 1084 | mPrivateLayout.setIsLowPriority(isLowPriority); |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1085 | mNotificationInflater.setIsLowPriority(mIsLowPriority); |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 1086 | if (mChildrenContainer != null) { |
| 1087 | mChildrenContainer.setIsLowPriority(isLowPriority); |
| 1088 | } |
| 1089 | } |
| 1090 | |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1091 | public boolean isLowPriority() { |
| 1092 | return mIsLowPriority; |
| 1093 | } |
| 1094 | |
Selim Cinek | 7d1009b | 2017-01-25 15:28:28 -0800 | [diff] [blame] | 1095 | public void setUseIncreasedCollapsedHeight(boolean use) { |
| 1096 | mUseIncreasedCollapsedHeight = use; |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1097 | mNotificationInflater.setUsesIncreasedHeight(use); |
Selim Cinek | 7d1009b | 2017-01-25 15:28:28 -0800 | [diff] [blame] | 1098 | } |
| 1099 | |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 1100 | public void setUseIncreasedHeadsUpHeight(boolean use) { |
| 1101 | mUseIncreasedHeadsUpHeight = use; |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1102 | mNotificationInflater.setUsesIncreasedHeadsUpHeight(use); |
| 1103 | } |
| 1104 | |
| 1105 | public void setRemoteViewClickHandler(RemoteViews.OnClickHandler remoteViewClickHandler) { |
| 1106 | mNotificationInflater.setRemoteViewClickHandler(remoteViewClickHandler); |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 1107 | } |
| 1108 | |
Selim Cinek | c478f90 | 2017-02-22 20:55:44 -0800 | [diff] [blame] | 1109 | public void setInflateExceptionHandler(InflationExceptionHandler inflateExceptionHandler) { |
| 1110 | mNotificationInflater.setInflateExceptionHandler(inflateExceptionHandler); |
| 1111 | } |
| 1112 | |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1113 | public interface ExpansionLogger { |
| 1114 | public void logNotificationExpansion(String key, boolean userAction, boolean expanded); |
| 1115 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1116 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1117 | public ExpandableNotificationRow(Context context, AttributeSet attrs) { |
| 1118 | super(context, attrs); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 1119 | mFalsingManager = FalsingManager.getInstance(context); |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1120 | mNotificationInflater = new NotificationInflater(this); |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 1121 | mMenuRow = new NotificationMenuRow(mContext); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 1122 | initDimens(); |
| 1123 | } |
| 1124 | |
| 1125 | private void initDimens() { |
Selim Cinek | f619ffc | 2016-02-17 14:53:05 -0800 | [diff] [blame] | 1126 | mNotificationMinHeightLegacy = getFontScaledHeight(R.dimen.notification_min_height_legacy); |
| 1127 | mNotificationMinHeight = getFontScaledHeight(R.dimen.notification_min_height); |
Selim Cinek | 7d1009b | 2017-01-25 15:28:28 -0800 | [diff] [blame] | 1128 | mNotificationMinHeightLarge = getFontScaledHeight( |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 1129 | R.dimen.notification_min_height_increased); |
Selim Cinek | f619ffc | 2016-02-17 14:53:05 -0800 | [diff] [blame] | 1130 | mNotificationMaxHeight = getFontScaledHeight(R.dimen.notification_max_height); |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 1131 | mNotificationAmbientHeight = getFontScaledHeight(R.dimen.notification_ambient_height); |
Selim Cinek | f619ffc | 2016-02-17 14:53:05 -0800 | [diff] [blame] | 1132 | mMaxHeadsUpHeightLegacy = getFontScaledHeight( |
Selim Cinek | 77019c7 | 2015-12-09 10:18:02 -0800 | [diff] [blame] | 1133 | R.dimen.notification_max_heads_up_height_legacy); |
Selim Cinek | f619ffc | 2016-02-17 14:53:05 -0800 | [diff] [blame] | 1134 | mMaxHeadsUpHeight = getFontScaledHeight(R.dimen.notification_max_heads_up_height); |
Selim Cinek | 87ed69b | 2017-02-09 15:59:43 -0800 | [diff] [blame] | 1135 | mMaxHeadsUpHeightIncreased = getFontScaledHeight( |
| 1136 | R.dimen.notification_max_heads_up_height_increased); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1137 | mIncreasedPaddingBetweenElements = getResources() |
| 1138 | .getDimensionPixelSize(R.dimen.notification_divider_height_increased); |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1139 | mIconTransformContentShiftNoIcon = getResources().getDimensionPixelSize( |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 1140 | R.dimen.notification_icon_transform_content_shift); |
Selim Cinek | f619ffc | 2016-02-17 14:53:05 -0800 | [diff] [blame] | 1141 | } |
| 1142 | |
| 1143 | /** |
| 1144 | * @param dimenId the dimen to look up |
| 1145 | * @return the font scaled dimen as if it were in sp but doesn't shrink sizes below dp |
| 1146 | */ |
| 1147 | private int getFontScaledHeight(int dimenId) { |
| 1148 | int dimensionPixelSize = getResources().getDimensionPixelSize(dimenId); |
| 1149 | float factor = Math.max(1.0f, getResources().getDisplayMetrics().scaledDensity / |
| 1150 | getResources().getDisplayMetrics().density); |
| 1151 | return (int) (dimensionPixelSize * factor); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1152 | } |
| 1153 | |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 1154 | /** |
| 1155 | * Resets this view so it can be re-used for an updated notification. |
| 1156 | */ |
| 1157 | public void reset() { |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1158 | mShowingPublicInitialized = false; |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1159 | onHeightReset(); |
Selim Cinek | 6e28a67 | 2014-09-05 14:43:28 +0200 | [diff] [blame] | 1160 | requestLayout(); |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 1161 | } |
| 1162 | |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 1163 | @Override |
| 1164 | protected void onFinishInflate() { |
| 1165 | super.onFinishInflate(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1166 | mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic); |
| 1167 | mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded); |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1168 | mLayouts = new NotificationContentView[] {mPrivateLayout, mPublicLayout}; |
| 1169 | |
| 1170 | for (NotificationContentView l : mLayouts) { |
| 1171 | l.setExpandClickListener(mExpandClickListener); |
| 1172 | l.setContainingNotification(this); |
| 1173 | } |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 1174 | mGutsStub = (ViewStub) findViewById(R.id.notification_guts_stub); |
| 1175 | mGutsStub.setOnInflateListener(new ViewStub.OnInflateListener() { |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1176 | @Override |
| 1177 | public void onInflate(ViewStub stub, View inflated) { |
| 1178 | mGuts = (NotificationGuts) inflated; |
| 1179 | mGuts.setClipTopAmount(getClipTopAmount()); |
| 1180 | mGuts.setActualHeight(getActualHeight()); |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 1181 | mGutsStub = null; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1182 | } |
| 1183 | }); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1184 | mChildrenContainerStub = (ViewStub) findViewById(R.id.child_container_stub); |
| 1185 | mChildrenContainerStub.setOnInflateListener(new ViewStub.OnInflateListener() { |
| 1186 | |
| 1187 | @Override |
| 1188 | public void onInflate(ViewStub stub, View inflated) { |
| 1189 | mChildrenContainer = (NotificationChildrenContainer) inflated; |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 1190 | mChildrenContainer.setIsLowPriority(mIsLowPriority); |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1191 | mChildrenContainer.setContainingNotification(ExpandableNotificationRow.this); |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 1192 | mChildrenContainer.onNotificationUpdated(); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1193 | mTranslateableViews.add(mChildrenContainer); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1194 | } |
| 1195 | }); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1196 | |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 1197 | // Add the views that we translate to reveal the menu |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1198 | mTranslateableViews = new ArrayList<View>(); |
| 1199 | for (int i = 0; i < getChildCount(); i++) { |
| 1200 | mTranslateableViews.add(getChildAt(i)); |
| 1201 | } |
| 1202 | // Remove views that don't translate |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1203 | mTranslateableViews.remove(mChildrenContainerStub); |
| 1204 | mTranslateableViews.remove(mGutsStub); |
| 1205 | } |
| 1206 | |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1207 | public void resetTranslation() { |
Mady Mellor | 32c638a | 2016-09-14 08:58:25 -0700 | [diff] [blame] | 1208 | if (mTranslateAnim != null) { |
| 1209 | mTranslateAnim.cancel(); |
| 1210 | } |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1211 | if (mTranslateableViews != null) { |
| 1212 | for (int i = 0; i < mTranslateableViews.size(); i++) { |
| 1213 | mTranslateableViews.get(i).setTranslationX(0); |
| 1214 | } |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1215 | } |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1216 | invalidateOutline(); |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 1217 | mMenuRow.resetMenu(); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1218 | } |
| 1219 | |
| 1220 | public void animateTranslateNotification(final float leftTarget) { |
| 1221 | if (mTranslateAnim != null) { |
| 1222 | mTranslateAnim.cancel(); |
| 1223 | } |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1224 | mTranslateAnim = getTranslateViewAnimator(leftTarget, null /* updateListener */); |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 1225 | if (mTranslateAnim != null) { |
| 1226 | mTranslateAnim.start(); |
| 1227 | } |
| 1228 | } |
| 1229 | |
| 1230 | @Override |
| 1231 | public void setTranslation(float translationX) { |
| 1232 | if (areGutsExposed()) { |
| 1233 | // Don't translate if guts are showing. |
| 1234 | return; |
| 1235 | } |
| 1236 | // Translate the group of views |
| 1237 | for (int i = 0; i < mTranslateableViews.size(); i++) { |
| 1238 | if (mTranslateableViews.get(i) != null) { |
| 1239 | mTranslateableViews.get(i).setTranslationX(translationX); |
| 1240 | } |
| 1241 | } |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1242 | invalidateOutline(); |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 1243 | if (mMenuRow.getMenuView() != null) { |
| 1244 | mMenuRow.onTranslationUpdate(translationX); |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 1245 | } |
| 1246 | } |
| 1247 | |
| 1248 | @Override |
| 1249 | public float getTranslation() { |
| 1250 | if (mTranslateableViews != null && mTranslateableViews.size() > 0) { |
| 1251 | // All of the views in the list should have same translation, just use first one. |
| 1252 | return mTranslateableViews.get(0).getTranslationX(); |
| 1253 | } |
| 1254 | return 0; |
| 1255 | } |
| 1256 | |
| 1257 | public Animator getTranslateViewAnimator(final float leftTarget, |
| 1258 | AnimatorUpdateListener listener) { |
Mady Mellor | 723f1f9 | 2016-03-13 15:54:06 -0700 | [diff] [blame] | 1259 | if (mTranslateAnim != null) { |
| 1260 | mTranslateAnim.cancel(); |
| 1261 | } |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 1262 | if (areGutsExposed()) { |
| 1263 | // No translation if guts are exposed. |
| 1264 | return null; |
| 1265 | } |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1266 | final ObjectAnimator translateAnim = ObjectAnimator.ofFloat(this, TRANSLATE_CONTENT, |
| 1267 | leftTarget); |
| 1268 | if (listener != null) { |
| 1269 | translateAnim.addUpdateListener(listener); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1270 | } |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1271 | translateAnim.addListener(new AnimatorListenerAdapter() { |
| 1272 | boolean cancelled = false; |
| 1273 | |
| 1274 | @Override |
| 1275 | public void onAnimationCancel(Animator anim) { |
| 1276 | cancelled = true; |
| 1277 | } |
| 1278 | |
| 1279 | @Override |
| 1280 | public void onAnimationEnd(Animator anim) { |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 1281 | if (!cancelled && leftTarget == 0) { |
| 1282 | mMenuRow.resetMenu(); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1283 | mTranslateAnim = null; |
| 1284 | } |
| 1285 | } |
| 1286 | }); |
| 1287 | mTranslateAnim = translateAnim; |
| 1288 | return translateAnim; |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1289 | } |
| 1290 | |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 1291 | public void inflateGuts() { |
| 1292 | if (mGuts == null) { |
| 1293 | mGutsStub.inflate(); |
| 1294 | } |
| 1295 | } |
| 1296 | |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 1297 | private void updateChildrenVisibility() { |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1298 | mPrivateLayout.setVisibility(!mShowingPublic && !mIsSummaryWithChildren ? VISIBLE |
| 1299 | : INVISIBLE); |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1300 | if (mChildrenContainer != null) { |
| 1301 | mChildrenContainer.setVisibility(!mShowingPublic && mIsSummaryWithChildren ? VISIBLE |
| 1302 | : INVISIBLE); |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1303 | } |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 1304 | // The limits might have changed if the view suddenly became a group or vice versa |
| 1305 | updateLimits(); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1306 | } |
| 1307 | |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 1308 | @Override |
Alan Viverette | a54956a | 2015-01-07 16:05:02 -0800 | [diff] [blame] | 1309 | public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event) { |
| 1310 | if (super.onRequestSendAccessibilityEventInternal(child, event)) { |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 1311 | // Add a record for the entire layout since its content is somehow small. |
| 1312 | // The event comes from a leaf view that is interacted with. |
| 1313 | AccessibilityEvent record = AccessibilityEvent.obtain(); |
| 1314 | onInitializeAccessibilityEvent(record); |
| 1315 | dispatchPopulateAccessibilityEvent(record); |
| 1316 | event.appendRecord(record); |
| 1317 | return true; |
| 1318 | } |
| 1319 | return false; |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 1320 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1321 | |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 1322 | @Override |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 1323 | public void setDark(boolean dark, boolean fade, long delay) { |
| 1324 | super.setDark(dark, fade, delay); |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 1325 | final NotificationContentView showing = getShowingLayout(); |
| 1326 | if (showing != null) { |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 1327 | showing.setDark(dark, fade, delay); |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 1328 | } |
Selim Cinek | 9c7712d | 2015-12-08 19:19:48 -0800 | [diff] [blame] | 1329 | if (mIsSummaryWithChildren) { |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 1330 | mChildrenContainer.setDark(dark, fade, delay); |
Selim Cinek | 9c7712d | 2015-12-08 19:19:48 -0800 | [diff] [blame] | 1331 | } |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 1332 | } |
| 1333 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1334 | public boolean isExpandable() { |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 1335 | if (mIsSummaryWithChildren && !mShowingPublic) { |
| 1336 | return !mChildrenExpanded; |
| 1337 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1338 | return mExpandable; |
| 1339 | } |
| 1340 | |
| 1341 | public void setExpandable(boolean expandable) { |
| 1342 | mExpandable = expandable; |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 1343 | mPrivateLayout.updateExpandButtons(isExpandable()); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1344 | } |
| 1345 | |
Selim Cinek | 4ffd636 | 2015-12-29 15:12:23 +0100 | [diff] [blame] | 1346 | @Override |
| 1347 | public void setClipToActualHeight(boolean clipToActualHeight) { |
Selim Cinek | 084c16b | 2016-01-22 17:48:22 -0800 | [diff] [blame] | 1348 | super.setClipToActualHeight(clipToActualHeight || isUserLocked()); |
| 1349 | getShowingLayout().setClipToActualHeight(clipToActualHeight || isUserLocked()); |
Selim Cinek | 4ffd636 | 2015-12-29 15:12:23 +0100 | [diff] [blame] | 1350 | } |
| 1351 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1352 | /** |
| 1353 | * @return whether the user has changed the expansion state |
| 1354 | */ |
| 1355 | public boolean hasUserChangedExpansion() { |
| 1356 | return mHasUserChangedExpansion; |
| 1357 | } |
| 1358 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1359 | public boolean isUserExpanded() { |
| 1360 | return mUserExpanded; |
| 1361 | } |
| 1362 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1363 | /** |
| 1364 | * Set this notification to be expanded by the user |
| 1365 | * |
| 1366 | * @param userExpanded whether the user wants this notification to be expanded |
| 1367 | */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1368 | public void setUserExpanded(boolean userExpanded) { |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 1369 | setUserExpanded(userExpanded, false /* allowChildExpansion */); |
| 1370 | } |
| 1371 | |
| 1372 | /** |
| 1373 | * Set this notification to be expanded by the user |
| 1374 | * |
| 1375 | * @param userExpanded whether the user wants this notification to be expanded |
| 1376 | * @param allowChildExpansion whether a call to this method allows expanding children |
| 1377 | */ |
| 1378 | public void setUserExpanded(boolean userExpanded, boolean allowChildExpansion) { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 1379 | mFalsingManager.setNotificationExpanded(); |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1380 | if (mIsSummaryWithChildren && !mShowingPublic && allowChildExpansion |
| 1381 | && !mChildrenContainer.showingAsLowPriority()) { |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame] | 1382 | final boolean wasExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification); |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 1383 | mGroupManager.setGroupExpanded(mStatusBarNotification, userExpanded); |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1384 | onExpansionChanged(true /* userAction */, wasExpanded); |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 1385 | return; |
| 1386 | } |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 1387 | if (userExpanded && !mExpandable) return; |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1388 | final boolean wasExpanded = isExpanded(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1389 | mHasUserChangedExpansion = true; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1390 | mUserExpanded = userExpanded; |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1391 | onExpansionChanged(true /* userAction */, wasExpanded); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1392 | } |
| 1393 | |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 1394 | public void resetUserExpansion() { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1395 | boolean changed = mUserExpanded; |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 1396 | mHasUserChangedExpansion = false; |
| 1397 | mUserExpanded = false; |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1398 | if (changed && mIsSummaryWithChildren) { |
| 1399 | mChildrenContainer.onExpansionChanged(); |
| 1400 | } |
| 1401 | updateShelfIconColor(); |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 1402 | } |
| 1403 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1404 | public boolean isUserLocked() { |
Selim Cinek | 1b2a05e | 2016-04-28 14:20:39 -0700 | [diff] [blame] | 1405 | return mUserLocked && !mForceUnlocked; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1406 | } |
| 1407 | |
| 1408 | public void setUserLocked(boolean userLocked) { |
| 1409 | mUserLocked = userLocked; |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 1410 | mPrivateLayout.setUserExpanding(userLocked); |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1411 | if (mIsSummaryWithChildren) { |
| 1412 | mChildrenContainer.setUserLocked(userLocked); |
Selim Cinek | 7baaa9e | 2016-07-21 17:21:09 -0700 | [diff] [blame] | 1413 | if (userLocked || !isGroupExpanded()) { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1414 | updateBackgroundForGroupState(); |
| 1415 | } |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1416 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1417 | } |
| 1418 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1419 | /** |
| 1420 | * @return has the system set this notification to be expanded |
| 1421 | */ |
| 1422 | public boolean isSystemExpanded() { |
| 1423 | return mIsSystemExpanded; |
| 1424 | } |
| 1425 | |
| 1426 | /** |
| 1427 | * Set this notification to be expanded by the system. |
| 1428 | * |
| 1429 | * @param expand whether the system wants this notification to be expanded. |
| 1430 | */ |
| 1431 | public void setSystemExpanded(boolean expand) { |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1432 | if (expand != mIsSystemExpanded) { |
| 1433 | final boolean wasExpanded = isExpanded(); |
| 1434 | mIsSystemExpanded = expand; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1435 | notifyHeightChanged(false /* needsAnimation */); |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1436 | onExpansionChanged(false /* userAction */, wasExpanded); |
Selim Cinek | ed6913b | 2016-06-01 12:01:17 -0700 | [diff] [blame] | 1437 | if (mIsSummaryWithChildren) { |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 1438 | mChildrenContainer.updateGroupOverflow(); |
| 1439 | } |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1440 | } |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 1441 | } |
| 1442 | |
| 1443 | /** |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1444 | * @param onKeyguard whether to prevent notification expansion |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 1445 | */ |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1446 | public void setOnKeyguard(boolean onKeyguard) { |
| 1447 | if (onKeyguard != mOnKeyguard) { |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1448 | final boolean wasExpanded = isExpanded(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1449 | mOnKeyguard = onKeyguard; |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1450 | onExpansionChanged(false /* userAction */, wasExpanded); |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1451 | if (wasExpanded != isExpanded()) { |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 1452 | if (mIsSummaryWithChildren) { |
| 1453 | mChildrenContainer.updateGroupOverflow(); |
| 1454 | } |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1455 | notifyHeightChanged(false /* needsAnimation */); |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1456 | } |
| 1457 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1458 | } |
| 1459 | |
| 1460 | /** |
Selim Cinek | 9e624e7 | 2016-07-20 13:46:49 -0700 | [diff] [blame] | 1461 | * @return Can the underlying notification be cleared? This can be different from whether the |
| 1462 | * notification can be dismissed in case notifications are sensitive on the lockscreen. |
| 1463 | * @see #canViewBeDismissed() |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 1464 | */ |
| 1465 | public boolean isClearable() { |
Selim Cinek | 506deb6 | 2016-07-20 15:43:59 -0700 | [diff] [blame] | 1466 | if (mStatusBarNotification == null || !mStatusBarNotification.isClearable()) { |
| 1467 | return false; |
| 1468 | } |
| 1469 | if (mIsSummaryWithChildren) { |
| 1470 | List<ExpandableNotificationRow> notificationChildren = |
| 1471 | mChildrenContainer.getNotificationChildren(); |
| 1472 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 1473 | ExpandableNotificationRow child = notificationChildren.get(i); |
| 1474 | if (!child.isClearable()) { |
| 1475 | return false; |
| 1476 | } |
| 1477 | } |
| 1478 | } |
| 1479 | return true; |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 1480 | } |
| 1481 | |
Jorim Jaggi | 9cbadd3 | 2014-05-01 20:18:31 +0200 | [diff] [blame] | 1482 | @Override |
| 1483 | public int getIntrinsicHeight() { |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1484 | if (isUserLocked()) { |
| 1485 | return getActualHeight(); |
| 1486 | } |
Geoffrey Pitsch | 4dd5006 | 2016-12-06 16:41:22 -0500 | [diff] [blame] | 1487 | if (mGuts != null && mGuts.isExposed()) { |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1488 | return mGuts.getHeight(); |
| 1489 | } else if ((isChildInGroup() && !isGroupExpanded())) { |
| 1490 | return mPrivateLayout.getMinHeight(); |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 1491 | } else if (mShowAmbient) { |
| 1492 | return getAmbientHeight(); |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1493 | } else if (mSensitive && mHideSensitiveForIntrinsicHeight) { |
| 1494 | return getMinHeight(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1495 | } else if (mIsSummaryWithChildren && !mOnKeyguard) { |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 1496 | return mChildrenContainer.getIntrinsicHeight(); |
Selim Cinek | 01ee2cd5 | 2016-12-21 18:23:11 +0100 | [diff] [blame] | 1497 | } else if (!mOnKeyguard && (mIsHeadsUp || mHeadsupDisappearRunning)) { |
Selim Cinek | 73cf02a | 2016-06-17 13:08:00 -0700 | [diff] [blame] | 1498 | if (isPinned() || mHeadsupDisappearRunning) { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 1499 | return getPinnedHeadsUpHeight(true /* atLeastMinHeight */); |
| 1500 | } else if (isExpanded()) { |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1501 | return Math.max(getMaxExpandHeight(), mHeadsUpHeight); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1502 | } else { |
Selim Cinek | 567e845 | 2016-03-24 10:54:56 -0700 | [diff] [blame] | 1503 | return Math.max(getCollapsedHeight(), mHeadsUpHeight); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1504 | } |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 1505 | } else if (isExpanded()) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1506 | return getMaxExpandHeight(); |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1507 | } else { |
Selim Cinek | 567e845 | 2016-03-24 10:54:56 -0700 | [diff] [blame] | 1508 | return getCollapsedHeight(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1509 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1510 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1511 | |
Mady Mellor | 43c2cd1 | 2016-12-12 21:05:13 -0800 | [diff] [blame] | 1512 | @Override |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1513 | public boolean isGroupExpanded() { |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 1514 | return mGroupManager.isGroupExpanded(mStatusBarNotification); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1515 | } |
| 1516 | |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 1517 | private void onChildrenCountChanged() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 1518 | mIsSummaryWithChildren = StatusBar.ENABLE_CHILD_NOTIFICATIONS |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1519 | && mChildrenContainer != null && mChildrenContainer.getNotificationChildCount() > 0; |
| 1520 | if (mIsSummaryWithChildren && mChildrenContainer.getHeaderView() == null) { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1521 | mChildrenContainer.recreateNotificationHeader(mExpandClickListener |
| 1522 | ); |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 1523 | } |
Mady Mellor | 6baed9e | 2016-05-25 16:05:09 -0700 | [diff] [blame] | 1524 | getShowingLayout().updateBackgroundColor(false /* animate */); |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 1525 | mPrivateLayout.updateExpandButtons(isExpandable()); |
Selim Cinek | ea4bef7 | 2015-12-02 15:51:10 -0800 | [diff] [blame] | 1526 | updateChildrenHeaderAppearance(); |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 1527 | updateChildrenVisibility(); |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 1528 | } |
| 1529 | |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1530 | public void updateChildrenHeaderAppearance() { |
Selim Cinek | ed6913b | 2016-06-01 12:01:17 -0700 | [diff] [blame] | 1531 | if (mIsSummaryWithChildren) { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1532 | mChildrenContainer.updateChildrenHeaderAppearance(); |
| 1533 | } |
| 1534 | } |
| 1535 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1536 | /** |
| 1537 | * Check whether the view state is currently expanded. This is given by the system in {@link |
| 1538 | * #setSystemExpanded(boolean)} and can be overridden by user expansion or |
| 1539 | * collapsing in {@link #setUserExpanded(boolean)}. Note that the visual appearance of this |
| 1540 | * view can differ from this state, if layout params are modified from outside. |
| 1541 | * |
| 1542 | * @return whether the view state is currently expanded. |
| 1543 | */ |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1544 | public boolean isExpanded() { |
Selim Cinek | e81b82b | 2016-03-04 11:22:28 -0800 | [diff] [blame] | 1545 | return isExpanded(false /* allowOnKeyguard */); |
| 1546 | } |
| 1547 | |
| 1548 | public boolean isExpanded(boolean allowOnKeyguard) { |
| 1549 | return (!mOnKeyguard || allowOnKeyguard) |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1550 | && (!hasUserChangedExpansion() && (isSystemExpanded() || isSystemChildExpanded()) |
| 1551 | || isUserExpanded()); |
| 1552 | } |
| 1553 | |
| 1554 | private boolean isSystemChildExpanded() { |
| 1555 | return mIsSystemChildExpanded; |
| 1556 | } |
| 1557 | |
| 1558 | public void setSystemChildExpanded(boolean expanded) { |
| 1559 | mIsSystemChildExpanded = expanded; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1560 | } |
| 1561 | |
| 1562 | @Override |
| 1563 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
| 1564 | super.onLayout(changed, left, top, right, bottom); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1565 | updateMaxHeights(); |
Mady Mellor | 95d743c | 2017-01-10 12:05:27 -0800 | [diff] [blame^] | 1566 | if (mMenuRow.getMenuView() != null) { |
| 1567 | mMenuRow.onHeightUpdate(); |
Mady Mellor | a6edc87 | 2016-04-26 11:01:03 -0700 | [diff] [blame] | 1568 | } |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1569 | updateContentShiftHeight(); |
| 1570 | } |
| 1571 | |
| 1572 | /** |
| 1573 | * Updates the content shift height such that the header is completely hidden when coming from |
| 1574 | * the top. |
| 1575 | */ |
| 1576 | private void updateContentShiftHeight() { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1577 | NotificationHeaderView notificationHeader = getVisibleNotificationHeader(); |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 1578 | if (notificationHeader != null) { |
| 1579 | CachingIconView icon = notificationHeader.getIcon(); |
| 1580 | mIconTransformContentShift = getRelativeTopPadding(icon) + icon.getHeight(); |
| 1581 | } else { |
| 1582 | mIconTransformContentShift = mIconTransformContentShiftNoIcon; |
| 1583 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1584 | } |
| 1585 | |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1586 | private void updateMaxHeights() { |
Selim Cinek | d2319fb | 2014-09-01 19:41:54 +0200 | [diff] [blame] | 1587 | int intrinsicBefore = getIntrinsicHeight(); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1588 | View expandedChild = mPrivateLayout.getExpandedChild(); |
| 1589 | if (expandedChild == null) { |
| 1590 | expandedChild = mPrivateLayout.getContractedChild(); |
| 1591 | } |
| 1592 | mMaxExpandHeight = expandedChild.getHeight(); |
| 1593 | View headsUpChild = mPrivateLayout.getHeadsUpChild(); |
Selim Cinek | 1f3f544 | 2015-04-10 17:54:46 -0700 | [diff] [blame] | 1594 | if (headsUpChild == null) { |
| 1595 | headsUpChild = mPrivateLayout.getContractedChild(); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1596 | } |
Selim Cinek | 1f3f544 | 2015-04-10 17:54:46 -0700 | [diff] [blame] | 1597 | mHeadsUpHeight = headsUpChild.getHeight(); |
Selim Cinek | d2319fb | 2014-09-01 19:41:54 +0200 | [diff] [blame] | 1598 | if (intrinsicBefore != getIntrinsicHeight()) { |
Selim Cinek | bb42b7d | 2016-08-10 13:02:38 -0700 | [diff] [blame] | 1599 | notifyHeightChanged(true /* needsAnimation */); |
Selim Cinek | d2319fb | 2014-09-01 19:41:54 +0200 | [diff] [blame] | 1600 | } |
| 1601 | } |
| 1602 | |
Selim Cinek | fa0a2d3 | 2016-01-14 13:02:21 -0800 | [diff] [blame] | 1603 | @Override |
| 1604 | public void notifyHeightChanged(boolean needsAnimation) { |
| 1605 | super.notifyHeightChanged(needsAnimation); |
| 1606 | getShowingLayout().requestSelectLayout(needsAnimation || isUserLocked()); |
| 1607 | } |
| 1608 | |
Selim Cinek | 3c76d50 | 2016-02-19 15:16:33 -0800 | [diff] [blame] | 1609 | public void setSensitive(boolean sensitive, boolean hideSensitive) { |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1610 | mSensitive = sensitive; |
Selim Cinek | 3c76d50 | 2016-02-19 15:16:33 -0800 | [diff] [blame] | 1611 | mSensitiveHiddenInGeneral = hideSensitive; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1612 | } |
| 1613 | |
Mady Mellor | 43c2cd1 | 2016-12-12 21:05:13 -0800 | [diff] [blame] | 1614 | @Override |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1615 | public void setHideSensitiveForIntrinsicHeight(boolean hideSensitive) { |
Selim Cinek | 60122be | 2015-04-15 18:16:50 -0700 | [diff] [blame] | 1616 | mHideSensitiveForIntrinsicHeight = hideSensitive; |
Selim Cinek | a52f6a1 | 2016-02-29 15:35:58 -0800 | [diff] [blame] | 1617 | if (mIsSummaryWithChildren) { |
| 1618 | List<ExpandableNotificationRow> notificationChildren = |
| 1619 | mChildrenContainer.getNotificationChildren(); |
| 1620 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 1621 | ExpandableNotificationRow child = notificationChildren.get(i); |
| 1622 | child.setHideSensitiveForIntrinsicHeight(hideSensitive); |
| 1623 | } |
| 1624 | } |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1625 | } |
| 1626 | |
Mady Mellor | 43c2cd1 | 2016-12-12 21:05:13 -0800 | [diff] [blame] | 1627 | @Override |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1628 | public void setHideSensitive(boolean hideSensitive, boolean animated, long delay, |
| 1629 | long duration) { |
| 1630 | boolean oldShowingPublic = mShowingPublic; |
| 1631 | mShowingPublic = mSensitive && hideSensitive; |
| 1632 | if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) { |
| 1633 | return; |
| 1634 | } |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1635 | |
| 1636 | // bail out if no public version |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1637 | if (mPublicLayout.getChildCount() == 0) return; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1638 | |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1639 | if (!animated) { |
| 1640 | mPublicLayout.animate().cancel(); |
| 1641 | mPrivateLayout.animate().cancel(); |
Selim Cinek | a554c70 | 2016-06-17 18:02:12 -0700 | [diff] [blame] | 1642 | if (mChildrenContainer != null) { |
| 1643 | mChildrenContainer.animate().cancel(); |
| 1644 | mChildrenContainer.setAlpha(1f); |
| 1645 | } |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1646 | mPublicLayout.setAlpha(1f); |
| 1647 | mPrivateLayout.setAlpha(1f); |
| 1648 | mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE); |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1649 | updateChildrenVisibility(); |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1650 | } else { |
| 1651 | animateShowingPublic(delay, duration); |
| 1652 | } |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 1653 | NotificationContentView showingLayout = getShowingLayout(); |
| 1654 | showingLayout.updateBackgroundColor(animated); |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 1655 | mPrivateLayout.updateExpandButtons(isExpandable()); |
Adrian Roos | e5726a2 | 2016-12-19 14:26:51 -0800 | [diff] [blame] | 1656 | showingLayout.setDark(isDark(), false /* animate */, 0 /* delay */); |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1657 | mShowingPublicInitialized = true; |
| 1658 | } |
| 1659 | |
| 1660 | private void animateShowingPublic(long delay, long duration) { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1661 | View[] privateViews = mIsSummaryWithChildren |
| 1662 | ? new View[] {mChildrenContainer} |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1663 | : new View[] {mPrivateLayout}; |
| 1664 | View[] publicViews = new View[] {mPublicLayout}; |
| 1665 | View[] hiddenChildren = mShowingPublic ? privateViews : publicViews; |
| 1666 | View[] shownChildren = mShowingPublic ? publicViews : privateViews; |
| 1667 | for (final View hiddenView : hiddenChildren) { |
| 1668 | hiddenView.setVisibility(View.VISIBLE); |
| 1669 | hiddenView.animate().cancel(); |
| 1670 | hiddenView.animate() |
| 1671 | .alpha(0f) |
| 1672 | .setStartDelay(delay) |
| 1673 | .setDuration(duration) |
| 1674 | .withEndAction(new Runnable() { |
| 1675 | @Override |
| 1676 | public void run() { |
| 1677 | hiddenView.setVisibility(View.INVISIBLE); |
| 1678 | } |
| 1679 | }); |
| 1680 | } |
| 1681 | for (View showView : shownChildren) { |
| 1682 | showView.setVisibility(View.VISIBLE); |
| 1683 | showView.setAlpha(0f); |
| 1684 | showView.animate().cancel(); |
| 1685 | showView.animate() |
| 1686 | .alpha(1f) |
| 1687 | .setStartDelay(delay) |
| 1688 | .setDuration(duration); |
| 1689 | } |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 1690 | } |
| 1691 | |
Mady Mellor | 43c2cd1 | 2016-12-12 21:05:13 -0800 | [diff] [blame] | 1692 | @Override |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 1693 | public boolean mustStayOnScreen() { |
| 1694 | return mIsHeadsUp; |
| 1695 | } |
| 1696 | |
Selim Cinek | 9e624e7 | 2016-07-20 13:46:49 -0700 | [diff] [blame] | 1697 | /** |
| 1698 | * @return Whether this view is allowed to be dismissed. Only valid for visible notifications as |
| 1699 | * otherwise some state might not be updated. To request about the general clearability |
| 1700 | * see {@link #isClearable()}. |
| 1701 | */ |
| 1702 | public boolean canViewBeDismissed() { |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 1703 | return isClearable() && (!mShowingPublic || !mSensitiveHiddenInGeneral); |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1704 | } |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 1705 | |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 1706 | public void makeActionsVisibile() { |
| 1707 | setUserExpanded(true, true); |
| 1708 | if (isChildInGroup()) { |
| 1709 | mGroupManager.setGroupExpanded(mStatusBarNotification, true); |
| 1710 | } |
Selim Cinek | bb42b7d | 2016-08-10 13:02:38 -0700 | [diff] [blame] | 1711 | notifyHeightChanged(false /* needsAnimation */); |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 1712 | } |
| 1713 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1714 | public void setChildrenExpanded(boolean expanded, boolean animate) { |
| 1715 | mChildrenExpanded = expanded; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1716 | if (mChildrenContainer != null) { |
| 1717 | mChildrenContainer.setChildrenExpanded(expanded); |
| 1718 | } |
Mady Mellor | 1a5d8ea | 2016-06-09 10:42:42 -0700 | [diff] [blame] | 1719 | updateBackgroundForGroupState(); |
Selim Cinek | ddf1b39 | 2016-05-27 16:33:10 -0700 | [diff] [blame] | 1720 | updateClickAndFocus(); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1721 | } |
| 1722 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1723 | public static void applyTint(View v, int color) { |
| 1724 | int alpha; |
| 1725 | if (color != 0) { |
| 1726 | alpha = COLORED_DIVIDER_ALPHA; |
| 1727 | } else { |
| 1728 | color = 0xff000000; |
| 1729 | alpha = DEFAULT_DIVIDER_ALPHA; |
| 1730 | } |
| 1731 | if (v.getBackground() instanceof ColorDrawable) { |
| 1732 | ColorDrawable background = (ColorDrawable) v.getBackground(); |
| 1733 | background.mutate(); |
| 1734 | background.setColor(color); |
| 1735 | background.setAlpha(alpha); |
| 1736 | } |
| 1737 | } |
| 1738 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1739 | public int getMaxExpandHeight() { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1740 | return mMaxExpandHeight; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1741 | } |
Jorim Jaggi | 584a7aa | 2014-04-10 23:26:13 +0200 | [diff] [blame] | 1742 | |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 1743 | public boolean areGutsExposed() { |
Geoffrey Pitsch | 4dd5006 | 2016-12-06 16:41:22 -0500 | [diff] [blame] | 1744 | return (mGuts != null && mGuts.isExposed()); |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 1745 | } |
| 1746 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1747 | @Override |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1748 | public boolean isContentExpandable() { |
Selim Cinek | c0ac4af | 2017-03-03 15:13:48 -0800 | [diff] [blame] | 1749 | if (mIsSummaryWithChildren && !mShowingPublic) { |
| 1750 | return true; |
| 1751 | } |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 1752 | NotificationContentView showingLayout = getShowingLayout(); |
| 1753 | return showingLayout.isContentExpandable(); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1754 | } |
| 1755 | |
| 1756 | @Override |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 1757 | protected View getContentView() { |
Selim Cinek | aa3901a | 2016-08-05 11:04:37 -0700 | [diff] [blame] | 1758 | if (mIsSummaryWithChildren && !mShowingPublic) { |
Selim Cinek | a570318 | 2016-05-11 21:23:16 -0400 | [diff] [blame] | 1759 | return mChildrenContainer; |
| 1760 | } |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 1761 | return getShowingLayout(); |
| 1762 | } |
| 1763 | |
| 1764 | @Override |
Selim Cinek | aa3901a | 2016-08-05 11:04:37 -0700 | [diff] [blame] | 1765 | protected void onAppearAnimationFinished(boolean wasAppearing) { |
| 1766 | super.onAppearAnimationFinished(wasAppearing); |
| 1767 | if (wasAppearing) { |
| 1768 | // During the animation the visible view might have changed, so let's make sure all |
| 1769 | // alphas are reset |
| 1770 | if (mChildrenContainer != null) { |
| 1771 | mChildrenContainer.setAlpha(1.0f); |
| 1772 | mChildrenContainer.setLayerType(LAYER_TYPE_NONE, null); |
| 1773 | } |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1774 | for (NotificationContentView l : mLayouts) { |
| 1775 | l.setAlpha(1.0f); |
| 1776 | l.setLayerType(LAYER_TYPE_NONE, null); |
| 1777 | } |
Selim Cinek | aa3901a | 2016-08-05 11:04:37 -0700 | [diff] [blame] | 1778 | } |
| 1779 | } |
| 1780 | |
| 1781 | @Override |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1782 | public int getExtraBottomPadding() { |
| 1783 | if (mIsSummaryWithChildren && isGroupExpanded()) { |
| 1784 | return mIncreasedPaddingBetweenElements; |
| 1785 | } |
| 1786 | return 0; |
| 1787 | } |
| 1788 | |
| 1789 | @Override |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 1790 | public void setActualHeight(int height, boolean notifyListeners) { |
Selim Cinek | 4ca6c63 | 2017-02-23 18:03:37 -0800 | [diff] [blame] | 1791 | boolean changed = height != getActualHeight(); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1792 | super.setActualHeight(height, notifyListeners); |
Selim Cinek | 4ca6c63 | 2017-02-23 18:03:37 -0800 | [diff] [blame] | 1793 | if (changed && isRemoved()) { |
| 1794 | // TODO: remove this once we found the gfx bug for this. |
| 1795 | // This is a hack since a removed view sometimes would just stay blank. it occured |
| 1796 | // when sending yourself a message and then clicking on it. |
| 1797 | ViewGroup parent = (ViewGroup) getParent(); |
| 1798 | if (parent != null) { |
| 1799 | parent.invalidate(); |
| 1800 | } |
| 1801 | } |
Geoffrey Pitsch | 4dd5006 | 2016-12-06 16:41:22 -0500 | [diff] [blame] | 1802 | if (mGuts != null && mGuts.isExposed()) { |
Mady Mellor | b53bc27 | 2016-02-11 18:28:23 -0800 | [diff] [blame] | 1803 | mGuts.setActualHeight(height); |
| 1804 | return; |
| 1805 | } |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 1806 | int contentHeight = Math.max(getMinHeight(), height); |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1807 | for (NotificationContentView l : mLayouts) { |
| 1808 | l.setContentHeight(contentHeight); |
| 1809 | } |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1810 | if (mIsSummaryWithChildren) { |
| 1811 | mChildrenContainer.setActualHeight(height); |
| 1812 | } |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1813 | if (mGuts != null) { |
| 1814 | mGuts.setActualHeight(height); |
| 1815 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1816 | } |
| 1817 | |
| 1818 | @Override |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1819 | public int getMaxContentHeight() { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1820 | if (mIsSummaryWithChildren && !mShowingPublic) { |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 1821 | return mChildrenContainer.getMaxContentHeight(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1822 | } |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 1823 | NotificationContentView showingLayout = getShowingLayout(); |
| 1824 | return showingLayout.getMaxHeight(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1825 | } |
| 1826 | |
| 1827 | @Override |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1828 | public int getMinHeight() { |
Selim Cinek | 01ee2cd5 | 2016-12-21 18:23:11 +0100 | [diff] [blame] | 1829 | if (!mOnKeyguard && mIsHeadsUp && mHeadsUpManager.isTrackingHeadsUp()) { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 1830 | return getPinnedHeadsUpHeight(false /* atLeastMinHeight */); |
| 1831 | } else if (mIsSummaryWithChildren && !isGroupExpanded() && !mShowingPublic) { |
Selim Cinek | b55386d | 2015-12-16 17:26:49 -0800 | [diff] [blame] | 1832 | return mChildrenContainer.getMinHeight(); |
Selim Cinek | 01ee2cd5 | 2016-12-21 18:23:11 +0100 | [diff] [blame] | 1833 | } else if (!mOnKeyguard && mIsHeadsUp) { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 1834 | return mHeadsUpHeight; |
Selim Cinek | b55386d | 2015-12-16 17:26:49 -0800 | [diff] [blame] | 1835 | } |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 1836 | NotificationContentView showingLayout = getShowingLayout(); |
| 1837 | return showingLayout.getMinHeight(); |
| 1838 | } |
| 1839 | |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 1840 | private int getAmbientHeight() { |
| 1841 | NotificationContentView showingLayout = getShowingLayout(); |
| 1842 | return showingLayout.getAmbientChild() != null |
| 1843 | ? showingLayout.getAmbientChild().getHeight() |
| 1844 | : getCollapsedHeight(); |
| 1845 | } |
| 1846 | |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 1847 | @Override |
Selim Cinek | 567e845 | 2016-03-24 10:54:56 -0700 | [diff] [blame] | 1848 | public int getCollapsedHeight() { |
Selim Cinek | 2c58461 | 2016-02-29 16:14:25 -0800 | [diff] [blame] | 1849 | if (mIsSummaryWithChildren && !mShowingPublic) { |
Selim Cinek | 567e845 | 2016-03-24 10:54:56 -0700 | [diff] [blame] | 1850 | return mChildrenContainer.getCollapsedHeight(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1851 | } |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 1852 | return getMinHeight(); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1853 | } |
| 1854 | |
| 1855 | @Override |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1856 | public void setClipTopAmount(int clipTopAmount) { |
| 1857 | super.setClipTopAmount(clipTopAmount); |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1858 | for (NotificationContentView l : mLayouts) { |
| 1859 | l.setClipTopAmount(clipTopAmount); |
| 1860 | } |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1861 | if (mGuts != null) { |
| 1862 | mGuts.setClipTopAmount(clipTopAmount); |
| 1863 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1864 | } |
| 1865 | |
Selim Cinek | a686b2c | 2016-10-26 13:58:27 -0700 | [diff] [blame] | 1866 | @Override |
| 1867 | public void setClipBottomAmount(int clipBottomAmount) { |
Selim Cinek | 65d418e | 2016-11-29 15:42:34 -0800 | [diff] [blame] | 1868 | if (clipBottomAmount != mClipBottomAmount) { |
| 1869 | super.setClipBottomAmount(clipBottomAmount); |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1870 | for (NotificationContentView l : mLayouts) { |
| 1871 | l.setClipBottomAmount(clipBottomAmount); |
| 1872 | } |
Selim Cinek | 65d418e | 2016-11-29 15:42:34 -0800 | [diff] [blame] | 1873 | if (mGuts != null) { |
| 1874 | mGuts.setClipBottomAmount(clipBottomAmount); |
| 1875 | } |
Selim Cinek | a686b2c | 2016-10-26 13:58:27 -0700 | [diff] [blame] | 1876 | } |
Selim Cinek | b3dadcc | 2016-11-21 17:21:13 -0800 | [diff] [blame] | 1877 | if (mChildrenContainer != null) { |
Selim Cinek | 65d418e | 2016-11-29 15:42:34 -0800 | [diff] [blame] | 1878 | // We have to update this even if it hasn't changed, since the children locations can |
| 1879 | // have changed |
Selim Cinek | b3dadcc | 2016-11-21 17:21:13 -0800 | [diff] [blame] | 1880 | mChildrenContainer.setClipBottomAmount(clipBottomAmount); |
| 1881 | } |
Selim Cinek | a686b2c | 2016-10-26 13:58:27 -0700 | [diff] [blame] | 1882 | } |
| 1883 | |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1884 | public boolean isMaxExpandHeightInitialized() { |
| 1885 | return mMaxExpandHeight != 0; |
Selim Cinek | 7d44772 | 2014-06-10 15:51:59 +0200 | [diff] [blame] | 1886 | } |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 1887 | |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1888 | public NotificationContentView getShowingLayout() { |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 1889 | return mShowingPublic ? mPublicLayout : mPrivateLayout; |
| 1890 | } |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1891 | |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1892 | public void setLegacy(boolean legacy) { |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1893 | for (NotificationContentView l : mLayouts) { |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1894 | l.setLegacy(legacy); |
Adrian Roos | eb434ff | 2017-01-11 11:18:48 -0800 | [diff] [blame] | 1895 | } |
Jorim Jaggi | 59ec304 | 2015-06-05 15:18:43 -0700 | [diff] [blame] | 1896 | } |
| 1897 | |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 1898 | @Override |
| 1899 | protected void updateBackgroundTint() { |
| 1900 | super.updateBackgroundTint(); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1901 | updateBackgroundForGroupState(); |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 1902 | if (mIsSummaryWithChildren) { |
| 1903 | List<ExpandableNotificationRow> notificationChildren = |
| 1904 | mChildrenContainer.getNotificationChildren(); |
| 1905 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 1906 | ExpandableNotificationRow child = notificationChildren.get(i); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1907 | child.updateBackgroundForGroupState(); |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 1908 | } |
| 1909 | } |
| 1910 | } |
| 1911 | |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1912 | /** |
| 1913 | * Called when a group has finished animating from collapsed or expanded state. |
| 1914 | */ |
| 1915 | public void onFinishedExpansionChange() { |
| 1916 | mGroupExpansionChanging = false; |
| 1917 | updateBackgroundForGroupState(); |
| 1918 | } |
| 1919 | |
| 1920 | /** |
| 1921 | * Updates the parent and children backgrounds in a group based on the expansion state. |
| 1922 | */ |
| 1923 | public void updateBackgroundForGroupState() { |
| 1924 | if (mIsSummaryWithChildren) { |
| 1925 | // Only when the group has finished expanding do we hide its background. |
| 1926 | mShowNoBackground = isGroupExpanded() && !isGroupExpansionChanging() && !isUserLocked(); |
| 1927 | mChildrenContainer.updateHeaderForExpansion(mShowNoBackground); |
| 1928 | List<ExpandableNotificationRow> children = mChildrenContainer.getNotificationChildren(); |
| 1929 | for (int i = 0; i < children.size(); i++) { |
| 1930 | children.get(i).updateBackgroundForGroupState(); |
| 1931 | } |
| 1932 | } else if (isChildInGroup()) { |
| 1933 | final int childColor = getShowingLayout().getBackgroundColorForExpansionState(); |
| 1934 | // Only show a background if the group is expanded OR if it is expanding / collapsing |
| 1935 | // and has a custom background color |
| 1936 | final boolean showBackground = isGroupExpanded() |
| 1937 | || ((mNotificationParent.isGroupExpansionChanging() |
| 1938 | || mNotificationParent.isUserLocked()) && childColor != 0); |
| 1939 | mShowNoBackground = !showBackground; |
| 1940 | } else { |
| 1941 | // Only children or parents ever need no background. |
| 1942 | mShowNoBackground = false; |
| 1943 | } |
| 1944 | updateOutline(); |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 1945 | updateBackground(); |
| 1946 | } |
| 1947 | |
Adrian Roos | 4a57967 | 2016-05-24 16:54:37 -0700 | [diff] [blame] | 1948 | public int getPositionOfChild(ExpandableNotificationRow childRow) { |
| 1949 | if (mIsSummaryWithChildren) { |
| 1950 | return mChildrenContainer.getPositionInLinearLayout(childRow); |
| 1951 | } |
| 1952 | return 0; |
| 1953 | } |
| 1954 | |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1955 | public void setExpansionLogger(ExpansionLogger logger, String key) { |
| 1956 | mLogger = logger; |
| 1957 | mLoggingKey = key; |
| 1958 | } |
| 1959 | |
Chris Wren | 6abeeb9 | 2016-05-26 14:44:38 -0400 | [diff] [blame] | 1960 | public void onExpandedByGesture(boolean userExpanded) { |
| 1961 | int event = MetricsEvent.ACTION_NOTIFICATION_GESTURE_EXPANDER; |
| 1962 | if (mGroupManager.isSummaryOfGroup(getStatusBarNotification())) { |
| 1963 | event = MetricsEvent.ACTION_NOTIFICATION_GROUP_GESTURE_EXPANDER; |
| 1964 | } |
| 1965 | MetricsLogger.action(mContext, event, userExpanded); |
| 1966 | } |
| 1967 | |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 1968 | @Override |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1969 | public float getIncreasedPaddingAmount() { |
| 1970 | if (mIsSummaryWithChildren) { |
| 1971 | if (isGroupExpanded()) { |
| 1972 | return 1.0f; |
| 1973 | } else if (isUserLocked()) { |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1974 | return mChildrenContainer.getIncreasedPaddingAmount(); |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1975 | } |
Selim Cinek | 9910483 | 2017-01-25 14:47:33 -0800 | [diff] [blame] | 1976 | } else if (isColorized() && (!mIsLowPriority || isExpanded())) { |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 1977 | return -1.0f; |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1978 | } |
| 1979 | return 0.0f; |
Selim Cinek | 61633a8 | 2016-01-25 15:54:10 -0800 | [diff] [blame] | 1980 | } |
| 1981 | |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 1982 | private boolean isColorized() { |
Selim Cinek | 9910483 | 2017-01-25 14:47:33 -0800 | [diff] [blame] | 1983 | return mIsColorized && mBgTint != NO_COLOR; |
Selim Cinek | a7ed2c1 | 2017-01-23 20:47:24 -0800 | [diff] [blame] | 1984 | } |
| 1985 | |
Selim Cinek | 61633a8 | 2016-01-25 15:54:10 -0800 | [diff] [blame] | 1986 | @Override |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 1987 | protected boolean disallowSingleClick(MotionEvent event) { |
| 1988 | float x = event.getX(); |
| 1989 | float y = event.getY(); |
Selim Cinek | 34eda5e | 2016-02-18 17:10:43 -0800 | [diff] [blame] | 1990 | NotificationHeaderView header = getVisibleNotificationHeader(); |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 1991 | if (header != null) { |
Mady Mellor | a883351 | 2016-03-09 09:50:18 -0800 | [diff] [blame] | 1992 | return header.isInTouchRect(x - getTranslation(), y); |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 1993 | } |
| 1994 | return super.disallowSingleClick(event); |
| 1995 | } |
| 1996 | |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1997 | private void onExpansionChanged(boolean userAction, boolean wasExpanded) { |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame] | 1998 | boolean nowExpanded = isExpanded(); |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1999 | if (mIsSummaryWithChildren && (!mIsLowPriority || wasExpanded)) { |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame] | 2000 | nowExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification); |
| 2001 | } |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 2002 | if (nowExpanded != wasExpanded) { |
| 2003 | updateShelfIconColor(); |
| 2004 | if (mLogger != null) { |
| 2005 | mLogger.logNotificationExpansion(mLoggingKey, userAction, nowExpanded); |
| 2006 | } |
| 2007 | if (mIsSummaryWithChildren) { |
| 2008 | mChildrenContainer.onExpansionChanged(); |
| 2009 | } |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 2010 | } |
| 2011 | } |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 2012 | |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 2013 | @Override |
| 2014 | public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { |
| 2015 | super.onInitializeAccessibilityNodeInfoInternal(info); |
| 2016 | if (canViewBeDismissed()) { |
| 2017 | info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_DISMISS); |
| 2018 | } |
Selim Cinek | c0ac4af | 2017-03-03 15:13:48 -0800 | [diff] [blame] | 2019 | boolean expandable = mShowingPublic; |
| 2020 | boolean isExpanded = false; |
| 2021 | if (!expandable) { |
| 2022 | if (mIsSummaryWithChildren) { |
| 2023 | expandable = true; |
| 2024 | if (!mIsLowPriority || isExpanded()) { |
| 2025 | isExpanded = isGroupExpanded(); |
| 2026 | } |
| 2027 | } else { |
| 2028 | expandable = mPrivateLayout.isContentExpandable(); |
| 2029 | isExpanded = isExpanded(); |
| 2030 | } |
| 2031 | } |
| 2032 | if (expandable) { |
| 2033 | if (isExpanded) { |
| 2034 | info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_COLLAPSE); |
| 2035 | } else { |
| 2036 | info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND); |
| 2037 | } |
| 2038 | } |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 2039 | } |
| 2040 | |
| 2041 | @Override |
| 2042 | public boolean performAccessibilityActionInternal(int action, Bundle arguments) { |
| 2043 | if (super.performAccessibilityActionInternal(action, arguments)) { |
| 2044 | return true; |
| 2045 | } |
| 2046 | switch (action) { |
| 2047 | case AccessibilityNodeInfo.ACTION_DISMISS: |
| 2048 | NotificationStackScrollLayout.performDismiss(this, mGroupManager, |
| 2049 | true /* fromAccessibility */); |
| 2050 | return true; |
Selim Cinek | c0ac4af | 2017-03-03 15:13:48 -0800 | [diff] [blame] | 2051 | case AccessibilityNodeInfo.ACTION_COLLAPSE: |
| 2052 | case AccessibilityNodeInfo.ACTION_EXPAND: |
| 2053 | mExpandClickListener.onClick(this); |
| 2054 | return true; |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 2055 | } |
| 2056 | return false; |
| 2057 | } |
| 2058 | |
| 2059 | public boolean shouldRefocusOnDismiss() { |
| 2060 | return mRefocusOnDismiss || isAccessibilityFocused(); |
| 2061 | } |
| 2062 | |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 2063 | public interface OnExpandClickListener { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 2064 | void onExpandClicked(NotificationData.Entry clickedEntry, boolean nowExpanded); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 2065 | } |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 2066 | |
| 2067 | @Override |
| 2068 | public ExpandableViewState createNewViewState(StackScrollState stackScrollState) { |
| 2069 | return new NotificationViewState(stackScrollState); |
| 2070 | } |
| 2071 | |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 2072 | @Override |
| 2073 | public boolean isAboveShelf() { |
Selim Cinek | c8007c5 | 2017-02-28 16:09:56 -0800 | [diff] [blame] | 2074 | return !isOnKeyguard() |
| 2075 | && (mIsPinned || mHeadsupDisappearRunning || (mIsHeadsUp && mAboveShelf)); |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 2076 | } |
| 2077 | |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 2078 | public void setShowAmbient(boolean showAmbient) { |
| 2079 | if (showAmbient != mShowAmbient) { |
| 2080 | mShowAmbient = showAmbient; |
| 2081 | notifyHeightChanged(false /* needsAnimation */); |
| 2082 | } |
| 2083 | } |
| 2084 | |
Selim Cinek | d127d79 | 2016-11-01 19:11:41 -0700 | [diff] [blame] | 2085 | public void setAboveShelf(boolean aboveShelf) { |
| 2086 | mAboveShelf = aboveShelf; |
| 2087 | } |
| 2088 | |
Selim Cinek | d4776a5 | 2017-02-14 18:50:16 -0800 | [diff] [blame] | 2089 | public static class NotificationViewState extends ExpandableViewState { |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 2090 | |
| 2091 | private final StackScrollState mOverallState; |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 2092 | |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 2093 | |
| 2094 | private NotificationViewState(StackScrollState stackScrollState) { |
| 2095 | mOverallState = stackScrollState; |
| 2096 | } |
| 2097 | |
| 2098 | @Override |
| 2099 | public void applyToView(View view) { |
| 2100 | super.applyToView(view); |
| 2101 | if (view instanceof ExpandableNotificationRow) { |
| 2102 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 2103 | row.applyChildrenState(mOverallState); |
| 2104 | } |
| 2105 | } |
Selim Cinek | 0cfbef4 | 2016-11-09 19:06:36 -0800 | [diff] [blame] | 2106 | |
| 2107 | @Override |
Selim Cinek | 2b549f4 | 2016-11-22 16:38:51 -0800 | [diff] [blame] | 2108 | protected void onYTranslationAnimationFinished(View view) { |
| 2109 | super.onYTranslationAnimationFinished(view); |
Selim Cinek | d4776a5 | 2017-02-14 18:50:16 -0800 | [diff] [blame] | 2110 | if (view instanceof ExpandableNotificationRow) { |
| 2111 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
| 2112 | if (row.isHeadsUpAnimatingAway()) { |
| 2113 | row.setHeadsUpAnimatingAway(false); |
| 2114 | } |
Selim Cinek | 0cfbef4 | 2016-11-09 19:06:36 -0800 | [diff] [blame] | 2115 | } |
| 2116 | } |
| 2117 | |
| 2118 | @Override |
| 2119 | public void animateTo(View child, AnimationProperties properties) { |
| 2120 | super.animateTo(child, properties); |
| 2121 | if (child instanceof ExpandableNotificationRow) { |
| 2122 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 2123 | row.startChildAnimation(mOverallState, properties); |
| 2124 | } |
| 2125 | } |
Selim Cinek | bbcebde | 2016-11-09 18:28:20 -0800 | [diff] [blame] | 2126 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 2127 | } |