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