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 | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame^] | 19 | import android.app.Notification; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 20 | import android.content.Context; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 21 | import android.graphics.drawable.AnimatedVectorDrawable; |
| 22 | import android.graphics.drawable.AnimationDrawable; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 23 | import android.graphics.drawable.ColorDrawable; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 24 | import android.graphics.drawable.Drawable; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 25 | import android.service.notification.StatusBarNotification; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 26 | import android.util.AttributeSet; |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 27 | import android.view.MotionEvent; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 28 | import android.view.View; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 29 | import android.view.ViewStub; |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 30 | import android.view.accessibility.AccessibilityEvent; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 31 | import android.view.animation.LinearInterpolator; |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 32 | import android.widget.Chronometer; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 33 | import android.widget.ImageView; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 34 | |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 35 | import com.android.systemui.R; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 36 | import com.android.systemui.classifier.FalsingManager; |
Selim Cinek | 8d6440d | 2015-10-22 13:00:05 -0700 | [diff] [blame] | 37 | import com.android.systemui.statusbar.notification.NotificationHeaderView; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 38 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 39 | import com.android.systemui.statusbar.stack.NotificationChildrenContainer; |
| 40 | import com.android.systemui.statusbar.stack.StackScrollState; |
| 41 | import com.android.systemui.statusbar.stack.StackStateAnimator; |
| 42 | import com.android.systemui.statusbar.stack.StackViewState; |
| 43 | |
| 44 | import java.util.List; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 45 | |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 46 | public class ExpandableNotificationRow extends ActivatableNotificationView { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 47 | |
| 48 | private static final int DEFAULT_DIVIDER_ALPHA = 0x29; |
| 49 | private static final int COLORED_DIVIDER_ALPHA = 0x7B; |
| 50 | private final LinearInterpolator mLinearInterpolator = new LinearInterpolator(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 51 | private int mRowMinHeight; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 52 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 53 | /** Does this row contain layouts that can adapt to row expansion */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 54 | private boolean mExpandable; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 55 | /** Has the user actively changed the expansion state of this row */ |
| 56 | private boolean mHasUserChangedExpansion; |
| 57 | /** If {@link #mHasUserChangedExpansion}, has the user expanded this row */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 58 | private boolean mUserExpanded; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 59 | /** Is the user touching this row */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 60 | private boolean mUserLocked; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 61 | /** Are we showing the "public" version */ |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 62 | private boolean mShowingPublic; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 63 | private boolean mSensitive; |
| 64 | private boolean mShowingPublicInitialized; |
Selim Cinek | 60122be | 2015-04-15 18:16:50 -0700 | [diff] [blame] | 65 | private boolean mHideSensitiveForIntrinsicHeight; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 66 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 67 | /** |
| 68 | * Is this notification expanded by the system. The expansion state can be overridden by the |
| 69 | * user expansion. |
| 70 | */ |
| 71 | private boolean mIsSystemExpanded; |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 72 | |
| 73 | /** |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 74 | * Whether the notification is on the keyguard and the expansion is disabled. |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 75 | */ |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 76 | private boolean mOnKeyguard; |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 77 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 78 | private NotificationContentView mPublicLayout; |
| 79 | private NotificationContentView mPrivateLayout; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 80 | private int mMaxExpandHeight; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 81 | private int mHeadsUpHeight; |
Selim Cinek | 863834b | 2014-05-20 04:20:25 +0200 | [diff] [blame] | 82 | private View mVetoButton; |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 83 | private boolean mClearable; |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 84 | private ExpansionLogger mLogger; |
| 85 | private String mLoggingKey; |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 86 | private boolean mWasReset; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 87 | private NotificationGuts mGuts; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 88 | private StatusBarNotification mStatusBarNotification; |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 89 | private boolean mIsHeadsUp; |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 90 | private boolean mLastChronometerRunning = true; |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 91 | private NotificationHeaderView mNotificationHeader; |
| 92 | private ViewStub mNotificationHeaderStub; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 93 | private ViewStub mChildrenContainerStub; |
| 94 | private NotificationGroupManager mGroupManager; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 95 | private boolean mChildrenExpanded; |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 96 | private boolean mIsSummaryWithChildren; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 97 | private NotificationChildrenContainer mChildrenContainer; |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 98 | private ViewStub mGutsStub; |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 99 | private boolean mHasNotificationHeader; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 100 | private boolean mIsSystemChildExpanded; |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 101 | private boolean mIsPinned; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 102 | private FalsingManager mFalsingManager; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 103 | |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 104 | private boolean mJustClicked; |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 105 | private NotificationData.Entry mEntry; |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 106 | private boolean mShowNoBackground; |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 107 | private ExpandableNotificationRow mNotificationParent; |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 108 | |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 109 | public NotificationContentView getPrivateLayout() { |
| 110 | return mPrivateLayout; |
| 111 | } |
| 112 | |
| 113 | public NotificationContentView getPublicLayout() { |
| 114 | return mPublicLayout; |
| 115 | } |
| 116 | |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 117 | public void setIconAnimationRunning(boolean running) { |
| 118 | setIconAnimationRunning(running, mPublicLayout); |
| 119 | setIconAnimationRunning(running, mPrivateLayout); |
| 120 | } |
| 121 | |
| 122 | private void setIconAnimationRunning(boolean running, NotificationContentView layout) { |
| 123 | if (layout != null) { |
| 124 | View contractedChild = layout.getContractedChild(); |
| 125 | View expandedChild = layout.getExpandedChild(); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 126 | View headsUpChild = layout.getHeadsUpChild(); |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 127 | setIconAnimationRunningForChild(running, contractedChild); |
| 128 | setIconAnimationRunningForChild(running, expandedChild); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 129 | setIconAnimationRunningForChild(running, headsUpChild); |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 130 | } |
| 131 | } |
| 132 | |
| 133 | private void setIconAnimationRunningForChild(boolean running, View child) { |
| 134 | if (child != null) { |
| 135 | ImageView icon = (ImageView) child.findViewById(com.android.internal.R.id.icon); |
| 136 | setIconRunning(icon, running); |
| 137 | ImageView rightIcon = (ImageView) child.findViewById( |
| 138 | com.android.internal.R.id.right_icon); |
| 139 | setIconRunning(rightIcon, running); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | private void setIconRunning(ImageView imageView, boolean running) { |
| 144 | if (imageView != null) { |
| 145 | Drawable drawable = imageView.getDrawable(); |
| 146 | if (drawable instanceof AnimationDrawable) { |
| 147 | AnimationDrawable animationDrawable = (AnimationDrawable) drawable; |
| 148 | if (running) { |
| 149 | animationDrawable.start(); |
| 150 | } else { |
| 151 | animationDrawable.stop(); |
| 152 | } |
| 153 | } else if (drawable instanceof AnimatedVectorDrawable) { |
| 154 | AnimatedVectorDrawable animationDrawable = (AnimatedVectorDrawable) drawable; |
| 155 | if (running) { |
| 156 | animationDrawable.start(); |
| 157 | } else { |
| 158 | animationDrawable.stop(); |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 164 | private void setStatusBarNotification(StatusBarNotification statusBarNotification) { |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 165 | mStatusBarNotification = statusBarNotification; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 166 | mPrivateLayout.setStatusBarNotification(statusBarNotification); |
Selim Cinek | a37774f | 2014-11-11 19:16:18 +0100 | [diff] [blame] | 167 | updateVetoButton(); |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 168 | onChildrenCountChanged(); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | public StatusBarNotification getStatusBarNotification() { |
| 172 | return mStatusBarNotification; |
| 173 | } |
| 174 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 175 | public boolean isHeadsUp() { |
| 176 | return mIsHeadsUp; |
| 177 | } |
| 178 | |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 179 | public void setHeadsUp(boolean isHeadsUp) { |
Selim Cinek | c80fdb1 | 2015-04-13 15:09:08 -0700 | [diff] [blame] | 180 | int intrinsicBefore = getIntrinsicHeight(); |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 181 | mIsHeadsUp = isHeadsUp; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 182 | mPrivateLayout.setHeadsUp(isHeadsUp); |
Selim Cinek | c80fdb1 | 2015-04-13 15:09:08 -0700 | [diff] [blame] | 183 | if (intrinsicBefore != getIntrinsicHeight()) { |
| 184 | notifyHeightChanged(false /* needsAnimation */); |
| 185 | } |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 186 | } |
| 187 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 188 | public void setGroupManager(NotificationGroupManager groupManager) { |
| 189 | mGroupManager = groupManager; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 190 | mPrivateLayout.setGroupManager(groupManager); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | public void addChildNotification(ExpandableNotificationRow row) { |
| 194 | addChildNotification(row, -1); |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Add a child notification to this view. |
| 199 | * |
| 200 | * @param row the row to add |
| 201 | * @param childIndex the index to add it at, if -1 it will be added at the end |
| 202 | */ |
| 203 | public void addChildNotification(ExpandableNotificationRow row, int childIndex) { |
| 204 | if (mChildrenContainer == null) { |
| 205 | mChildrenContainerStub.inflate(); |
| 206 | } |
| 207 | mChildrenContainer.addNotification(row, childIndex); |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 208 | onChildrenCountChanged(); |
| 209 | row.setIsChildInGroup(true, this); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | public void removeChildNotification(ExpandableNotificationRow row) { |
| 213 | if (mChildrenContainer != null) { |
| 214 | mChildrenContainer.removeNotification(row); |
| 215 | } |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 216 | onChildrenCountChanged(); |
| 217 | row.setIsChildInGroup(false, null); |
| 218 | } |
| 219 | |
| 220 | public boolean isChildInGroup() { |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame^] | 221 | return mNotificationParent != null; |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 222 | } |
| 223 | |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 224 | public ExpandableNotificationRow getNotificationParent() { |
| 225 | return mNotificationParent; |
| 226 | } |
| 227 | |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 228 | /** |
| 229 | * @param isChildInGroup Is this notification now in a group |
| 230 | * @param parent the new parent notification |
| 231 | */ |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame^] | 232 | public void setIsChildInGroup(boolean isChildInGroup, ExpandableNotificationRow parent) {; |
| 233 | boolean childInGroup = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS && isChildInGroup; |
| 234 | mNotificationParent = childInGroup ? parent : null; |
| 235 | mPrivateLayout.setIsChildInGroup(childInGroup); |
| 236 | updateNoBackgroundState(); |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | @Override |
| 240 | protected boolean shouldHideBackground() { |
| 241 | return super.shouldHideBackground() || mShowNoBackground; |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | @Override |
| 245 | public boolean isSummaryWithChildren() { |
| 246 | return mIsSummaryWithChildren; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | @Override |
| 250 | public boolean areChildrenExpanded() { |
| 251 | return mChildrenExpanded; |
| 252 | } |
| 253 | |
| 254 | public List<ExpandableNotificationRow> getNotificationChildren() { |
| 255 | return mChildrenContainer == null ? null : mChildrenContainer.getNotificationChildren(); |
| 256 | } |
| 257 | |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 258 | public int getNumberOfNotificationChildren() { |
| 259 | if (mChildrenContainer == null) { |
| 260 | return 0; |
| 261 | } |
| 262 | return mChildrenContainer.getNotificationChildren().size(); |
| 263 | } |
| 264 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 265 | /** |
| 266 | * Apply the order given in the list to the children. |
| 267 | * |
| 268 | * @param childOrder the new list order |
| 269 | * @return whether the list order has changed |
| 270 | */ |
| 271 | public boolean applyChildOrder(List<ExpandableNotificationRow> childOrder) { |
| 272 | return mChildrenContainer != null && mChildrenContainer.applyChildOrder(childOrder); |
| 273 | } |
| 274 | |
| 275 | public void getChildrenStates(StackScrollState resultState) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 276 | if (mIsSummaryWithChildren) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 277 | StackViewState parentState = resultState.getViewStateForView(this); |
| 278 | mChildrenContainer.getState(resultState, parentState); |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | public void applyChildrenState(StackScrollState state) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 283 | if (mIsSummaryWithChildren) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 284 | mChildrenContainer.applyState(state); |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | public void prepareExpansionChanged(StackScrollState state) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 289 | if (mIsSummaryWithChildren) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 290 | mChildrenContainer.prepareExpansionChanged(state); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | public void startChildAnimation(StackScrollState finalState, |
| 295 | StackStateAnimator stateAnimator, boolean withDelays, long delay, long duration) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 296 | if (mIsSummaryWithChildren) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 297 | mChildrenContainer.startAnimationToState(finalState, stateAnimator, withDelays, delay, |
| 298 | duration); |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | public ExpandableNotificationRow getViewAtPosition(float y) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 303 | if (!mIsSummaryWithChildren || !mChildrenExpanded) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 304 | return this; |
| 305 | } else { |
| 306 | ExpandableNotificationRow view = mChildrenContainer.getViewAtPosition(y); |
| 307 | return view == null ? this : view; |
| 308 | } |
| 309 | } |
| 310 | |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 311 | public NotificationGuts getGuts() { |
| 312 | return mGuts; |
| 313 | } |
| 314 | |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 315 | /** |
| 316 | * Set this notification to be pinned to the top if {@link #isHeadsUp()} is true. By doing this |
| 317 | * the notification will be rendered on top of the screen. |
| 318 | * |
| 319 | * @param pinned whether it is pinned |
| 320 | */ |
| 321 | public void setPinned(boolean pinned) { |
| 322 | mIsPinned = pinned; |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 323 | setChronometerRunning(mLastChronometerRunning); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 324 | } |
| 325 | |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 326 | public boolean isPinned() { |
| 327 | return mIsPinned; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | public int getHeadsUpHeight() { |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 331 | return mHeadsUpHeight; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 332 | } |
| 333 | |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 334 | /** |
| 335 | * Mark whether this notification was just clicked, i.e. the user has just clicked this |
| 336 | * notification in this frame. |
| 337 | */ |
| 338 | public void setJustClicked(boolean justClicked) { |
| 339 | mJustClicked = justClicked; |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * @return true if this notification has been clicked in this frame, false otherwise |
| 344 | */ |
| 345 | public boolean wasJustClicked() { |
| 346 | return mJustClicked; |
| 347 | } |
| 348 | |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 349 | public void setChronometerRunning(boolean running) { |
| 350 | mLastChronometerRunning = running; |
| 351 | setChronometerRunning(running, mPrivateLayout); |
| 352 | setChronometerRunning(running, mPublicLayout); |
| 353 | if (mChildrenContainer != null) { |
| 354 | List<ExpandableNotificationRow> notificationChildren = |
| 355 | mChildrenContainer.getNotificationChildren(); |
| 356 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 357 | ExpandableNotificationRow child = notificationChildren.get(i); |
| 358 | child.setChronometerRunning(running); |
| 359 | } |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | private void setChronometerRunning(boolean running, NotificationContentView layout) { |
| 364 | if (layout != null) { |
| 365 | running = running || isPinned(); |
| 366 | View contractedChild = layout.getContractedChild(); |
| 367 | View expandedChild = layout.getExpandedChild(); |
| 368 | View headsUpChild = layout.getHeadsUpChild(); |
| 369 | setChronometerRunningForChild(running, contractedChild); |
| 370 | setChronometerRunningForChild(running, expandedChild); |
| 371 | setChronometerRunningForChild(running, headsUpChild); |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | private void setChronometerRunningForChild(boolean running, View child) { |
| 376 | if (child != null) { |
| 377 | View chronometer = child.findViewById(com.android.internal.R.id.chronometer); |
| 378 | if (chronometer instanceof Chronometer) { |
| 379 | ((Chronometer) chronometer).setStarted(running); |
| 380 | } |
| 381 | } |
| 382 | } |
| 383 | |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 384 | public void setEntry(NotificationData.Entry entry) { |
| 385 | mEntry = entry; |
| 386 | setStatusBarNotification(entry.notification); |
| 387 | } |
| 388 | |
Selim Cinek | 8d6440d | 2015-10-22 13:00:05 -0700 | [diff] [blame] | 389 | public CharSequence getSubText() { |
| 390 | Notification notification = mStatusBarNotification.getNotification(); |
| 391 | CharSequence subText = notification.extras.getCharSequence(Notification.EXTRA_SUMMARY_TEXT); |
| 392 | if (subText == null) { |
| 393 | subText = notification.extras.getCharSequence(Notification.EXTRA_SUB_TEXT); |
| 394 | } |
| 395 | return subText; |
| 396 | } |
| 397 | |
| 398 | public void setContentSubTextVisible(boolean visible) { |
| 399 | mPrivateLayout.setSubTextVisible(visible); |
| 400 | } |
| 401 | |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 402 | public interface ExpansionLogger { |
| 403 | public void logNotificationExpansion(String key, boolean userAction, boolean expanded); |
| 404 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 405 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 406 | public ExpandableNotificationRow(Context context, AttributeSet attrs) { |
| 407 | super(context, attrs); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 408 | mFalsingManager = FalsingManager.getInstance(context); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 409 | } |
| 410 | |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 411 | /** |
| 412 | * Resets this view so it can be re-used for an updated notification. |
| 413 | */ |
Christoph Studer | 22f2ee5 | 2014-07-29 22:57:21 +0200 | [diff] [blame] | 414 | @Override |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 415 | public void reset() { |
Christoph Studer | 22f2ee5 | 2014-07-29 22:57:21 +0200 | [diff] [blame] | 416 | super.reset(); |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 417 | mRowMinHeight = 0; |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 418 | final boolean wasExpanded = isExpanded(); |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 419 | mMaxViewHeight = 0; |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 420 | mExpandable = false; |
| 421 | mHasUserChangedExpansion = false; |
| 422 | mUserLocked = false; |
| 423 | mShowingPublic = false; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 424 | mSensitive = false; |
| 425 | mShowingPublicInitialized = false; |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 426 | mIsSystemExpanded = false; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 427 | mOnKeyguard = false; |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 428 | mPublicLayout.reset(mIsHeadsUp); |
| 429 | mPrivateLayout.reset(mIsHeadsUp); |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 430 | resetHeight(); |
| 431 | logExpansionEvent(false, wasExpanded); |
| 432 | } |
| 433 | |
| 434 | public void resetHeight() { |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 435 | if (mIsHeadsUp) { |
| 436 | resetActualHeight(); |
| 437 | } |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 438 | mMaxExpandHeight = 0; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 439 | mHeadsUpHeight = 0; |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 440 | mWasReset = true; |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 441 | onHeightReset(); |
Selim Cinek | 6e28a67 | 2014-09-05 14:43:28 +0200 | [diff] [blame] | 442 | requestLayout(); |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 443 | } |
| 444 | |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 445 | @Override |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 446 | protected boolean filterMotionEvent(MotionEvent event) { |
| 447 | return mIsHeadsUp || super.filterMotionEvent(event); |
| 448 | } |
| 449 | |
| 450 | @Override |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 451 | protected void onFinishInflate() { |
| 452 | super.onFinishInflate(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 453 | mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic); |
| 454 | mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded); |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 455 | mGutsStub = (ViewStub) findViewById(R.id.notification_guts_stub); |
| 456 | mGutsStub.setOnInflateListener(new ViewStub.OnInflateListener() { |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 457 | @Override |
| 458 | public void onInflate(ViewStub stub, View inflated) { |
| 459 | mGuts = (NotificationGuts) inflated; |
| 460 | mGuts.setClipTopAmount(getClipTopAmount()); |
| 461 | mGuts.setActualHeight(getActualHeight()); |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 462 | mGutsStub = null; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 463 | } |
| 464 | }); |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 465 | mNotificationHeaderStub = (ViewStub) findViewById(R.id.notification_header_stub); |
| 466 | mNotificationHeaderStub.setOnInflateListener(new ViewStub.OnInflateListener() { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 467 | @Override |
| 468 | public void onInflate(ViewStub stub, View inflated) { |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 469 | mNotificationHeader = (NotificationHeaderView) inflated; |
| 470 | mNotificationHeader.setGroupManager(mGroupManager); |
| 471 | mNotificationHeader.bind(mEntry); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 472 | } |
| 473 | }); |
| 474 | mChildrenContainerStub = (ViewStub) findViewById(R.id.child_container_stub); |
| 475 | mChildrenContainerStub.setOnInflateListener(new ViewStub.OnInflateListener() { |
| 476 | |
| 477 | @Override |
| 478 | public void onInflate(ViewStub stub, View inflated) { |
| 479 | mChildrenContainer = (NotificationChildrenContainer) inflated; |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 480 | mChildrenContainer.setNotificationParent(ExpandableNotificationRow.this); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 481 | } |
| 482 | }); |
Selim Cinek | 863834b | 2014-05-20 04:20:25 +0200 | [diff] [blame] | 483 | mVetoButton = findViewById(R.id.veto); |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 484 | } |
| 485 | |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 486 | public void inflateGuts() { |
| 487 | if (mGuts == null) { |
| 488 | mGutsStub.inflate(); |
| 489 | } |
| 490 | } |
| 491 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 492 | private void updateChildrenVisibility(boolean animated) { |
| 493 | if (mChildrenContainer == null) { |
| 494 | return; |
| 495 | } |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 496 | mChildrenContainer.setVisibility(mIsSummaryWithChildren ? VISIBLE : INVISIBLE); |
| 497 | mPrivateLayout.setVisibility(!mIsSummaryWithChildren ? VISIBLE : INVISIBLE); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 498 | } |
| 499 | |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 500 | @Override |
Alan Viverette | a54956a | 2015-01-07 16:05:02 -0800 | [diff] [blame] | 501 | public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event) { |
| 502 | if (super.onRequestSendAccessibilityEventInternal(child, event)) { |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 503 | // Add a record for the entire layout since its content is somehow small. |
| 504 | // The event comes from a leaf view that is interacted with. |
| 505 | AccessibilityEvent record = AccessibilityEvent.obtain(); |
| 506 | onInitializeAccessibilityEvent(record); |
| 507 | dispatchPopulateAccessibilityEvent(record); |
| 508 | event.appendRecord(record); |
| 509 | return true; |
| 510 | } |
| 511 | return false; |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 512 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 513 | |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 514 | @Override |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 515 | public void setDark(boolean dark, boolean fade, long delay) { |
| 516 | super.setDark(dark, fade, delay); |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 517 | final NotificationContentView showing = getShowingLayout(); |
| 518 | if (showing != null) { |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 519 | showing.setDark(dark, fade, delay); |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 520 | } |
| 521 | } |
| 522 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 523 | public void setHeightRange(int rowMinHeight, int rowMaxHeight) { |
| 524 | mRowMinHeight = rowMinHeight; |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 525 | mMaxViewHeight = rowMaxHeight; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | public boolean isExpandable() { |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 529 | if (mIsSummaryWithChildren && !mShowingPublic) { |
| 530 | return !mChildrenExpanded; |
| 531 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 532 | return mExpandable; |
| 533 | } |
| 534 | |
| 535 | public void setExpandable(boolean expandable) { |
| 536 | mExpandable = expandable; |
| 537 | } |
| 538 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 539 | /** |
| 540 | * @return whether the user has changed the expansion state |
| 541 | */ |
| 542 | public boolean hasUserChangedExpansion() { |
| 543 | return mHasUserChangedExpansion; |
| 544 | } |
| 545 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 546 | public boolean isUserExpanded() { |
| 547 | return mUserExpanded; |
| 548 | } |
| 549 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 550 | /** |
| 551 | * Set this notification to be expanded by the user |
| 552 | * |
| 553 | * @param userExpanded whether the user wants this notification to be expanded |
| 554 | */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 555 | public void setUserExpanded(boolean userExpanded) { |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 556 | setUserExpanded(userExpanded, false /* allowChildExpansion */); |
| 557 | } |
| 558 | |
| 559 | /** |
| 560 | * Set this notification to be expanded by the user |
| 561 | * |
| 562 | * @param userExpanded whether the user wants this notification to be expanded |
| 563 | * @param allowChildExpansion whether a call to this method allows expanding children |
| 564 | */ |
| 565 | public void setUserExpanded(boolean userExpanded, boolean allowChildExpansion) { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 566 | mFalsingManager.setNotificationExpanded(); |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 567 | if (mIsSummaryWithChildren && !mShowingPublic && allowChildExpansion) { |
| 568 | mGroupManager.setGroupExpanded(mStatusBarNotification, userExpanded); |
| 569 | return; |
| 570 | } |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 571 | if (userExpanded && !mExpandable) return; |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 572 | final boolean wasExpanded = isExpanded(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 573 | mHasUserChangedExpansion = true; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 574 | mUserExpanded = userExpanded; |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 575 | logExpansionEvent(true, wasExpanded); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 576 | } |
| 577 | |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 578 | public void resetUserExpansion() { |
| 579 | mHasUserChangedExpansion = false; |
| 580 | mUserExpanded = false; |
| 581 | } |
| 582 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 583 | public boolean isUserLocked() { |
| 584 | return mUserLocked; |
| 585 | } |
| 586 | |
| 587 | public void setUserLocked(boolean userLocked) { |
| 588 | mUserLocked = userLocked; |
| 589 | } |
| 590 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 591 | /** |
| 592 | * @return has the system set this notification to be expanded |
| 593 | */ |
| 594 | public boolean isSystemExpanded() { |
| 595 | return mIsSystemExpanded; |
| 596 | } |
| 597 | |
| 598 | /** |
| 599 | * Set this notification to be expanded by the system. |
| 600 | * |
| 601 | * @param expand whether the system wants this notification to be expanded. |
| 602 | */ |
| 603 | public void setSystemExpanded(boolean expand) { |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 604 | if (expand != mIsSystemExpanded) { |
| 605 | final boolean wasExpanded = isExpanded(); |
| 606 | mIsSystemExpanded = expand; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 607 | notifyHeightChanged(false /* needsAnimation */); |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 608 | logExpansionEvent(false, wasExpanded); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 609 | if (mChildrenContainer != null) { |
| 610 | mChildrenContainer.updateGroupOverflow(); |
| 611 | } |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 612 | } |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | /** |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 616 | * @param onKeyguard whether to prevent notification expansion |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 617 | */ |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 618 | public void setOnKeyguard(boolean onKeyguard) { |
| 619 | if (onKeyguard != mOnKeyguard) { |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 620 | final boolean wasExpanded = isExpanded(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 621 | mOnKeyguard = onKeyguard; |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 622 | logExpansionEvent(false, wasExpanded); |
| 623 | if (wasExpanded != isExpanded()) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 624 | notifyHeightChanged(false /* needsAnimation */); |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 625 | } |
| 626 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | /** |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 630 | * @return Can the underlying notification be cleared? |
| 631 | */ |
| 632 | public boolean isClearable() { |
Selim Cinek | a37774f | 2014-11-11 19:16:18 +0100 | [diff] [blame] | 633 | return mStatusBarNotification != null && mStatusBarNotification.isClearable(); |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 634 | } |
| 635 | |
| 636 | /** |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 637 | * Apply an expansion state to the layout. |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 638 | */ |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 639 | public void applyExpansionToLayout() { |
| 640 | boolean expand = isExpanded(); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 641 | if (expand && mExpandable) { |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 642 | setActualHeight(mMaxExpandHeight); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 643 | } else { |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 644 | setActualHeight(mRowMinHeight); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 645 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 646 | } |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 647 | |
Jorim Jaggi | 9cbadd3 | 2014-05-01 20:18:31 +0200 | [diff] [blame] | 648 | @Override |
| 649 | public int getIntrinsicHeight() { |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 650 | if (isUserLocked()) { |
| 651 | return getActualHeight(); |
| 652 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 653 | boolean inExpansionState = isExpanded(); |
Selim Cinek | 60122be | 2015-04-15 18:16:50 -0700 | [diff] [blame] | 654 | if (mSensitive && mHideSensitiveForIntrinsicHeight) { |
| 655 | return mRowMinHeight; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 656 | } else if (mIsSummaryWithChildren && !mOnKeyguard) { |
| 657 | return mChildrenContainer.getIntrinsicHeight() |
| 658 | + mNotificationHeader.getHeight(); |
Selim Cinek | 60122be | 2015-04-15 18:16:50 -0700 | [diff] [blame] | 659 | } else if (mIsHeadsUp) { |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 660 | if (inExpansionState) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 661 | return Math.max(mMaxExpandHeight, mHeadsUpHeight); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 662 | } else { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 663 | return Math.max(mRowMinHeight, mHeadsUpHeight); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 664 | } |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame^] | 665 | } else if (!inExpansionState || (isChildInGroup() && !isGroupExpanded())) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 666 | return getMinHeight(); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 667 | } else { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 668 | return getMaxExpandHeight(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 669 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 670 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 671 | |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 672 | private boolean isGroupExpanded() { |
| 673 | return mGroupManager.isGroupExpanded(mStatusBarNotification); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 674 | } |
| 675 | |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 676 | /** |
| 677 | * @return whether this view has a header on the top of the content |
| 678 | */ |
| 679 | private boolean hasNotificationHeader() { |
| 680 | return mIsSummaryWithChildren; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 681 | } |
| 682 | |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 683 | private void onChildrenCountChanged() { |
| 684 | mIsSummaryWithChildren = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS |
| 685 | && mGroupManager.hasGroupChildren(mStatusBarNotification); |
| 686 | if (mIsSummaryWithChildren && mChildrenContainer == null) { |
| 687 | mChildrenContainerStub.inflate(); |
| 688 | } |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 689 | updateNotificationHeader(); |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 690 | updateChildrenVisibility(true); |
| 691 | } |
| 692 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 693 | /** |
| 694 | * Check whether the view state is currently expanded. This is given by the system in {@link |
| 695 | * #setSystemExpanded(boolean)} and can be overridden by user expansion or |
| 696 | * collapsing in {@link #setUserExpanded(boolean)}. Note that the visual appearance of this |
| 697 | * view can differ from this state, if layout params are modified from outside. |
| 698 | * |
| 699 | * @return whether the view state is currently expanded. |
| 700 | */ |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 701 | public boolean isExpanded() { |
| 702 | return !mOnKeyguard |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 703 | && (!hasUserChangedExpansion() && (isSystemExpanded() || isSystemChildExpanded()) |
| 704 | || isUserExpanded()); |
| 705 | } |
| 706 | |
| 707 | private boolean isSystemChildExpanded() { |
| 708 | return mIsSystemChildExpanded; |
| 709 | } |
| 710 | |
| 711 | public void setSystemChildExpanded(boolean expanded) { |
| 712 | mIsSystemChildExpanded = expanded; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 713 | } |
| 714 | |
| 715 | @Override |
| 716 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
| 717 | super.onLayout(changed, left, top, right, bottom); |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 718 | boolean updateExpandHeight = mMaxExpandHeight == 0 && !mWasReset; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 719 | updateMaxHeights(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 720 | if (updateExpandHeight) { |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 721 | applyExpansionToLayout(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 722 | } |
Selim Cinek | a5e211b | 2014-08-11 17:35:48 +0200 | [diff] [blame] | 723 | mWasReset = false; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 724 | } |
| 725 | |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 726 | private void updateMaxHeights() { |
Selim Cinek | d2319fb | 2014-09-01 19:41:54 +0200 | [diff] [blame] | 727 | int intrinsicBefore = getIntrinsicHeight(); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 728 | View expandedChild = mPrivateLayout.getExpandedChild(); |
| 729 | if (expandedChild == null) { |
| 730 | expandedChild = mPrivateLayout.getContractedChild(); |
| 731 | } |
| 732 | mMaxExpandHeight = expandedChild.getHeight(); |
| 733 | View headsUpChild = mPrivateLayout.getHeadsUpChild(); |
Selim Cinek | 1f3f544 | 2015-04-10 17:54:46 -0700 | [diff] [blame] | 734 | if (headsUpChild == null) { |
| 735 | headsUpChild = mPrivateLayout.getContractedChild(); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 736 | } |
Selim Cinek | 1f3f544 | 2015-04-10 17:54:46 -0700 | [diff] [blame] | 737 | mHeadsUpHeight = headsUpChild.getHeight(); |
Selim Cinek | d2319fb | 2014-09-01 19:41:54 +0200 | [diff] [blame] | 738 | if (intrinsicBefore != getIntrinsicHeight()) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 739 | notifyHeightChanged(false /* needsAnimation */); |
Selim Cinek | d2319fb | 2014-09-01 19:41:54 +0200 | [diff] [blame] | 740 | } |
| 741 | } |
| 742 | |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 743 | public void setSensitive(boolean sensitive) { |
| 744 | mSensitive = sensitive; |
| 745 | } |
| 746 | |
| 747 | public void setHideSensitiveForIntrinsicHeight(boolean hideSensitive) { |
Selim Cinek | 60122be | 2015-04-15 18:16:50 -0700 | [diff] [blame] | 748 | mHideSensitiveForIntrinsicHeight = hideSensitive; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 749 | } |
| 750 | |
| 751 | public void setHideSensitive(boolean hideSensitive, boolean animated, long delay, |
| 752 | long duration) { |
| 753 | boolean oldShowingPublic = mShowingPublic; |
| 754 | mShowingPublic = mSensitive && hideSensitive; |
| 755 | if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) { |
| 756 | return; |
| 757 | } |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 758 | |
| 759 | // bail out if no public version |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 760 | if (mPublicLayout.getChildCount() == 0) return; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 761 | |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 762 | if (!animated) { |
| 763 | mPublicLayout.animate().cancel(); |
| 764 | mPrivateLayout.animate().cancel(); |
| 765 | mPublicLayout.setAlpha(1f); |
| 766 | mPrivateLayout.setAlpha(1f); |
| 767 | mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE); |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 768 | mPrivateLayout.setVisibility(!mShowingPublic && !mIsSummaryWithChildren ? View.VISIBLE |
| 769 | : View.INVISIBLE); |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 770 | } else { |
| 771 | animateShowingPublic(delay, duration); |
| 772 | } |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 773 | |
| 774 | updateVetoButton(); |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 775 | mShowingPublicInitialized = true; |
| 776 | } |
| 777 | |
| 778 | private void animateShowingPublic(long delay, long duration) { |
| 779 | final View source = mShowingPublic ? mPrivateLayout : mPublicLayout; |
| 780 | View target = mShowingPublic ? mPublicLayout : mPrivateLayout; |
| 781 | source.setVisibility(View.VISIBLE); |
| 782 | target.setVisibility(View.VISIBLE); |
| 783 | target.setAlpha(0f); |
| 784 | source.animate().cancel(); |
| 785 | target.animate().cancel(); |
| 786 | source.animate() |
| 787 | .alpha(0f) |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 788 | .setStartDelay(delay) |
| 789 | .setDuration(duration) |
| 790 | .withEndAction(new Runnable() { |
| 791 | @Override |
| 792 | public void run() { |
| 793 | source.setVisibility(View.INVISIBLE); |
| 794 | } |
| 795 | }); |
| 796 | target.animate() |
| 797 | .alpha(1f) |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 798 | .setStartDelay(delay) |
| 799 | .setDuration(duration); |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 800 | } |
| 801 | |
| 802 | private void updateVetoButton() { |
| 803 | // public versions cannot be dismissed |
| 804 | mVetoButton.setVisibility(isClearable() && !mShowingPublic ? View.VISIBLE : View.GONE); |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 805 | } |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 806 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 807 | public void setChildrenExpanded(boolean expanded, boolean animate) { |
| 808 | mChildrenExpanded = expanded; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 809 | if (mChildrenContainer != null) { |
| 810 | mChildrenContainer.setChildrenExpanded(expanded); |
| 811 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 812 | } |
| 813 | |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 814 | public void updateNotificationHeader() { |
| 815 | boolean hasHeader = hasNotificationHeader(); |
| 816 | if (hasHeader != mHasNotificationHeader) { |
| 817 | if (hasHeader) { |
| 818 | if (mNotificationHeader == null) { |
| 819 | mNotificationHeaderStub.inflate(); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 820 | } |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 821 | mNotificationHeader.setVisibility(View.VISIBLE); |
| 822 | } else if (mNotificationHeader != null) { |
| 823 | mNotificationHeader.setVisibility(View.GONE); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 824 | } |
| 825 | notifyHeightChanged(true /* needsAnimation */); |
| 826 | } |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 827 | if (hasHeader) { |
| 828 | mNotificationHeader.bind(mEntry); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 829 | } |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 830 | mHasNotificationHeader = hasHeader; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 831 | } |
| 832 | |
| 833 | public static void applyTint(View v, int color) { |
| 834 | int alpha; |
| 835 | if (color != 0) { |
| 836 | alpha = COLORED_DIVIDER_ALPHA; |
| 837 | } else { |
| 838 | color = 0xff000000; |
| 839 | alpha = DEFAULT_DIVIDER_ALPHA; |
| 840 | } |
| 841 | if (v.getBackground() instanceof ColorDrawable) { |
| 842 | ColorDrawable background = (ColorDrawable) v.getBackground(); |
| 843 | background.mutate(); |
| 844 | background.setColor(color); |
| 845 | background.setAlpha(alpha); |
| 846 | } |
| 847 | } |
| 848 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 849 | public int getMaxExpandHeight() { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 850 | return mMaxExpandHeight; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 851 | } |
Jorim Jaggi | 584a7aa | 2014-04-10 23:26:13 +0200 | [diff] [blame] | 852 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 853 | @Override |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 854 | public boolean isContentExpandable() { |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 855 | NotificationContentView showingLayout = getShowingLayout(); |
| 856 | return showingLayout.isContentExpandable(); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 857 | } |
| 858 | |
| 859 | @Override |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 860 | protected View getContentView() { |
| 861 | return getShowingLayout(); |
| 862 | } |
| 863 | |
| 864 | @Override |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 865 | public void setActualHeight(int height, boolean notifyListeners) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 866 | super.setActualHeight(height, notifyListeners); |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 867 | int contentHeight = Math.max(getMinHeight(), height); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 868 | mPrivateLayout.setContentHeight(contentHeight); |
| 869 | mPublicLayout.setContentHeight(contentHeight); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 870 | if (mGuts != null) { |
| 871 | mGuts.setActualHeight(height); |
| 872 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 873 | invalidate(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 874 | } |
| 875 | |
| 876 | @Override |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 877 | public int getMaxContentHeight() { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 878 | if (mIsSummaryWithChildren && !mShowingPublic) { |
| 879 | return mChildrenContainer.getMaxContentHeight() |
| 880 | + mNotificationHeader.getHeight(); |
| 881 | } |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 882 | NotificationContentView showingLayout = getShowingLayout(); |
| 883 | return showingLayout.getMaxHeight(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 884 | } |
| 885 | |
| 886 | @Override |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 887 | public int getMinHeight() { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 888 | if (mIsSummaryWithChildren && !mOnKeyguard) { |
| 889 | return mChildrenContainer.getMinHeight() |
| 890 | + mNotificationHeader.getHeight(); |
| 891 | } |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 892 | NotificationContentView showingLayout = getShowingLayout(); |
| 893 | return showingLayout.getMinHeight(); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 894 | } |
| 895 | |
| 896 | @Override |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 897 | protected boolean shouldLimitViewHeight() { |
| 898 | return !mIsSummaryWithChildren; |
| 899 | } |
| 900 | |
| 901 | @Override |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 902 | public void setClipTopAmount(int clipTopAmount) { |
| 903 | super.setClipTopAmount(clipTopAmount); |
| 904 | mPrivateLayout.setClipTopAmount(clipTopAmount); |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 905 | mPublicLayout.setClipTopAmount(clipTopAmount); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 906 | if (mGuts != null) { |
| 907 | mGuts.setClipTopAmount(clipTopAmount); |
| 908 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 909 | } |
| 910 | |
| 911 | public void notifyContentUpdated() { |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 912 | mPublicLayout.notifyContentUpdated(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 913 | mPrivateLayout.notifyContentUpdated(); |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 914 | } |
Selim Cinek | 7d44772 | 2014-06-10 15:51:59 +0200 | [diff] [blame] | 915 | |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 916 | public boolean isMaxExpandHeightInitialized() { |
| 917 | return mMaxExpandHeight != 0; |
Selim Cinek | 7d44772 | 2014-06-10 15:51:59 +0200 | [diff] [blame] | 918 | } |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 919 | |
| 920 | private NotificationContentView getShowingLayout() { |
| 921 | return mShowingPublic ? mPublicLayout : mPrivateLayout; |
| 922 | } |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 923 | |
Jorim Jaggi | 59ec304 | 2015-06-05 15:18:43 -0700 | [diff] [blame] | 924 | @Override |
| 925 | public void setShowingLegacyBackground(boolean showing) { |
| 926 | super.setShowingLegacyBackground(showing); |
| 927 | mPrivateLayout.setShowingLegacyBackground(showing); |
| 928 | mPublicLayout.setShowingLegacyBackground(showing); |
| 929 | } |
| 930 | |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame^] | 931 | @Override |
| 932 | protected void updateBackgroundTint() { |
| 933 | super.updateBackgroundTint(); |
| 934 | updateNoBackgroundState(); |
| 935 | if (mIsSummaryWithChildren) { |
| 936 | List<ExpandableNotificationRow> notificationChildren = |
| 937 | mChildrenContainer.getNotificationChildren(); |
| 938 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 939 | ExpandableNotificationRow child = notificationChildren.get(i); |
| 940 | child.updateNoBackgroundState(); |
| 941 | } |
| 942 | } |
| 943 | } |
| 944 | |
| 945 | private void updateNoBackgroundState() { |
| 946 | mShowNoBackground = isChildInGroup() && hasSameBgColor(mNotificationParent); |
| 947 | updateBackground(); |
| 948 | } |
| 949 | |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 950 | public void setExpansionLogger(ExpansionLogger logger, String key) { |
| 951 | mLogger = logger; |
| 952 | mLoggingKey = key; |
| 953 | } |
| 954 | |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 955 | private void logExpansionEvent(boolean userAction, boolean wasExpanded) { |
| 956 | final boolean nowExpanded = isExpanded(); |
| 957 | if (wasExpanded != nowExpanded && mLogger != null) { |
| 958 | mLogger.logNotificationExpansion(mLoggingKey, userAction, nowExpanded) ; |
| 959 | } |
| 960 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 961 | } |