Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 17 | package com.android.systemui.statusbar.notification.row; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 18 | |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 19 | import android.annotation.Nullable; |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 20 | import android.app.Notification; |
Adrian Roos | 4c1fcc8 | 2016-03-31 14:39:39 -0700 | [diff] [blame] | 21 | import android.app.PendingIntent; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 22 | import android.content.Context; |
| 23 | import android.graphics.Rect; |
Selim Cinek | 860b6da | 2015-12-16 19:02:19 -0800 | [diff] [blame] | 24 | import android.os.Build; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 25 | import android.service.notification.StatusBarNotification; |
Kevin | d5022f9 | 2018-10-08 18:30:26 -0700 | [diff] [blame] | 26 | import android.util.ArrayMap; |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 27 | import android.util.ArraySet; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 28 | import android.util.AttributeSet; |
Selim Cinek | 011bde9 | 2017-11-22 05:53:38 -0800 | [diff] [blame] | 29 | import android.util.Log; |
Selim Cinek | a77d2c5 | 2018-04-09 10:44:52 -0700 | [diff] [blame] | 30 | import android.view.MotionEvent; |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 31 | import android.view.NotificationHeaderView; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 32 | import android.view.View; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 33 | import android.view.ViewGroup; |
Selim Cinek | bb3d1cf | 2014-10-31 00:12:56 +0100 | [diff] [blame] | 34 | import android.view.ViewTreeObserver; |
Selim Cinek | c9c00ae | 2014-05-20 03:33:40 +0200 | [diff] [blame] | 35 | import android.widget.FrameLayout; |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 36 | import android.widget.ImageView; |
Petr Cermak | 7997d7a | 2018-01-18 15:52:10 +0000 | [diff] [blame] | 37 | import android.widget.LinearLayout; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 38 | |
Adrian Roos | e18033c | 2017-01-17 15:22:49 -0800 | [diff] [blame] | 39 | import com.android.internal.annotations.VisibleForTesting; |
Lucas Dupin | a291d19 | 2018-06-07 13:59:42 -0700 | [diff] [blame] | 40 | import com.android.internal.util.ContrastColorUtil; |
Petr Cermak | 10011fa | 2018-02-05 19:00:54 +0000 | [diff] [blame] | 41 | import com.android.systemui.Dependency; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 42 | import com.android.systemui.R; |
linanson | 2bcd403 | 2019-01-14 15:22:04 +0800 | [diff] [blame] | 43 | import com.android.systemui.statusbar.MediaTransferManager; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 44 | import com.android.systemui.statusbar.RemoteInputController; |
| 45 | import com.android.systemui.statusbar.SmartReplyController; |
| 46 | import com.android.systemui.statusbar.TransformableView; |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 47 | import com.android.systemui.statusbar.notification.NotificationUtils; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 48 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Tony Mak | 638430e | 2018-10-08 19:19:10 +0100 | [diff] [blame] | 49 | import com.android.systemui.statusbar.notification.row.wrapper.NotificationCustomViewWrapper; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 50 | import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 51 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
Gustav Sennton | b944ce5 | 2019-02-25 18:52:43 +0000 | [diff] [blame] | 52 | import com.android.systemui.statusbar.policy.InflatedSmartReplies; |
| 53 | import com.android.systemui.statusbar.policy.InflatedSmartReplies.SmartRepliesAndActions; |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 54 | import com.android.systemui.statusbar.policy.RemoteInputView; |
Petr Cermak | 10011fa | 2018-02-05 19:00:54 +0000 | [diff] [blame] | 55 | import com.android.systemui.statusbar.policy.SmartReplyConstants; |
Petr Cermak | 7997d7a | 2018-01-18 15:52:10 +0000 | [diff] [blame] | 56 | import com.android.systemui.statusbar.policy.SmartReplyView; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 57 | |
Selim Cinek | 85a8f9f | 2018-11-21 13:58:27 -0800 | [diff] [blame] | 58 | import java.io.FileDescriptor; |
| 59 | import java.io.PrintWriter; |
Gustav Sennton | eab5368 | 2018-11-01 16:30:23 +0000 | [diff] [blame] | 60 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 61 | /** |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 62 | * A frame layout containing the actual payload of the notification, including the contracted, |
| 63 | * expanded and heads up layout. This class is responsible for clipping the content and and |
| 64 | * switching between the expanded, contracted and the heads up view depending on its clipped size. |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 65 | */ |
Selim Cinek | c9c00ae | 2014-05-20 03:33:40 +0200 | [diff] [blame] | 66 | public class NotificationContentView extends FrameLayout { |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 67 | |
Selim Cinek | 011bde9 | 2017-11-22 05:53:38 -0800 | [diff] [blame] | 68 | private static final String TAG = "NotificationContentView"; |
Gustav Sennton | 2d66b51 | 2019-01-31 17:48:17 +0000 | [diff] [blame] | 69 | private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); |
Selim Cinek | 131f1a4 | 2017-06-05 17:50:19 -0700 | [diff] [blame] | 70 | public static final int VISIBLE_TYPE_CONTRACTED = 0; |
| 71 | public static final int VISIBLE_TYPE_EXPANDED = 1; |
| 72 | public static final int VISIBLE_TYPE_HEADSUP = 2; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 73 | private static final int VISIBLE_TYPE_SINGLELINE = 3; |
Selim Cinek | 131f1a4 | 2017-06-05 17:50:19 -0700 | [diff] [blame] | 74 | public static final int VISIBLE_TYPE_AMBIENT = 4; |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 75 | private static final int VISIBLE_TYPE_AMBIENT_SINGLELINE = 5; |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 76 | public static final int UNDEFINED = -1; |
Jorim Jaggi | 1129883 | 2014-05-24 16:18:38 +0200 | [diff] [blame] | 77 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 78 | private final Rect mClipBounds = new Rect(); |
| 79 | |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 80 | private int mMinContractedHeight; |
| 81 | private int mNotificationContentMarginEnd; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 82 | private View mContractedChild; |
| 83 | private View mExpandedChild; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 84 | private View mHeadsUpChild; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 85 | private HybridNotificationView mSingleLineView; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 86 | private View mAmbientChild; |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 87 | private HybridNotificationView mAmbientSingleLineChild; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 88 | |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 89 | private RemoteInputView mExpandedRemoteInput; |
| 90 | private RemoteInputView mHeadsUpRemoteInput; |
Petr Cermak | 10011fa | 2018-02-05 19:00:54 +0000 | [diff] [blame] | 91 | |
| 92 | private SmartReplyConstants mSmartReplyConstants; |
Milo Sredkov | e7cf498 | 2018-04-09 15:08:26 +0100 | [diff] [blame] | 93 | private SmartReplyView mExpandedSmartReplyView; |
Gustav Sennton | d0e8453 | 2018-12-03 16:48:36 +0000 | [diff] [blame] | 94 | private SmartReplyView mHeadsUpSmartReplyView; |
Kenny Guy | a0f6de8 | 2018-04-06 16:20:16 +0100 | [diff] [blame] | 95 | private SmartReplyController mSmartReplyController; |
Gustav Sennton | 5759f87 | 2019-02-13 17:25:26 +0000 | [diff] [blame] | 96 | private InflatedSmartReplies mExpandedInflatedSmartReplies; |
| 97 | private InflatedSmartReplies mHeadsUpInflatedSmartReplies; |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 98 | |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 99 | private NotificationViewWrapper mContractedWrapper; |
Jorim Jaggi | be4116a | 2015-05-20 20:04:08 -0700 | [diff] [blame] | 100 | private NotificationViewWrapper mExpandedWrapper; |
| 101 | private NotificationViewWrapper mHeadsUpWrapper; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 102 | private NotificationViewWrapper mAmbientWrapper; |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 103 | private HybridGroupManager mHybridGroupManager; |
Selim Cinek | c9c00ae | 2014-05-20 03:33:40 +0200 | [diff] [blame] | 104 | private int mClipTopAmount; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 105 | private int mContentHeight; |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 106 | private int mVisibleType = VISIBLE_TYPE_CONTRACTED; |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 107 | private boolean mDark; |
Selim Cinek | bb3d1cf | 2014-10-31 00:12:56 +0100 | [diff] [blame] | 108 | private boolean mAnimate; |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 109 | private boolean mIsHeadsUp; |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 110 | private boolean mLegacy; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 111 | private boolean mIsChildInGroup; |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 112 | private int mSmallHeight; |
Selim Cinek | 77019c7 | 2015-12-09 10:18:02 -0800 | [diff] [blame] | 113 | private int mHeadsUpHeight; |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 114 | private int mNotificationMaxHeight; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 115 | private int mNotificationAmbientHeight; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 116 | private StatusBarNotification mStatusBarNotification; |
Selim Cinek | 65b2e7c | 2015-10-26 14:11:31 -0700 | [diff] [blame] | 117 | private NotificationGroupManager mGroupManager; |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 118 | private RemoteInputController mRemoteInputController; |
Adrian Roos | 4320e89 | 2017-01-24 12:50:34 -0800 | [diff] [blame] | 119 | private Runnable mExpandedVisibleListener; |
Kevin | d5022f9 | 2018-10-08 18:30:26 -0700 | [diff] [blame] | 120 | /** |
| 121 | * List of listeners for when content views become inactive (i.e. not the showing view). |
| 122 | */ |
| 123 | private final ArrayMap<View, Runnable> mOnContentViewInactiveListeners = new ArrayMap<>(); |
Jorim Jaggi | 59ec304 | 2015-06-05 15:18:43 -0700 | [diff] [blame] | 124 | |
Jorim Jaggi | be4116a | 2015-05-20 20:04:08 -0700 | [diff] [blame] | 125 | private final ViewTreeObserver.OnPreDrawListener mEnableAnimationPredrawListener |
Selim Cinek | bb3d1cf | 2014-10-31 00:12:56 +0100 | [diff] [blame] | 126 | = new ViewTreeObserver.OnPreDrawListener() { |
| 127 | @Override |
| 128 | public boolean onPreDraw() { |
Selim Cinek | d1ad9ab | 2016-03-01 17:52:20 -0800 | [diff] [blame] | 129 | // We need to post since we don't want the notification to animate on the very first |
| 130 | // frame |
| 131 | post(new Runnable() { |
| 132 | @Override |
| 133 | public void run() { |
| 134 | mAnimate = true; |
| 135 | } |
| 136 | }); |
Selim Cinek | bb3d1cf | 2014-10-31 00:12:56 +0100 | [diff] [blame] | 137 | getViewTreeObserver().removeOnPreDrawListener(this); |
| 138 | return true; |
| 139 | } |
| 140 | }; |
Jorim Jaggi | 1129883 | 2014-05-24 16:18:38 +0200 | [diff] [blame] | 141 | |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 142 | private OnClickListener mExpandClickListener; |
Selim Cinek | 860b6da | 2015-12-16 19:02:19 -0800 | [diff] [blame] | 143 | private boolean mBeforeN; |
Selim Cinek | 98be3f3 | 2015-12-17 16:39:06 -0800 | [diff] [blame] | 144 | private boolean mExpandable; |
Selim Cinek | 4ffd636 | 2015-12-29 15:12:23 +0100 | [diff] [blame] | 145 | private boolean mClipToActualHeight = true; |
Selim Cinek | fa0a2d3 | 2016-01-14 13:02:21 -0800 | [diff] [blame] | 146 | private ExpandableNotificationRow mContainingNotification; |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 147 | /** The visible type at the start of a touch driven transformation */ |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 148 | private int mTransformationStartVisibleType; |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 149 | /** The visible type at the start of an animation driven transformation */ |
| 150 | private int mAnimationStartVisibleType = UNDEFINED; |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 151 | private boolean mUserExpanding; |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 152 | private int mSingleLineWidthIndention; |
Selim Cinek | 589fd3e | 2016-04-26 18:17:57 -0700 | [diff] [blame] | 153 | private boolean mForceSelectNextLayout = true; |
Adrian Roos | 4c1fcc8 | 2016-03-31 14:39:39 -0700 | [diff] [blame] | 154 | private PendingIntent mPreviousExpandedRemoteInputIntent; |
| 155 | private PendingIntent mPreviousHeadsUpRemoteInputIntent; |
Adrian Roos | 7813dd7 | 2016-09-23 17:12:17 -0700 | [diff] [blame] | 156 | private RemoteInputView mCachedExpandedRemoteInput; |
| 157 | private RemoteInputView mCachedHeadsUpRemoteInput; |
Selim Cinek | 98be3f3 | 2015-12-17 16:39:06 -0800 | [diff] [blame] | 158 | |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 159 | private int mContentHeightAtAnimationStart = UNDEFINED; |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 160 | private boolean mFocusOnVisibilityChange; |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 161 | private boolean mHeadsUpAnimatingAway; |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 162 | private boolean mIconsVisible; |
Selim Cinek | a686b2c | 2016-10-26 13:58:27 -0700 | [diff] [blame] | 163 | private int mClipBottomAmount; |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 164 | private boolean mIsLowPriority; |
Selim Cinek | c0ac4af | 2017-03-03 15:13:48 -0800 | [diff] [blame] | 165 | private boolean mIsContentExpandable; |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 166 | private boolean mRemoteInputVisible; |
| 167 | private int mUnrestrictedContentHeight; |
linanson | 2bcd403 | 2019-01-14 15:22:04 +0800 | [diff] [blame] | 168 | private MediaTransferManager mMediaTransferManager; |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 169 | |
| 170 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 171 | public NotificationContentView(Context context, AttributeSet attrs) { |
| 172 | super(context, attrs); |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 173 | mHybridGroupManager = new HybridGroupManager(getContext(), this); |
linanson | 2bcd403 | 2019-01-14 15:22:04 +0800 | [diff] [blame] | 174 | mMediaTransferManager = new MediaTransferManager(getContext()); |
Petr Cermak | 10011fa | 2018-02-05 19:00:54 +0000 | [diff] [blame] | 175 | mSmartReplyConstants = Dependency.get(SmartReplyConstants.class); |
Kenny Guy | a0f6de8 | 2018-04-06 16:20:16 +0100 | [diff] [blame] | 176 | mSmartReplyController = Dependency.get(SmartReplyController.class); |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 177 | initView(); |
| 178 | } |
| 179 | |
| 180 | public void initView() { |
Selim Cinek | 860b6da | 2015-12-16 19:02:19 -0800 | [diff] [blame] | 181 | mMinContractedHeight = getResources().getDimensionPixelSize( |
| 182 | R.dimen.min_notification_layout_height); |
Selim Cinek | 6ecc810 | 2016-01-26 18:26:19 -0800 | [diff] [blame] | 183 | mNotificationContentMarginEnd = getResources().getDimensionPixelSize( |
| 184 | com.android.internal.R.dimen.notification_content_margin_end); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 185 | } |
| 186 | |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 187 | public void setHeights(int smallHeight, int headsUpMaxHeight, int maxHeight, |
| 188 | int ambientHeight) { |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 189 | mSmallHeight = smallHeight; |
Selim Cinek | 77019c7 | 2015-12-09 10:18:02 -0800 | [diff] [blame] | 190 | mHeadsUpHeight = headsUpMaxHeight; |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 191 | mNotificationMaxHeight = maxHeight; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 192 | mNotificationAmbientHeight = ambientHeight; |
Selim Cinek | 816c8e4 | 2015-11-19 12:00:45 -0800 | [diff] [blame] | 193 | } |
| 194 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 195 | @Override |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 196 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 197 | int heightMode = MeasureSpec.getMode(heightMeasureSpec); |
| 198 | boolean hasFixedHeight = heightMode == MeasureSpec.EXACTLY; |
| 199 | boolean isHeightLimited = heightMode == MeasureSpec.AT_MOST; |
Selim Cinek | be570ce | 2018-05-11 12:29:52 -0700 | [diff] [blame] | 200 | int maxSize = Integer.MAX_VALUE / 2; |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 201 | int width = MeasureSpec.getSize(widthMeasureSpec); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 202 | if (hasFixedHeight || isHeightLimited) { |
| 203 | maxSize = MeasureSpec.getSize(heightMeasureSpec); |
| 204 | } |
| 205 | int maxChildHeight = 0; |
Selim Cinek | 6ecc810 | 2016-01-26 18:26:19 -0800 | [diff] [blame] | 206 | if (mExpandedChild != null) { |
Milo Sredkov | e7cf498 | 2018-04-09 15:08:26 +0100 | [diff] [blame] | 207 | int notificationMaxHeight = mNotificationMaxHeight; |
| 208 | if (mExpandedSmartReplyView != null) { |
| 209 | notificationMaxHeight += mExpandedSmartReplyView.getHeightUpperLimit(); |
| 210 | } |
Selim Cinek | bee4e07 | 2018-05-21 22:06:43 -0700 | [diff] [blame] | 211 | notificationMaxHeight += mExpandedWrapper.getExtraMeasureHeight(); |
Selim Cinek | be570ce | 2018-05-11 12:29:52 -0700 | [diff] [blame] | 212 | int size = notificationMaxHeight; |
Selim Cinek | 6ecc810 | 2016-01-26 18:26:19 -0800 | [diff] [blame] | 213 | ViewGroup.LayoutParams layoutParams = mExpandedChild.getLayoutParams(); |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 214 | boolean useExactly = false; |
Selim Cinek | 6ecc810 | 2016-01-26 18:26:19 -0800 | [diff] [blame] | 215 | if (layoutParams.height >= 0) { |
| 216 | // An actual height is set |
Selim Cinek | be570ce | 2018-05-11 12:29:52 -0700 | [diff] [blame] | 217 | size = Math.min(size, layoutParams.height); |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 218 | useExactly = true; |
Selim Cinek | 6ecc810 | 2016-01-26 18:26:19 -0800 | [diff] [blame] | 219 | } |
Selim Cinek | be570ce | 2018-05-11 12:29:52 -0700 | [diff] [blame] | 220 | int spec = MeasureSpec.makeMeasureSpec(size, useExactly |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 221 | ? MeasureSpec.EXACTLY |
| 222 | : MeasureSpec.AT_MOST); |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 223 | measureChildWithMargins(mExpandedChild, widthMeasureSpec, 0, spec, 0); |
Selim Cinek | 6ecc810 | 2016-01-26 18:26:19 -0800 | [diff] [blame] | 224 | maxChildHeight = Math.max(maxChildHeight, mExpandedChild.getMeasuredHeight()); |
| 225 | } |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 226 | if (mContractedChild != null) { |
Selim Cinek | 860b6da | 2015-12-16 19:02:19 -0800 | [diff] [blame] | 227 | int heightSpec; |
Selim Cinek | be570ce | 2018-05-11 12:29:52 -0700 | [diff] [blame] | 228 | int size = mSmallHeight; |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 229 | ViewGroup.LayoutParams layoutParams = mContractedChild.getLayoutParams(); |
| 230 | boolean useExactly = false; |
| 231 | if (layoutParams.height >= 0) { |
| 232 | // An actual height is set |
| 233 | size = Math.min(size, layoutParams.height); |
| 234 | useExactly = true; |
| 235 | } |
| 236 | if (shouldContractedBeFixedSize() || useExactly) { |
Selim Cinek | 860b6da | 2015-12-16 19:02:19 -0800 | [diff] [blame] | 237 | heightSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY); |
| 238 | } else { |
Selim Cinek | f619ffc | 2016-02-17 14:53:05 -0800 | [diff] [blame] | 239 | heightSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.AT_MOST); |
Selim Cinek | 860b6da | 2015-12-16 19:02:19 -0800 | [diff] [blame] | 240 | } |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 241 | measureChildWithMargins(mContractedChild, widthMeasureSpec, 0, heightSpec, 0); |
Selim Cinek | 860b6da | 2015-12-16 19:02:19 -0800 | [diff] [blame] | 242 | int measuredHeight = mContractedChild.getMeasuredHeight(); |
| 243 | if (measuredHeight < mMinContractedHeight) { |
| 244 | heightSpec = MeasureSpec.makeMeasureSpec(mMinContractedHeight, MeasureSpec.EXACTLY); |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 245 | measureChildWithMargins(mContractedChild, widthMeasureSpec, 0, heightSpec, 0); |
Selim Cinek | 860b6da | 2015-12-16 19:02:19 -0800 | [diff] [blame] | 246 | } |
| 247 | maxChildHeight = Math.max(maxChildHeight, measuredHeight); |
Selim Cinek | 6ecc810 | 2016-01-26 18:26:19 -0800 | [diff] [blame] | 248 | if (updateContractedHeaderWidth()) { |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 249 | measureChildWithMargins(mContractedChild, widthMeasureSpec, 0, heightSpec, 0); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 250 | } |
Selim Cinek | 1ba41d1 | 2016-04-21 16:14:46 -0700 | [diff] [blame] | 251 | if (mExpandedChild != null |
| 252 | && mContractedChild.getMeasuredHeight() > mExpandedChild.getMeasuredHeight()) { |
| 253 | // the Expanded child is smaller then the collapsed. Let's remeasure it. |
| 254 | heightSpec = MeasureSpec.makeMeasureSpec(mContractedChild.getMeasuredHeight(), |
| 255 | MeasureSpec.EXACTLY); |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 256 | measureChildWithMargins(mExpandedChild, widthMeasureSpec, 0, heightSpec, 0); |
Selim Cinek | 1ba41d1 | 2016-04-21 16:14:46 -0700 | [diff] [blame] | 257 | } |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 258 | } |
| 259 | if (mHeadsUpChild != null) { |
Selim Cinek | 396caca | 2018-04-10 17:46:46 -0700 | [diff] [blame] | 260 | int maxHeight = mHeadsUpHeight; |
Gustav Sennton | d0e8453 | 2018-12-03 16:48:36 +0000 | [diff] [blame] | 261 | if (mHeadsUpSmartReplyView != null) { |
| 262 | maxHeight += mHeadsUpSmartReplyView.getHeightUpperLimit(); |
| 263 | } |
Selim Cinek | 396caca | 2018-04-10 17:46:46 -0700 | [diff] [blame] | 264 | maxHeight += mHeadsUpWrapper.getExtraMeasureHeight(); |
Selim Cinek | be570ce | 2018-05-11 12:29:52 -0700 | [diff] [blame] | 265 | int size = maxHeight; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 266 | ViewGroup.LayoutParams layoutParams = mHeadsUpChild.getLayoutParams(); |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 267 | boolean useExactly = false; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 268 | if (layoutParams.height >= 0) { |
| 269 | // An actual height is set |
Selim Cinek | 77019c7 | 2015-12-09 10:18:02 -0800 | [diff] [blame] | 270 | size = Math.min(size, layoutParams.height); |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 271 | useExactly = true; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 272 | } |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 273 | measureChildWithMargins(mHeadsUpChild, widthMeasureSpec, 0, |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 274 | MeasureSpec.makeMeasureSpec(size, useExactly ? MeasureSpec.EXACTLY |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 275 | : MeasureSpec.AT_MOST), 0); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 276 | maxChildHeight = Math.max(maxChildHeight, mHeadsUpChild.getMeasuredHeight()); |
| 277 | } |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 278 | if (mSingleLineView != null) { |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 279 | int singleLineWidthSpec = widthMeasureSpec; |
| 280 | if (mSingleLineWidthIndention != 0 |
| 281 | && MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.UNSPECIFIED) { |
| 282 | singleLineWidthSpec = MeasureSpec.makeMeasureSpec( |
| 283 | width - mSingleLineWidthIndention + mSingleLineView.getPaddingEnd(), |
Selim Cinek | 09b7dea | 2016-08-30 11:28:19 -0700 | [diff] [blame] | 284 | MeasureSpec.EXACTLY); |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 285 | } |
| 286 | mSingleLineView.measure(singleLineWidthSpec, |
Selim Cinek | be570ce | 2018-05-11 12:29:52 -0700 | [diff] [blame] | 287 | MeasureSpec.makeMeasureSpec(mNotificationMaxHeight, MeasureSpec.AT_MOST)); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 288 | maxChildHeight = Math.max(maxChildHeight, mSingleLineView.getMeasuredHeight()); |
| 289 | } |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 290 | if (mAmbientChild != null) { |
Selim Cinek | be570ce | 2018-05-11 12:29:52 -0700 | [diff] [blame] | 291 | int size = mNotificationAmbientHeight; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 292 | ViewGroup.LayoutParams layoutParams = mAmbientChild.getLayoutParams(); |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 293 | boolean useExactly = false; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 294 | if (layoutParams.height >= 0) { |
| 295 | // An actual height is set |
| 296 | size = Math.min(size, layoutParams.height); |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 297 | useExactly = true; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 298 | } |
| 299 | mAmbientChild.measure(widthMeasureSpec, |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 300 | MeasureSpec.makeMeasureSpec(size, useExactly ? MeasureSpec.EXACTLY |
| 301 | : MeasureSpec.AT_MOST)); |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 302 | maxChildHeight = Math.max(maxChildHeight, mAmbientChild.getMeasuredHeight()); |
| 303 | } |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 304 | if (mAmbientSingleLineChild != null) { |
Selim Cinek | be570ce | 2018-05-11 12:29:52 -0700 | [diff] [blame] | 305 | int size = mNotificationAmbientHeight; |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 306 | ViewGroup.LayoutParams layoutParams = mAmbientSingleLineChild.getLayoutParams(); |
| 307 | boolean useExactly = false; |
| 308 | if (layoutParams.height >= 0) { |
| 309 | // An actual height is set |
| 310 | size = Math.min(size, layoutParams.height); |
| 311 | useExactly = true; |
| 312 | } |
| 313 | int ambientSingleLineWidthSpec = widthMeasureSpec; |
| 314 | if (mSingleLineWidthIndention != 0 |
| 315 | && MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.UNSPECIFIED) { |
| 316 | ambientSingleLineWidthSpec = MeasureSpec.makeMeasureSpec( |
| 317 | width - mSingleLineWidthIndention + mAmbientSingleLineChild.getPaddingEnd(), |
| 318 | MeasureSpec.EXACTLY); |
| 319 | } |
| 320 | mAmbientSingleLineChild.measure(ambientSingleLineWidthSpec, |
| 321 | MeasureSpec.makeMeasureSpec(size, useExactly ? MeasureSpec.EXACTLY |
| 322 | : MeasureSpec.AT_MOST)); |
| 323 | maxChildHeight = Math.max(maxChildHeight, mAmbientSingleLineChild.getMeasuredHeight()); |
| 324 | } |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 325 | int ownHeight = Math.min(maxChildHeight, maxSize); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 326 | setMeasuredDimension(width, ownHeight); |
| 327 | } |
| 328 | |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 329 | /** |
| 330 | * Get the extra height that needs to be added to the notification height for a given |
| 331 | * {@link RemoteInputView}. |
| 332 | * This is needed when the user is inline replying in order to ensure that the reply bar has |
| 333 | * enough padding. |
| 334 | * |
| 335 | * @param remoteInput The remote input to check. |
| 336 | * @return The extra height needed. |
| 337 | */ |
| 338 | private int getExtraRemoteInputHeight(RemoteInputView remoteInput) { |
Selim Cinek | 09b442e | 2018-05-04 15:46:18 -0700 | [diff] [blame] | 339 | if (remoteInput != null && (remoteInput.isActive() || remoteInput.isSending())) { |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 340 | return getResources().getDimensionPixelSize( |
| 341 | com.android.internal.R.dimen.notification_content_margin); |
| 342 | } |
| 343 | return 0; |
| 344 | } |
| 345 | |
Selim Cinek | 6ecc810 | 2016-01-26 18:26:19 -0800 | [diff] [blame] | 346 | private boolean updateContractedHeaderWidth() { |
| 347 | // We need to update the expanded and the collapsed header to have exactly the same with to |
| 348 | // have the expand buttons laid out at the same location. |
| 349 | NotificationHeaderView contractedHeader = mContractedWrapper.getNotificationHeader(); |
| 350 | if (contractedHeader != null) { |
| 351 | if (mExpandedChild != null |
| 352 | && mExpandedWrapper.getNotificationHeader() != null) { |
| 353 | NotificationHeaderView expandedHeader = mExpandedWrapper.getNotificationHeader(); |
| 354 | int expandedSize = expandedHeader.getMeasuredWidth() |
| 355 | - expandedHeader.getPaddingEnd(); |
| 356 | int collapsedSize = contractedHeader.getMeasuredWidth() |
| 357 | - expandedHeader.getPaddingEnd(); |
| 358 | if (expandedSize != collapsedSize) { |
| 359 | int paddingEnd = contractedHeader.getMeasuredWidth() - expandedSize; |
| 360 | contractedHeader.setPadding( |
Selim Cinek | cb44568 | 2016-01-29 16:13:12 -0800 | [diff] [blame] | 361 | contractedHeader.isLayoutRtl() |
| 362 | ? paddingEnd |
| 363 | : contractedHeader.getPaddingLeft(), |
Selim Cinek | 6ecc810 | 2016-01-26 18:26:19 -0800 | [diff] [blame] | 364 | contractedHeader.getPaddingTop(), |
Selim Cinek | cb44568 | 2016-01-29 16:13:12 -0800 | [diff] [blame] | 365 | contractedHeader.isLayoutRtl() |
| 366 | ? contractedHeader.getPaddingLeft() |
| 367 | : paddingEnd, |
Selim Cinek | 6ecc810 | 2016-01-26 18:26:19 -0800 | [diff] [blame] | 368 | contractedHeader.getPaddingBottom()); |
| 369 | contractedHeader.setShowWorkBadgeAtEnd(true); |
| 370 | return true; |
| 371 | } |
| 372 | } else { |
| 373 | int paddingEnd = mNotificationContentMarginEnd; |
| 374 | if (contractedHeader.getPaddingEnd() != paddingEnd) { |
| 375 | contractedHeader.setPadding( |
Selim Cinek | cb44568 | 2016-01-29 16:13:12 -0800 | [diff] [blame] | 376 | contractedHeader.isLayoutRtl() |
| 377 | ? paddingEnd |
| 378 | : contractedHeader.getPaddingLeft(), |
Selim Cinek | 6ecc810 | 2016-01-26 18:26:19 -0800 | [diff] [blame] | 379 | contractedHeader.getPaddingTop(), |
Selim Cinek | cb44568 | 2016-01-29 16:13:12 -0800 | [diff] [blame] | 380 | contractedHeader.isLayoutRtl() |
| 381 | ? contractedHeader.getPaddingLeft() |
| 382 | : paddingEnd, |
Selim Cinek | 6ecc810 | 2016-01-26 18:26:19 -0800 | [diff] [blame] | 383 | contractedHeader.getPaddingBottom()); |
| 384 | contractedHeader.setShowWorkBadgeAtEnd(false); |
| 385 | return true; |
| 386 | } |
| 387 | } |
| 388 | } |
| 389 | return false; |
| 390 | } |
| 391 | |
Selim Cinek | 860b6da | 2015-12-16 19:02:19 -0800 | [diff] [blame] | 392 | private boolean shouldContractedBeFixedSize() { |
| 393 | return mBeforeN && mContractedWrapper instanceof NotificationCustomViewWrapper; |
| 394 | } |
| 395 | |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 396 | @Override |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 397 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 398 | int previousHeight = 0; |
| 399 | if (mExpandedChild != null) { |
| 400 | previousHeight = mExpandedChild.getHeight(); |
| 401 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 402 | super.onLayout(changed, left, top, right, bottom); |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 403 | if (previousHeight != 0 && mExpandedChild.getHeight() != previousHeight) { |
| 404 | mContentHeightAtAnimationStart = previousHeight; |
| 405 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 406 | updateClipping(); |
Jorim Jaggi | be4116a | 2015-05-20 20:04:08 -0700 | [diff] [blame] | 407 | invalidateOutline(); |
Selim Cinek | 589fd3e | 2016-04-26 18:17:57 -0700 | [diff] [blame] | 408 | selectLayout(false /* animate */, mForceSelectNextLayout /* force */); |
| 409 | mForceSelectNextLayout = false; |
Selim Cinek | 5f56d85 | 2016-05-24 16:55:13 -0700 | [diff] [blame] | 410 | updateExpandButtons(mExpandable); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 411 | } |
| 412 | |
Selim Cinek | bb3d1cf | 2014-10-31 00:12:56 +0100 | [diff] [blame] | 413 | @Override |
Selim Cinek | 7b8157e | 2014-11-20 16:00:32 +0100 | [diff] [blame] | 414 | protected void onAttachedToWindow() { |
| 415 | super.onAttachedToWindow(); |
Selim Cinek | bb3d1cf | 2014-10-31 00:12:56 +0100 | [diff] [blame] | 416 | updateVisibility(); |
| 417 | } |
| 418 | |
Selim Cinek | cab4a60 | 2014-09-03 14:47:57 +0200 | [diff] [blame] | 419 | public View getContractedChild() { |
| 420 | return mContractedChild; |
| 421 | } |
| 422 | |
| 423 | public View getExpandedChild() { |
| 424 | return mExpandedChild; |
| 425 | } |
| 426 | |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 427 | public View getHeadsUpChild() { |
| 428 | return mHeadsUpChild; |
| 429 | } |
| 430 | |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 431 | public View getAmbientChild() { |
| 432 | return mAmbientChild; |
| 433 | } |
| 434 | |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 435 | public HybridNotificationView getAmbientSingleLineChild() { |
| 436 | return mAmbientSingleLineChild; |
| 437 | } |
| 438 | |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 439 | /** |
| 440 | * Sets the contracted view. Child may be null to remove the content view. |
| 441 | * |
| 442 | * @param child contracted content view to set |
| 443 | */ |
| 444 | public void setContractedChild(@Nullable View child) { |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 445 | if (mContractedChild != null) { |
Jorim Jaggi | 0d9f35d | 2014-08-20 17:06:55 +0200 | [diff] [blame] | 446 | mContractedChild.animate().cancel(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 447 | removeView(mContractedChild); |
| 448 | } |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 449 | if (child == null) { |
| 450 | mContractedChild = null; |
| 451 | mContractedWrapper = null; |
| 452 | if (mTransformationStartVisibleType == VISIBLE_TYPE_CONTRACTED) { |
| 453 | mTransformationStartVisibleType = UNDEFINED; |
| 454 | } |
| 455 | return; |
| 456 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 457 | addView(child); |
| 458 | mContractedChild = child; |
Selim Cinek | 7d1c63e | 2016-04-21 15:26:10 -0700 | [diff] [blame] | 459 | mContractedWrapper = NotificationViewWrapper.wrap(getContext(), child, |
| 460 | mContainingNotification); |
Selim Cinek | 9b49f6d | 2017-11-13 18:19:35 -0800 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | private NotificationViewWrapper getWrapperForView(View child) { |
| 464 | if (child == mContractedChild) { |
| 465 | return mContractedWrapper; |
| 466 | } |
| 467 | if (child == mExpandedChild) { |
| 468 | return mExpandedWrapper; |
| 469 | } |
| 470 | if (child == mHeadsUpChild) { |
| 471 | return mHeadsUpWrapper; |
| 472 | } |
| 473 | if (child == mAmbientChild) { |
| 474 | return mAmbientWrapper; |
| 475 | } |
| 476 | return null; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 477 | } |
| 478 | |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 479 | /** |
| 480 | * Sets the expanded view. Child may be null to remove the content view. |
| 481 | * |
| 482 | * @param child expanded content view to set |
| 483 | */ |
| 484 | public void setExpandedChild(@Nullable View child) { |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 485 | if (mExpandedChild != null) { |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 486 | mPreviousExpandedRemoteInputIntent = null; |
| 487 | if (mExpandedRemoteInput != null) { |
| 488 | mExpandedRemoteInput.onNotificationUpdateOrReset(); |
| 489 | if (mExpandedRemoteInput.isActive()) { |
| 490 | mPreviousExpandedRemoteInputIntent = mExpandedRemoteInput.getPendingIntent(); |
| 491 | mCachedExpandedRemoteInput = mExpandedRemoteInput; |
| 492 | mExpandedRemoteInput.dispatchStartTemporaryDetach(); |
| 493 | ((ViewGroup)mExpandedRemoteInput.getParent()).removeView(mExpandedRemoteInput); |
| 494 | } |
| 495 | } |
Jorim Jaggi | 0d9f35d | 2014-08-20 17:06:55 +0200 | [diff] [blame] | 496 | mExpandedChild.animate().cancel(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 497 | removeView(mExpandedChild); |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 498 | mExpandedRemoteInput = null; |
| 499 | } |
| 500 | if (child == null) { |
| 501 | mExpandedChild = null; |
| 502 | mExpandedWrapper = null; |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 503 | if (mTransformationStartVisibleType == VISIBLE_TYPE_EXPANDED) { |
| 504 | mTransformationStartVisibleType = UNDEFINED; |
| 505 | } |
Selim Cinek | 9f18664 | 2018-11-29 15:47:40 -0800 | [diff] [blame] | 506 | if (mVisibleType == VISIBLE_TYPE_EXPANDED) { |
| 507 | selectLayout(false /* animate */, true /* force */); |
| 508 | } |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 509 | return; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 510 | } |
| 511 | addView(child); |
| 512 | mExpandedChild = child; |
Selim Cinek | 7d1c63e | 2016-04-21 15:26:10 -0700 | [diff] [blame] | 513 | mExpandedWrapper = NotificationViewWrapper.wrap(getContext(), child, |
| 514 | mContainingNotification); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 515 | } |
| 516 | |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 517 | /** |
| 518 | * Sets the heads up view. Child may be null to remove the content view. |
| 519 | * |
| 520 | * @param child heads up content view to set |
| 521 | */ |
| 522 | public void setHeadsUpChild(@Nullable View child) { |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 523 | if (mHeadsUpChild != null) { |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 524 | mPreviousHeadsUpRemoteInputIntent = null; |
| 525 | if (mHeadsUpRemoteInput != null) { |
| 526 | mHeadsUpRemoteInput.onNotificationUpdateOrReset(); |
| 527 | if (mHeadsUpRemoteInput.isActive()) { |
| 528 | mPreviousHeadsUpRemoteInputIntent = mHeadsUpRemoteInput.getPendingIntent(); |
| 529 | mCachedHeadsUpRemoteInput = mHeadsUpRemoteInput; |
| 530 | mHeadsUpRemoteInput.dispatchStartTemporaryDetach(); |
| 531 | ((ViewGroup)mHeadsUpRemoteInput.getParent()).removeView(mHeadsUpRemoteInput); |
| 532 | } |
| 533 | } |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 534 | mHeadsUpChild.animate().cancel(); |
| 535 | removeView(mHeadsUpChild); |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 536 | mHeadsUpRemoteInput = null; |
| 537 | } |
| 538 | if (child == null) { |
| 539 | mHeadsUpChild = null; |
| 540 | mHeadsUpWrapper = null; |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 541 | if (mTransformationStartVisibleType == VISIBLE_TYPE_HEADSUP) { |
| 542 | mTransformationStartVisibleType = UNDEFINED; |
| 543 | } |
Selim Cinek | 9f18664 | 2018-11-29 15:47:40 -0800 | [diff] [blame] | 544 | if (mVisibleType == VISIBLE_TYPE_HEADSUP) { |
| 545 | selectLayout(false /* animate */, true /* force */); |
| 546 | } |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 547 | return; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 548 | } |
| 549 | addView(child); |
| 550 | mHeadsUpChild = child; |
Selim Cinek | 7d1c63e | 2016-04-21 15:26:10 -0700 | [diff] [blame] | 551 | mHeadsUpWrapper = NotificationViewWrapper.wrap(getContext(), child, |
| 552 | mContainingNotification); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 553 | } |
| 554 | |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 555 | /** |
| 556 | * Sets the ambient view. Child may be null to remove the content view. |
| 557 | * |
| 558 | * @param child ambient content view to set |
| 559 | */ |
| 560 | public void setAmbientChild(@Nullable View child) { |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 561 | if (mAmbientChild != null) { |
| 562 | mAmbientChild.animate().cancel(); |
| 563 | removeView(mAmbientChild); |
| 564 | } |
Adrian Roos | 1a1ecfc | 2017-04-17 11:17:59 -0700 | [diff] [blame] | 565 | if (child == null) { |
Kevin | d4660b2 | 2018-09-27 10:57:35 -0700 | [diff] [blame] | 566 | mAmbientChild = null; |
| 567 | mAmbientWrapper = null; |
Kevin | d4660b2 | 2018-09-27 10:57:35 -0700 | [diff] [blame] | 568 | if (mTransformationStartVisibleType == VISIBLE_TYPE_AMBIENT) { |
| 569 | mTransformationStartVisibleType = UNDEFINED; |
| 570 | } |
Selim Cinek | 9f18664 | 2018-11-29 15:47:40 -0800 | [diff] [blame] | 571 | if (mVisibleType == VISIBLE_TYPE_AMBIENT) { |
| 572 | selectLayout(false /* animate */, true /* force */); |
| 573 | } |
Adrian Roos | 1a1ecfc | 2017-04-17 11:17:59 -0700 | [diff] [blame] | 574 | return; |
| 575 | } |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 576 | addView(child); |
| 577 | mAmbientChild = child; |
| 578 | mAmbientWrapper = NotificationViewWrapper.wrap(getContext(), child, |
| 579 | mContainingNotification); |
| 580 | } |
| 581 | |
Selim Cinek | bb3d1cf | 2014-10-31 00:12:56 +0100 | [diff] [blame] | 582 | @Override |
| 583 | protected void onVisibilityChanged(View changedView, int visibility) { |
| 584 | super.onVisibilityChanged(changedView, visibility); |
| 585 | updateVisibility(); |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 586 | if (visibility != VISIBLE) { |
| 587 | // View is no longer visible so all content views are inactive. |
| 588 | for (Runnable r : mOnContentViewInactiveListeners.values()) { |
| 589 | r.run(); |
| 590 | } |
| 591 | mOnContentViewInactiveListeners.clear(); |
| 592 | } |
Selim Cinek | bb3d1cf | 2014-10-31 00:12:56 +0100 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | private void updateVisibility() { |
| 596 | setVisible(isShown()); |
| 597 | } |
| 598 | |
Jorim Jaggi | 38b5ec9 | 2016-04-12 01:39:49 -0700 | [diff] [blame] | 599 | @Override |
| 600 | protected void onDetachedFromWindow() { |
| 601 | super.onDetachedFromWindow(); |
| 602 | getViewTreeObserver().removeOnPreDrawListener(mEnableAnimationPredrawListener); |
| 603 | } |
| 604 | |
Selim Cinek | bb3d1cf | 2014-10-31 00:12:56 +0100 | [diff] [blame] | 605 | private void setVisible(final boolean isVisible) { |
| 606 | if (isVisible) { |
Selim Cinek | f1614a6 | 2016-05-26 16:57:20 -0700 | [diff] [blame] | 607 | // This call can happen multiple times, but removing only removes a single one. |
| 608 | // We therefore need to remove the old one. |
| 609 | getViewTreeObserver().removeOnPreDrawListener(mEnableAnimationPredrawListener); |
Selim Cinek | bb3d1cf | 2014-10-31 00:12:56 +0100 | [diff] [blame] | 610 | // We only animate if we are drawn at least once, otherwise the view might animate when |
| 611 | // it's shown the first time |
| 612 | getViewTreeObserver().addOnPreDrawListener(mEnableAnimationPredrawListener); |
| 613 | } else { |
| 614 | getViewTreeObserver().removeOnPreDrawListener(mEnableAnimationPredrawListener); |
| 615 | mAnimate = false; |
| 616 | } |
| 617 | } |
| 618 | |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 619 | private void focusExpandButtonIfNecessary() { |
| 620 | if (mFocusOnVisibilityChange) { |
| 621 | NotificationHeaderView header = getVisibleNotificationHeader(); |
| 622 | if (header != null) { |
| 623 | ImageView expandButton = header.getExpandButton(); |
| 624 | if (expandButton != null) { |
| 625 | expandButton.requestAccessibilityFocus(); |
| 626 | } |
| 627 | } |
| 628 | mFocusOnVisibilityChange = false; |
| 629 | } |
| 630 | } |
| 631 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 632 | public void setContentHeight(int contentHeight) { |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 633 | mUnrestrictedContentHeight = Math.max(contentHeight, getMinHeight()); |
| 634 | int maxContentHeight = mContainingNotification.getIntrinsicHeight() |
| 635 | - getExtraRemoteInputHeight(mExpandedRemoteInput) |
| 636 | - getExtraRemoteInputHeight(mHeadsUpRemoteInput); |
| 637 | mContentHeight = Math.min(mUnrestrictedContentHeight, maxContentHeight); |
Selim Cinek | bb3d1cf | 2014-10-31 00:12:56 +0100 | [diff] [blame] | 638 | selectLayout(mAnimate /* animate */, false /* force */); |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 639 | |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 640 | if (mContractedChild == null) { |
| 641 | // Contracted child may be null if this is the public content view and we don't need to |
| 642 | // show it. |
| 643 | return; |
| 644 | } |
| 645 | |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 646 | int minHeightHint = getMinContentHeightHint(); |
| 647 | |
| 648 | NotificationViewWrapper wrapper = getVisibleWrapper(mVisibleType); |
| 649 | if (wrapper != null) { |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 650 | wrapper.setContentHeight(mUnrestrictedContentHeight, minHeightHint); |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | wrapper = getVisibleWrapper(mTransformationStartVisibleType); |
| 654 | if (wrapper != null) { |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 655 | wrapper.setContentHeight(mUnrestrictedContentHeight, minHeightHint); |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 656 | } |
| 657 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 658 | updateClipping(); |
Jorim Jaggi | be4116a | 2015-05-20 20:04:08 -0700 | [diff] [blame] | 659 | invalidateOutline(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 660 | } |
| 661 | |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 662 | /** |
| 663 | * @return the minimum apparent height that the wrapper should allow for the purpose |
| 664 | * of aligning elements at the bottom edge. If this is larger than the content |
| 665 | * height, the notification is clipped instead of being further shrunk. |
| 666 | */ |
| 667 | private int getMinContentHeightHint() { |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 668 | if (mIsChildInGroup && isVisibleOrTransitioning(VISIBLE_TYPE_SINGLELINE)) { |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 669 | return mContext.getResources().getDimensionPixelSize( |
| 670 | com.android.internal.R.dimen.notification_action_list_height); |
| 671 | } |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 672 | |
| 673 | // Transition between heads-up & expanded, or pinned. |
| 674 | if (mHeadsUpChild != null && mExpandedChild != null) { |
| 675 | boolean transitioningBetweenHunAndExpanded = |
| 676 | isTransitioningFromTo(VISIBLE_TYPE_HEADSUP, VISIBLE_TYPE_EXPANDED) || |
| 677 | isTransitioningFromTo(VISIBLE_TYPE_EXPANDED, VISIBLE_TYPE_HEADSUP); |
Selim Cinek | 73cf02a | 2016-06-17 13:08:00 -0700 | [diff] [blame] | 678 | boolean pinned = !isVisibleOrTransitioning(VISIBLE_TYPE_CONTRACTED) |
Selim Cinek | c494e38 | 2017-01-31 16:09:23 -0800 | [diff] [blame] | 679 | && (mIsHeadsUp || mHeadsUpAnimatingAway) |
| 680 | && !mContainingNotification.isOnKeyguard(); |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 681 | if (transitioningBetweenHunAndExpanded || pinned) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 682 | return Math.min(getViewHeight(VISIBLE_TYPE_HEADSUP), |
| 683 | getViewHeight(VISIBLE_TYPE_EXPANDED)); |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 684 | } |
| 685 | } |
| 686 | |
| 687 | // Size change of the expanded version |
| 688 | if ((mVisibleType == VISIBLE_TYPE_EXPANDED) && mContentHeightAtAnimationStart >= 0 |
| 689 | && mExpandedChild != null) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 690 | return Math.min(mContentHeightAtAnimationStart, getViewHeight(VISIBLE_TYPE_EXPANDED)); |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 691 | } |
| 692 | |
Adrian Roos | bb73e9c6 | 2016-05-26 12:06:40 -0700 | [diff] [blame] | 693 | int hint; |
Adrian Roos | 05d3d00 | 2017-01-26 15:28:07 -0800 | [diff] [blame] | 694 | if (mAmbientChild != null && isVisibleOrTransitioning(VISIBLE_TYPE_AMBIENT)) { |
| 695 | hint = mAmbientChild.getHeight(); |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 696 | } else if (mAmbientSingleLineChild != null && isVisibleOrTransitioning( |
| 697 | VISIBLE_TYPE_AMBIENT_SINGLELINE)) { |
| 698 | hint = mAmbientSingleLineChild.getHeight(); |
Adrian Roos | 05d3d00 | 2017-01-26 15:28:07 -0800 | [diff] [blame] | 699 | } else if (mHeadsUpChild != null && isVisibleOrTransitioning(VISIBLE_TYPE_HEADSUP)) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 700 | hint = getViewHeight(VISIBLE_TYPE_HEADSUP); |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 701 | } else if (mExpandedChild != null) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 702 | hint = getViewHeight(VISIBLE_TYPE_EXPANDED); |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 703 | } else { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 704 | hint = getViewHeight(VISIBLE_TYPE_CONTRACTED) |
| 705 | + mContext.getResources().getDimensionPixelSize( |
| 706 | com.android.internal.R.dimen.notification_action_list_height); |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 707 | } |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 708 | |
| 709 | if (mExpandedChild != null && isVisibleOrTransitioning(VISIBLE_TYPE_EXPANDED)) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 710 | hint = Math.min(hint, getViewHeight(VISIBLE_TYPE_EXPANDED)); |
Adrian Roos | bb73e9c6 | 2016-05-26 12:06:40 -0700 | [diff] [blame] | 711 | } |
| 712 | return hint; |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 713 | } |
| 714 | |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 715 | private boolean isTransitioningFromTo(int from, int to) { |
| 716 | return (mTransformationStartVisibleType == from || mAnimationStartVisibleType == from) |
| 717 | && mVisibleType == to; |
| 718 | } |
| 719 | |
| 720 | private boolean isVisibleOrTransitioning(int type) { |
| 721 | return mVisibleType == type || mTransformationStartVisibleType == type |
| 722 | || mAnimationStartVisibleType == type; |
| 723 | } |
| 724 | |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 725 | private void updateContentTransformation() { |
| 726 | int visibleType = calculateVisibleType(); |
| 727 | if (visibleType != mVisibleType) { |
| 728 | // A new transformation starts |
| 729 | mTransformationStartVisibleType = mVisibleType; |
| 730 | final TransformableView shownView = getTransformableViewForVisibleType(visibleType); |
| 731 | final TransformableView hiddenView = getTransformableViewForVisibleType( |
| 732 | mTransformationStartVisibleType); |
| 733 | shownView.transformFrom(hiddenView, 0.0f); |
| 734 | getViewForVisibleType(visibleType).setVisibility(View.VISIBLE); |
| 735 | hiddenView.transformTo(shownView, 0.0f); |
| 736 | mVisibleType = visibleType; |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 737 | updateBackgroundColor(true /* animate */); |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 738 | } |
Selim Cinek | e857887 | 2016-05-03 16:42:50 -0700 | [diff] [blame] | 739 | if (mForceSelectNextLayout) { |
| 740 | forceUpdateVisibilities(); |
| 741 | } |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 742 | if (mTransformationStartVisibleType != UNDEFINED |
Selim Cinek | 589fd3e | 2016-04-26 18:17:57 -0700 | [diff] [blame] | 743 | && mVisibleType != mTransformationStartVisibleType |
| 744 | && getViewForVisibleType(mTransformationStartVisibleType) != null) { |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 745 | final TransformableView shownView = getTransformableViewForVisibleType(mVisibleType); |
| 746 | final TransformableView hiddenView = getTransformableViewForVisibleType( |
| 747 | mTransformationStartVisibleType); |
| 748 | float transformationAmount = calculateTransformationAmount(); |
| 749 | shownView.transformFrom(hiddenView, transformationAmount); |
| 750 | hiddenView.transformTo(shownView, transformationAmount); |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 751 | updateBackgroundTransformation(transformationAmount); |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 752 | } else { |
| 753 | updateViewVisibilities(visibleType); |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 754 | updateBackgroundColor(false); |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 755 | } |
| 756 | } |
| 757 | |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 758 | private void updateBackgroundTransformation(float transformationAmount) { |
| 759 | int endColor = getBackgroundColor(mVisibleType); |
| 760 | int startColor = getBackgroundColor(mTransformationStartVisibleType); |
| 761 | if (endColor != startColor) { |
| 762 | if (startColor == 0) { |
| 763 | startColor = mContainingNotification.getBackgroundColorWithoutTint(); |
| 764 | } |
| 765 | if (endColor == 0) { |
| 766 | endColor = mContainingNotification.getBackgroundColorWithoutTint(); |
| 767 | } |
| 768 | endColor = NotificationUtils.interpolateColors(startColor, endColor, |
| 769 | transformationAmount); |
| 770 | } |
Mady Mellor | c7d65b4 | 2016-05-04 11:44:57 -0400 | [diff] [blame] | 771 | mContainingNotification.updateBackgroundAlpha(transformationAmount); |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 772 | mContainingNotification.setContentBackground(endColor, false, this); |
| 773 | } |
| 774 | |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 775 | private float calculateTransformationAmount() { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 776 | int startHeight = getViewHeight(mTransformationStartVisibleType); |
| 777 | int endHeight = getViewHeight(mVisibleType); |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 778 | int progress = Math.abs(mContentHeight - startHeight); |
| 779 | int totalDistance = Math.abs(endHeight - startHeight); |
Selim Cinek | 011bde9 | 2017-11-22 05:53:38 -0800 | [diff] [blame] | 780 | if (totalDistance == 0) { |
| 781 | Log.wtf(TAG, "the total transformation distance is 0" |
| 782 | + "\n StartType: " + mTransformationStartVisibleType + " height: " + startHeight |
| 783 | + "\n VisibleType: " + mVisibleType + " height: " + endHeight |
| 784 | + "\n mContentHeight: " + mContentHeight); |
| 785 | return 1.0f; |
| 786 | } |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 787 | float amount = (float) progress / (float) totalDistance; |
| 788 | return Math.min(1.0f, amount); |
| 789 | } |
| 790 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 791 | public int getContentHeight() { |
| 792 | return mContentHeight; |
| 793 | } |
| 794 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 795 | public int getMaxHeight() { |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 796 | if (mContainingNotification.isOnAmbient() && getShowingAmbientView() != null) { |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 797 | return getShowingAmbientView().getHeight(); |
| 798 | } else if (mExpandedChild != null) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 799 | return getViewHeight(VISIBLE_TYPE_EXPANDED) |
| 800 | + getExtraRemoteInputHeight(mExpandedRemoteInput); |
Selim Cinek | c494e38 | 2017-01-31 16:09:23 -0800 | [diff] [blame] | 801 | } else if (mIsHeadsUp && mHeadsUpChild != null && !mContainingNotification.isOnKeyguard()) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 802 | return getViewHeight(VISIBLE_TYPE_HEADSUP) |
| 803 | + getExtraRemoteInputHeight(mHeadsUpRemoteInput); |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 804 | } else if (mContractedChild != null) { |
| 805 | return getViewHeight(VISIBLE_TYPE_CONTRACTED); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 806 | } |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 807 | return mNotificationMaxHeight; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 808 | } |
| 809 | |
| 810 | private int getViewHeight(int visibleType) { |
| 811 | View view = getViewForVisibleType(visibleType); |
| 812 | int height = view.getHeight(); |
| 813 | NotificationViewWrapper viewWrapper = getWrapperForView(view); |
| 814 | if (viewWrapper != null) { |
| 815 | height += viewWrapper.getHeaderTranslation(); |
| 816 | } |
| 817 | return height; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 818 | } |
| 819 | |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 820 | public int getMinHeight() { |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 821 | return getMinHeight(false /* likeGroupExpanded */); |
| 822 | } |
| 823 | |
| 824 | public int getMinHeight(boolean likeGroupExpanded) { |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 825 | if (mContainingNotification.isOnAmbient() && getShowingAmbientView() != null) { |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 826 | return getShowingAmbientView().getHeight(); |
| 827 | } else if (likeGroupExpanded || !mIsChildInGroup || isGroupExpanded()) { |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 828 | return mContractedChild != null |
| 829 | ? getViewHeight(VISIBLE_TYPE_CONTRACTED) : mMinContractedHeight; |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 830 | } else { |
| 831 | return mSingleLineView.getHeight(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 832 | } |
| 833 | } |
| 834 | |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 835 | public View getShowingAmbientView() { |
| 836 | View v = mIsChildInGroup ? mAmbientSingleLineChild : mAmbientChild; |
| 837 | if (v != null) { |
| 838 | return v; |
| 839 | } else { |
| 840 | return mContractedChild; |
| 841 | } |
| 842 | } |
| 843 | |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 844 | private boolean isGroupExpanded() { |
| 845 | return mGroupManager.isGroupExpanded(mStatusBarNotification); |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 846 | } |
| 847 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 848 | public void setClipTopAmount(int clipTopAmount) { |
Selim Cinek | c9c00ae | 2014-05-20 03:33:40 +0200 | [diff] [blame] | 849 | mClipTopAmount = clipTopAmount; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 850 | updateClipping(); |
| 851 | } |
| 852 | |
Selim Cinek | a686b2c | 2016-10-26 13:58:27 -0700 | [diff] [blame] | 853 | |
| 854 | public void setClipBottomAmount(int clipBottomAmount) { |
| 855 | mClipBottomAmount = clipBottomAmount; |
| 856 | updateClipping(); |
| 857 | } |
| 858 | |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 859 | @Override |
| 860 | public void setTranslationY(float translationY) { |
| 861 | super.setTranslationY(translationY); |
| 862 | updateClipping(); |
| 863 | } |
| 864 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 865 | private void updateClipping() { |
Selim Cinek | 4ffd636 | 2015-12-29 15:12:23 +0100 | [diff] [blame] | 866 | if (mClipToActualHeight) { |
Selim Cinek | 875a3a1 | 2016-11-18 17:52:16 -0800 | [diff] [blame] | 867 | int top = (int) (mClipTopAmount - getTranslationY()); |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 868 | int bottom = (int) (mUnrestrictedContentHeight - mClipBottomAmount - getTranslationY()); |
Selim Cinek | a686b2c | 2016-10-26 13:58:27 -0700 | [diff] [blame] | 869 | bottom = Math.max(top, bottom); |
| 870 | mClipBounds.set(0, top, getWidth(), bottom); |
Selim Cinek | 4ffd636 | 2015-12-29 15:12:23 +0100 | [diff] [blame] | 871 | setClipBounds(mClipBounds); |
| 872 | } else { |
| 873 | setClipBounds(null); |
| 874 | } |
| 875 | } |
| 876 | |
| 877 | public void setClipToActualHeight(boolean clipToActualHeight) { |
| 878 | mClipToActualHeight = clipToActualHeight; |
| 879 | updateClipping(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 880 | } |
| 881 | |
Jorim Jaggi | 1129883 | 2014-05-24 16:18:38 +0200 | [diff] [blame] | 882 | private void selectLayout(boolean animate, boolean force) { |
| 883 | if (mContractedChild == null) { |
| 884 | return; |
| 885 | } |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 886 | if (mUserExpanding) { |
| 887 | updateContentTransformation(); |
Selim Cinek | 589fd3e | 2016-04-26 18:17:57 -0700 | [diff] [blame] | 888 | } else { |
| 889 | int visibleType = calculateVisibleType(); |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 890 | boolean changedType = visibleType != mVisibleType; |
| 891 | if (changedType || force) { |
Adrian Roos | 181385c | 2016-05-05 17:45:44 -0400 | [diff] [blame] | 892 | View visibleView = getViewForVisibleType(visibleType); |
| 893 | if (visibleView != null) { |
| 894 | visibleView.setVisibility(VISIBLE); |
| 895 | transferRemoteInputFocus(visibleType); |
| 896 | } |
Adrian Roos | 4c1fcc8 | 2016-03-31 14:39:39 -0700 | [diff] [blame] | 897 | |
Selim Cinek | 589fd3e | 2016-04-26 18:17:57 -0700 | [diff] [blame] | 898 | if (animate && ((visibleType == VISIBLE_TYPE_EXPANDED && mExpandedChild != null) |
| 899 | || (visibleType == VISIBLE_TYPE_HEADSUP && mHeadsUpChild != null) |
| 900 | || (visibleType == VISIBLE_TYPE_SINGLELINE && mSingleLineView != null) |
| 901 | || visibleType == VISIBLE_TYPE_CONTRACTED)) { |
| 902 | animateToVisibleType(visibleType); |
| 903 | } else { |
| 904 | updateViewVisibilities(visibleType); |
| 905 | } |
| 906 | mVisibleType = visibleType; |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 907 | if (changedType) { |
| 908 | focusExpandButtonIfNecessary(); |
| 909 | } |
Adrian Roos | 05d3d00 | 2017-01-26 15:28:07 -0800 | [diff] [blame] | 910 | NotificationViewWrapper visibleWrapper = getVisibleWrapper(visibleType); |
| 911 | if (visibleWrapper != null) { |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 912 | visibleWrapper.setContentHeight(mUnrestrictedContentHeight, |
| 913 | getMinContentHeightHint()); |
Adrian Roos | 05d3d00 | 2017-01-26 15:28:07 -0800 | [diff] [blame] | 914 | } |
Selim Cinek | 589fd3e | 2016-04-26 18:17:57 -0700 | [diff] [blame] | 915 | updateBackgroundColor(animate); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 916 | } |
Selim Cinek | 589fd3e | 2016-04-26 18:17:57 -0700 | [diff] [blame] | 917 | } |
Selim Cinek | 589fd3e | 2016-04-26 18:17:57 -0700 | [diff] [blame] | 918 | } |
| 919 | |
| 920 | private void forceUpdateVisibilities() { |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 921 | forceUpdateVisibility(VISIBLE_TYPE_CONTRACTED, mContractedChild, mContractedWrapper); |
| 922 | forceUpdateVisibility(VISIBLE_TYPE_EXPANDED, mExpandedChild, mExpandedWrapper); |
| 923 | forceUpdateVisibility(VISIBLE_TYPE_HEADSUP, mHeadsUpChild, mHeadsUpWrapper); |
| 924 | forceUpdateVisibility(VISIBLE_TYPE_SINGLELINE, mSingleLineView, mSingleLineView); |
| 925 | forceUpdateVisibility(VISIBLE_TYPE_AMBIENT, mAmbientChild, mAmbientWrapper); |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 926 | forceUpdateVisibility(VISIBLE_TYPE_AMBIENT_SINGLELINE, mAmbientSingleLineChild, |
| 927 | mAmbientSingleLineChild); |
Adrian Roos | 4320e89 | 2017-01-24 12:50:34 -0800 | [diff] [blame] | 928 | fireExpandedVisibleListenerIfVisible(); |
Adrian Roos | e18033c | 2017-01-17 15:22:49 -0800 | [diff] [blame] | 929 | // forceUpdateVisibilities cancels outstanding animations without updating the |
| 930 | // mAnimationStartVisibleType. Do so here instead. |
| 931 | mAnimationStartVisibleType = UNDEFINED; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 932 | } |
| 933 | |
Adrian Roos | 4320e89 | 2017-01-24 12:50:34 -0800 | [diff] [blame] | 934 | private void fireExpandedVisibleListenerIfVisible() { |
| 935 | if (mExpandedVisibleListener != null && mExpandedChild != null && isShown() |
| 936 | && mExpandedChild.getVisibility() == VISIBLE) { |
| 937 | Runnable listener = mExpandedVisibleListener; |
| 938 | mExpandedVisibleListener = null; |
| 939 | listener.run(); |
| 940 | } |
| 941 | } |
| 942 | |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 943 | private void forceUpdateVisibility(int type, View view, TransformableView wrapper) { |
| 944 | if (view == null) { |
| 945 | return; |
| 946 | } |
| 947 | boolean visible = mVisibleType == type |
| 948 | || mTransformationStartVisibleType == type; |
| 949 | if (!visible) { |
| 950 | view.setVisibility(INVISIBLE); |
Selim Cinek | 589fd3e | 2016-04-26 18:17:57 -0700 | [diff] [blame] | 951 | } else { |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 952 | wrapper.setVisible(true); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 953 | } |
Jorim Jaggi | 1129883 | 2014-05-24 16:18:38 +0200 | [diff] [blame] | 954 | } |
| 955 | |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 956 | public void updateBackgroundColor(boolean animate) { |
| 957 | int customBackgroundColor = getBackgroundColor(mVisibleType); |
Mady Mellor | c7d65b4 | 2016-05-04 11:44:57 -0400 | [diff] [blame] | 958 | mContainingNotification.resetBackgroundAlpha(); |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 959 | mContainingNotification.setContentBackground(customBackgroundColor, animate, this); |
| 960 | } |
| 961 | |
Kenny Guy | 14d035c | 2018-05-02 19:10:36 +0100 | [diff] [blame] | 962 | public void setBackgroundTintColor(int color) { |
| 963 | if (mExpandedSmartReplyView != null) { |
| 964 | mExpandedSmartReplyView.setBackgroundTintColor(color); |
| 965 | } |
Gustav Sennton | d0e8453 | 2018-12-03 16:48:36 +0000 | [diff] [blame] | 966 | if (mHeadsUpSmartReplyView != null) { |
| 967 | mHeadsUpSmartReplyView.setBackgroundTintColor(color); |
| 968 | } |
Kenny Guy | 14d035c | 2018-05-02 19:10:36 +0100 | [diff] [blame] | 969 | } |
| 970 | |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 971 | public int getVisibleType() { |
| 972 | return mVisibleType; |
| 973 | } |
| 974 | |
| 975 | public int getBackgroundColorForExpansionState() { |
| 976 | // When expanding or user locked we want the new type, when collapsing we want |
| 977 | // the original type |
| 978 | final int visibleType = (mContainingNotification.isGroupExpanded() |
| 979 | || mContainingNotification.isUserLocked()) |
| 980 | ? calculateVisibleType() |
| 981 | : getVisibleType(); |
| 982 | return getBackgroundColor(visibleType); |
| 983 | } |
| 984 | |
| 985 | public int getBackgroundColor(int visibleType) { |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 986 | NotificationViewWrapper currentVisibleWrapper = getVisibleWrapper(visibleType); |
| 987 | int customBackgroundColor = 0; |
| 988 | if (currentVisibleWrapper != null) { |
| 989 | customBackgroundColor = currentVisibleWrapper.getCustomBackgroundColor(); |
| 990 | } |
| 991 | return customBackgroundColor; |
| 992 | } |
| 993 | |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 994 | private void updateViewVisibilities(int visibleType) { |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 995 | updateViewVisibility(visibleType, VISIBLE_TYPE_CONTRACTED, |
| 996 | mContractedChild, mContractedWrapper); |
| 997 | updateViewVisibility(visibleType, VISIBLE_TYPE_EXPANDED, |
| 998 | mExpandedChild, mExpandedWrapper); |
| 999 | updateViewVisibility(visibleType, VISIBLE_TYPE_HEADSUP, |
| 1000 | mHeadsUpChild, mHeadsUpWrapper); |
| 1001 | updateViewVisibility(visibleType, VISIBLE_TYPE_SINGLELINE, |
| 1002 | mSingleLineView, mSingleLineView); |
| 1003 | updateViewVisibility(visibleType, VISIBLE_TYPE_AMBIENT, |
| 1004 | mAmbientChild, mAmbientWrapper); |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 1005 | updateViewVisibility(visibleType, VISIBLE_TYPE_AMBIENT_SINGLELINE, |
| 1006 | mAmbientSingleLineChild, mAmbientSingleLineChild); |
Adrian Roos | 4320e89 | 2017-01-24 12:50:34 -0800 | [diff] [blame] | 1007 | fireExpandedVisibleListenerIfVisible(); |
Adrian Roos | e18033c | 2017-01-17 15:22:49 -0800 | [diff] [blame] | 1008 | // updateViewVisibilities cancels outstanding animations without updating the |
| 1009 | // mAnimationStartVisibleType. Do so here instead. |
| 1010 | mAnimationStartVisibleType = UNDEFINED; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 1011 | } |
| 1012 | |
| 1013 | private void updateViewVisibility(int visibleType, int type, View view, |
| 1014 | TransformableView wrapper) { |
| 1015 | if (view != null) { |
| 1016 | wrapper.setVisible(visibleType == type); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1017 | } |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1018 | } |
| 1019 | |
Selim Cinek | 4ffd636 | 2015-12-29 15:12:23 +0100 | [diff] [blame] | 1020 | private void animateToVisibleType(int visibleType) { |
| 1021 | final TransformableView shownView = getTransformableViewForVisibleType(visibleType); |
| 1022 | final TransformableView hiddenView = getTransformableViewForVisibleType(mVisibleType); |
Selim Cinek | 589fd3e | 2016-04-26 18:17:57 -0700 | [diff] [blame] | 1023 | if (shownView == hiddenView || hiddenView == null) { |
Selim Cinek | 51d9491 | 2016-03-02 15:34:28 -0800 | [diff] [blame] | 1024 | shownView.setVisible(true); |
| 1025 | return; |
| 1026 | } |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 1027 | mAnimationStartVisibleType = mVisibleType; |
Selim Cinek | 4ffd636 | 2015-12-29 15:12:23 +0100 | [diff] [blame] | 1028 | shownView.transformFrom(hiddenView); |
| 1029 | getViewForVisibleType(visibleType).setVisibility(View.VISIBLE); |
| 1030 | hiddenView.transformTo(shownView, new Runnable() { |
| 1031 | @Override |
| 1032 | public void run() { |
Selim Cinek | 51d9491 | 2016-03-02 15:34:28 -0800 | [diff] [blame] | 1033 | if (hiddenView != getTransformableViewForVisibleType(mVisibleType)) { |
| 1034 | hiddenView.setVisible(false); |
| 1035 | } |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 1036 | mAnimationStartVisibleType = UNDEFINED; |
Selim Cinek | 4ffd636 | 2015-12-29 15:12:23 +0100 | [diff] [blame] | 1037 | } |
| 1038 | }); |
Adrian Roos | 4320e89 | 2017-01-24 12:50:34 -0800 | [diff] [blame] | 1039 | fireExpandedVisibleListenerIfVisible(); |
Jorim Jaggi | 1129883 | 2014-05-24 16:18:38 +0200 | [diff] [blame] | 1040 | } |
| 1041 | |
Adrian Roos | 4c1fcc8 | 2016-03-31 14:39:39 -0700 | [diff] [blame] | 1042 | private void transferRemoteInputFocus(int visibleType) { |
| 1043 | if (visibleType == VISIBLE_TYPE_HEADSUP |
| 1044 | && mHeadsUpRemoteInput != null |
| 1045 | && (mExpandedRemoteInput != null && mExpandedRemoteInput.isActive())) { |
| 1046 | mHeadsUpRemoteInput.stealFocusFrom(mExpandedRemoteInput); |
| 1047 | } |
| 1048 | if (visibleType == VISIBLE_TYPE_EXPANDED |
| 1049 | && mExpandedRemoteInput != null |
| 1050 | && (mHeadsUpRemoteInput != null && mHeadsUpRemoteInput.isActive())) { |
| 1051 | mExpandedRemoteInput.stealFocusFrom(mHeadsUpRemoteInput); |
| 1052 | } |
| 1053 | } |
| 1054 | |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1055 | /** |
| 1056 | * @param visibleType one of the static enum types in this view |
Selim Cinek | 4ffd636 | 2015-12-29 15:12:23 +0100 | [diff] [blame] | 1057 | * @return the corresponding transformable view according to the given visible type |
| 1058 | */ |
| 1059 | private TransformableView getTransformableViewForVisibleType(int visibleType) { |
| 1060 | switch (visibleType) { |
| 1061 | case VISIBLE_TYPE_EXPANDED: |
| 1062 | return mExpandedWrapper; |
| 1063 | case VISIBLE_TYPE_HEADSUP: |
| 1064 | return mHeadsUpWrapper; |
| 1065 | case VISIBLE_TYPE_SINGLELINE: |
| 1066 | return mSingleLineView; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 1067 | case VISIBLE_TYPE_AMBIENT: |
| 1068 | return mAmbientWrapper; |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 1069 | case VISIBLE_TYPE_AMBIENT_SINGLELINE: |
| 1070 | return mAmbientSingleLineChild; |
Selim Cinek | 4ffd636 | 2015-12-29 15:12:23 +0100 | [diff] [blame] | 1071 | default: |
| 1072 | return mContractedWrapper; |
| 1073 | } |
| 1074 | } |
| 1075 | |
| 1076 | /** |
| 1077 | * @param visibleType one of the static enum types in this view |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1078 | * @return the corresponding view according to the given visible type |
| 1079 | */ |
| 1080 | private View getViewForVisibleType(int visibleType) { |
| 1081 | switch (visibleType) { |
| 1082 | case VISIBLE_TYPE_EXPANDED: |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1083 | return mExpandedChild; |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1084 | case VISIBLE_TYPE_HEADSUP: |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1085 | return mHeadsUpChild; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1086 | case VISIBLE_TYPE_SINGLELINE: |
| 1087 | return mSingleLineView; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 1088 | case VISIBLE_TYPE_AMBIENT: |
| 1089 | return mAmbientChild; |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 1090 | case VISIBLE_TYPE_AMBIENT_SINGLELINE: |
| 1091 | return mAmbientSingleLineChild; |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1092 | default: |
| 1093 | return mContractedChild; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1094 | } |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1095 | } |
| 1096 | |
Selim Cinek | 131f1a4 | 2017-06-05 17:50:19 -0700 | [diff] [blame] | 1097 | public NotificationViewWrapper getVisibleWrapper(int visibleType) { |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 1098 | switch (visibleType) { |
Selim Cinek | 34eda5e | 2016-02-18 17:10:43 -0800 | [diff] [blame] | 1099 | case VISIBLE_TYPE_EXPANDED: |
| 1100 | return mExpandedWrapper; |
| 1101 | case VISIBLE_TYPE_HEADSUP: |
| 1102 | return mHeadsUpWrapper; |
| 1103 | case VISIBLE_TYPE_CONTRACTED: |
| 1104 | return mContractedWrapper; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 1105 | case VISIBLE_TYPE_AMBIENT: |
| 1106 | return mAmbientWrapper; |
Selim Cinek | 34eda5e | 2016-02-18 17:10:43 -0800 | [diff] [blame] | 1107 | default: |
| 1108 | return null; |
| 1109 | } |
| 1110 | } |
| 1111 | |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1112 | /** |
| 1113 | * @return one of the static enum types in this view, calculated form the current state |
| 1114 | */ |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 1115 | public int calculateVisibleType() { |
Kevin | a97ea05 | 2018-09-11 13:53:18 -0700 | [diff] [blame] | 1116 | if (mContainingNotification.isOnAmbient()) { |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 1117 | if (mIsChildInGroup && mAmbientSingleLineChild != null) { |
| 1118 | return VISIBLE_TYPE_AMBIENT_SINGLELINE; |
| 1119 | } else if (mAmbientChild != null) { |
| 1120 | return VISIBLE_TYPE_AMBIENT; |
| 1121 | } else { |
| 1122 | return VISIBLE_TYPE_CONTRACTED; |
| 1123 | } |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 1124 | } |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 1125 | if (mUserExpanding) { |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1126 | int height = !mIsChildInGroup || isGroupExpanded() |
Selim Cinek | e81b82b | 2016-03-04 11:22:28 -0800 | [diff] [blame] | 1127 | || mContainingNotification.isExpanded(true /* allowOnKeyguard */) |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1128 | ? mContainingNotification.getMaxContentHeight() |
| 1129 | : mContainingNotification.getShowingLayout().getMinHeight(); |
Selim Cinek | 51d9491 | 2016-03-02 15:34:28 -0800 | [diff] [blame] | 1130 | if (height == 0) { |
| 1131 | height = mContentHeight; |
| 1132 | } |
Selim Cinek | 42357e0 | 2016-02-24 18:48:01 -0800 | [diff] [blame] | 1133 | int expandedVisualType = getVisualTypeForHeight(height); |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1134 | int collapsedVisualType = mIsChildInGroup && !isGroupExpanded() |
Selim Cinek | 589fd3e | 2016-04-26 18:17:57 -0700 | [diff] [blame] | 1135 | ? VISIBLE_TYPE_SINGLELINE |
| 1136 | : getVisualTypeForHeight(mContainingNotification.getCollapsedHeight()); |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 1137 | return mTransformationStartVisibleType == collapsedVisualType |
| 1138 | ? expandedVisualType |
| 1139 | : collapsedVisualType; |
| 1140 | } |
Selim Cinek | 51d9491 | 2016-03-02 15:34:28 -0800 | [diff] [blame] | 1141 | int intrinsicHeight = mContainingNotification.getIntrinsicHeight(); |
| 1142 | int viewHeight = mContentHeight; |
| 1143 | if (intrinsicHeight != 0) { |
| 1144 | // the intrinsicHeight might be 0 because it was just reset. |
| 1145 | viewHeight = Math.min(mContentHeight, intrinsicHeight); |
| 1146 | } |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 1147 | return getVisualTypeForHeight(viewHeight); |
| 1148 | } |
| 1149 | |
| 1150 | private int getVisualTypeForHeight(float viewHeight) { |
| 1151 | boolean noExpandedChild = mExpandedChild == null; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1152 | if (!noExpandedChild && viewHeight == getViewHeight(VISIBLE_TYPE_EXPANDED)) { |
Adrian Roos | 777ef56 | 2015-12-01 17:37:14 -0800 | [diff] [blame] | 1153 | return VISIBLE_TYPE_EXPANDED; |
| 1154 | } |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1155 | if (!mUserExpanding && mIsChildInGroup && !isGroupExpanded()) { |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1156 | return VISIBLE_TYPE_SINGLELINE; |
| 1157 | } |
Adrian Roos | 777ef56 | 2015-12-01 17:37:14 -0800 | [diff] [blame] | 1158 | |
Selim Cinek | c494e38 | 2017-01-31 16:09:23 -0800 | [diff] [blame] | 1159 | if ((mIsHeadsUp || mHeadsUpAnimatingAway) && mHeadsUpChild != null |
| 1160 | && !mContainingNotification.isOnKeyguard()) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1161 | if (viewHeight <= getViewHeight(VISIBLE_TYPE_HEADSUP) || noExpandedChild) { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1162 | return VISIBLE_TYPE_HEADSUP; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1163 | } else { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1164 | return VISIBLE_TYPE_EXPANDED; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1165 | } |
| 1166 | } else { |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 1167 | if (noExpandedChild || (mContractedChild != null |
| 1168 | && viewHeight <= getViewHeight(VISIBLE_TYPE_CONTRACTED) |
Selim Cinek | 6ac3fa8 | 2016-05-10 17:11:54 -0400 | [diff] [blame] | 1169 | && (!mIsChildInGroup || isGroupExpanded() |
Selim Cinek | e81b82b | 2016-03-04 11:22:28 -0800 | [diff] [blame] | 1170 | || !mContainingNotification.isExpanded(true /* allowOnKeyguard */)))) { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1171 | return VISIBLE_TYPE_CONTRACTED; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1172 | } else { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1173 | return VISIBLE_TYPE_EXPANDED; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1174 | } |
| 1175 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1176 | } |
| 1177 | |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1178 | public boolean isContentExpandable() { |
Selim Cinek | c0ac4af | 2017-03-03 15:13:48 -0800 | [diff] [blame] | 1179 | return mIsContentExpandable; |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1180 | } |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 1181 | |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 1182 | public void setDark(boolean dark, boolean fade, long delay) { |
Selim Cinek | b88b984 | 2016-02-26 09:25:33 -0800 | [diff] [blame] | 1183 | if (mContractedChild == null) { |
Selim Cinek | 0934bd9 | 2016-02-19 12:22:33 -0800 | [diff] [blame] | 1184 | return; |
| 1185 | } |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 1186 | mDark = dark; |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 1187 | selectLayout(!dark && fade /* animate */, false /* force */); |
John Spurlock | e15452b | 2014-08-21 09:44:39 -0400 | [diff] [blame] | 1188 | } |
| 1189 | |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1190 | public void setHeadsUp(boolean headsUp) { |
| 1191 | mIsHeadsUp = headsUp; |
| 1192 | selectLayout(false /* animate */, true /* force */); |
Selim Cinek | 98be3f3 | 2015-12-17 16:39:06 -0800 | [diff] [blame] | 1193 | updateExpandButtons(mExpandable); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1194 | } |
| 1195 | |
Jorim Jaggi | aa92ffb | 2014-09-10 23:29:28 +0200 | [diff] [blame] | 1196 | @Override |
| 1197 | public boolean hasOverlappingRendering() { |
| 1198 | |
| 1199 | // This is not really true, but good enough when fading from the contracted to the expanded |
| 1200 | // layout, and saves us some layers. |
| 1201 | return false; |
| 1202 | } |
Jorim Jaggi | 59ec304 | 2015-06-05 15:18:43 -0700 | [diff] [blame] | 1203 | |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1204 | public void setLegacy(boolean legacy) { |
| 1205 | mLegacy = legacy; |
| 1206 | updateLegacy(); |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 1207 | } |
| 1208 | |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1209 | private void updateLegacy() { |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 1210 | if (mContractedChild != null) { |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1211 | mContractedWrapper.setLegacy(mLegacy); |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 1212 | } |
| 1213 | if (mExpandedChild != null) { |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1214 | mExpandedWrapper.setLegacy(mLegacy); |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 1215 | } |
| 1216 | if (mHeadsUpChild != null) { |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1217 | mHeadsUpWrapper.setLegacy(mLegacy); |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 1218 | } |
Jorim Jaggi | 59ec304 | 2015-06-05 15:18:43 -0700 | [diff] [blame] | 1219 | } |
Selim Cinek | 8d6440d | 2015-10-22 13:00:05 -0700 | [diff] [blame] | 1220 | |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1221 | public void setIsChildInGroup(boolean isChildInGroup) { |
| 1222 | mIsChildInGroup = isChildInGroup; |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 1223 | if (mContractedChild != null) { |
| 1224 | mContractedWrapper.setIsChildInGroup(mIsChildInGroup); |
| 1225 | } |
| 1226 | if (mExpandedChild != null) { |
| 1227 | mExpandedWrapper.setIsChildInGroup(mIsChildInGroup); |
| 1228 | } |
| 1229 | if (mHeadsUpChild != null) { |
| 1230 | mHeadsUpWrapper.setIsChildInGroup(mIsChildInGroup); |
| 1231 | } |
| 1232 | if (mAmbientChild != null) { |
| 1233 | mAmbientWrapper.setIsChildInGroup(mIsChildInGroup); |
| 1234 | } |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 1235 | updateAllSingleLineViews(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1236 | } |
| 1237 | |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 1238 | public void onNotificationUpdated(NotificationEntry entry) { |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1239 | mStatusBarNotification = entry.notification; |
Kevin | d5022f9 | 2018-10-08 18:30:26 -0700 | [diff] [blame] | 1240 | mOnContentViewInactiveListeners.clear(); |
Selim Cinek | 860b6da | 2015-12-16 19:02:19 -0800 | [diff] [blame] | 1241 | mBeforeN = entry.targetSdk < Build.VERSION_CODES.N; |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 1242 | updateAllSingleLineViews(); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 1243 | ExpandableNotificationRow row = entry.getRow(); |
Selim Cinek | 8fc93c9 | 2015-11-23 17:48:07 -0800 | [diff] [blame] | 1244 | if (mContractedChild != null) { |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 1245 | mContractedWrapper.onContentUpdated(row); |
Selim Cinek | 8fc93c9 | 2015-11-23 17:48:07 -0800 | [diff] [blame] | 1246 | } |
| 1247 | if (mExpandedChild != null) { |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 1248 | mExpandedWrapper.onContentUpdated(row); |
Selim Cinek | 8fc93c9 | 2015-11-23 17:48:07 -0800 | [diff] [blame] | 1249 | } |
| 1250 | if (mHeadsUpChild != null) { |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 1251 | mHeadsUpWrapper.onContentUpdated(row); |
Selim Cinek | 8fc93c9 | 2015-11-23 17:48:07 -0800 | [diff] [blame] | 1252 | } |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 1253 | if (mAmbientChild != null) { |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 1254 | mAmbientWrapper.onContentUpdated(row); |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 1255 | } |
Petr Cermak | 7997d7a | 2018-01-18 15:52:10 +0000 | [diff] [blame] | 1256 | applyRemoteInputAndSmartReply(entry); |
linanson | 2bcd403 | 2019-01-14 15:22:04 +0800 | [diff] [blame] | 1257 | applyMediaTransfer(entry); |
Selim Cinek | 1a48bab | 2017-02-17 19:38:40 -0800 | [diff] [blame] | 1258 | updateLegacy(); |
Selim Cinek | 589fd3e | 2016-04-26 18:17:57 -0700 | [diff] [blame] | 1259 | mForceSelectNextLayout = true; |
Selim Cinek | b88b984 | 2016-02-26 09:25:33 -0800 | [diff] [blame] | 1260 | setDark(mDark, false /* animate */, 0 /* delay */); |
Adrian Roos | 4c1fcc8 | 2016-03-31 14:39:39 -0700 | [diff] [blame] | 1261 | mPreviousExpandedRemoteInputIntent = null; |
| 1262 | mPreviousHeadsUpRemoteInputIntent = null; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1263 | } |
| 1264 | |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 1265 | private void updateAllSingleLineViews() { |
| 1266 | updateSingleLineView(); |
| 1267 | updateAmbientSingleLineView(); |
| 1268 | } |
Tony Mak | 638430e | 2018-10-08 19:19:10 +0100 | [diff] [blame] | 1269 | |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1270 | private void updateSingleLineView() { |
| 1271 | if (mIsChildInGroup) { |
Selim Cinek | c5926c3 | 2018-05-15 11:17:07 -0700 | [diff] [blame] | 1272 | boolean isNewView = mSingleLineView == null; |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 1273 | mSingleLineView = mHybridGroupManager.bindFromNotification( |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1274 | mSingleLineView, mStatusBarNotification.getNotification()); |
Selim Cinek | c5926c3 | 2018-05-15 11:17:07 -0700 | [diff] [blame] | 1275 | if (isNewView) { |
| 1276 | updateViewVisibility(mVisibleType, VISIBLE_TYPE_SINGLELINE, |
| 1277 | mSingleLineView, mSingleLineView); |
| 1278 | } |
Selim Cinek | de33a4a | 2016-02-11 16:43:41 -0800 | [diff] [blame] | 1279 | } else if (mSingleLineView != null) { |
| 1280 | removeView(mSingleLineView); |
| 1281 | mSingleLineView = null; |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1282 | } |
| 1283 | } |
| 1284 | |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 1285 | private void updateAmbientSingleLineView() { |
| 1286 | if (mIsChildInGroup) { |
Selim Cinek | c5926c3 | 2018-05-15 11:17:07 -0700 | [diff] [blame] | 1287 | boolean isNewView = mAmbientSingleLineChild == null; |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 1288 | mAmbientSingleLineChild = mHybridGroupManager.bindAmbientFromNotification( |
| 1289 | mAmbientSingleLineChild, mStatusBarNotification.getNotification()); |
Selim Cinek | c5926c3 | 2018-05-15 11:17:07 -0700 | [diff] [blame] | 1290 | if (isNewView) { |
| 1291 | updateViewVisibility(mVisibleType, VISIBLE_TYPE_AMBIENT_SINGLELINE, |
| 1292 | mAmbientSingleLineChild, mAmbientSingleLineChild); |
| 1293 | } |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 1294 | } else if (mAmbientSingleLineChild != null) { |
| 1295 | removeView(mAmbientSingleLineChild); |
| 1296 | mAmbientSingleLineChild = null; |
| 1297 | } |
| 1298 | } |
| 1299 | |
linanson | 2bcd403 | 2019-01-14 15:22:04 +0800 | [diff] [blame] | 1300 | private void applyMediaTransfer(final NotificationEntry entry) { |
| 1301 | View bigContentView = mExpandedChild; |
| 1302 | if (bigContentView == null || !entry.isMediaNotification()) { |
| 1303 | return; |
| 1304 | } |
| 1305 | |
| 1306 | View mediaActionContainer = bigContentView.findViewById( |
| 1307 | com.android.internal.R.id.media_actions); |
| 1308 | if (!(mediaActionContainer instanceof LinearLayout)) { |
| 1309 | return; |
| 1310 | } |
| 1311 | |
| 1312 | mMediaTransferManager.applyMediaTransferView((ViewGroup) mediaActionContainer, |
| 1313 | entry); |
| 1314 | } |
| 1315 | |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 1316 | private void applyRemoteInputAndSmartReply(final NotificationEntry entry) { |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1317 | if (mRemoteInputController == null) { |
| 1318 | return; |
| 1319 | } |
| 1320 | |
Gustav Sennton | 5759f87 | 2019-02-13 17:25:26 +0000 | [diff] [blame] | 1321 | applyRemoteInput(entry, InflatedSmartReplies.hasFreeformRemoteInput(entry)); |
| 1322 | |
| 1323 | if (mExpandedInflatedSmartReplies == null && mHeadsUpInflatedSmartReplies == null) { |
| 1324 | if (DEBUG) { |
| 1325 | Log.d(TAG, "Both expanded, and heads-up InflatedSmartReplies are null, " |
| 1326 | + "don't add smart replies."); |
| 1327 | } |
| 1328 | return; |
| 1329 | } |
| 1330 | // The inflated smart-reply objects for the expanded view and the heads-up view both contain |
| 1331 | // the same SmartRepliesAndActions to avoid discrepancies between the two views. We here |
| 1332 | // reuse that object for our local SmartRepliesAndActions to avoid discrepancies between |
| 1333 | // this class and the InflatedSmartReplies classes. |
| 1334 | SmartRepliesAndActions smartRepliesAndActions = mExpandedInflatedSmartReplies != null |
| 1335 | ? mExpandedInflatedSmartReplies.getSmartRepliesAndActions() |
| 1336 | : mHeadsUpInflatedSmartReplies.getSmartRepliesAndActions(); |
Gustav Sennton | 2d66b51 | 2019-01-31 17:48:17 +0000 | [diff] [blame] | 1337 | if (DEBUG) { |
| 1338 | Log.d(TAG, String.format("Adding suggestions for %s, %d actions, and %d replies.", |
| 1339 | entry.notification.getKey(), |
| 1340 | smartRepliesAndActions.smartActions == null ? 0 : |
| 1341 | smartRepliesAndActions.smartActions.actions.size(), |
| 1342 | smartRepliesAndActions.smartReplies == null ? 0 : |
| 1343 | smartRepliesAndActions.smartReplies.choices.length)); |
| 1344 | } |
Gustav Sennton | eab5368 | 2018-11-01 16:30:23 +0000 | [diff] [blame] | 1345 | applySmartReplyView(smartRepliesAndActions, entry); |
| 1346 | } |
Tony Mak | 638430e | 2018-10-08 19:19:10 +0100 | [diff] [blame] | 1347 | |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 1348 | private void applyRemoteInput(NotificationEntry entry, boolean hasFreeformRemoteInput) { |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1349 | View bigContentView = mExpandedChild; |
| 1350 | if (bigContentView != null) { |
Tony Mak | 638430e | 2018-10-08 19:19:10 +0100 | [diff] [blame] | 1351 | mExpandedRemoteInput = applyRemoteInput(bigContentView, entry, hasFreeformRemoteInput, |
Adrian Roos | 7b9ed0d | 2017-01-24 15:55:18 -0800 | [diff] [blame] | 1352 | mPreviousExpandedRemoteInputIntent, mCachedExpandedRemoteInput, |
| 1353 | mExpandedWrapper); |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 1354 | } else { |
| 1355 | mExpandedRemoteInput = null; |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1356 | } |
Adrian Roos | 7813dd7 | 2016-09-23 17:12:17 -0700 | [diff] [blame] | 1357 | if (mCachedExpandedRemoteInput != null |
| 1358 | && mCachedExpandedRemoteInput != mExpandedRemoteInput) { |
| 1359 | // We had a cached remote input but didn't reuse it. Clean up required. |
| 1360 | mCachedExpandedRemoteInput.dispatchFinishTemporaryDetach(); |
| 1361 | } |
| 1362 | mCachedExpandedRemoteInput = null; |
Adrian Roos | 4c1fcc8 | 2016-03-31 14:39:39 -0700 | [diff] [blame] | 1363 | |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1364 | View headsUpContentView = mHeadsUpChild; |
| 1365 | if (headsUpContentView != null) { |
Tony Mak | 638430e | 2018-10-08 19:19:10 +0100 | [diff] [blame] | 1366 | mHeadsUpRemoteInput = applyRemoteInput( |
| 1367 | headsUpContentView, entry, hasFreeformRemoteInput, |
Adrian Roos | 7b9ed0d | 2017-01-24 15:55:18 -0800 | [diff] [blame] | 1368 | mPreviousHeadsUpRemoteInputIntent, mCachedHeadsUpRemoteInput, mHeadsUpWrapper); |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 1369 | } else { |
| 1370 | mHeadsUpRemoteInput = null; |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1371 | } |
Adrian Roos | 7813dd7 | 2016-09-23 17:12:17 -0700 | [diff] [blame] | 1372 | if (mCachedHeadsUpRemoteInput != null |
| 1373 | && mCachedHeadsUpRemoteInput != mHeadsUpRemoteInput) { |
| 1374 | // We had a cached remote input but didn't reuse it. Clean up required. |
| 1375 | mCachedHeadsUpRemoteInput.dispatchFinishTemporaryDetach(); |
| 1376 | } |
| 1377 | mCachedHeadsUpRemoteInput = null; |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1378 | } |
| 1379 | |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 1380 | private RemoteInputView applyRemoteInput(View view, NotificationEntry entry, |
Adrian Roos | 7813dd7 | 2016-09-23 17:12:17 -0700 | [diff] [blame] | 1381 | boolean hasRemoteInput, PendingIntent existingPendingIntent, |
Adrian Roos | 7b9ed0d | 2017-01-24 15:55:18 -0800 | [diff] [blame] | 1382 | RemoteInputView cachedView, NotificationViewWrapper wrapper) { |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1383 | View actionContainerCandidate = view.findViewById( |
| 1384 | com.android.internal.R.id.actions_container); |
| 1385 | if (actionContainerCandidate instanceof FrameLayout) { |
| 1386 | RemoteInputView existing = (RemoteInputView) |
| 1387 | view.findViewWithTag(RemoteInputView.VIEW_TAG); |
| 1388 | |
| 1389 | if (existing != null) { |
Adrian Roos | 0789ee0 | 2016-06-01 11:34:58 -0700 | [diff] [blame] | 1390 | existing.onNotificationUpdateOrReset(); |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1391 | } |
| 1392 | |
| 1393 | if (existing == null && hasRemoteInput) { |
| 1394 | ViewGroup actionContainer = (FrameLayout) actionContainerCandidate; |
Adrian Roos | 7813dd7 | 2016-09-23 17:12:17 -0700 | [diff] [blame] | 1395 | if (cachedView == null) { |
| 1396 | RemoteInputView riv = RemoteInputView.inflate( |
| 1397 | mContext, actionContainer, entry, mRemoteInputController); |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1398 | |
Adrian Roos | 7813dd7 | 2016-09-23 17:12:17 -0700 | [diff] [blame] | 1399 | riv.setVisibility(View.INVISIBLE); |
| 1400 | actionContainer.addView(riv, new LayoutParams( |
| 1401 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 1402 | ViewGroup.LayoutParams.MATCH_PARENT) |
| 1403 | ); |
| 1404 | existing = riv; |
| 1405 | } else { |
| 1406 | actionContainer.addView(cachedView); |
| 1407 | cachedView.dispatchFinishTemporaryDetach(); |
| 1408 | cachedView.requestFocus(); |
| 1409 | existing = cachedView; |
| 1410 | } |
Adrian Roos | 4ff3b12 | 2016-02-01 12:26:13 -0800 | [diff] [blame] | 1411 | } |
| 1412 | if (hasRemoteInput) { |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1413 | int color = entry.notification.getNotification().color; |
| 1414 | if (color == Notification.COLOR_DEFAULT) { |
| 1415 | color = mContext.getColor(R.color.default_remote_input_background); |
| 1416 | } |
Lucas Dupin | a291d19 | 2018-06-07 13:59:42 -0700 | [diff] [blame] | 1417 | existing.setBackgroundColor(ContrastColorUtil.ensureTextBackgroundColor(color, |
Adrian Roos | 25ea5b8 | 2016-04-27 16:34:35 -0700 | [diff] [blame] | 1418 | mContext.getColor(R.color.remote_input_text_enabled), |
Adrian Roos | 4ff3b12 | 2016-02-01 12:26:13 -0800 | [diff] [blame] | 1419 | mContext.getColor(R.color.remote_input_hint))); |
Adrian Roos | 4c1fcc8 | 2016-03-31 14:39:39 -0700 | [diff] [blame] | 1420 | |
Adrian Roos | 7b9ed0d | 2017-01-24 15:55:18 -0800 | [diff] [blame] | 1421 | existing.setWrapper(wrapper); |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 1422 | existing.setOnVisibilityChangedListener(this::setRemoteInputVisible); |
Adrian Roos | 7b9ed0d | 2017-01-24 15:55:18 -0800 | [diff] [blame] | 1423 | |
Adrian Roos | 4c1fcc8 | 2016-03-31 14:39:39 -0700 | [diff] [blame] | 1424 | if (existingPendingIntent != null || existing.isActive()) { |
| 1425 | // The current action could be gone, or the pending intent no longer valid. |
| 1426 | // If we find a matching action in the new notification, focus, otherwise close. |
| 1427 | Notification.Action[] actions = entry.notification.getNotification().actions; |
| 1428 | if (existingPendingIntent != null) { |
| 1429 | existing.setPendingIntent(existingPendingIntent); |
| 1430 | } |
| 1431 | if (existing.updatePendingIntentFromActions(actions)) { |
| 1432 | if (!existing.isActive()) { |
| 1433 | existing.focus(); |
| 1434 | } |
| 1435 | } else { |
| 1436 | if (existing.isActive()) { |
| 1437 | existing.close(); |
| 1438 | } |
| 1439 | } |
| 1440 | } |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1441 | } |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 1442 | return existing; |
| 1443 | } |
| 1444 | return null; |
| 1445 | } |
| 1446 | |
Gustav Sennton | 5759f87 | 2019-02-13 17:25:26 +0000 | [diff] [blame] | 1447 | private void applySmartReplyView( |
| 1448 | SmartRepliesAndActions smartRepliesAndActions, |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 1449 | NotificationEntry entry) { |
Kenny Guy | 2399110 | 2018-04-05 21:18:38 +0100 | [diff] [blame] | 1450 | if (mExpandedChild != null) { |
Gustav Sennton | 5759f87 | 2019-02-13 17:25:26 +0000 | [diff] [blame] | 1451 | mExpandedSmartReplyView = applySmartReplyView(mExpandedChild, smartRepliesAndActions, |
| 1452 | entry, mExpandedInflatedSmartReplies); |
Gustav Sennton | d25a64d | 2018-12-07 10:58:39 +0000 | [diff] [blame] | 1453 | if (mExpandedSmartReplyView != null) { |
| 1454 | if (smartRepliesAndActions.smartReplies != null |
| 1455 | || smartRepliesAndActions.smartActions != null) { |
| 1456 | int numSmartReplies = smartRepliesAndActions.smartReplies == null |
| 1457 | ? 0 : smartRepliesAndActions.smartReplies.choices.length; |
| 1458 | int numSmartActions = smartRepliesAndActions.smartActions == null |
| 1459 | ? 0 : smartRepliesAndActions.smartActions.actions.size(); |
| 1460 | boolean fromAssistant = smartRepliesAndActions.smartReplies == null |
| 1461 | ? smartRepliesAndActions.smartActions.fromAssistant |
| 1462 | : smartRepliesAndActions.smartReplies.fromAssistant; |
Milo Sredkov | 13d8811 | 2019-02-01 12:23:24 +0000 | [diff] [blame] | 1463 | boolean editBeforeSending = smartRepliesAndActions.smartReplies != null |
| 1464 | && mSmartReplyConstants.getEffectiveEditChoicesBeforeSending( |
| 1465 | smartRepliesAndActions.smartReplies.remoteInput |
| 1466 | .getEditChoicesBeforeSending()); |
| 1467 | |
Gustav Sennton | d25a64d | 2018-12-07 10:58:39 +0000 | [diff] [blame] | 1468 | mSmartReplyController.smartSuggestionsAdded(entry, numSmartReplies, |
Milo Sredkov | 13d8811 | 2019-02-01 12:23:24 +0000 | [diff] [blame] | 1469 | numSmartActions, fromAssistant, editBeforeSending); |
Gustav Sennton | d25a64d | 2018-12-07 10:58:39 +0000 | [diff] [blame] | 1470 | } |
Kenny Guy | 2399110 | 2018-04-05 21:18:38 +0100 | [diff] [blame] | 1471 | } |
| 1472 | } |
Gustav Sennton | 3f3eaff | 2019-01-08 09:39:51 +0000 | [diff] [blame] | 1473 | if (mHeadsUpChild != null && mSmartReplyConstants.getShowInHeadsUp()) { |
Gustav Sennton | 5759f87 | 2019-02-13 17:25:26 +0000 | [diff] [blame] | 1474 | mHeadsUpSmartReplyView = applySmartReplyView(mHeadsUpChild, smartRepliesAndActions, |
| 1475 | entry, mHeadsUpInflatedSmartReplies); |
Gustav Sennton | d0e8453 | 2018-12-03 16:48:36 +0000 | [diff] [blame] | 1476 | } |
Petr Cermak | 7997d7a | 2018-01-18 15:52:10 +0000 | [diff] [blame] | 1477 | } |
| 1478 | |
Gustav Sennton | 5759f87 | 2019-02-13 17:25:26 +0000 | [diff] [blame] | 1479 | @Nullable |
Gustav Sennton | eab5368 | 2018-11-01 16:30:23 +0000 | [diff] [blame] | 1480 | private SmartReplyView applySmartReplyView(View view, |
Gustav Sennton | 5759f87 | 2019-02-13 17:25:26 +0000 | [diff] [blame] | 1481 | SmartRepliesAndActions smartRepliesAndActions, |
| 1482 | NotificationEntry entry, InflatedSmartReplies inflatedSmartReplyView) { |
Petr Cermak | 7997d7a | 2018-01-18 15:52:10 +0000 | [diff] [blame] | 1483 | View smartReplyContainerCandidate = view.findViewById( |
| 1484 | com.android.internal.R.id.smart_reply_container); |
| 1485 | if (!(smartReplyContainerCandidate instanceof LinearLayout)) { |
| 1486 | return null; |
| 1487 | } |
Gustav Sennton | 5759f87 | 2019-02-13 17:25:26 +0000 | [diff] [blame] | 1488 | |
Petr Cermak | 7997d7a | 2018-01-18 15:52:10 +0000 | [diff] [blame] | 1489 | LinearLayout smartReplyContainer = (LinearLayout) smartReplyContainerCandidate; |
Gustav Sennton | b944ce5 | 2019-02-25 18:52:43 +0000 | [diff] [blame] | 1490 | if (!InflatedSmartReplies.shouldShowSmartReplyView(entry, smartRepliesAndActions)) { |
Petr Cermak | 7997d7a | 2018-01-18 15:52:10 +0000 | [diff] [blame] | 1491 | smartReplyContainer.setVisibility(View.GONE); |
| 1492 | return null; |
| 1493 | } |
Gustav Sennton | b944ce5 | 2019-02-25 18:52:43 +0000 | [diff] [blame] | 1494 | |
Petr Cermak | 7997d7a | 2018-01-18 15:52:10 +0000 | [diff] [blame] | 1495 | SmartReplyView smartReplyView = null; |
Gustav Sennton | 5759f87 | 2019-02-13 17:25:26 +0000 | [diff] [blame] | 1496 | if (smartReplyContainer.getChildCount() == 1 |
| 1497 | && smartReplyContainer.getChildAt(0) instanceof SmartReplyView) { |
| 1498 | // If we already have a SmartReplyView - replace it with the newly inflated one. The |
| 1499 | // newly inflated one is connected to the new inflated smart reply/action buttons. |
| 1500 | smartReplyContainer.removeAllViews(); |
| 1501 | } |
| 1502 | if (smartReplyContainer.getChildCount() == 0 |
| 1503 | && inflatedSmartReplyView != null |
| 1504 | && inflatedSmartReplyView.getSmartReplyView() != null) { |
| 1505 | smartReplyView = inflatedSmartReplyView.getSmartReplyView(); |
Petr Cermak | 7997d7a | 2018-01-18 15:52:10 +0000 | [diff] [blame] | 1506 | smartReplyContainer.addView(smartReplyView); |
Petr Cermak | 7997d7a | 2018-01-18 15:52:10 +0000 | [diff] [blame] | 1507 | } |
| 1508 | if (smartReplyView != null) { |
Gustav Sennton | eab5368 | 2018-11-01 16:30:23 +0000 | [diff] [blame] | 1509 | smartReplyView.resetSmartSuggestions(smartReplyContainer); |
Gustav Sennton | 5759f87 | 2019-02-13 17:25:26 +0000 | [diff] [blame] | 1510 | smartReplyView.addPreInflatedButtons( |
| 1511 | inflatedSmartReplyView.getSmartSuggestionButtons()); |
Petr Cermak | 7997d7a | 2018-01-18 15:52:10 +0000 | [diff] [blame] | 1512 | smartReplyContainer.setVisibility(View.VISIBLE); |
| 1513 | } |
| 1514 | return smartReplyView; |
| 1515 | } |
| 1516 | |
Gustav Sennton | 5759f87 | 2019-02-13 17:25:26 +0000 | [diff] [blame] | 1517 | /** |
| 1518 | * Set pre-inflated views necessary to display smart replies and actions in the expanded |
| 1519 | * notification state. |
| 1520 | * |
| 1521 | * @param inflatedSmartReplies the pre-inflated state to add to this view. If null the existing |
| 1522 | * {@link SmartReplyView} related to the expanded notification state is cleared. |
| 1523 | */ |
| 1524 | public void setExpandedInflatedSmartReplies( |
| 1525 | @Nullable InflatedSmartReplies inflatedSmartReplies) { |
| 1526 | mExpandedInflatedSmartReplies = inflatedSmartReplies; |
| 1527 | if (inflatedSmartReplies == null) { |
| 1528 | mExpandedSmartReplyView = null; |
| 1529 | } |
| 1530 | } |
| 1531 | |
| 1532 | /** |
| 1533 | * Set pre-inflated views necessary to display smart replies and actions in the heads-up |
| 1534 | * notification state. |
| 1535 | * |
| 1536 | * @param inflatedSmartReplies the pre-inflated state to add to this view. If null the existing |
| 1537 | * {@link SmartReplyView} related to the heads-up notification state is cleared. |
| 1538 | */ |
| 1539 | public void setHeadsUpInflatedSmartReplies( |
| 1540 | @Nullable InflatedSmartReplies inflatedSmartReplies) { |
| 1541 | mHeadsUpInflatedSmartReplies = inflatedSmartReplies; |
| 1542 | if (inflatedSmartReplies == null) { |
| 1543 | mHeadsUpSmartReplyView = null; |
| 1544 | } |
| 1545 | } |
| 1546 | |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 1547 | public void closeRemoteInput() { |
| 1548 | if (mHeadsUpRemoteInput != null) { |
| 1549 | mHeadsUpRemoteInput.close(); |
| 1550 | } |
| 1551 | if (mExpandedRemoteInput != null) { |
| 1552 | mExpandedRemoteInput.close(); |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1553 | } |
| 1554 | } |
| 1555 | |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 1556 | public void setGroupManager(NotificationGroupManager groupManager) { |
| 1557 | mGroupManager = groupManager; |
| 1558 | } |
Selim Cinek | 65b2e7c | 2015-10-26 14:11:31 -0700 | [diff] [blame] | 1559 | |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1560 | public void setRemoteInputController(RemoteInputController r) { |
| 1561 | mRemoteInputController = r; |
| 1562 | } |
| 1563 | |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 1564 | public void setExpandClickListener(OnClickListener expandClickListener) { |
| 1565 | mExpandClickListener = expandClickListener; |
| 1566 | } |
| 1567 | |
| 1568 | public void updateExpandButtons(boolean expandable) { |
Selim Cinek | 98be3f3 | 2015-12-17 16:39:06 -0800 | [diff] [blame] | 1569 | mExpandable = expandable; |
| 1570 | // if the expanded child has the same height as the collapsed one we hide it. |
Selim Cinek | 8ea2d5f | 2016-04-20 17:10:40 -0700 | [diff] [blame] | 1571 | if (mExpandedChild != null && mExpandedChild.getHeight() != 0) { |
Selim Cinek | 4ca6c63 | 2017-02-23 18:03:37 -0800 | [diff] [blame] | 1572 | if ((!mIsHeadsUp && !mHeadsUpAnimatingAway) |
| 1573 | || mHeadsUpChild == null || mContainingNotification.isOnKeyguard()) { |
Selim Cinek | 9635cf3 | 2017-03-03 16:59:03 -0800 | [diff] [blame] | 1574 | if (mExpandedChild.getHeight() <= mContractedChild.getHeight()) { |
Selim Cinek | 8ea2d5f | 2016-04-20 17:10:40 -0700 | [diff] [blame] | 1575 | expandable = false; |
| 1576 | } |
Selim Cinek | 9635cf3 | 2017-03-03 16:59:03 -0800 | [diff] [blame] | 1577 | } else if (mExpandedChild.getHeight() <= mHeadsUpChild.getHeight()) { |
Selim Cinek | 8ea2d5f | 2016-04-20 17:10:40 -0700 | [diff] [blame] | 1578 | expandable = false; |
| 1579 | } |
Selim Cinek | 98be3f3 | 2015-12-17 16:39:06 -0800 | [diff] [blame] | 1580 | } |
Selim Cinek | 65b2e7c | 2015-10-26 14:11:31 -0700 | [diff] [blame] | 1581 | if (mExpandedChild != null) { |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 1582 | mExpandedWrapper.updateExpandability(expandable, mExpandClickListener); |
Selim Cinek | 65b2e7c | 2015-10-26 14:11:31 -0700 | [diff] [blame] | 1583 | } |
| 1584 | if (mContractedChild != null) { |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 1585 | mContractedWrapper.updateExpandability(expandable, mExpandClickListener); |
Selim Cinek | 65b2e7c | 2015-10-26 14:11:31 -0700 | [diff] [blame] | 1586 | } |
| 1587 | if (mHeadsUpChild != null) { |
Selim Cinek | eaa29ca | 2015-11-23 13:51:13 -0800 | [diff] [blame] | 1588 | mHeadsUpWrapper.updateExpandability(expandable, mExpandClickListener); |
Selim Cinek | 65b2e7c | 2015-10-26 14:11:31 -0700 | [diff] [blame] | 1589 | } |
Selim Cinek | c0ac4af | 2017-03-03 15:13:48 -0800 | [diff] [blame] | 1590 | mIsContentExpandable = expandable; |
Selim Cinek | 65b2e7c | 2015-10-26 14:11:31 -0700 | [diff] [blame] | 1591 | } |
Selim Cinek | ea4bef7 | 2015-12-02 15:51:10 -0800 | [diff] [blame] | 1592 | |
| 1593 | public NotificationHeaderView getNotificationHeader() { |
| 1594 | NotificationHeaderView header = null; |
| 1595 | if (mContractedChild != null) { |
| 1596 | header = mContractedWrapper.getNotificationHeader(); |
| 1597 | } |
| 1598 | if (header == null && mExpandedChild != null) { |
| 1599 | header = mExpandedWrapper.getNotificationHeader(); |
| 1600 | } |
| 1601 | if (header == null && mHeadsUpChild != null) { |
| 1602 | header = mHeadsUpWrapper.getNotificationHeader(); |
| 1603 | } |
Adrian Roos | 0aac04f | 2016-12-08 15:59:29 -0800 | [diff] [blame] | 1604 | if (header == null && mAmbientChild != null) { |
| 1605 | header = mAmbientWrapper.getNotificationHeader(); |
| 1606 | } |
Selim Cinek | ea4bef7 | 2015-12-02 15:51:10 -0800 | [diff] [blame] | 1607 | return header; |
| 1608 | } |
Selim Cinek | fa0a2d3 | 2016-01-14 13:02:21 -0800 | [diff] [blame] | 1609 | |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 1610 | public void showAppOpsIcons(ArraySet<Integer> activeOps) { |
| 1611 | if (mContractedChild != null && mContractedWrapper.getNotificationHeader() != null) { |
| 1612 | mContractedWrapper.getNotificationHeader().showAppOpsIcons(activeOps); |
| 1613 | } |
| 1614 | if (mExpandedChild != null && mExpandedWrapper.getNotificationHeader() != null) { |
| 1615 | mExpandedWrapper.getNotificationHeader().showAppOpsIcons(activeOps); |
| 1616 | } |
| 1617 | if (mHeadsUpChild != null && mHeadsUpWrapper.getNotificationHeader() != null) { |
| 1618 | mHeadsUpWrapper.getNotificationHeader().showAppOpsIcons(activeOps); |
| 1619 | } |
| 1620 | } |
Selim Cinek | b26afa3 | 2017-06-29 10:28:17 +0200 | [diff] [blame] | 1621 | |
Gus Prevas | a322649 | 2018-10-23 11:10:09 -0400 | [diff] [blame] | 1622 | /** Sets whether the notification being displayed audibly alerted the user. */ |
Gus Prevas | 7306b90 | 2018-12-11 10:57:06 -0500 | [diff] [blame] | 1623 | public void setRecentlyAudiblyAlerted(boolean audiblyAlerted) { |
Gus Prevas | a322649 | 2018-10-23 11:10:09 -0400 | [diff] [blame] | 1624 | if (mContractedChild != null && mContractedWrapper.getNotificationHeader() != null) { |
Gus Prevas | 7306b90 | 2018-12-11 10:57:06 -0500 | [diff] [blame] | 1625 | mContractedWrapper.getNotificationHeader().setRecentlyAudiblyAlerted(audiblyAlerted); |
Gus Prevas | a322649 | 2018-10-23 11:10:09 -0400 | [diff] [blame] | 1626 | } |
| 1627 | if (mExpandedChild != null && mExpandedWrapper.getNotificationHeader() != null) { |
Gus Prevas | 7306b90 | 2018-12-11 10:57:06 -0500 | [diff] [blame] | 1628 | mExpandedWrapper.getNotificationHeader().setRecentlyAudiblyAlerted(audiblyAlerted); |
Gus Prevas | a322649 | 2018-10-23 11:10:09 -0400 | [diff] [blame] | 1629 | } |
| 1630 | if (mHeadsUpChild != null && mHeadsUpWrapper.getNotificationHeader() != null) { |
Gus Prevas | 7306b90 | 2018-12-11 10:57:06 -0500 | [diff] [blame] | 1631 | mHeadsUpWrapper.getNotificationHeader().setRecentlyAudiblyAlerted(audiblyAlerted); |
Gus Prevas | a322649 | 2018-10-23 11:10:09 -0400 | [diff] [blame] | 1632 | } |
| 1633 | } |
| 1634 | |
Selim Cinek | b26afa3 | 2017-06-29 10:28:17 +0200 | [diff] [blame] | 1635 | public NotificationHeaderView getContractedNotificationHeader() { |
| 1636 | if (mContractedChild != null) { |
| 1637 | return mContractedWrapper.getNotificationHeader(); |
| 1638 | } |
| 1639 | return null; |
| 1640 | } |
| 1641 | |
Selim Cinek | 34eda5e | 2016-02-18 17:10:43 -0800 | [diff] [blame] | 1642 | public NotificationHeaderView getVisibleNotificationHeader() { |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 1643 | NotificationViewWrapper wrapper = getVisibleWrapper(mVisibleType); |
Selim Cinek | 34eda5e | 2016-02-18 17:10:43 -0800 | [diff] [blame] | 1644 | return wrapper == null ? null : wrapper.getNotificationHeader(); |
| 1645 | } |
| 1646 | |
Selim Cinek | fa0a2d3 | 2016-01-14 13:02:21 -0800 | [diff] [blame] | 1647 | public void setContainingNotification(ExpandableNotificationRow containingNotification) { |
| 1648 | mContainingNotification = containingNotification; |
| 1649 | } |
| 1650 | |
| 1651 | public void requestSelectLayout(boolean needsAnimation) { |
| 1652 | selectLayout(needsAnimation, false); |
| 1653 | } |
Selim Cinek | de33a4a | 2016-02-11 16:43:41 -0800 | [diff] [blame] | 1654 | |
| 1655 | public void reInflateViews() { |
| 1656 | if (mIsChildInGroup && mSingleLineView != null) { |
| 1657 | removeView(mSingleLineView); |
| 1658 | mSingleLineView = null; |
Adrian Roos | 6f6e159 | 2017-05-02 16:22:53 -0700 | [diff] [blame] | 1659 | updateAllSingleLineViews(); |
Selim Cinek | de33a4a | 2016-02-11 16:43:41 -0800 | [diff] [blame] | 1660 | } |
| 1661 | } |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 1662 | |
| 1663 | public void setUserExpanding(boolean userExpanding) { |
| 1664 | mUserExpanding = userExpanding; |
| 1665 | if (userExpanding) { |
| 1666 | mTransformationStartVisibleType = mVisibleType; |
| 1667 | } else { |
| 1668 | mTransformationStartVisibleType = UNDEFINED; |
| 1669 | mVisibleType = calculateVisibleType(); |
| 1670 | updateViewVisibilities(mVisibleType); |
Selim Cinek | c317933 | 2016-03-04 14:44:56 -0800 | [diff] [blame] | 1671 | updateBackgroundColor(false); |
Selim Cinek | 8f2f6a6 | 2016-02-23 19:56:31 -0800 | [diff] [blame] | 1672 | } |
| 1673 | } |
Selim Cinek | c897bd3 | 2016-03-18 17:32:31 -0700 | [diff] [blame] | 1674 | |
| 1675 | /** |
| 1676 | * Set by how much the single line view should be indented. Used when a overflow indicator is |
| 1677 | * present and only during measuring |
| 1678 | */ |
| 1679 | public void setSingleLineWidthIndention(int singleLineWidthIndention) { |
| 1680 | if (singleLineWidthIndention != mSingleLineWidthIndention) { |
| 1681 | mSingleLineWidthIndention = singleLineWidthIndention; |
| 1682 | mContainingNotification.forceLayout(); |
| 1683 | forceLayout(); |
| 1684 | } |
| 1685 | } |
| 1686 | |
| 1687 | public HybridNotificationView getSingleLineView() { |
| 1688 | return mSingleLineView; |
| 1689 | } |
Adrian Roos | d009ab1 | 2016-05-20 17:58:53 -0700 | [diff] [blame] | 1690 | |
| 1691 | public void setRemoved() { |
| 1692 | if (mExpandedRemoteInput != null) { |
| 1693 | mExpandedRemoteInput.setRemoved(); |
| 1694 | } |
| 1695 | if (mHeadsUpRemoteInput != null) { |
| 1696 | mHeadsUpRemoteInput.setRemoved(); |
| 1697 | } |
| 1698 | } |
Adrian Roos | 599be34 | 2016-06-13 14:54:39 -0700 | [diff] [blame] | 1699 | |
| 1700 | public void setContentHeightAnimating(boolean animating) { |
| 1701 | if (!animating) { |
| 1702 | mContentHeightAtAnimationStart = UNDEFINED; |
| 1703 | } |
| 1704 | } |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 1705 | |
Adrian Roos | e18033c | 2017-01-17 15:22:49 -0800 | [diff] [blame] | 1706 | @VisibleForTesting |
| 1707 | boolean isAnimatingVisibleType() { |
| 1708 | return mAnimationStartVisibleType != UNDEFINED; |
| 1709 | } |
| 1710 | |
Selim Cinek | cafa87f | 2016-10-26 17:00:17 -0700 | [diff] [blame] | 1711 | public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) { |
| 1712 | mHeadsUpAnimatingAway = headsUpAnimatingAway; |
Selim Cinek | 73cf02a | 2016-06-17 13:08:00 -0700 | [diff] [blame] | 1713 | selectLayout(false /* animate */, true /* force */); |
| 1714 | } |
| 1715 | |
Selim Cinek | e9bad24 | 2016-06-15 11:46:37 -0700 | [diff] [blame] | 1716 | public void setFocusOnVisibilityChange() { |
| 1717 | mFocusOnVisibilityChange = true; |
| 1718 | } |
Selim Cinek | 0242fbb | 2016-10-19 13:38:32 -0700 | [diff] [blame] | 1719 | |
| 1720 | public void setIconsVisible(boolean iconsVisible) { |
| 1721 | mIconsVisible = iconsVisible; |
| 1722 | updateIconVisibilities(); |
| 1723 | } |
| 1724 | |
| 1725 | private void updateIconVisibilities() { |
| 1726 | if (mContractedWrapper != null) { |
| 1727 | NotificationHeaderView header = mContractedWrapper.getNotificationHeader(); |
| 1728 | if (header != null) { |
| 1729 | header.getIcon().setForceHidden(!mIconsVisible); |
| 1730 | } |
| 1731 | } |
| 1732 | if (mHeadsUpWrapper != null) { |
| 1733 | NotificationHeaderView header = mHeadsUpWrapper.getNotificationHeader(); |
| 1734 | if (header != null) { |
| 1735 | header.getIcon().setForceHidden(!mIconsVisible); |
| 1736 | } |
| 1737 | } |
| 1738 | if (mExpandedWrapper != null) { |
| 1739 | NotificationHeaderView header = mExpandedWrapper.getNotificationHeader(); |
| 1740 | if (header != null) { |
| 1741 | header.getIcon().setForceHidden(!mIconsVisible); |
| 1742 | } |
| 1743 | } |
| 1744 | } |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 1745 | |
Adrian Roos | 4320e89 | 2017-01-24 12:50:34 -0800 | [diff] [blame] | 1746 | @Override |
| 1747 | public void onVisibilityAggregated(boolean isVisible) { |
| 1748 | super.onVisibilityAggregated(isVisible); |
| 1749 | if (isVisible) { |
| 1750 | fireExpandedVisibleListenerIfVisible(); |
| 1751 | } |
| 1752 | } |
| 1753 | |
| 1754 | /** |
| 1755 | * Sets a one-shot listener for when the expanded view becomes visible. |
| 1756 | * |
| 1757 | * This will fire the listener immediately if the expanded view is already visible. |
| 1758 | */ |
| 1759 | public void setOnExpandedVisibleListener(Runnable r) { |
| 1760 | mExpandedVisibleListener = r; |
| 1761 | fireExpandedVisibleListenerIfVisible(); |
| 1762 | } |
| 1763 | |
Kevin | d5022f9 | 2018-10-08 18:30:26 -0700 | [diff] [blame] | 1764 | /** |
| 1765 | * Set a one-shot listener to run when a given content view becomes inactive. |
| 1766 | * |
| 1767 | * @param visibleType visible type corresponding to the content view to listen |
| 1768 | * @param listener runnable to run once when the content view becomes inactive |
| 1769 | */ |
| 1770 | public void performWhenContentInactive(int visibleType, Runnable listener) { |
| 1771 | View view = getViewForVisibleType(visibleType); |
| 1772 | // View is already inactive |
| 1773 | if (view == null || isContentViewInactive(visibleType)) { |
| 1774 | listener.run(); |
| 1775 | return; |
| 1776 | } |
| 1777 | mOnContentViewInactiveListeners.put(view, listener); |
| 1778 | } |
| 1779 | |
| 1780 | /** |
| 1781 | * Whether or not the content view is inactive. This means it should not be visible |
| 1782 | * or the showing content as removing it would cause visual jank. |
| 1783 | * |
| 1784 | * @param visibleType visible type corresponding to the content view to be removed |
| 1785 | * @return true if the content view is inactive, false otherwise |
| 1786 | */ |
| 1787 | public boolean isContentViewInactive(int visibleType) { |
| 1788 | View view = getViewForVisibleType(visibleType); |
| 1789 | return isContentViewInactive(view); |
| 1790 | } |
| 1791 | |
| 1792 | /** |
| 1793 | * Whether or not the content view is inactive. |
| 1794 | * |
| 1795 | * @param view view to see if its inactive |
| 1796 | * @return true if the view is inactive, false o/w |
| 1797 | */ |
| 1798 | private boolean isContentViewInactive(View view) { |
| 1799 | if (view == null) { |
| 1800 | return true; |
| 1801 | } |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 1802 | return !isShown() |
| 1803 | || (view.getVisibility() != VISIBLE && getViewForVisibleType(mVisibleType) != view); |
Kevin | d5022f9 | 2018-10-08 18:30:26 -0700 | [diff] [blame] | 1804 | } |
| 1805 | |
| 1806 | @Override |
| 1807 | protected void onChildVisibilityChanged(View child, int oldVisibility, int newVisibility) { |
| 1808 | super.onChildVisibilityChanged(child, oldVisibility, newVisibility); |
| 1809 | if (isContentViewInactive(child)) { |
| 1810 | Runnable listener = mOnContentViewInactiveListeners.remove(child); |
| 1811 | if (listener != null) { |
| 1812 | listener.run(); |
| 1813 | } |
| 1814 | } |
| 1815 | } |
| 1816 | |
Selim Cinek | 6743c0b | 2017-01-18 18:24:01 -0800 | [diff] [blame] | 1817 | public void setIsLowPriority(boolean isLowPriority) { |
| 1818 | mIsLowPriority = isLowPriority; |
| 1819 | } |
Selim Cinek | 63edaf2 | 2017-04-24 22:18:48 -0700 | [diff] [blame] | 1820 | |
| 1821 | public boolean isDimmable() { |
Kevin | 38ce6fa | 2018-10-17 16:00:14 -0700 | [diff] [blame] | 1822 | return mContractedWrapper != null && mContractedWrapper.isDimmable(); |
Selim Cinek | 63edaf2 | 2017-04-24 22:18:48 -0700 | [diff] [blame] | 1823 | } |
Selim Cinek | 5d6ef8d | 2017-05-18 22:16:00 -0700 | [diff] [blame] | 1824 | |
| 1825 | /** |
| 1826 | * Should a single click be disallowed on this view when on the keyguard? |
| 1827 | */ |
| 1828 | public boolean disallowSingleClick(float x, float y) { |
| 1829 | NotificationViewWrapper visibleWrapper = getVisibleWrapper(getVisibleType()); |
| 1830 | if (visibleWrapper != null) { |
| 1831 | return visibleWrapper.disallowSingleClick(x, y); |
| 1832 | } |
| 1833 | return false; |
| 1834 | } |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 1835 | |
Selim Cinek | 86bfcee | 2018-01-17 11:00:47 -0800 | [diff] [blame] | 1836 | public boolean shouldClipToRounding(boolean topRounded, boolean bottomRounded) { |
| 1837 | boolean needsPaddings = shouldClipToRounding(getVisibleType(), topRounded, bottomRounded); |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 1838 | if (mUserExpanding) { |
Selim Cinek | 86bfcee | 2018-01-17 11:00:47 -0800 | [diff] [blame] | 1839 | needsPaddings |= shouldClipToRounding(mTransformationStartVisibleType, topRounded, |
| 1840 | bottomRounded); |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 1841 | } |
| 1842 | return needsPaddings; |
| 1843 | } |
| 1844 | |
Selim Cinek | 86bfcee | 2018-01-17 11:00:47 -0800 | [diff] [blame] | 1845 | private boolean shouldClipToRounding(int visibleType, boolean topRounded, |
| 1846 | boolean bottomRounded) { |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 1847 | NotificationViewWrapper visibleWrapper = getVisibleWrapper(visibleType); |
| 1848 | if (visibleWrapper == null) { |
| 1849 | return false; |
| 1850 | } |
Selim Cinek | 86bfcee | 2018-01-17 11:00:47 -0800 | [diff] [blame] | 1851 | return visibleWrapper.shouldClipToRounding(topRounded, bottomRounded); |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 1852 | } |
Selim Cinek | de4de0e | 2018-01-24 16:21:07 -0800 | [diff] [blame] | 1853 | |
| 1854 | public CharSequence getActiveRemoteInputText() { |
| 1855 | if (mExpandedRemoteInput != null && mExpandedRemoteInput.isActive()) { |
| 1856 | return mExpandedRemoteInput.getText(); |
| 1857 | } |
| 1858 | if (mHeadsUpRemoteInput != null && mHeadsUpRemoteInput.isActive()) { |
| 1859 | return mHeadsUpRemoteInput.getText(); |
| 1860 | } |
| 1861 | return null; |
| 1862 | } |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 1863 | |
Selim Cinek | a77d2c5 | 2018-04-09 10:44:52 -0700 | [diff] [blame] | 1864 | @Override |
| 1865 | public boolean dispatchTouchEvent(MotionEvent ev) { |
| 1866 | float y = ev.getY(); |
| 1867 | // We still want to distribute touch events to the remote input even if it's outside the |
| 1868 | // view boundary. We're therefore manually dispatching these events to the remote view |
| 1869 | RemoteInputView riv = getRemoteInputForView(getViewForVisibleType(mVisibleType)); |
| 1870 | if (riv != null && riv.getVisibility() == VISIBLE) { |
| 1871 | int inputStart = mUnrestrictedContentHeight - riv.getHeight(); |
| 1872 | if (y <= mUnrestrictedContentHeight && y >= inputStart) { |
| 1873 | ev.offsetLocation(0, -inputStart); |
| 1874 | return riv.dispatchTouchEvent(ev); |
| 1875 | } |
| 1876 | } |
| 1877 | return super.dispatchTouchEvent(ev); |
| 1878 | } |
| 1879 | |
| 1880 | /** |
| 1881 | * Overridden to make sure touches to the reply action bar actually go through to this view |
| 1882 | */ |
| 1883 | @Override |
| 1884 | public boolean pointInView(float localX, float localY, float slop) { |
| 1885 | float top = mClipTopAmount; |
| 1886 | float bottom = mUnrestrictedContentHeight; |
| 1887 | return localX >= -slop && localY >= top - slop && localX < ((mRight - mLeft) + slop) && |
| 1888 | localY < (bottom + slop); |
| 1889 | } |
| 1890 | |
| 1891 | private RemoteInputView getRemoteInputForView(View child) { |
| 1892 | if (child == mExpandedChild) { |
| 1893 | return mExpandedRemoteInput; |
| 1894 | } else if (child == mHeadsUpChild) { |
| 1895 | return mHeadsUpRemoteInput; |
| 1896 | } |
| 1897 | return null; |
| 1898 | } |
| 1899 | |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 1900 | public int getExpandHeight() { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1901 | int viewType = VISIBLE_TYPE_EXPANDED; |
| 1902 | if (mExpandedChild == null) { |
| 1903 | viewType = VISIBLE_TYPE_CONTRACTED; |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 1904 | } |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1905 | return getViewHeight(viewType) + getExtraRemoteInputHeight(mExpandedRemoteInput); |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 1906 | } |
| 1907 | |
| 1908 | public int getHeadsUpHeight() { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1909 | int viewType = VISIBLE_TYPE_HEADSUP; |
| 1910 | if (mHeadsUpChild == null) { |
| 1911 | viewType = VISIBLE_TYPE_CONTRACTED; |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 1912 | } |
Selim Cinek | 09b442e | 2018-05-04 15:46:18 -0700 | [diff] [blame] | 1913 | // The headsUp remote input quickly switches to the expanded one, so lets also include that |
| 1914 | // one |
| 1915 | return getViewHeight(viewType) + getExtraRemoteInputHeight(mHeadsUpRemoteInput) |
| 1916 | + getExtraRemoteInputHeight(mExpandedRemoteInput); |
Selim Cinek | ed64a14 | 2018-02-06 18:06:01 -0800 | [diff] [blame] | 1917 | } |
| 1918 | |
| 1919 | public void setRemoteInputVisible(boolean remoteInputVisible) { |
| 1920 | mRemoteInputVisible = remoteInputVisible; |
| 1921 | setClipChildren(!remoteInputVisible); |
| 1922 | } |
| 1923 | |
| 1924 | @Override |
| 1925 | public void setClipChildren(boolean clipChildren) { |
| 1926 | clipChildren = clipChildren && !mRemoteInputVisible; |
| 1927 | super.setClipChildren(clipChildren); |
| 1928 | } |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1929 | |
| 1930 | public void setHeaderVisibleAmount(float headerVisibleAmount) { |
| 1931 | if (mContractedWrapper != null) { |
| 1932 | mContractedWrapper.setHeaderVisibleAmount(headerVisibleAmount); |
| 1933 | } |
| 1934 | if (mHeadsUpWrapper != null) { |
| 1935 | mHeadsUpWrapper.setHeaderVisibleAmount(headerVisibleAmount); |
| 1936 | } |
| 1937 | if (mExpandedWrapper != null) { |
| 1938 | mExpandedWrapper.setHeaderVisibleAmount(headerVisibleAmount); |
| 1939 | } |
| 1940 | } |
Selim Cinek | 85a8f9f | 2018-11-21 13:58:27 -0800 | [diff] [blame] | 1941 | |
| 1942 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 1943 | pw.print(" "); |
| 1944 | pw.print("contentView visibility: " + getVisibility()); |
| 1945 | pw.print(", alpha: " + getAlpha()); |
| 1946 | pw.print(", clipBounds: " + getClipBounds()); |
| 1947 | pw.print(", contentHeight: " + mContentHeight); |
| 1948 | pw.print(", visibleType: " + mVisibleType); |
| 1949 | View view = getViewForVisibleType(mVisibleType); |
| 1950 | pw.print(", visibleView "); |
| 1951 | if (view != null) { |
| 1952 | pw.print(" visibility: " + view.getVisibility()); |
| 1953 | pw.print(", alpha: " + view.getAlpha()); |
| 1954 | pw.print(", clipBounds: " + view.getClipBounds()); |
| 1955 | } else { |
| 1956 | pw.print("null"); |
| 1957 | } |
| 1958 | pw.println(); |
| 1959 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1960 | } |