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