blob: 788db29fc26c8d04c37973baa099d000d0869a52 [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;
Chris Wren51c75102013-07-16 20:49:17 -040034
Selim Cinek1685e632014-04-08 02:27:49 +020035 /** Does this row contain layouts that can adapt to row expansion */
Chris Wren51c75102013-07-16 20:49:17 -040036 private boolean mExpandable;
Selim Cinek1685e632014-04-08 02:27:49 +020037 /** Has the user actively changed the expansion state of this row */
38 private boolean mHasUserChangedExpansion;
39 /** If {@link #mHasUserChangedExpansion}, has the user expanded this row */
Chris Wren51c75102013-07-16 20:49:17 -040040 private boolean mUserExpanded;
Selim Cinek1685e632014-04-08 02:27:49 +020041 /** Is the user touching this row */
Chris Wren51c75102013-07-16 20:49:17 -040042 private boolean mUserLocked;
Selim Cinek1685e632014-04-08 02:27:49 +020043 /** Are we showing the "public" version */
Dan Sandlera5e0f412014-01-23 15:11:54 -050044 private boolean mShowingPublic;
Jorim Jaggiae441282014-08-01 02:45:18 +020045 private boolean mSensitive;
46 private boolean mShowingPublicInitialized;
47 private boolean mShowingPublicForIntrinsicHeight;
Chris Wren51c75102013-07-16 20:49:17 -040048
Selim Cinek1685e632014-04-08 02:27:49 +020049 /**
50 * Is this notification expanded by the system. The expansion state can be overridden by the
51 * user expansion.
52 */
53 private boolean mIsSystemExpanded;
Jorim Jaggidce3c4c2014-04-29 23:12:24 +020054
55 /**
56 * Whether the notification expansion is disabled. This is the case on Keyguard.
57 */
58 private boolean mExpansionDisabled;
59
Jorim Jaggibe565df2014-04-28 17:51:23 +020060 private NotificationContentView mPublicLayout;
61 private NotificationContentView mPrivateLayout;
Selim Cinek1685e632014-04-08 02:27:49 +020062 private int mMaxExpandHeight;
Selim Cinek863834b2014-05-20 04:20:25 +020063 private View mVetoButton;
Dan Sandler0d3e62f2014-07-14 17:13:50 -040064 private boolean mClearable;
Chris Wren78403d72014-07-28 10:23:24 +010065 private ExpansionLogger mLogger;
66 private String mLoggingKey;
Selim Cineka5e211b2014-08-11 17:35:48 +020067 private boolean mWasReset;
Selim Cinek024ca592014-09-01 15:11:28 +020068 private NotificationGuts mGuts;
Chris Wren78403d72014-07-28 10:23:24 +010069
Jorim Jaggib1cd3c12014-09-08 19:55:17 +020070 private StatusBarNotification mStatusBarNotification;
Selim Cinek1a521f32014-11-03 17:39:29 +010071 private boolean mIsHeadsUp;
Selim Cinekab29aeb2015-02-20 18:18:32 +010072 private ViewStub mGutsStub;
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
Selim Cinekab29aeb2015-02-20 18:18:32 +0100132 public NotificationGuts getGuts() {
133 return mGuts;
134 }
135
Chris Wren78403d72014-07-28 10:23:24 +0100136 public interface ExpansionLogger {
137 public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
138 }
Selim Cinek1685e632014-04-08 02:27:49 +0200139
Chris Wren51c75102013-07-16 20:49:17 -0400140 public ExpandableNotificationRow(Context context, AttributeSet attrs) {
141 super(context, attrs);
142 }
143
Christoph Studera7fe6312014-06-27 19:32:44 +0200144 /**
145 * Resets this view so it can be re-used for an updated notification.
146 */
Christoph Studer22f2ee52014-07-29 22:57:21 +0200147 @Override
Christoph Studera7fe6312014-06-27 19:32:44 +0200148 public void reset() {
Christoph Studer22f2ee52014-07-29 22:57:21 +0200149 super.reset();
Christoph Studera7fe6312014-06-27 19:32:44 +0200150 mRowMinHeight = 0;
Chris Wren78403d72014-07-28 10:23:24 +0100151 final boolean wasExpanded = isExpanded();
Selim Cinek379ff8f2015-02-20 17:03:16 +0100152 mMaxViewHeight = 0;
Christoph Studera7fe6312014-06-27 19:32:44 +0200153 mExpandable = false;
154 mHasUserChangedExpansion = false;
155 mUserLocked = false;
156 mShowingPublic = false;
Jorim Jaggiae441282014-08-01 02:45:18 +0200157 mSensitive = false;
158 mShowingPublicInitialized = false;
Christoph Studera7fe6312014-06-27 19:32:44 +0200159 mIsSystemExpanded = false;
160 mExpansionDisabled = false;
Selim Cinek1a521f32014-11-03 17:39:29 +0100161 mPublicLayout.reset(mIsHeadsUp);
162 mPrivateLayout.reset(mIsHeadsUp);
Selim Cinek31094df2014-08-14 19:28:15 +0200163 resetHeight();
164 logExpansionEvent(false, wasExpanded);
165 }
166
167 public void resetHeight() {
Selim Cinek1a521f32014-11-03 17:39:29 +0100168 if (mIsHeadsUp) {
169 resetActualHeight();
170 }
Christoph Studera7fe6312014-06-27 19:32:44 +0200171 mMaxExpandHeight = 0;
Selim Cineka5e211b2014-08-11 17:35:48 +0200172 mWasReset = true;
Selim Cinek31094df2014-08-14 19:28:15 +0200173 onHeightReset();
Selim Cinek6e28a672014-09-05 14:43:28 +0200174 requestLayout();
Christoph Studera7fe6312014-06-27 19:32:44 +0200175 }
176
Jorim Jaggi251957d2014-04-09 04:24:09 +0200177 @Override
Selim Cinek1a521f32014-11-03 17:39:29 +0100178 protected boolean filterMotionEvent(MotionEvent event) {
179 return mIsHeadsUp || super.filterMotionEvent(event);
180 }
181
182 @Override
Jorim Jaggi251957d2014-04-09 04:24:09 +0200183 protected void onFinishInflate() {
184 super.onFinishInflate();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200185 mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
186 mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded);
Selim Cinekab29aeb2015-02-20 18:18:32 +0100187 mGutsStub = (ViewStub) findViewById(R.id.notification_guts_stub);
188 mGutsStub.setOnInflateListener(new ViewStub.OnInflateListener() {
Jorim Jaggib1cd3c12014-09-08 19:55:17 +0200189 @Override
190 public void onInflate(ViewStub stub, View inflated) {
191 mGuts = (NotificationGuts) inflated;
192 mGuts.setClipTopAmount(getClipTopAmount());
193 mGuts.setActualHeight(getActualHeight());
Selim Cinekab29aeb2015-02-20 18:18:32 +0100194 mGutsStub = null;
Jorim Jaggib1cd3c12014-09-08 19:55:17 +0200195 }
196 });
Selim Cinek863834b2014-05-20 04:20:25 +0200197 mVetoButton = findViewById(R.id.veto);
Jorim Jaggife40f7d2014-04-28 15:20:04 +0200198 }
199
Selim Cinekab29aeb2015-02-20 18:18:32 +0100200 public void inflateGuts() {
201 if (mGuts == null) {
202 mGutsStub.inflate();
203 }
204 }
205
Jorim Jaggife40f7d2014-04-28 15:20:04 +0200206 @Override
Alan Viverettea54956a2015-01-07 16:05:02 -0800207 public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event) {
208 if (super.onRequestSendAccessibilityEventInternal(child, event)) {
Jorim Jaggife40f7d2014-04-28 15:20:04 +0200209 // Add a record for the entire layout since its content is somehow small.
210 // The event comes from a leaf view that is interacted with.
211 AccessibilityEvent record = AccessibilityEvent.obtain();
212 onInitializeAccessibilityEvent(record);
213 dispatchPopulateAccessibilityEvent(record);
214 event.appendRecord(record);
215 return true;
216 }
217 return false;
Jorim Jaggic5dc0d02014-04-15 15:42:55 +0200218 }
Chris Wren51c75102013-07-16 20:49:17 -0400219
John Spurlocke15452b2014-08-21 09:44:39 -0400220 @Override
Jorim Jaggi4e857f42014-11-17 19:14:04 +0100221 public void setDark(boolean dark, boolean fade, long delay) {
222 super.setDark(dark, fade, delay);
John Spurlocke15452b2014-08-21 09:44:39 -0400223 final NotificationContentView showing = getShowingLayout();
224 if (showing != null) {
Jorim Jaggi4e857f42014-11-17 19:14:04 +0100225 showing.setDark(dark, fade, delay);
John Spurlocke15452b2014-08-21 09:44:39 -0400226 }
227 }
228
Selim Cinek1685e632014-04-08 02:27:49 +0200229 public void setHeightRange(int rowMinHeight, int rowMaxHeight) {
230 mRowMinHeight = rowMinHeight;
Selim Cinek379ff8f2015-02-20 17:03:16 +0100231 mMaxViewHeight = rowMaxHeight;
Chris Wren51c75102013-07-16 20:49:17 -0400232 }
233
234 public boolean isExpandable() {
235 return mExpandable;
236 }
237
238 public void setExpandable(boolean expandable) {
239 mExpandable = expandable;
240 }
241
Selim Cinek1685e632014-04-08 02:27:49 +0200242 /**
243 * @return whether the user has changed the expansion state
244 */
245 public boolean hasUserChangedExpansion() {
246 return mHasUserChangedExpansion;
247 }
248
Chris Wren51c75102013-07-16 20:49:17 -0400249 public boolean isUserExpanded() {
250 return mUserExpanded;
251 }
252
Selim Cinek1685e632014-04-08 02:27:49 +0200253 /**
254 * Set this notification to be expanded by the user
255 *
256 * @param userExpanded whether the user wants this notification to be expanded
257 */
Chris Wren51c75102013-07-16 20:49:17 -0400258 public void setUserExpanded(boolean userExpanded) {
Christoph Studera7fe6312014-06-27 19:32:44 +0200259 if (userExpanded && !mExpandable) return;
Chris Wren78403d72014-07-28 10:23:24 +0100260 final boolean wasExpanded = isExpanded();
Selim Cinek1685e632014-04-08 02:27:49 +0200261 mHasUserChangedExpansion = true;
Chris Wren51c75102013-07-16 20:49:17 -0400262 mUserExpanded = userExpanded;
Chris Wren78403d72014-07-28 10:23:24 +0100263 logExpansionEvent(true, wasExpanded);
Chris Wren51c75102013-07-16 20:49:17 -0400264 }
265
Selim Cinekccd14fb2014-08-12 18:53:24 +0200266 public void resetUserExpansion() {
267 mHasUserChangedExpansion = false;
268 mUserExpanded = false;
269 }
270
Chris Wren51c75102013-07-16 20:49:17 -0400271 public boolean isUserLocked() {
272 return mUserLocked;
273 }
274
275 public void setUserLocked(boolean userLocked) {
276 mUserLocked = userLocked;
277 }
278
Selim Cinek1685e632014-04-08 02:27:49 +0200279 /**
280 * @return has the system set this notification to be expanded
281 */
282 public boolean isSystemExpanded() {
283 return mIsSystemExpanded;
284 }
285
286 /**
287 * Set this notification to be expanded by the system.
288 *
289 * @param expand whether the system wants this notification to be expanded.
290 */
291 public void setSystemExpanded(boolean expand) {
Selim Cinek31094df2014-08-14 19:28:15 +0200292 if (expand != mIsSystemExpanded) {
293 final boolean wasExpanded = isExpanded();
294 mIsSystemExpanded = expand;
295 notifyHeightChanged();
296 logExpansionEvent(false, wasExpanded);
297 }
Jorim Jaggidce3c4c2014-04-29 23:12:24 +0200298 }
299
300 /**
301 * @param expansionDisabled whether to prevent notification expansion
302 */
303 public void setExpansionDisabled(boolean expansionDisabled) {
Selim Cinek31094df2014-08-14 19:28:15 +0200304 if (expansionDisabled != mExpansionDisabled) {
305 final boolean wasExpanded = isExpanded();
306 mExpansionDisabled = expansionDisabled;
307 logExpansionEvent(false, wasExpanded);
308 if (wasExpanded != isExpanded()) {
309 notifyHeightChanged();
310 }
311 }
Selim Cinek1685e632014-04-08 02:27:49 +0200312 }
313
314 /**
Dan Sandler0d3e62f2014-07-14 17:13:50 -0400315 * @return Can the underlying notification be cleared?
316 */
317 public boolean isClearable() {
Selim Cineka37774f2014-11-11 19:16:18 +0100318 return mStatusBarNotification != null && mStatusBarNotification.isClearable();
Dan Sandler0d3e62f2014-07-14 17:13:50 -0400319 }
320
321 /**
Selim Cinek1685e632014-04-08 02:27:49 +0200322 * Apply an expansion state to the layout.
Selim Cinek1685e632014-04-08 02:27:49 +0200323 */
Jorim Jaggidce3c4c2014-04-29 23:12:24 +0200324 public void applyExpansionToLayout() {
325 boolean expand = isExpanded();
Chris Wren51c75102013-07-16 20:49:17 -0400326 if (expand && mExpandable) {
Jorim Jaggibe565df2014-04-28 17:51:23 +0200327 setActualHeight(mMaxExpandHeight);
Chris Wren51c75102013-07-16 20:49:17 -0400328 } else {
Jorim Jaggibe565df2014-04-28 17:51:23 +0200329 setActualHeight(mRowMinHeight);
Chris Wren51c75102013-07-16 20:49:17 -0400330 }
Chris Wren51c75102013-07-16 20:49:17 -0400331 }
Dan Sandlera5e0f412014-01-23 15:11:54 -0500332
Jorim Jaggi9cbadd32014-05-01 20:18:31 +0200333 @Override
334 public int getIntrinsicHeight() {
Jorim Jaggibe565df2014-04-28 17:51:23 +0200335 if (isUserLocked()) {
336 return getActualHeight();
337 }
Selim Cinek1685e632014-04-08 02:27:49 +0200338 boolean inExpansionState = isExpanded();
339 if (!inExpansionState) {
340 // not expanded, so we return the collapsed size
341 return mRowMinHeight;
342 }
343
Jorim Jaggiae441282014-08-01 02:45:18 +0200344 return mShowingPublicForIntrinsicHeight ? mRowMinHeight : getMaxExpandHeight();
Selim Cinek1685e632014-04-08 02:27:49 +0200345 }
346
Selim Cinek1685e632014-04-08 02:27:49 +0200347 /**
348 * Check whether the view state is currently expanded. This is given by the system in {@link
349 * #setSystemExpanded(boolean)} and can be overridden by user expansion or
350 * collapsing in {@link #setUserExpanded(boolean)}. Note that the visual appearance of this
351 * view can differ from this state, if layout params are modified from outside.
352 *
353 * @return whether the view state is currently expanded.
354 */
355 private boolean isExpanded() {
Jorim Jaggidce3c4c2014-04-29 23:12:24 +0200356 return !mExpansionDisabled
357 && (!hasUserChangedExpansion() && isSystemExpanded() || isUserExpanded());
Selim Cinek1685e632014-04-08 02:27:49 +0200358 }
359
360 @Override
361 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
362 super.onLayout(changed, left, top, right, bottom);
Selim Cineka5e211b2014-08-11 17:35:48 +0200363 boolean updateExpandHeight = mMaxExpandHeight == 0 && !mWasReset;
Selim Cinekd2319fb2014-09-01 19:41:54 +0200364 updateMaxExpandHeight();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200365 if (updateExpandHeight) {
Jorim Jaggidce3c4c2014-04-29 23:12:24 +0200366 applyExpansionToLayout();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200367 }
Selim Cineka5e211b2014-08-11 17:35:48 +0200368 mWasReset = false;
Selim Cinek1685e632014-04-08 02:27:49 +0200369 }
370
Selim Cinekd2319fb2014-09-01 19:41:54 +0200371 private void updateMaxExpandHeight() {
372 int intrinsicBefore = getIntrinsicHeight();
373 mMaxExpandHeight = mPrivateLayout.getMaxHeight();
374 if (intrinsicBefore != getIntrinsicHeight()) {
375 notifyHeightChanged();
376 }
377 }
378
Jorim Jaggiae441282014-08-01 02:45:18 +0200379 public void setSensitive(boolean sensitive) {
380 mSensitive = sensitive;
381 }
382
383 public void setHideSensitiveForIntrinsicHeight(boolean hideSensitive) {
384 mShowingPublicForIntrinsicHeight = mSensitive && hideSensitive;
385 }
386
387 public void setHideSensitive(boolean hideSensitive, boolean animated, long delay,
388 long duration) {
389 boolean oldShowingPublic = mShowingPublic;
390 mShowingPublic = mSensitive && hideSensitive;
391 if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) {
392 return;
393 }
Dan Sandlera5e0f412014-01-23 15:11:54 -0500394
395 // bail out if no public version
Selim Cinek1685e632014-04-08 02:27:49 +0200396 if (mPublicLayout.getChildCount() == 0) return;
Dan Sandlera5e0f412014-01-23 15:11:54 -0500397
Jorim Jaggiae441282014-08-01 02:45:18 +0200398 if (!animated) {
399 mPublicLayout.animate().cancel();
400 mPrivateLayout.animate().cancel();
401 mPublicLayout.setAlpha(1f);
402 mPrivateLayout.setAlpha(1f);
403 mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE);
404 mPrivateLayout.setVisibility(mShowingPublic ? View.INVISIBLE : View.VISIBLE);
405 } else {
406 animateShowingPublic(delay, duration);
407 }
Dan Sandler0d3e62f2014-07-14 17:13:50 -0400408
409 updateVetoButton();
Jorim Jaggiae441282014-08-01 02:45:18 +0200410 mShowingPublicInitialized = true;
411 }
412
413 private void animateShowingPublic(long delay, long duration) {
414 final View source = mShowingPublic ? mPrivateLayout : mPublicLayout;
415 View target = mShowingPublic ? mPublicLayout : mPrivateLayout;
416 source.setVisibility(View.VISIBLE);
417 target.setVisibility(View.VISIBLE);
418 target.setAlpha(0f);
419 source.animate().cancel();
420 target.animate().cancel();
421 source.animate()
422 .alpha(0f)
Jorim Jaggiae441282014-08-01 02:45:18 +0200423 .setStartDelay(delay)
424 .setDuration(duration)
425 .withEndAction(new Runnable() {
426 @Override
427 public void run() {
428 source.setVisibility(View.INVISIBLE);
429 }
430 });
431 target.animate()
432 .alpha(1f)
Jorim Jaggiae441282014-08-01 02:45:18 +0200433 .setStartDelay(delay)
434 .setDuration(duration);
Dan Sandler0d3e62f2014-07-14 17:13:50 -0400435 }
436
437 private void updateVetoButton() {
438 // public versions cannot be dismissed
439 mVetoButton.setVisibility(isClearable() && !mShowingPublic ? View.VISIBLE : View.GONE);
Dan Sandlera5e0f412014-01-23 15:11:54 -0500440 }
Jorim Jaggi251957d2014-04-09 04:24:09 +0200441
Selim Cinek1685e632014-04-08 02:27:49 +0200442 public int getMaxExpandHeight() {
Jorim Jaggiae441282014-08-01 02:45:18 +0200443 return mShowingPublicForIntrinsicHeight ? mRowMinHeight : mMaxExpandHeight;
Chris Wren51c75102013-07-16 20:49:17 -0400444 }
Jorim Jaggi584a7aa2014-04-10 23:26:13 +0200445
Jorim Jaggibe565df2014-04-28 17:51:23 +0200446 @Override
Jorim Jaggi4222d9a2014-04-23 16:13:15 +0200447 public boolean isContentExpandable() {
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200448 NotificationContentView showingLayout = getShowingLayout();
449 return showingLayout.isContentExpandable();
Jorim Jaggi4222d9a2014-04-23 16:13:15 +0200450 }
451
452 @Override
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200453 public void setActualHeight(int height, boolean notifyListeners) {
Selim Cinekc9c00ae2014-05-20 03:33:40 +0200454 mPrivateLayout.setActualHeight(height);
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200455 mPublicLayout.setActualHeight(height);
Jorim Jaggib1cd3c12014-09-08 19:55:17 +0200456 if (mGuts != null) {
457 mGuts.setActualHeight(height);
458 }
Jorim Jaggibe565df2014-04-28 17:51:23 +0200459 invalidate();
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200460 super.setActualHeight(height, notifyListeners);
Jorim Jaggibe565df2014-04-28 17:51:23 +0200461 }
462
463 @Override
464 public int getMaxHeight() {
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200465 NotificationContentView showingLayout = getShowingLayout();
466 return showingLayout.getMaxHeight();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200467 }
468
469 @Override
Jorim Jaggi4222d9a2014-04-23 16:13:15 +0200470 public int getMinHeight() {
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200471 NotificationContentView showingLayout = getShowingLayout();
472 return showingLayout.getMinHeight();
Jorim Jaggi4222d9a2014-04-23 16:13:15 +0200473 }
474
475 @Override
Jorim Jaggibe565df2014-04-28 17:51:23 +0200476 public void setClipTopAmount(int clipTopAmount) {
477 super.setClipTopAmount(clipTopAmount);
478 mPrivateLayout.setClipTopAmount(clipTopAmount);
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200479 mPublicLayout.setClipTopAmount(clipTopAmount);
Jorim Jaggib1cd3c12014-09-08 19:55:17 +0200480 if (mGuts != null) {
481 mGuts.setClipTopAmount(clipTopAmount);
482 }
Jorim Jaggibe565df2014-04-28 17:51:23 +0200483 }
484
485 public void notifyContentUpdated() {
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200486 mPublicLayout.notifyContentUpdated();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200487 mPrivateLayout.notifyContentUpdated();
Selim Cinek343e6e22014-04-11 21:23:30 +0200488 }
Selim Cinek7d447722014-06-10 15:51:59 +0200489
Selim Cinek31094df2014-08-14 19:28:15 +0200490 public boolean isMaxExpandHeightInitialized() {
491 return mMaxExpandHeight != 0;
Selim Cinek7d447722014-06-10 15:51:59 +0200492 }
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200493
494 private NotificationContentView getShowingLayout() {
495 return mShowingPublic ? mPublicLayout : mPrivateLayout;
496 }
Chris Wren78403d72014-07-28 10:23:24 +0100497
498 public void setExpansionLogger(ExpansionLogger logger, String key) {
499 mLogger = logger;
500 mLoggingKey = key;
501 }
502
503
504 private void logExpansionEvent(boolean userAction, boolean wasExpanded) {
505 final boolean nowExpanded = isExpanded();
506 if (wasExpanded != nowExpanded && mLogger != null) {
507 mLogger.logNotificationExpansion(mLoggingKey, userAction, nowExpanded) ;
508 }
509 }
Chris Wren51c75102013-07-16 20:49:17 -0400510}