blob: a52d0f6404b9099b5af87f2ffe957f7ae44bdb8b [file] [log] [blame]
Chris Wren51c75102013-07-16 20:49:17 -04001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.systemui.statusbar;
18
19import android.content.Context;
Selim Cinekcab4a602014-09-03 14:47:57 +020020import android.graphics.drawable.AnimatedVectorDrawable;
21import android.graphics.drawable.AnimationDrawable;
22import android.graphics.drawable.Drawable;
Jorim Jaggib1cd3c12014-09-08 19:55:17 +020023import android.service.notification.StatusBarNotification;
Chris Wren51c75102013-07-16 20:49:17 -040024import android.util.AttributeSet;
Selim Cinek1a521f32014-11-03 17:39:29 +010025import android.view.MotionEvent;
Dan Sandlera5e0f412014-01-23 15:11:54 -050026import android.view.View;
Jorim Jaggib1cd3c12014-09-08 19:55:17 +020027import android.view.ViewStub;
Jorim Jaggife40f7d2014-04-28 15:20:04 +020028import android.view.accessibility.AccessibilityEvent;
Selim Cinekcab4a602014-09-03 14:47:57 +020029import android.widget.ImageView;
Dan Sandlera5e0f412014-01-23 15:11:54 -050030import com.android.systemui.R;
31
Jorim Jaggi4222d9a2014-04-23 16:13:15 +020032public class ExpandableNotificationRow extends ActivatableNotificationView {
Selim Cinek1685e632014-04-08 02:27:49 +020033 private int mRowMinHeight;
34 private int mRowMaxHeight;
Chris Wren51c75102013-07-16 20:49:17 -040035
Selim Cinek1685e632014-04-08 02:27:49 +020036 /** Does this row contain layouts that can adapt to row expansion */
Chris Wren51c75102013-07-16 20:49:17 -040037 private boolean mExpandable;
Selim Cinek1685e632014-04-08 02:27:49 +020038 /** Has the user actively changed the expansion state of this row */
39 private boolean mHasUserChangedExpansion;
40 /** If {@link #mHasUserChangedExpansion}, has the user expanded this row */
Chris Wren51c75102013-07-16 20:49:17 -040041 private boolean mUserExpanded;
Selim Cinek1685e632014-04-08 02:27:49 +020042 /** Is the user touching this row */
Chris Wren51c75102013-07-16 20:49:17 -040043 private boolean mUserLocked;
Selim Cinek1685e632014-04-08 02:27:49 +020044 /** Are we showing the "public" version */
Dan Sandlera5e0f412014-01-23 15:11:54 -050045 private boolean mShowingPublic;
Jorim Jaggiae441282014-08-01 02:45:18 +020046 private boolean mSensitive;
47 private boolean mShowingPublicInitialized;
48 private boolean mShowingPublicForIntrinsicHeight;
Chris Wren51c75102013-07-16 20:49:17 -040049
Selim Cinek1685e632014-04-08 02:27:49 +020050 /**
51 * Is this notification expanded by the system. The expansion state can be overridden by the
52 * user expansion.
53 */
54 private boolean mIsSystemExpanded;
Jorim Jaggidce3c4c2014-04-29 23:12:24 +020055
56 /**
57 * Whether the notification expansion is disabled. This is the case on Keyguard.
58 */
59 private boolean mExpansionDisabled;
60
Jorim Jaggibe565df2014-04-28 17:51:23 +020061 private NotificationContentView mPublicLayout;
62 private NotificationContentView mPrivateLayout;
Selim Cinek1685e632014-04-08 02:27:49 +020063 private int mMaxExpandHeight;
Selim Cinek863834b2014-05-20 04:20:25 +020064 private View mVetoButton;
Dan Sandler0d3e62f2014-07-14 17:13:50 -040065 private boolean mClearable;
Chris Wren78403d72014-07-28 10:23:24 +010066 private ExpansionLogger mLogger;
67 private String mLoggingKey;
Selim Cineka5e211b2014-08-11 17:35:48 +020068 private boolean mWasReset;
Selim Cinek024ca592014-09-01 15:11:28 +020069 private NotificationGuts mGuts;
Chris Wren78403d72014-07-28 10:23:24 +010070
Jorim Jaggib1cd3c12014-09-08 19:55:17 +020071 private StatusBarNotification mStatusBarNotification;
Selim Cinek1a521f32014-11-03 17:39:29 +010072 private boolean mIsHeadsUp;
Jorim Jaggib1cd3c12014-09-08 19:55:17 +020073
Selim Cinekcab4a602014-09-03 14:47:57 +020074 public void setIconAnimationRunning(boolean running) {
75 setIconAnimationRunning(running, mPublicLayout);
76 setIconAnimationRunning(running, mPrivateLayout);
77 }
78
79 private void setIconAnimationRunning(boolean running, NotificationContentView layout) {
80 if (layout != null) {
81 View contractedChild = layout.getContractedChild();
82 View expandedChild = layout.getExpandedChild();
83 setIconAnimationRunningForChild(running, contractedChild);
84 setIconAnimationRunningForChild(running, expandedChild);
85 }
86 }
87
88 private void setIconAnimationRunningForChild(boolean running, View child) {
89 if (child != null) {
90 ImageView icon = (ImageView) child.findViewById(com.android.internal.R.id.icon);
91 setIconRunning(icon, running);
92 ImageView rightIcon = (ImageView) child.findViewById(
93 com.android.internal.R.id.right_icon);
94 setIconRunning(rightIcon, running);
95 }
96 }
97
98 private void setIconRunning(ImageView imageView, boolean running) {
99 if (imageView != null) {
100 Drawable drawable = imageView.getDrawable();
101 if (drawable instanceof AnimationDrawable) {
102 AnimationDrawable animationDrawable = (AnimationDrawable) drawable;
103 if (running) {
104 animationDrawable.start();
105 } else {
106 animationDrawable.stop();
107 }
108 } else if (drawable instanceof AnimatedVectorDrawable) {
109 AnimatedVectorDrawable animationDrawable = (AnimatedVectorDrawable) drawable;
110 if (running) {
111 animationDrawable.start();
112 } else {
113 animationDrawable.stop();
114 }
115 }
116 }
117 }
118
Jorim Jaggib1cd3c12014-09-08 19:55:17 +0200119 public void setStatusBarNotification(StatusBarNotification statusBarNotification) {
120 mStatusBarNotification = statusBarNotification;
Selim Cineka37774f2014-11-11 19:16:18 +0100121 updateVetoButton();
Jorim Jaggib1cd3c12014-09-08 19:55:17 +0200122 }
123
124 public StatusBarNotification getStatusBarNotification() {
125 return mStatusBarNotification;
126 }
127
Selim Cinek1a521f32014-11-03 17:39:29 +0100128 public void setHeadsUp(boolean isHeadsUp) {
129 mIsHeadsUp = isHeadsUp;
130 }
131
Chris Wren78403d72014-07-28 10:23:24 +0100132 public interface ExpansionLogger {
133 public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
134 }
Selim Cinek1685e632014-04-08 02:27:49 +0200135
Chris Wren51c75102013-07-16 20:49:17 -0400136 public ExpandableNotificationRow(Context context, AttributeSet attrs) {
137 super(context, attrs);
138 }
139
Christoph Studera7fe6312014-06-27 19:32:44 +0200140 /**
141 * Resets this view so it can be re-used for an updated notification.
142 */
Christoph Studer22f2ee52014-07-29 22:57:21 +0200143 @Override
Christoph Studera7fe6312014-06-27 19:32:44 +0200144 public void reset() {
Christoph Studer22f2ee52014-07-29 22:57:21 +0200145 super.reset();
Christoph Studera7fe6312014-06-27 19:32:44 +0200146 mRowMinHeight = 0;
Chris Wren78403d72014-07-28 10:23:24 +0100147 final boolean wasExpanded = isExpanded();
Christoph Studera7fe6312014-06-27 19:32:44 +0200148 mRowMaxHeight = 0;
149 mExpandable = false;
150 mHasUserChangedExpansion = false;
151 mUserLocked = false;
152 mShowingPublic = false;
Jorim Jaggiae441282014-08-01 02:45:18 +0200153 mSensitive = false;
154 mShowingPublicInitialized = false;
Christoph Studera7fe6312014-06-27 19:32:44 +0200155 mIsSystemExpanded = false;
156 mExpansionDisabled = false;
Selim Cinek1a521f32014-11-03 17:39:29 +0100157 mPublicLayout.reset(mIsHeadsUp);
158 mPrivateLayout.reset(mIsHeadsUp);
Selim Cinek31094df2014-08-14 19:28:15 +0200159 resetHeight();
160 logExpansionEvent(false, wasExpanded);
161 }
162
163 public void resetHeight() {
Selim Cinek1a521f32014-11-03 17:39:29 +0100164 if (mIsHeadsUp) {
165 resetActualHeight();
166 }
Christoph Studera7fe6312014-06-27 19:32:44 +0200167 mMaxExpandHeight = 0;
Selim Cineka5e211b2014-08-11 17:35:48 +0200168 mWasReset = true;
Selim Cinek31094df2014-08-14 19:28:15 +0200169 onHeightReset();
Selim Cinek6e28a672014-09-05 14:43:28 +0200170 requestLayout();
Christoph Studera7fe6312014-06-27 19:32:44 +0200171 }
172
Jorim Jaggi251957d2014-04-09 04:24:09 +0200173 @Override
Selim Cinek1a521f32014-11-03 17:39:29 +0100174 protected boolean filterMotionEvent(MotionEvent event) {
175 return mIsHeadsUp || super.filterMotionEvent(event);
176 }
177
178 @Override
Jorim Jaggi251957d2014-04-09 04:24:09 +0200179 protected void onFinishInflate() {
180 super.onFinishInflate();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200181 mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
182 mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded);
Jorim Jaggib1cd3c12014-09-08 19:55:17 +0200183 ViewStub gutsStub = (ViewStub) findViewById(R.id.notification_guts_stub);
184 gutsStub.setOnInflateListener(new ViewStub.OnInflateListener() {
185 @Override
186 public void onInflate(ViewStub stub, View inflated) {
187 mGuts = (NotificationGuts) inflated;
188 mGuts.setClipTopAmount(getClipTopAmount());
189 mGuts.setActualHeight(getActualHeight());
190 }
191 });
Selim Cinek863834b2014-05-20 04:20:25 +0200192 mVetoButton = findViewById(R.id.veto);
Jorim Jaggife40f7d2014-04-28 15:20:04 +0200193 }
194
195 @Override
Alan Viverettea54956a2015-01-07 16:05:02 -0800196 public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event) {
197 if (super.onRequestSendAccessibilityEventInternal(child, event)) {
Jorim Jaggife40f7d2014-04-28 15:20:04 +0200198 // Add a record for the entire layout since its content is somehow small.
199 // The event comes from a leaf view that is interacted with.
200 AccessibilityEvent record = AccessibilityEvent.obtain();
201 onInitializeAccessibilityEvent(record);
202 dispatchPopulateAccessibilityEvent(record);
203 event.appendRecord(record);
204 return true;
205 }
206 return false;
Jorim Jaggic5dc0d02014-04-15 15:42:55 +0200207 }
Chris Wren51c75102013-07-16 20:49:17 -0400208
John Spurlocke15452b2014-08-21 09:44:39 -0400209 @Override
Jorim Jaggi4e857f42014-11-17 19:14:04 +0100210 public void setDark(boolean dark, boolean fade, long delay) {
211 super.setDark(dark, fade, delay);
John Spurlocke15452b2014-08-21 09:44:39 -0400212 final NotificationContentView showing = getShowingLayout();
213 if (showing != null) {
Jorim Jaggi4e857f42014-11-17 19:14:04 +0100214 showing.setDark(dark, fade, delay);
John Spurlocke15452b2014-08-21 09:44:39 -0400215 }
216 }
217
Selim Cinek1685e632014-04-08 02:27:49 +0200218 public void setHeightRange(int rowMinHeight, int rowMaxHeight) {
219 mRowMinHeight = rowMinHeight;
220 mRowMaxHeight = rowMaxHeight;
Chris Wren51c75102013-07-16 20:49:17 -0400221 }
222
223 public boolean isExpandable() {
224 return mExpandable;
225 }
226
227 public void setExpandable(boolean expandable) {
228 mExpandable = expandable;
229 }
230
Selim Cinek1685e632014-04-08 02:27:49 +0200231 /**
232 * @return whether the user has changed the expansion state
233 */
234 public boolean hasUserChangedExpansion() {
235 return mHasUserChangedExpansion;
236 }
237
Chris Wren51c75102013-07-16 20:49:17 -0400238 public boolean isUserExpanded() {
239 return mUserExpanded;
240 }
241
Selim Cinek1685e632014-04-08 02:27:49 +0200242 /**
243 * Set this notification to be expanded by the user
244 *
245 * @param userExpanded whether the user wants this notification to be expanded
246 */
Chris Wren51c75102013-07-16 20:49:17 -0400247 public void setUserExpanded(boolean userExpanded) {
Christoph Studera7fe6312014-06-27 19:32:44 +0200248 if (userExpanded && !mExpandable) return;
Chris Wren78403d72014-07-28 10:23:24 +0100249 final boolean wasExpanded = isExpanded();
Selim Cinek1685e632014-04-08 02:27:49 +0200250 mHasUserChangedExpansion = true;
Chris Wren51c75102013-07-16 20:49:17 -0400251 mUserExpanded = userExpanded;
Chris Wren78403d72014-07-28 10:23:24 +0100252 logExpansionEvent(true, wasExpanded);
Chris Wren51c75102013-07-16 20:49:17 -0400253 }
254
Selim Cinekccd14fb2014-08-12 18:53:24 +0200255 public void resetUserExpansion() {
256 mHasUserChangedExpansion = false;
257 mUserExpanded = false;
258 }
259
Chris Wren51c75102013-07-16 20:49:17 -0400260 public boolean isUserLocked() {
261 return mUserLocked;
262 }
263
264 public void setUserLocked(boolean userLocked) {
265 mUserLocked = userLocked;
266 }
267
Selim Cinek1685e632014-04-08 02:27:49 +0200268 /**
269 * @return has the system set this notification to be expanded
270 */
271 public boolean isSystemExpanded() {
272 return mIsSystemExpanded;
273 }
274
275 /**
276 * Set this notification to be expanded by the system.
277 *
278 * @param expand whether the system wants this notification to be expanded.
279 */
280 public void setSystemExpanded(boolean expand) {
Selim Cinek31094df2014-08-14 19:28:15 +0200281 if (expand != mIsSystemExpanded) {
282 final boolean wasExpanded = isExpanded();
283 mIsSystemExpanded = expand;
284 notifyHeightChanged();
285 logExpansionEvent(false, wasExpanded);
286 }
Jorim Jaggidce3c4c2014-04-29 23:12:24 +0200287 }
288
289 /**
290 * @param expansionDisabled whether to prevent notification expansion
291 */
292 public void setExpansionDisabled(boolean expansionDisabled) {
Selim Cinek31094df2014-08-14 19:28:15 +0200293 if (expansionDisabled != mExpansionDisabled) {
294 final boolean wasExpanded = isExpanded();
295 mExpansionDisabled = expansionDisabled;
296 logExpansionEvent(false, wasExpanded);
297 if (wasExpanded != isExpanded()) {
298 notifyHeightChanged();
299 }
300 }
Selim Cinek1685e632014-04-08 02:27:49 +0200301 }
302
303 /**
Dan Sandler0d3e62f2014-07-14 17:13:50 -0400304 * @return Can the underlying notification be cleared?
305 */
306 public boolean isClearable() {
Selim Cineka37774f2014-11-11 19:16:18 +0100307 return mStatusBarNotification != null && mStatusBarNotification.isClearable();
Dan Sandler0d3e62f2014-07-14 17:13:50 -0400308 }
309
310 /**
Selim Cinek1685e632014-04-08 02:27:49 +0200311 * Apply an expansion state to the layout.
Selim Cinek1685e632014-04-08 02:27:49 +0200312 */
Jorim Jaggidce3c4c2014-04-29 23:12:24 +0200313 public void applyExpansionToLayout() {
314 boolean expand = isExpanded();
Chris Wren51c75102013-07-16 20:49:17 -0400315 if (expand && mExpandable) {
Jorim Jaggibe565df2014-04-28 17:51:23 +0200316 setActualHeight(mMaxExpandHeight);
Chris Wren51c75102013-07-16 20:49:17 -0400317 } else {
Jorim Jaggibe565df2014-04-28 17:51:23 +0200318 setActualHeight(mRowMinHeight);
Chris Wren51c75102013-07-16 20:49:17 -0400319 }
Chris Wren51c75102013-07-16 20:49:17 -0400320 }
Dan Sandlera5e0f412014-01-23 15:11:54 -0500321
Jorim Jaggi9cbadd32014-05-01 20:18:31 +0200322 @Override
323 public int getIntrinsicHeight() {
Jorim Jaggibe565df2014-04-28 17:51:23 +0200324 if (isUserLocked()) {
325 return getActualHeight();
326 }
Selim Cinek1685e632014-04-08 02:27:49 +0200327 boolean inExpansionState = isExpanded();
328 if (!inExpansionState) {
329 // not expanded, so we return the collapsed size
330 return mRowMinHeight;
331 }
332
Jorim Jaggiae441282014-08-01 02:45:18 +0200333 return mShowingPublicForIntrinsicHeight ? mRowMinHeight : getMaxExpandHeight();
Selim Cinek1685e632014-04-08 02:27:49 +0200334 }
335
Selim Cinek1685e632014-04-08 02:27:49 +0200336 /**
337 * Check whether the view state is currently expanded. This is given by the system in {@link
338 * #setSystemExpanded(boolean)} and can be overridden by user expansion or
339 * collapsing in {@link #setUserExpanded(boolean)}. Note that the visual appearance of this
340 * view can differ from this state, if layout params are modified from outside.
341 *
342 * @return whether the view state is currently expanded.
343 */
344 private boolean isExpanded() {
Jorim Jaggidce3c4c2014-04-29 23:12:24 +0200345 return !mExpansionDisabled
346 && (!hasUserChangedExpansion() && isSystemExpanded() || isUserExpanded());
Selim Cinek1685e632014-04-08 02:27:49 +0200347 }
348
349 @Override
350 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
351 super.onLayout(changed, left, top, right, bottom);
Selim Cineka5e211b2014-08-11 17:35:48 +0200352 boolean updateExpandHeight = mMaxExpandHeight == 0 && !mWasReset;
Selim Cinekd2319fb2014-09-01 19:41:54 +0200353 updateMaxExpandHeight();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200354 if (updateExpandHeight) {
Jorim Jaggidce3c4c2014-04-29 23:12:24 +0200355 applyExpansionToLayout();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200356 }
Selim Cineka5e211b2014-08-11 17:35:48 +0200357 mWasReset = false;
Selim Cinek1685e632014-04-08 02:27:49 +0200358 }
359
Selim Cinekd2319fb2014-09-01 19:41:54 +0200360 private void updateMaxExpandHeight() {
361 int intrinsicBefore = getIntrinsicHeight();
362 mMaxExpandHeight = mPrivateLayout.getMaxHeight();
363 if (intrinsicBefore != getIntrinsicHeight()) {
364 notifyHeightChanged();
365 }
366 }
367
Jorim Jaggiae441282014-08-01 02:45:18 +0200368 public void setSensitive(boolean sensitive) {
369 mSensitive = sensitive;
370 }
371
372 public void setHideSensitiveForIntrinsicHeight(boolean hideSensitive) {
373 mShowingPublicForIntrinsicHeight = mSensitive && hideSensitive;
374 }
375
376 public void setHideSensitive(boolean hideSensitive, boolean animated, long delay,
377 long duration) {
378 boolean oldShowingPublic = mShowingPublic;
379 mShowingPublic = mSensitive && hideSensitive;
380 if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) {
381 return;
382 }
Dan Sandlera5e0f412014-01-23 15:11:54 -0500383
384 // bail out if no public version
Selim Cinek1685e632014-04-08 02:27:49 +0200385 if (mPublicLayout.getChildCount() == 0) return;
Dan Sandlera5e0f412014-01-23 15:11:54 -0500386
Jorim Jaggiae441282014-08-01 02:45:18 +0200387 if (!animated) {
388 mPublicLayout.animate().cancel();
389 mPrivateLayout.animate().cancel();
390 mPublicLayout.setAlpha(1f);
391 mPrivateLayout.setAlpha(1f);
392 mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE);
393 mPrivateLayout.setVisibility(mShowingPublic ? View.INVISIBLE : View.VISIBLE);
394 } else {
395 animateShowingPublic(delay, duration);
396 }
Dan Sandler0d3e62f2014-07-14 17:13:50 -0400397
398 updateVetoButton();
Jorim Jaggiae441282014-08-01 02:45:18 +0200399 mShowingPublicInitialized = true;
400 }
401
402 private void animateShowingPublic(long delay, long duration) {
403 final View source = mShowingPublic ? mPrivateLayout : mPublicLayout;
404 View target = mShowingPublic ? mPublicLayout : mPrivateLayout;
405 source.setVisibility(View.VISIBLE);
406 target.setVisibility(View.VISIBLE);
407 target.setAlpha(0f);
408 source.animate().cancel();
409 target.animate().cancel();
410 source.animate()
411 .alpha(0f)
Jorim Jaggiae441282014-08-01 02:45:18 +0200412 .setStartDelay(delay)
413 .setDuration(duration)
414 .withEndAction(new Runnable() {
415 @Override
416 public void run() {
417 source.setVisibility(View.INVISIBLE);
418 }
419 });
420 target.animate()
421 .alpha(1f)
Jorim Jaggiae441282014-08-01 02:45:18 +0200422 .setStartDelay(delay)
423 .setDuration(duration);
Dan Sandler0d3e62f2014-07-14 17:13:50 -0400424 }
425
426 private void updateVetoButton() {
427 // public versions cannot be dismissed
428 mVetoButton.setVisibility(isClearable() && !mShowingPublic ? View.VISIBLE : View.GONE);
Dan Sandlera5e0f412014-01-23 15:11:54 -0500429 }
Jorim Jaggi251957d2014-04-09 04:24:09 +0200430
Selim Cinek1685e632014-04-08 02:27:49 +0200431 public int getMaxExpandHeight() {
Jorim Jaggiae441282014-08-01 02:45:18 +0200432 return mShowingPublicForIntrinsicHeight ? mRowMinHeight : mMaxExpandHeight;
Chris Wren51c75102013-07-16 20:49:17 -0400433 }
Jorim Jaggi584a7aa2014-04-10 23:26:13 +0200434
Jorim Jaggibe565df2014-04-28 17:51:23 +0200435 @Override
Jorim Jaggi4222d9a2014-04-23 16:13:15 +0200436 public boolean isContentExpandable() {
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200437 NotificationContentView showingLayout = getShowingLayout();
438 return showingLayout.isContentExpandable();
Jorim Jaggi4222d9a2014-04-23 16:13:15 +0200439 }
440
441 @Override
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200442 public void setActualHeight(int height, boolean notifyListeners) {
Selim Cinekc9c00ae2014-05-20 03:33:40 +0200443 mPrivateLayout.setActualHeight(height);
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200444 mPublicLayout.setActualHeight(height);
Jorim Jaggib1cd3c12014-09-08 19:55:17 +0200445 if (mGuts != null) {
446 mGuts.setActualHeight(height);
447 }
Jorim Jaggibe565df2014-04-28 17:51:23 +0200448 invalidate();
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200449 super.setActualHeight(height, notifyListeners);
Jorim Jaggibe565df2014-04-28 17:51:23 +0200450 }
451
452 @Override
453 public int getMaxHeight() {
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200454 NotificationContentView showingLayout = getShowingLayout();
455 return showingLayout.getMaxHeight();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200456 }
457
458 @Override
Jorim Jaggi4222d9a2014-04-23 16:13:15 +0200459 public int getMinHeight() {
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200460 NotificationContentView showingLayout = getShowingLayout();
461 return showingLayout.getMinHeight();
Jorim Jaggi4222d9a2014-04-23 16:13:15 +0200462 }
463
464 @Override
Jorim Jaggibe565df2014-04-28 17:51:23 +0200465 public void setClipTopAmount(int clipTopAmount) {
466 super.setClipTopAmount(clipTopAmount);
467 mPrivateLayout.setClipTopAmount(clipTopAmount);
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200468 mPublicLayout.setClipTopAmount(clipTopAmount);
Jorim Jaggib1cd3c12014-09-08 19:55:17 +0200469 if (mGuts != null) {
470 mGuts.setClipTopAmount(clipTopAmount);
471 }
Jorim Jaggibe565df2014-04-28 17:51:23 +0200472 }
473
474 public void notifyContentUpdated() {
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200475 mPublicLayout.notifyContentUpdated();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200476 mPrivateLayout.notifyContentUpdated();
Selim Cinek343e6e22014-04-11 21:23:30 +0200477 }
Selim Cinek7d447722014-06-10 15:51:59 +0200478
Selim Cinek31094df2014-08-14 19:28:15 +0200479 public boolean isMaxExpandHeightInitialized() {
480 return mMaxExpandHeight != 0;
Selim Cinek7d447722014-06-10 15:51:59 +0200481 }
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200482
483 private NotificationContentView getShowingLayout() {
484 return mShowingPublic ? mPublicLayout : mPrivateLayout;
485 }
Chris Wren78403d72014-07-28 10:23:24 +0100486
487 public void setExpansionLogger(ExpansionLogger logger, String key) {
488 mLogger = logger;
489 mLoggingKey = key;
490 }
491
492
493 private void logExpansionEvent(boolean userAction, boolean wasExpanded) {
494 final boolean nowExpanded = isExpanded();
495 if (wasExpanded != nowExpanded && mLogger != null) {
496 mLogger.logNotificationExpansion(mLoggingKey, userAction, nowExpanded) ;
497 }
498 }
Chris Wren51c75102013-07-16 20:49:17 -0400499}