ExpandableNotificationRow.java revision a6c6bfb61ba14b0467b73082d591c834576cddf4
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 19a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinekimport android.app.Notification; 2051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wrenimport android.content.Context; 21cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinekimport android.graphics.drawable.AnimatedVectorDrawable; 22cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinekimport android.graphics.drawable.AnimationDrawable; 23b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport android.graphics.drawable.ColorDrawable; 24cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinekimport android.graphics.drawable.Drawable; 25b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggiimport android.service.notification.StatusBarNotification; 2651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wrenimport android.util.AttributeSet; 271a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinekimport android.view.MotionEvent; 28a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandlerimport android.view.View; 29b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggiimport android.view.ViewStub; 30fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggiimport android.view.accessibility.AccessibilityEvent; 31b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport android.view.animation.LinearInterpolator; 3298713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinekimport android.widget.Chronometer; 33cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinekimport android.widget.ImageView; 34b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 35a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandlerimport com.android.systemui.R; 360e2ffbd48bbedf47deb7f6aed96bd07e2fc96f53Blazej Magnowskiimport com.android.systemui.classifier.FalsingManager; 378d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinekimport com.android.systemui.statusbar.notification.NotificationHeaderView; 38b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport com.android.systemui.statusbar.phone.NotificationGroupManager; 39b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport com.android.systemui.statusbar.stack.NotificationChildrenContainer; 40b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport com.android.systemui.statusbar.stack.StackScrollState; 41b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport com.android.systemui.statusbar.stack.StackStateAnimator; 42b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport com.android.systemui.statusbar.stack.StackViewState; 43b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 44b5605e58cb8080c8c887b1885336b707596c8094Selim Cinekimport java.util.List; 45a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler 464222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggipublic class ExpandableNotificationRow extends ActivatableNotificationView { 47b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 48b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private static final int DEFAULT_DIVIDER_ALPHA = 0x29; 49b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private static final int COLORED_DIVIDER_ALPHA = 0x7B; 50b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private final LinearInterpolator mLinearInterpolator = new LinearInterpolator(); 511685e634fb0b14033bd436af8d7174436699ffecSelim Cinek private int mRowMinHeight; 5251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 531685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** Does this row contain layouts that can adapt to row expansion */ 5451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren private boolean mExpandable; 551685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** Has the user actively changed the expansion state of this row */ 561685e634fb0b14033bd436af8d7174436699ffecSelim Cinek private boolean mHasUserChangedExpansion; 571685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** If {@link #mHasUserChangedExpansion}, has the user expanded this row */ 5851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren private boolean mUserExpanded; 591685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** Is the user touching this row */ 6051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren private boolean mUserLocked; 611685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** Are we showing the "public" version */ 62a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler private boolean mShowingPublic; 63ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi private boolean mSensitive; 64ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi private boolean mShowingPublicInitialized; 6560122be6747c4f79b96f6808158f8f7e7548b7d3Selim Cinek private boolean mHideSensitiveForIntrinsicHeight; 6651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 671685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** 681685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * Is this notification expanded by the system. The expansion state can be overridden by the 691685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * user expansion. 701685e634fb0b14033bd436af8d7174436699ffecSelim Cinek */ 711685e634fb0b14033bd436af8d7174436699ffecSelim Cinek private boolean mIsSystemExpanded; 72dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi 73dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi /** 7483bc78338437a460076a4b5778ded38440ac3501Selim Cinek * Whether the notification is on the keyguard and the expansion is disabled. 75dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi */ 7683bc78338437a460076a4b5778ded38440ac3501Selim Cinek private boolean mOnKeyguard; 77dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi 78be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi private NotificationContentView mPublicLayout; 79be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi private NotificationContentView mPrivateLayout; 801685e634fb0b14033bd436af8d7174436699ffecSelim Cinek private int mMaxExpandHeight; 818d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek private int mHeadsUpHeight; 82863834bd96bdebcf21f4c4a7d8285d4858c061e4Selim Cinek private View mVetoButton; 830d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler private boolean mClearable; 8478403d79739605511ea88b653564d81d7bf4bbbaChris Wren private ExpansionLogger mLogger; 8578403d79739605511ea88b653564d81d7bf4bbbaChris Wren private String mLoggingKey; 86a5e211b1f2a8d055b369dadc464dc5d5bc3dd9c1Selim Cinek private boolean mWasReset; 878d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek private NotificationGuts mGuts; 88b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi private StatusBarNotification mStatusBarNotification; 891a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek private boolean mIsHeadsUp; 9098713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek private boolean mLastChronometerRunning = true; 91eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek private NotificationHeaderView mNotificationHeader; 92eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek private ViewStub mNotificationHeaderStub; 93b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private ViewStub mChildrenContainerStub; 94b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private NotificationGroupManager mGroupManager; 95b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private boolean mChildrenExpanded; 96263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek private boolean mIsSummaryWithChildren; 97b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private NotificationChildrenContainer mChildrenContainer; 98ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek private ViewStub mGutsStub; 99eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek private boolean mHasNotificationHeader; 100b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private boolean mIsSystemChildExpanded; 101684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek private boolean mIsPinned; 1020e2ffbd48bbedf47deb7f6aed96bd07e2fc96f53Blazej Magnowski private FalsingManager mFalsingManager; 103b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi 1045eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi private boolean mJustClicked; 105eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek private NotificationData.Entry mEntry; 10634d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek private boolean mShowNoBackground; 107388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek private ExpandableNotificationRow mNotificationParent; 1085eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi 1098d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek public NotificationContentView getPrivateLayout() { 1108d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek return mPrivateLayout; 1118d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek } 1128d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek 1138d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek public NotificationContentView getPublicLayout() { 1148d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek return mPublicLayout; 1158d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek } 1168d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek 117cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek public void setIconAnimationRunning(boolean running) { 118cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek setIconAnimationRunning(running, mPublicLayout); 119cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek setIconAnimationRunning(running, mPrivateLayout); 120cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 121cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek 122cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek private void setIconAnimationRunning(boolean running, NotificationContentView layout) { 123cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek if (layout != null) { 124cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek View contractedChild = layout.getContractedChild(); 125cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek View expandedChild = layout.getExpandedChild(); 1268d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek View headsUpChild = layout.getHeadsUpChild(); 127cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek setIconAnimationRunningForChild(running, contractedChild); 128cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek setIconAnimationRunningForChild(running, expandedChild); 1298d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek setIconAnimationRunningForChild(running, headsUpChild); 130cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 131cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 132cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek 133cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek private void setIconAnimationRunningForChild(boolean running, View child) { 134cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek if (child != null) { 135cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek ImageView icon = (ImageView) child.findViewById(com.android.internal.R.id.icon); 136cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek setIconRunning(icon, running); 137cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek ImageView rightIcon = (ImageView) child.findViewById( 138cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek com.android.internal.R.id.right_icon); 139cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek setIconRunning(rightIcon, running); 140cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 141cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 142cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek 143cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek private void setIconRunning(ImageView imageView, boolean running) { 144cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek if (imageView != null) { 145cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek Drawable drawable = imageView.getDrawable(); 146cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek if (drawable instanceof AnimationDrawable) { 147cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek AnimationDrawable animationDrawable = (AnimationDrawable) drawable; 148cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek if (running) { 149cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek animationDrawable.start(); 150cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } else { 151cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek animationDrawable.stop(); 152cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 153cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } else if (drawable instanceof AnimatedVectorDrawable) { 154cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek AnimatedVectorDrawable animationDrawable = (AnimatedVectorDrawable) drawable; 155cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek if (running) { 156cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek animationDrawable.start(); 157cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } else { 158cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek animationDrawable.stop(); 159cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 160cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 161cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 162cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek } 163cab4a60c485872848fc0fa3e65baaeb06d21a7d8Selim Cinek 164eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek private void setStatusBarNotification(StatusBarNotification statusBarNotification) { 165b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi mStatusBarNotification = statusBarNotification; 16683bc78338437a460076a4b5778ded38440ac3501Selim Cinek mPrivateLayout.setStatusBarNotification(statusBarNotification); 167a37774f098a5204947ff4b4787c4b753bb9016dbSelim Cinek updateVetoButton(); 168263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek onChildrenCountChanged(); 169b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi } 170b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi 171b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi public StatusBarNotification getStatusBarNotification() { 172b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi return mStatusBarNotification; 173b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi } 174b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi 175b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek public boolean isHeadsUp() { 176b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek return mIsHeadsUp; 177b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek } 178b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek 1791a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek public void setHeadsUp(boolean isHeadsUp) { 180c80fdb11f55f4c1f3ca9b5cdc7035afa2a0b9e91Selim Cinek int intrinsicBefore = getIntrinsicHeight(); 1811a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek mIsHeadsUp = isHeadsUp; 1828d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek mPrivateLayout.setHeadsUp(isHeadsUp); 183c80fdb11f55f4c1f3ca9b5cdc7035afa2a0b9e91Selim Cinek if (intrinsicBefore != getIntrinsicHeight()) { 184c80fdb11f55f4c1f3ca9b5cdc7035afa2a0b9e91Selim Cinek notifyHeightChanged(false /* needsAnimation */); 185c80fdb11f55f4c1f3ca9b5cdc7035afa2a0b9e91Selim Cinek } 1861a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek } 1871a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek 188b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void setGroupManager(NotificationGroupManager groupManager) { 189b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mGroupManager = groupManager; 19083bc78338437a460076a4b5778ded38440ac3501Selim Cinek mPrivateLayout.setGroupManager(groupManager); 191b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 192b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 193b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void addChildNotification(ExpandableNotificationRow row) { 194b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek addChildNotification(row, -1); 195b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 196b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 197b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek /** 198b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * Add a child notification to this view. 199b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * 200b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * @param row the row to add 201b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * @param childIndex the index to add it at, if -1 it will be added at the end 202b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek */ 203b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void addChildNotification(ExpandableNotificationRow row, int childIndex) { 204b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek if (mChildrenContainer == null) { 205b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainerStub.inflate(); 206b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 207b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainer.addNotification(row, childIndex); 208263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek onChildrenCountChanged(); 209263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek row.setIsChildInGroup(true, this); 210b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 211b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 212b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void removeChildNotification(ExpandableNotificationRow row) { 213b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek if (mChildrenContainer != null) { 214b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainer.removeNotification(row); 215b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 216263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek onChildrenCountChanged(); 217263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek row.setIsChildInGroup(false, null); 218263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek } 219263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek 220263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek public boolean isChildInGroup() { 221a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek return mNotificationParent != null; 222263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek } 223263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek 224388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek public ExpandableNotificationRow getNotificationParent() { 225388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek return mNotificationParent; 226388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek } 227388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek 228263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek /** 229263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek * @param isChildInGroup Is this notification now in a group 230263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek * @param parent the new parent notification 231263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek */ 232a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek public void setIsChildInGroup(boolean isChildInGroup, ExpandableNotificationRow parent) {; 233a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek boolean childInGroup = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS && isChildInGroup; 234a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek mNotificationParent = childInGroup ? parent : null; 235a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek mPrivateLayout.setIsChildInGroup(childInGroup); 236a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek updateNoBackgroundState(); 23734d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek } 23834d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek 23934d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek @Override 24034d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek protected boolean shouldHideBackground() { 24134d93b0985063090a9bad88a1b80e1b99bae3332Selim Cinek return super.shouldHideBackground() || mShowNoBackground; 242263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek } 243263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek 244263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek @Override 245263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek public boolean isSummaryWithChildren() { 246263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek return mIsSummaryWithChildren; 247b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 248b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 249b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek @Override 250b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public boolean areChildrenExpanded() { 251b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek return mChildrenExpanded; 252b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 253b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 254b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public List<ExpandableNotificationRow> getNotificationChildren() { 255b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek return mChildrenContainer == null ? null : mChildrenContainer.getNotificationChildren(); 256b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 257b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 258eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek public int getNumberOfNotificationChildren() { 259eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek if (mChildrenContainer == null) { 260eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek return 0; 261eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek } 262eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek return mChildrenContainer.getNotificationChildren().size(); 263eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek } 264eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek 265b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek /** 266b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * Apply the order given in the list to the children. 267b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * 268b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * @param childOrder the new list order 269b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek * @return whether the list order has changed 270b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek */ 271b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public boolean applyChildOrder(List<ExpandableNotificationRow> childOrder) { 272b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek return mChildrenContainer != null && mChildrenContainer.applyChildOrder(childOrder); 273b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 274b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 275b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void getChildrenStates(StackScrollState resultState) { 27683bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (mIsSummaryWithChildren) { 277b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek StackViewState parentState = resultState.getViewStateForView(this); 278b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainer.getState(resultState, parentState); 279b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 280b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 281b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 282b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void applyChildrenState(StackScrollState state) { 28383bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (mIsSummaryWithChildren) { 284b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainer.applyState(state); 285b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 286b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 287b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 288b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void prepareExpansionChanged(StackScrollState state) { 28983bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (mIsSummaryWithChildren) { 290b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainer.prepareExpansionChanged(state); 291b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 292b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 293b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 294b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void startChildAnimation(StackScrollState finalState, 295b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek StackStateAnimator stateAnimator, boolean withDelays, long delay, long duration) { 29683bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (mIsSummaryWithChildren) { 297b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainer.startAnimationToState(finalState, stateAnimator, withDelays, delay, 298b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek duration); 299b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 300b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 301b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 302b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public ExpandableNotificationRow getViewAtPosition(float y) { 30383bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (!mIsSummaryWithChildren || !mChildrenExpanded) { 304b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek return this; 305b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } else { 306b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek ExpandableNotificationRow view = mChildrenContainer.getViewAtPosition(y); 307b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek return view == null ? this : view; 308b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 309b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 310b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 311ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek public NotificationGuts getGuts() { 312ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek return mGuts; 313ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek } 314ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek 315684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek /** 316684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek * Set this notification to be pinned to the top if {@link #isHeadsUp()} is true. By doing this 317684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek * the notification will be rendered on top of the screen. 318684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek * 319684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek * @param pinned whether it is pinned 320684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek */ 321684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek public void setPinned(boolean pinned) { 322684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek mIsPinned = pinned; 32398713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek setChronometerRunning(mLastChronometerRunning); 324b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek } 325b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek 326684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek public boolean isPinned() { 327684a442b812a5e95d813700ffa2fd17ca72048a7Selim Cinek return mIsPinned; 328b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek } 329b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek 330b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek public int getHeadsUpHeight() { 3318d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek return mHeadsUpHeight; 332b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek } 333b8f09cf5533d458868a335ce334e4880b2b0788dSelim Cinek 3345eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi /** 3355eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi * Mark whether this notification was just clicked, i.e. the user has just clicked this 3365eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi * notification in this frame. 3375eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi */ 3385eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi public void setJustClicked(boolean justClicked) { 3395eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi mJustClicked = justClicked; 3405eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi } 3415eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi 3425eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi /** 3435eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi * @return true if this notification has been clicked in this frame, false otherwise 3445eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi */ 3455eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi public boolean wasJustClicked() { 3465eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi return mJustClicked; 3475eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi } 3485eb67c22489f5fda22770d1fc824e7a8013ec025Jorim Jaggi 34998713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek public void setChronometerRunning(boolean running) { 35098713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek mLastChronometerRunning = running; 35198713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek setChronometerRunning(running, mPrivateLayout); 35298713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek setChronometerRunning(running, mPublicLayout); 35398713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek if (mChildrenContainer != null) { 35498713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek List<ExpandableNotificationRow> notificationChildren = 35598713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek mChildrenContainer.getNotificationChildren(); 35698713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek for (int i = 0; i < notificationChildren.size(); i++) { 35798713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek ExpandableNotificationRow child = notificationChildren.get(i); 35898713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek child.setChronometerRunning(running); 35998713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 36098713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 36198713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 36298713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek 36398713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek private void setChronometerRunning(boolean running, NotificationContentView layout) { 36498713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek if (layout != null) { 36598713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek running = running || isPinned(); 36698713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek View contractedChild = layout.getContractedChild(); 36798713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek View expandedChild = layout.getExpandedChild(); 36898713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek View headsUpChild = layout.getHeadsUpChild(); 36998713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek setChronometerRunningForChild(running, contractedChild); 37098713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek setChronometerRunningForChild(running, expandedChild); 37198713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek setChronometerRunningForChild(running, headsUpChild); 37298713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 37398713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 37498713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek 37598713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek private void setChronometerRunningForChild(boolean running, View child) { 37698713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek if (child != null) { 37798713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek View chronometer = child.findViewById(com.android.internal.R.id.chronometer); 37898713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek if (chronometer instanceof Chronometer) { 37998713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek ((Chronometer) chronometer).setStarted(running); 38098713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 38198713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 38298713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek } 38398713a4fcf1061d3366b333c954fd7b8e9f12841Selim Cinek 384eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek public void setEntry(NotificationData.Entry entry) { 385eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek mEntry = entry; 386eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek setStatusBarNotification(entry.notification); 387eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek } 388eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek 3898d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek public CharSequence getSubText() { 3908d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek Notification notification = mStatusBarNotification.getNotification(); 3918d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek CharSequence subText = notification.extras.getCharSequence(Notification.EXTRA_SUMMARY_TEXT); 3928d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek if (subText == null) { 3938d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek subText = notification.extras.getCharSequence(Notification.EXTRA_SUB_TEXT); 3948d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek } 3958d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek return subText; 3968d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek } 3978d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek 3988d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek public void setContentSubTextVisible(boolean visible) { 3998d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek mPrivateLayout.setSubTextVisible(visible); 4008d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek } 4018d6440dbaba4310cb517ab2a725d75be1ef934f4Selim Cinek 40278403d79739605511ea88b653564d81d7bf4bbbaChris Wren public interface ExpansionLogger { 40378403d79739605511ea88b653564d81d7bf4bbbaChris Wren public void logNotificationExpansion(String key, boolean userAction, boolean expanded); 40478403d79739605511ea88b653564d81d7bf4bbbaChris Wren } 4051685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 40651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public ExpandableNotificationRow(Context context, AttributeSet attrs) { 40751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren super(context, attrs); 4080e2ffbd48bbedf47deb7f6aed96bd07e2fc96f53Blazej Magnowski mFalsingManager = FalsingManager.getInstance(context); 40951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 41051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 411a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer /** 412a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer * Resets this view so it can be re-used for an updated notification. 413a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer */ 41422f2ee567dd1b1a42432251229bcb2f05c1c4700Christoph Studer @Override 415a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer public void reset() { 41622f2ee567dd1b1a42432251229bcb2f05c1c4700Christoph Studer super.reset(); 417a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer mRowMinHeight = 0; 41878403d79739605511ea88b653564d81d7bf4bbbaChris Wren final boolean wasExpanded = isExpanded(); 419379ff8f6b18b236b679a59a2dc14c0baeede3baeSelim Cinek mMaxViewHeight = 0; 420a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer mExpandable = false; 421a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer mHasUserChangedExpansion = false; 422a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer mUserLocked = false; 423a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer mShowingPublic = false; 424ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mSensitive = false; 425ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mShowingPublicInitialized = false; 426a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer mIsSystemExpanded = false; 42783bc78338437a460076a4b5778ded38440ac3501Selim Cinek mOnKeyguard = false; 4281a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek mPublicLayout.reset(mIsHeadsUp); 4291a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek mPrivateLayout.reset(mIsHeadsUp); 43031094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek resetHeight(); 43131094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek logExpansionEvent(false, wasExpanded); 43231094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek } 43331094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek 43431094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek public void resetHeight() { 4351a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek if (mIsHeadsUp) { 4361a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek resetActualHeight(); 4371a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek } 438a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer mMaxExpandHeight = 0; 4398d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek mHeadsUpHeight = 0; 440a5e211b1f2a8d055b369dadc464dc5d5bc3dd9c1Selim Cinek mWasReset = true; 44131094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek onHeightReset(); 4426e28a678c7f9fe2cae5a51bfdbab3071a2d8d0baSelim Cinek requestLayout(); 443a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer } 444a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer 445251957d76e57eb6e5f8068b37346144e10e586a4Jorim Jaggi @Override 4461a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek protected boolean filterMotionEvent(MotionEvent event) { 4471a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek return mIsHeadsUp || super.filterMotionEvent(event); 4481a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek } 4491a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek 4501a521f3ea841f6db9686bbec7f950a3883d075aaSelim Cinek @Override 451251957d76e57eb6e5f8068b37346144e10e586a4Jorim Jaggi protected void onFinishInflate() { 452251957d76e57eb6e5f8068b37346144e10e586a4Jorim Jaggi super.onFinishInflate(); 453be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic); 454be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded); 455ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek mGutsStub = (ViewStub) findViewById(R.id.notification_guts_stub); 456ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek mGutsStub.setOnInflateListener(new ViewStub.OnInflateListener() { 457b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi @Override 458b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi public void onInflate(ViewStub stub, View inflated) { 459b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi mGuts = (NotificationGuts) inflated; 460b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi mGuts.setClipTopAmount(getClipTopAmount()); 461b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi mGuts.setActualHeight(getActualHeight()); 462ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek mGutsStub = null; 463b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi } 464b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi }); 465eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek mNotificationHeaderStub = (ViewStub) findViewById(R.id.notification_header_stub); 466eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek mNotificationHeaderStub.setOnInflateListener(new ViewStub.OnInflateListener() { 467b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek @Override 468b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void onInflate(ViewStub stub, View inflated) { 469eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek mNotificationHeader = (NotificationHeaderView) inflated; 470eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek mNotificationHeader.setGroupManager(mGroupManager); 471eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek mNotificationHeader.bind(mEntry); 472b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 473b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek }); 474b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainerStub = (ViewStub) findViewById(R.id.child_container_stub); 475b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainerStub.setOnInflateListener(new ViewStub.OnInflateListener() { 476b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 477b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek @Override 478b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void onInflate(ViewStub stub, View inflated) { 479b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenContainer = (NotificationChildrenContainer) inflated; 480388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek mChildrenContainer.setNotificationParent(ExpandableNotificationRow.this); 481b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 482b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek }); 483863834bd96bdebcf21f4c4a7d8285d4858c061e4Selim Cinek mVetoButton = findViewById(R.id.veto); 484fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi } 485fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi 486ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek public void inflateGuts() { 487ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek if (mGuts == null) { 488ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek mGutsStub.inflate(); 489ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek } 490ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek } 491ab29aebf00a0ebd286a92d129f35c182b6888f3bSelim Cinek 492b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private void updateChildrenVisibility(boolean animated) { 493b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek if (mChildrenContainer == null) { 494b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek return; 495b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 496eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek mChildrenContainer.setVisibility(mIsSummaryWithChildren ? VISIBLE : INVISIBLE); 497eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek mPrivateLayout.setVisibility(!mIsSummaryWithChildren ? VISIBLE : INVISIBLE); 498b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 499b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 500fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi @Override 501a54956a0bc611b1e9b3914edc7a604b59688f6b7Alan Viverette public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event) { 502a54956a0bc611b1e9b3914edc7a604b59688f6b7Alan Viverette if (super.onRequestSendAccessibilityEventInternal(child, event)) { 503fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi // Add a record for the entire layout since its content is somehow small. 504fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi // The event comes from a leaf view that is interacted with. 505fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi AccessibilityEvent record = AccessibilityEvent.obtain(); 506fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi onInitializeAccessibilityEvent(record); 507fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi dispatchPopulateAccessibilityEvent(record); 508fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi event.appendRecord(record); 509fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi return true; 510fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi } 511fe40f7d13bfc1faa35c9a131ce4be5104cb8f6b9Jorim Jaggi return false; 512c5dc0d0cce373fbf292e13633c114a431d747167Jorim Jaggi } 51351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 514e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock @Override 5154e857f4ef0357e05806819d0488a73a12208fe8fJorim Jaggi public void setDark(boolean dark, boolean fade, long delay) { 5164e857f4ef0357e05806819d0488a73a12208fe8fJorim Jaggi super.setDark(dark, fade, delay); 517e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock final NotificationContentView showing = getShowingLayout(); 518e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock if (showing != null) { 5194e857f4ef0357e05806819d0488a73a12208fe8fJorim Jaggi showing.setDark(dark, fade, delay); 520e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock } 521e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock } 522e15452bb49d2531eee3086acb4763dd125f8053aJohn Spurlock 5231685e634fb0b14033bd436af8d7174436699ffecSelim Cinek public void setHeightRange(int rowMinHeight, int rowMaxHeight) { 5241685e634fb0b14033bd436af8d7174436699ffecSelim Cinek mRowMinHeight = rowMinHeight; 525379ff8f6b18b236b679a59a2dc14c0baeede3baeSelim Cinek mMaxViewHeight = rowMaxHeight; 52651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 52751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 52851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public boolean isExpandable() { 529388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek if (mIsSummaryWithChildren && !mShowingPublic) { 530388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek return !mChildrenExpanded; 531388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek } 53251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren return mExpandable; 53351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 53451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 53551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public void setExpandable(boolean expandable) { 53651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren mExpandable = expandable; 53751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 53851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 5391685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** 5401685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * @return whether the user has changed the expansion state 5411685e634fb0b14033bd436af8d7174436699ffecSelim Cinek */ 5421685e634fb0b14033bd436af8d7174436699ffecSelim Cinek public boolean hasUserChangedExpansion() { 5431685e634fb0b14033bd436af8d7174436699ffecSelim Cinek return mHasUserChangedExpansion; 5441685e634fb0b14033bd436af8d7174436699ffecSelim Cinek } 5451685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 54651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public boolean isUserExpanded() { 54751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren return mUserExpanded; 54851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 54951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 5501685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** 5511685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * Set this notification to be expanded by the user 5521685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * 5531685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * @param userExpanded whether the user wants this notification to be expanded 5541685e634fb0b14033bd436af8d7174436699ffecSelim Cinek */ 55551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public void setUserExpanded(boolean userExpanded) { 556388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek setUserExpanded(userExpanded, false /* allowChildExpansion */); 557388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek } 558388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek 559388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek /** 560388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek * Set this notification to be expanded by the user 561388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek * 562388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek * @param userExpanded whether the user wants this notification to be expanded 563388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek * @param allowChildExpansion whether a call to this method allows expanding children 564388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek */ 565388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek public void setUserExpanded(boolean userExpanded, boolean allowChildExpansion) { 5660e2ffbd48bbedf47deb7f6aed96bd07e2fc96f53Blazej Magnowski mFalsingManager.setNotificationExpanded(); 567388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek if (mIsSummaryWithChildren && !mShowingPublic && allowChildExpansion) { 568388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek mGroupManager.setGroupExpanded(mStatusBarNotification, userExpanded); 569388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek return; 570388df6dd3d07376ecd7446cae36e1486cd313171Selim Cinek } 571a7fe63190cc3f95af1830886edd80acef0c334e3Christoph Studer if (userExpanded && !mExpandable) return; 57278403d79739605511ea88b653564d81d7bf4bbbaChris Wren final boolean wasExpanded = isExpanded(); 5731685e634fb0b14033bd436af8d7174436699ffecSelim Cinek mHasUserChangedExpansion = true; 57451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren mUserExpanded = userExpanded; 57578403d79739605511ea88b653564d81d7bf4bbbaChris Wren logExpansionEvent(true, wasExpanded); 57651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 57751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 578ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek public void resetUserExpansion() { 579ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek mHasUserChangedExpansion = false; 580ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek mUserExpanded = false; 581ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek } 582ccd14fbcfe613eae71f0e00c39f38e5125749389Selim Cinek 58351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public boolean isUserLocked() { 58451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren return mUserLocked; 58551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 58651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 58751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public void setUserLocked(boolean userLocked) { 58851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren mUserLocked = userLocked; 58951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 59051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 5911685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** 5921685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * @return has the system set this notification to be expanded 5931685e634fb0b14033bd436af8d7174436699ffecSelim Cinek */ 5941685e634fb0b14033bd436af8d7174436699ffecSelim Cinek public boolean isSystemExpanded() { 5951685e634fb0b14033bd436af8d7174436699ffecSelim Cinek return mIsSystemExpanded; 5961685e634fb0b14033bd436af8d7174436699ffecSelim Cinek } 5971685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 5981685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** 5991685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * Set this notification to be expanded by the system. 6001685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * 6011685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * @param expand whether the system wants this notification to be expanded. 6021685e634fb0b14033bd436af8d7174436699ffecSelim Cinek */ 6031685e634fb0b14033bd436af8d7174436699ffecSelim Cinek public void setSystemExpanded(boolean expand) { 60431094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek if (expand != mIsSystemExpanded) { 60531094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek final boolean wasExpanded = isExpanded(); 60631094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek mIsSystemExpanded = expand; 607b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek notifyHeightChanged(false /* needsAnimation */); 60831094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek logExpansionEvent(false, wasExpanded); 60983bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (mChildrenContainer != null) { 61083bc78338437a460076a4b5778ded38440ac3501Selim Cinek mChildrenContainer.updateGroupOverflow(); 61183bc78338437a460076a4b5778ded38440ac3501Selim Cinek } 61231094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek } 613dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi } 614dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi 615dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi /** 61683bc78338437a460076a4b5778ded38440ac3501Selim Cinek * @param onKeyguard whether to prevent notification expansion 617dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi */ 61883bc78338437a460076a4b5778ded38440ac3501Selim Cinek public void setOnKeyguard(boolean onKeyguard) { 61983bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (onKeyguard != mOnKeyguard) { 62031094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek final boolean wasExpanded = isExpanded(); 62183bc78338437a460076a4b5778ded38440ac3501Selim Cinek mOnKeyguard = onKeyguard; 62231094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek logExpansionEvent(false, wasExpanded); 62331094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek if (wasExpanded != isExpanded()) { 624b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek notifyHeightChanged(false /* needsAnimation */); 62531094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek } 62631094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek } 6271685e634fb0b14033bd436af8d7174436699ffecSelim Cinek } 6281685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 6291685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** 6300d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler * @return Can the underlying notification be cleared? 6310d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler */ 6320d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler public boolean isClearable() { 633a37774f098a5204947ff4b4787c4b753bb9016dbSelim Cinek return mStatusBarNotification != null && mStatusBarNotification.isClearable(); 6340d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler } 6350d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler 6360d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler /** 6371685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * Apply an expansion state to the layout. 6381685e634fb0b14033bd436af8d7174436699ffecSelim Cinek */ 639dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi public void applyExpansionToLayout() { 640dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi boolean expand = isExpanded(); 64151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren if (expand && mExpandable) { 642eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek setActualHeight(mMaxExpandHeight); 64351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } else { 644eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek setActualHeight(mRowMinHeight); 64551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 64651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 647a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler 6489cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi @Override 6499cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi public int getIntrinsicHeight() { 650be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi if (isUserLocked()) { 651be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi return getActualHeight(); 652be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi } 6531685e634fb0b14033bd436af8d7174436699ffecSelim Cinek boolean inExpansionState = isExpanded(); 65460122be6747c4f79b96f6808158f8f7e7548b7d3Selim Cinek if (mSensitive && mHideSensitiveForIntrinsicHeight) { 65560122be6747c4f79b96f6808158f8f7e7548b7d3Selim Cinek return mRowMinHeight; 65683bc78338437a460076a4b5778ded38440ac3501Selim Cinek } else if (mIsSummaryWithChildren && !mOnKeyguard) { 65783bc78338437a460076a4b5778ded38440ac3501Selim Cinek return mChildrenContainer.getIntrinsicHeight() 65883bc78338437a460076a4b5778ded38440ac3501Selim Cinek + mNotificationHeader.getHeight(); 65960122be6747c4f79b96f6808158f8f7e7548b7d3Selim Cinek } else if (mIsHeadsUp) { 6608d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek if (inExpansionState) { 66183bc78338437a460076a4b5778ded38440ac3501Selim Cinek return Math.max(mMaxExpandHeight, mHeadsUpHeight); 6628d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek } else { 66383bc78338437a460076a4b5778ded38440ac3501Selim Cinek return Math.max(mRowMinHeight, mHeadsUpHeight); 6648d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek } 665a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek } else if (!inExpansionState || (isChildInGroup() && !isGroupExpanded())) { 66683bc78338437a460076a4b5778ded38440ac3501Selim Cinek return getMinHeight(); 667b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } else { 66883bc78338437a460076a4b5778ded38440ac3501Selim Cinek return getMaxExpandHeight(); 6691685e634fb0b14033bd436af8d7174436699ffecSelim Cinek } 670b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 6711685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 672eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek private boolean isGroupExpanded() { 673eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek return mGroupManager.isGroupExpanded(mStatusBarNotification); 674b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 675b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 676eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek /** 677eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek * @return whether this view has a header on the top of the content 678eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek */ 679eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek private boolean hasNotificationHeader() { 680eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek return mIsSummaryWithChildren; 6811685e634fb0b14033bd436af8d7174436699ffecSelim Cinek } 6821685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 683263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek private void onChildrenCountChanged() { 684263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek mIsSummaryWithChildren = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS 685263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek && mGroupManager.hasGroupChildren(mStatusBarNotification); 686263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek if (mIsSummaryWithChildren && mChildrenContainer == null) { 687263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek mChildrenContainerStub.inflate(); 688263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek } 689eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek updateNotificationHeader(); 690263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek updateChildrenVisibility(true); 691263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek } 692263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek 6931685e634fb0b14033bd436af8d7174436699ffecSelim Cinek /** 6941685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * Check whether the view state is currently expanded. This is given by the system in {@link 6951685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * #setSystemExpanded(boolean)} and can be overridden by user expansion or 6961685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * collapsing in {@link #setUserExpanded(boolean)}. Note that the visual appearance of this 6971685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * view can differ from this state, if layout params are modified from outside. 6981685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * 6991685e634fb0b14033bd436af8d7174436699ffecSelim Cinek * @return whether the view state is currently expanded. 7001685e634fb0b14033bd436af8d7174436699ffecSelim Cinek */ 70183bc78338437a460076a4b5778ded38440ac3501Selim Cinek public boolean isExpanded() { 70283bc78338437a460076a4b5778ded38440ac3501Selim Cinek return !mOnKeyguard 703b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek && (!hasUserChangedExpansion() && (isSystemExpanded() || isSystemChildExpanded()) 704b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek || isUserExpanded()); 705b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 706b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 707b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek private boolean isSystemChildExpanded() { 708b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek return mIsSystemChildExpanded; 709b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 710b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 711b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void setSystemChildExpanded(boolean expanded) { 712b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mIsSystemChildExpanded = expanded; 7131685e634fb0b14033bd436af8d7174436699ffecSelim Cinek } 7141685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 7151685e634fb0b14033bd436af8d7174436699ffecSelim Cinek @Override 7161685e634fb0b14033bd436af8d7174436699ffecSelim Cinek protected void onLayout(boolean changed, int left, int top, int right, int bottom) { 7171685e634fb0b14033bd436af8d7174436699ffecSelim Cinek super.onLayout(changed, left, top, right, bottom); 718a5e211b1f2a8d055b369dadc464dc5d5bc3dd9c1Selim Cinek boolean updateExpandHeight = mMaxExpandHeight == 0 && !mWasReset; 7198d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek updateMaxHeights(); 720be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi if (updateExpandHeight) { 721dce3c4cca5d4df4cc49c1a9f0537e2fecdbc45d2Jorim Jaggi applyExpansionToLayout(); 722be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi } 723a5e211b1f2a8d055b369dadc464dc5d5bc3dd9c1Selim Cinek mWasReset = false; 7241685e634fb0b14033bd436af8d7174436699ffecSelim Cinek } 7251685e634fb0b14033bd436af8d7174436699ffecSelim Cinek 7268d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek private void updateMaxHeights() { 727d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek int intrinsicBefore = getIntrinsicHeight(); 7288d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek View expandedChild = mPrivateLayout.getExpandedChild(); 7298d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek if (expandedChild == null) { 7308d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek expandedChild = mPrivateLayout.getContractedChild(); 7318d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek } 7328d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek mMaxExpandHeight = expandedChild.getHeight(); 7338d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek View headsUpChild = mPrivateLayout.getHeadsUpChild(); 7341f3f544f21cab3728f749ab66cd6859e9dfcf389Selim Cinek if (headsUpChild == null) { 7351f3f544f21cab3728f749ab66cd6859e9dfcf389Selim Cinek headsUpChild = mPrivateLayout.getContractedChild(); 7368d490d427c0b0cc321ae61987bb3cfc1c23ff930Selim Cinek } 7371f3f544f21cab3728f749ab66cd6859e9dfcf389Selim Cinek mHeadsUpHeight = headsUpChild.getHeight(); 738d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek if (intrinsicBefore != getIntrinsicHeight()) { 739b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek notifyHeightChanged(false /* needsAnimation */); 740d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek } 741d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek } 742d2319fbe6a53ac4c38ca02e4d8e32da86ed0994bSelim Cinek 743ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi public void setSensitive(boolean sensitive) { 744ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mSensitive = sensitive; 745ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi } 746ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi 747ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi public void setHideSensitiveForIntrinsicHeight(boolean hideSensitive) { 74860122be6747c4f79b96f6808158f8f7e7548b7d3Selim Cinek mHideSensitiveForIntrinsicHeight = hideSensitive; 749ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi } 750ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi 751ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi public void setHideSensitive(boolean hideSensitive, boolean animated, long delay, 752ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi long duration) { 753ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi boolean oldShowingPublic = mShowingPublic; 754ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mShowingPublic = mSensitive && hideSensitive; 755ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) { 756ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi return; 757ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi } 758a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler 759a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler // bail out if no public version 7601685e634fb0b14033bd436af8d7174436699ffecSelim Cinek if (mPublicLayout.getChildCount() == 0) return; 761a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler 762ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi if (!animated) { 763ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mPublicLayout.animate().cancel(); 764ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mPrivateLayout.animate().cancel(); 765ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mPublicLayout.setAlpha(1f); 766ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mPrivateLayout.setAlpha(1f); 767ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE); 768263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek mPrivateLayout.setVisibility(!mShowingPublic && !mIsSummaryWithChildren ? View.VISIBLE 769263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek : View.INVISIBLE); 770ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi } else { 771ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi animateShowingPublic(delay, duration); 772ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi } 7730d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler 7740d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler updateVetoButton(); 775ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi mShowingPublicInitialized = true; 776ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi } 777ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi 778ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi private void animateShowingPublic(long delay, long duration) { 779ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi final View source = mShowingPublic ? mPrivateLayout : mPublicLayout; 780ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi View target = mShowingPublic ? mPublicLayout : mPrivateLayout; 781ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi source.setVisibility(View.VISIBLE); 782ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi target.setVisibility(View.VISIBLE); 783ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi target.setAlpha(0f); 784ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi source.animate().cancel(); 785ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi target.animate().cancel(); 786ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi source.animate() 787ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi .alpha(0f) 788ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi .setStartDelay(delay) 789ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi .setDuration(duration) 790ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi .withEndAction(new Runnable() { 791ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi @Override 792ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi public void run() { 793ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi source.setVisibility(View.INVISIBLE); 794ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi } 795ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi }); 796ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi target.animate() 797ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi .alpha(1f) 798ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi .setStartDelay(delay) 799ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi .setDuration(duration); 8000d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler } 8010d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler 8020d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler private void updateVetoButton() { 8030d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler // public versions cannot be dismissed 8040d3e62f3e07a69f21c1b1dfa2c8c0fb8b6c95655Dan Sandler mVetoButton.setVisibility(isClearable() && !mShowingPublic ? View.VISIBLE : View.GONE); 805a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler } 806251957d76e57eb6e5f8068b37346144e10e586a4Jorim Jaggi 807b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public void setChildrenExpanded(boolean expanded, boolean animate) { 808b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mChildrenExpanded = expanded; 80983bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (mChildrenContainer != null) { 81083bc78338437a460076a4b5778ded38440ac3501Selim Cinek mChildrenContainer.setChildrenExpanded(expanded); 81183bc78338437a460076a4b5778ded38440ac3501Selim Cinek } 812b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 813b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 814eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek public void updateNotificationHeader() { 815eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek boolean hasHeader = hasNotificationHeader(); 816eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek if (hasHeader != mHasNotificationHeader) { 817eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek if (hasHeader) { 818eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek if (mNotificationHeader == null) { 819eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek mNotificationHeaderStub.inflate(); 820b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 821eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek mNotificationHeader.setVisibility(View.VISIBLE); 822eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek } else if (mNotificationHeader != null) { 823eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek mNotificationHeader.setVisibility(View.GONE); 824b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 825b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek notifyHeightChanged(true /* needsAnimation */); 826b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 827eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek if (hasHeader) { 828eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek mNotificationHeader.bind(mEntry); 829b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 830eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek mHasNotificationHeader = hasHeader; 831b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 832b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 833b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public static void applyTint(View v, int color) { 834b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek int alpha; 835b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek if (color != 0) { 836b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek alpha = COLORED_DIVIDER_ALPHA; 837b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } else { 838b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek color = 0xff000000; 839b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek alpha = DEFAULT_DIVIDER_ALPHA; 840b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 841b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek if (v.getBackground() instanceof ColorDrawable) { 842b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek ColorDrawable background = (ColorDrawable) v.getBackground(); 843b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek background.mutate(); 844b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek background.setColor(color); 845b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek background.setAlpha(alpha); 846b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 847b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek } 848b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek 8491685e634fb0b14033bd436af8d7174436699ffecSelim Cinek public int getMaxExpandHeight() { 850b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek return mMaxExpandHeight; 851a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler } 852584a7aa62c54bcbd654a6696d4fbb56e124874e7Jorim Jaggi 853be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi @Override 8544222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi public boolean isContentExpandable() { 8552f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek NotificationContentView showingLayout = getShowingLayout(); 8562f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek return showingLayout.isContentExpandable(); 8574222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi } 8584222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi 8594222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi @Override 860560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek protected View getContentView() { 861560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek return getShowingLayout(); 862560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek } 863560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek 864560e64d3d95a17123048bebe2fb06ffe4567fb78Selim Cinek @Override 865d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi public void setActualHeight(int height, boolean notifyListeners) { 866b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek super.setActualHeight(height, notifyListeners); 867eef842851026a90b6a217d8bc423454fa48df4feSelim Cinek int contentHeight = Math.max(getMinHeight(), height); 868b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mPrivateLayout.setContentHeight(contentHeight); 869b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek mPublicLayout.setContentHeight(contentHeight); 870b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi if (mGuts != null) { 871b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi mGuts.setActualHeight(height); 872b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi } 873be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi invalidate(); 874be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi } 875be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi 876be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi @Override 877b5605e58cb8080c8c887b1885336b707596c8094Selim Cinek public int getMaxContentHeight() { 87883bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (mIsSummaryWithChildren && !mShowingPublic) { 87983bc78338437a460076a4b5778ded38440ac3501Selim Cinek return mChildrenContainer.getMaxContentHeight() 88083bc78338437a460076a4b5778ded38440ac3501Selim Cinek + mNotificationHeader.getHeight(); 88183bc78338437a460076a4b5778ded38440ac3501Selim Cinek } 8822f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek NotificationContentView showingLayout = getShowingLayout(); 8832f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek return showingLayout.getMaxHeight(); 884be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi } 885be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi 886be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi @Override 8874222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi public int getMinHeight() { 88883bc78338437a460076a4b5778ded38440ac3501Selim Cinek if (mIsSummaryWithChildren && !mOnKeyguard) { 88983bc78338437a460076a4b5778ded38440ac3501Selim Cinek return mChildrenContainer.getMinHeight() 89083bc78338437a460076a4b5778ded38440ac3501Selim Cinek + mNotificationHeader.getHeight(); 89183bc78338437a460076a4b5778ded38440ac3501Selim Cinek } 8922f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek NotificationContentView showingLayout = getShowingLayout(); 8932f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek return showingLayout.getMinHeight(); 8944222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi } 8954222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi 8964222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi @Override 897263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek protected boolean shouldLimitViewHeight() { 898263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek return !mIsSummaryWithChildren; 899263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek } 900263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek 901263398f0175efc8bc8c965473f9565a693a0a0e0Selim Cinek @Override 902be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi public void setClipTopAmount(int clipTopAmount) { 903be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi super.setClipTopAmount(clipTopAmount); 904be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi mPrivateLayout.setClipTopAmount(clipTopAmount); 9052f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek mPublicLayout.setClipTopAmount(clipTopAmount); 906b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi if (mGuts != null) { 907b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi mGuts.setClipTopAmount(clipTopAmount); 908b1cd3c1945499721d7d1ce57bdda67695ffe936bJorim Jaggi } 909be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi } 910be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi 911be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi public void notifyContentUpdated() { 9122f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek mPublicLayout.notifyContentUpdated(); 913be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi mPrivateLayout.notifyContentUpdated(); 914343e6e258ab6a9f647eabebaed05ce3acafd2ff1Selim Cinek } 9157d447726e2cb9fae80db417012039828daab8fe7Selim Cinek 91631094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek public boolean isMaxExpandHeightInitialized() { 91731094df5c6e3cb3a4a4faacb091e35eea1f6a5deSelim Cinek return mMaxExpandHeight != 0; 9187d447726e2cb9fae80db417012039828daab8fe7Selim Cinek } 9192f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek 9202f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek private NotificationContentView getShowingLayout() { 9212f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek return mShowingPublic ? mPublicLayout : mPrivateLayout; 9222f0df8ae038dbb873bf2e11e1e13c75cf95b0198Selim Cinek } 92378403d79739605511ea88b653564d81d7bf4bbbaChris Wren 92459ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi @Override 92559ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi public void setShowingLegacyBackground(boolean showing) { 92659ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi super.setShowingLegacyBackground(showing); 92759ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi mPrivateLayout.setShowingLegacyBackground(showing); 92859ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi mPublicLayout.setShowingLegacyBackground(showing); 92959ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi } 93059ec304eaebf1bc4098d6feb6cca9039c8b70d3dJorim Jaggi 931a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek @Override 932a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek protected void updateBackgroundTint() { 933a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek super.updateBackgroundTint(); 934a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek updateNoBackgroundState(); 935a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek if (mIsSummaryWithChildren) { 936a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek List<ExpandableNotificationRow> notificationChildren = 937a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek mChildrenContainer.getNotificationChildren(); 938a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek for (int i = 0; i < notificationChildren.size(); i++) { 939a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek ExpandableNotificationRow child = notificationChildren.get(i); 940a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek child.updateNoBackgroundState(); 941a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek } 942a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek } 943a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek } 944a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek 945a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek private void updateNoBackgroundState() { 946a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek mShowNoBackground = isChildInGroup() && hasSameBgColor(mNotificationParent); 947a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek updateBackground(); 948a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek } 949a6c6bfb61ba14b0467b73082d591c834576cddf4Selim Cinek 95078403d79739605511ea88b653564d81d7bf4bbbaChris Wren public void setExpansionLogger(ExpansionLogger logger, String key) { 95178403d79739605511ea88b653564d81d7bf4bbbaChris Wren mLogger = logger; 95278403d79739605511ea88b653564d81d7bf4bbbaChris Wren mLoggingKey = key; 95378403d79739605511ea88b653564d81d7bf4bbbaChris Wren } 95478403d79739605511ea88b653564d81d7bf4bbbaChris Wren 95578403d79739605511ea88b653564d81d7bf4bbbaChris Wren private void logExpansionEvent(boolean userAction, boolean wasExpanded) { 95678403d79739605511ea88b653564d81d7bf4bbbaChris Wren final boolean nowExpanded = isExpanded(); 95778403d79739605511ea88b653564d81d7bf4bbbaChris Wren if (wasExpanded != nowExpanded && mLogger != null) { 95878403d79739605511ea88b653564d81d7bf4bbbaChris Wren mLogger.logNotificationExpansion(mLoggingKey, userAction, nowExpanded) ; 95978403d79739605511ea88b653564d81d7bf4bbbaChris Wren } 96078403d79739605511ea88b653564d81d7bf4bbbaChris Wren } 96151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren} 962