From fe718433e0437db3fec741e5d8fdde5c71d39aba Mon Sep 17 00:00:00 2001 From: Christoph Studer Date: Mon, 1 Sep 2014 18:21:18 +0200 Subject: [PATCH] Notification: Reset view params for re-use Since RemoteViews are reapplied in SysUI, reset potentially modified view params before configuring it. Bug: 17175860 Change-Id: I0eceb1522461f8302e69af1a995a8d036951d1ed --- core/java/android/app/Notification.java | 38 ++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 966d2ce2f725a..83e3b5fd1e952 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -2623,10 +2623,39 @@ public class Notification implements Parcelable contentView.setTextViewTextSize(R.id.text, TypedValue.COMPLEX_UNIT_PX, subTextSize); } + private void unshrinkLine3Text(RemoteViews contentView) { + float regularTextSize = mContext.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.notification_text_size); + contentView.setTextViewTextSize(R.id.text, TypedValue.COMPLEX_UNIT_PX, regularTextSize); + } + + private void resetStandardTemplate(RemoteViews contentView) { + removeLargeIconBackground(contentView); + contentView.setViewPadding(R.id.icon, 0, 0, 0, 0); + contentView.setImageViewResource(R.id.icon, 0); + contentView.setInt(R.id.icon, "setBackgroundResource", 0); + contentView.setViewVisibility(R.id.right_icon, View.GONE); + contentView.setInt(R.id.right_icon, "setBackgroundResource", 0); + contentView.setImageViewResource(R.id.right_icon, 0); + contentView.setImageViewResource(R.id.icon, 0); + contentView.setTextViewText(R.id.title, null); + contentView.setTextViewText(R.id.text, null); + unshrinkLine3Text(contentView); + contentView.setTextViewText(R.id.text2, null); + contentView.setViewVisibility(R.id.text2, View.GONE); + contentView.setViewVisibility(R.id.info, View.GONE); + contentView.setViewVisibility(R.id.time, View.GONE); + contentView.setViewVisibility(R.id.line3, View.GONE); + contentView.setViewVisibility(R.id.overflow_divider, View.GONE); + contentView.setViewVisibility(R.id.progress, View.GONE); + } + private RemoteViews applyStandardTemplate(int resId) { RemoteViews contentView = new BuilderRemoteViews(mContext.getPackageName(), mOriginatingUserId, resId); + resetStandardTemplate(contentView); + boolean showLine3 = false; boolean showLine2 = false; boolean contentTextInLine2 = false; @@ -2769,15 +2798,22 @@ public class Notification implements Parcelable return Math.round((1 - largeFactor) * padding + largeFactor * largePadding); } + private void resetStandardTemplateWithActions(RemoteViews big) { + big.setViewVisibility(R.id.actions, View.GONE); + big.setViewVisibility(R.id.action_divider, View.GONE); + big.removeAllViews(R.id.actions); + } + private RemoteViews applyStandardTemplateWithActions(int layoutId) { RemoteViews big = applyStandardTemplate(layoutId); + resetStandardTemplateWithActions(big); + int N = mActions.size(); if (N > 0) { big.setViewVisibility(R.id.actions, View.VISIBLE); big.setViewVisibility(R.id.action_divider, View.VISIBLE); if (N>MAX_ACTION_BUTTONS) N=MAX_ACTION_BUTTONS; - big.removeAllViews(R.id.actions); for (int i=0; i