blob: f8332eae46b74feb075303535fb9b744017aba16 [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;
121 }
122
123 public StatusBarNotification getStatusBarNotification() {
124 return mStatusBarNotification;
125 }
126
Selim Cinek1a521f32014-11-03 17:39:29 +0100127 public void setHeadsUp(boolean isHeadsUp) {
128 mIsHeadsUp = isHeadsUp;
129 }
130
Chris Wren78403d72014-07-28 10:23:24 +0100131 public interface ExpansionLogger {
132 public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
133 }
Selim Cinek1685e632014-04-08 02:27:49 +0200134
Chris Wren51c75102013-07-16 20:49:17 -0400135 public ExpandableNotificationRow(Context context, AttributeSet attrs) {
136 super(context, attrs);
137 }
138
Christoph Studera7fe6312014-06-27 19:32:44 +0200139 /**
140 * Resets this view so it can be re-used for an updated notification.
141 */
Christoph Studer22f2ee52014-07-29 22:57:21 +0200142 @Override
Christoph Studera7fe6312014-06-27 19:32:44 +0200143 public void reset() {
Christoph Studer22f2ee52014-07-29 22:57:21 +0200144 super.reset();
Christoph Studera7fe6312014-06-27 19:32:44 +0200145 mRowMinHeight = 0;
Chris Wren78403d72014-07-28 10:23:24 +0100146 final boolean wasExpanded = isExpanded();
Christoph Studera7fe6312014-06-27 19:32:44 +0200147 mRowMaxHeight = 0;
148 mExpandable = false;
149 mHasUserChangedExpansion = false;
150 mUserLocked = false;
151 mShowingPublic = false;
Jorim Jaggiae441282014-08-01 02:45:18 +0200152 mSensitive = false;
153 mShowingPublicInitialized = false;
Christoph Studera7fe6312014-06-27 19:32:44 +0200154 mIsSystemExpanded = false;
155 mExpansionDisabled = false;
Selim Cinek1a521f32014-11-03 17:39:29 +0100156 mPublicLayout.reset(mIsHeadsUp);
157 mPrivateLayout.reset(mIsHeadsUp);
Selim Cinek31094df2014-08-14 19:28:15 +0200158 resetHeight();
159 logExpansionEvent(false, wasExpanded);
160 }
161
162 public void resetHeight() {
Selim Cinek1a521f32014-11-03 17:39:29 +0100163 if (mIsHeadsUp) {
164 resetActualHeight();
165 }
Christoph Studera7fe6312014-06-27 19:32:44 +0200166 mMaxExpandHeight = 0;
Selim Cineka5e211b2014-08-11 17:35:48 +0200167 mWasReset = true;
Selim Cinek31094df2014-08-14 19:28:15 +0200168 onHeightReset();
Selim Cinek6e28a672014-09-05 14:43:28 +0200169 requestLayout();
Christoph Studera7fe6312014-06-27 19:32:44 +0200170 }
171
Jorim Jaggi251957d2014-04-09 04:24:09 +0200172 @Override
Selim Cinek1a521f32014-11-03 17:39:29 +0100173 protected boolean filterMotionEvent(MotionEvent event) {
174 return mIsHeadsUp || super.filterMotionEvent(event);
175 }
176
177 @Override
Jorim Jaggi251957d2014-04-09 04:24:09 +0200178 protected void onFinishInflate() {
179 super.onFinishInflate();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200180 mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
181 mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded);
Jorim Jaggib1cd3c12014-09-08 19:55:17 +0200182 ViewStub gutsStub = (ViewStub) findViewById(R.id.notification_guts_stub);
183 gutsStub.setOnInflateListener(new ViewStub.OnInflateListener() {
184 @Override
185 public void onInflate(ViewStub stub, View inflated) {
186 mGuts = (NotificationGuts) inflated;
187 mGuts.setClipTopAmount(getClipTopAmount());
188 mGuts.setActualHeight(getActualHeight());
189 }
190 });
Selim Cinek863834b2014-05-20 04:20:25 +0200191 mVetoButton = findViewById(R.id.veto);
Jorim Jaggife40f7d2014-04-28 15:20:04 +0200192 }
193
194 @Override
195 public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
196 if (super.onRequestSendAccessibilityEvent(child, event)) {
197 // Add a record for the entire layout since its content is somehow small.
198 // The event comes from a leaf view that is interacted with.
199 AccessibilityEvent record = AccessibilityEvent.obtain();
200 onInitializeAccessibilityEvent(record);
201 dispatchPopulateAccessibilityEvent(record);
202 event.appendRecord(record);
203 return true;
204 }
205 return false;
Jorim Jaggic5dc0d02014-04-15 15:42:55 +0200206 }
Chris Wren51c75102013-07-16 20:49:17 -0400207
John Spurlocke15452b2014-08-21 09:44:39 -0400208 @Override
209 public void setDark(boolean dark, boolean fade) {
210 super.setDark(dark, fade);
211 final NotificationContentView showing = getShowingLayout();
212 if (showing != null) {
213 showing.setDark(dark, fade);
214 }
215 }
216
Selim Cinek1685e632014-04-08 02:27:49 +0200217 public void setHeightRange(int rowMinHeight, int rowMaxHeight) {
218 mRowMinHeight = rowMinHeight;
219 mRowMaxHeight = rowMaxHeight;
Chris Wren51c75102013-07-16 20:49:17 -0400220 }
221
222 public boolean isExpandable() {
223 return mExpandable;
224 }
225
226 public void setExpandable(boolean expandable) {
227 mExpandable = expandable;
228 }
229
Selim Cinek1685e632014-04-08 02:27:49 +0200230 /**
231 * @return whether the user has changed the expansion state
232 */
233 public boolean hasUserChangedExpansion() {
234 return mHasUserChangedExpansion;
235 }
236
Chris Wren51c75102013-07-16 20:49:17 -0400237 public boolean isUserExpanded() {
238 return mUserExpanded;
239 }
240
Selim Cinek1685e632014-04-08 02:27:49 +0200241 /**
242 * Set this notification to be expanded by the user
243 *
244 * @param userExpanded whether the user wants this notification to be expanded
245 */
Chris Wren51c75102013-07-16 20:49:17 -0400246 public void setUserExpanded(boolean userExpanded) {
Christoph Studera7fe6312014-06-27 19:32:44 +0200247 if (userExpanded && !mExpandable) return;
Chris Wren78403d72014-07-28 10:23:24 +0100248 final boolean wasExpanded = isExpanded();
Selim Cinek1685e632014-04-08 02:27:49 +0200249 mHasUserChangedExpansion = true;
Chris Wren51c75102013-07-16 20:49:17 -0400250 mUserExpanded = userExpanded;
Chris Wren78403d72014-07-28 10:23:24 +0100251 logExpansionEvent(true, wasExpanded);
Chris Wren51c75102013-07-16 20:49:17 -0400252 }
253
Selim Cinekccd14fb2014-08-12 18:53:24 +0200254 public void resetUserExpansion() {
255 mHasUserChangedExpansion = false;
256 mUserExpanded = false;
257 }
258
Chris Wren51c75102013-07-16 20:49:17 -0400259 public boolean isUserLocked() {
260 return mUserLocked;
261 }
262
263 public void setUserLocked(boolean userLocked) {
264 mUserLocked = userLocked;
265 }
266
Selim Cinek1685e632014-04-08 02:27:49 +0200267 /**
268 * @return has the system set this notification to be expanded
269 */
270 public boolean isSystemExpanded() {
271 return mIsSystemExpanded;
272 }
273
274 /**
275 * Set this notification to be expanded by the system.
276 *
277 * @param expand whether the system wants this notification to be expanded.
278 */
279 public void setSystemExpanded(boolean expand) {
Selim Cinek31094df2014-08-14 19:28:15 +0200280 if (expand != mIsSystemExpanded) {
281 final boolean wasExpanded = isExpanded();
282 mIsSystemExpanded = expand;
283 notifyHeightChanged();
284 logExpansionEvent(false, wasExpanded);
285 }
Jorim Jaggidce3c4c2014-04-29 23:12:24 +0200286 }
287
288 /**
289 * @param expansionDisabled whether to prevent notification expansion
290 */
291 public void setExpansionDisabled(boolean expansionDisabled) {
Selim Cinek31094df2014-08-14 19:28:15 +0200292 if (expansionDisabled != mExpansionDisabled) {
293 final boolean wasExpanded = isExpanded();
294 mExpansionDisabled = expansionDisabled;
295 logExpansionEvent(false, wasExpanded);
296 if (wasExpanded != isExpanded()) {
297 notifyHeightChanged();
298 }
299 }
Selim Cinek1685e632014-04-08 02:27:49 +0200300 }
301
302 /**
Dan Sandler0d3e62f2014-07-14 17:13:50 -0400303 * @return Can the underlying notification be cleared?
304 */
305 public boolean isClearable() {
306 return mClearable;
307 }
308
309 /**
310 * Set whether the notification can be cleared.
311 *
312 * @param clearable
313 */
314 public void setClearable(boolean clearable) {
315 mClearable = clearable;
316 updateVetoButton();
317 }
318
319 /**
Selim Cinek1685e632014-04-08 02:27:49 +0200320 * Apply an expansion state to the layout.
Selim Cinek1685e632014-04-08 02:27:49 +0200321 */
Jorim Jaggidce3c4c2014-04-29 23:12:24 +0200322 public void applyExpansionToLayout() {
323 boolean expand = isExpanded();
Chris Wren51c75102013-07-16 20:49:17 -0400324 if (expand && mExpandable) {
Jorim Jaggibe565df2014-04-28 17:51:23 +0200325 setActualHeight(mMaxExpandHeight);
Chris Wren51c75102013-07-16 20:49:17 -0400326 } else {
Jorim Jaggibe565df2014-04-28 17:51:23 +0200327 setActualHeight(mRowMinHeight);
Chris Wren51c75102013-07-16 20:49:17 -0400328 }
Chris Wren51c75102013-07-16 20:49:17 -0400329 }
Dan Sandlera5e0f412014-01-23 15:11:54 -0500330
Jorim Jaggi9cbadd32014-05-01 20:18:31 +0200331 @Override
332 public int getIntrinsicHeight() {
Jorim Jaggibe565df2014-04-28 17:51:23 +0200333 if (isUserLocked()) {
334 return getActualHeight();
335 }
Selim Cinek1685e632014-04-08 02:27:49 +0200336 boolean inExpansionState = isExpanded();
337 if (!inExpansionState) {
338 // not expanded, so we return the collapsed size
339 return mRowMinHeight;
340 }
341
Jorim Jaggiae441282014-08-01 02:45:18 +0200342 return mShowingPublicForIntrinsicHeight ? mRowMinHeight : getMaxExpandHeight();
Selim Cinek1685e632014-04-08 02:27:49 +0200343 }
344
Selim Cinek1685e632014-04-08 02:27:49 +0200345 /**
346 * Check whether the view state is currently expanded. This is given by the system in {@link
347 * #setSystemExpanded(boolean)} and can be overridden by user expansion or
348 * collapsing in {@link #setUserExpanded(boolean)}. Note that the visual appearance of this
349 * view can differ from this state, if layout params are modified from outside.
350 *
351 * @return whether the view state is currently expanded.
352 */
353 private boolean isExpanded() {
Jorim Jaggidce3c4c2014-04-29 23:12:24 +0200354 return !mExpansionDisabled
355 && (!hasUserChangedExpansion() && isSystemExpanded() || isUserExpanded());
Selim Cinek1685e632014-04-08 02:27:49 +0200356 }
357
358 @Override
359 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
360 super.onLayout(changed, left, top, right, bottom);
Selim Cineka5e211b2014-08-11 17:35:48 +0200361 boolean updateExpandHeight = mMaxExpandHeight == 0 && !mWasReset;
Selim Cinekd2319fb2014-09-01 19:41:54 +0200362 updateMaxExpandHeight();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200363 if (updateExpandHeight) {
Jorim Jaggidce3c4c2014-04-29 23:12:24 +0200364 applyExpansionToLayout();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200365 }
Selim Cineka5e211b2014-08-11 17:35:48 +0200366 mWasReset = false;
Selim Cinek1685e632014-04-08 02:27:49 +0200367 }
368
Selim Cinekd2319fb2014-09-01 19:41:54 +0200369 private void updateMaxExpandHeight() {
370 int intrinsicBefore = getIntrinsicHeight();
371 mMaxExpandHeight = mPrivateLayout.getMaxHeight();
372 if (intrinsicBefore != getIntrinsicHeight()) {
373 notifyHeightChanged();
374 }
375 }
376
Jorim Jaggiae441282014-08-01 02:45:18 +0200377 public void setSensitive(boolean sensitive) {
378 mSensitive = sensitive;
379 }
380
381 public void setHideSensitiveForIntrinsicHeight(boolean hideSensitive) {
382 mShowingPublicForIntrinsicHeight = mSensitive && hideSensitive;
383 }
384
385 public void setHideSensitive(boolean hideSensitive, boolean animated, long delay,
386 long duration) {
387 boolean oldShowingPublic = mShowingPublic;
388 mShowingPublic = mSensitive && hideSensitive;
389 if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) {
390 return;
391 }
Dan Sandlera5e0f412014-01-23 15:11:54 -0500392
393 // bail out if no public version
Selim Cinek1685e632014-04-08 02:27:49 +0200394 if (mPublicLayout.getChildCount() == 0) return;
Dan Sandlera5e0f412014-01-23 15:11:54 -0500395
Jorim Jaggiae441282014-08-01 02:45:18 +0200396 if (!animated) {
397 mPublicLayout.animate().cancel();
398 mPrivateLayout.animate().cancel();
399 mPublicLayout.setAlpha(1f);
400 mPrivateLayout.setAlpha(1f);
401 mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE);
402 mPrivateLayout.setVisibility(mShowingPublic ? View.INVISIBLE : View.VISIBLE);
403 } else {
404 animateShowingPublic(delay, duration);
405 }
Dan Sandler0d3e62f2014-07-14 17:13:50 -0400406
407 updateVetoButton();
Jorim Jaggiae441282014-08-01 02:45:18 +0200408 mShowingPublicInitialized = true;
409 }
410
411 private void animateShowingPublic(long delay, long duration) {
412 final View source = mShowingPublic ? mPrivateLayout : mPublicLayout;
413 View target = mShowingPublic ? mPublicLayout : mPrivateLayout;
414 source.setVisibility(View.VISIBLE);
415 target.setVisibility(View.VISIBLE);
416 target.setAlpha(0f);
417 source.animate().cancel();
418 target.animate().cancel();
419 source.animate()
420 .alpha(0f)
Jorim Jaggiae441282014-08-01 02:45:18 +0200421 .setStartDelay(delay)
422 .setDuration(duration)
423 .withEndAction(new Runnable() {
424 @Override
425 public void run() {
426 source.setVisibility(View.INVISIBLE);
427 }
428 });
429 target.animate()
430 .alpha(1f)
Jorim Jaggiae441282014-08-01 02:45:18 +0200431 .setStartDelay(delay)
432 .setDuration(duration);
Dan Sandler0d3e62f2014-07-14 17:13:50 -0400433 }
434
435 private void updateVetoButton() {
436 // public versions cannot be dismissed
437 mVetoButton.setVisibility(isClearable() && !mShowingPublic ? View.VISIBLE : View.GONE);
Dan Sandlera5e0f412014-01-23 15:11:54 -0500438 }
Jorim Jaggi251957d2014-04-09 04:24:09 +0200439
Selim Cinek1685e632014-04-08 02:27:49 +0200440 public int getMaxExpandHeight() {
Jorim Jaggiae441282014-08-01 02:45:18 +0200441 return mShowingPublicForIntrinsicHeight ? mRowMinHeight : mMaxExpandHeight;
Chris Wren51c75102013-07-16 20:49:17 -0400442 }
Jorim Jaggi584a7aa2014-04-10 23:26:13 +0200443
Jorim Jaggibe565df2014-04-28 17:51:23 +0200444 @Override
Jorim Jaggi4222d9a2014-04-23 16:13:15 +0200445 public boolean isContentExpandable() {
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200446 NotificationContentView showingLayout = getShowingLayout();
447 return showingLayout.isContentExpandable();
Jorim Jaggi4222d9a2014-04-23 16:13:15 +0200448 }
449
450 @Override
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200451 public void setActualHeight(int height, boolean notifyListeners) {
Selim Cinekc9c00ae2014-05-20 03:33:40 +0200452 mPrivateLayout.setActualHeight(height);
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200453 mPublicLayout.setActualHeight(height);
Jorim Jaggib1cd3c12014-09-08 19:55:17 +0200454 if (mGuts != null) {
455 mGuts.setActualHeight(height);
456 }
Jorim Jaggibe565df2014-04-28 17:51:23 +0200457 invalidate();
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200458 super.setActualHeight(height, notifyListeners);
Jorim Jaggibe565df2014-04-28 17:51:23 +0200459 }
460
461 @Override
462 public int getMaxHeight() {
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200463 NotificationContentView showingLayout = getShowingLayout();
464 return showingLayout.getMaxHeight();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200465 }
466
467 @Override
Jorim Jaggi4222d9a2014-04-23 16:13:15 +0200468 public int getMinHeight() {
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200469 NotificationContentView showingLayout = getShowingLayout();
470 return showingLayout.getMinHeight();
Jorim Jaggi4222d9a2014-04-23 16:13:15 +0200471 }
472
473 @Override
Jorim Jaggibe565df2014-04-28 17:51:23 +0200474 public void setClipTopAmount(int clipTopAmount) {
475 super.setClipTopAmount(clipTopAmount);
476 mPrivateLayout.setClipTopAmount(clipTopAmount);
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200477 mPublicLayout.setClipTopAmount(clipTopAmount);
Jorim Jaggib1cd3c12014-09-08 19:55:17 +0200478 if (mGuts != null) {
479 mGuts.setClipTopAmount(clipTopAmount);
480 }
Jorim Jaggibe565df2014-04-28 17:51:23 +0200481 }
482
483 public void notifyContentUpdated() {
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200484 mPublicLayout.notifyContentUpdated();
Jorim Jaggibe565df2014-04-28 17:51:23 +0200485 mPrivateLayout.notifyContentUpdated();
Selim Cinek343e6e22014-04-11 21:23:30 +0200486 }
Selim Cinek7d447722014-06-10 15:51:59 +0200487
Selim Cinek31094df2014-08-14 19:28:15 +0200488 public boolean isMaxExpandHeightInitialized() {
489 return mMaxExpandHeight != 0;
Selim Cinek7d447722014-06-10 15:51:59 +0200490 }
Selim Cinek2f0df8a2014-06-10 17:40:42 +0200491
492 private NotificationContentView getShowingLayout() {
493 return mShowingPublic ? mPublicLayout : mPrivateLayout;
494 }
Chris Wren78403d72014-07-28 10:23:24 +0100495
496 public void setExpansionLogger(ExpansionLogger logger, String key) {
497 mLogger = logger;
498 mLoggingKey = key;
499 }
500
501
502 private void logExpansionEvent(boolean userAction, boolean wasExpanded) {
503 final boolean nowExpanded = isExpanded();
504 if (wasExpanded != nowExpanded && mLogger != null) {
505 mLogger.logNotificationExpansion(mLoggingKey, userAction, nowExpanded) ;
506 }
507 }
Chris Wren51c75102013-07-16 20:49:17 -0400508}