ExpandableNotificationRow.java revision 9ce3285dc3a5da05d21b0b1c4628ea3bf86f6644
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; 5387d7945f0693d3ca943bfb6491d4eba3a8d7cc75Mady Mellorimport com.android.systemui.plugins.statusbar.NotificationMenuRowProvider.MenuItem; 54c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinekimport com.android.systemui.statusbar.notification.HybridNotificationView; 556743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinekimport com.android.systemui.statusbar.notification.NotificationUtils; 56a7d4f82c05f1c6ea5dd92a4871711d380b01100aSelim Cinekimport com.android.systemui.statusbar.notification.VisualStabilityManager; 57b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport com.android.systemui.statusbar.phone.NotificationGroupManager; 582a6ea9c2a1b52b0386270ec73e1e6d6a9b614a34Jason Monkimport com.android.systemui.statusbar.phone.StatusBar; 5931aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinekimport com.android.systemui.statusbar.policy.HeadsUpManager; 600cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinekimport com.android.systemui.statusbar.stack.AnimationProperties; 610cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinekimport com.android.systemui.statusbar.stack.ExpandableViewState; 62b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport com.android.systemui.statusbar.stack.NotificationChildrenContainer; 63e9bad242f38bebadae481a22b647cc153f093070Selim Cinekimport com.android.systemui.statusbar.stack.NotificationStackScrollLayout; 64b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport com.android.systemui.statusbar.stack.StackScrollState; 65b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 664b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellorimport java.util.ArrayList; 67b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport java.util.List; 68a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler 694222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggipublic class ExpandableNotificationRow extends ActivatableNotificationView { 70b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 71b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private static final int DEFAULT_DIVIDER_ALPHA = 0x29; 72b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private static final int COLORED_DIVIDER_ALPHA = 0x7B; 730242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek private int mIconTransformContentShift; 74875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek private int mIconTransformContentShiftNoIcon; 7501af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek private int mNotificationMinHeightLegacy; 7601af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek private int mMaxHeadsUpHeightLegacy; 7701af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek private int mMaxHeadsUpHeight; 7887ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek private int mMaxHeadsUpHeightIncreased; 7901af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek private int mNotificationMinHeight; 807d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek private int mNotificationMinHeightLarge; 8101af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek private int mNotificationMaxHeight; 820aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos private int mNotificationAmbientHeight; 83b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor private int mIncreasedPaddingBetweenElements; 8451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 851685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** Does this row contain layouts that can adapt to row expansion */ 8651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren private boolean mExpandable; 871685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** Has the user actively changed the expansion state of this row */ 881685e634fb0b14033bd436af8d7174436699ffecSelim Cinek private boolean mHasUserChangedExpansion; 891685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** If {@link #mHasUserChangedExpansion}, has the user expanded this row */ 9051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren private boolean mUserExpanded; 9131aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek 9231aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek /** 9331aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek * Has this notification been expanded while it was pinned 9431aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek */ 9531aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek private boolean mExpandedWhenPinned; 961685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** Is the user touching this row */ 9751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren private boolean mUserLocked; 981685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** Are we showing the "public" version */ 99a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler private boolean mShowingPublic; 100ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi private boolean mSensitive; 1013c76d509d362cf5086a63722ab41e04f5d539182Selim Cinek private boolean mSensitiveHiddenInGeneral; 102ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi private boolean mShowingPublicInitialized; 10360122be6747c4f79b96f6808158f8f7e7548b7d3Selim Cinek private boolean mHideSensitiveForIntrinsicHeight; 10451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 1051685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** 1061685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * Is this notification expanded by the system. The expansion state can be overridden by the 1071685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * user expansion. 1081685e634fb0b14033bd436af8d7174436699ffecSelim Cinek */ 1091685e634fb0b14033bd436af8d7174436699ffecSelim Cinek private boolean mIsSystemExpanded; 110dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi 111dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi /** 11283bc78338437a460076a4b5778ded38440ac3501Selim Cinek * Whether the notification is on the keyguard and the expansion is disabled. 113dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi */ 11483bc78338437a460076a4b5778ded38440ac3501Selim Cinek private boolean mOnKeyguard; 115dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi 116b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor private Animator mTranslateAnim; 1174b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor private ArrayList<View> mTranslateableViews; 118be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi private NotificationContentView mPublicLayout; 119be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi private NotificationContentView mPrivateLayout; 120eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos private NotificationContentView[] mLayouts; 1211685e634fb0b14033bd436af8d7174436699ffecSelim Cinek private int mMaxExpandHeight; 1228d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek private int mHeadsUpHeight; 1234bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek private int mNotificationColor; 12478403d79739605511ea88b653564d81d7bf4bbbaChris Wren private ExpansionLogger mLogger; 12578403d79739605511ea88b653564d81d7bf4bbbaChris Wren private String mLoggingKey; 126761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor private NotificationMenuRow mMenuRow; 1278d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek private NotificationGuts mGuts; 128da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek private NotificationData.Entry mEntry; 129b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi private StatusBarNotification mStatusBarNotification; 1303fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor private String mAppName; 1311a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek private boolean mIsHeadsUp; 13298713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek private boolean mLastChronometerRunning = true; 133b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private ViewStub mChildrenContainerStub; 134b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private NotificationGroupManager mGroupManager; 135b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private boolean mChildrenExpanded; 136263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek private boolean mIsSummaryWithChildren; 137b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private NotificationChildrenContainer mChildrenContainer; 138761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor private ViewStub mMenuRowStub; 139ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek private ViewStub mGutsStub; 140b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private boolean mIsSystemChildExpanded; 141684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek private boolean mIsPinned; 1420e2ffbd48bbedf47deb7f6aed96bd07e2fc96f53Blazej Magnowski private FalsingManager mFalsingManager; 14331aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek private HeadsUpManager mHeadsUpManager; 144b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi 1455eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi private boolean mJustClicked; 1465a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek private boolean mIconAnimationRunning; 14734d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek private boolean mShowNoBackground; 148388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek private ExpandableNotificationRow mNotificationParent; 149570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek private OnExpandClickListener mOnExpandClickListener; 150b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor private boolean mGroupExpansionChanging; 151b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor 152eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek private OnClickListener mExpandClickListener = new OnClickListener() { 153eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek @Override 154eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek public void onClick(View v) { 155624c02db7f1d24ec1e307530ff32d4fd5859feaeSelim Cinek if (!mShowingPublic && mGroupManager.isSummaryOfGroup(mStatusBarNotification)) { 1561a5d8eadd56b435843dfbc1adf3779aa7286081bMady Mellor mGroupExpansionChanging = true; 157698b1706be196de41fc6bf03cf15971c82a11949Chris Wren final boolean wasExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification); 158698b1706be196de41fc6bf03cf15971c82a11949Chris Wren boolean nowExpanded = mGroupManager.toggleGroupExpansion(mStatusBarNotification); 159698b1706be196de41fc6bf03cf15971c82a11949Chris Wren mOnExpandClickListener.onExpandClicked(mEntry, nowExpanded); 160698b1706be196de41fc6bf03cf15971c82a11949Chris Wren MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTIFICATION_GROUP_EXPANDER, 161698b1706be196de41fc6bf03cf15971c82a11949Chris Wren nowExpanded); 162698b1706be196de41fc6bf03cf15971c82a11949Chris Wren logExpansionEvent(true /* userAction */, wasExpanded); 163eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek } else { 164e9bad242f38bebadae481a22b647cc153f093070Selim Cinek if (v.isAccessibilityFocused()) { 165e9bad242f38bebadae481a22b647cc153f093070Selim Cinek mPrivateLayout.setFocusOnVisibilityChange(); 166e9bad242f38bebadae481a22b647cc153f093070Selim Cinek } 16731aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek boolean nowExpanded; 16831aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek if (isPinned()) { 16931aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek nowExpanded = !mExpandedWhenPinned; 17031aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek mExpandedWhenPinned = nowExpanded; 17131aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek } else { 17231aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek nowExpanded = !isExpanded(); 17331aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek setUserExpanded(nowExpanded); 17431aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek } 175eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek notifyHeightChanged(true); 17631aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek mOnExpandClickListener.onExpandClicked(mEntry, nowExpanded); 177698b1706be196de41fc6bf03cf15971c82a11949Chris Wren MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTIFICATION_EXPANDER, 178698b1706be196de41fc6bf03cf15971c82a11949Chris Wren nowExpanded); 179eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek } 180eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek } 181eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek }; 1821b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek private boolean mForceUnlocked; 1833f19f60d654421eee5b35a92129081f08c977629Selim Cinek private boolean mDismissed; 1843f19f60d654421eee5b35a92129081f08c977629Selim Cinek private boolean mKeepInParent; 1853f19f60d654421eee5b35a92129081f08c977629Selim Cinek private boolean mRemoved; 186b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor private static final Property<ExpandableNotificationRow, Float> TRANSLATE_CONTENT = 187b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor new FloatProperty<ExpandableNotificationRow>("translate") { 188b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor @Override 189b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor public void setValue(ExpandableNotificationRow object, float value) { 190b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor object.setTranslation(value); 191b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 192b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor 193b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor @Override 194b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor public Float get(ExpandableNotificationRow object) { 195b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor return object.getTranslation(); 196b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 197b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor }; 198ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek private OnClickListener mOnClickListener; 19973cf02a0783e3857cae21fece9c292abcc9e1409Selim Cinek private boolean mHeadsupDisappearRunning; 200e9bad242f38bebadae481a22b647cc153f093070Selim Cinek private View mChildAfterViewWhenDismissed; 201e9bad242f38bebadae481a22b647cc153f093070Selim Cinek private View mGroupParentWhenDismissed; 202e9bad242f38bebadae481a22b647cc153f093070Selim Cinek private boolean mRefocusOnDismiss; 2032b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek private float mContentTransformationAmount; 2040242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek private boolean mIconsVisible = true; 205d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek private boolean mAboveShelf; 2060aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos private boolean mShowAmbient; 207875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek private boolean mIsLastChild; 208e907911e63c979f36d4297aa9eefef1f194daecbSelim Cinek private Runnable mOnDismissRunnable; 2096743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek private boolean mIsLowPriority; 210a7ed2c1aaa49f0f53507fa3b7e832dca15997a3bSelim Cinek private boolean mIsColorized; 2117d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek private boolean mUseIncreasedCollapsedHeight; 21287ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek private boolean mUseIncreasedHeadsUpHeight; 213ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek private float mTranslationWhenRemoved; 214ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek private boolean mWasChildInGroupWhenRemoved; 215b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor 21643c2cd1a4071e152e9f4aa9044b03a29cd5ada31Mady Mellor @Override 217b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor public boolean isGroupExpansionChanging() { 218b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor if (isChildInGroup()) { 219b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor return mNotificationParent.isGroupExpansionChanging(); 220b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 221b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor return mGroupExpansionChanging; 222b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 223b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor 224b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor public void setGroupExpansionChanging(boolean changing) { 225b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mGroupExpansionChanging = changing; 226b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 2275eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi 228599be34e6e3274e97512f3970a0d6edddedb8eb4Adrian Roos @Override 229599be34e6e3274e97512f3970a0d6edddedb8eb4Adrian Roos public void setActualHeightAnimating(boolean animating) { 230599be34e6e3274e97512f3970a0d6edddedb8eb4Adrian Roos if (mPrivateLayout != null) { 231599be34e6e3274e97512f3970a0d6edddedb8eb4Adrian Roos mPrivateLayout.setContentHeightAnimating(animating); 232599be34e6e3274e97512f3970a0d6edddedb8eb4Adrian Roos } 233599be34e6e3274e97512f3970a0d6edddedb8eb4Adrian Roos } 234599be34e6e3274e97512f3970a0d6edddedb8eb4Adrian Roos 2358d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek public NotificationContentView getPrivateLayout() { 2368d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek return mPrivateLayout; 2378d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek } 2388d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek 2398d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek public NotificationContentView getPublicLayout() { 2408d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek return mPublicLayout; 2418d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek } 2428d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek 243cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek public void setIconAnimationRunning(boolean running) { 244eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos for (NotificationContentView l : mLayouts) { 245eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos setIconAnimationRunning(running, l); 246eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos } 2475a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek if (mIsSummaryWithChildren) { 248b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor setIconAnimationRunningForChild(running, mChildrenContainer.getHeaderView()); 2495a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek List<ExpandableNotificationRow> notificationChildren = 2505a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek mChildrenContainer.getNotificationChildren(); 2515a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek for (int i = 0; i < notificationChildren.size(); i++) { 2525a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek ExpandableNotificationRow child = notificationChildren.get(i); 2535a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek child.setIconAnimationRunning(running); 2545a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek } 2555a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek } 2565a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek mIconAnimationRunning = running; 257cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 258cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek 259cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek private void setIconAnimationRunning(boolean running, NotificationContentView layout) { 260cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek if (layout != null) { 261cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek View contractedChild = layout.getContractedChild(); 262cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek View expandedChild = layout.getExpandedChild(); 2638d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek View headsUpChild = layout.getHeadsUpChild(); 264cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek setIconAnimationRunningForChild(running, contractedChild); 265cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek setIconAnimationRunningForChild(running, expandedChild); 2668d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek setIconAnimationRunningForChild(running, headsUpChild); 267cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 268cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 269cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek 270cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek private void setIconAnimationRunningForChild(boolean running, View child) { 271cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek if (child != null) { 272cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek ImageView icon = (ImageView) child.findViewById(com.android.internal.R.id.icon); 273cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek setIconRunning(icon, running); 274cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek ImageView rightIcon = (ImageView) child.findViewById( 275cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek com.android.internal.R.id.right_icon); 276cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek setIconRunning(rightIcon, running); 277cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 278cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 279cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek 280cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek private void setIconRunning(ImageView imageView, boolean running) { 281cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek if (imageView != null) { 282cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek Drawable drawable = imageView.getDrawable(); 283cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek if (drawable instanceof AnimationDrawable) { 284cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek AnimationDrawable animationDrawable = (AnimationDrawable) drawable; 285cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek if (running) { 286cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek animationDrawable.start(); 287cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } else { 288cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek animationDrawable.stop(); 289cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 290cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } else if (drawable instanceof AnimatedVectorDrawable) { 291cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek AnimatedVectorDrawable animationDrawable = (AnimatedVectorDrawable) drawable; 292cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek if (running) { 293cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek animationDrawable.start(); 294cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } else { 295cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek animationDrawable.stop(); 296cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 297cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 298cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 299cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 300cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek 301da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek public void onNotificationUpdated(NotificationData.Entry entry) { 302da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek mEntry = entry; 303da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek mStatusBarNotification = entry.notification; 304eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos for (NotificationContentView l : mLayouts) { 305eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos l.onNotificationUpdated(entry); 306eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos } 307a7ed2c1aaa49f0f53507fa3b7e832dca15997a3bSelim Cinek mIsColorized = mStatusBarNotification.getNotification().isColorized(); 308757d879966fdbff1b67c9ec6fd4b6c75152b991aSelim Cinek mShowingPublicInitialized = false; 3094bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek updateNotificationColor(); 3108fc93c90839e5d9dd52bca9dd97c198c0fe68af1Selim Cinek if (mIsSummaryWithChildren) { 311b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mChildrenContainer.recreateNotificationHeader(mExpandClickListener, mEntry.notification); 312c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek mChildrenContainer.onNotificationUpdated(); 3138fc93c90839e5d9dd52bca9dd97c198c0fe68af1Selim Cinek } 3145a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek if (mIconAnimationRunning) { 3155a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek setIconAnimationRunning(true); 3165a175d9d543c4438672990aa8a820bd1292bdd6aSelim Cinek } 317ea4bef7386ca6c6260f292bf006d16a99b93f698Selim Cinek if (mNotificationParent != null) { 318ea4bef7386ca6c6260f292bf006d16a99b93f698Selim Cinek mNotificationParent.updateChildrenHeaderAppearance(); 319ea4bef7386ca6c6260f292bf006d16a99b93f698Selim Cinek } 320263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek onChildrenCountChanged(); 321624c02db7f1d24ec1e307530ff32d4fd5859feaeSelim Cinek // The public layouts expand button is always visible 322624c02db7f1d24ec1e307530ff32d4fd5859feaeSelim Cinek mPublicLayout.updateExpandButtons(true); 323da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek updateLimits(); 3240242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek updateIconVisibilities(); 3256743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek updateShelfIconColor(); 3266743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek } 3276743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek 3286743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek private void updateShelfIconColor() { 3296743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek StatusBarIconView expandedIcon = mEntry.expandedIcon; 3306743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek boolean isPreL = Boolean.TRUE.equals(expandedIcon.getTag(R.id.icon_is_pre_L)); 3316743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek boolean colorize = !isPreL || NotificationUtils.isGrayscale(expandedIcon, 3326743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek NotificationColorUtil.getInstance(mContext)); 333875ba9bd8ec0fa3d29fe27efcb3a20e53ce85f4fSelim Cinek int color = StatusBarIconView.NO_COLOR; 3346743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek if (colorize) { 335875ba9bd8ec0fa3d29fe27efcb3a20e53ce85f4fSelim Cinek color = mEntry.getContrastedColor(mContext, mIsLowPriority && !isExpanded()); 3366743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek } 337875ba9bd8ec0fa3d29fe27efcb3a20e53ce85f4fSelim Cinek expandedIcon.setStaticDrawableColor(color); 338da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek } 339da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek 340da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek private void updateLimits() { 341eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos for (NotificationContentView l : mLayouts) { 342eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos updateLimitsForView(l); 343eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos } 344a1744872f4447dd370002a607c32776dffe519f5Selim Cinek } 345a1744872f4447dd370002a607c32776dffe519f5Selim Cinek 346a1744872f4447dd370002a607c32776dffe519f5Selim Cinek private void updateLimitsForView(NotificationContentView layout) { 347a1744872f4447dd370002a607c32776dffe519f5Selim Cinek boolean customView = layout.getContractedChild().getId() 348da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek != com.android.internal.R.id.status_bar_latest_event_content; 349da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek boolean beforeN = mEntry.targetSdk < Build.VERSION_CODES.N; 3507d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek int minHeight; 3517d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek if (customView && beforeN && !mIsSummaryWithChildren) { 3527d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek minHeight = mNotificationMinHeightLegacy; 3537d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek } else if (mUseIncreasedCollapsedHeight && layout == mPrivateLayout) { 3547d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek minHeight = mNotificationMinHeightLarge; 3557d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek } else { 3567d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek minHeight = mNotificationMinHeight; 3577d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek } 358a1744872f4447dd370002a607c32776dffe519f5Selim Cinek boolean headsUpCustom = layout.getHeadsUpChild() != null && 359a1744872f4447dd370002a607c32776dffe519f5Selim Cinek layout.getHeadsUpChild().getId() 360a1744872f4447dd370002a607c32776dffe519f5Selim Cinek != com.android.internal.R.id.status_bar_latest_event_content; 36187ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek int headsUpheight; 36287ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek if (headsUpCustom && beforeN) { 36387ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek headsUpheight = mMaxHeadsUpHeightLegacy; 36487ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek } else if (mUseIncreasedHeadsUpHeight && layout == mPrivateLayout) { 36587ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek headsUpheight = mMaxHeadsUpHeightIncreased; 36687ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek } else { 36787ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek headsUpheight = mMaxHeadsUpHeight; 36887ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek } 3690aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos layout.setHeights(minHeight, headsUpheight, mNotificationMaxHeight, 3700aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos mNotificationAmbientHeight); 371b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi } 372b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi 373b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi public StatusBarNotification getStatusBarNotification() { 374b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi return mStatusBarNotification; 375b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi } 376b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi 377281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek public NotificationData.Entry getEntry() { 378281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek return mEntry; 379281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek } 380281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek 381b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek public boolean isHeadsUp() { 382b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek return mIsHeadsUp; 383b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek } 384b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek 3851a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek public void setHeadsUp(boolean isHeadsUp) { 386c80fdb11f55f4c1f3ca9b5cdc7035afa2a0b9e91Selim Cinek int intrinsicBefore = getIntrinsicHeight(); 3871a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek mIsHeadsUp = isHeadsUp; 3888d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek mPrivateLayout.setHeadsUp(isHeadsUp); 389b41b2f6fc2bcce6da6d6ae855a2a36cfa6f7f99dSelim Cinek if (mIsSummaryWithChildren) { 390b41b2f6fc2bcce6da6d6ae855a2a36cfa6f7f99dSelim Cinek // The overflow might change since we allow more lines as HUN. 391b41b2f6fc2bcce6da6d6ae855a2a36cfa6f7f99dSelim Cinek mChildrenContainer.updateGroupOverflow(); 392b41b2f6fc2bcce6da6d6ae855a2a36cfa6f7f99dSelim Cinek } 393c80fdb11f55f4c1f3ca9b5cdc7035afa2a0b9e91Selim Cinek if (intrinsicBefore != getIntrinsicHeight()) { 394c80fdb11f55f4c1f3ca9b5cdc7035afa2a0b9e91Selim Cinek notifyHeightChanged(false /* needsAnimation */); 395c80fdb11f55f4c1f3ca9b5cdc7035afa2a0b9e91Selim Cinek } 396d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek if (isHeadsUp) { 397d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek setAboveShelf(true); 398d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek } 3991a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek } 4001a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek 401b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void setGroupManager(NotificationGroupManager groupManager) { 402b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mGroupManager = groupManager; 40383bc78338437a460076a4b5778ded38440ac3501Selim Cinek mPrivateLayout.setGroupManager(groupManager); 404b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 405b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 406b88b1a1dbde3364cd92d6a69a41ef2d4e2877294Adrian Roos public void setRemoteInputController(RemoteInputController r) { 407b88b1a1dbde3364cd92d6a69a41ef2d4e2877294Adrian Roos mPrivateLayout.setRemoteInputController(r); 408b88b1a1dbde3364cd92d6a69a41ef2d4e2877294Adrian Roos } 409b88b1a1dbde3364cd92d6a69a41ef2d4e2877294Adrian Roos 4103fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor public void setAppName(String appName) { 4113fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor mAppName = appName; 412761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor if (mMenuRow != null) { 413761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRow.setAppName(mAppName); 4143fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor } 4153fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor } 4163fd273e6113fb1b8986314a03ab6d7e90efd0beaMady Mellor 417b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void addChildNotification(ExpandableNotificationRow row) { 418b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek addChildNotification(row, -1); 419b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 420b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 421b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek /** 422b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * Add a child notification to this view. 423b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * 424b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * @param row the row to add 425b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * @param childIndex the index to add it at, if -1 it will be added at the end 426b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek */ 427b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void addChildNotification(ExpandableNotificationRow row, int childIndex) { 428b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek if (mChildrenContainer == null) { 429b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainerStub.inflate(); 430b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 431b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainer.addNotification(row, childIndex); 432263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek onChildrenCountChanged(); 433263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek row.setIsChildInGroup(true, this); 434b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 435b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 436b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void removeChildNotification(ExpandableNotificationRow row) { 437b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek if (mChildrenContainer != null) { 438b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainer.removeNotification(row); 439b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 440263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek onChildrenCountChanged(); 441263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek row.setIsChildInGroup(false, null); 442263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek } 443263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek 44443c2cd1a4071e152e9f4aa9044b03a29cd5ada31Mady Mellor @Override 445263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek public boolean isChildInGroup() { 446a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek return mNotificationParent != null; 447263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek } 448263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek 449388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek public ExpandableNotificationRow getNotificationParent() { 450388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek return mNotificationParent; 451388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek } 452388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek 453263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek /** 454263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek * @param isChildInGroup Is this notification now in a group 455263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek * @param parent the new parent notification 456263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek */ 457a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek public void setIsChildInGroup(boolean isChildInGroup, ExpandableNotificationRow parent) {; 4582a6ea9c2a1b52b0386270ec73e1e6d6a9b614a34Jason Monk boolean childInGroup = StatusBar.ENABLE_CHILD_NOTIFICATIONS && isChildInGroup; 459a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek mNotificationParent = childInGroup ? parent : null; 460a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek mPrivateLayout.setIsChildInGroup(childInGroup); 461c7d65b4e9c784a8235424c30620bacd54cc0892eMady Mellor resetBackgroundAlpha(); 462b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor updateBackgroundForGroupState(); 463ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek updateClickAndFocus(); 464b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor if (mNotificationParent != null) { 4659ce3285dc3a5da05d21b0b1c4628ea3bf86f6644Selim Cinek setOverrideTintColor(NO_COLOR, 0.0f); 466b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mNotificationParent.updateBackgroundForGroupState(); 467b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 468db16737031091160a3a7d080ac44ce2836402d74Selim Cinek updateIconVisibilities(); 46934d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek } 47034d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek 47134d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek @Override 4727210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek public boolean onTouchEvent(MotionEvent event) { 4737210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek if (event.getActionMasked() != MotionEvent.ACTION_DOWN 4747210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek || !isChildInGroup() || isGroupExpanded()) { 4757210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek return super.onTouchEvent(event); 4767210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek } else { 4777210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek return false; 4787210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek } 4797210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek } 4807210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek 4817210947e0d0e384fc34d61160c99adc2f36734e0Selim Cinek @Override 482f062580d395a8c99631c104d6aec250f961152ddMady Mellor protected boolean handleSlideBack() { 483761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor if (mMenuRow != null && mMenuRow.isVisible()) { 484f062580d395a8c99631c104d6aec250f961152ddMady Mellor animateTranslateNotification(0 /* targetLeft */); 485f062580d395a8c99631c104d6aec250f961152ddMady Mellor return true; 486f062580d395a8c99631c104d6aec250f961152ddMady Mellor } 487f062580d395a8c99631c104d6aec250f961152ddMady Mellor return false; 488f062580d395a8c99631c104d6aec250f961152ddMady Mellor } 489f062580d395a8c99631c104d6aec250f961152ddMady Mellor 490f062580d395a8c99631c104d6aec250f961152ddMady Mellor @Override 49134d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek protected boolean shouldHideBackground() { 49234d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek return super.shouldHideBackground() || mShowNoBackground; 493263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek } 494263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek 495263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek @Override 496263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek public boolean isSummaryWithChildren() { 497263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek return mIsSummaryWithChildren; 498b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 499b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 500b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek @Override 501b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public boolean areChildrenExpanded() { 502b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek return mChildrenExpanded; 503b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 504b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 505b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public List<ExpandableNotificationRow> getNotificationChildren() { 506b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek return mChildrenContainer == null ? null : mChildrenContainer.getNotificationChildren(); 507b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 508b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 509eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek public int getNumberOfNotificationChildren() { 510eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek if (mChildrenContainer == null) { 511eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek return 0; 512eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek } 513eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek return mChildrenContainer.getNotificationChildren().size(); 514eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek } 515eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek 516b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek /** 517b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * Apply the order given in the list to the children. 518b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * 519b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * @param childOrder the new list order 520a7d4f82c05f1c6ea5dd92a4871711d380b01100aSelim Cinek * @param visualStabilityManager 521a7d4f82c05f1c6ea5dd92a4871711d380b01100aSelim Cinek * @param callback the callback to invoked in case it is not allowed 522b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * @return whether the list order has changed 523b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek */ 524a7d4f82c05f1c6ea5dd92a4871711d380b01100aSelim Cinek public boolean applyChildOrder(List<ExpandableNotificationRow> childOrder, 525a7d4f82c05f1c6ea5dd92a4871711d380b01100aSelim Cinek VisualStabilityManager visualStabilityManager, 526a7d4f82c05f1c6ea5dd92a4871711d380b01100aSelim Cinek VisualStabilityManager.Callback callback) { 527a7d4f82c05f1c6ea5dd92a4871711d380b01100aSelim Cinek return mChildrenContainer != null && mChildrenContainer.applyChildOrder(childOrder, 528a7d4f82c05f1c6ea5dd92a4871711d380b01100aSelim Cinek visualStabilityManager, callback); 529b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 530b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 531b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void getChildrenStates(StackScrollState resultState) { 53283bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (mIsSummaryWithChildren) { 533bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek ExpandableViewState parentState = resultState.getViewStateForView(this); 534b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainer.getState(resultState, parentState); 535b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 536b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 537b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 538b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void applyChildrenState(StackScrollState state) { 53983bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (mIsSummaryWithChildren) { 540b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainer.applyState(state); 541b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 542b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 543b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 544b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void prepareExpansionChanged(StackScrollState state) { 54583bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (mIsSummaryWithChildren) { 546b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainer.prepareExpansionChanged(state); 547b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 548b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 549b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 5500cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek public void startChildAnimation(StackScrollState finalState, AnimationProperties properties) { 55183bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (mIsSummaryWithChildren) { 5520cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek mChildrenContainer.startAnimationToState(finalState, properties); 553b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 554b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 555b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 556b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public ExpandableNotificationRow getViewAtPosition(float y) { 55743d30f03f45f3f9ad3955f5c83f4d21f26891de6Selim Cinek if (!mIsSummaryWithChildren || !mChildrenExpanded) { 558b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek return this; 559b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } else { 560b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek ExpandableNotificationRow view = mChildrenContainer.getViewAtPosition(y); 561b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek return view == null ? this : view; 562b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 563b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 564b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 565ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek public NotificationGuts getGuts() { 566ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek return mGuts; 567ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek } 568ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek 569684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek /** 570684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek * Set this notification to be pinned to the top if {@link #isHeadsUp()} is true. By doing this 571684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek * the notification will be rendered on top of the screen. 572684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek * 573684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek * @param pinned whether it is pinned 574684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek */ 575684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek public void setPinned(boolean pinned) { 576def35a86530200958384191d43d321dbcda16e2aSelim Cinek int intrinsicHeight = getIntrinsicHeight(); 577684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek mIsPinned = pinned; 578def35a86530200958384191d43d321dbcda16e2aSelim Cinek if (intrinsicHeight != getIntrinsicHeight()) { 579bb42b7dd4892a8ab99f2f702cad931235d1d463eSelim Cinek notifyHeightChanged(false /* needsAnimation */); 580def35a86530200958384191d43d321dbcda16e2aSelim Cinek } 58131aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek if (pinned) { 58231aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek setIconAnimationRunning(true); 58331aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek mExpandedWhenPinned = false; 58431aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek } else if (mExpandedWhenPinned) { 58531aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek setUserExpanded(true); 58631aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek } 58798713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek setChronometerRunning(mLastChronometerRunning); 588b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek } 589b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek 590684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek public boolean isPinned() { 591684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek return mIsPinned; 592b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek } 593b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek 594d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek @Override 595d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek public int getPinnedHeadsUpHeight() { 596d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek return getPinnedHeadsUpHeight(true /* atLeastMinHeight */); 597d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek } 598d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek 59931aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek /** 60031aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek * @param atLeastMinHeight should the value returned be at least the minimum height. 60131aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek * Used to avoid cyclic calls 60231aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek * @return the height of the heads up notification when pinned 60331aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek */ 604d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek private int getPinnedHeadsUpHeight(boolean atLeastMinHeight) { 60577019c72332cb31dd1cb713ea4c66e267e6cbf39Selim Cinek if (mIsSummaryWithChildren) { 60677019c72332cb31dd1cb713ea4c66e267e6cbf39Selim Cinek return mChildrenContainer.getIntrinsicHeight(); 60777019c72332cb31dd1cb713ea4c66e267e6cbf39Selim Cinek } 60831aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek if(mExpandedWhenPinned) { 60931aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek return Math.max(getMaxExpandHeight(), mHeadsUpHeight); 61031aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek } else if (atLeastMinHeight) { 611567e845d99840a6e556595739a15e16132eb2f1eSelim Cinek return Math.max(getCollapsedHeight(), mHeadsUpHeight); 61231aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek } else { 61331aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek return mHeadsUpHeight; 61431aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek } 615b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek } 616b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek 6175eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi /** 6185eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi * Mark whether this notification was just clicked, i.e. the user has just clicked this 6195eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi * notification in this frame. 6205eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi */ 6215eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi public void setJustClicked(boolean justClicked) { 6225eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi mJustClicked = justClicked; 6235eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi } 6245eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi 6255eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi /** 6265eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi * @return true if this notification has been clicked in this frame, false otherwise 6275eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi */ 6285eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi public boolean wasJustClicked() { 6295eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi return mJustClicked; 6305eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi } 6315eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi 63298713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek public void setChronometerRunning(boolean running) { 63398713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek mLastChronometerRunning = running; 63498713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek setChronometerRunning(running, mPrivateLayout); 63598713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek setChronometerRunning(running, mPublicLayout); 63698713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek if (mChildrenContainer != null) { 63798713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek List<ExpandableNotificationRow> notificationChildren = 63898713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek mChildrenContainer.getNotificationChildren(); 63998713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek for (int i = 0; i < notificationChildren.size(); i++) { 64098713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek ExpandableNotificationRow child = notificationChildren.get(i); 64198713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek child.setChronometerRunning(running); 64298713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 64398713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 64498713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 64598713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek 64698713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek private void setChronometerRunning(boolean running, NotificationContentView layout) { 64798713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek if (layout != null) { 64898713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek running = running || isPinned(); 64998713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek View contractedChild = layout.getContractedChild(); 65098713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek View expandedChild = layout.getExpandedChild(); 65198713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek View headsUpChild = layout.getHeadsUpChild(); 65298713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek setChronometerRunningForChild(running, contractedChild); 65398713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek setChronometerRunningForChild(running, expandedChild); 65498713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek setChronometerRunningForChild(running, headsUpChild); 65598713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 65698713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 65798713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek 65898713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek private void setChronometerRunningForChild(boolean running, View child) { 65998713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek if (child != null) { 66098713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek View chronometer = child.findViewById(com.android.internal.R.id.chronometer); 66198713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek if (chronometer instanceof Chronometer) { 66298713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek ((Chronometer) chronometer).setStarted(running); 66398713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 66498713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 66598713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 66698713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek 667ea4bef7386ca6c6260f292bf006d16a99b93f698Selim Cinek public NotificationHeaderView getNotificationHeader() { 668b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor if (mIsSummaryWithChildren) { 669b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor return mChildrenContainer.getHeaderView(); 6708d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek } 671ea4bef7386ca6c6260f292bf006d16a99b93f698Selim Cinek return mPrivateLayout.getNotificationHeader(); 6728d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek } 6738d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek 67434eda5ed70863320e41b6860a550ba6a4248c652Selim Cinek private NotificationHeaderView getVisibleNotificationHeader() { 675aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek if (mIsSummaryWithChildren && !mShowingPublic) { 676b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor return mChildrenContainer.getHeaderView(); 67734eda5ed70863320e41b6860a550ba6a4248c652Selim Cinek } 67834eda5ed70863320e41b6860a550ba6a4248c652Selim Cinek return getShowingLayout().getVisibleNotificationHeader(); 67934eda5ed70863320e41b6860a550ba6a4248c652Selim Cinek } 68034eda5ed70863320e41b6860a550ba6a4248c652Selim Cinek 681570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek public void setOnExpandClickListener(OnExpandClickListener onExpandClickListener) { 682570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek mOnExpandClickListener = onExpandClickListener; 683570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek } 684570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek 685ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek @Override 686ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek public void setOnClickListener(@Nullable OnClickListener l) { 687ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek super.setOnClickListener(l); 688ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek mOnClickListener = l; 689ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek updateClickAndFocus(); 690ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek } 691ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek 692ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek private void updateClickAndFocus() { 693ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek boolean normalChild = !isChildInGroup() || isGroupExpanded(); 694ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek boolean clickable = mOnClickListener != null && normalChild; 695ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek if (isFocusable() != normalChild) { 696ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek setFocusable(normalChild); 697ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek } 698ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek if (isClickable() != clickable) { 699ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek setClickable(clickable); 700ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek } 701ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek } 702ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek 70331aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek public void setHeadsUpManager(HeadsUpManager headsUpManager) { 70431aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek mHeadsUpManager = headsUpManager; 70531aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek } 70631aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek 70787d7945f0693d3ca943bfb6491d4eba3a8d7cc75Mady Mellor public void setGutsView(MenuItem item) { 70887d7945f0693d3ca943bfb6491d4eba3a8d7cc75Mady Mellor if (mGuts != null) { 70987d7945f0693d3ca943bfb6491d4eba3a8d7cc75Mady Mellor item.gutsContent.setInteractionListener(mGuts); 71087d7945f0693d3ca943bfb6491d4eba3a8d7cc75Mady Mellor mGuts.setGutsContent(item.gutsContent); 71187d7945f0693d3ca943bfb6491d4eba3a8d7cc75Mady Mellor } 71287d7945f0693d3ca943bfb6491d4eba3a8d7cc75Mady Mellor } 71387d7945f0693d3ca943bfb6491d4eba3a8d7cc75Mady Mellor 71401af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek public void reInflateViews() { 71501af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek initDimens(); 71601af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek if (mIsSummaryWithChildren) { 71701af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek if (mChildrenContainer != null) { 718b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mChildrenContainer.reInflateViews(mExpandClickListener, mEntry.notification); 71901af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek } 72001af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek } 72101af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek if (mGuts != null) { 72201af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek View oldGuts = mGuts; 72301af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek int index = indexOfChild(oldGuts); 72401af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek removeView(oldGuts); 72501af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek mGuts = (NotificationGuts) LayoutInflater.from(mContext).inflate( 72601af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek R.layout.notification_guts, this, false); 72701af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek mGuts.setVisibility(oldGuts.getVisibility()); 72801af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek addView(mGuts, index); 72901af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek } 730761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor if (mMenuRow != null) { 731761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor View oldMenu = mMenuRow; 732761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor int menuIndex = indexOfChild(oldMenu); 733761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor removeView(oldMenu); 734761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRow = (NotificationMenuRow) LayoutInflater.from(mContext).inflate( 735761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor R.layout.notification_menu_row, this, false); 736761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRow.setNotificationRowParent(ExpandableNotificationRow.this); 737761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRow.setAppName(mAppName); 738761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRow.setVisibility(oldMenu.getVisibility()); 739761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor addView(mMenuRow, menuIndex); 7404b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor 7414b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 742eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos for (NotificationContentView l : mLayouts) { 743eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos l.reInflateViews(); 744eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos } 74501af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek } 74601af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek 747c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek public void setContentBackground(int customBackgroundColor, boolean animate, 748c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek NotificationContentView notificationContentView) { 749c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek if (getShowingLayout() == notificationContentView) { 750c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek setTintColor(customBackgroundColor, animate); 751c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek } 752c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek } 753c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek 7540bd8a4b29bf92a901855d889c53186383dd2c5e7Adrian Roos public void closeRemoteInput() { 755eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos for (NotificationContentView l : mLayouts) { 756eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos l.closeRemoteInput(); 757eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos } 7580bd8a4b29bf92a901855d889c53186383dd2c5e7Adrian Roos } 7590bd8a4b29bf92a901855d889c53186383dd2c5e7Adrian Roos 760c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek /** 761c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek * Set by how much the single line view should be indented. 762c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek */ 763c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek public void setSingleLineWidthIndention(int indention) { 764c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek mPrivateLayout.setSingleLineWidthIndention(indention); 765c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek } 766c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek 767c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek public int getNotificationColor() { 7684bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek return mNotificationColor; 7694bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek } 7704bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek 7714bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek private void updateNotificationColor() { 7724bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek mNotificationColor = NotificationColorUtil.resolveContrastColor(mContext, 7734bb593492ccf560382fac9ae533a7429cec53c94Selim Cinek getStatusBarNotification().getNotification().color); 774c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek } 775c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek 776c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek public HybridNotificationView getSingleLineView() { 777c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek return mPrivateLayout.getSingleLineView(); 778c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek } 779c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek 780f07d06212b08939809aa4128f153bd5179f81fc7Selim Cinek public boolean isOnKeyguard() { 781f07d06212b08939809aa4128f153bd5179f81fc7Selim Cinek return mOnKeyguard; 782f07d06212b08939809aa4128f153bd5179f81fc7Selim Cinek } 783f07d06212b08939809aa4128f153bd5179f81fc7Selim Cinek 784c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek public void removeAllChildren() { 785c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek List<ExpandableNotificationRow> notificationChildren 786c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek = mChildrenContainer.getNotificationChildren(); 787c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek ArrayList<ExpandableNotificationRow> clonedList = new ArrayList<>(notificationChildren); 788c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek for (int i = 0; i < clonedList.size(); i++) { 789c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek ExpandableNotificationRow row = clonedList.get(i); 7903f19f60d654421eee5b35a92129081f08c977629Selim Cinek if (row.keepInParent()) { 7913f19f60d654421eee5b35a92129081f08c977629Selim Cinek continue; 7923f19f60d654421eee5b35a92129081f08c977629Selim Cinek } 793c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek mChildrenContainer.removeNotification(row); 794c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek row.setIsChildInGroup(false, null); 795c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek } 796c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek onChildrenCountChanged(); 797c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek } 798c1e389dadc234827354b95bac98a9c7146ed301cSelim Cinek 7991b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek public void setForceUnlocked(boolean forceUnlocked) { 8001b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek mForceUnlocked = forceUnlocked; 8011b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek if (mIsSummaryWithChildren) { 8021b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek List<ExpandableNotificationRow> notificationChildren = getNotificationChildren(); 8031b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek for (ExpandableNotificationRow child : notificationChildren) { 8041b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek child.setForceUnlocked(forceUnlocked); 8051b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek } 8061b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek } 8071b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek } 8081b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek 809e9bad242f38bebadae481a22b647cc153f093070Selim Cinek public void setDismissed(boolean dismissed, boolean fromAccessibility) { 8103f19f60d654421eee5b35a92129081f08c977629Selim Cinek mDismissed = dismissed; 811e9bad242f38bebadae481a22b647cc153f093070Selim Cinek mGroupParentWhenDismissed = mNotificationParent; 812e9bad242f38bebadae481a22b647cc153f093070Selim Cinek mRefocusOnDismiss = fromAccessibility; 813e9bad242f38bebadae481a22b647cc153f093070Selim Cinek mChildAfterViewWhenDismissed = null; 814e9bad242f38bebadae481a22b647cc153f093070Selim Cinek if (isChildInGroup()) { 815e9bad242f38bebadae481a22b647cc153f093070Selim Cinek List<ExpandableNotificationRow> notificationChildren = 816e9bad242f38bebadae481a22b647cc153f093070Selim Cinek mNotificationParent.getNotificationChildren(); 817e9bad242f38bebadae481a22b647cc153f093070Selim Cinek int i = notificationChildren.indexOf(this); 818e9bad242f38bebadae481a22b647cc153f093070Selim Cinek if (i != -1 && i < notificationChildren.size() - 1) { 819e9bad242f38bebadae481a22b647cc153f093070Selim Cinek mChildAfterViewWhenDismissed = notificationChildren.get(i + 1); 820e9bad242f38bebadae481a22b647cc153f093070Selim Cinek } 821e9bad242f38bebadae481a22b647cc153f093070Selim Cinek } 8223f19f60d654421eee5b35a92129081f08c977629Selim Cinek } 8233f19f60d654421eee5b35a92129081f08c977629Selim Cinek 8243f19f60d654421eee5b35a92129081f08c977629Selim Cinek public boolean isDismissed() { 8253f19f60d654421eee5b35a92129081f08c977629Selim Cinek return mDismissed; 8263f19f60d654421eee5b35a92129081f08c977629Selim Cinek } 8273f19f60d654421eee5b35a92129081f08c977629Selim Cinek 8283f19f60d654421eee5b35a92129081f08c977629Selim Cinek public boolean keepInParent() { 8293f19f60d654421eee5b35a92129081f08c977629Selim Cinek return mKeepInParent; 8303f19f60d654421eee5b35a92129081f08c977629Selim Cinek } 8313f19f60d654421eee5b35a92129081f08c977629Selim Cinek 8323f19f60d654421eee5b35a92129081f08c977629Selim Cinek public void setKeepInParent(boolean keepInParent) { 8333f19f60d654421eee5b35a92129081f08c977629Selim Cinek mKeepInParent = keepInParent; 8343f19f60d654421eee5b35a92129081f08c977629Selim Cinek } 8353f19f60d654421eee5b35a92129081f08c977629Selim Cinek 8363f19f60d654421eee5b35a92129081f08c977629Selim Cinek public boolean isRemoved() { 8373f19f60d654421eee5b35a92129081f08c977629Selim Cinek return mRemoved; 8383f19f60d654421eee5b35a92129081f08c977629Selim Cinek } 8393f19f60d654421eee5b35a92129081f08c977629Selim Cinek 840d009ab1e2a57648cac9de93912964e2a36ae1762Adrian Roos public void setRemoved() { 841d009ab1e2a57648cac9de93912964e2a36ae1762Adrian Roos mRemoved = true; 842ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek mTranslationWhenRemoved = getTranslationY(); 843ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek mWasChildInGroupWhenRemoved = isChildInGroup(); 844ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek if (isChildInGroup()) { 845ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek mTranslationWhenRemoved += getNotificationParent().getTranslationY(); 846ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek } 847d009ab1e2a57648cac9de93912964e2a36ae1762Adrian Roos mPrivateLayout.setRemoved(); 8483f19f60d654421eee5b35a92129081f08c977629Selim Cinek } 8493f19f60d654421eee5b35a92129081f08c977629Selim Cinek 850ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek public boolean wasChildInGroupWhenRemoved() { 851ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek return mWasChildInGroupWhenRemoved; 852ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek } 853ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek 854ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek public float getTranslationWhenRemoved() { 855ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek return mTranslationWhenRemoved; 856ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek } 857ef8c2257045f73f0576c90c05c715c5f31ef81d8Selim Cinek 858d13956475e97da9de83f6519eab514770118e7afSelim Cinek public NotificationChildrenContainer getChildrenContainer() { 859d13956475e97da9de83f6519eab514770118e7afSelim Cinek return mChildrenContainer; 860d13956475e97da9de83f6519eab514770118e7afSelim Cinek } 861d13956475e97da9de83f6519eab514770118e7afSelim Cinek 862cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) { 863cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek mHeadsupDisappearRunning = headsUpAnimatingAway; 864cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek mPrivateLayout.setHeadsUpAnimatingAway(headsUpAnimatingAway); 865cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek } 866cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek 867cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek /** 868cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek * @return if the view was just heads upped and is now animating away. During such a time the 869cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek * layout needs to be kept consistent 870cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek */ 871cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek public boolean isHeadsUpAnimatingAway() { 872cafa87f91da77cd2bc7f4a18bd12f6b71df23b5cSelim Cinek return mHeadsupDisappearRunning; 87373cf02a0783e3857cae21fece9c292abcc9e1409Selim Cinek } 87473cf02a0783e3857cae21fece9c292abcc9e1409Selim Cinek 875e9bad242f38bebadae481a22b647cc153f093070Selim Cinek public View getChildAfterViewWhenDismissed() { 876e9bad242f38bebadae481a22b647cc153f093070Selim Cinek return mChildAfterViewWhenDismissed; 877e9bad242f38bebadae481a22b647cc153f093070Selim Cinek } 878e9bad242f38bebadae481a22b647cc153f093070Selim Cinek 879e9bad242f38bebadae481a22b647cc153f093070Selim Cinek public View getGroupParentWhenDismissed() { 880e9bad242f38bebadae481a22b647cc153f093070Selim Cinek return mGroupParentWhenDismissed; 881e9bad242f38bebadae481a22b647cc153f093070Selim Cinek } 882e9bad242f38bebadae481a22b647cc153f093070Selim Cinek 8839e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek public void performDismiss() { 884e907911e63c979f36d4297aa9eefef1f194daecbSelim Cinek if (mOnDismissRunnable != null) { 885e907911e63c979f36d4297aa9eefef1f194daecbSelim Cinek mOnDismissRunnable.run(); 886e907911e63c979f36d4297aa9eefef1f194daecbSelim Cinek } 8879e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek } 8889e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek 889e907911e63c979f36d4297aa9eefef1f194daecbSelim Cinek public void setOnDismissRunnable(Runnable onDismissRunnable) { 890e907911e63c979f36d4297aa9eefef1f194daecbSelim Cinek mOnDismissRunnable = onDismissRunnable; 8919e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek } 8929e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek 893281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek public View getNotificationIcon() { 894281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek NotificationHeaderView notificationHeader = getNotificationHeader(); 895281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek if (notificationHeader != null) { 896281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek return notificationHeader.getIcon(); 897281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek } 898281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek return null; 899281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek } 900281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek 901281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek /** 902281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek * @return whether the notification is currently showing a view with an icon. 903281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek */ 904281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek public boolean isShowingIcon() { 905281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek if (mIsSummaryWithChildren) { 906281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek return true; 907281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek } 908281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek NotificationContentView showingLayout = getShowingLayout(); 909281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek NotificationHeaderView notificationHeader = showingLayout.getVisibleNotificationHeader(); 910281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek return notificationHeader != null; 911281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek } 912281c202784fe6eecab4cc535461f1b12c85b2cc0Selim Cinek 9130242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek /** 9140242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek * Set how much this notification is transformed into an icon. 9150242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek * 9162b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek * @param contentTransformationAmount A value from 0 to 1 indicating how much we are transformed 9172b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek * to the content away 918875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek * @param isLastChild is this the last child in the list. If true, then the transformation is 919875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek * different since it's content fades out. 9200242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek */ 9212b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek public void setContentTransformationAmount(float contentTransformationAmount, 9222b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek boolean isLastChild) { 923875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek boolean changeTransformation = isLastChild != mIsLastChild; 9242b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek changeTransformation |= mContentTransformationAmount != contentTransformationAmount; 925875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek mIsLastChild = isLastChild; 9262b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek mContentTransformationAmount = contentTransformationAmount; 927875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek if (changeTransformation) { 928875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek updateContentTransformation(); 9292b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek } 9302b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek } 9312b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek 9322b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek /** 9332b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek * Set the icons to be visible of this notification. 9342b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek */ 9352b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek public void setIconsVisible(boolean iconsVisible) { 9362b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek if (iconsVisible != mIconsVisible) { 9372b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek mIconsVisible = iconsVisible; 9382b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek updateIconVisibilities(); 9390242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek } 9400242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek } 9410242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek 942db16737031091160a3a7d080ac44ce2836402d74Selim Cinek @Override 943db16737031091160a3a7d080ac44ce2836402d74Selim Cinek protected void onBelowSpeedBumpChanged() { 944db16737031091160a3a7d080ac44ce2836402d74Selim Cinek updateIconVisibilities(); 945db16737031091160a3a7d080ac44ce2836402d74Selim Cinek } 946db16737031091160a3a7d080ac44ce2836402d74Selim Cinek 947875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek private void updateContentTransformation() { 948875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek float contentAlpha; 9492b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek float translationY = -mContentTransformationAmount * mIconTransformContentShift; 950875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek if (mIsLastChild) { 9512b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek contentAlpha = 1.0f - mContentTransformationAmount; 952875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek contentAlpha = Math.min(contentAlpha / 0.5f, 1.0f); 9530242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek contentAlpha = Interpolators.ALPHA_OUT.getInterpolation(contentAlpha); 954875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek translationY *= 0.4f; 955875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek } else { 956875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek contentAlpha = 1.0f; 957875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek } 958eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos for (NotificationContentView l : mLayouts) { 959eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos l.setAlpha(contentAlpha); 960eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos l.setTranslationY(translationY); 961eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos } 962875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek if (mChildrenContainer != null) { 963875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek mChildrenContainer.setAlpha(contentAlpha); 964875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek mChildrenContainer.setTranslationY(translationY); 965875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek // TODO: handle children fade out better 9660242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek } 9670242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek } 9680242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek 9690242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek private void updateIconVisibilities() { 97017e1b69523086a98189178fc7f2b23d74860c738Selim Cinek boolean visible = isChildInGroup() 97117e1b69523086a98189178fc7f2b23d74860c738Selim Cinek || (isBelowSpeedBump() && !NotificationShelf.SHOW_AMBIENT_ICONS) 97217e1b69523086a98189178fc7f2b23d74860c738Selim Cinek || mIconsVisible; 973eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos for (NotificationContentView l : mLayouts) { 974eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos l.setIconsVisible(visible); 975eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos } 976db16737031091160a3a7d080ac44ce2836402d74Selim Cinek if (mChildrenContainer != null) { 977db16737031091160a3a7d080ac44ce2836402d74Selim Cinek mChildrenContainer.setIconsVisible(visible); 9780242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek } 9790242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek } 9800242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek 981875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek /** 982875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek * Get the relative top padding of a view relative to this view. This recursively walks up the 983875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek * hierarchy and does the corresponding measuring. 984875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek * 985875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek * @param view the view to the the padding for. The requested view has to be a child of this 986875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek * notification. 987875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek * @return the toppadding 988875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek */ 989875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek public int getRelativeTopPadding(View view) { 990875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek int topPadding = 0; 991875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek while (view.getParent() instanceof ViewGroup) { 992875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek topPadding += view.getTop(); 993875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek view = (View) view.getParent(); 994875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek if (view instanceof ExpandableNotificationRow) { 995875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek return topPadding; 996875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek } 997875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek } 998875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek return topPadding; 999875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek } 1000875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek 1001a1d9790735a183578ad8789234b7defd67ed0866Selim Cinek public float getContentTranslation() { 1002a1d9790735a183578ad8789234b7defd67ed0866Selim Cinek return mPrivateLayout.getTranslationY(); 1003a1d9790735a183578ad8789234b7defd67ed0866Selim Cinek } 1004a1d9790735a183578ad8789234b7defd67ed0866Selim Cinek 10056743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek public void setIsLowPriority(boolean isLowPriority) { 10066743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek mIsLowPriority = isLowPriority; 10076743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek mPrivateLayout.setIsLowPriority(isLowPriority); 10086743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek if (mChildrenContainer != null) { 10096743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek mChildrenContainer.setIsLowPriority(isLowPriority); 10106743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek } 10116743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek } 10126743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek 10137d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek public void setUseIncreasedCollapsedHeight(boolean use) { 10147d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek mUseIncreasedCollapsedHeight = use; 10157d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek } 10167d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek 101787ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek public void setUseIncreasedHeadsUpHeight(boolean use) { 101887ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek mUseIncreasedHeadsUpHeight = use; 101987ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek } 102087ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek 102178403d79739605511ea88b653564d81d7bf4bbbaChris Wren public interface ExpansionLogger { 102278403d79739605511ea88b653564d81d7bf4bbbaChris Wren public void logNotificationExpansion(String key, boolean userAction, boolean expanded); 102378403d79739605511ea88b653564d81d7bf4bbbaChris Wren } 10241685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 102551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public ExpandableNotificationRow(Context context, AttributeSet attrs) { 102651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren super(context, attrs); 10270e2ffbd48bbedf47deb7f6aed96bd07e2fc96f53Blazej Magnowski mFalsingManager = FalsingManager.getInstance(context); 102801af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek initDimens(); 102901af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek } 103001af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek 103101af334b70c8ad47c8ce1f465e458863ebe9eae2Selim Cinek private void initDimens() { 1032f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek mNotificationMinHeightLegacy = getFontScaledHeight(R.dimen.notification_min_height_legacy); 1033f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek mNotificationMinHeight = getFontScaledHeight(R.dimen.notification_min_height); 10347d1009b3bd3b69768f293eb73109c52b8da8ec8eSelim Cinek mNotificationMinHeightLarge = getFontScaledHeight( 103587ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek R.dimen.notification_min_height_increased); 1036f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek mNotificationMaxHeight = getFontScaledHeight(R.dimen.notification_max_height); 10370aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos mNotificationAmbientHeight = getFontScaledHeight(R.dimen.notification_ambient_height); 1038f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek mMaxHeadsUpHeightLegacy = getFontScaledHeight( 103977019c72332cb31dd1cb713ea4c66e267e6cbf39Selim Cinek R.dimen.notification_max_heads_up_height_legacy); 1040f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek mMaxHeadsUpHeight = getFontScaledHeight(R.dimen.notification_max_heads_up_height); 104187ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek mMaxHeadsUpHeightIncreased = getFontScaledHeight( 104287ed69bd6b652c716364e05ba5bad6517eb005c8Selim Cinek R.dimen.notification_max_heads_up_height_increased); 1043b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mIncreasedPaddingBetweenElements = getResources() 1044b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor .getDimensionPixelSize(R.dimen.notification_divider_height_increased); 1045875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek mIconTransformContentShiftNoIcon = getResources().getDimensionPixelSize( 10460242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek R.dimen.notification_icon_transform_content_shift); 1047f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek } 1048f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek 1049f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek /** 1050f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek * @param dimenId the dimen to look up 1051f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek * @return the font scaled dimen as if it were in sp but doesn't shrink sizes below dp 1052f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek */ 1053f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek private int getFontScaledHeight(int dimenId) { 1054f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek int dimensionPixelSize = getResources().getDimensionPixelSize(dimenId); 1055f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek float factor = Math.max(1.0f, getResources().getDisplayMetrics().scaledDensity / 1056f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek getResources().getDisplayMetrics().density); 1057f619ffccd77c20702d45bd2bd63b626e41b08018Selim Cinek return (int) (dimensionPixelSize * factor); 105851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 105951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 1060a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer /** 1061a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer * Resets this view so it can be re-used for an updated notification. 1062a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer */ 106322f2ee567dd1b1a42432251229bcb2f05c1c4700Christoph Studer @Override 1064a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer public void reset() { 106522f2ee567dd1b1a42432251229bcb2f05c1c4700Christoph Studer super.reset(); 106678403d79739605511ea88b653564d81d7bf4bbbaChris Wren final boolean wasExpanded = isExpanded(); 1067a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer mExpandable = false; 1068a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer mHasUserChangedExpansion = false; 1069a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer mUserLocked = false; 1070a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer mShowingPublic = false; 1071ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mSensitive = false; 1072ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mShowingPublicInitialized = false; 1073a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer mIsSystemExpanded = false; 107483bc78338437a460076a4b5778ded38440ac3501Selim Cinek mOnKeyguard = false; 107551d94917c7dc53845701702bfd63f102a3a2dbc8Selim Cinek mPublicLayout.reset(); 107651d94917c7dc53845701702bfd63f102a3a2dbc8Selim Cinek mPrivateLayout.reset(); 107731094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek resetHeight(); 10784b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor resetTranslation(); 107931094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek logExpansionEvent(false, wasExpanded); 108031094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek } 108131094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek 108231094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek public void resetHeight() { 108331094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek onHeightReset(); 10846e28a678c7f9fe2cae5a51bfdbab3071a2d8d0baSelim Cinek requestLayout(); 1085a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer } 1086a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer 1087251957d76e57eb6e5f8068b37346144e10e586a4Jorim Jaggi @Override 1088251957d76e57eb6e5f8068b37346144e10e586a4Jorim Jaggi protected void onFinishInflate() { 1089251957d76e57eb6e5f8068b37346144e10e586a4Jorim Jaggi super.onFinishInflate(); 1090be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic); 1091be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded); 1092eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos mLayouts = new NotificationContentView[] {mPrivateLayout, mPublicLayout}; 1093eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos 1094eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos for (NotificationContentView l : mLayouts) { 1095eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos l.setExpandClickListener(mExpandClickListener); 1096eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos l.setContainingNotification(this); 1097eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos } 1098761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRowStub = (ViewStub) findViewById(R.id.menu_row_stub); 1099761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRowStub.setOnInflateListener(new ViewStub.OnInflateListener() { 11004b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor @Override 11014b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor public void onInflate(ViewStub stub, View inflated) { 1102761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRow = (NotificationMenuRow) inflated; 1103761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRow.setNotificationRowParent(ExpandableNotificationRow.this); 1104761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRow.setAppName(mAppName); 11054b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 11064b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor }); 1107ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek mGutsStub = (ViewStub) findViewById(R.id.notification_guts_stub); 1108ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek mGutsStub.setOnInflateListener(new ViewStub.OnInflateListener() { 1109b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi @Override 1110b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi public void onInflate(ViewStub stub, View inflated) { 1111b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi mGuts = (NotificationGuts) inflated; 1112b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi mGuts.setClipTopAmount(getClipTopAmount()); 1113b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi mGuts.setActualHeight(getActualHeight()); 1114ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek mGutsStub = null; 1115b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi } 1116b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi }); 1117b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainerStub = (ViewStub) findViewById(R.id.child_container_stub); 1118b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainerStub.setOnInflateListener(new ViewStub.OnInflateListener() { 1119b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 1120b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek @Override 1121b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void onInflate(ViewStub stub, View inflated) { 1122b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainer = (NotificationChildrenContainer) inflated; 11236743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek mChildrenContainer.setIsLowPriority(mIsLowPriority); 1124388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek mChildrenContainer.setNotificationParent(ExpandableNotificationRow.this); 1125c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek mChildrenContainer.onNotificationUpdated(); 11264b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor mTranslateableViews.add(mChildrenContainer); 1127b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 1128b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek }); 11294b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor 11304b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor // Add the views that we translate to reveal the gear 11314b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor mTranslateableViews = new ArrayList<View>(); 11324b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor for (int i = 0; i < getChildCount(); i++) { 11334b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor mTranslateableViews.add(getChildAt(i)); 11344b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 11354b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor // Remove views that don't translate 1136761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mTranslateableViews.remove(mMenuRowStub); 11374b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor mTranslateableViews.remove(mChildrenContainerStub); 11384b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor mTranslateableViews.remove(mGutsStub); 11394b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 11404b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor 11414b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor public void resetTranslation() { 114232c638a597dccbe4be600fd483060ee1466fdb04Mady Mellor if (mTranslateAnim != null) { 114332c638a597dccbe4be600fd483060ee1466fdb04Mady Mellor mTranslateAnim.cancel(); 114432c638a597dccbe4be600fd483060ee1466fdb04Mady Mellor } 11454b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor if (mTranslateableViews != null) { 11464b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor for (int i = 0; i < mTranslateableViews.size(); i++) { 11474b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor mTranslateableViews.get(i).setTranslationX(0); 11484b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 11494b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 1150b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor invalidateOutline(); 1151761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor if (mMenuRow != null) { 1152761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRow.resetState(true /* notify */); 11534b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 11544b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 11554b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor 11564b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor public void animateTranslateNotification(final float leftTarget) { 11574b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor if (mTranslateAnim != null) { 11584b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor mTranslateAnim.cancel(); 11594b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 1160b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mTranslateAnim = getTranslateViewAnimator(leftTarget, null /* updateListener */); 116134958fa272c9216db4002546c3efad692b3d7775Mady Mellor if (mTranslateAnim != null) { 116234958fa272c9216db4002546c3efad692b3d7775Mady Mellor mTranslateAnim.start(); 116334958fa272c9216db4002546c3efad692b3d7775Mady Mellor } 116434958fa272c9216db4002546c3efad692b3d7775Mady Mellor } 116534958fa272c9216db4002546c3efad692b3d7775Mady Mellor 116634958fa272c9216db4002546c3efad692b3d7775Mady Mellor @Override 116734958fa272c9216db4002546c3efad692b3d7775Mady Mellor public void setTranslation(float translationX) { 116834958fa272c9216db4002546c3efad692b3d7775Mady Mellor if (areGutsExposed()) { 116934958fa272c9216db4002546c3efad692b3d7775Mady Mellor // Don't translate if guts are showing. 117034958fa272c9216db4002546c3efad692b3d7775Mady Mellor return; 117134958fa272c9216db4002546c3efad692b3d7775Mady Mellor } 117234958fa272c9216db4002546c3efad692b3d7775Mady Mellor // Translate the group of views 117334958fa272c9216db4002546c3efad692b3d7775Mady Mellor for (int i = 0; i < mTranslateableViews.size(); i++) { 117434958fa272c9216db4002546c3efad692b3d7775Mady Mellor if (mTranslateableViews.get(i) != null) { 117534958fa272c9216db4002546c3efad692b3d7775Mady Mellor mTranslateableViews.get(i).setTranslationX(translationX); 117634958fa272c9216db4002546c3efad692b3d7775Mady Mellor } 117734958fa272c9216db4002546c3efad692b3d7775Mady Mellor } 1178b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor invalidateOutline(); 1179761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor if (mMenuRow != null) { 1180761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRow.updateMenuAlpha(translationX, getMeasuredWidth()); 118134958fa272c9216db4002546c3efad692b3d7775Mady Mellor } 118234958fa272c9216db4002546c3efad692b3d7775Mady Mellor } 118334958fa272c9216db4002546c3efad692b3d7775Mady Mellor 118434958fa272c9216db4002546c3efad692b3d7775Mady Mellor @Override 118534958fa272c9216db4002546c3efad692b3d7775Mady Mellor public float getTranslation() { 118634958fa272c9216db4002546c3efad692b3d7775Mady Mellor if (mTranslateableViews != null && mTranslateableViews.size() > 0) { 118734958fa272c9216db4002546c3efad692b3d7775Mady Mellor // All of the views in the list should have same translation, just use first one. 118834958fa272c9216db4002546c3efad692b3d7775Mady Mellor return mTranslateableViews.get(0).getTranslationX(); 118934958fa272c9216db4002546c3efad692b3d7775Mady Mellor } 119034958fa272c9216db4002546c3efad692b3d7775Mady Mellor return 0; 119134958fa272c9216db4002546c3efad692b3d7775Mady Mellor } 119234958fa272c9216db4002546c3efad692b3d7775Mady Mellor 119334958fa272c9216db4002546c3efad692b3d7775Mady Mellor public Animator getTranslateViewAnimator(final float leftTarget, 119434958fa272c9216db4002546c3efad692b3d7775Mady Mellor AnimatorUpdateListener listener) { 1195723f1f996fd78f08e5e91ed57420bd431e11f903Mady Mellor if (mTranslateAnim != null) { 1196723f1f996fd78f08e5e91ed57420bd431e11f903Mady Mellor mTranslateAnim.cancel(); 1197723f1f996fd78f08e5e91ed57420bd431e11f903Mady Mellor } 119834958fa272c9216db4002546c3efad692b3d7775Mady Mellor if (areGutsExposed()) { 119934958fa272c9216db4002546c3efad692b3d7775Mady Mellor // No translation if guts are exposed. 120034958fa272c9216db4002546c3efad692b3d7775Mady Mellor return null; 120134958fa272c9216db4002546c3efad692b3d7775Mady Mellor } 1202b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor final ObjectAnimator translateAnim = ObjectAnimator.ofFloat(this, TRANSLATE_CONTENT, 1203b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor leftTarget); 1204b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor if (listener != null) { 1205b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor translateAnim.addUpdateListener(listener); 1206b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 1207b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor translateAnim.addListener(new AnimatorListenerAdapter() { 1208b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor boolean cancelled = false; 1209723f1f996fd78f08e5e91ed57420bd431e11f903Mady Mellor 1210b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor @Override 1211b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor public void onAnimationCancel(Animator anim) { 1212b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor cancelled = true; 1213b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 1214723f1f996fd78f08e5e91ed57420bd431e11f903Mady Mellor 1215b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor @Override 1216b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor public void onAnimationEnd(Animator anim) { 1217761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor if (!cancelled && mMenuRow != null && leftTarget == 0) { 1218761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRow.resetState(true /* notify */); 1219b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mTranslateAnim = null; 1220723f1f996fd78f08e5e91ed57420bd431e11f903Mady Mellor } 12214b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 1222b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor }); 1223b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mTranslateAnim = translateAnim; 1224b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor return translateAnim; 12254b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 12264b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor 12274b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor public float getSpaceForGear() { 1228761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor if (mMenuRow != null) { 1229761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor return mMenuRow.getSpaceForMenu(); 12304b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 12314b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor return 0; 12324b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 12334b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor 1234761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor public NotificationMenuRow getSettingsRow() { 1235761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor if (mMenuRow == null) { 1236761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRowStub.inflate(); 12374b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 1238761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor return mMenuRow; 12394b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor } 12404b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor 1241ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek public void inflateGuts() { 1242ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek if (mGuts == null) { 1243ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek mGutsStub.inflate(); 1244ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek } 1245ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek } 1246ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek 1247da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek private void updateChildrenVisibility() { 1248d84a5930cca7add37e7e23305538d29959daf199Selim Cinek mPrivateLayout.setVisibility(!mShowingPublic && !mIsSummaryWithChildren ? VISIBLE 1249d84a5930cca7add37e7e23305538d29959daf199Selim Cinek : INVISIBLE); 1250ef5127ea5f34f7a4c961021f6b691174bcb81d2eSelim Cinek if (mChildrenContainer != null) { 1251ef5127ea5f34f7a4c961021f6b691174bcb81d2eSelim Cinek mChildrenContainer.setVisibility(!mShowingPublic && mIsSummaryWithChildren ? VISIBLE 1252ef5127ea5f34f7a4c961021f6b691174bcb81d2eSelim Cinek : INVISIBLE); 1253b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mChildrenContainer.updateHeaderVisibility(!mShowingPublic && mIsSummaryWithChildren 1254b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor ? VISIBLE 1255ef5127ea5f34f7a4c961021f6b691174bcb81d2eSelim Cinek : INVISIBLE); 1256b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 1257da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek // The limits might have changed if the view suddenly became a group or vice versa 1258da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek updateLimits(); 1259b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 1260b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 1261fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi @Override 1262a54956a0bc611b1e9b3914edc7a604b59688f6b7Alan Viverette public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event) { 1263a54956a0bc611b1e9b3914edc7a604b59688f6b7Alan Viverette if (super.onRequestSendAccessibilityEventInternal(child, event)) { 1264fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi // Add a record for the entire layout since its content is somehow small. 1265fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi // The event comes from a leaf view that is interacted with. 1266fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi AccessibilityEvent record = AccessibilityEvent.obtain(); 1267fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi onInitializeAccessibilityEvent(record); 1268fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi dispatchPopulateAccessibilityEvent(record); 1269fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi event.appendRecord(record); 1270fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi return true; 1271fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi } 1272fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi return false; 1273c5dc0d0cce373fbf292e13633c114a431d747167Jorim Jaggi } 127451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 1275e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock @Override 12764e857f4ef0357e05806819d0488a73a12208fe8fJorim Jaggi public void setDark(boolean dark, boolean fade, long delay) { 12774e857f4ef0357e05806819d0488a73a12208fe8fJorim Jaggi super.setDark(dark, fade, delay); 1278e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock final NotificationContentView showing = getShowingLayout(); 1279e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock if (showing != null) { 12804e857f4ef0357e05806819d0488a73a12208fe8fJorim Jaggi showing.setDark(dark, fade, delay); 1281e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock } 12829c7712d45ccec56a80873a83e56a83f810624b43Selim Cinek if (mIsSummaryWithChildren) { 1283c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek mChildrenContainer.setDark(dark, fade, delay); 12849c7712d45ccec56a80873a83e56a83f810624b43Selim Cinek } 1285e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock } 1286e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock 128751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public boolean isExpandable() { 1288388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek if (mIsSummaryWithChildren && !mShowingPublic) { 1289388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek return !mChildrenExpanded; 1290388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek } 129151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren return mExpandable; 129251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 129351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 129451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public void setExpandable(boolean expandable) { 129551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren mExpandable = expandable; 1296eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek mPrivateLayout.updateExpandButtons(isExpandable()); 129751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 129851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 12994ffd63611a0d516c9988b37e9c06e6f8390c2a2fSelim Cinek @Override 13004ffd63611a0d516c9988b37e9c06e6f8390c2a2fSelim Cinek public void setClipToActualHeight(boolean clipToActualHeight) { 1301084c16b8b380e7ff0d38d9e2846db321f0214931Selim Cinek super.setClipToActualHeight(clipToActualHeight || isUserLocked()); 1302084c16b8b380e7ff0d38d9e2846db321f0214931Selim Cinek getShowingLayout().setClipToActualHeight(clipToActualHeight || isUserLocked()); 13034ffd63611a0d516c9988b37e9c06e6f8390c2a2fSelim Cinek } 13044ffd63611a0d516c9988b37e9c06e6f8390c2a2fSelim Cinek 13051685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** 13061685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * @return whether the user has changed the expansion state 13071685e634fb0b14033bd436af8d7174436699ffecSelim Cinek */ 13081685e634fb0b14033bd436af8d7174436699ffecSelim Cinek public boolean hasUserChangedExpansion() { 13091685e634fb0b14033bd436af8d7174436699ffecSelim Cinek return mHasUserChangedExpansion; 13101685e634fb0b14033bd436af8d7174436699ffecSelim Cinek } 13111685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 131251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public boolean isUserExpanded() { 131351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren return mUserExpanded; 131451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 131551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 13161685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** 13171685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * Set this notification to be expanded by the user 13181685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * 13191685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * @param userExpanded whether the user wants this notification to be expanded 13201685e634fb0b14033bd436af8d7174436699ffecSelim Cinek */ 132151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public void setUserExpanded(boolean userExpanded) { 1322388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek setUserExpanded(userExpanded, false /* allowChildExpansion */); 13236743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek updateShelfIconColor(); 1324388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek } 1325388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek 1326388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek /** 1327388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek * Set this notification to be expanded by the user 1328388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek * 1329388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek * @param userExpanded whether the user wants this notification to be expanded 1330388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek * @param allowChildExpansion whether a call to this method allows expanding children 1331388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek */ 1332388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek public void setUserExpanded(boolean userExpanded, boolean allowChildExpansion) { 13330e2ffbd48bbedf47deb7f6aed96bd07e2fc96f53Blazej Magnowski mFalsingManager.setNotificationExpanded(); 1334388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek if (mIsSummaryWithChildren && !mShowingPublic && allowChildExpansion) { 1335698b1706be196de41fc6bf03cf15971c82a11949Chris Wren final boolean wasExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification); 1336388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek mGroupManager.setGroupExpanded(mStatusBarNotification, userExpanded); 1337698b1706be196de41fc6bf03cf15971c82a11949Chris Wren logExpansionEvent(true /* userAction */, wasExpanded); 1338388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek return; 1339388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek } 1340a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer if (userExpanded && !mExpandable) return; 134178403d79739605511ea88b653564d81d7bf4bbbaChris Wren final boolean wasExpanded = isExpanded(); 13421685e634fb0b14033bd436af8d7174436699ffecSelim Cinek mHasUserChangedExpansion = true; 134351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren mUserExpanded = userExpanded; 134478403d79739605511ea88b653564d81d7bf4bbbaChris Wren logExpansionEvent(true, wasExpanded); 134551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 134651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 1347ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek public void resetUserExpansion() { 1348ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek mHasUserChangedExpansion = false; 1349ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek mUserExpanded = false; 1350ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek } 1351ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek 135251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public boolean isUserLocked() { 13531b2a05eb00746756c4d37ad76d597d909019e56fSelim Cinek return mUserLocked && !mForceUnlocked; 135451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 135551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 135651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public void setUserLocked(boolean userLocked) { 135751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren mUserLocked = userLocked; 13588f2f6a67fad7aed720e33a6629cb65d368ebfb80Selim Cinek mPrivateLayout.setUserExpanding(userLocked); 135942357e030c095867b95e2e8a718649587c5ebf52Selim Cinek if (mIsSummaryWithChildren) { 136042357e030c095867b95e2e8a718649587c5ebf52Selim Cinek mChildrenContainer.setUserLocked(userLocked); 13617baaa9e82bebc6b3e7735828dbf67340eebc5821Selim Cinek if (userLocked || !isGroupExpanded()) { 1362b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor updateBackgroundForGroupState(); 1363b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 136442357e030c095867b95e2e8a718649587c5ebf52Selim Cinek } 136551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 136651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 13671685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** 13681685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * @return has the system set this notification to be expanded 13691685e634fb0b14033bd436af8d7174436699ffecSelim Cinek */ 13701685e634fb0b14033bd436af8d7174436699ffecSelim Cinek public boolean isSystemExpanded() { 13711685e634fb0b14033bd436af8d7174436699ffecSelim Cinek return mIsSystemExpanded; 13721685e634fb0b14033bd436af8d7174436699ffecSelim Cinek } 13731685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 13741685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** 13751685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * Set this notification to be expanded by the system. 13761685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * 13771685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * @param expand whether the system wants this notification to be expanded. 13781685e634fb0b14033bd436af8d7174436699ffecSelim Cinek */ 13791685e634fb0b14033bd436af8d7174436699ffecSelim Cinek public void setSystemExpanded(boolean expand) { 138031094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek if (expand != mIsSystemExpanded) { 138131094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek final boolean wasExpanded = isExpanded(); 138231094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek mIsSystemExpanded = expand; 13836743c0bd52606444ce78316a7bbc51923a140a4aSelim Cinek updateShelfIconColor(); 1384b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek notifyHeightChanged(false /* needsAnimation */); 138531094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek logExpansionEvent(false, wasExpanded); 1386ed6913b0ce99784188713975218dcff113a3d4a7Selim Cinek if (mIsSummaryWithChildren) { 1387c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek mChildrenContainer.updateGroupOverflow(); 1388c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek } 138931094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek } 1390dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi } 1391dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi 1392dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi /** 139383bc78338437a460076a4b5778ded38440ac3501Selim Cinek * @param onKeyguard whether to prevent notification expansion 1394dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi */ 139583bc78338437a460076a4b5778ded38440ac3501Selim Cinek public void setOnKeyguard(boolean onKeyguard) { 139683bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (onKeyguard != mOnKeyguard) { 139731094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek final boolean wasExpanded = isExpanded(); 139883bc78338437a460076a4b5778ded38440ac3501Selim Cinek mOnKeyguard = onKeyguard; 139931094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek logExpansionEvent(false, wasExpanded); 140031094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek if (wasExpanded != isExpanded()) { 1401c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek if (mIsSummaryWithChildren) { 1402c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek mChildrenContainer.updateGroupOverflow(); 1403c897bd3e91ed442b0f32c3a5b9918e9e580b62b1Selim Cinek } 14044b80b1025f82fa7becc8e126bfa4aea39affcf65Mady Mellor notifyHeightChanged(false /* needsAnimation */); 140531094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek } 140631094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek } 14071685e634fb0b14033bd436af8d7174436699ffecSelim Cinek } 14081685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 14091685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** 14109e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek * @return Can the underlying notification be cleared? This can be different from whether the 14119e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek * notification can be dismissed in case notifications are sensitive on the lockscreen. 14129e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek * @see #canViewBeDismissed() 14130d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler */ 14140d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler public boolean isClearable() { 1415506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek if (mStatusBarNotification == null || !mStatusBarNotification.isClearable()) { 1416506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek return false; 1417506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek } 1418506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek if (mIsSummaryWithChildren) { 1419506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek List<ExpandableNotificationRow> notificationChildren = 1420506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek mChildrenContainer.getNotificationChildren(); 1421506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek for (int i = 0; i < notificationChildren.size(); i++) { 1422506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek ExpandableNotificationRow child = notificationChildren.get(i); 1423506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek if (!child.isClearable()) { 1424506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek return false; 1425506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek } 1426506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek } 1427506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek } 1428506deb69a744fe0fa704eda588c3a263b3f8fc2cSelim Cinek return true; 14290d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler } 14300d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler 14319cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi @Override 14329cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi public int getIntrinsicHeight() { 1433be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi if (isUserLocked()) { 1434be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi return getActualHeight(); 1435be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi } 14364dd5006ff58c3b1ee5a2e0db343170e7cbd1b585Geoffrey Pitsch if (mGuts != null && mGuts.isExposed()) { 1437d84a5930cca7add37e7e23305538d29959daf199Selim Cinek return mGuts.getHeight(); 1438d84a5930cca7add37e7e23305538d29959daf199Selim Cinek } else if ((isChildInGroup() && !isGroupExpanded())) { 1439d84a5930cca7add37e7e23305538d29959daf199Selim Cinek return mPrivateLayout.getMinHeight(); 14400aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos } else if (mShowAmbient) { 14410aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos return getAmbientHeight(); 1442d84a5930cca7add37e7e23305538d29959daf199Selim Cinek } else if (mSensitive && mHideSensitiveForIntrinsicHeight) { 1443d84a5930cca7add37e7e23305538d29959daf199Selim Cinek return getMinHeight(); 144483bc78338437a460076a4b5778ded38440ac3501Selim Cinek } else if (mIsSummaryWithChildren && !mOnKeyguard) { 1445eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek return mChildrenContainer.getIntrinsicHeight(); 144601ee2cd5c4071f528d4b208deeec8d10eec5e1c4Selim Cinek } else if (!mOnKeyguard && (mIsHeadsUp || mHeadsupDisappearRunning)) { 144773cf02a0783e3857cae21fece9c292abcc9e1409Selim Cinek if (isPinned() || mHeadsupDisappearRunning) { 144831aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek return getPinnedHeadsUpHeight(true /* atLeastMinHeight */); 144931aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek } else if (isExpanded()) { 1450d84a5930cca7add37e7e23305538d29959daf199Selim Cinek return Math.max(getMaxExpandHeight(), mHeadsUpHeight); 14518d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek } else { 1452567e845d99840a6e556595739a15e16132eb2f1eSelim Cinek return Math.max(getCollapsedHeight(), mHeadsUpHeight); 14538d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek } 145431aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek } else if (isExpanded()) { 145583bc78338437a460076a4b5778ded38440ac3501Selim Cinek return getMaxExpandHeight(); 1456d84a5930cca7add37e7e23305538d29959daf199Selim Cinek } else { 1457567e845d99840a6e556595739a15e16132eb2f1eSelim Cinek return getCollapsedHeight(); 14581685e634fb0b14033bd436af8d7174436699ffecSelim Cinek } 1459b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 14601685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 146143c2cd1a4071e152e9f4aa9044b03a29cd5ada31Mady Mellor @Override 1462b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor public boolean isGroupExpanded() { 1463eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek return mGroupManager.isGroupExpanded(mStatusBarNotification); 1464b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 1465b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 1466263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek private void onChildrenCountChanged() { 14672a6ea9c2a1b52b0386270ec73e1e6d6a9b614a34Jason Monk mIsSummaryWithChildren = StatusBar.ENABLE_CHILD_NOTIFICATIONS 1468b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor && mChildrenContainer != null && mChildrenContainer.getNotificationChildCount() > 0; 1469b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor if (mIsSummaryWithChildren && mChildrenContainer.getHeaderView() == null) { 1470b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mChildrenContainer.recreateNotificationHeader(mExpandClickListener, 1471b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mEntry.notification); 1472263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek } 14736baed9e3a272b09e87f15801a389d7714d0b051fMady Mellor getShowingLayout().updateBackgroundColor(false /* animate */); 1474eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek mPrivateLayout.updateExpandButtons(isExpandable()); 1475ea4bef7386ca6c6260f292bf006d16a99b93f698Selim Cinek updateChildrenHeaderAppearance(); 1476da42d65ea5a0eec7d1eaf48fee19ead419994b16Selim Cinek updateChildrenVisibility(); 1477263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek } 1478263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek 1479b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor public void updateChildrenHeaderAppearance() { 1480ed6913b0ce99784188713975218dcff113a3d4a7Selim Cinek if (mIsSummaryWithChildren) { 1481b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mChildrenContainer.updateChildrenHeaderAppearance(); 1482b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 1483b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 1484b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor 14851685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** 14861685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * Check whether the view state is currently expanded. This is given by the system in {@link 14871685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * #setSystemExpanded(boolean)} and can be overridden by user expansion or 14881685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * collapsing in {@link #setUserExpanded(boolean)}. Note that the visual appearance of this 14891685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * view can differ from this state, if layout params are modified from outside. 14901685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * 14911685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * @return whether the view state is currently expanded. 14921685e634fb0b14033bd436af8d7174436699ffecSelim Cinek */ 149383bc78338437a460076a4b5778ded38440ac3501Selim Cinek public boolean isExpanded() { 1494e81b82ba252582753cb87ba424c82028b6e490ecSelim Cinek return isExpanded(false /* allowOnKeyguard */); 1495e81b82ba252582753cb87ba424c82028b6e490ecSelim Cinek } 1496e81b82ba252582753cb87ba424c82028b6e490ecSelim Cinek 1497e81b82ba252582753cb87ba424c82028b6e490ecSelim Cinek public boolean isExpanded(boolean allowOnKeyguard) { 1498e81b82ba252582753cb87ba424c82028b6e490ecSelim Cinek return (!mOnKeyguard || allowOnKeyguard) 1499b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek && (!hasUserChangedExpansion() && (isSystemExpanded() || isSystemChildExpanded()) 1500b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek || isUserExpanded()); 1501b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 1502b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 1503b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private boolean isSystemChildExpanded() { 1504b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek return mIsSystemChildExpanded; 1505b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 1506b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 1507b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void setSystemChildExpanded(boolean expanded) { 1508b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mIsSystemChildExpanded = expanded; 15091685e634fb0b14033bd436af8d7174436699ffecSelim Cinek } 15101685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 15111685e634fb0b14033bd436af8d7174436699ffecSelim Cinek @Override 15121685e634fb0b14033bd436af8d7174436699ffecSelim Cinek protected void onLayout(boolean changed, int left, int top, int right, int bottom) { 15131685e634fb0b14033bd436af8d7174436699ffecSelim Cinek super.onLayout(changed, left, top, right, bottom); 15148d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek updateMaxHeights(); 1515761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor if (mMenuRow != null) { 1516761cde1173cdfbc058034ffb10283e5507ed0ed4Mady Mellor mMenuRow.updateVerticalLocation(); 1517a6edc878293e49594a6aac7a0d0e41c7980ece07Mady Mellor } 1518875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek updateContentShiftHeight(); 1519875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek } 1520875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek 1521875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek /** 1522875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek * Updates the content shift height such that the header is completely hidden when coming from 1523875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek * the top. 1524875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek */ 1525875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek private void updateContentShiftHeight() { 1526875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek NotificationHeaderView notificationHeader = getNotificationHeader(); 1527875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek if (notificationHeader != null) { 1528875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek CachingIconView icon = notificationHeader.getIcon(); 1529875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek mIconTransformContentShift = getRelativeTopPadding(icon) + icon.getHeight(); 1530875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek } else { 1531875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek mIconTransformContentShift = mIconTransformContentShiftNoIcon; 1532875a3a11e2bfcb10d873cd9b4272bed1edf3fe93Selim Cinek } 15331685e634fb0b14033bd436af8d7174436699ffecSelim Cinek } 15341685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 15358d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek private void updateMaxHeights() { 1536d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek int intrinsicBefore = getIntrinsicHeight(); 15378d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek View expandedChild = mPrivateLayout.getExpandedChild(); 15388d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek if (expandedChild == null) { 15398d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek expandedChild = mPrivateLayout.getContractedChild(); 15408d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek } 15418d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek mMaxExpandHeight = expandedChild.getHeight(); 15428d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek View headsUpChild = mPrivateLayout.getHeadsUpChild(); 15431f3f544f21cab3728f749ab66cd6859e9dfcf389Selim Cinek if (headsUpChild == null) { 15441f3f544f21cab3728f749ab66cd6859e9dfcf389Selim Cinek headsUpChild = mPrivateLayout.getContractedChild(); 15458d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek } 15461f3f544f21cab3728f749ab66cd6859e9dfcf389Selim Cinek mHeadsUpHeight = headsUpChild.getHeight(); 1547d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek if (intrinsicBefore != getIntrinsicHeight()) { 1548bb42b7dd4892a8ab99f2f702cad931235d1d463eSelim Cinek notifyHeightChanged(true /* needsAnimation */); 1549d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek } 1550d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek } 1551d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek 1552fa0a2d3d90fdde14784ec6351a0798bc21c2f126Selim Cinek @Override 1553fa0a2d3d90fdde14784ec6351a0798bc21c2f126Selim Cinek public void notifyHeightChanged(boolean needsAnimation) { 1554fa0a2d3d90fdde14784ec6351a0798bc21c2f126Selim Cinek super.notifyHeightChanged(needsAnimation); 1555fa0a2d3d90fdde14784ec6351a0798bc21c2f126Selim Cinek getShowingLayout().requestSelectLayout(needsAnimation || isUserLocked()); 1556fa0a2d3d90fdde14784ec6351a0798bc21c2f126Selim Cinek } 1557fa0a2d3d90fdde14784ec6351a0798bc21c2f126Selim Cinek 15583c76d509d362cf5086a63722ab41e04f5d539182Selim Cinek public void setSensitive(boolean sensitive, boolean hideSensitive) { 1559ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mSensitive = sensitive; 15603c76d509d362cf5086a63722ab41e04f5d539182Selim Cinek mSensitiveHiddenInGeneral = hideSensitive; 1561ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi } 1562ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi 156343c2cd1a4071e152e9f4aa9044b03a29cd5ada31Mady Mellor @Override 1564ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi public void setHideSensitiveForIntrinsicHeight(boolean hideSensitive) { 156560122be6747c4f79b96f6808158f8f7e7548b7d3Selim Cinek mHideSensitiveForIntrinsicHeight = hideSensitive; 1566a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek if (mIsSummaryWithChildren) { 1567a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek List<ExpandableNotificationRow> notificationChildren = 1568a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek mChildrenContainer.getNotificationChildren(); 1569a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek for (int i = 0; i < notificationChildren.size(); i++) { 1570a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek ExpandableNotificationRow child = notificationChildren.get(i); 1571a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek child.setHideSensitiveForIntrinsicHeight(hideSensitive); 1572a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek } 1573a52f6a17efa944adc945a61788cc3beb54c569e7Selim Cinek } 1574ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi } 1575ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi 157643c2cd1a4071e152e9f4aa9044b03a29cd5ada31Mady Mellor @Override 1577ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi public void setHideSensitive(boolean hideSensitive, boolean animated, long delay, 1578ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi long duration) { 1579ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi boolean oldShowingPublic = mShowingPublic; 1580ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mShowingPublic = mSensitive && hideSensitive; 1581ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) { 1582ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi return; 1583ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi } 1584a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler 1585a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler // bail out if no public version 15861685e634fb0b14033bd436af8d7174436699ffecSelim Cinek if (mPublicLayout.getChildCount() == 0) return; 1587a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler 1588ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi if (!animated) { 1589ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mPublicLayout.animate().cancel(); 1590ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mPrivateLayout.animate().cancel(); 1591a554c707386eb8a6c6fb3a2399f23b79a1c17f74Selim Cinek if (mChildrenContainer != null) { 1592a554c707386eb8a6c6fb3a2399f23b79a1c17f74Selim Cinek mChildrenContainer.animate().cancel(); 1593a554c707386eb8a6c6fb3a2399f23b79a1c17f74Selim Cinek mChildrenContainer.setAlpha(1f); 1594a554c707386eb8a6c6fb3a2399f23b79a1c17f74Selim Cinek } 1595ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mPublicLayout.setAlpha(1f); 1596ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mPrivateLayout.setAlpha(1f); 1597ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE); 1598d84a5930cca7add37e7e23305538d29959daf199Selim Cinek updateChildrenVisibility(); 1599ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi } else { 1600ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi animateShowingPublic(delay, duration); 1601ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi } 1602c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek NotificationContentView showingLayout = getShowingLayout(); 1603c317933a91b1d33cc4af9b7c6218b9ce675d05eaSelim Cinek showingLayout.updateBackgroundColor(animated); 1604eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek mPrivateLayout.updateExpandButtons(isExpandable()); 1605e5726a20824c3cb2ff369207c8d75bfcdb814f69Adrian Roos showingLayout.setDark(isDark(), false /* animate */, 0 /* delay */); 1606ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mShowingPublicInitialized = true; 1607ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi } 1608ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi 1609ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi private void animateShowingPublic(long delay, long duration) { 1610b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor View[] privateViews = mIsSummaryWithChildren 1611b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor ? new View[] {mChildrenContainer} 1612d84a5930cca7add37e7e23305538d29959daf199Selim Cinek : new View[] {mPrivateLayout}; 1613d84a5930cca7add37e7e23305538d29959daf199Selim Cinek View[] publicViews = new View[] {mPublicLayout}; 1614d84a5930cca7add37e7e23305538d29959daf199Selim Cinek View[] hiddenChildren = mShowingPublic ? privateViews : publicViews; 1615d84a5930cca7add37e7e23305538d29959daf199Selim Cinek View[] shownChildren = mShowingPublic ? publicViews : privateViews; 1616d84a5930cca7add37e7e23305538d29959daf199Selim Cinek for (final View hiddenView : hiddenChildren) { 1617d84a5930cca7add37e7e23305538d29959daf199Selim Cinek hiddenView.setVisibility(View.VISIBLE); 1618d84a5930cca7add37e7e23305538d29959daf199Selim Cinek hiddenView.animate().cancel(); 1619d84a5930cca7add37e7e23305538d29959daf199Selim Cinek hiddenView.animate() 1620d84a5930cca7add37e7e23305538d29959daf199Selim Cinek .alpha(0f) 1621d84a5930cca7add37e7e23305538d29959daf199Selim Cinek .setStartDelay(delay) 1622d84a5930cca7add37e7e23305538d29959daf199Selim Cinek .setDuration(duration) 1623d84a5930cca7add37e7e23305538d29959daf199Selim Cinek .withEndAction(new Runnable() { 1624d84a5930cca7add37e7e23305538d29959daf199Selim Cinek @Override 1625d84a5930cca7add37e7e23305538d29959daf199Selim Cinek public void run() { 1626d84a5930cca7add37e7e23305538d29959daf199Selim Cinek hiddenView.setVisibility(View.INVISIBLE); 1627d84a5930cca7add37e7e23305538d29959daf199Selim Cinek } 1628d84a5930cca7add37e7e23305538d29959daf199Selim Cinek }); 1629d84a5930cca7add37e7e23305538d29959daf199Selim Cinek } 1630d84a5930cca7add37e7e23305538d29959daf199Selim Cinek for (View showView : shownChildren) { 1631d84a5930cca7add37e7e23305538d29959daf199Selim Cinek showView.setVisibility(View.VISIBLE); 1632d84a5930cca7add37e7e23305538d29959daf199Selim Cinek showView.setAlpha(0f); 1633d84a5930cca7add37e7e23305538d29959daf199Selim Cinek showView.animate().cancel(); 1634d84a5930cca7add37e7e23305538d29959daf199Selim Cinek showView.animate() 1635d84a5930cca7add37e7e23305538d29959daf199Selim Cinek .alpha(1f) 1636d84a5930cca7add37e7e23305538d29959daf199Selim Cinek .setStartDelay(delay) 1637d84a5930cca7add37e7e23305538d29959daf199Selim Cinek .setDuration(duration); 1638d84a5930cca7add37e7e23305538d29959daf199Selim Cinek } 16390d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler } 16400d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler 164143c2cd1a4071e152e9f4aa9044b03a29cd5ada31Mady Mellor @Override 16423776fe007550451bb237c705d333247eab2a291cSelim Cinek public boolean mustStayOnScreen() { 16433776fe007550451bb237c705d333247eab2a291cSelim Cinek return mIsHeadsUp; 16443776fe007550451bb237c705d333247eab2a291cSelim Cinek } 16453776fe007550451bb237c705d333247eab2a291cSelim Cinek 16469e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek /** 16479e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek * @return Whether this view is allowed to be dismissed. Only valid for visible notifications as 16489e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek * otherwise some state might not be updated. To request about the general clearability 16499e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek * see {@link #isClearable()}. 16509e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek */ 16519e624e732aa5646c83d203587be9c2c4e94c9266Selim Cinek public boolean canViewBeDismissed() { 1652e9bad242f38bebadae481a22b647cc153f093070Selim Cinek return isClearable() && (!mShowingPublic || !mSensitiveHiddenInGeneral); 1653a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler } 1654251957d76e57eb6e5f8068b37346144e10e586a4Jorim Jaggi 1655cd35def3c35f04d7fd056590d4668b5ebbc80490Ricky Wai public void makeActionsVisibile() { 1656cd35def3c35f04d7fd056590d4668b5ebbc80490Ricky Wai setUserExpanded(true, true); 1657cd35def3c35f04d7fd056590d4668b5ebbc80490Ricky Wai if (isChildInGroup()) { 1658cd35def3c35f04d7fd056590d4668b5ebbc80490Ricky Wai mGroupManager.setGroupExpanded(mStatusBarNotification, true); 1659cd35def3c35f04d7fd056590d4668b5ebbc80490Ricky Wai } 1660bb42b7dd4892a8ab99f2f702cad931235d1d463eSelim Cinek notifyHeightChanged(false /* needsAnimation */); 1661cd35def3c35f04d7fd056590d4668b5ebbc80490Ricky Wai } 1662cd35def3c35f04d7fd056590d4668b5ebbc80490Ricky Wai 1663b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void setChildrenExpanded(boolean expanded, boolean animate) { 1664b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenExpanded = expanded; 166583bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (mChildrenContainer != null) { 166683bc78338437a460076a4b5778ded38440ac3501Selim Cinek mChildrenContainer.setChildrenExpanded(expanded); 166783bc78338437a460076a4b5778ded38440ac3501Selim Cinek } 16681a5d8eadd56b435843dfbc1adf3779aa7286081bMady Mellor updateBackgroundForGroupState(); 1669ddf1b399d85ca417301625a55b2a3c7acab2633cSelim Cinek updateClickAndFocus(); 1670b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 1671b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 1672b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public static void applyTint(View v, int color) { 1673b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek int alpha; 1674b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek if (color != 0) { 1675b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek alpha = COLORED_DIVIDER_ALPHA; 1676b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } else { 1677b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek color = 0xff000000; 1678b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek alpha = DEFAULT_DIVIDER_ALPHA; 1679b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 1680b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek if (v.getBackground() instanceof ColorDrawable) { 1681b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek ColorDrawable background = (ColorDrawable) v.getBackground(); 1682b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek background.mutate(); 1683b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek background.setColor(color); 1684b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek background.setAlpha(alpha); 1685b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 1686b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 1687b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 16881685e634fb0b14033bd436af8d7174436699ffecSelim Cinek public int getMaxExpandHeight() { 1689b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek return mMaxExpandHeight; 1690a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler } 1691584a7aa62c54bcbd654a6696d4fbb56e124874e7Jorim Jaggi 169234958fa272c9216db4002546c3efad692b3d7775Mady Mellor public boolean areGutsExposed() { 16934dd5006ff58c3b1ee5a2e0db343170e7cbd1b585Geoffrey Pitsch return (mGuts != null && mGuts.isExposed()); 169434958fa272c9216db4002546c3efad692b3d7775Mady Mellor } 169534958fa272c9216db4002546c3efad692b3d7775Mady Mellor 1696be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi @Override 16974222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi public boolean isContentExpandable() { 16982f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek NotificationContentView showingLayout = getShowingLayout(); 16992f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek return showingLayout.isContentExpandable(); 17004222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi } 17014222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi 17024222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi @Override 1703560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek protected View getContentView() { 1704aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek if (mIsSummaryWithChildren && !mShowingPublic) { 1705a5703187a9dba418f742fab0874a8f683b0bbb0eSelim Cinek return mChildrenContainer; 1706a5703187a9dba418f742fab0874a8f683b0bbb0eSelim Cinek } 1707560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek return getShowingLayout(); 1708560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek } 1709560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek 1710560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek @Override 1711aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek protected void onAppearAnimationFinished(boolean wasAppearing) { 1712aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek super.onAppearAnimationFinished(wasAppearing); 1713aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek if (wasAppearing) { 1714aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek // During the animation the visible view might have changed, so let's make sure all 1715aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek // alphas are reset 1716aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek if (mChildrenContainer != null) { 1717aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek mChildrenContainer.setAlpha(1.0f); 1718aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek mChildrenContainer.setLayerType(LAYER_TYPE_NONE, null); 1719aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek } 1720eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos for (NotificationContentView l : mLayouts) { 1721eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos l.setAlpha(1.0f); 1722eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos l.setLayerType(LAYER_TYPE_NONE, null); 1723eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos } 1724aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek } 1725aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek } 1726aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek 1727aa3901a5ee68a7256663daa88be92a5faa267c23Selim Cinek @Override 1728b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor public int getExtraBottomPadding() { 1729b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor if (mIsSummaryWithChildren && isGroupExpanded()) { 1730b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor return mIncreasedPaddingBetweenElements; 1731b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 1732b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor return 0; 1733b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 1734b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor 1735b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor @Override 1736d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi public void setActualHeight(int height, boolean notifyListeners) { 1737b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek super.setActualHeight(height, notifyListeners); 17384dd5006ff58c3b1ee5a2e0db343170e7cbd1b585Geoffrey Pitsch if (mGuts != null && mGuts.isExposed()) { 1739b53bc276d6ec093817988a358b7c2a6c63ee0c48Mady Mellor mGuts.setActualHeight(height); 1740b53bc276d6ec093817988a358b7c2a6c63ee0c48Mady Mellor return; 1741b53bc276d6ec093817988a358b7c2a6c63ee0c48Mady Mellor } 1742eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek int contentHeight = Math.max(getMinHeight(), height); 1743eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos for (NotificationContentView l : mLayouts) { 1744eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos l.setContentHeight(contentHeight); 1745eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos } 174642357e030c095867b95e2e8a718649587c5ebf52Selim Cinek if (mIsSummaryWithChildren) { 174742357e030c095867b95e2e8a718649587c5ebf52Selim Cinek mChildrenContainer.setActualHeight(height); 174842357e030c095867b95e2e8a718649587c5ebf52Selim Cinek } 1749b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi if (mGuts != null) { 1750b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi mGuts.setActualHeight(height); 1751b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi } 1752be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi } 1753be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi 1754be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi @Override 1755b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public int getMaxContentHeight() { 175683bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (mIsSummaryWithChildren && !mShowingPublic) { 1757eaa29ca6ff7a4c21a0729118d0e7c38750b9c93eSelim Cinek return mChildrenContainer.getMaxContentHeight(); 175883bc78338437a460076a4b5778ded38440ac3501Selim Cinek } 17592f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek NotificationContentView showingLayout = getShowingLayout(); 17602f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek return showingLayout.getMaxHeight(); 1761be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi } 1762be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi 1763be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi @Override 17644222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi public int getMinHeight() { 176501ee2cd5c4071f528d4b208deeec8d10eec5e1c4Selim Cinek if (!mOnKeyguard && mIsHeadsUp && mHeadsUpManager.isTrackingHeadsUp()) { 176631aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek return getPinnedHeadsUpHeight(false /* atLeastMinHeight */); 176731aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek } else if (mIsSummaryWithChildren && !isGroupExpanded() && !mShowingPublic) { 1768b55386d64aeb80f74ed21035d1e389d86be89db6Selim Cinek return mChildrenContainer.getMinHeight(); 176901ee2cd5c4071f528d4b208deeec8d10eec5e1c4Selim Cinek } else if (!mOnKeyguard && mIsHeadsUp) { 177031aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek return mHeadsUpHeight; 1771b55386d64aeb80f74ed21035d1e389d86be89db6Selim Cinek } 1772816c8e4735f975f4d8bffa1a5a37be6557424ea3Selim Cinek NotificationContentView showingLayout = getShowingLayout(); 1773816c8e4735f975f4d8bffa1a5a37be6557424ea3Selim Cinek return showingLayout.getMinHeight(); 1774816c8e4735f975f4d8bffa1a5a37be6557424ea3Selim Cinek } 1775816c8e4735f975f4d8bffa1a5a37be6557424ea3Selim Cinek 17760aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos private int getAmbientHeight() { 17770aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos NotificationContentView showingLayout = getShowingLayout(); 17780aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos return showingLayout.getAmbientChild() != null 17790aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos ? showingLayout.getAmbientChild().getHeight() 17800aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos : getCollapsedHeight(); 17810aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos } 17820aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos 1783816c8e4735f975f4d8bffa1a5a37be6557424ea3Selim Cinek @Override 1784567e845d99840a6e556595739a15e16132eb2f1eSelim Cinek public int getCollapsedHeight() { 17852c58461daf909fae5a2605f0ba63da3f9c897731Selim Cinek if (mIsSummaryWithChildren && !mShowingPublic) { 1786567e845d99840a6e556595739a15e16132eb2f1eSelim Cinek return mChildrenContainer.getCollapsedHeight(); 178783bc78338437a460076a4b5778ded38440ac3501Selim Cinek } 1788816c8e4735f975f4d8bffa1a5a37be6557424ea3Selim Cinek return getMinHeight(); 17894222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi } 17904222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi 17914222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi @Override 1792be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi public void setClipTopAmount(int clipTopAmount) { 1793be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi super.setClipTopAmount(clipTopAmount); 1794eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos for (NotificationContentView l : mLayouts) { 1795eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos l.setClipTopAmount(clipTopAmount); 1796eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos } 1797b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi if (mGuts != null) { 1798b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi mGuts.setClipTopAmount(clipTopAmount); 1799b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi } 1800be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi } 1801be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi 1802a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek @Override 1803a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek public void setClipBottomAmount(int clipBottomAmount) { 180465d418ec8957fb1af03a8cc68aed90744a5848ffSelim Cinek if (clipBottomAmount != mClipBottomAmount) { 180565d418ec8957fb1af03a8cc68aed90744a5848ffSelim Cinek super.setClipBottomAmount(clipBottomAmount); 1806eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos for (NotificationContentView l : mLayouts) { 1807eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos l.setClipBottomAmount(clipBottomAmount); 1808eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos } 180965d418ec8957fb1af03a8cc68aed90744a5848ffSelim Cinek if (mGuts != null) { 181065d418ec8957fb1af03a8cc68aed90744a5848ffSelim Cinek mGuts.setClipBottomAmount(clipBottomAmount); 181165d418ec8957fb1af03a8cc68aed90744a5848ffSelim Cinek } 1812a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek } 1813b3dadccbc5c7040260a51a3e17efcb74aeec6a11Selim Cinek if (mChildrenContainer != null) { 181465d418ec8957fb1af03a8cc68aed90744a5848ffSelim Cinek // We have to update this even if it hasn't changed, since the children locations can 181565d418ec8957fb1af03a8cc68aed90744a5848ffSelim Cinek // have changed 1816b3dadccbc5c7040260a51a3e17efcb74aeec6a11Selim Cinek mChildrenContainer.setClipBottomAmount(clipBottomAmount); 1817b3dadccbc5c7040260a51a3e17efcb74aeec6a11Selim Cinek } 1818a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek } 1819a686b2c9a91e2e6276676e5730339f7630e2f927Selim Cinek 182031094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek public boolean isMaxExpandHeightInitialized() { 182131094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek return mMaxExpandHeight != 0; 18227d447726e2cb9fae80db417012039828daab8fe7Selim Cinek } 18232f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek 182442357e030c095867b95e2e8a718649587c5ebf52Selim Cinek public NotificationContentView getShowingLayout() { 18252f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek return mShowingPublic ? mPublicLayout : mPrivateLayout; 18262f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek } 182778403d79739605511ea88b653564d81d7bf4bbbaChris Wren 182859ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi public void setShowingLegacyBackground(boolean showing) { 1829eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos for (NotificationContentView l : mLayouts) { 1830eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos l.setShowingLegacyBackground(showing); 1831eb434ff5b7c9f3e1a601c623ce5af46322d28aa9Adrian Roos } 183259ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi } 183359ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi 1834a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek @Override 1835a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek protected void updateBackgroundTint() { 1836a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek super.updateBackgroundTint(); 1837b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor updateBackgroundForGroupState(); 1838a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek if (mIsSummaryWithChildren) { 1839a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek List<ExpandableNotificationRow> notificationChildren = 1840a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek mChildrenContainer.getNotificationChildren(); 1841a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek for (int i = 0; i < notificationChildren.size(); i++) { 1842a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek ExpandableNotificationRow child = notificationChildren.get(i); 1843b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor child.updateBackgroundForGroupState(); 1844a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek } 1845a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek } 1846a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek } 1847a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek 1848b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor /** 1849b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor * Called when a group has finished animating from collapsed or expanded state. 1850b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor */ 1851b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor public void onFinishedExpansionChange() { 1852b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mGroupExpansionChanging = false; 1853b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor updateBackgroundForGroupState(); 1854b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 1855b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor 1856b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor /** 1857b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor * Updates the parent and children backgrounds in a group based on the expansion state. 1858b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor */ 1859b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor public void updateBackgroundForGroupState() { 1860b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor if (mIsSummaryWithChildren) { 1861b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor // Only when the group has finished expanding do we hide its background. 1862b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mShowNoBackground = isGroupExpanded() && !isGroupExpansionChanging() && !isUserLocked(); 1863b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mChildrenContainer.updateHeaderForExpansion(mShowNoBackground); 1864b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor List<ExpandableNotificationRow> children = mChildrenContainer.getNotificationChildren(); 1865b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor for (int i = 0; i < children.size(); i++) { 1866b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor children.get(i).updateBackgroundForGroupState(); 1867b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 1868b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } else if (isChildInGroup()) { 1869b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor final int childColor = getShowingLayout().getBackgroundColorForExpansionState(); 1870b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor // Only show a background if the group is expanded OR if it is expanding / collapsing 1871b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor // and has a custom background color 1872b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor final boolean showBackground = isGroupExpanded() 1873b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor || ((mNotificationParent.isGroupExpansionChanging() 1874b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor || mNotificationParent.isUserLocked()) && childColor != 0); 1875b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mShowNoBackground = !showBackground; 1876b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } else { 1877b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor // Only children or parents ever need no background. 1878b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor mShowNoBackground = false; 1879b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor } 1880b0a824687f56b6950338aad169d8d837f8ed657bMady Mellor updateOutline(); 1881a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek updateBackground(); 1882a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek } 1883a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek 18844a5796765041dcb45ce782fc7ec5866b89fe0df0Adrian Roos public int getPositionOfChild(ExpandableNotificationRow childRow) { 18854a5796765041dcb45ce782fc7ec5866b89fe0df0Adrian Roos if (mIsSummaryWithChildren) { 18864a5796765041dcb45ce782fc7ec5866b89fe0df0Adrian Roos return mChildrenContainer.getPositionInLinearLayout(childRow); 18874a5796765041dcb45ce782fc7ec5866b89fe0df0Adrian Roos } 18884a5796765041dcb45ce782fc7ec5866b89fe0df0Adrian Roos return 0; 18894a5796765041dcb45ce782fc7ec5866b89fe0df0Adrian Roos } 18904a5796765041dcb45ce782fc7ec5866b89fe0df0Adrian Roos 189178403d79739605511ea88b653564d81d7bf4bbbaChris Wren public void setExpansionLogger(ExpansionLogger logger, String key) { 189278403d79739605511ea88b653564d81d7bf4bbbaChris Wren mLogger = logger; 189378403d79739605511ea88b653564d81d7bf4bbbaChris Wren mLoggingKey = key; 189478403d79739605511ea88b653564d81d7bf4bbbaChris Wren } 189578403d79739605511ea88b653564d81d7bf4bbbaChris Wren 18966abeeb91194818e1d19f75336b03d1e305af0842Chris Wren public void onExpandedByGesture(boolean userExpanded) { 18976abeeb91194818e1d19f75336b03d1e305af0842Chris Wren int event = MetricsEvent.ACTION_NOTIFICATION_GESTURE_EXPANDER; 18986abeeb91194818e1d19f75336b03d1e305af0842Chris Wren if (mGroupManager.isSummaryOfGroup(getStatusBarNotification())) { 18996abeeb91194818e1d19f75336b03d1e305af0842Chris Wren event = MetricsEvent.ACTION_NOTIFICATION_GROUP_GESTURE_EXPANDER; 19006abeeb91194818e1d19f75336b03d1e305af0842Chris Wren } 19016abeeb91194818e1d19f75336b03d1e305af0842Chris Wren MetricsLogger.action(mContext, event, userExpanded); 19026abeeb91194818e1d19f75336b03d1e305af0842Chris Wren } 19036abeeb91194818e1d19f75336b03d1e305af0842Chris Wren 19046183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek @Override 190542357e030c095867b95e2e8a718649587c5ebf52Selim Cinek public float getIncreasedPaddingAmount() { 190642357e030c095867b95e2e8a718649587c5ebf52Selim Cinek if (mIsSummaryWithChildren) { 190742357e030c095867b95e2e8a718649587c5ebf52Selim Cinek if (isGroupExpanded()) { 190842357e030c095867b95e2e8a718649587c5ebf52Selim Cinek return 1.0f; 190942357e030c095867b95e2e8a718649587c5ebf52Selim Cinek } else if (isUserLocked()) { 1910f07d06212b08939809aa4128f153bd5179f81fc7Selim Cinek return mChildrenContainer.getGroupExpandFraction(); 191142357e030c095867b95e2e8a718649587c5ebf52Selim Cinek } 191299104836083738f9e5e73ab4170879d91de6ba67Selim Cinek } else if (isColorized() && (!mIsLowPriority || isExpanded())) { 1913a7ed2c1aaa49f0f53507fa3b7e832dca15997a3bSelim Cinek return -1.0f; 191442357e030c095867b95e2e8a718649587c5ebf52Selim Cinek } 191542357e030c095867b95e2e8a718649587c5ebf52Selim Cinek return 0.0f; 191661633a8db8dfdefa84b4444a7ae668d0e24f53e9Selim Cinek } 191761633a8db8dfdefa84b4444a7ae668d0e24f53e9Selim Cinek 1918a7ed2c1aaa49f0f53507fa3b7e832dca15997a3bSelim Cinek private boolean isColorized() { 191999104836083738f9e5e73ab4170879d91de6ba67Selim Cinek return mIsColorized && mBgTint != NO_COLOR; 1920a7ed2c1aaa49f0f53507fa3b7e832dca15997a3bSelim Cinek } 1921a7ed2c1aaa49f0f53507fa3b7e832dca15997a3bSelim Cinek 192261633a8db8dfdefa84b4444a7ae668d0e24f53e9Selim Cinek @Override 19236183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek protected boolean disallowSingleClick(MotionEvent event) { 19246183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek float x = event.getX(); 19256183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek float y = event.getY(); 192634eda5ed70863320e41b6860a550ba6a4248c652Selim Cinek NotificationHeaderView header = getVisibleNotificationHeader(); 19276183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek if (header != null) { 1928a883351024f8dbdf8041c551f8a8987d9357dcd8Mady Mellor return header.isInTouchRect(x - getTranslation(), y); 19296183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek } 19306183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek return super.disallowSingleClick(event); 19316183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek } 19326183d12926a189b08cc3be8d9c78470617e63db0Selim Cinek 193378403d79739605511ea88b653564d81d7bf4bbbaChris Wren private void logExpansionEvent(boolean userAction, boolean wasExpanded) { 1934698b1706be196de41fc6bf03cf15971c82a11949Chris Wren boolean nowExpanded = isExpanded(); 1935698b1706be196de41fc6bf03cf15971c82a11949Chris Wren if (mIsSummaryWithChildren) { 1936698b1706be196de41fc6bf03cf15971c82a11949Chris Wren nowExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification); 1937698b1706be196de41fc6bf03cf15971c82a11949Chris Wren } 193878403d79739605511ea88b653564d81d7bf4bbbaChris Wren if (wasExpanded != nowExpanded && mLogger != null) { 193978403d79739605511ea88b653564d81d7bf4bbbaChris Wren mLogger.logNotificationExpansion(mLoggingKey, userAction, nowExpanded) ; 194078403d79739605511ea88b653564d81d7bf4bbbaChris Wren } 194178403d79739605511ea88b653564d81d7bf4bbbaChris Wren } 1942570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek 1943e9bad242f38bebadae481a22b647cc153f093070Selim Cinek @Override 1944e9bad242f38bebadae481a22b647cc153f093070Selim Cinek public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { 1945e9bad242f38bebadae481a22b647cc153f093070Selim Cinek super.onInitializeAccessibilityNodeInfoInternal(info); 1946e9bad242f38bebadae481a22b647cc153f093070Selim Cinek if (canViewBeDismissed()) { 1947e9bad242f38bebadae481a22b647cc153f093070Selim Cinek info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_DISMISS); 1948e9bad242f38bebadae481a22b647cc153f093070Selim Cinek } 1949e9bad242f38bebadae481a22b647cc153f093070Selim Cinek } 1950e9bad242f38bebadae481a22b647cc153f093070Selim Cinek 1951e9bad242f38bebadae481a22b647cc153f093070Selim Cinek @Override 1952e9bad242f38bebadae481a22b647cc153f093070Selim Cinek public boolean performAccessibilityActionInternal(int action, Bundle arguments) { 1953e9bad242f38bebadae481a22b647cc153f093070Selim Cinek if (super.performAccessibilityActionInternal(action, arguments)) { 1954e9bad242f38bebadae481a22b647cc153f093070Selim Cinek return true; 1955e9bad242f38bebadae481a22b647cc153f093070Selim Cinek } 1956e9bad242f38bebadae481a22b647cc153f093070Selim Cinek switch (action) { 1957e9bad242f38bebadae481a22b647cc153f093070Selim Cinek case AccessibilityNodeInfo.ACTION_DISMISS: 1958e9bad242f38bebadae481a22b647cc153f093070Selim Cinek NotificationStackScrollLayout.performDismiss(this, mGroupManager, 1959e9bad242f38bebadae481a22b647cc153f093070Selim Cinek true /* fromAccessibility */); 1960e9bad242f38bebadae481a22b647cc153f093070Selim Cinek return true; 1961e9bad242f38bebadae481a22b647cc153f093070Selim Cinek } 1962e9bad242f38bebadae481a22b647cc153f093070Selim Cinek return false; 1963e9bad242f38bebadae481a22b647cc153f093070Selim Cinek } 1964e9bad242f38bebadae481a22b647cc153f093070Selim Cinek 1965e9bad242f38bebadae481a22b647cc153f093070Selim Cinek public boolean shouldRefocusOnDismiss() { 1966e9bad242f38bebadae481a22b647cc153f093070Selim Cinek return mRefocusOnDismiss || isAccessibilityFocused(); 1967e9bad242f38bebadae481a22b647cc153f093070Selim Cinek } 1968e9bad242f38bebadae481a22b647cc153f093070Selim Cinek 1969570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek public interface OnExpandClickListener { 197031aada4ef4ff37f8cdc110b196c06918841647c7Selim Cinek void onExpandClicked(NotificationData.Entry clickedEntry, boolean nowExpanded); 1971570981d5f1bcd0e5186cc02655254a0606b6ec14Selim Cinek } 1972bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek 1973bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek @Override 1974bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek public ExpandableViewState createNewViewState(StackScrollState stackScrollState) { 1975bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek return new NotificationViewState(stackScrollState); 1976bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek } 1977bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek 1978d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek @Override 1979d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek public boolean isAboveShelf() { 1980d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek return mIsPinned || mHeadsupDisappearRunning || (mIsHeadsUp && mAboveShelf); 1981d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek } 1982d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek 19830aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos public void setShowAmbient(boolean showAmbient) { 19840aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos if (showAmbient != mShowAmbient) { 19850aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos mShowAmbient = showAmbient; 19860aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos notifyHeightChanged(false /* needsAnimation */); 19870aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos } 19880aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos } 19890aac04ff79b43933742d5ebdd8d7a94751ff6309Adrian Roos 1990d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek public void setAboveShelf(boolean aboveShelf) { 1991d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek mAboveShelf = aboveShelf; 1992d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek } 1993d127d7923191c5023db423952d639f6ec8aa86ccSelim Cinek 1994d4776a52b45a9f83f0c67f7e967c36ec9cb2c17aSelim Cinek public static class NotificationViewState extends ExpandableViewState { 1995bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek 1996bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek private final StackScrollState mOverallState; 19970242fbb9fdd7db0398a197d0e63d20dcac7cd916Selim Cinek 1998bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek 1999bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek private NotificationViewState(StackScrollState stackScrollState) { 2000bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek mOverallState = stackScrollState; 2001bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek } 2002bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek 2003bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek @Override 2004bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek public void applyToView(View view) { 2005bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek super.applyToView(view); 2006bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek if (view instanceof ExpandableNotificationRow) { 2007bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek ExpandableNotificationRow row = (ExpandableNotificationRow) view; 2008bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek row.applyChildrenState(mOverallState); 2009bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek } 2010bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek } 20110cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek 20120cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek @Override 20132b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek protected void onYTranslationAnimationFinished(View view) { 20142b549f4bd436787bd2543812b24add2d8c5b53eeSelim Cinek super.onYTranslationAnimationFinished(view); 2015d4776a52b45a9f83f0c67f7e967c36ec9cb2c17aSelim Cinek if (view instanceof ExpandableNotificationRow) { 2016d4776a52b45a9f83f0c67f7e967c36ec9cb2c17aSelim Cinek ExpandableNotificationRow row = (ExpandableNotificationRow) view; 2017d4776a52b45a9f83f0c67f7e967c36ec9cb2c17aSelim Cinek if (row.isHeadsUpAnimatingAway()) { 2018d4776a52b45a9f83f0c67f7e967c36ec9cb2c17aSelim Cinek row.setHeadsUpAnimatingAway(false); 2019d4776a52b45a9f83f0c67f7e967c36ec9cb2c17aSelim Cinek } 20200cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek } 20210cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek } 20220cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek 20230cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek @Override 20240cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek public void animateTo(View child, AnimationProperties properties) { 20250cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek super.animateTo(child, properties); 20260cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek if (child instanceof ExpandableNotificationRow) { 20270cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek ExpandableNotificationRow row = (ExpandableNotificationRow) child; 20280cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek row.startChildAnimation(mOverallState, properties); 20290cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek } 20300cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek } 2031bbcebde5f47d070d82270a367bec2f375c55d359Selim Cinek } 203251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren} 2033