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 | |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 19 | import android.animation.Animator; |
| 20 | import android.animation.AnimatorListenerAdapter; |
| 21 | import android.animation.AnimatorSet; |
| 22 | import android.animation.ObjectAnimator; |
| 23 | import android.animation.ValueAnimator; |
| 24 | import android.animation.ValueAnimator.AnimatorUpdateListener; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 25 | import android.content.Context; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 26 | import android.graphics.drawable.AnimatedVectorDrawable; |
| 27 | import android.graphics.drawable.AnimationDrawable; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 28 | import android.graphics.drawable.ColorDrawable; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 29 | import android.graphics.drawable.Drawable; |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 30 | import android.os.Build; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 31 | import android.service.notification.StatusBarNotification; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 32 | import android.util.AttributeSet; |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 33 | import android.util.FloatProperty; |
| 34 | import android.util.Property; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 35 | import android.view.LayoutInflater; |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 36 | import android.view.MotionEvent; |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 37 | import android.view.NotificationHeaderView; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 38 | import android.view.View; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 39 | import android.view.ViewStub; |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 40 | import android.view.accessibility.AccessibilityEvent; |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 41 | import android.widget.Chronometer; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 42 | import android.widget.ImageView; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 43 | |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame^] | 44 | import com.android.internal.logging.MetricsLogger; |
| 45 | import com.android.internal.logging.MetricsProto; |
| 46 | import com.android.internal.logging.MetricsProto.MetricsEvent; |
Selim Cinek | 4bb5934 | 2016-04-08 19:29:35 -0700 | [diff] [blame] | 47 | import com.android.internal.util.NotificationColorUtil; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 48 | import com.android.systemui.R; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 49 | import com.android.systemui.classifier.FalsingManager; |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 50 | import com.android.systemui.statusbar.notification.HybridNotificationView; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 51 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 52 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 53 | import com.android.systemui.statusbar.stack.NotificationChildrenContainer; |
| 54 | import com.android.systemui.statusbar.stack.StackScrollState; |
| 55 | import com.android.systemui.statusbar.stack.StackStateAnimator; |
| 56 | import com.android.systemui.statusbar.stack.StackViewState; |
| 57 | |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 58 | import java.util.ArrayList; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 59 | import java.util.List; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 60 | |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 61 | public class ExpandableNotificationRow extends ActivatableNotificationView { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 62 | |
| 63 | private static final int DEFAULT_DIVIDER_ALPHA = 0x29; |
| 64 | private static final int COLORED_DIVIDER_ALPHA = 0x7B; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 65 | private int mNotificationMinHeightLegacy; |
| 66 | private int mMaxHeadsUpHeightLegacy; |
| 67 | private int mMaxHeadsUpHeight; |
| 68 | private int mNotificationMinHeight; |
| 69 | private int mNotificationMaxHeight; |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 70 | private int mIncreasedPaddingBetweenElements; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 71 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 72 | /** Does this row contain layouts that can adapt to row expansion */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 73 | private boolean mExpandable; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 74 | /** Has the user actively changed the expansion state of this row */ |
| 75 | private boolean mHasUserChangedExpansion; |
| 76 | /** If {@link #mHasUserChangedExpansion}, has the user expanded this row */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 77 | private boolean mUserExpanded; |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 78 | |
| 79 | /** |
| 80 | * Has this notification been expanded while it was pinned |
| 81 | */ |
| 82 | private boolean mExpandedWhenPinned; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 83 | /** Is the user touching this row */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 84 | private boolean mUserLocked; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 85 | /** Are we showing the "public" version */ |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 86 | private boolean mShowingPublic; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 87 | private boolean mSensitive; |
Selim Cinek | 3c76d50 | 2016-02-19 15:16:33 -0800 | [diff] [blame] | 88 | private boolean mSensitiveHiddenInGeneral; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 89 | private boolean mShowingPublicInitialized; |
Selim Cinek | 60122be | 2015-04-15 18:16:50 -0700 | [diff] [blame] | 90 | private boolean mHideSensitiveForIntrinsicHeight; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 91 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 92 | /** |
| 93 | * Is this notification expanded by the system. The expansion state can be overridden by the |
| 94 | * user expansion. |
| 95 | */ |
| 96 | private boolean mIsSystemExpanded; |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 97 | |
| 98 | /** |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 99 | * Whether the notification is on the keyguard and the expansion is disabled. |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 100 | */ |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 101 | private boolean mOnKeyguard; |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 102 | |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 103 | private Animator mTranslateAnim; |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 104 | private ArrayList<View> mTranslateableViews; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 105 | private NotificationContentView mPublicLayout; |
| 106 | private NotificationContentView mPrivateLayout; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 107 | private int mMaxExpandHeight; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 108 | private int mHeadsUpHeight; |
Selim Cinek | 863834b | 2014-05-20 04:20:25 +0200 | [diff] [blame] | 109 | private View mVetoButton; |
Selim Cinek | 4bb5934 | 2016-04-08 19:29:35 -0700 | [diff] [blame] | 110 | private int mNotificationColor; |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 111 | private boolean mClearable; |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 112 | private ExpansionLogger mLogger; |
| 113 | private String mLoggingKey; |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 114 | private NotificationSettingsIconRow mSettingsIconRow; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 115 | private NotificationGuts mGuts; |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 116 | private NotificationData.Entry mEntry; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 117 | private StatusBarNotification mStatusBarNotification; |
Mady Mellor | 3fd273e | 2016-03-15 21:08:14 -0700 | [diff] [blame] | 118 | private String mAppName; |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 119 | private boolean mIsHeadsUp; |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 120 | private boolean mLastChronometerRunning = true; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 121 | private ViewStub mChildrenContainerStub; |
| 122 | private NotificationGroupManager mGroupManager; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 123 | private boolean mChildrenExpanded; |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 124 | private boolean mIsSummaryWithChildren; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 125 | private NotificationChildrenContainer mChildrenContainer; |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 126 | private ViewStub mSettingsIconRowStub; |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 127 | private ViewStub mGutsStub; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 128 | private boolean mIsSystemChildExpanded; |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 129 | private boolean mIsPinned; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 130 | private FalsingManager mFalsingManager; |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 131 | private HeadsUpManager mHeadsUpManager; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 132 | |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 133 | private boolean mJustClicked; |
Selim Cinek | 5a175d9 | 2015-11-23 18:01:33 -0800 | [diff] [blame] | 134 | private boolean mIconAnimationRunning; |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 135 | private boolean mShowNoBackground; |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 136 | private ExpandableNotificationRow mNotificationParent; |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 137 | private OnExpandClickListener mOnExpandClickListener; |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 138 | private boolean mGroupExpansionChanging; |
| 139 | |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 140 | private OnClickListener mExpandClickListener = new OnClickListener() { |
| 141 | @Override |
| 142 | public void onClick(View v) { |
Selim Cinek | 624c02db | 2015-12-14 21:00:02 -0800 | [diff] [blame] | 143 | if (!mShowingPublic && mGroupManager.isSummaryOfGroup(mStatusBarNotification)) { |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame^] | 144 | final boolean wasExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification); |
| 145 | boolean nowExpanded = mGroupManager.toggleGroupExpansion(mStatusBarNotification); |
| 146 | mOnExpandClickListener.onExpandClicked(mEntry, nowExpanded); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 147 | mGroupExpansionChanging = true; |
| 148 | updateBackgroundForGroupState(); |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame^] | 149 | MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTIFICATION_GROUP_EXPANDER, |
| 150 | nowExpanded); |
| 151 | logExpansionEvent(true /* userAction */, wasExpanded); |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 152 | } else { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 153 | boolean nowExpanded; |
| 154 | if (isPinned()) { |
| 155 | nowExpanded = !mExpandedWhenPinned; |
| 156 | mExpandedWhenPinned = nowExpanded; |
| 157 | } else { |
| 158 | nowExpanded = !isExpanded(); |
| 159 | setUserExpanded(nowExpanded); |
| 160 | } |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 161 | notifyHeightChanged(true); |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 162 | mOnExpandClickListener.onExpandClicked(mEntry, nowExpanded); |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame^] | 163 | MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTIFICATION_EXPANDER, |
| 164 | nowExpanded); |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 165 | } |
| 166 | } |
| 167 | }; |
Selim Cinek | 1b2a05e | 2016-04-28 14:20:39 -0700 | [diff] [blame] | 168 | private boolean mForceUnlocked; |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 169 | private boolean mDismissed; |
| 170 | private boolean mKeepInParent; |
| 171 | private boolean mRemoved; |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 172 | private static final Property<ExpandableNotificationRow, Float> TRANSLATE_CONTENT = |
| 173 | new FloatProperty<ExpandableNotificationRow>("translate") { |
| 174 | @Override |
| 175 | public void setValue(ExpandableNotificationRow object, float value) { |
| 176 | object.setTranslation(value); |
| 177 | } |
| 178 | |
| 179 | @Override |
| 180 | public Float get(ExpandableNotificationRow object) { |
| 181 | return object.getTranslation(); |
| 182 | } |
| 183 | }; |
| 184 | |
| 185 | public boolean isGroupExpansionChanging() { |
| 186 | if (isChildInGroup()) { |
| 187 | return mNotificationParent.isGroupExpansionChanging(); |
| 188 | } |
| 189 | return mGroupExpansionChanging; |
| 190 | } |
| 191 | |
| 192 | public void setGroupExpansionChanging(boolean changing) { |
| 193 | mGroupExpansionChanging = changing; |
| 194 | } |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 195 | |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 196 | public NotificationContentView getPrivateLayout() { |
| 197 | return mPrivateLayout; |
| 198 | } |
| 199 | |
| 200 | public NotificationContentView getPublicLayout() { |
| 201 | return mPublicLayout; |
| 202 | } |
| 203 | |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 204 | public void setIconAnimationRunning(boolean running) { |
| 205 | setIconAnimationRunning(running, mPublicLayout); |
| 206 | setIconAnimationRunning(running, mPrivateLayout); |
Selim Cinek | 5a175d9 | 2015-11-23 18:01:33 -0800 | [diff] [blame] | 207 | if (mIsSummaryWithChildren) { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 208 | setIconAnimationRunningForChild(running, mChildrenContainer.getHeaderView()); |
Selim Cinek | 5a175d9 | 2015-11-23 18:01:33 -0800 | [diff] [blame] | 209 | List<ExpandableNotificationRow> notificationChildren = |
| 210 | mChildrenContainer.getNotificationChildren(); |
| 211 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 212 | ExpandableNotificationRow child = notificationChildren.get(i); |
| 213 | child.setIconAnimationRunning(running); |
| 214 | } |
| 215 | } |
| 216 | mIconAnimationRunning = running; |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | private void setIconAnimationRunning(boolean running, NotificationContentView layout) { |
| 220 | if (layout != null) { |
| 221 | View contractedChild = layout.getContractedChild(); |
| 222 | View expandedChild = layout.getExpandedChild(); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 223 | View headsUpChild = layout.getHeadsUpChild(); |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 224 | setIconAnimationRunningForChild(running, contractedChild); |
| 225 | setIconAnimationRunningForChild(running, expandedChild); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 226 | setIconAnimationRunningForChild(running, headsUpChild); |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 227 | } |
| 228 | } |
| 229 | |
| 230 | private void setIconAnimationRunningForChild(boolean running, View child) { |
| 231 | if (child != null) { |
| 232 | ImageView icon = (ImageView) child.findViewById(com.android.internal.R.id.icon); |
| 233 | setIconRunning(icon, running); |
| 234 | ImageView rightIcon = (ImageView) child.findViewById( |
| 235 | com.android.internal.R.id.right_icon); |
| 236 | setIconRunning(rightIcon, running); |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | private void setIconRunning(ImageView imageView, boolean running) { |
| 241 | if (imageView != null) { |
| 242 | Drawable drawable = imageView.getDrawable(); |
| 243 | if (drawable instanceof AnimationDrawable) { |
| 244 | AnimationDrawable animationDrawable = (AnimationDrawable) drawable; |
| 245 | if (running) { |
| 246 | animationDrawable.start(); |
| 247 | } else { |
| 248 | animationDrawable.stop(); |
| 249 | } |
| 250 | } else if (drawable instanceof AnimatedVectorDrawable) { |
| 251 | AnimatedVectorDrawable animationDrawable = (AnimatedVectorDrawable) drawable; |
| 252 | if (running) { |
| 253 | animationDrawable.start(); |
| 254 | } else { |
| 255 | animationDrawable.stop(); |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 261 | public void onNotificationUpdated(NotificationData.Entry entry) { |
| 262 | mEntry = entry; |
| 263 | mStatusBarNotification = entry.notification; |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 264 | mPrivateLayout.onNotificationUpdated(entry); |
| 265 | mPublicLayout.onNotificationUpdated(entry); |
Selim Cinek | 757d879 | 2016-01-28 16:21:08 -0800 | [diff] [blame] | 266 | mShowingPublicInitialized = false; |
Selim Cinek | 4bb5934 | 2016-04-08 19:29:35 -0700 | [diff] [blame] | 267 | updateNotificationColor(); |
Selim Cinek | 757d879 | 2016-01-28 16:21:08 -0800 | [diff] [blame] | 268 | updateClearability(); |
Selim Cinek | 8fc93c9 | 2015-11-23 17:48:07 -0800 | [diff] [blame] | 269 | if (mIsSummaryWithChildren) { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 270 | mChildrenContainer.recreateNotificationHeader(mExpandClickListener, mEntry.notification); |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 271 | mChildrenContainer.onNotificationUpdated(); |
Selim Cinek | 8fc93c9 | 2015-11-23 17:48:07 -0800 | [diff] [blame] | 272 | } |
Selim Cinek | 5a175d9 | 2015-11-23 18:01:33 -0800 | [diff] [blame] | 273 | if (mIconAnimationRunning) { |
| 274 | setIconAnimationRunning(true); |
| 275 | } |
Selim Cinek | ea4bef7 | 2015-12-02 15:51:10 -0800 | [diff] [blame] | 276 | if (mNotificationParent != null) { |
| 277 | mNotificationParent.updateChildrenHeaderAppearance(); |
| 278 | } |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 279 | onChildrenCountChanged(); |
Selim Cinek | 624c02db | 2015-12-14 21:00:02 -0800 | [diff] [blame] | 280 | // The public layouts expand button is always visible |
| 281 | mPublicLayout.updateExpandButtons(true); |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 282 | updateLimits(); |
| 283 | } |
| 284 | |
| 285 | private void updateLimits() { |
Selim Cinek | a174487 | 2016-03-11 15:36:06 -0800 | [diff] [blame] | 286 | updateLimitsForView(mPrivateLayout); |
| 287 | updateLimitsForView(mPublicLayout); |
| 288 | } |
| 289 | |
| 290 | private void updateLimitsForView(NotificationContentView layout) { |
| 291 | boolean customView = layout.getContractedChild().getId() |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 292 | != com.android.internal.R.id.status_bar_latest_event_content; |
| 293 | boolean beforeN = mEntry.targetSdk < Build.VERSION_CODES.N; |
| 294 | int minHeight = customView && beforeN && !mIsSummaryWithChildren ? |
| 295 | mNotificationMinHeightLegacy : mNotificationMinHeight; |
Selim Cinek | a174487 | 2016-03-11 15:36:06 -0800 | [diff] [blame] | 296 | boolean headsUpCustom = layout.getHeadsUpChild() != null && |
| 297 | layout.getHeadsUpChild().getId() |
| 298 | != com.android.internal.R.id.status_bar_latest_event_content; |
Selim Cinek | 77019c7 | 2015-12-09 10:18:02 -0800 | [diff] [blame] | 299 | int headsUpheight = headsUpCustom && beforeN ? mMaxHeadsUpHeightLegacy |
| 300 | : mMaxHeadsUpHeight; |
Selim Cinek | a174487 | 2016-03-11 15:36:06 -0800 | [diff] [blame] | 301 | layout.setHeights(minHeight, headsUpheight, mNotificationMaxHeight); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | public StatusBarNotification getStatusBarNotification() { |
| 305 | return mStatusBarNotification; |
| 306 | } |
| 307 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 308 | public boolean isHeadsUp() { |
| 309 | return mIsHeadsUp; |
| 310 | } |
| 311 | |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 312 | public void setHeadsUp(boolean isHeadsUp) { |
Selim Cinek | c80fdb1 | 2015-04-13 15:09:08 -0700 | [diff] [blame] | 313 | int intrinsicBefore = getIntrinsicHeight(); |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 314 | mIsHeadsUp = isHeadsUp; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 315 | mPrivateLayout.setHeadsUp(isHeadsUp); |
Selim Cinek | b41b2f6 | 2016-04-26 14:03:29 -0700 | [diff] [blame] | 316 | if (mIsSummaryWithChildren) { |
| 317 | // The overflow might change since we allow more lines as HUN. |
| 318 | mChildrenContainer.updateGroupOverflow(); |
| 319 | } |
Selim Cinek | c80fdb1 | 2015-04-13 15:09:08 -0700 | [diff] [blame] | 320 | if (intrinsicBefore != getIntrinsicHeight()) { |
| 321 | notifyHeightChanged(false /* needsAnimation */); |
| 322 | } |
Selim Cinek | 1a521f3 | 2014-11-03 17:39:29 +0100 | [diff] [blame] | 323 | } |
| 324 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 325 | public void setGroupManager(NotificationGroupManager groupManager) { |
| 326 | mGroupManager = groupManager; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 327 | mPrivateLayout.setGroupManager(groupManager); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 328 | } |
| 329 | |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 330 | public void setRemoteInputController(RemoteInputController r) { |
| 331 | mPrivateLayout.setRemoteInputController(r); |
| 332 | } |
| 333 | |
Mady Mellor | 3fd273e | 2016-03-15 21:08:14 -0700 | [diff] [blame] | 334 | public void setAppName(String appName) { |
| 335 | mAppName = appName; |
| 336 | if (mSettingsIconRow != null) { |
| 337 | mSettingsIconRow.setAppName(mAppName); |
| 338 | } |
| 339 | } |
| 340 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 341 | public void addChildNotification(ExpandableNotificationRow row) { |
| 342 | addChildNotification(row, -1); |
| 343 | } |
| 344 | |
| 345 | /** |
| 346 | * Add a child notification to this view. |
| 347 | * |
| 348 | * @param row the row to add |
| 349 | * @param childIndex the index to add it at, if -1 it will be added at the end |
| 350 | */ |
| 351 | public void addChildNotification(ExpandableNotificationRow row, int childIndex) { |
| 352 | if (mChildrenContainer == null) { |
| 353 | mChildrenContainerStub.inflate(); |
| 354 | } |
| 355 | mChildrenContainer.addNotification(row, childIndex); |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 356 | onChildrenCountChanged(); |
| 357 | row.setIsChildInGroup(true, this); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | public void removeChildNotification(ExpandableNotificationRow row) { |
| 361 | if (mChildrenContainer != null) { |
| 362 | mChildrenContainer.removeNotification(row); |
| 363 | } |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 364 | onChildrenCountChanged(); |
| 365 | row.setIsChildInGroup(false, null); |
| 366 | } |
| 367 | |
| 368 | public boolean isChildInGroup() { |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 369 | return mNotificationParent != null; |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 370 | } |
| 371 | |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 372 | public ExpandableNotificationRow getNotificationParent() { |
| 373 | return mNotificationParent; |
| 374 | } |
| 375 | |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 376 | /** |
| 377 | * @param isChildInGroup Is this notification now in a group |
| 378 | * @param parent the new parent notification |
| 379 | */ |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 380 | public void setIsChildInGroup(boolean isChildInGroup, ExpandableNotificationRow parent) {; |
| 381 | boolean childInGroup = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS && isChildInGroup; |
| 382 | mNotificationParent = childInGroup ? parent : null; |
| 383 | mPrivateLayout.setIsChildInGroup(childInGroup); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 384 | updateBackgroundForGroupState(); |
| 385 | if (mNotificationParent != null) { |
| 386 | mNotificationParent.updateBackgroundForGroupState(); |
| 387 | } |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | @Override |
Selim Cinek | 7210947 | 2016-01-15 16:33:22 -0800 | [diff] [blame] | 391 | public boolean onTouchEvent(MotionEvent event) { |
| 392 | if (event.getActionMasked() != MotionEvent.ACTION_DOWN |
| 393 | || !isChildInGroup() || isGroupExpanded()) { |
| 394 | return super.onTouchEvent(event); |
| 395 | } else { |
| 396 | return false; |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | @Override |
Mady Mellor | f062580 | 2016-02-11 18:03:48 -0800 | [diff] [blame] | 401 | protected boolean handleSlideBack() { |
| 402 | if (mSettingsIconRow != null && mSettingsIconRow.isVisible()) { |
| 403 | animateTranslateNotification(0 /* targetLeft */); |
| 404 | return true; |
| 405 | } |
| 406 | return false; |
| 407 | } |
| 408 | |
| 409 | @Override |
Selim Cinek | 34d93b0 | 2015-10-22 12:30:38 -0700 | [diff] [blame] | 410 | protected boolean shouldHideBackground() { |
| 411 | return super.shouldHideBackground() || mShowNoBackground; |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | @Override |
| 415 | public boolean isSummaryWithChildren() { |
| 416 | return mIsSummaryWithChildren; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | @Override |
| 420 | public boolean areChildrenExpanded() { |
| 421 | return mChildrenExpanded; |
| 422 | } |
| 423 | |
| 424 | public List<ExpandableNotificationRow> getNotificationChildren() { |
| 425 | return mChildrenContainer == null ? null : mChildrenContainer.getNotificationChildren(); |
| 426 | } |
| 427 | |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 428 | public int getNumberOfNotificationChildren() { |
| 429 | if (mChildrenContainer == null) { |
| 430 | return 0; |
| 431 | } |
| 432 | return mChildrenContainer.getNotificationChildren().size(); |
| 433 | } |
| 434 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 435 | /** |
| 436 | * Apply the order given in the list to the children. |
| 437 | * |
| 438 | * @param childOrder the new list order |
| 439 | * @return whether the list order has changed |
| 440 | */ |
| 441 | public boolean applyChildOrder(List<ExpandableNotificationRow> childOrder) { |
| 442 | return mChildrenContainer != null && mChildrenContainer.applyChildOrder(childOrder); |
| 443 | } |
| 444 | |
| 445 | public void getChildrenStates(StackScrollState resultState) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 446 | if (mIsSummaryWithChildren) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 447 | StackViewState parentState = resultState.getViewStateForView(this); |
| 448 | mChildrenContainer.getState(resultState, parentState); |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | public void applyChildrenState(StackScrollState state) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 453 | if (mIsSummaryWithChildren) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 454 | mChildrenContainer.applyState(state); |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | public void prepareExpansionChanged(StackScrollState state) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 459 | if (mIsSummaryWithChildren) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 460 | mChildrenContainer.prepareExpansionChanged(state); |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | public void startChildAnimation(StackScrollState finalState, |
Selim Cinek | 9969559 | 2016-01-12 17:51:35 -0800 | [diff] [blame] | 465 | StackStateAnimator stateAnimator, long delay, long duration) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 466 | if (mIsSummaryWithChildren) { |
Selim Cinek | 9969559 | 2016-01-12 17:51:35 -0800 | [diff] [blame] | 467 | mChildrenContainer.startAnimationToState(finalState, stateAnimator, delay, |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 468 | duration); |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | public ExpandableNotificationRow getViewAtPosition(float y) { |
Selim Cinek | 43d30f0 | 2016-03-04 10:51:32 -0800 | [diff] [blame] | 473 | if (!mIsSummaryWithChildren || !mChildrenExpanded) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 474 | return this; |
| 475 | } else { |
| 476 | ExpandableNotificationRow view = mChildrenContainer.getViewAtPosition(y); |
| 477 | return view == null ? this : view; |
| 478 | } |
| 479 | } |
| 480 | |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 481 | public NotificationGuts getGuts() { |
| 482 | return mGuts; |
| 483 | } |
| 484 | |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 485 | /** |
| 486 | * Set this notification to be pinned to the top if {@link #isHeadsUp()} is true. By doing this |
| 487 | * the notification will be rendered on top of the screen. |
| 488 | * |
| 489 | * @param pinned whether it is pinned |
| 490 | */ |
| 491 | public void setPinned(boolean pinned) { |
Selim Cinek | def35a8 | 2016-05-03 15:52:51 -0700 | [diff] [blame] | 492 | int intrinsicHeight = getIntrinsicHeight(); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 493 | mIsPinned = pinned; |
Selim Cinek | def35a8 | 2016-05-03 15:52:51 -0700 | [diff] [blame] | 494 | if (intrinsicHeight != getIntrinsicHeight()) { |
| 495 | notifyHeightChanged(false); |
| 496 | } |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 497 | if (pinned) { |
| 498 | setIconAnimationRunning(true); |
| 499 | mExpandedWhenPinned = false; |
| 500 | } else if (mExpandedWhenPinned) { |
| 501 | setUserExpanded(true); |
| 502 | } |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 503 | setChronometerRunning(mLastChronometerRunning); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 504 | } |
| 505 | |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 506 | public boolean isPinned() { |
| 507 | return mIsPinned; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 508 | } |
| 509 | |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 510 | /** |
| 511 | * @param atLeastMinHeight should the value returned be at least the minimum height. |
| 512 | * Used to avoid cyclic calls |
| 513 | * @return the height of the heads up notification when pinned |
| 514 | */ |
| 515 | public int getPinnedHeadsUpHeight(boolean atLeastMinHeight) { |
Selim Cinek | 77019c7 | 2015-12-09 10:18:02 -0800 | [diff] [blame] | 516 | if (mIsSummaryWithChildren) { |
| 517 | return mChildrenContainer.getIntrinsicHeight(); |
| 518 | } |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 519 | if(mExpandedWhenPinned) { |
| 520 | return Math.max(getMaxExpandHeight(), mHeadsUpHeight); |
| 521 | } else if (atLeastMinHeight) { |
Selim Cinek | 567e845 | 2016-03-24 10:54:56 -0700 | [diff] [blame] | 522 | return Math.max(getCollapsedHeight(), mHeadsUpHeight); |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 523 | } else { |
| 524 | return mHeadsUpHeight; |
| 525 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 526 | } |
| 527 | |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 528 | /** |
| 529 | * Mark whether this notification was just clicked, i.e. the user has just clicked this |
| 530 | * notification in this frame. |
| 531 | */ |
| 532 | public void setJustClicked(boolean justClicked) { |
| 533 | mJustClicked = justClicked; |
| 534 | } |
| 535 | |
| 536 | /** |
| 537 | * @return true if this notification has been clicked in this frame, false otherwise |
| 538 | */ |
| 539 | public boolean wasJustClicked() { |
| 540 | return mJustClicked; |
| 541 | } |
| 542 | |
Selim Cinek | 98713a4 | 2015-09-21 15:47:20 +0200 | [diff] [blame] | 543 | public void setChronometerRunning(boolean running) { |
| 544 | mLastChronometerRunning = running; |
| 545 | setChronometerRunning(running, mPrivateLayout); |
| 546 | setChronometerRunning(running, mPublicLayout); |
| 547 | if (mChildrenContainer != null) { |
| 548 | List<ExpandableNotificationRow> notificationChildren = |
| 549 | mChildrenContainer.getNotificationChildren(); |
| 550 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 551 | ExpandableNotificationRow child = notificationChildren.get(i); |
| 552 | child.setChronometerRunning(running); |
| 553 | } |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | private void setChronometerRunning(boolean running, NotificationContentView layout) { |
| 558 | if (layout != null) { |
| 559 | running = running || isPinned(); |
| 560 | View contractedChild = layout.getContractedChild(); |
| 561 | View expandedChild = layout.getExpandedChild(); |
| 562 | View headsUpChild = layout.getHeadsUpChild(); |
| 563 | setChronometerRunningForChild(running, contractedChild); |
| 564 | setChronometerRunningForChild(running, expandedChild); |
| 565 | setChronometerRunningForChild(running, headsUpChild); |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | private void setChronometerRunningForChild(boolean running, View child) { |
| 570 | if (child != null) { |
| 571 | View chronometer = child.findViewById(com.android.internal.R.id.chronometer); |
| 572 | if (chronometer instanceof Chronometer) { |
| 573 | ((Chronometer) chronometer).setStarted(running); |
| 574 | } |
| 575 | } |
| 576 | } |
| 577 | |
Selim Cinek | ea4bef7 | 2015-12-02 15:51:10 -0800 | [diff] [blame] | 578 | public NotificationHeaderView getNotificationHeader() { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 579 | if (mIsSummaryWithChildren) { |
| 580 | return mChildrenContainer.getHeaderView(); |
Selim Cinek | 8d6440d | 2015-10-22 13:00:05 -0700 | [diff] [blame] | 581 | } |
Selim Cinek | ea4bef7 | 2015-12-02 15:51:10 -0800 | [diff] [blame] | 582 | return mPrivateLayout.getNotificationHeader(); |
Selim Cinek | 8d6440d | 2015-10-22 13:00:05 -0700 | [diff] [blame] | 583 | } |
| 584 | |
Selim Cinek | 34eda5e | 2016-02-18 17:10:43 -0800 | [diff] [blame] | 585 | private NotificationHeaderView getVisibleNotificationHeader() { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 586 | if (mIsSummaryWithChildren) { |
| 587 | return mChildrenContainer.getHeaderView(); |
Selim Cinek | 34eda5e | 2016-02-18 17:10:43 -0800 | [diff] [blame] | 588 | } |
| 589 | return getShowingLayout().getVisibleNotificationHeader(); |
| 590 | } |
| 591 | |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 592 | public void setOnExpandClickListener(OnExpandClickListener onExpandClickListener) { |
| 593 | mOnExpandClickListener = onExpandClickListener; |
| 594 | } |
| 595 | |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 596 | public void setHeadsUpManager(HeadsUpManager headsUpManager) { |
| 597 | mHeadsUpManager = headsUpManager; |
| 598 | } |
| 599 | |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 600 | public void reInflateViews() { |
| 601 | initDimens(); |
| 602 | if (mIsSummaryWithChildren) { |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 603 | if (mChildrenContainer != null) { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 604 | mChildrenContainer.reInflateViews(mExpandClickListener, mEntry.notification); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 605 | } |
| 606 | } |
| 607 | if (mGuts != null) { |
| 608 | View oldGuts = mGuts; |
| 609 | int index = indexOfChild(oldGuts); |
| 610 | removeView(oldGuts); |
| 611 | mGuts = (NotificationGuts) LayoutInflater.from(mContext).inflate( |
| 612 | R.layout.notification_guts, this, false); |
| 613 | mGuts.setVisibility(oldGuts.getVisibility()); |
| 614 | addView(mGuts, index); |
| 615 | } |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 616 | if (mSettingsIconRow != null) { |
| 617 | View oldSettings = mSettingsIconRow; |
| 618 | int settingsIndex = indexOfChild(oldSettings); |
| 619 | removeView(oldSettings); |
| 620 | mSettingsIconRow = (NotificationSettingsIconRow) LayoutInflater.from(mContext).inflate( |
| 621 | R.layout.notification_settings_icon_row, this, false); |
| 622 | mSettingsIconRow.setNotificationRowParent(ExpandableNotificationRow.this); |
Mady Mellor | 3fd273e | 2016-03-15 21:08:14 -0700 | [diff] [blame] | 623 | mSettingsIconRow.setAppName(mAppName); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 624 | mSettingsIconRow.setVisibility(oldSettings.getVisibility()); |
| 625 | addView(mSettingsIconRow, settingsIndex); |
| 626 | |
| 627 | } |
Selim Cinek | de33a4a | 2016-02-11 16:43:41 -0800 | [diff] [blame] | 628 | mPrivateLayout.reInflateViews(); |
| 629 | mPublicLayout.reInflateViews(); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 630 | } |
| 631 | |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 632 | public void setContentBackground(int customBackgroundColor, boolean animate, |
| 633 | NotificationContentView notificationContentView) { |
| 634 | if (getShowingLayout() == notificationContentView) { |
| 635 | setTintColor(customBackgroundColor, animate); |
| 636 | } |
| 637 | } |
| 638 | |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 639 | public void closeRemoteInput() { |
| 640 | mPrivateLayout.closeRemoteInput(); |
| 641 | mPublicLayout.closeRemoteInput(); |
| 642 | } |
| 643 | |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 644 | /** |
| 645 | * Set by how much the single line view should be indented. |
| 646 | */ |
| 647 | public void setSingleLineWidthIndention(int indention) { |
| 648 | mPrivateLayout.setSingleLineWidthIndention(indention); |
| 649 | } |
| 650 | |
| 651 | public int getNotificationColor() { |
Selim Cinek | 4bb5934 | 2016-04-08 19:29:35 -0700 | [diff] [blame] | 652 | return mNotificationColor; |
| 653 | } |
| 654 | |
| 655 | private void updateNotificationColor() { |
| 656 | mNotificationColor = NotificationColorUtil.resolveContrastColor(mContext, |
| 657 | getStatusBarNotification().getNotification().color); |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | public HybridNotificationView getSingleLineView() { |
| 661 | return mPrivateLayout.getSingleLineView(); |
| 662 | } |
| 663 | |
Selim Cinek | f07d062 | 2016-03-21 19:52:52 -0700 | [diff] [blame] | 664 | public boolean isOnKeyguard() { |
| 665 | return mOnKeyguard; |
| 666 | } |
| 667 | |
Selim Cinek | c1e389d | 2016-04-07 11:02:57 -0700 | [diff] [blame] | 668 | public void removeAllChildren() { |
| 669 | List<ExpandableNotificationRow> notificationChildren |
| 670 | = mChildrenContainer.getNotificationChildren(); |
| 671 | ArrayList<ExpandableNotificationRow> clonedList = new ArrayList<>(notificationChildren); |
| 672 | for (int i = 0; i < clonedList.size(); i++) { |
| 673 | ExpandableNotificationRow row = clonedList.get(i); |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 674 | if (row.keepInParent()) { |
| 675 | continue; |
| 676 | } |
Selim Cinek | c1e389d | 2016-04-07 11:02:57 -0700 | [diff] [blame] | 677 | mChildrenContainer.removeNotification(row); |
Selim Cinek | c1e389d | 2016-04-07 11:02:57 -0700 | [diff] [blame] | 678 | row.setIsChildInGroup(false, null); |
| 679 | } |
| 680 | onChildrenCountChanged(); |
| 681 | } |
| 682 | |
Selim Cinek | 1b2a05e | 2016-04-28 14:20:39 -0700 | [diff] [blame] | 683 | public void setForceUnlocked(boolean forceUnlocked) { |
| 684 | mForceUnlocked = forceUnlocked; |
| 685 | if (mIsSummaryWithChildren) { |
| 686 | List<ExpandableNotificationRow> notificationChildren = getNotificationChildren(); |
| 687 | for (ExpandableNotificationRow child : notificationChildren) { |
| 688 | child.setForceUnlocked(forceUnlocked); |
| 689 | } |
| 690 | } |
| 691 | } |
| 692 | |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 693 | public void setDismissed(boolean dismissed) { |
| 694 | mDismissed = dismissed; |
| 695 | } |
| 696 | |
| 697 | public boolean isDismissed() { |
| 698 | return mDismissed; |
| 699 | } |
| 700 | |
| 701 | public boolean keepInParent() { |
| 702 | return mKeepInParent; |
| 703 | } |
| 704 | |
| 705 | public void setKeepInParent(boolean keepInParent) { |
| 706 | mKeepInParent = keepInParent; |
| 707 | } |
| 708 | |
| 709 | public boolean isRemoved() { |
| 710 | return mRemoved; |
| 711 | } |
| 712 | |
Adrian Roos | d009ab1 | 2016-05-20 17:58:53 -0700 | [diff] [blame] | 713 | public void setRemoved() { |
| 714 | mRemoved = true; |
| 715 | |
| 716 | mPrivateLayout.setRemoved(); |
| 717 | if (mChildrenContainer != null) { |
| 718 | mChildrenContainer.setRemoved(); |
| 719 | } |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 720 | } |
| 721 | |
Selim Cinek | d139564 | 2016-04-28 12:22:42 -0700 | [diff] [blame] | 722 | public NotificationChildrenContainer getChildrenContainer() { |
| 723 | return mChildrenContainer; |
| 724 | } |
| 725 | |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 726 | public interface ExpansionLogger { |
| 727 | public void logNotificationExpansion(String key, boolean userAction, boolean expanded); |
| 728 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 729 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 730 | public ExpandableNotificationRow(Context context, AttributeSet attrs) { |
| 731 | super(context, attrs); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 732 | mFalsingManager = FalsingManager.getInstance(context); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 733 | initDimens(); |
| 734 | } |
| 735 | |
| 736 | private void initDimens() { |
Selim Cinek | f619ffc | 2016-02-17 14:53:05 -0800 | [diff] [blame] | 737 | mNotificationMinHeightLegacy = getFontScaledHeight(R.dimen.notification_min_height_legacy); |
| 738 | mNotificationMinHeight = getFontScaledHeight(R.dimen.notification_min_height); |
| 739 | mNotificationMaxHeight = getFontScaledHeight(R.dimen.notification_max_height); |
| 740 | mMaxHeadsUpHeightLegacy = getFontScaledHeight( |
Selim Cinek | 77019c7 | 2015-12-09 10:18:02 -0800 | [diff] [blame] | 741 | R.dimen.notification_max_heads_up_height_legacy); |
Selim Cinek | f619ffc | 2016-02-17 14:53:05 -0800 | [diff] [blame] | 742 | mMaxHeadsUpHeight = getFontScaledHeight(R.dimen.notification_max_heads_up_height); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 743 | mIncreasedPaddingBetweenElements = getResources() |
| 744 | .getDimensionPixelSize(R.dimen.notification_divider_height_increased); |
Selim Cinek | f619ffc | 2016-02-17 14:53:05 -0800 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | /** |
| 748 | * @param dimenId the dimen to look up |
| 749 | * @return the font scaled dimen as if it were in sp but doesn't shrink sizes below dp |
| 750 | */ |
| 751 | private int getFontScaledHeight(int dimenId) { |
| 752 | int dimensionPixelSize = getResources().getDimensionPixelSize(dimenId); |
| 753 | float factor = Math.max(1.0f, getResources().getDisplayMetrics().scaledDensity / |
| 754 | getResources().getDisplayMetrics().density); |
| 755 | return (int) (dimensionPixelSize * factor); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 756 | } |
| 757 | |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 758 | /** |
| 759 | * Resets this view so it can be re-used for an updated notification. |
| 760 | */ |
Christoph Studer | 22f2ee5 | 2014-07-29 22:57:21 +0200 | [diff] [blame] | 761 | @Override |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 762 | public void reset() { |
Christoph Studer | 22f2ee5 | 2014-07-29 22:57:21 +0200 | [diff] [blame] | 763 | super.reset(); |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 764 | final boolean wasExpanded = isExpanded(); |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 765 | mExpandable = false; |
| 766 | mHasUserChangedExpansion = false; |
| 767 | mUserLocked = false; |
| 768 | mShowingPublic = false; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 769 | mSensitive = false; |
| 770 | mShowingPublicInitialized = false; |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 771 | mIsSystemExpanded = false; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 772 | mOnKeyguard = false; |
Selim Cinek | 51d9491 | 2016-03-02 15:34:28 -0800 | [diff] [blame] | 773 | mPublicLayout.reset(); |
| 774 | mPrivateLayout.reset(); |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 775 | resetHeight(); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 776 | resetTranslation(); |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 777 | logExpansionEvent(false, wasExpanded); |
| 778 | } |
| 779 | |
| 780 | public void resetHeight() { |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 781 | mMaxExpandHeight = 0; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 782 | mHeadsUpHeight = 0; |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 783 | onHeightReset(); |
Selim Cinek | 6e28a67 | 2014-09-05 14:43:28 +0200 | [diff] [blame] | 784 | requestLayout(); |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 785 | } |
| 786 | |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 787 | @Override |
| 788 | protected void onFinishInflate() { |
| 789 | super.onFinishInflate(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 790 | mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic); |
Selim Cinek | fa0a2d3 | 2016-01-14 13:02:21 -0800 | [diff] [blame] | 791 | mPublicLayout.setContainingNotification(this); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 792 | mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded); |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 793 | mPrivateLayout.setExpandClickListener(mExpandClickListener); |
Selim Cinek | fa0a2d3 | 2016-01-14 13:02:21 -0800 | [diff] [blame] | 794 | mPrivateLayout.setContainingNotification(this); |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 795 | mPublicLayout.setExpandClickListener(mExpandClickListener); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 796 | mSettingsIconRowStub = (ViewStub) findViewById(R.id.settings_icon_row_stub); |
| 797 | mSettingsIconRowStub.setOnInflateListener(new ViewStub.OnInflateListener() { |
| 798 | @Override |
| 799 | public void onInflate(ViewStub stub, View inflated) { |
| 800 | mSettingsIconRow = (NotificationSettingsIconRow) inflated; |
| 801 | mSettingsIconRow.setNotificationRowParent(ExpandableNotificationRow.this); |
Mady Mellor | 3fd273e | 2016-03-15 21:08:14 -0700 | [diff] [blame] | 802 | mSettingsIconRow.setAppName(mAppName); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 803 | } |
| 804 | }); |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 805 | mGutsStub = (ViewStub) findViewById(R.id.notification_guts_stub); |
| 806 | mGutsStub.setOnInflateListener(new ViewStub.OnInflateListener() { |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 807 | @Override |
| 808 | public void onInflate(ViewStub stub, View inflated) { |
| 809 | mGuts = (NotificationGuts) inflated; |
| 810 | mGuts.setClipTopAmount(getClipTopAmount()); |
| 811 | mGuts.setActualHeight(getActualHeight()); |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 812 | mGutsStub = null; |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 813 | } |
| 814 | }); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 815 | mChildrenContainerStub = (ViewStub) findViewById(R.id.child_container_stub); |
| 816 | mChildrenContainerStub.setOnInflateListener(new ViewStub.OnInflateListener() { |
| 817 | |
| 818 | @Override |
| 819 | public void onInflate(ViewStub stub, View inflated) { |
| 820 | mChildrenContainer = (NotificationChildrenContainer) inflated; |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 821 | mChildrenContainer.setNotificationParent(ExpandableNotificationRow.this); |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 822 | mChildrenContainer.onNotificationUpdated(); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 823 | mTranslateableViews.add(mChildrenContainer); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 824 | } |
| 825 | }); |
Selim Cinek | 863834b | 2014-05-20 04:20:25 +0200 | [diff] [blame] | 826 | mVetoButton = findViewById(R.id.veto); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 827 | |
| 828 | // Add the views that we translate to reveal the gear |
| 829 | mTranslateableViews = new ArrayList<View>(); |
| 830 | for (int i = 0; i < getChildCount(); i++) { |
| 831 | mTranslateableViews.add(getChildAt(i)); |
| 832 | } |
| 833 | // Remove views that don't translate |
| 834 | mTranslateableViews.remove(mVetoButton); |
| 835 | mTranslateableViews.remove(mSettingsIconRowStub); |
| 836 | mTranslateableViews.remove(mChildrenContainerStub); |
| 837 | mTranslateableViews.remove(mGutsStub); |
| 838 | } |
| 839 | |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 840 | public void resetTranslation() { |
| 841 | if (mTranslateableViews != null) { |
| 842 | for (int i = 0; i < mTranslateableViews.size(); i++) { |
| 843 | mTranslateableViews.get(i).setTranslationX(0); |
| 844 | } |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 845 | } |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 846 | invalidateOutline(); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 847 | if (mSettingsIconRow != null) { |
| 848 | mSettingsIconRow.resetState(); |
| 849 | } |
| 850 | } |
| 851 | |
| 852 | public void animateTranslateNotification(final float leftTarget) { |
| 853 | if (mTranslateAnim != null) { |
| 854 | mTranslateAnim.cancel(); |
| 855 | } |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 856 | mTranslateAnim = getTranslateViewAnimator(leftTarget, null /* updateListener */); |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 857 | if (mTranslateAnim != null) { |
| 858 | mTranslateAnim.start(); |
| 859 | } |
| 860 | } |
| 861 | |
| 862 | @Override |
| 863 | public void setTranslation(float translationX) { |
| 864 | if (areGutsExposed()) { |
| 865 | // Don't translate if guts are showing. |
| 866 | return; |
| 867 | } |
| 868 | // Translate the group of views |
| 869 | for (int i = 0; i < mTranslateableViews.size(); i++) { |
| 870 | if (mTranslateableViews.get(i) != null) { |
| 871 | mTranslateableViews.get(i).setTranslationX(translationX); |
| 872 | } |
| 873 | } |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 874 | invalidateOutline(); |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 875 | if (mSettingsIconRow != null) { |
| 876 | mSettingsIconRow.updateSettingsIcons(translationX, getMeasuredWidth()); |
| 877 | } |
| 878 | } |
| 879 | |
| 880 | @Override |
| 881 | public float getTranslation() { |
| 882 | if (mTranslateableViews != null && mTranslateableViews.size() > 0) { |
| 883 | // All of the views in the list should have same translation, just use first one. |
| 884 | return mTranslateableViews.get(0).getTranslationX(); |
| 885 | } |
| 886 | return 0; |
| 887 | } |
| 888 | |
| 889 | public Animator getTranslateViewAnimator(final float leftTarget, |
| 890 | AnimatorUpdateListener listener) { |
Mady Mellor | 723f1f9 | 2016-03-13 15:54:06 -0700 | [diff] [blame] | 891 | if (mTranslateAnim != null) { |
| 892 | mTranslateAnim.cancel(); |
| 893 | } |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 894 | if (areGutsExposed()) { |
| 895 | // No translation if guts are exposed. |
| 896 | return null; |
| 897 | } |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 898 | final ObjectAnimator translateAnim = ObjectAnimator.ofFloat(this, TRANSLATE_CONTENT, |
| 899 | leftTarget); |
| 900 | if (listener != null) { |
| 901 | translateAnim.addUpdateListener(listener); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 902 | } |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 903 | translateAnim.addListener(new AnimatorListenerAdapter() { |
| 904 | boolean cancelled = false; |
| 905 | |
| 906 | @Override |
| 907 | public void onAnimationCancel(Animator anim) { |
| 908 | cancelled = true; |
| 909 | } |
| 910 | |
| 911 | @Override |
| 912 | public void onAnimationEnd(Animator anim) { |
| 913 | if (!cancelled && mSettingsIconRow != null && leftTarget == 0) { |
| 914 | mSettingsIconRow.resetState(); |
| 915 | mTranslateAnim = null; |
| 916 | } |
| 917 | } |
| 918 | }); |
| 919 | mTranslateAnim = translateAnim; |
| 920 | return translateAnim; |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 921 | } |
| 922 | |
| 923 | public float getSpaceForGear() { |
| 924 | if (mSettingsIconRow != null) { |
| 925 | return mSettingsIconRow.getSpaceForGear(); |
| 926 | } |
| 927 | return 0; |
| 928 | } |
| 929 | |
| 930 | public NotificationSettingsIconRow getSettingsRow() { |
| 931 | if (mSettingsIconRow == null) { |
| 932 | mSettingsIconRowStub.inflate(); |
| 933 | } |
| 934 | return mSettingsIconRow; |
| 935 | } |
| 936 | |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 937 | public void inflateGuts() { |
| 938 | if (mGuts == null) { |
| 939 | mGutsStub.inflate(); |
| 940 | } |
| 941 | } |
| 942 | |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 943 | private void updateChildrenVisibility() { |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 944 | mPrivateLayout.setVisibility(!mShowingPublic && !mIsSummaryWithChildren ? VISIBLE |
| 945 | : INVISIBLE); |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 946 | if (mChildrenContainer != null) { |
| 947 | mChildrenContainer.setVisibility(!mShowingPublic && mIsSummaryWithChildren ? VISIBLE |
| 948 | : INVISIBLE); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 949 | mChildrenContainer.updateHeaderVisibility(!mShowingPublic && mIsSummaryWithChildren |
| 950 | ? VISIBLE |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 951 | : INVISIBLE); |
| 952 | } |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 953 | // The limits might have changed if the view suddenly became a group or vice versa |
| 954 | updateLimits(); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 955 | } |
| 956 | |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 957 | @Override |
Alan Viverette | a54956a | 2015-01-07 16:05:02 -0800 | [diff] [blame] | 958 | public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event) { |
| 959 | if (super.onRequestSendAccessibilityEventInternal(child, event)) { |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 960 | // Add a record for the entire layout since its content is somehow small. |
| 961 | // The event comes from a leaf view that is interacted with. |
| 962 | AccessibilityEvent record = AccessibilityEvent.obtain(); |
| 963 | onInitializeAccessibilityEvent(record); |
| 964 | dispatchPopulateAccessibilityEvent(record); |
| 965 | event.appendRecord(record); |
| 966 | return true; |
| 967 | } |
| 968 | return false; |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 969 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 970 | |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 971 | @Override |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 972 | public void setDark(boolean dark, boolean fade, long delay) { |
| 973 | super.setDark(dark, fade, delay); |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 974 | final NotificationContentView showing = getShowingLayout(); |
| 975 | if (showing != null) { |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 976 | showing.setDark(dark, fade, delay); |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 977 | } |
Selim Cinek | 9c7712d | 2015-12-08 19:19:48 -0800 | [diff] [blame] | 978 | if (mIsSummaryWithChildren) { |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 979 | mChildrenContainer.setDark(dark, fade, delay); |
Selim Cinek | 9c7712d | 2015-12-08 19:19:48 -0800 | [diff] [blame] | 980 | } |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 981 | } |
| 982 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 983 | public boolean isExpandable() { |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 984 | if (mIsSummaryWithChildren && !mShowingPublic) { |
| 985 | return !mChildrenExpanded; |
| 986 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 987 | return mExpandable; |
| 988 | } |
| 989 | |
| 990 | public void setExpandable(boolean expandable) { |
| 991 | mExpandable = expandable; |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 992 | mPrivateLayout.updateExpandButtons(isExpandable()); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 993 | } |
| 994 | |
Selim Cinek | 4ffd636 | 2015-12-29 15:12:23 +0100 | [diff] [blame] | 995 | @Override |
| 996 | public void setClipToActualHeight(boolean clipToActualHeight) { |
Selim Cinek | 084c16b | 2016-01-22 17:48:22 -0800 | [diff] [blame] | 997 | super.setClipToActualHeight(clipToActualHeight || isUserLocked()); |
| 998 | getShowingLayout().setClipToActualHeight(clipToActualHeight || isUserLocked()); |
Selim Cinek | 4ffd636 | 2015-12-29 15:12:23 +0100 | [diff] [blame] | 999 | } |
| 1000 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1001 | /** |
| 1002 | * @return whether the user has changed the expansion state |
| 1003 | */ |
| 1004 | public boolean hasUserChangedExpansion() { |
| 1005 | return mHasUserChangedExpansion; |
| 1006 | } |
| 1007 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1008 | public boolean isUserExpanded() { |
| 1009 | return mUserExpanded; |
| 1010 | } |
| 1011 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1012 | /** |
| 1013 | * Set this notification to be expanded by the user |
| 1014 | * |
| 1015 | * @param userExpanded whether the user wants this notification to be expanded |
| 1016 | */ |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1017 | public void setUserExpanded(boolean userExpanded) { |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 1018 | setUserExpanded(userExpanded, false /* allowChildExpansion */); |
| 1019 | } |
| 1020 | |
| 1021 | /** |
| 1022 | * Set this notification to be expanded by the user |
| 1023 | * |
| 1024 | * @param userExpanded whether the user wants this notification to be expanded |
| 1025 | * @param allowChildExpansion whether a call to this method allows expanding children |
| 1026 | */ |
| 1027 | public void setUserExpanded(boolean userExpanded, boolean allowChildExpansion) { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 1028 | mFalsingManager.setNotificationExpanded(); |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 1029 | if (mIsSummaryWithChildren && !mShowingPublic && allowChildExpansion) { |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame^] | 1030 | final boolean wasExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification); |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 1031 | mGroupManager.setGroupExpanded(mStatusBarNotification, userExpanded); |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame^] | 1032 | logExpansionEvent(true /* userAction */, wasExpanded); |
Selim Cinek | 388df6d | 2015-10-22 13:25:11 -0700 | [diff] [blame] | 1033 | return; |
| 1034 | } |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 1035 | if (userExpanded && !mExpandable) return; |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1036 | final boolean wasExpanded = isExpanded(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1037 | mHasUserChangedExpansion = true; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1038 | mUserExpanded = userExpanded; |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1039 | logExpansionEvent(true, wasExpanded); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1040 | } |
| 1041 | |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 1042 | public void resetUserExpansion() { |
| 1043 | mHasUserChangedExpansion = false; |
| 1044 | mUserExpanded = false; |
| 1045 | } |
| 1046 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1047 | public boolean isUserLocked() { |
Selim Cinek | 1b2a05e | 2016-04-28 14:20:39 -0700 | [diff] [blame] | 1048 | return mUserLocked && !mForceUnlocked; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1049 | } |
| 1050 | |
| 1051 | public void setUserLocked(boolean userLocked) { |
| 1052 | mUserLocked = userLocked; |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 1053 | mPrivateLayout.setUserExpanding(userLocked); |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1054 | if (mIsSummaryWithChildren) { |
| 1055 | mChildrenContainer.setUserLocked(userLocked); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1056 | if (userLocked) { |
| 1057 | updateBackgroundForGroupState(); |
| 1058 | } |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1059 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1060 | } |
| 1061 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1062 | /** |
| 1063 | * @return has the system set this notification to be expanded |
| 1064 | */ |
| 1065 | public boolean isSystemExpanded() { |
| 1066 | return mIsSystemExpanded; |
| 1067 | } |
| 1068 | |
| 1069 | /** |
| 1070 | * Set this notification to be expanded by the system. |
| 1071 | * |
| 1072 | * @param expand whether the system wants this notification to be expanded. |
| 1073 | */ |
| 1074 | public void setSystemExpanded(boolean expand) { |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1075 | if (expand != mIsSystemExpanded) { |
| 1076 | final boolean wasExpanded = isExpanded(); |
| 1077 | mIsSystemExpanded = expand; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1078 | notifyHeightChanged(false /* needsAnimation */); |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1079 | logExpansionEvent(false, wasExpanded); |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 1080 | if (mChildrenContainer != null) { |
| 1081 | mChildrenContainer.updateGroupOverflow(); |
| 1082 | } |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1083 | } |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 1084 | } |
| 1085 | |
| 1086 | /** |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1087 | * @param onKeyguard whether to prevent notification expansion |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 1088 | */ |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1089 | public void setOnKeyguard(boolean onKeyguard) { |
| 1090 | if (onKeyguard != mOnKeyguard) { |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1091 | final boolean wasExpanded = isExpanded(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1092 | mOnKeyguard = onKeyguard; |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1093 | logExpansionEvent(false, wasExpanded); |
| 1094 | if (wasExpanded != isExpanded()) { |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 1095 | if (mIsSummaryWithChildren) { |
| 1096 | mChildrenContainer.updateGroupOverflow(); |
| 1097 | } |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1098 | notifyHeightChanged(false /* needsAnimation */); |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1099 | } |
| 1100 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1101 | } |
| 1102 | |
| 1103 | /** |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 1104 | * @return Can the underlying notification be cleared? |
| 1105 | */ |
| 1106 | public boolean isClearable() { |
Selim Cinek | a37774f | 2014-11-11 19:16:18 +0100 | [diff] [blame] | 1107 | return mStatusBarNotification != null && mStatusBarNotification.isClearable(); |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 1108 | } |
| 1109 | |
Jorim Jaggi | 9cbadd3 | 2014-05-01 20:18:31 +0200 | [diff] [blame] | 1110 | @Override |
| 1111 | public int getIntrinsicHeight() { |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1112 | if (isUserLocked()) { |
| 1113 | return getActualHeight(); |
| 1114 | } |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1115 | if (mGuts != null && mGuts.areGutsExposed()) { |
| 1116 | return mGuts.getHeight(); |
| 1117 | } else if ((isChildInGroup() && !isGroupExpanded())) { |
| 1118 | return mPrivateLayout.getMinHeight(); |
| 1119 | } else if (mSensitive && mHideSensitiveForIntrinsicHeight) { |
| 1120 | return getMinHeight(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1121 | } else if (mIsSummaryWithChildren && !mOnKeyguard) { |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 1122 | return mChildrenContainer.getIntrinsicHeight(); |
Selim Cinek | 60122be | 2015-04-15 18:16:50 -0700 | [diff] [blame] | 1123 | } else if (mIsHeadsUp) { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 1124 | if (isPinned()) { |
| 1125 | return getPinnedHeadsUpHeight(true /* atLeastMinHeight */); |
| 1126 | } else if (isExpanded()) { |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1127 | return Math.max(getMaxExpandHeight(), mHeadsUpHeight); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1128 | } else { |
Selim Cinek | 567e845 | 2016-03-24 10:54:56 -0700 | [diff] [blame] | 1129 | return Math.max(getCollapsedHeight(), mHeadsUpHeight); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1130 | } |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 1131 | } else if (isExpanded()) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1132 | return getMaxExpandHeight(); |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1133 | } else { |
Selim Cinek | 567e845 | 2016-03-24 10:54:56 -0700 | [diff] [blame] | 1134 | return getCollapsedHeight(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1135 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1136 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1137 | |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1138 | public boolean isGroupExpanded() { |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 1139 | return mGroupManager.isGroupExpanded(mStatusBarNotification); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1140 | } |
| 1141 | |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 1142 | private void onChildrenCountChanged() { |
Selim Cinek | 8fc93c9 | 2015-11-23 17:48:07 -0800 | [diff] [blame] | 1143 | mIsSummaryWithChildren = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1144 | && mChildrenContainer != null && mChildrenContainer.getNotificationChildCount() > 0; |
| 1145 | if (mIsSummaryWithChildren && mChildrenContainer.getHeaderView() == null) { |
| 1146 | mChildrenContainer.recreateNotificationHeader(mExpandClickListener, |
| 1147 | mEntry.notification); |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 1148 | } |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 1149 | mPrivateLayout.updateExpandButtons(isExpandable()); |
Selim Cinek | ea4bef7 | 2015-12-02 15:51:10 -0800 | [diff] [blame] | 1150 | updateChildrenHeaderAppearance(); |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 1151 | updateChildrenVisibility(); |
Selim Cinek | 263398f | 2015-10-21 17:40:23 -0700 | [diff] [blame] | 1152 | } |
| 1153 | |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1154 | public void updateChildrenHeaderAppearance() { |
| 1155 | if (mChildrenContainer != null) { |
| 1156 | mChildrenContainer.updateChildrenHeaderAppearance(); |
| 1157 | } |
| 1158 | } |
| 1159 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1160 | /** |
| 1161 | * Check whether the view state is currently expanded. This is given by the system in {@link |
| 1162 | * #setSystemExpanded(boolean)} and can be overridden by user expansion or |
| 1163 | * collapsing in {@link #setUserExpanded(boolean)}. Note that the visual appearance of this |
| 1164 | * view can differ from this state, if layout params are modified from outside. |
| 1165 | * |
| 1166 | * @return whether the view state is currently expanded. |
| 1167 | */ |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1168 | public boolean isExpanded() { |
Selim Cinek | e81b82b | 2016-03-04 11:22:28 -0800 | [diff] [blame] | 1169 | return isExpanded(false /* allowOnKeyguard */); |
| 1170 | } |
| 1171 | |
| 1172 | public boolean isExpanded(boolean allowOnKeyguard) { |
| 1173 | return (!mOnKeyguard || allowOnKeyguard) |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1174 | && (!hasUserChangedExpansion() && (isSystemExpanded() || isSystemChildExpanded()) |
| 1175 | || isUserExpanded()); |
| 1176 | } |
| 1177 | |
| 1178 | private boolean isSystemChildExpanded() { |
| 1179 | return mIsSystemChildExpanded; |
| 1180 | } |
| 1181 | |
| 1182 | public void setSystemChildExpanded(boolean expanded) { |
| 1183 | mIsSystemChildExpanded = expanded; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1184 | } |
| 1185 | |
| 1186 | @Override |
| 1187 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
| 1188 | super.onLayout(changed, left, top, right, bottom); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1189 | updateMaxHeights(); |
Mady Mellor | a6edc87 | 2016-04-26 11:01:03 -0700 | [diff] [blame] | 1190 | if (mSettingsIconRow != null) { |
| 1191 | mSettingsIconRow.updateVerticalLocation(); |
| 1192 | } |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1193 | } |
| 1194 | |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1195 | private void updateMaxHeights() { |
Selim Cinek | d2319fb | 2014-09-01 19:41:54 +0200 | [diff] [blame] | 1196 | int intrinsicBefore = getIntrinsicHeight(); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1197 | View expandedChild = mPrivateLayout.getExpandedChild(); |
| 1198 | if (expandedChild == null) { |
| 1199 | expandedChild = mPrivateLayout.getContractedChild(); |
| 1200 | } |
| 1201 | mMaxExpandHeight = expandedChild.getHeight(); |
| 1202 | View headsUpChild = mPrivateLayout.getHeadsUpChild(); |
Selim Cinek | 1f3f544 | 2015-04-10 17:54:46 -0700 | [diff] [blame] | 1203 | if (headsUpChild == null) { |
| 1204 | headsUpChild = mPrivateLayout.getContractedChild(); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1205 | } |
Selim Cinek | 1f3f544 | 2015-04-10 17:54:46 -0700 | [diff] [blame] | 1206 | mHeadsUpHeight = headsUpChild.getHeight(); |
Selim Cinek | d2319fb | 2014-09-01 19:41:54 +0200 | [diff] [blame] | 1207 | if (intrinsicBefore != getIntrinsicHeight()) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1208 | notifyHeightChanged(false /* needsAnimation */); |
Selim Cinek | d2319fb | 2014-09-01 19:41:54 +0200 | [diff] [blame] | 1209 | } |
| 1210 | } |
| 1211 | |
Selim Cinek | fa0a2d3 | 2016-01-14 13:02:21 -0800 | [diff] [blame] | 1212 | @Override |
| 1213 | public void notifyHeightChanged(boolean needsAnimation) { |
| 1214 | super.notifyHeightChanged(needsAnimation); |
| 1215 | getShowingLayout().requestSelectLayout(needsAnimation || isUserLocked()); |
| 1216 | } |
| 1217 | |
Selim Cinek | 3c76d50 | 2016-02-19 15:16:33 -0800 | [diff] [blame] | 1218 | public void setSensitive(boolean sensitive, boolean hideSensitive) { |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1219 | mSensitive = sensitive; |
Selim Cinek | 3c76d50 | 2016-02-19 15:16:33 -0800 | [diff] [blame] | 1220 | mSensitiveHiddenInGeneral = hideSensitive; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1221 | } |
| 1222 | |
| 1223 | public void setHideSensitiveForIntrinsicHeight(boolean hideSensitive) { |
Selim Cinek | 60122be | 2015-04-15 18:16:50 -0700 | [diff] [blame] | 1224 | mHideSensitiveForIntrinsicHeight = hideSensitive; |
Selim Cinek | a52f6a1 | 2016-02-29 15:35:58 -0800 | [diff] [blame] | 1225 | if (mIsSummaryWithChildren) { |
| 1226 | List<ExpandableNotificationRow> notificationChildren = |
| 1227 | mChildrenContainer.getNotificationChildren(); |
| 1228 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 1229 | ExpandableNotificationRow child = notificationChildren.get(i); |
| 1230 | child.setHideSensitiveForIntrinsicHeight(hideSensitive); |
| 1231 | } |
| 1232 | } |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1233 | } |
| 1234 | |
| 1235 | public void setHideSensitive(boolean hideSensitive, boolean animated, long delay, |
| 1236 | long duration) { |
| 1237 | boolean oldShowingPublic = mShowingPublic; |
| 1238 | mShowingPublic = mSensitive && hideSensitive; |
| 1239 | if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) { |
| 1240 | return; |
| 1241 | } |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1242 | |
| 1243 | // bail out if no public version |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1244 | if (mPublicLayout.getChildCount() == 0) return; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1245 | |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1246 | if (!animated) { |
| 1247 | mPublicLayout.animate().cancel(); |
| 1248 | mPrivateLayout.animate().cancel(); |
| 1249 | mPublicLayout.setAlpha(1f); |
| 1250 | mPrivateLayout.setAlpha(1f); |
| 1251 | mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE); |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1252 | updateChildrenVisibility(); |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1253 | } else { |
| 1254 | animateShowingPublic(delay, duration); |
| 1255 | } |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 1256 | NotificationContentView showingLayout = getShowingLayout(); |
| 1257 | showingLayout.updateBackgroundColor(animated); |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 1258 | mPrivateLayout.updateExpandButtons(isExpandable()); |
Selim Cinek | 757d879 | 2016-01-28 16:21:08 -0800 | [diff] [blame] | 1259 | updateClearability(); |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1260 | mShowingPublicInitialized = true; |
| 1261 | } |
| 1262 | |
| 1263 | private void animateShowingPublic(long delay, long duration) { |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1264 | View[] privateViews = mIsSummaryWithChildren |
| 1265 | ? new View[] {mChildrenContainer} |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1266 | : new View[] {mPrivateLayout}; |
| 1267 | View[] publicViews = new View[] {mPublicLayout}; |
| 1268 | View[] hiddenChildren = mShowingPublic ? privateViews : publicViews; |
| 1269 | View[] shownChildren = mShowingPublic ? publicViews : privateViews; |
| 1270 | for (final View hiddenView : hiddenChildren) { |
| 1271 | hiddenView.setVisibility(View.VISIBLE); |
| 1272 | hiddenView.animate().cancel(); |
| 1273 | hiddenView.animate() |
| 1274 | .alpha(0f) |
| 1275 | .setStartDelay(delay) |
| 1276 | .setDuration(duration) |
| 1277 | .withEndAction(new Runnable() { |
| 1278 | @Override |
| 1279 | public void run() { |
| 1280 | hiddenView.setVisibility(View.INVISIBLE); |
| 1281 | } |
| 1282 | }); |
| 1283 | } |
| 1284 | for (View showView : shownChildren) { |
| 1285 | showView.setVisibility(View.VISIBLE); |
| 1286 | showView.setAlpha(0f); |
| 1287 | showView.animate().cancel(); |
| 1288 | showView.animate() |
| 1289 | .alpha(1f) |
| 1290 | .setStartDelay(delay) |
| 1291 | .setDuration(duration); |
| 1292 | } |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 1293 | } |
| 1294 | |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 1295 | public boolean mustStayOnScreen() { |
| 1296 | return mIsHeadsUp; |
| 1297 | } |
| 1298 | |
Selim Cinek | 757d879 | 2016-01-28 16:21:08 -0800 | [diff] [blame] | 1299 | private void updateClearability() { |
Dan Sandler | 0d3e62f | 2014-07-14 17:13:50 -0400 | [diff] [blame] | 1300 | // public versions cannot be dismissed |
Selim Cinek | 3c76d50 | 2016-02-19 15:16:33 -0800 | [diff] [blame] | 1301 | mVetoButton.setVisibility(isClearable() && (!mShowingPublic |
| 1302 | || !mSensitiveHiddenInGeneral) ? View.VISIBLE : View.GONE); |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1303 | } |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 1304 | |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 1305 | public void makeActionsVisibile() { |
| 1306 | setUserExpanded(true, true); |
| 1307 | if (isChildInGroup()) { |
| 1308 | mGroupManager.setGroupExpanded(mStatusBarNotification, true); |
| 1309 | } |
| 1310 | notifyHeightChanged(false); |
| 1311 | } |
| 1312 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1313 | public void setChildrenExpanded(boolean expanded, boolean animate) { |
| 1314 | mChildrenExpanded = expanded; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1315 | if (mChildrenContainer != null) { |
| 1316 | mChildrenContainer.setChildrenExpanded(expanded); |
| 1317 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1318 | } |
| 1319 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1320 | public static void applyTint(View v, int color) { |
| 1321 | int alpha; |
| 1322 | if (color != 0) { |
| 1323 | alpha = COLORED_DIVIDER_ALPHA; |
| 1324 | } else { |
| 1325 | color = 0xff000000; |
| 1326 | alpha = DEFAULT_DIVIDER_ALPHA; |
| 1327 | } |
| 1328 | if (v.getBackground() instanceof ColorDrawable) { |
| 1329 | ColorDrawable background = (ColorDrawable) v.getBackground(); |
| 1330 | background.mutate(); |
| 1331 | background.setColor(color); |
| 1332 | background.setAlpha(alpha); |
| 1333 | } |
| 1334 | } |
| 1335 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1336 | public int getMaxExpandHeight() { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1337 | return mMaxExpandHeight; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1338 | } |
Jorim Jaggi | 584a7aa | 2014-04-10 23:26:13 +0200 | [diff] [blame] | 1339 | |
Mady Mellor | 34958fa | 2016-02-23 09:52:17 -0800 | [diff] [blame] | 1340 | public boolean areGutsExposed() { |
| 1341 | return (mGuts != null && mGuts.areGutsExposed()); |
| 1342 | } |
| 1343 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1344 | @Override |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1345 | public boolean isContentExpandable() { |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 1346 | NotificationContentView showingLayout = getShowingLayout(); |
| 1347 | return showingLayout.isContentExpandable(); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1348 | } |
| 1349 | |
| 1350 | @Override |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 1351 | protected View getContentView() { |
Selim Cinek | a570318 | 2016-05-11 21:23:16 -0400 | [diff] [blame] | 1352 | if (mIsSummaryWithChildren) { |
| 1353 | return mChildrenContainer; |
| 1354 | } |
Selim Cinek | 560e64d | 2015-06-09 19:58:11 -0700 | [diff] [blame] | 1355 | return getShowingLayout(); |
| 1356 | } |
| 1357 | |
| 1358 | @Override |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1359 | public int getExtraBottomPadding() { |
| 1360 | if (mIsSummaryWithChildren && isGroupExpanded()) { |
| 1361 | return mIncreasedPaddingBetweenElements; |
| 1362 | } |
| 1363 | return 0; |
| 1364 | } |
| 1365 | |
| 1366 | @Override |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 1367 | public void setActualHeight(int height, boolean notifyListeners) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1368 | super.setActualHeight(height, notifyListeners); |
Mady Mellor | b53bc27 | 2016-02-11 18:28:23 -0800 | [diff] [blame] | 1369 | if (mGuts != null && mGuts.areGutsExposed()) { |
| 1370 | mGuts.setActualHeight(height); |
| 1371 | return; |
| 1372 | } |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 1373 | int contentHeight = Math.max(getMinHeight(), height); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1374 | mPrivateLayout.setContentHeight(contentHeight); |
| 1375 | mPublicLayout.setContentHeight(contentHeight); |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1376 | if (mIsSummaryWithChildren) { |
| 1377 | mChildrenContainer.setActualHeight(height); |
| 1378 | } |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1379 | if (mGuts != null) { |
| 1380 | mGuts.setActualHeight(height); |
| 1381 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1382 | } |
| 1383 | |
| 1384 | @Override |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1385 | public int getMaxContentHeight() { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1386 | if (mIsSummaryWithChildren && !mShowingPublic) { |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 1387 | return mChildrenContainer.getMaxContentHeight(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1388 | } |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 1389 | NotificationContentView showingLayout = getShowingLayout(); |
| 1390 | return showingLayout.getMaxHeight(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1391 | } |
| 1392 | |
| 1393 | @Override |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1394 | public int getMinHeight() { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 1395 | if (mIsHeadsUp && mHeadsUpManager.isTrackingHeadsUp()) { |
| 1396 | return getPinnedHeadsUpHeight(false /* atLeastMinHeight */); |
| 1397 | } else if (mIsSummaryWithChildren && !isGroupExpanded() && !mShowingPublic) { |
Selim Cinek | b55386d | 2015-12-16 17:26:49 -0800 | [diff] [blame] | 1398 | return mChildrenContainer.getMinHeight(); |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 1399 | } else if (mIsHeadsUp) { |
| 1400 | return mHeadsUpHeight; |
Selim Cinek | b55386d | 2015-12-16 17:26:49 -0800 | [diff] [blame] | 1401 | } |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 1402 | NotificationContentView showingLayout = getShowingLayout(); |
| 1403 | return showingLayout.getMinHeight(); |
| 1404 | } |
| 1405 | |
| 1406 | @Override |
Selim Cinek | 567e845 | 2016-03-24 10:54:56 -0700 | [diff] [blame] | 1407 | public int getCollapsedHeight() { |
Selim Cinek | 2c58461 | 2016-02-29 16:14:25 -0800 | [diff] [blame] | 1408 | if (mIsSummaryWithChildren && !mShowingPublic) { |
Selim Cinek | 567e845 | 2016-03-24 10:54:56 -0700 | [diff] [blame] | 1409 | return mChildrenContainer.getCollapsedHeight(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1410 | } |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 1411 | return getMinHeight(); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1412 | } |
| 1413 | |
| 1414 | @Override |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1415 | public void setClipTopAmount(int clipTopAmount) { |
| 1416 | super.setClipTopAmount(clipTopAmount); |
| 1417 | mPrivateLayout.setClipTopAmount(clipTopAmount); |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 1418 | mPublicLayout.setClipTopAmount(clipTopAmount); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1419 | if (mGuts != null) { |
| 1420 | mGuts.setClipTopAmount(clipTopAmount); |
| 1421 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1422 | } |
| 1423 | |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 1424 | public boolean isMaxExpandHeightInitialized() { |
| 1425 | return mMaxExpandHeight != 0; |
Selim Cinek | 7d44772 | 2014-06-10 15:51:59 +0200 | [diff] [blame] | 1426 | } |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 1427 | |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1428 | public NotificationContentView getShowingLayout() { |
Selim Cinek | 2f0df8a | 2014-06-10 17:40:42 +0200 | [diff] [blame] | 1429 | return mShowingPublic ? mPublicLayout : mPrivateLayout; |
| 1430 | } |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1431 | |
Jorim Jaggi | 59ec304 | 2015-06-05 15:18:43 -0700 | [diff] [blame] | 1432 | @Override |
| 1433 | public void setShowingLegacyBackground(boolean showing) { |
| 1434 | super.setShowingLegacyBackground(showing); |
| 1435 | mPrivateLayout.setShowingLegacyBackground(showing); |
| 1436 | mPublicLayout.setShowingLegacyBackground(showing); |
| 1437 | } |
| 1438 | |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 1439 | @Override |
| 1440 | protected void updateBackgroundTint() { |
| 1441 | super.updateBackgroundTint(); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1442 | updateBackgroundForGroupState(); |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 1443 | if (mIsSummaryWithChildren) { |
| 1444 | List<ExpandableNotificationRow> notificationChildren = |
| 1445 | mChildrenContainer.getNotificationChildren(); |
| 1446 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 1447 | ExpandableNotificationRow child = notificationChildren.get(i); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1448 | child.updateBackgroundForGroupState(); |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 1449 | } |
| 1450 | } |
| 1451 | } |
| 1452 | |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1453 | /** |
| 1454 | * Called when a group has finished animating from collapsed or expanded state. |
| 1455 | */ |
| 1456 | public void onFinishedExpansionChange() { |
| 1457 | mGroupExpansionChanging = false; |
| 1458 | updateBackgroundForGroupState(); |
| 1459 | } |
| 1460 | |
| 1461 | /** |
| 1462 | * Updates the parent and children backgrounds in a group based on the expansion state. |
| 1463 | */ |
| 1464 | public void updateBackgroundForGroupState() { |
| 1465 | if (mIsSummaryWithChildren) { |
| 1466 | // Only when the group has finished expanding do we hide its background. |
| 1467 | mShowNoBackground = isGroupExpanded() && !isGroupExpansionChanging() && !isUserLocked(); |
| 1468 | mChildrenContainer.updateHeaderForExpansion(mShowNoBackground); |
| 1469 | List<ExpandableNotificationRow> children = mChildrenContainer.getNotificationChildren(); |
| 1470 | for (int i = 0; i < children.size(); i++) { |
| 1471 | children.get(i).updateBackgroundForGroupState(); |
| 1472 | } |
| 1473 | } else if (isChildInGroup()) { |
| 1474 | final int childColor = getShowingLayout().getBackgroundColorForExpansionState(); |
| 1475 | // Only show a background if the group is expanded OR if it is expanding / collapsing |
| 1476 | // and has a custom background color |
| 1477 | final boolean showBackground = isGroupExpanded() |
| 1478 | || ((mNotificationParent.isGroupExpansionChanging() |
| 1479 | || mNotificationParent.isUserLocked()) && childColor != 0); |
| 1480 | mShowNoBackground = !showBackground; |
| 1481 | } else { |
| 1482 | // Only children or parents ever need no background. |
| 1483 | mShowNoBackground = false; |
| 1484 | } |
| 1485 | updateOutline(); |
Selim Cinek | a6c6bfb | 2015-10-29 16:27:08 -0700 | [diff] [blame] | 1486 | updateBackground(); |
| 1487 | } |
| 1488 | |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1489 | public void setExpansionLogger(ExpansionLogger logger, String key) { |
| 1490 | mLogger = logger; |
| 1491 | mLoggingKey = key; |
| 1492 | } |
| 1493 | |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 1494 | @Override |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1495 | public float getIncreasedPaddingAmount() { |
| 1496 | if (mIsSummaryWithChildren) { |
| 1497 | if (isGroupExpanded()) { |
| 1498 | return 1.0f; |
| 1499 | } else if (isUserLocked()) { |
Selim Cinek | f07d062 | 2016-03-21 19:52:52 -0700 | [diff] [blame] | 1500 | return mChildrenContainer.getGroupExpandFraction(); |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1501 | } |
| 1502 | } |
| 1503 | return 0.0f; |
Selim Cinek | 61633a8 | 2016-01-25 15:54:10 -0800 | [diff] [blame] | 1504 | } |
| 1505 | |
| 1506 | @Override |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 1507 | protected boolean disallowSingleClick(MotionEvent event) { |
| 1508 | float x = event.getX(); |
| 1509 | float y = event.getY(); |
Selim Cinek | 34eda5e | 2016-02-18 17:10:43 -0800 | [diff] [blame] | 1510 | NotificationHeaderView header = getVisibleNotificationHeader(); |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 1511 | if (header != null) { |
Mady Mellor | a883351 | 2016-03-09 09:50:18 -0800 | [diff] [blame] | 1512 | return header.isInTouchRect(x - getTranslation(), y); |
Selim Cinek | 6183d12 | 2016-01-14 18:48:41 -0800 | [diff] [blame] | 1513 | } |
| 1514 | return super.disallowSingleClick(event); |
| 1515 | } |
| 1516 | |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1517 | private void logExpansionEvent(boolean userAction, boolean wasExpanded) { |
Chris Wren | 698b170 | 2016-05-23 11:16:32 -0400 | [diff] [blame^] | 1518 | boolean nowExpanded = isExpanded(); |
| 1519 | if (mIsSummaryWithChildren) { |
| 1520 | nowExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification); |
| 1521 | } |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1522 | if (wasExpanded != nowExpanded && mLogger != null) { |
| 1523 | mLogger.logNotificationExpansion(mLoggingKey, userAction, nowExpanded) ; |
| 1524 | } |
| 1525 | } |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 1526 | |
| 1527 | public interface OnExpandClickListener { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 1528 | void onExpandClicked(NotificationData.Entry clickedEntry, boolean nowExpanded); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 1529 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1530 | } |