ExpandableNotificationRow.java revision b3dadccbc5c7040260a51a3e17efcb74aeec6a11
151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren/*
251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * Copyright (C) 2013 The Android Open Source Project
351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren *
451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * Licensed under the Apache License, Version 2.0 (the "License");
551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * you may not use this file except in compliance with the License.
651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * You may obtain a copy of the License at
751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren *
851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren *      http://www.apache.org/licenses/LICENSE-2.0
951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren *
1051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * Unless required by applicable law or agreed to in writing, software
1151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * distributed under the License is distributed on an "AS IS" BASIS,
1251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * See the License for the specific language governing permissions and
1451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * limitations under the License.
1551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren */
1651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren
1751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wrenpackage com.android.systemui.statusbar;
1851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren
194b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellorimport android.animation.Animator;
204b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellorimport android.animation.AnimatorListenerAdapter;
214b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellorimport android.animation.ObjectAnimator;
224b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellorimport android.animation.ValueAnimator.AnimatorUpdateListener;
23ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinekimport android.annotation.Nullable;
2451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wrenimport android.content.Context;
25cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinekimport android.graphics.drawable.AnimatedVectorDrawable;
26cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinekimport android.graphics.drawable.AnimationDrawable;
27b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport android.graphics.drawable.ColorDrawable;
28cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinekimport android.graphics.drawable.Drawable;
29da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinekimport android.os.Build;
30e9bad242f38bebadae481a22b647cc153f093070Selim Cinekimport android.os.Bundle;
31b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggiimport android.service.notification.StatusBarNotification;
3251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wrenimport android.util.AttributeSet;
33b0a824687f56b6950338aad169d8d837f8ed657bMady Mellorimport android.util.FloatProperty;
34b0a824687f56b6950338aad169d8d837f8ed657bMady Mellorimport android.util.Property;
3501af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinekimport android.view.LayoutInflater;
366183d12926a189b08cc3be8d9c78470617e63db0Selim Cinekimport android.view.MotionEvent;
37eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinekimport android.view.NotificationHeaderView;
38a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandlerimport android.view.View;
39875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinekimport android.view.ViewGroup;
40b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggiimport android.view.ViewStub;
41fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggiimport android.view.accessibility.AccessibilityEvent;
42e9bad242f38bebadae481a22b647cc153f093070Selim Cinekimport android.view.accessibility.AccessibilityNodeInfo;
4398713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinekimport android.widget.Chronometer;
44cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinekimport android.widget.ImageView;
45b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
46698b1706be196de41fc6bf03cf15971c82a11949Chris Wrenimport com.android.internal.logging.MetricsLogger;
47383db5ebcc3a4a615faf249bf4f126f42e80b82eTamas Berghammerimport com.android.internal.logging.nano.MetricsProto.MetricsEvent;
484bb593492ccf560382fac9ae533a7429cec53c94Selim Cinekimport com.android.internal.util.NotificationColorUtil;
49875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinekimport com.android.internal.widget.CachingIconView;
500242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinekimport com.android.systemui.Interpolators;
51a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandlerimport com.android.systemui.R;
520e2ffbd48bbedf47deb7f6aed96bd07e2fc96f53Blazej Magnowskiimport com.android.systemui.classifier.FalsingManager;
53c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinekimport com.android.systemui.statusbar.notification.HybridNotificationView;
54b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport com.android.systemui.statusbar.phone.NotificationGroupManager;
5531aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinekimport com.android.systemui.statusbar.policy.HeadsUpManager;
560cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinekimport com.android.systemui.statusbar.stack.AnimationProperties;
570cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinekimport com.android.systemui.statusbar.stack.ExpandableViewState;
58b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport com.android.systemui.statusbar.stack.NotificationChildrenContainer;
59e9bad242f38bebadae481a22b647cc153f093070Selim Cinekimport com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
60b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport com.android.systemui.statusbar.stack.StackScrollState;
61b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
624b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellorimport java.util.ArrayList;
63b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport java.util.List;
64a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler
654222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggipublic class ExpandableNotificationRow extends ActivatableNotificationView {
66b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
67b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    private static final int DEFAULT_DIVIDER_ALPHA = 0x29;
68b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    private static final int COLORED_DIVIDER_ALPHA = 0x7B;
690242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek    private int mIconTransformContentShift;
70875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek    private int mIconTransformContentShiftNoIcon;
7101af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek    private int mNotificationMinHeightLegacy;
7201af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek    private int mMaxHeadsUpHeightLegacy;
7301af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek    private int mMaxHeadsUpHeight;
7401af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek    private int mNotificationMinHeight;
7501af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek    private int mNotificationMaxHeight;
76b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    private int mIncreasedPaddingBetweenElements;
7751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren
781685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    /** Does this row contain layouts that can adapt to row expansion */
7951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    private boolean mExpandable;
801685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    /** Has the user actively changed the expansion state of this row */
811685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    private boolean mHasUserChangedExpansion;
821685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    /** If {@link #mHasUserChangedExpansion}, has the user expanded this row */
8351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    private boolean mUserExpanded;
8431aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek
8531aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek    /**
8631aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek     * Has this notification been expanded while it was pinned
8731aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek     */
8831aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek    private boolean mExpandedWhenPinned;
891685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    /** Is the user touching this row */
9051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    private boolean mUserLocked;
911685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    /** Are we showing the "public" version */
92a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler    private boolean mShowingPublic;
93ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi    private boolean mSensitive;
943c76d509d362cf5086a63722ab41e04f5d539182Selim Cinek    private boolean mSensitiveHiddenInGeneral;
95ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi    private boolean mShowingPublicInitialized;
9660122be6747c4f79b96f6808158f8f7e7548b7d3Selim Cinek    private boolean mHideSensitiveForIntrinsicHeight;
9751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren
981685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    /**
991685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     * Is this notification expanded by the system. The expansion state can be overridden by the
1001685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     * user expansion.
1011685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     */
1021685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    private boolean mIsSystemExpanded;
103dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi
104dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi    /**
10583bc78338437a460076a4b5778ded38440ac3501Selim Cinek     * Whether the notification is on the keyguard and the expansion is disabled.
106dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi     */
10783bc78338437a460076a4b5778ded38440ac3501Selim Cinek    private boolean mOnKeyguard;
108dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi
109b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    private Animator mTranslateAnim;
1104b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor    private ArrayList<View> mTranslateableViews;
111be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    private NotificationContentView mPublicLayout;
112be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    private NotificationContentView mPrivateLayout;
1131685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    private int mMaxExpandHeight;
1148d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek    private int mHeadsUpHeight;
115863834bd96bdebcf21f4c4a7d8285d4858c061e4Selim Cinek    private View mVetoButton;
1164bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek    private int mNotificationColor;
11778403d79739605511ea88b653564d81d7bf4bbbaChris Wren    private ExpansionLogger mLogger;
11878403d79739605511ea88b653564d81d7bf4bbbaChris Wren    private String mLoggingKey;
1194b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor    private NotificationSettingsIconRow mSettingsIconRow;
1208d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek    private NotificationGuts mGuts;
121da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek    private NotificationData.Entry mEntry;
122b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi    private StatusBarNotification mStatusBarNotification;
1233fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor    private String mAppName;
1241a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek    private boolean mIsHeadsUp;
12598713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek    private boolean mLastChronometerRunning = true;
126b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    private ViewStub mChildrenContainerStub;
127b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    private NotificationGroupManager mGroupManager;
128b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    private boolean mChildrenExpanded;
129263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek    private boolean mIsSummaryWithChildren;
130b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    private NotificationChildrenContainer mChildrenContainer;
1314b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor    private ViewStub mSettingsIconRowStub;
132ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek    private ViewStub mGutsStub;
133b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    private boolean mIsSystemChildExpanded;
134684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek    private boolean mIsPinned;
1350e2ffbd48bbedf47deb7f6aed96bd07e2fc96f53Blazej Magnowski    private FalsingManager mFalsingManager;
13631aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek    private HeadsUpManager mHeadsUpManager;
137b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi
1385eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi    private boolean mJustClicked;
1395a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek    private boolean mIconAnimationRunning;
14034d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek    private boolean mShowNoBackground;
141388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek    private ExpandableNotificationRow mNotificationParent;
142570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek    private OnExpandClickListener mOnExpandClickListener;
143b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    private boolean mGroupExpansionChanging;
144b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor
145eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek    private OnClickListener mExpandClickListener = new OnClickListener() {
146eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek        @Override
147eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek        public void onClick(View v) {
148624c02db7f1d24ec1e307530ff32d4fd5859feaeSelim Cinek            if (!mShowingPublic && mGroupManager.isSummaryOfGroup(mStatusBarNotification)) {
1491a5d8eadd56b435843dfbc1adf3779aa7286081bMady Mellor                mGroupExpansionChanging = true;
150698b1706be196de41fc6bf03cf15971c82a11949Chris Wren                final boolean wasExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification);
151698b1706be196de41fc6bf03cf15971c82a11949Chris Wren                boolean nowExpanded = mGroupManager.toggleGroupExpansion(mStatusBarNotification);
152698b1706be196de41fc6bf03cf15971c82a11949Chris Wren                mOnExpandClickListener.onExpandClicked(mEntry, nowExpanded);
153698b1706be196de41fc6bf03cf15971c82a11949Chris Wren                MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTIFICATION_GROUP_EXPANDER,
154698b1706be196de41fc6bf03cf15971c82a11949Chris Wren                        nowExpanded);
155698b1706be196de41fc6bf03cf15971c82a11949Chris Wren                logExpansionEvent(true /* userAction */, wasExpanded);
156eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek            } else {
157e9bad242f38bebadae481a22b647cc153f093070Selim Cinek                if (v.isAccessibilityFocused()) {
158e9bad242f38bebadae481a22b647cc153f093070Selim Cinek                    mPrivateLayout.setFocusOnVisibilityChange();
159e9bad242f38bebadae481a22b647cc153f093070Selim Cinek                }
16031aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek                boolean nowExpanded;
16131aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek                if (isPinned()) {
16231aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek                    nowExpanded = !mExpandedWhenPinned;
16331aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek                    mExpandedWhenPinned = nowExpanded;
16431aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek                } else {
16531aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek                    nowExpanded = !isExpanded();
16631aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek                    setUserExpanded(nowExpanded);
16731aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek                }
168eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek                notifyHeightChanged(true);
16931aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek                mOnExpandClickListener.onExpandClicked(mEntry, nowExpanded);
170698b1706be196de41fc6bf03cf15971c82a11949Chris Wren                MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTIFICATION_EXPANDER,
171698b1706be196de41fc6bf03cf15971c82a11949Chris Wren                        nowExpanded);
172eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek            }
173eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek        }
174eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek    };
1751b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek    private boolean mForceUnlocked;
1763f19f60d654421eee5b35a92129081f08c977629Selim Cinek    private boolean mDismissed;
1773f19f60d654421eee5b35a92129081f08c977629Selim Cinek    private boolean mKeepInParent;
1783f19f60d654421eee5b35a92129081f08c977629Selim Cinek    private boolean mRemoved;
179b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    private static final Property<ExpandableNotificationRow, Float> TRANSLATE_CONTENT =
180b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            new FloatProperty<ExpandableNotificationRow>("translate") {
181b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                @Override
182b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                public void setValue(ExpandableNotificationRow object, float value) {
183b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                    object.setTranslation(value);
184b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                }
185b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor
186b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                @Override
187b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                public Float get(ExpandableNotificationRow object) {
188b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                    return object.getTranslation();
189b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                }
190b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    };
191ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek    private OnClickListener mOnClickListener;
19273cf02a0783e3857cae21fece9c292abcc9e1409Selim Cinek    private boolean mHeadsupDisappearRunning;
193e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    private View mChildAfterViewWhenDismissed;
194e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    private View mGroupParentWhenDismissed;
195e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    private boolean mRefocusOnDismiss;
1960242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek    private float mIconTransformationAmount;
1970242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek    private boolean mIconsVisible = true;
198d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek    private boolean mAboveShelf;
199875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek    private boolean mIsLastChild;
200b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor
201b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    public boolean isGroupExpansionChanging() {
202b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        if (isChildInGroup()) {
203b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            return mNotificationParent.isGroupExpansionChanging();
204b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        }
205b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        return mGroupExpansionChanging;
206b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    }
207b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor
208b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    public void setGroupExpansionChanging(boolean changing) {
209b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        mGroupExpansionChanging = changing;
210b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    }
2115eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi
212599be34e6e3274e97512f3970a0d6edddedb8eb4Adrian Roos    @Override
213599be34e6e3274e97512f3970a0d6edddedb8eb4Adrian Roos    public void setActualHeightAnimating(boolean animating) {
214599be34e6e3274e97512f3970a0d6edddedb8eb4Adrian Roos        if (mPrivateLayout != null) {
215599be34e6e3274e97512f3970a0d6edddedb8eb4Adrian Roos            mPrivateLayout.setContentHeightAnimating(animating);
216599be34e6e3274e97512f3970a0d6edddedb8eb4Adrian Roos        }
217599be34e6e3274e97512f3970a0d6edddedb8eb4Adrian Roos    }
218599be34e6e3274e97512f3970a0d6edddedb8eb4Adrian Roos
2198d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek    public NotificationContentView getPrivateLayout() {
2208d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek        return mPrivateLayout;
2218d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek    }
2228d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek
2238d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek    public NotificationContentView getPublicLayout() {
2248d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek        return mPublicLayout;
2258d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek    }
2268d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek
227cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek    public void setIconAnimationRunning(boolean running) {
228cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek        setIconAnimationRunning(running, mPublicLayout);
229cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek        setIconAnimationRunning(running, mPrivateLayout);
2305a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek        if (mIsSummaryWithChildren) {
231b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            setIconAnimationRunningForChild(running, mChildrenContainer.getHeaderView());
2325a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek            List<ExpandableNotificationRow> notificationChildren =
2335a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek                    mChildrenContainer.getNotificationChildren();
2345a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek            for (int i = 0; i < notificationChildren.size(); i++) {
2355a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek                ExpandableNotificationRow child = notificationChildren.get(i);
2365a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek                child.setIconAnimationRunning(running);
2375a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek            }
2385a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek        }
2395a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek        mIconAnimationRunning = running;
240cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek    }
241cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek
242cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek    private void setIconAnimationRunning(boolean running, NotificationContentView layout) {
243cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek        if (layout != null) {
244cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek            View contractedChild = layout.getContractedChild();
245cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek            View expandedChild = layout.getExpandedChild();
2468d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek            View headsUpChild = layout.getHeadsUpChild();
247cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek            setIconAnimationRunningForChild(running, contractedChild);
248cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek            setIconAnimationRunningForChild(running, expandedChild);
2498d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek            setIconAnimationRunningForChild(running, headsUpChild);
250cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek        }
251cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek    }
252cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek
253cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek    private void setIconAnimationRunningForChild(boolean running, View child) {
254cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek        if (child != null) {
255cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek            ImageView icon = (ImageView) child.findViewById(com.android.internal.R.id.icon);
256cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek            setIconRunning(icon, running);
257cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek            ImageView rightIcon = (ImageView) child.findViewById(
258cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek                    com.android.internal.R.id.right_icon);
259cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek            setIconRunning(rightIcon, running);
260cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek        }
261cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek    }
262cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek
263cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek    private void setIconRunning(ImageView imageView, boolean running) {
264cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek        if (imageView != null) {
265cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek            Drawable drawable = imageView.getDrawable();
266cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek            if (drawable instanceof AnimationDrawable) {
267cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek                AnimationDrawable animationDrawable = (AnimationDrawable) drawable;
268cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek                if (running) {
269cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek                    animationDrawable.start();
270cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek                } else {
271cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek                    animationDrawable.stop();
272cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek                }
273cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek            } else if (drawable instanceof AnimatedVectorDrawable) {
274cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek                AnimatedVectorDrawable animationDrawable = (AnimatedVectorDrawable) drawable;
275cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek                if (running) {
276cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek                    animationDrawable.start();
277cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek                } else {
278cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek                    animationDrawable.stop();
279cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek                }
280cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek            }
281cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek        }
282cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek    }
283cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek
284da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek    public void onNotificationUpdated(NotificationData.Entry entry) {
285da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek        mEntry = entry;
286da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek        mStatusBarNotification = entry.notification;
287b88b1a1dbde3364cd92d6a69a41ef2d4e2877294Adrian Roos        mPrivateLayout.onNotificationUpdated(entry);
288b88b1a1dbde3364cd92d6a69a41ef2d4e2877294Adrian Roos        mPublicLayout.onNotificationUpdated(entry);
289757d879966fdbff1b67c9ec6fd4b6c75152b991aSelim Cinek        mShowingPublicInitialized = false;
2904bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek        updateNotificationColor();
2918fc93c90839e5d9dd52bca9dd97c198c0fe68af1Selim Cinek        if (mIsSummaryWithChildren) {
292b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            mChildrenContainer.recreateNotificationHeader(mExpandClickListener, mEntry.notification);
293c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek            mChildrenContainer.onNotificationUpdated();
2948fc93c90839e5d9dd52bca9dd97c198c0fe68af1Selim Cinek        }
2955a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek        if (mIconAnimationRunning) {
2965a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek            setIconAnimationRunning(true);
2975a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek        }
298ea4bef7386ca6c6260f292bf006d16a99b93f698Selim Cinek        if (mNotificationParent != null) {
299ea4bef7386ca6c6260f292bf006d16a99b93f698Selim Cinek            mNotificationParent.updateChildrenHeaderAppearance();
300ea4bef7386ca6c6260f292bf006d16a99b93f698Selim Cinek        }
301263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek        onChildrenCountChanged();
302624c02db7f1d24ec1e307530ff32d4fd5859feaeSelim Cinek        // The public layouts expand button is always visible
303624c02db7f1d24ec1e307530ff32d4fd5859feaeSelim Cinek        mPublicLayout.updateExpandButtons(true);
304da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek        updateLimits();
3050242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek        updateIconVisibilities();
306da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek    }
307da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek
308da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek    private void updateLimits() {
309a1744872f4447dd370002a607c32776dffe519f5Selim Cinek        updateLimitsForView(mPrivateLayout);
310a1744872f4447dd370002a607c32776dffe519f5Selim Cinek        updateLimitsForView(mPublicLayout);
311a1744872f4447dd370002a607c32776dffe519f5Selim Cinek    }
312a1744872f4447dd370002a607c32776dffe519f5Selim Cinek
313a1744872f4447dd370002a607c32776dffe519f5Selim Cinek    private void updateLimitsForView(NotificationContentView layout) {
314a1744872f4447dd370002a607c32776dffe519f5Selim Cinek        boolean customView = layout.getContractedChild().getId()
315da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek                != com.android.internal.R.id.status_bar_latest_event_content;
316da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek        boolean beforeN = mEntry.targetSdk < Build.VERSION_CODES.N;
317da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek        int minHeight = customView && beforeN && !mIsSummaryWithChildren ?
318da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek                mNotificationMinHeightLegacy : mNotificationMinHeight;
319a1744872f4447dd370002a607c32776dffe519f5Selim Cinek        boolean headsUpCustom = layout.getHeadsUpChild() != null &&
320a1744872f4447dd370002a607c32776dffe519f5Selim Cinek                layout.getHeadsUpChild().getId()
321a1744872f4447dd370002a607c32776dffe519f5Selim Cinek                        != com.android.internal.R.id.status_bar_latest_event_content;
32277019c72332cb31dd1cb713ea4c66e267e6cbf39Selim Cinek        int headsUpheight = headsUpCustom && beforeN ? mMaxHeadsUpHeightLegacy
32377019c72332cb31dd1cb713ea4c66e267e6cbf39Selim Cinek                : mMaxHeadsUpHeight;
324a1744872f4447dd370002a607c32776dffe519f5Selim Cinek        layout.setHeights(minHeight, headsUpheight, mNotificationMaxHeight);
325b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi    }
326b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi
327b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi    public StatusBarNotification getStatusBarNotification() {
328b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi        return mStatusBarNotification;
329b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi    }
330b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi
331281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek    public NotificationData.Entry getEntry() {
332281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek        return mEntry;
333281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek    }
334281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek
335b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek    public boolean isHeadsUp() {
336b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek        return mIsHeadsUp;
337b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek    }
338b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek
3391a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek    public void setHeadsUp(boolean isHeadsUp) {
340c80fdb11f55f4c1f3ca9b5cdc7035afa2a0b9e91Selim Cinek        int intrinsicBefore = getIntrinsicHeight();
3411a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek        mIsHeadsUp = isHeadsUp;
3428d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek        mPrivateLayout.setHeadsUp(isHeadsUp);
343b41b2f6fc2bcce6da6d6ae855a2a36cfa6f7f99dSelim Cinek        if (mIsSummaryWithChildren) {
344b41b2f6fc2bcce6da6d6ae855a2a36cfa6f7f99dSelim Cinek            // The overflow might change since we allow more lines as HUN.
345b41b2f6fc2bcce6da6d6ae855a2a36cfa6f7f99dSelim Cinek            mChildrenContainer.updateGroupOverflow();
346b41b2f6fc2bcce6da6d6ae855a2a36cfa6f7f99dSelim Cinek        }
347c80fdb11f55f4c1f3ca9b5cdc7035afa2a0b9e91Selim Cinek        if (intrinsicBefore != getIntrinsicHeight()) {
348c80fdb11f55f4c1f3ca9b5cdc7035afa2a0b9e91Selim Cinek            notifyHeightChanged(false  /* needsAnimation */);
349c80fdb11f55f4c1f3ca9b5cdc7035afa2a0b9e91Selim Cinek        }
350d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek        if (isHeadsUp) {
351d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek            setAboveShelf(true);
352d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek        }
3531a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek    }
3541a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek
355b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public void setGroupManager(NotificationGroupManager groupManager) {
356b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        mGroupManager = groupManager;
35783bc78338437a460076a4b5778ded38440ac3501Selim Cinek        mPrivateLayout.setGroupManager(groupManager);
358b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
359b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
360b88b1a1dbde3364cd92d6a69a41ef2d4e2877294Adrian Roos    public void setRemoteInputController(RemoteInputController r) {
361b88b1a1dbde3364cd92d6a69a41ef2d4e2877294Adrian Roos        mPrivateLayout.setRemoteInputController(r);
362b88b1a1dbde3364cd92d6a69a41ef2d4e2877294Adrian Roos    }
363b88b1a1dbde3364cd92d6a69a41ef2d4e2877294Adrian Roos
3643fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor    public void setAppName(String appName) {
3653fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor        mAppName = appName;
3663fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor        if (mSettingsIconRow != null) {
3673fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor            mSettingsIconRow.setAppName(mAppName);
3683fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor        }
3693fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor    }
3703fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor
371b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public void addChildNotification(ExpandableNotificationRow row) {
372b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        addChildNotification(row, -1);
373b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
374b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
375b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    /**
376b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek     * Add a child notification to this view.
377b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek     *
378b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek     * @param row the row to add
379b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek     * @param childIndex the index to add it at, if -1 it will be added at the end
380b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek     */
381b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public void addChildNotification(ExpandableNotificationRow row, int childIndex) {
382b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        if (mChildrenContainer == null) {
383b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            mChildrenContainerStub.inflate();
384b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        }
385b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        mChildrenContainer.addNotification(row, childIndex);
386263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek        onChildrenCountChanged();
387263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek        row.setIsChildInGroup(true, this);
388b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
389b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
390b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public void removeChildNotification(ExpandableNotificationRow row) {
391b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        if (mChildrenContainer != null) {
392b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            mChildrenContainer.removeNotification(row);
393b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        }
394263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek        onChildrenCountChanged();
395263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek        row.setIsChildInGroup(false, null);
396263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek    }
397263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek
398263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek    public boolean isChildInGroup() {
399a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek        return mNotificationParent != null;
400263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek    }
401263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek
402388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek    public ExpandableNotificationRow getNotificationParent() {
403388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek        return mNotificationParent;
404388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek    }
405388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek
406263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek    /**
407263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek     * @param isChildInGroup Is this notification now in a group
408263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek     * @param parent the new parent notification
409263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek     */
410a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek    public void setIsChildInGroup(boolean isChildInGroup, ExpandableNotificationRow parent) {;
411a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek        boolean childInGroup = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS && isChildInGroup;
412a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek        mNotificationParent = childInGroup ? parent : null;
413a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek        mPrivateLayout.setIsChildInGroup(childInGroup);
414c7d65b4e9c784a8235424c30620bacd54cc0892eMady Mellor        resetBackgroundAlpha();
415b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        updateBackgroundForGroupState();
416ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek        updateClickAndFocus();
417b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        if (mNotificationParent != null) {
418b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            mNotificationParent.updateBackgroundForGroupState();
419b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        }
420db16737031091160a3a7d080ac44ce2836402d74Selim Cinek        updateIconVisibilities();
42134d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek    }
42234d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek
42334d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek    @Override
4247210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek    public boolean onTouchEvent(MotionEvent event) {
4257210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek        if (event.getActionMasked() != MotionEvent.ACTION_DOWN
4267210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek                || !isChildInGroup() || isGroupExpanded()) {
4277210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek            return super.onTouchEvent(event);
4287210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek        } else {
4297210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek            return false;
4307210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek        }
4317210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek    }
4327210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek
4337210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek    @Override
434f062580d395a8c99631c104d6aec250f961152ddMady Mellor    protected boolean handleSlideBack() {
435f062580d395a8c99631c104d6aec250f961152ddMady Mellor        if (mSettingsIconRow != null && mSettingsIconRow.isVisible()) {
436f062580d395a8c99631c104d6aec250f961152ddMady Mellor            animateTranslateNotification(0 /* targetLeft */);
437f062580d395a8c99631c104d6aec250f961152ddMady Mellor            return true;
438f062580d395a8c99631c104d6aec250f961152ddMady Mellor        }
439f062580d395a8c99631c104d6aec250f961152ddMady Mellor        return false;
440f062580d395a8c99631c104d6aec250f961152ddMady Mellor    }
441f062580d395a8c99631c104d6aec250f961152ddMady Mellor
442f062580d395a8c99631c104d6aec250f961152ddMady Mellor    @Override
44334d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek    protected boolean shouldHideBackground() {
44434d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek        return super.shouldHideBackground() || mShowNoBackground;
445263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek    }
446263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek
447263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek    @Override
448263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek    public boolean isSummaryWithChildren() {
449263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek        return mIsSummaryWithChildren;
450b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
451b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
452b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    @Override
453b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public boolean areChildrenExpanded() {
454b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        return mChildrenExpanded;
455b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
456b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
457b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public List<ExpandableNotificationRow> getNotificationChildren() {
458b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        return mChildrenContainer == null ? null : mChildrenContainer.getNotificationChildren();
459b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
460b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
461eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek    public int getNumberOfNotificationChildren() {
462eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek        if (mChildrenContainer == null) {
463eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek            return 0;
464eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek        }
465eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek        return mChildrenContainer.getNotificationChildren().size();
466eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek    }
467eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek
468b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    /**
469b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek     * Apply the order given in the list to the children.
470b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek     *
471b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek     * @param childOrder the new list order
472b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek     * @return whether the list order has changed
473b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek     */
474b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public boolean applyChildOrder(List<ExpandableNotificationRow> childOrder) {
475b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        return mChildrenContainer != null && mChildrenContainer.applyChildOrder(childOrder);
476b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
477b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
478b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public void getChildrenStates(StackScrollState resultState) {
47983bc78338437a460076a4b5778ded38440ac3501Selim Cinek        if (mIsSummaryWithChildren) {
480bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek            ExpandableViewState parentState = resultState.getViewStateForView(this);
481b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            mChildrenContainer.getState(resultState, parentState);
482b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        }
483b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
484b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
485b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public void applyChildrenState(StackScrollState state) {
48683bc78338437a460076a4b5778ded38440ac3501Selim Cinek        if (mIsSummaryWithChildren) {
487b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            mChildrenContainer.applyState(state);
488b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        }
489b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
490b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
491b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public void prepareExpansionChanged(StackScrollState state) {
49283bc78338437a460076a4b5778ded38440ac3501Selim Cinek        if (mIsSummaryWithChildren) {
493b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            mChildrenContainer.prepareExpansionChanged(state);
494b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        }
495b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
496b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
4970cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek    public void startChildAnimation(StackScrollState finalState, AnimationProperties properties) {
49883bc78338437a460076a4b5778ded38440ac3501Selim Cinek        if (mIsSummaryWithChildren) {
4990cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek            mChildrenContainer.startAnimationToState(finalState, properties);
500b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        }
501b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
502b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
503b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public ExpandableNotificationRow getViewAtPosition(float y) {
50443d30f03f45f3f9ad3955f5c83f4d21f26891de6Selim Cinek        if (!mIsSummaryWithChildren || !mChildrenExpanded) {
505b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            return this;
506b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        } else {
507b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            ExpandableNotificationRow view = mChildrenContainer.getViewAtPosition(y);
508b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            return view == null ? this : view;
509b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        }
510b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
511b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
512ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek    public NotificationGuts getGuts() {
513ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek        return mGuts;
514ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek    }
515ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek
516684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek    /**
517684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek     * Set this notification to be pinned to the top if {@link #isHeadsUp()} is true. By doing this
518684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek     * the notification will be rendered on top of the screen.
519684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek     *
520684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek     * @param pinned whether it is pinned
521684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek     */
522684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek    public void setPinned(boolean pinned) {
523def35a86530200958384191d43d321dbcda16e2aSelim Cinek        int intrinsicHeight = getIntrinsicHeight();
524684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek        mIsPinned = pinned;
525def35a86530200958384191d43d321dbcda16e2aSelim Cinek        if (intrinsicHeight != getIntrinsicHeight()) {
526bb42b7dd4892a8ab99f2f702cad931235d1d463eSelim Cinek            notifyHeightChanged(false /* needsAnimation */);
527def35a86530200958384191d43d321dbcda16e2aSelim Cinek        }
52831aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek        if (pinned) {
52931aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek            setIconAnimationRunning(true);
53031aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek            mExpandedWhenPinned = false;
53131aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek        } else if (mExpandedWhenPinned) {
53231aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek            setUserExpanded(true);
53331aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek        }
53498713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek        setChronometerRunning(mLastChronometerRunning);
535b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek    }
536b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek
537684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek    public boolean isPinned() {
538684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek        return mIsPinned;
539b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek    }
540b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek
541d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek    @Override
542d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek    public int getPinnedHeadsUpHeight() {
543d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek        return getPinnedHeadsUpHeight(true /* atLeastMinHeight */);
544d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek    }
545d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek
54631aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek    /**
54731aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek     * @param atLeastMinHeight should the value returned be at least the minimum height.
54831aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek     *                         Used to avoid cyclic calls
54931aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek     * @return the height of the heads up notification when pinned
55031aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek     */
551d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek    private int getPinnedHeadsUpHeight(boolean atLeastMinHeight) {
55277019c72332cb31dd1cb713ea4c66e267e6cbf39Selim Cinek        if (mIsSummaryWithChildren) {
55377019c72332cb31dd1cb713ea4c66e267e6cbf39Selim Cinek            return mChildrenContainer.getIntrinsicHeight();
55477019c72332cb31dd1cb713ea4c66e267e6cbf39Selim Cinek        }
55531aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek        if(mExpandedWhenPinned) {
55631aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek            return Math.max(getMaxExpandHeight(), mHeadsUpHeight);
55731aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek        } else if (atLeastMinHeight) {
558567e845d99840a6e556595739a15e16132eb2f1eSelim Cinek            return Math.max(getCollapsedHeight(), mHeadsUpHeight);
55931aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek        } else {
56031aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek            return mHeadsUpHeight;
56131aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek        }
562b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek    }
563b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek
5645eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi    /**
5655eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi     * Mark whether this notification was just clicked, i.e. the user has just clicked this
5665eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi     * notification in this frame.
5675eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi     */
5685eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi    public void setJustClicked(boolean justClicked) {
5695eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi        mJustClicked = justClicked;
5705eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi    }
5715eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi
5725eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi    /**
5735eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi     * @return true if this notification has been clicked in this frame, false otherwise
5745eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi     */
5755eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi    public boolean wasJustClicked() {
5765eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi        return mJustClicked;
5775eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi    }
5785eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi
57998713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek    public void setChronometerRunning(boolean running) {
58098713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek        mLastChronometerRunning = running;
58198713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek        setChronometerRunning(running, mPrivateLayout);
58298713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek        setChronometerRunning(running, mPublicLayout);
58398713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek        if (mChildrenContainer != null) {
58498713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek            List<ExpandableNotificationRow> notificationChildren =
58598713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek                    mChildrenContainer.getNotificationChildren();
58698713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek            for (int i = 0; i < notificationChildren.size(); i++) {
58798713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek                ExpandableNotificationRow child = notificationChildren.get(i);
58898713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek                child.setChronometerRunning(running);
58998713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek            }
59098713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek        }
59198713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek    }
59298713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek
59398713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek    private void setChronometerRunning(boolean running, NotificationContentView layout) {
59498713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek        if (layout != null) {
59598713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek            running = running || isPinned();
59698713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek            View contractedChild = layout.getContractedChild();
59798713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek            View expandedChild = layout.getExpandedChild();
59898713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek            View headsUpChild = layout.getHeadsUpChild();
59998713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek            setChronometerRunningForChild(running, contractedChild);
60098713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek            setChronometerRunningForChild(running, expandedChild);
60198713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek            setChronometerRunningForChild(running, headsUpChild);
60298713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek        }
60398713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek    }
60498713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek
60598713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek    private void setChronometerRunningForChild(boolean running, View child) {
60698713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek        if (child != null) {
60798713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek            View chronometer = child.findViewById(com.android.internal.R.id.chronometer);
60898713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek            if (chronometer instanceof Chronometer) {
60998713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek                ((Chronometer) chronometer).setStarted(running);
61098713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek            }
61198713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek        }
61298713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek    }
61398713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek
614ea4bef7386ca6c6260f292bf006d16a99b93f698Selim Cinek    public NotificationHeaderView getNotificationHeader() {
615b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        if (mIsSummaryWithChildren) {
616b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            return mChildrenContainer.getHeaderView();
6178d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek        }
618ea4bef7386ca6c6260f292bf006d16a99b93f698Selim Cinek        return mPrivateLayout.getNotificationHeader();
6198d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek    }
6208d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek
62134eda5ed70863320e41b6860a550ba6a4248c652Selim Cinek    private NotificationHeaderView getVisibleNotificationHeader() {
622aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek        if (mIsSummaryWithChildren && !mShowingPublic) {
623b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            return mChildrenContainer.getHeaderView();
62434eda5ed70863320e41b6860a550ba6a4248c652Selim Cinek        }
62534eda5ed70863320e41b6860a550ba6a4248c652Selim Cinek        return getShowingLayout().getVisibleNotificationHeader();
62634eda5ed70863320e41b6860a550ba6a4248c652Selim Cinek    }
62734eda5ed70863320e41b6860a550ba6a4248c652Selim Cinek
628570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek    public void setOnExpandClickListener(OnExpandClickListener onExpandClickListener) {
629570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek        mOnExpandClickListener = onExpandClickListener;
630570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek    }
631570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek
632ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek    @Override
633ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek    public void setOnClickListener(@Nullable OnClickListener l) {
634ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek        super.setOnClickListener(l);
635ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek        mOnClickListener = l;
636ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek        updateClickAndFocus();
637ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek    }
638ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek
639ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek    private void updateClickAndFocus() {
640ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek        boolean normalChild = !isChildInGroup() || isGroupExpanded();
641ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek        boolean clickable = mOnClickListener != null && normalChild;
642ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek        if (isFocusable() != normalChild) {
643ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek            setFocusable(normalChild);
644ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek        }
645ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek        if (isClickable() != clickable) {
646ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek            setClickable(clickable);
647ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek        }
648ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek    }
649ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek
65031aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek    public void setHeadsUpManager(HeadsUpManager headsUpManager) {
65131aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek        mHeadsUpManager = headsUpManager;
65231aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek    }
65331aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek
65401af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek    public void reInflateViews() {
65501af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek        initDimens();
65601af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek        if (mIsSummaryWithChildren) {
65701af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek            if (mChildrenContainer != null) {
658b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                mChildrenContainer.reInflateViews(mExpandClickListener, mEntry.notification);
65901af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek            }
66001af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek        }
66101af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek        if (mGuts != null) {
66201af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek            View oldGuts = mGuts;
66301af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek            int index = indexOfChild(oldGuts);
66401af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek            removeView(oldGuts);
66501af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek            mGuts = (NotificationGuts) LayoutInflater.from(mContext).inflate(
66601af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek                    R.layout.notification_guts, this, false);
66701af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek            mGuts.setVisibility(oldGuts.getVisibility());
66801af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek            addView(mGuts, index);
66901af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek        }
6704b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        if (mSettingsIconRow != null) {
6714b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            View oldSettings = mSettingsIconRow;
6724b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            int settingsIndex = indexOfChild(oldSettings);
6734b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            removeView(oldSettings);
6744b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            mSettingsIconRow = (NotificationSettingsIconRow) LayoutInflater.from(mContext).inflate(
6754b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor                    R.layout.notification_settings_icon_row, this, false);
6764b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            mSettingsIconRow.setNotificationRowParent(ExpandableNotificationRow.this);
6773fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor            mSettingsIconRow.setAppName(mAppName);
6784b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            mSettingsIconRow.setVisibility(oldSettings.getVisibility());
6794b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            addView(mSettingsIconRow, settingsIndex);
6804b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor
6814b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        }
682de33a4ad5696173942dca363339027c892927e8dSelim Cinek        mPrivateLayout.reInflateViews();
683de33a4ad5696173942dca363339027c892927e8dSelim Cinek        mPublicLayout.reInflateViews();
68401af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek    }
68501af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek
686c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek    public void setContentBackground(int customBackgroundColor, boolean animate,
687c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek            NotificationContentView notificationContentView) {
688c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek        if (getShowingLayout() == notificationContentView) {
689c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek            setTintColor(customBackgroundColor, animate);
690c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek        }
691c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek    }
692c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek
6930bd8a4b29bf92a901855d889c53186383dd2c5e7Adrian Roos    public void closeRemoteInput() {
6940bd8a4b29bf92a901855d889c53186383dd2c5e7Adrian Roos        mPrivateLayout.closeRemoteInput();
6950bd8a4b29bf92a901855d889c53186383dd2c5e7Adrian Roos        mPublicLayout.closeRemoteInput();
6960bd8a4b29bf92a901855d889c53186383dd2c5e7Adrian Roos    }
6970bd8a4b29bf92a901855d889c53186383dd2c5e7Adrian Roos
698c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek    /**
699c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek     * Set by how much the single line view should be indented.
700c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek     */
701c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek    public void setSingleLineWidthIndention(int indention) {
702c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek        mPrivateLayout.setSingleLineWidthIndention(indention);
703c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek    }
704c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek
705c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek    public int getNotificationColor() {
7064bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek        return mNotificationColor;
7074bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek    }
7084bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek
7094bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek    private void updateNotificationColor() {
7104bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek        mNotificationColor = NotificationColorUtil.resolveContrastColor(mContext,
7114bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek                getStatusBarNotification().getNotification().color);
712c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek    }
713c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek
714c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek    public HybridNotificationView getSingleLineView() {
715c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek        return mPrivateLayout.getSingleLineView();
716c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek    }
717c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek
718f07d06212b08939809aa4128f153bd5179f81fc7Selim Cinek    public boolean isOnKeyguard() {
719f07d06212b08939809aa4128f153bd5179f81fc7Selim Cinek        return mOnKeyguard;
720f07d06212b08939809aa4128f153bd5179f81fc7Selim Cinek    }
721f07d06212b08939809aa4128f153bd5179f81fc7Selim Cinek
722c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek    public void removeAllChildren() {
723c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek        List<ExpandableNotificationRow> notificationChildren
724c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek                = mChildrenContainer.getNotificationChildren();
725c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek        ArrayList<ExpandableNotificationRow> clonedList = new ArrayList<>(notificationChildren);
726c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek        for (int i = 0; i < clonedList.size(); i++) {
727c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek            ExpandableNotificationRow row = clonedList.get(i);
7283f19f60d654421eee5b35a92129081f08c977629Selim Cinek            if (row.keepInParent()) {
7293f19f60d654421eee5b35a92129081f08c977629Selim Cinek                continue;
7303f19f60d654421eee5b35a92129081f08c977629Selim Cinek            }
731c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek            mChildrenContainer.removeNotification(row);
732c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek            row.setIsChildInGroup(false, null);
733c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek        }
734c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek        onChildrenCountChanged();
735c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek    }
736c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek
7371b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek    public void setForceUnlocked(boolean forceUnlocked) {
7381b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek        mForceUnlocked = forceUnlocked;
7391b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek        if (mIsSummaryWithChildren) {
7401b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek            List<ExpandableNotificationRow> notificationChildren = getNotificationChildren();
7411b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek            for (ExpandableNotificationRow child : notificationChildren) {
7421b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek                child.setForceUnlocked(forceUnlocked);
7431b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek            }
7441b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek        }
7451b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek    }
7461b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek
747e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    public void setDismissed(boolean dismissed, boolean fromAccessibility) {
7483f19f60d654421eee5b35a92129081f08c977629Selim Cinek        mDismissed = dismissed;
749e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        mGroupParentWhenDismissed = mNotificationParent;
750e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        mRefocusOnDismiss = fromAccessibility;
751e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        mChildAfterViewWhenDismissed = null;
752e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        if (isChildInGroup()) {
753e9bad242f38bebadae481a22b647cc153f093070Selim Cinek            List<ExpandableNotificationRow> notificationChildren =
754e9bad242f38bebadae481a22b647cc153f093070Selim Cinek                    mNotificationParent.getNotificationChildren();
755e9bad242f38bebadae481a22b647cc153f093070Selim Cinek            int i = notificationChildren.indexOf(this);
756e9bad242f38bebadae481a22b647cc153f093070Selim Cinek            if (i != -1 && i < notificationChildren.size() - 1) {
757e9bad242f38bebadae481a22b647cc153f093070Selim Cinek                mChildAfterViewWhenDismissed = notificationChildren.get(i + 1);
758e9bad242f38bebadae481a22b647cc153f093070Selim Cinek            }
759e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        }
7603f19f60d654421eee5b35a92129081f08c977629Selim Cinek    }
7613f19f60d654421eee5b35a92129081f08c977629Selim Cinek
7623f19f60d654421eee5b35a92129081f08c977629Selim Cinek    public boolean isDismissed() {
7633f19f60d654421eee5b35a92129081f08c977629Selim Cinek        return mDismissed;
7643f19f60d654421eee5b35a92129081f08c977629Selim Cinek    }
7653f19f60d654421eee5b35a92129081f08c977629Selim Cinek
7663f19f60d654421eee5b35a92129081f08c977629Selim Cinek    public boolean keepInParent() {
7673f19f60d654421eee5b35a92129081f08c977629Selim Cinek        return mKeepInParent;
7683f19f60d654421eee5b35a92129081f08c977629Selim Cinek    }
7693f19f60d654421eee5b35a92129081f08c977629Selim Cinek
7703f19f60d654421eee5b35a92129081f08c977629Selim Cinek    public void setKeepInParent(boolean keepInParent) {
7713f19f60d654421eee5b35a92129081f08c977629Selim Cinek        mKeepInParent = keepInParent;
7723f19f60d654421eee5b35a92129081f08c977629Selim Cinek    }
7733f19f60d654421eee5b35a92129081f08c977629Selim Cinek
7743f19f60d654421eee5b35a92129081f08c977629Selim Cinek    public boolean isRemoved() {
7753f19f60d654421eee5b35a92129081f08c977629Selim Cinek        return mRemoved;
7763f19f60d654421eee5b35a92129081f08c977629Selim Cinek    }
7773f19f60d654421eee5b35a92129081f08c977629Selim Cinek
778d009ab1e2a57648cac9de93912964e2a36ae1762Adrian Roos    public void setRemoved() {
779d009ab1e2a57648cac9de93912964e2a36ae1762Adrian Roos        mRemoved = true;
780d009ab1e2a57648cac9de93912964e2a36ae1762Adrian Roos
781d009ab1e2a57648cac9de93912964e2a36ae1762Adrian Roos        mPrivateLayout.setRemoved();
7823f19f60d654421eee5b35a92129081f08c977629Selim Cinek    }
7833f19f60d654421eee5b35a92129081f08c977629Selim Cinek
784d13956475e97da9de83f6519eab514770118e7afSelim Cinek    public NotificationChildrenContainer getChildrenContainer() {
785d13956475e97da9de83f6519eab514770118e7afSelim Cinek        return mChildrenContainer;
786d13956475e97da9de83f6519eab514770118e7afSelim Cinek    }
787d13956475e97da9de83f6519eab514770118e7afSelim Cinek
788cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek    public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
789cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek        mHeadsupDisappearRunning = headsUpAnimatingAway;
790cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek        mPrivateLayout.setHeadsUpAnimatingAway(headsUpAnimatingAway);
791cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek    }
792cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek
793cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek    /**
794cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek     * @return if the view was just heads upped and is now animating away. During such a time the
795cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek     * layout needs to be kept consistent
796cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek     */
797cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek    public boolean isHeadsUpAnimatingAway() {
798cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek        return mHeadsupDisappearRunning;
79973cf02a0783e3857cae21fece9c292abcc9e1409Selim Cinek    }
80073cf02a0783e3857cae21fece9c292abcc9e1409Selim Cinek
801e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    public View getChildAfterViewWhenDismissed() {
802e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        return mChildAfterViewWhenDismissed;
803e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    }
804e9bad242f38bebadae481a22b647cc153f093070Selim Cinek
805e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    public View getGroupParentWhenDismissed() {
806e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        return mGroupParentWhenDismissed;
807e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    }
808e9bad242f38bebadae481a22b647cc153f093070Selim Cinek
8099e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek    public void performDismiss() {
8109e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek        mVetoButton.performClick();
8119e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek    }
8129e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek
8139e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek    public void setOnDismissListener(OnClickListener listener) {
8149e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek        mVetoButton.setOnClickListener(listener);
8159e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek    }
8169e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek
817281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek    public View getNotificationIcon() {
818281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek        NotificationHeaderView notificationHeader = getNotificationHeader();
819281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek        if (notificationHeader != null) {
820281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek            return notificationHeader.getIcon();
821281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek        }
822281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek        return null;
823281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek    }
824281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek
825281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek    /**
826281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek     * @return whether the notification is currently showing a view with an icon.
827281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek     */
828281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek    public boolean isShowingIcon() {
829281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek        if (mIsSummaryWithChildren) {
830281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek            return true;
831281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek        }
832281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek        NotificationContentView showingLayout = getShowingLayout();
833281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek        NotificationHeaderView notificationHeader = showingLayout.getVisibleNotificationHeader();
834281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek        return notificationHeader != null;
835281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek    }
836281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek
8370242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek    /**
8380242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek     * Set how much this notification is transformed into an icon.
8390242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek     *
8400242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek     * @param iconTransformationAmount A value from 0 to 1 indicating how much we are transformed
8410242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek     *                                 to an icon
842875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek     * @param isLastChild is this the last child in the list. If true, then the transformation is
843875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek     *                    different since it's content fades out.
8440242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek     */
845875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek    public void setIconTransformationAmount(float iconTransformationAmount, boolean isLastChild) {
846875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        boolean changeTransformation = isLastChild != mIsLastChild;
847875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        changeTransformation |= mIconTransformationAmount != iconTransformationAmount;
848875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        mIsLastChild = isLastChild;
849875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        mIconTransformationAmount = iconTransformationAmount;
850875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        if (changeTransformation) {
851875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            updateContentTransformation();
8520242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek            boolean iconsVisible = mIconTransformationAmount == 0.0f;
8530242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek            if (iconsVisible != mIconsVisible) {
8540242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek                mIconsVisible = iconsVisible;
8550242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek                updateIconVisibilities();
8560242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek            }
8570242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek        }
8580242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek    }
8590242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek
860db16737031091160a3a7d080ac44ce2836402d74Selim Cinek    @Override
861db16737031091160a3a7d080ac44ce2836402d74Selim Cinek    protected void onBelowSpeedBumpChanged() {
862db16737031091160a3a7d080ac44ce2836402d74Selim Cinek        updateIconVisibilities();
863db16737031091160a3a7d080ac44ce2836402d74Selim Cinek    }
864db16737031091160a3a7d080ac44ce2836402d74Selim Cinek
865875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek    private void updateContentTransformation() {
866875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        float contentAlpha;
867875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        float translationY = - mIconTransformationAmount * mIconTransformContentShift;
868875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        if (mIsLastChild) {
869875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            contentAlpha = 1.0f - mIconTransformationAmount;
870875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            contentAlpha = Math.min(contentAlpha / 0.5f, 1.0f);
8710242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek            contentAlpha = Interpolators.ALPHA_OUT.getInterpolation(contentAlpha);
872875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            translationY *= 0.4f;
873875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        } else {
874875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            contentAlpha = 1.0f;
875875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        }
876875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        mPublicLayout.setAlpha(contentAlpha);
877875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        mPrivateLayout.setAlpha(contentAlpha);
878875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        mPublicLayout.setTranslationY(translationY);
879875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        mPrivateLayout.setTranslationY(translationY);
880875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        if (mChildrenContainer != null) {
881875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            mChildrenContainer.setAlpha(contentAlpha);
882875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            mChildrenContainer.setTranslationY(translationY);
883875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            // TODO: handle children fade out better
8840242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek        }
8850242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek    }
8860242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek
8870242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek    private void updateIconVisibilities() {
888db16737031091160a3a7d080ac44ce2836402d74Selim Cinek        boolean visible = isChildInGroup() || isBelowSpeedBump() || mIconsVisible;
889db16737031091160a3a7d080ac44ce2836402d74Selim Cinek        mPublicLayout.setIconsVisible(visible);
890db16737031091160a3a7d080ac44ce2836402d74Selim Cinek        mPrivateLayout.setIconsVisible(visible);
891db16737031091160a3a7d080ac44ce2836402d74Selim Cinek        if (mChildrenContainer != null) {
892db16737031091160a3a7d080ac44ce2836402d74Selim Cinek            mChildrenContainer.setIconsVisible(visible);
8930242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek        }
8940242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek    }
8950242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek
896875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek    /**
897875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek     * Get the relative top padding of a view relative to this view. This recursively walks up the
898875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek     * hierarchy and does the corresponding measuring.
899875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek     *
900875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek     * @param view the view to the the padding for. The requested view has to be a child of this
901875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek     *             notification.
902875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek     * @return the toppadding
903875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek     */
904875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek    public int getRelativeTopPadding(View view) {
905875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        int topPadding = 0;
906875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        while (view.getParent() instanceof ViewGroup) {
907875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            topPadding += view.getTop();
908875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            view = (View) view.getParent();
909875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            if (view instanceof ExpandableNotificationRow) {
910875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek                return topPadding;
911875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            }
912875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        }
913875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        return topPadding;
914875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek    }
915875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek
91678403d79739605511ea88b653564d81d7bf4bbbaChris Wren    public interface ExpansionLogger {
91778403d79739605511ea88b653564d81d7bf4bbbaChris Wren        public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
91878403d79739605511ea88b653564d81d7bf4bbbaChris Wren    }
9191685e634fb0b14033bd436af8d7174436699ffecSelim Cinek
92051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    public ExpandableNotificationRow(Context context, AttributeSet attrs) {
92151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren        super(context, attrs);
9220e2ffbd48bbedf47deb7f6aed96bd07e2fc96f53Blazej Magnowski        mFalsingManager = FalsingManager.getInstance(context);
92301af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek        initDimens();
92401af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek    }
92501af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek
92601af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek    private void initDimens() {
927f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek        mNotificationMinHeightLegacy = getFontScaledHeight(R.dimen.notification_min_height_legacy);
928f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek        mNotificationMinHeight = getFontScaledHeight(R.dimen.notification_min_height);
929f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek        mNotificationMaxHeight = getFontScaledHeight(R.dimen.notification_max_height);
930f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek        mMaxHeadsUpHeightLegacy = getFontScaledHeight(
93177019c72332cb31dd1cb713ea4c66e267e6cbf39Selim Cinek                R.dimen.notification_max_heads_up_height_legacy);
932f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek        mMaxHeadsUpHeight = getFontScaledHeight(R.dimen.notification_max_heads_up_height);
933b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        mIncreasedPaddingBetweenElements = getResources()
934b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                .getDimensionPixelSize(R.dimen.notification_divider_height_increased);
935875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        mIconTransformContentShiftNoIcon = getResources().getDimensionPixelSize(
9360242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek                R.dimen.notification_icon_transform_content_shift);
937f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek    }
938f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek
939f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek    /**
940f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek     * @param dimenId the dimen to look up
941f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek     * @return the font scaled dimen as if it were in sp but doesn't shrink sizes below dp
942f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek     */
943f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek    private int getFontScaledHeight(int dimenId) {
944f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek        int dimensionPixelSize = getResources().getDimensionPixelSize(dimenId);
945f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek        float factor = Math.max(1.0f, getResources().getDisplayMetrics().scaledDensity /
946f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek                getResources().getDisplayMetrics().density);
947f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek        return (int) (dimensionPixelSize * factor);
94851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    }
94951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren
950a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer    /**
951a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer     * Resets this view so it can be re-used for an updated notification.
952a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer     */
95322f2ee567dd1b1a42432251229bcb2f05c1c4700Christoph Studer    @Override
954a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer    public void reset() {
95522f2ee567dd1b1a42432251229bcb2f05c1c4700Christoph Studer        super.reset();
95678403d79739605511ea88b653564d81d7bf4bbbaChris Wren        final boolean wasExpanded = isExpanded();
957a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer        mExpandable = false;
958a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer        mHasUserChangedExpansion = false;
959a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer        mUserLocked = false;
960a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer        mShowingPublic = false;
961ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi        mSensitive = false;
962ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi        mShowingPublicInitialized = false;
963a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer        mIsSystemExpanded = false;
96483bc78338437a460076a4b5778ded38440ac3501Selim Cinek        mOnKeyguard = false;
96551d94917c7dc53845701702bfd63f102a3a2dbc8Selim Cinek        mPublicLayout.reset();
96651d94917c7dc53845701702bfd63f102a3a2dbc8Selim Cinek        mPrivateLayout.reset();
96731094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek        resetHeight();
9684b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        resetTranslation();
96931094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek        logExpansionEvent(false, wasExpanded);
97031094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek    }
97131094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek
97231094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek    public void resetHeight() {
97331094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek        onHeightReset();
9746e28a678c7f9fe2cae5a51bfdbab3071a2d8d0baSelim Cinek        requestLayout();
975a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer    }
976a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer
977251957d76e57eb6e5f8068b37346144e10e586a4Jorim Jaggi    @Override
978251957d76e57eb6e5f8068b37346144e10e586a4Jorim Jaggi    protected void onFinishInflate() {
979251957d76e57eb6e5f8068b37346144e10e586a4Jorim Jaggi        super.onFinishInflate();
980be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi        mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
981fa0a2d3d90fdde14784ec6351a0798bc21c2f126Selim Cinek        mPublicLayout.setContainingNotification(this);
982be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi        mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded);
983eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek        mPrivateLayout.setExpandClickListener(mExpandClickListener);
984fa0a2d3d90fdde14784ec6351a0798bc21c2f126Selim Cinek        mPrivateLayout.setContainingNotification(this);
985eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek        mPublicLayout.setExpandClickListener(mExpandClickListener);
9864b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        mSettingsIconRowStub = (ViewStub) findViewById(R.id.settings_icon_row_stub);
9874b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        mSettingsIconRowStub.setOnInflateListener(new ViewStub.OnInflateListener() {
9884b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            @Override
9894b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            public void onInflate(ViewStub stub, View inflated) {
9904b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor                mSettingsIconRow = (NotificationSettingsIconRow) inflated;
9914b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor                mSettingsIconRow.setNotificationRowParent(ExpandableNotificationRow.this);
9923fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor                mSettingsIconRow.setAppName(mAppName);
9934b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            }
9944b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        });
995ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek        mGutsStub = (ViewStub) findViewById(R.id.notification_guts_stub);
996ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek        mGutsStub.setOnInflateListener(new ViewStub.OnInflateListener() {
997b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi            @Override
998b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi            public void onInflate(ViewStub stub, View inflated) {
999b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi                mGuts = (NotificationGuts) inflated;
1000b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi                mGuts.setClipTopAmount(getClipTopAmount());
1001b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi                mGuts.setActualHeight(getActualHeight());
1002ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek                mGutsStub = null;
1003b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi            }
1004b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi        });
1005b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        mChildrenContainerStub = (ViewStub) findViewById(R.id.child_container_stub);
1006b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        mChildrenContainerStub.setOnInflateListener(new ViewStub.OnInflateListener() {
1007b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
1008b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            @Override
1009b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            public void onInflate(ViewStub stub, View inflated) {
1010b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek                mChildrenContainer = (NotificationChildrenContainer) inflated;
1011388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek                mChildrenContainer.setNotificationParent(ExpandableNotificationRow.this);
1012c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek                mChildrenContainer.onNotificationUpdated();
10134b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor                mTranslateableViews.add(mChildrenContainer);
1014b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            }
1015b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        });
1016863834bd96bdebcf21f4c4a7d8285d4858c061e4Selim Cinek        mVetoButton = findViewById(R.id.veto);
10179e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek        mVetoButton.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
10189e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek        mVetoButton.setContentDescription(mContext.getString(
10199e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek                R.string.accessibility_remove_notification));
10204b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor
10214b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        // Add the views that we translate to reveal the gear
10224b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        mTranslateableViews = new ArrayList<View>();
10234b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        for (int i = 0; i < getChildCount(); i++) {
10244b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            mTranslateableViews.add(getChildAt(i));
10254b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        }
10264b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        // Remove views that don't translate
10274b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        mTranslateableViews.remove(mVetoButton);
10284b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        mTranslateableViews.remove(mSettingsIconRowStub);
10294b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        mTranslateableViews.remove(mChildrenContainerStub);
10304b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        mTranslateableViews.remove(mGutsStub);
10314b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor    }
10324b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor
10339e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek    public View getVetoButton() {
10349e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek        return mVetoButton;
10359e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek    }
10369e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek
10374b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor    public void resetTranslation() {
103832c638a597dccbe4be600fd483060ee1466fdb04Mady Mellor        if (mTranslateAnim != null) {
103932c638a597dccbe4be600fd483060ee1466fdb04Mady Mellor            mTranslateAnim.cancel();
104032c638a597dccbe4be600fd483060ee1466fdb04Mady Mellor        }
10414b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        if (mTranslateableViews != null) {
10424b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            for (int i = 0; i < mTranslateableViews.size(); i++) {
10434b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor                mTranslateableViews.get(i).setTranslationX(0);
10444b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            }
10454b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        }
1046b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        invalidateOutline();
10474b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        if (mSettingsIconRow != null) {
10484b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            mSettingsIconRow.resetState();
10494b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        }
10504b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor    }
10514b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor
10524b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor    public void animateTranslateNotification(final float leftTarget) {
10534b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        if (mTranslateAnim != null) {
10544b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            mTranslateAnim.cancel();
10554b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        }
1056b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        mTranslateAnim = getTranslateViewAnimator(leftTarget, null /* updateListener */);
105734958fa272c9216db4002546c3efad692b3d7775Mady Mellor        if (mTranslateAnim != null) {
105834958fa272c9216db4002546c3efad692b3d7775Mady Mellor            mTranslateAnim.start();
105934958fa272c9216db4002546c3efad692b3d7775Mady Mellor        }
106034958fa272c9216db4002546c3efad692b3d7775Mady Mellor    }
106134958fa272c9216db4002546c3efad692b3d7775Mady Mellor
106234958fa272c9216db4002546c3efad692b3d7775Mady Mellor    @Override
106334958fa272c9216db4002546c3efad692b3d7775Mady Mellor    public void setTranslation(float translationX) {
106434958fa272c9216db4002546c3efad692b3d7775Mady Mellor        if (areGutsExposed()) {
106534958fa272c9216db4002546c3efad692b3d7775Mady Mellor            // Don't translate if guts are showing.
106634958fa272c9216db4002546c3efad692b3d7775Mady Mellor            return;
106734958fa272c9216db4002546c3efad692b3d7775Mady Mellor        }
106834958fa272c9216db4002546c3efad692b3d7775Mady Mellor        // Translate the group of views
106934958fa272c9216db4002546c3efad692b3d7775Mady Mellor        for (int i = 0; i < mTranslateableViews.size(); i++) {
107034958fa272c9216db4002546c3efad692b3d7775Mady Mellor            if (mTranslateableViews.get(i) != null) {
107134958fa272c9216db4002546c3efad692b3d7775Mady Mellor                mTranslateableViews.get(i).setTranslationX(translationX);
107234958fa272c9216db4002546c3efad692b3d7775Mady Mellor            }
107334958fa272c9216db4002546c3efad692b3d7775Mady Mellor        }
1074b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        invalidateOutline();
107534958fa272c9216db4002546c3efad692b3d7775Mady Mellor        if (mSettingsIconRow != null) {
107634958fa272c9216db4002546c3efad692b3d7775Mady Mellor            mSettingsIconRow.updateSettingsIcons(translationX, getMeasuredWidth());
107734958fa272c9216db4002546c3efad692b3d7775Mady Mellor        }
107834958fa272c9216db4002546c3efad692b3d7775Mady Mellor    }
107934958fa272c9216db4002546c3efad692b3d7775Mady Mellor
108034958fa272c9216db4002546c3efad692b3d7775Mady Mellor    @Override
108134958fa272c9216db4002546c3efad692b3d7775Mady Mellor    public float getTranslation() {
108234958fa272c9216db4002546c3efad692b3d7775Mady Mellor        if (mTranslateableViews != null && mTranslateableViews.size() > 0) {
108334958fa272c9216db4002546c3efad692b3d7775Mady Mellor            // All of the views in the list should have same translation, just use first one.
108434958fa272c9216db4002546c3efad692b3d7775Mady Mellor            return mTranslateableViews.get(0).getTranslationX();
108534958fa272c9216db4002546c3efad692b3d7775Mady Mellor        }
108634958fa272c9216db4002546c3efad692b3d7775Mady Mellor        return 0;
108734958fa272c9216db4002546c3efad692b3d7775Mady Mellor    }
108834958fa272c9216db4002546c3efad692b3d7775Mady Mellor
108934958fa272c9216db4002546c3efad692b3d7775Mady Mellor    public Animator getTranslateViewAnimator(final float leftTarget,
109034958fa272c9216db4002546c3efad692b3d7775Mady Mellor            AnimatorUpdateListener listener) {
1091723f1f996fd78f08e5e91ed57420bd431e11f903Mady Mellor        if (mTranslateAnim != null) {
1092723f1f996fd78f08e5e91ed57420bd431e11f903Mady Mellor            mTranslateAnim.cancel();
1093723f1f996fd78f08e5e91ed57420bd431e11f903Mady Mellor        }
109434958fa272c9216db4002546c3efad692b3d7775Mady Mellor        if (areGutsExposed()) {
109534958fa272c9216db4002546c3efad692b3d7775Mady Mellor            // No translation if guts are exposed.
109634958fa272c9216db4002546c3efad692b3d7775Mady Mellor            return null;
109734958fa272c9216db4002546c3efad692b3d7775Mady Mellor        }
1098b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        final ObjectAnimator translateAnim = ObjectAnimator.ofFloat(this, TRANSLATE_CONTENT,
1099b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                leftTarget);
1100b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        if (listener != null) {
1101b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            translateAnim.addUpdateListener(listener);
1102b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        }
1103b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        translateAnim.addListener(new AnimatorListenerAdapter() {
1104b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            boolean cancelled = false;
1105723f1f996fd78f08e5e91ed57420bd431e11f903Mady Mellor
1106b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            @Override
1107b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            public void onAnimationCancel(Animator anim) {
1108b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                cancelled = true;
1109b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            }
1110723f1f996fd78f08e5e91ed57420bd431e11f903Mady Mellor
1111b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            @Override
1112b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            public void onAnimationEnd(Animator anim) {
1113b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                if (!cancelled && mSettingsIconRow != null && leftTarget == 0) {
1114b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                    mSettingsIconRow.resetState();
1115b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                    mTranslateAnim = null;
1116723f1f996fd78f08e5e91ed57420bd431e11f903Mady Mellor                }
11174b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            }
1118b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        });
1119b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        mTranslateAnim = translateAnim;
1120b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        return translateAnim;
11214b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor    }
11224b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor
11234b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor    public float getSpaceForGear() {
11244b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        if (mSettingsIconRow != null) {
11254b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            return mSettingsIconRow.getSpaceForGear();
11264b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        }
11274b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        return 0;
11284b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor    }
11294b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor
11304b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor    public NotificationSettingsIconRow getSettingsRow() {
11314b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        if (mSettingsIconRow == null) {
11324b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor            mSettingsIconRowStub.inflate();
11334b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        }
11344b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor        return mSettingsIconRow;
11354b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor    }
11364b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor
1137ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek    public void inflateGuts() {
1138ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek        if (mGuts == null) {
1139ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek            mGutsStub.inflate();
1140ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek        }
1141ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek    }
1142ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek
1143da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek    private void updateChildrenVisibility() {
1144d84a5930cca7add37e7e23305538d29959daf199Selim Cinek        mPrivateLayout.setVisibility(!mShowingPublic && !mIsSummaryWithChildren ? VISIBLE
1145d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                : INVISIBLE);
1146ef5127ea5f34f7a4c961021f6b691174bcb81d2eSelim Cinek        if (mChildrenContainer != null) {
1147ef5127ea5f34f7a4c961021f6b691174bcb81d2eSelim Cinek            mChildrenContainer.setVisibility(!mShowingPublic && mIsSummaryWithChildren ? VISIBLE
1148ef5127ea5f34f7a4c961021f6b691174bcb81d2eSelim Cinek                    : INVISIBLE);
1149b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            mChildrenContainer.updateHeaderVisibility(!mShowingPublic && mIsSummaryWithChildren
1150b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                    ? VISIBLE
1151ef5127ea5f34f7a4c961021f6b691174bcb81d2eSelim Cinek                    : INVISIBLE);
1152b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        }
1153da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek        // The limits might have changed if the view suddenly became a group or vice versa
1154da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek        updateLimits();
1155b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
1156b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
1157fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi    @Override
1158a54956a0bc611b1e9b3914edc7a604b59688f6b7Alan Viverette    public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event) {
1159a54956a0bc611b1e9b3914edc7a604b59688f6b7Alan Viverette        if (super.onRequestSendAccessibilityEventInternal(child, event)) {
1160fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi            // Add a record for the entire layout since its content is somehow small.
1161fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi            // The event comes from a leaf view that is interacted with.
1162fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi            AccessibilityEvent record = AccessibilityEvent.obtain();
1163fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi            onInitializeAccessibilityEvent(record);
1164fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi            dispatchPopulateAccessibilityEvent(record);
1165fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi            event.appendRecord(record);
1166fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi            return true;
1167fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi        }
1168fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi        return false;
1169c5dc0d0cce373fbf292e13633c114a431d747167Jorim Jaggi    }
117051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren
1171e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock    @Override
11724e857f4ef0357e05806819d0488a73a12208fe8fJorim Jaggi    public void setDark(boolean dark, boolean fade, long delay) {
11734e857f4ef0357e05806819d0488a73a12208fe8fJorim Jaggi        super.setDark(dark, fade, delay);
1174e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock        final NotificationContentView showing = getShowingLayout();
1175e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock        if (showing != null) {
11764e857f4ef0357e05806819d0488a73a12208fe8fJorim Jaggi            showing.setDark(dark, fade, delay);
1177e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock        }
11789c7712d45ccec56a80873a83e56a83f810624b43Selim Cinek        if (mIsSummaryWithChildren) {
1179c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek            mChildrenContainer.setDark(dark, fade, delay);
11809c7712d45ccec56a80873a83e56a83f810624b43Selim Cinek        }
1181e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock    }
1182e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock
118351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    public boolean isExpandable() {
1184388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek        if (mIsSummaryWithChildren && !mShowingPublic) {
1185388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek            return !mChildrenExpanded;
1186388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek        }
118751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren        return mExpandable;
118851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    }
118951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren
119051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    public void setExpandable(boolean expandable) {
119151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren        mExpandable = expandable;
1192eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek        mPrivateLayout.updateExpandButtons(isExpandable());
119351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    }
119451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren
11954ffd63611a0d516c9988b37e9c06e6f8390c2a2fSelim Cinek    @Override
11964ffd63611a0d516c9988b37e9c06e6f8390c2a2fSelim Cinek    public void setClipToActualHeight(boolean clipToActualHeight) {
1197084c16b8b380e7ff0d38d9e2846db321f0214931Selim Cinek        super.setClipToActualHeight(clipToActualHeight || isUserLocked());
1198084c16b8b380e7ff0d38d9e2846db321f0214931Selim Cinek        getShowingLayout().setClipToActualHeight(clipToActualHeight || isUserLocked());
11994ffd63611a0d516c9988b37e9c06e6f8390c2a2fSelim Cinek    }
12004ffd63611a0d516c9988b37e9c06e6f8390c2a2fSelim Cinek
12011685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    /**
12021685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     * @return whether the user has changed the expansion state
12031685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     */
12041685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    public boolean hasUserChangedExpansion() {
12051685e634fb0b14033bd436af8d7174436699ffecSelim Cinek        return mHasUserChangedExpansion;
12061685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    }
12071685e634fb0b14033bd436af8d7174436699ffecSelim Cinek
120851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    public boolean isUserExpanded() {
120951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren        return mUserExpanded;
121051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    }
121151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren
12121685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    /**
12131685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     * Set this notification to be expanded by the user
12141685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     *
12151685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     * @param userExpanded whether the user wants this notification to be expanded
12161685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     */
121751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    public void setUserExpanded(boolean userExpanded) {
1218388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek        setUserExpanded(userExpanded, false /* allowChildExpansion */);
1219388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek    }
1220388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek
1221388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek    /**
1222388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek     * Set this notification to be expanded by the user
1223388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek     *
1224388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek     * @param userExpanded whether the user wants this notification to be expanded
1225388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek     * @param allowChildExpansion whether a call to this method allows expanding children
1226388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek     */
1227388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek    public void setUserExpanded(boolean userExpanded, boolean allowChildExpansion) {
12280e2ffbd48bbedf47deb7f6aed96bd07e2fc96f53Blazej Magnowski        mFalsingManager.setNotificationExpanded();
1229388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek        if (mIsSummaryWithChildren && !mShowingPublic && allowChildExpansion) {
1230698b1706be196de41fc6bf03cf15971c82a11949Chris Wren            final boolean wasExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification);
1231388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek            mGroupManager.setGroupExpanded(mStatusBarNotification, userExpanded);
1232698b1706be196de41fc6bf03cf15971c82a11949Chris Wren            logExpansionEvent(true /* userAction */, wasExpanded);
1233388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek            return;
1234388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek        }
1235a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer        if (userExpanded && !mExpandable) return;
123678403d79739605511ea88b653564d81d7bf4bbbaChris Wren        final boolean wasExpanded = isExpanded();
12371685e634fb0b14033bd436af8d7174436699ffecSelim Cinek        mHasUserChangedExpansion = true;
123851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren        mUserExpanded = userExpanded;
123978403d79739605511ea88b653564d81d7bf4bbbaChris Wren        logExpansionEvent(true, wasExpanded);
124051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    }
124151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren
1242ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek    public void resetUserExpansion() {
1243ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek        mHasUserChangedExpansion = false;
1244ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek        mUserExpanded = false;
1245ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek    }
1246ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek
124751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    public boolean isUserLocked() {
12481b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek        return mUserLocked && !mForceUnlocked;
124951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    }
125051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren
125151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    public void setUserLocked(boolean userLocked) {
125251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren        mUserLocked = userLocked;
12538f2f6a67fad7aed720e33a6629cb65d368ebfb80Selim Cinek        mPrivateLayout.setUserExpanding(userLocked);
125442357e030c095867b95e2e8a718649587c5ebf52Selim Cinek        if (mIsSummaryWithChildren) {
125542357e030c095867b95e2e8a718649587c5ebf52Selim Cinek            mChildrenContainer.setUserLocked(userLocked);
12567baaa9e82bebc6b3e7735828dbf67340eebc5821Selim Cinek            if (userLocked || !isGroupExpanded()) {
1257b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                updateBackgroundForGroupState();
1258b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            }
125942357e030c095867b95e2e8a718649587c5ebf52Selim Cinek        }
126051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren    }
126151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren
12621685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    /**
12631685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     * @return has the system set this notification to be expanded
12641685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     */
12651685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    public boolean isSystemExpanded() {
12661685e634fb0b14033bd436af8d7174436699ffecSelim Cinek        return mIsSystemExpanded;
12671685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    }
12681685e634fb0b14033bd436af8d7174436699ffecSelim Cinek
12691685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    /**
12701685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     * Set this notification to be expanded by the system.
12711685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     *
12721685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     * @param expand whether the system wants this notification to be expanded.
12731685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     */
12741685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    public void setSystemExpanded(boolean expand) {
127531094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek        if (expand != mIsSystemExpanded) {
127631094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek            final boolean wasExpanded = isExpanded();
127731094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek            mIsSystemExpanded = expand;
1278b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            notifyHeightChanged(false /* needsAnimation */);
127931094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek            logExpansionEvent(false, wasExpanded);
1280ed6913b0ce99784188713975218dcff113a3d4a7Selim Cinek            if (mIsSummaryWithChildren) {
1281c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek                mChildrenContainer.updateGroupOverflow();
1282c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek            }
128331094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek        }
1284dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi    }
1285dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi
1286dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi    /**
128783bc78338437a460076a4b5778ded38440ac3501Selim Cinek     * @param onKeyguard whether to prevent notification expansion
1288dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi     */
128983bc78338437a460076a4b5778ded38440ac3501Selim Cinek    public void setOnKeyguard(boolean onKeyguard) {
129083bc78338437a460076a4b5778ded38440ac3501Selim Cinek        if (onKeyguard != mOnKeyguard) {
129131094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek            final boolean wasExpanded = isExpanded();
129283bc78338437a460076a4b5778ded38440ac3501Selim Cinek            mOnKeyguard = onKeyguard;
129331094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek            logExpansionEvent(false, wasExpanded);
129431094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek            if (wasExpanded != isExpanded()) {
1295c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek                if (mIsSummaryWithChildren) {
1296c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek                    mChildrenContainer.updateGroupOverflow();
1297c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek                }
12984b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor                notifyHeightChanged(false /* needsAnimation */);
129931094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek            }
130031094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek        }
13011685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    }
13021685e634fb0b14033bd436af8d7174436699ffecSelim Cinek
13031685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    /**
13049e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek     * @return Can the underlying notification be cleared? This can be different from whether the
13059e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek     *         notification can be dismissed in case notifications are sensitive on the lockscreen.
13069e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek     * @see #canViewBeDismissed()
13070d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler     */
13080d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler    public boolean isClearable() {
1309506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek        if (mStatusBarNotification == null || !mStatusBarNotification.isClearable()) {
1310506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek            return false;
1311506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek        }
1312506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek        if (mIsSummaryWithChildren) {
1313506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek            List<ExpandableNotificationRow> notificationChildren =
1314506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek                    mChildrenContainer.getNotificationChildren();
1315506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek            for (int i = 0; i < notificationChildren.size(); i++) {
1316506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek                ExpandableNotificationRow child = notificationChildren.get(i);
1317506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek                if (!child.isClearable()) {
1318506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek                    return false;
1319506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek                }
1320506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek            }
1321506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek        }
1322506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek        return true;
13230d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler    }
13240d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler
13259cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi    @Override
13269cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi    public int getIntrinsicHeight() {
1327be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi        if (isUserLocked()) {
1328be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi            return getActualHeight();
1329be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi        }
1330d84a5930cca7add37e7e23305538d29959daf199Selim Cinek        if (mGuts != null && mGuts.areGutsExposed()) {
1331d84a5930cca7add37e7e23305538d29959daf199Selim Cinek            return mGuts.getHeight();
1332d84a5930cca7add37e7e23305538d29959daf199Selim Cinek        } else if ((isChildInGroup() && !isGroupExpanded())) {
1333d84a5930cca7add37e7e23305538d29959daf199Selim Cinek            return mPrivateLayout.getMinHeight();
1334d84a5930cca7add37e7e23305538d29959daf199Selim Cinek        } else if (mSensitive && mHideSensitiveForIntrinsicHeight) {
1335d84a5930cca7add37e7e23305538d29959daf199Selim Cinek            return getMinHeight();
133683bc78338437a460076a4b5778ded38440ac3501Selim Cinek        } else if (mIsSummaryWithChildren && !mOnKeyguard) {
1337eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek            return mChildrenContainer.getIntrinsicHeight();
133873cf02a0783e3857cae21fece9c292abcc9e1409Selim Cinek        } else if (mIsHeadsUp || mHeadsupDisappearRunning) {
133973cf02a0783e3857cae21fece9c292abcc9e1409Selim Cinek            if (isPinned() || mHeadsupDisappearRunning) {
134031aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek                return getPinnedHeadsUpHeight(true /* atLeastMinHeight */);
134131aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek            } else if (isExpanded()) {
1342d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                return Math.max(getMaxExpandHeight(), mHeadsUpHeight);
13438d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek            } else {
1344567e845d99840a6e556595739a15e16132eb2f1eSelim Cinek                return Math.max(getCollapsedHeight(), mHeadsUpHeight);
13458d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek            }
134631aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek        } else if (isExpanded()) {
134783bc78338437a460076a4b5778ded38440ac3501Selim Cinek            return getMaxExpandHeight();
1348d84a5930cca7add37e7e23305538d29959daf199Selim Cinek        } else {
1349567e845d99840a6e556595739a15e16132eb2f1eSelim Cinek            return getCollapsedHeight();
13501685e634fb0b14033bd436af8d7174436699ffecSelim Cinek        }
1351b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
13521685e634fb0b14033bd436af8d7174436699ffecSelim Cinek
1353b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    public boolean isGroupExpanded() {
1354eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek        return mGroupManager.isGroupExpanded(mStatusBarNotification);
1355b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
1356b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
1357263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek    private void onChildrenCountChanged() {
13588fc93c90839e5d9dd52bca9dd97c198c0fe68af1Selim Cinek        mIsSummaryWithChildren = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS
1359b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                && mChildrenContainer != null && mChildrenContainer.getNotificationChildCount() > 0;
1360b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        if (mIsSummaryWithChildren && mChildrenContainer.getHeaderView() == null) {
1361b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            mChildrenContainer.recreateNotificationHeader(mExpandClickListener,
1362b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                    mEntry.notification);
1363263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek        }
13646baed9e3a272b09e87f15801a389d7714d0b051fMady Mellor        getShowingLayout().updateBackgroundColor(false /* animate */);
1365eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek        mPrivateLayout.updateExpandButtons(isExpandable());
1366ea4bef7386ca6c6260f292bf006d16a99b93f698Selim Cinek        updateChildrenHeaderAppearance();
1367da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek        updateChildrenVisibility();
1368263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek    }
1369263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek
1370b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    public void updateChildrenHeaderAppearance() {
1371ed6913b0ce99784188713975218dcff113a3d4a7Selim Cinek        if (mIsSummaryWithChildren) {
1372b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            mChildrenContainer.updateChildrenHeaderAppearance();
1373b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        }
1374b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    }
1375b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor
13761685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    /**
13771685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     * Check whether the view state is currently expanded. This is given by the system in {@link
13781685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     * #setSystemExpanded(boolean)} and can be overridden by user expansion or
13791685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     * collapsing in {@link #setUserExpanded(boolean)}. Note that the visual appearance of this
13801685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     * view can differ from this state, if layout params are modified from outside.
13811685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     *
13821685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     * @return whether the view state is currently expanded.
13831685e634fb0b14033bd436af8d7174436699ffecSelim Cinek     */
138483bc78338437a460076a4b5778ded38440ac3501Selim Cinek    public boolean isExpanded() {
1385e81b82ba252582753cb87ba424c82028b6e490ecSelim Cinek        return isExpanded(false /* allowOnKeyguard */);
1386e81b82ba252582753cb87ba424c82028b6e490ecSelim Cinek    }
1387e81b82ba252582753cb87ba424c82028b6e490ecSelim Cinek
1388e81b82ba252582753cb87ba424c82028b6e490ecSelim Cinek    public boolean isExpanded(boolean allowOnKeyguard) {
1389e81b82ba252582753cb87ba424c82028b6e490ecSelim Cinek        return (!mOnKeyguard || allowOnKeyguard)
1390b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek                && (!hasUserChangedExpansion() && (isSystemExpanded() || isSystemChildExpanded())
1391b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek                || isUserExpanded());
1392b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
1393b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
1394b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    private boolean isSystemChildExpanded() {
1395b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        return mIsSystemChildExpanded;
1396b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
1397b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
1398b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public void setSystemChildExpanded(boolean expanded) {
1399b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        mIsSystemChildExpanded = expanded;
14001685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    }
14011685e634fb0b14033bd436af8d7174436699ffecSelim Cinek
14021685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    @Override
14031685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
14041685e634fb0b14033bd436af8d7174436699ffecSelim Cinek        super.onLayout(changed, left, top, right, bottom);
14058d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek        updateMaxHeights();
1406a6edc878293e49594a6aac7a0d0e41c7980ece07Mady Mellor        if (mSettingsIconRow != null) {
1407a6edc878293e49594a6aac7a0d0e41c7980ece07Mady Mellor            mSettingsIconRow.updateVerticalLocation();
1408a6edc878293e49594a6aac7a0d0e41c7980ece07Mady Mellor        }
1409875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        updateContentShiftHeight();
1410875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek    }
1411875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek
1412875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek    /**
1413875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek     * Updates the content shift height such that the header is completely hidden when coming from
1414875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek     * the top.
1415875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek     */
1416875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek    private void updateContentShiftHeight() {
1417875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        NotificationHeaderView notificationHeader = getNotificationHeader();
1418875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        if (notificationHeader != null) {
1419875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            CachingIconView icon = notificationHeader.getIcon();
1420875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            mIconTransformContentShift = getRelativeTopPadding(icon) + icon.getHeight();
1421875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        } else {
1422875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek            mIconTransformContentShift = mIconTransformContentShiftNoIcon;
1423875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek        }
14241685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    }
14251685e634fb0b14033bd436af8d7174436699ffecSelim Cinek
14268d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek    private void updateMaxHeights() {
1427d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek        int intrinsicBefore = getIntrinsicHeight();
14288d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek        View expandedChild = mPrivateLayout.getExpandedChild();
14298d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek        if (expandedChild == null) {
14308d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek            expandedChild = mPrivateLayout.getContractedChild();
14318d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek        }
14328d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek        mMaxExpandHeight = expandedChild.getHeight();
14338d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek        View headsUpChild = mPrivateLayout.getHeadsUpChild();
14341f3f544f21cab3728f749ab66cd6859e9dfcf389Selim Cinek        if (headsUpChild == null) {
14351f3f544f21cab3728f749ab66cd6859e9dfcf389Selim Cinek            headsUpChild = mPrivateLayout.getContractedChild();
14368d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek        }
14371f3f544f21cab3728f749ab66cd6859e9dfcf389Selim Cinek        mHeadsUpHeight = headsUpChild.getHeight();
1438d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek        if (intrinsicBefore != getIntrinsicHeight()) {
1439bb42b7dd4892a8ab99f2f702cad931235d1d463eSelim Cinek            notifyHeightChanged(true  /* needsAnimation */);
1440d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek        }
1441d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek    }
1442d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek
1443fa0a2d3d90fdde14784ec6351a0798bc21c2f126Selim Cinek    @Override
1444fa0a2d3d90fdde14784ec6351a0798bc21c2f126Selim Cinek    public void notifyHeightChanged(boolean needsAnimation) {
1445fa0a2d3d90fdde14784ec6351a0798bc21c2f126Selim Cinek        super.notifyHeightChanged(needsAnimation);
1446fa0a2d3d90fdde14784ec6351a0798bc21c2f126Selim Cinek        getShowingLayout().requestSelectLayout(needsAnimation || isUserLocked());
1447fa0a2d3d90fdde14784ec6351a0798bc21c2f126Selim Cinek    }
1448fa0a2d3d90fdde14784ec6351a0798bc21c2f126Selim Cinek
14493c76d509d362cf5086a63722ab41e04f5d539182Selim Cinek    public void setSensitive(boolean sensitive, boolean hideSensitive) {
1450ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi        mSensitive = sensitive;
14513c76d509d362cf5086a63722ab41e04f5d539182Selim Cinek        mSensitiveHiddenInGeneral = hideSensitive;
1452ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi    }
1453ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi
1454ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi    public void setHideSensitiveForIntrinsicHeight(boolean hideSensitive) {
145560122be6747c4f79b96f6808158f8f7e7548b7d3Selim Cinek        mHideSensitiveForIntrinsicHeight = hideSensitive;
1456a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek        if (mIsSummaryWithChildren) {
1457a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek            List<ExpandableNotificationRow> notificationChildren =
1458a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek                    mChildrenContainer.getNotificationChildren();
1459a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek            for (int i = 0; i < notificationChildren.size(); i++) {
1460a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek                ExpandableNotificationRow child = notificationChildren.get(i);
1461a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek                child.setHideSensitiveForIntrinsicHeight(hideSensitive);
1462a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek            }
1463a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek        }
1464ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi    }
1465ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi
1466ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi    public void setHideSensitive(boolean hideSensitive, boolean animated, long delay,
1467ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi            long duration) {
1468ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi        boolean oldShowingPublic = mShowingPublic;
1469ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi        mShowingPublic = mSensitive && hideSensitive;
1470ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi        if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) {
1471ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi            return;
1472ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi        }
1473a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler
1474a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler        // bail out if no public version
14751685e634fb0b14033bd436af8d7174436699ffecSelim Cinek        if (mPublicLayout.getChildCount() == 0) return;
1476a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler
1477ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi        if (!animated) {
1478ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi            mPublicLayout.animate().cancel();
1479ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi            mPrivateLayout.animate().cancel();
1480a554c707386eb8a6c6fb3a2399f23b79a1c17f74Selim Cinek            if (mChildrenContainer != null) {
1481a554c707386eb8a6c6fb3a2399f23b79a1c17f74Selim Cinek                mChildrenContainer.animate().cancel();
1482a554c707386eb8a6c6fb3a2399f23b79a1c17f74Selim Cinek                mChildrenContainer.setAlpha(1f);
1483a554c707386eb8a6c6fb3a2399f23b79a1c17f74Selim Cinek            }
1484ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi            mPublicLayout.setAlpha(1f);
1485ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi            mPrivateLayout.setAlpha(1f);
1486ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi            mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE);
1487d84a5930cca7add37e7e23305538d29959daf199Selim Cinek            updateChildrenVisibility();
1488ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi        } else {
1489ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi            animateShowingPublic(delay, duration);
1490ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi        }
1491c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek        NotificationContentView showingLayout = getShowingLayout();
1492c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek        showingLayout.updateBackgroundColor(animated);
1493eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek        mPrivateLayout.updateExpandButtons(isExpandable());
1494ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi        mShowingPublicInitialized = true;
1495ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi    }
1496ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi
1497ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi    private void animateShowingPublic(long delay, long duration) {
1498b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        View[] privateViews = mIsSummaryWithChildren
1499b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                ? new View[] {mChildrenContainer}
1500d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                : new View[] {mPrivateLayout};
1501d84a5930cca7add37e7e23305538d29959daf199Selim Cinek        View[] publicViews = new View[] {mPublicLayout};
1502d84a5930cca7add37e7e23305538d29959daf199Selim Cinek        View[] hiddenChildren = mShowingPublic ? privateViews : publicViews;
1503d84a5930cca7add37e7e23305538d29959daf199Selim Cinek        View[] shownChildren = mShowingPublic ? publicViews : privateViews;
1504d84a5930cca7add37e7e23305538d29959daf199Selim Cinek        for (final View hiddenView : hiddenChildren) {
1505d84a5930cca7add37e7e23305538d29959daf199Selim Cinek            hiddenView.setVisibility(View.VISIBLE);
1506d84a5930cca7add37e7e23305538d29959daf199Selim Cinek            hiddenView.animate().cancel();
1507d84a5930cca7add37e7e23305538d29959daf199Selim Cinek            hiddenView.animate()
1508d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                    .alpha(0f)
1509d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                    .setStartDelay(delay)
1510d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                    .setDuration(duration)
1511d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                    .withEndAction(new Runnable() {
1512d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                        @Override
1513d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                        public void run() {
1514d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                            hiddenView.setVisibility(View.INVISIBLE);
1515d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                        }
1516d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                    });
1517d84a5930cca7add37e7e23305538d29959daf199Selim Cinek        }
1518d84a5930cca7add37e7e23305538d29959daf199Selim Cinek        for (View showView : shownChildren) {
1519d84a5930cca7add37e7e23305538d29959daf199Selim Cinek            showView.setVisibility(View.VISIBLE);
1520d84a5930cca7add37e7e23305538d29959daf199Selim Cinek            showView.setAlpha(0f);
1521d84a5930cca7add37e7e23305538d29959daf199Selim Cinek            showView.animate().cancel();
1522d84a5930cca7add37e7e23305538d29959daf199Selim Cinek            showView.animate()
1523d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                    .alpha(1f)
1524d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                    .setStartDelay(delay)
1525d84a5930cca7add37e7e23305538d29959daf199Selim Cinek                    .setDuration(duration);
1526d84a5930cca7add37e7e23305538d29959daf199Selim Cinek        }
15270d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler    }
15280d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler
15293776fe007550451bb237c705d333247eab2a291cSelim Cinek    public boolean mustStayOnScreen() {
15303776fe007550451bb237c705d333247eab2a291cSelim Cinek        return mIsHeadsUp;
15313776fe007550451bb237c705d333247eab2a291cSelim Cinek    }
15323776fe007550451bb237c705d333247eab2a291cSelim Cinek
15339e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek    /**
15349e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek     * @return Whether this view is allowed to be dismissed. Only valid for visible notifications as
15359e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek     *         otherwise some state might not be updated. To request about the general clearability
15369e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek     *         see {@link #isClearable()}.
15379e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek     */
15389e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek    public boolean canViewBeDismissed() {
1539e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        return isClearable() && (!mShowingPublic || !mSensitiveHiddenInGeneral);
1540a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler    }
1541251957d76e57eb6e5f8068b37346144e10e586a4Jorim Jaggi
1542cd35def3c35f04d7fd056590d4668b5ebbc80490Ricky Wai    public void makeActionsVisibile() {
1543cd35def3c35f04d7fd056590d4668b5ebbc80490Ricky Wai        setUserExpanded(true, true);
1544cd35def3c35f04d7fd056590d4668b5ebbc80490Ricky Wai        if (isChildInGroup()) {
1545cd35def3c35f04d7fd056590d4668b5ebbc80490Ricky Wai            mGroupManager.setGroupExpanded(mStatusBarNotification, true);
1546cd35def3c35f04d7fd056590d4668b5ebbc80490Ricky Wai        }
1547bb42b7dd4892a8ab99f2f702cad931235d1d463eSelim Cinek        notifyHeightChanged(false /* needsAnimation */);
1548cd35def3c35f04d7fd056590d4668b5ebbc80490Ricky Wai    }
1549cd35def3c35f04d7fd056590d4668b5ebbc80490Ricky Wai
1550b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public void setChildrenExpanded(boolean expanded, boolean animate) {
1551b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        mChildrenExpanded = expanded;
155283bc78338437a460076a4b5778ded38440ac3501Selim Cinek        if (mChildrenContainer != null) {
155383bc78338437a460076a4b5778ded38440ac3501Selim Cinek            mChildrenContainer.setChildrenExpanded(expanded);
155483bc78338437a460076a4b5778ded38440ac3501Selim Cinek        }
15551a5d8eadd56b435843dfbc1adf3779aa7286081bMady Mellor        updateBackgroundForGroupState();
1556ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek        updateClickAndFocus();
1557b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
1558b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
1559b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public static void applyTint(View v, int color) {
1560b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        int alpha;
1561b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        if (color != 0) {
1562b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            alpha = COLORED_DIVIDER_ALPHA;
1563b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        } else {
1564b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            color = 0xff000000;
1565b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            alpha = DEFAULT_DIVIDER_ALPHA;
1566b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        }
1567b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        if (v.getBackground() instanceof ColorDrawable) {
1568b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            ColorDrawable background = (ColorDrawable) v.getBackground();
1569b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            background.mutate();
1570b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            background.setColor(color);
1571b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek            background.setAlpha(alpha);
1572b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        }
1573b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    }
1574b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek
15751685e634fb0b14033bd436af8d7174436699ffecSelim Cinek    public int getMaxExpandHeight() {
1576b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        return mMaxExpandHeight;
1577a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler    }
1578584a7aa62c54bcbd654a6696d4fbb56e124874e7Jorim Jaggi
157934958fa272c9216db4002546c3efad692b3d7775Mady Mellor    public boolean areGutsExposed() {
158034958fa272c9216db4002546c3efad692b3d7775Mady Mellor        return (mGuts != null && mGuts.areGutsExposed());
158134958fa272c9216db4002546c3efad692b3d7775Mady Mellor    }
158234958fa272c9216db4002546c3efad692b3d7775Mady Mellor
1583be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    @Override
15844222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi    public boolean isContentExpandable() {
15852f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek        NotificationContentView showingLayout = getShowingLayout();
15862f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek        return showingLayout.isContentExpandable();
15874222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi    }
15884222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi
15894222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi    @Override
1590560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek    protected View getContentView() {
1591aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek        if (mIsSummaryWithChildren && !mShowingPublic) {
1592a5703187a9dba418f742fab0874a8f683b0bbb0eSelim Cinek            return mChildrenContainer;
1593a5703187a9dba418f742fab0874a8f683b0bbb0eSelim Cinek        }
1594560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek        return getShowingLayout();
1595560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek    }
1596560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek
1597560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek    @Override
1598aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek    protected void onAppearAnimationFinished(boolean wasAppearing) {
1599aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek        super.onAppearAnimationFinished(wasAppearing);
1600aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek        if (wasAppearing) {
1601aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek            // During the animation the visible view might have changed, so let's make sure all
1602aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek            // alphas are reset
1603aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek            if (mChildrenContainer != null) {
1604aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek                mChildrenContainer.setAlpha(1.0f);
1605aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek                mChildrenContainer.setLayerType(LAYER_TYPE_NONE, null);
1606aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek            }
1607aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek            mPrivateLayout.setAlpha(1.0f);
1608aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek            mPrivateLayout.setLayerType(LAYER_TYPE_NONE, null);
1609aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek            mPublicLayout.setAlpha(1.0f);
1610aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek            mPublicLayout.setLayerType(LAYER_TYPE_NONE, null);
1611aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek        }
1612aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek    }
1613aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek
1614aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek    @Override
1615b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    public int getExtraBottomPadding() {
1616b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        if (mIsSummaryWithChildren && isGroupExpanded()) {
1617b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            return mIncreasedPaddingBetweenElements;
1618b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        }
1619b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        return 0;
1620b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    }
1621b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor
1622b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    @Override
1623d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi    public void setActualHeight(int height, boolean notifyListeners) {
1624b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        super.setActualHeight(height, notifyListeners);
1625b53bc276d6ec093817988a358b7c2a6c63ee0c48Mady Mellor        if (mGuts != null && mGuts.areGutsExposed()) {
1626b53bc276d6ec093817988a358b7c2a6c63ee0c48Mady Mellor            mGuts.setActualHeight(height);
1627b53bc276d6ec093817988a358b7c2a6c63ee0c48Mady Mellor            return;
1628b53bc276d6ec093817988a358b7c2a6c63ee0c48Mady Mellor        }
1629eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek        int contentHeight = Math.max(getMinHeight(), height);
1630b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        mPrivateLayout.setContentHeight(contentHeight);
1631b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek        mPublicLayout.setContentHeight(contentHeight);
163242357e030c095867b95e2e8a718649587c5ebf52Selim Cinek        if (mIsSummaryWithChildren) {
163342357e030c095867b95e2e8a718649587c5ebf52Selim Cinek            mChildrenContainer.setActualHeight(height);
163442357e030c095867b95e2e8a718649587c5ebf52Selim Cinek        }
1635b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi        if (mGuts != null) {
1636b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi            mGuts.setActualHeight(height);
1637b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi        }
1638be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    }
1639be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
1640be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    @Override
1641b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek    public int getMaxContentHeight() {
164283bc78338437a460076a4b5778ded38440ac3501Selim Cinek        if (mIsSummaryWithChildren && !mShowingPublic) {
1643eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek            return mChildrenContainer.getMaxContentHeight();
164483bc78338437a460076a4b5778ded38440ac3501Selim Cinek        }
16452f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek        NotificationContentView showingLayout = getShowingLayout();
16462f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek        return showingLayout.getMaxHeight();
1647be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    }
1648be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
1649be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    @Override
16504222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi    public int getMinHeight() {
165131aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek        if (mIsHeadsUp && mHeadsUpManager.isTrackingHeadsUp()) {
165231aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek                return getPinnedHeadsUpHeight(false /* atLeastMinHeight */);
165331aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek        } else if (mIsSummaryWithChildren && !isGroupExpanded() && !mShowingPublic) {
1654b55386d64aeb80f74ed21035d1e389d86be89db6Selim Cinek            return mChildrenContainer.getMinHeight();
165531aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek        } else if (mIsHeadsUp) {
165631aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek            return mHeadsUpHeight;
1657b55386d64aeb80f74ed21035d1e389d86be89db6Selim Cinek        }
1658816c8e4735f975f4d8bffa1a5a37be6557424ea3Selim Cinek        NotificationContentView showingLayout = getShowingLayout();
1659816c8e4735f975f4d8bffa1a5a37be6557424ea3Selim Cinek        return showingLayout.getMinHeight();
1660816c8e4735f975f4d8bffa1a5a37be6557424ea3Selim Cinek    }
1661816c8e4735f975f4d8bffa1a5a37be6557424ea3Selim Cinek
1662816c8e4735f975f4d8bffa1a5a37be6557424ea3Selim Cinek    @Override
1663567e845d99840a6e556595739a15e16132eb2f1eSelim Cinek    public int getCollapsedHeight() {
16642c58461daf909fae5a2605f0ba63da3f9c897731Selim Cinek        if (mIsSummaryWithChildren && !mShowingPublic) {
1665567e845d99840a6e556595739a15e16132eb2f1eSelim Cinek            return mChildrenContainer.getCollapsedHeight();
166683bc78338437a460076a4b5778ded38440ac3501Selim Cinek        }
1667816c8e4735f975f4d8bffa1a5a37be6557424ea3Selim Cinek        return getMinHeight();
16684222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi    }
16694222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi
16704222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi    @Override
1671be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    public void setClipTopAmount(int clipTopAmount) {
1672be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi        super.setClipTopAmount(clipTopAmount);
1673be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi        mPrivateLayout.setClipTopAmount(clipTopAmount);
16742f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek        mPublicLayout.setClipTopAmount(clipTopAmount);
1675b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi        if (mGuts != null) {
1676b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi            mGuts.setClipTopAmount(clipTopAmount);
1677b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi        }
1678be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    }
1679be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
1680a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek    @Override
1681a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek    public void setClipBottomAmount(int clipBottomAmount) {
1682a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek        super.setClipBottomAmount(clipBottomAmount);
1683a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek        mPrivateLayout.setClipBottomAmount(clipBottomAmount);
1684a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek        mPublicLayout.setClipBottomAmount(clipBottomAmount);
1685a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek        if (mGuts != null) {
1686a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek            mGuts.setClipBottomAmount(clipBottomAmount);
1687a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek        }
1688b3dadccbc5c7040260a51a3e17efcb74aeec6a11Selim Cinek        if (mChildrenContainer != null) {
1689b3dadccbc5c7040260a51a3e17efcb74aeec6a11Selim Cinek            mChildrenContainer.setClipBottomAmount(clipBottomAmount);
1690b3dadccbc5c7040260a51a3e17efcb74aeec6a11Selim Cinek        }
1691a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek    }
1692a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek
169331094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek    public boolean isMaxExpandHeightInitialized() {
169431094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek        return mMaxExpandHeight != 0;
16957d447726e2cb9fae80db417012039828daab8fe7Selim Cinek    }
16962f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek
169742357e030c095867b95e2e8a718649587c5ebf52Selim Cinek    public NotificationContentView getShowingLayout() {
16982f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek        return mShowingPublic ? mPublicLayout : mPrivateLayout;
16992f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek    }
170078403d79739605511ea88b653564d81d7bf4bbbaChris Wren
170159ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi    @Override
170259ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi    public void setShowingLegacyBackground(boolean showing) {
170359ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi        super.setShowingLegacyBackground(showing);
170459ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi        mPrivateLayout.setShowingLegacyBackground(showing);
170559ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi        mPublicLayout.setShowingLegacyBackground(showing);
170659ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi    }
170759ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi
1708a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek    @Override
1709a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek    protected void updateBackgroundTint() {
1710a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek        super.updateBackgroundTint();
1711b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        updateBackgroundForGroupState();
1712a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek        if (mIsSummaryWithChildren) {
1713a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek            List<ExpandableNotificationRow> notificationChildren =
1714a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek                    mChildrenContainer.getNotificationChildren();
1715a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek            for (int i = 0; i < notificationChildren.size(); i++) {
1716a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek                ExpandableNotificationRow child = notificationChildren.get(i);
1717b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                child.updateBackgroundForGroupState();
1718a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek            }
1719a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek        }
1720a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek    }
1721a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek
1722b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    /**
1723b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor     * Called when a group has finished animating from collapsed or expanded state.
1724b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor     */
1725b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    public void onFinishedExpansionChange() {
1726b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        mGroupExpansionChanging = false;
1727b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        updateBackgroundForGroupState();
1728b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    }
1729b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor
1730b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    /**
1731b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor     * Updates the parent and children backgrounds in a group based on the expansion state.
1732b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor     */
1733b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor    public void updateBackgroundForGroupState() {
1734b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        if (mIsSummaryWithChildren) {
1735b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            // Only when the group has finished expanding do we hide its background.
1736b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            mShowNoBackground = isGroupExpanded() && !isGroupExpansionChanging() && !isUserLocked();
1737b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            mChildrenContainer.updateHeaderForExpansion(mShowNoBackground);
1738b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            List<ExpandableNotificationRow> children = mChildrenContainer.getNotificationChildren();
1739b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            for (int i = 0; i < children.size(); i++) {
1740b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                children.get(i).updateBackgroundForGroupState();
1741b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            }
1742b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        } else if (isChildInGroup()) {
1743b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            final int childColor = getShowingLayout().getBackgroundColorForExpansionState();
1744b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            // Only show a background if the group is expanded OR if it is expanding / collapsing
1745b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            // and has a custom background color
1746b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            final boolean showBackground = isGroupExpanded()
1747b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                    || ((mNotificationParent.isGroupExpansionChanging()
1748b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor                            || mNotificationParent.isUserLocked()) && childColor != 0);
1749b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            mShowNoBackground = !showBackground;
1750b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        } else {
1751b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            // Only children or parents ever need no background.
1752b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor            mShowNoBackground = false;
1753b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        }
1754b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor        updateOutline();
1755a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek        updateBackground();
1756a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek    }
1757a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek
17584a5796765041dcb45ce782fc7ec5866b89fe0df0Adrian Roos    public int getPositionOfChild(ExpandableNotificationRow childRow) {
17594a5796765041dcb45ce782fc7ec5866b89fe0df0Adrian Roos        if (mIsSummaryWithChildren) {
17604a5796765041dcb45ce782fc7ec5866b89fe0df0Adrian Roos            return mChildrenContainer.getPositionInLinearLayout(childRow);
17614a5796765041dcb45ce782fc7ec5866b89fe0df0Adrian Roos        }
17624a5796765041dcb45ce782fc7ec5866b89fe0df0Adrian Roos        return 0;
17634a5796765041dcb45ce782fc7ec5866b89fe0df0Adrian Roos    }
17644a5796765041dcb45ce782fc7ec5866b89fe0df0Adrian Roos
176578403d79739605511ea88b653564d81d7bf4bbbaChris Wren    public void setExpansionLogger(ExpansionLogger logger, String key) {
176678403d79739605511ea88b653564d81d7bf4bbbaChris Wren        mLogger = logger;
176778403d79739605511ea88b653564d81d7bf4bbbaChris Wren        mLoggingKey = key;
176878403d79739605511ea88b653564d81d7bf4bbbaChris Wren    }
176978403d79739605511ea88b653564d81d7bf4bbbaChris Wren
17706abeeb91194818e1d19f75336b03d1e305af0842Chris Wren    public void onExpandedByGesture(boolean userExpanded) {
17716abeeb91194818e1d19f75336b03d1e305af0842Chris Wren        int event = MetricsEvent.ACTION_NOTIFICATION_GESTURE_EXPANDER;
17726abeeb91194818e1d19f75336b03d1e305af0842Chris Wren        if (mGroupManager.isSummaryOfGroup(getStatusBarNotification())) {
17736abeeb91194818e1d19f75336b03d1e305af0842Chris Wren            event = MetricsEvent.ACTION_NOTIFICATION_GROUP_GESTURE_EXPANDER;
17746abeeb91194818e1d19f75336b03d1e305af0842Chris Wren        }
17756abeeb91194818e1d19f75336b03d1e305af0842Chris Wren        MetricsLogger.action(mContext, event, userExpanded);
17766abeeb91194818e1d19f75336b03d1e305af0842Chris Wren    }
17776abeeb91194818e1d19f75336b03d1e305af0842Chris Wren
17786183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek    @Override
177942357e030c095867b95e2e8a718649587c5ebf52Selim Cinek    public float getIncreasedPaddingAmount() {
178042357e030c095867b95e2e8a718649587c5ebf52Selim Cinek        if (mIsSummaryWithChildren) {
178142357e030c095867b95e2e8a718649587c5ebf52Selim Cinek            if (isGroupExpanded()) {
178242357e030c095867b95e2e8a718649587c5ebf52Selim Cinek                return 1.0f;
178342357e030c095867b95e2e8a718649587c5ebf52Selim Cinek            } else if (isUserLocked()) {
1784f07d06212b08939809aa4128f153bd5179f81fc7Selim Cinek                return mChildrenContainer.getGroupExpandFraction();
178542357e030c095867b95e2e8a718649587c5ebf52Selim Cinek            }
178642357e030c095867b95e2e8a718649587c5ebf52Selim Cinek        }
178742357e030c095867b95e2e8a718649587c5ebf52Selim Cinek        return 0.0f;
178861633a8db8dfdefa84b4444a7ae668d0e24f53e9Selim Cinek    }
178961633a8db8dfdefa84b4444a7ae668d0e24f53e9Selim Cinek
179061633a8db8dfdefa84b4444a7ae668d0e24f53e9Selim Cinek    @Override
17916183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek    protected boolean disallowSingleClick(MotionEvent event) {
17926183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek        float x = event.getX();
17936183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek        float y = event.getY();
179434eda5ed70863320e41b6860a550ba6a4248c652Selim Cinek        NotificationHeaderView header = getVisibleNotificationHeader();
17956183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek        if (header != null) {
1796a883351024f8dbdf8041c551f8a8987d9357dcd8Mady Mellor            return header.isInTouchRect(x - getTranslation(), y);
17976183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek        }
17986183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek        return super.disallowSingleClick(event);
17996183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek    }
18006183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek
180178403d79739605511ea88b653564d81d7bf4bbbaChris Wren    private void logExpansionEvent(boolean userAction, boolean wasExpanded) {
1802698b1706be196de41fc6bf03cf15971c82a11949Chris Wren        boolean nowExpanded = isExpanded();
1803698b1706be196de41fc6bf03cf15971c82a11949Chris Wren        if (mIsSummaryWithChildren) {
1804698b1706be196de41fc6bf03cf15971c82a11949Chris Wren            nowExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification);
1805698b1706be196de41fc6bf03cf15971c82a11949Chris Wren        }
180678403d79739605511ea88b653564d81d7bf4bbbaChris Wren        if (wasExpanded != nowExpanded && mLogger != null) {
180778403d79739605511ea88b653564d81d7bf4bbbaChris Wren            mLogger.logNotificationExpansion(mLoggingKey, userAction, nowExpanded) ;
180878403d79739605511ea88b653564d81d7bf4bbbaChris Wren        }
180978403d79739605511ea88b653564d81d7bf4bbbaChris Wren    }
1810570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek
1811e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    @Override
1812e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
1813e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        super.onInitializeAccessibilityNodeInfoInternal(info);
1814e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        if (canViewBeDismissed()) {
1815e9bad242f38bebadae481a22b647cc153f093070Selim Cinek            info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_DISMISS);
1816e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        }
1817e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    }
1818e9bad242f38bebadae481a22b647cc153f093070Selim Cinek
1819e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    @Override
1820e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    public boolean performAccessibilityActionInternal(int action, Bundle arguments) {
1821e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        if (super.performAccessibilityActionInternal(action, arguments)) {
1822e9bad242f38bebadae481a22b647cc153f093070Selim Cinek            return true;
1823e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        }
1824e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        switch (action) {
1825e9bad242f38bebadae481a22b647cc153f093070Selim Cinek            case AccessibilityNodeInfo.ACTION_DISMISS:
1826e9bad242f38bebadae481a22b647cc153f093070Selim Cinek                NotificationStackScrollLayout.performDismiss(this, mGroupManager,
1827e9bad242f38bebadae481a22b647cc153f093070Selim Cinek                        true /* fromAccessibility */);
1828e9bad242f38bebadae481a22b647cc153f093070Selim Cinek                return true;
1829e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        }
1830e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        return false;
1831e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    }
1832e9bad242f38bebadae481a22b647cc153f093070Selim Cinek
1833e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    public boolean shouldRefocusOnDismiss() {
1834e9bad242f38bebadae481a22b647cc153f093070Selim Cinek        return mRefocusOnDismiss || isAccessibilityFocused();
1835e9bad242f38bebadae481a22b647cc153f093070Selim Cinek    }
1836e9bad242f38bebadae481a22b647cc153f093070Selim Cinek
1837570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek    public interface OnExpandClickListener {
183831aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek        void onExpandClicked(NotificationData.Entry clickedEntry, boolean nowExpanded);
1839570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek    }
1840bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek
1841bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek    @Override
1842bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek    public ExpandableViewState createNewViewState(StackScrollState stackScrollState) {
1843bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek        return new NotificationViewState(stackScrollState);
1844bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek    }
1845bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek
1846d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek    @Override
1847d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek    public boolean isAboveShelf() {
1848d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek        return mIsPinned || mHeadsupDisappearRunning || (mIsHeadsUp && mAboveShelf);
1849d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek    }
1850d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek
1851d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek    public void setAboveShelf(boolean aboveShelf) {
1852d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek        mAboveShelf = aboveShelf;
1853d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek    }
1854d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek
18550cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek    public class NotificationViewState extends ExpandableViewState {
1856bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek
1857bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek        private final StackScrollState mOverallState;
18580242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek
1859bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek
1860bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek        private NotificationViewState(StackScrollState stackScrollState) {
1861bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek            mOverallState = stackScrollState;
1862bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek        }
1863bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek
1864bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek        @Override
1865bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek        public void applyToView(View view) {
1866bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek            super.applyToView(view);
1867bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek            if (view instanceof ExpandableNotificationRow) {
1868bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek                ExpandableNotificationRow row = (ExpandableNotificationRow) view;
1869bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek                row.applyChildrenState(mOverallState);
1870bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek            }
1871bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek        }
18720cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek
18730cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek        @Override
18740cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek        protected void onYTranslationAnimationFinished() {
18750cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek            super.onYTranslationAnimationFinished();
18760cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek            if (mHeadsupDisappearRunning) {
1877cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek                setHeadsUpAnimatingAway(false);
18780cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek            }
18790cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek        }
18800cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek
18810cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek        @Override
18820cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek        public void animateTo(View child, AnimationProperties properties) {
18830cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek            super.animateTo(child, properties);
18840cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek            if (child instanceof ExpandableNotificationRow) {
18850cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek                ExpandableNotificationRow row = (ExpandableNotificationRow) child;
18860cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek                row.startChildAnimation(mOverallState, properties);
18870cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek            }
18880cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek        }
1889bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek    }
189051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren}
1891