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