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