summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/Notification.java35
1 files changed, 26 insertions, 9 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index f896fb592be9..6fc1820c3c36 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1866,6 +1866,10 @@ public class Notification implements Parcelable
} else {
parcel.writeInt(0);
}
+ if (mLargeIcon == null && largeIcon != null) {
+ // you snuck an icon in here without using the builder; let's try to keep it
+ mLargeIcon = Icon.createWithBitmap(largeIcon);
+ }
if (mLargeIcon != null) {
parcel.writeInt(1);
mLargeIcon.writeToParcel(parcel, 0);
@@ -3230,7 +3234,7 @@ public class Notification implements Parcelable
contentView.setViewVisibility(textId, View.VISIBLE);
}
- setContentMinHeight(contentView, showProgress || mN.mLargeIcon != null);
+ setContentMinHeight(contentView, showProgress || mN.hasLargeIcon());
return contentView;
}
@@ -3274,6 +3278,9 @@ public class Notification implements Parcelable
}
private void bindLargeIcon(RemoteViews contentView) {
+ if (mN.mLargeIcon == null && mN.largeIcon != null) {
+ mN.mLargeIcon = Icon.createWithBitmap(mN.largeIcon);
+ }
if (mN.mLargeIcon != null) {
contentView.setViewVisibility(R.id.right_icon, View.VISIBLE);
contentView.setImageViewIcon(R.id.right_icon, mN.mLargeIcon);
@@ -3380,6 +3387,9 @@ public class Notification implements Parcelable
}
private void bindSmallIcon(RemoteViews contentView) {
+ if (mN.mSmallIcon == null && mN.icon != 0) {
+ mN.mSmallIcon = Icon.createWithResource(mContext, mN.icon);
+ }
contentView.setImageViewIcon(R.id.icon, mN.mSmallIcon);
processSmallIconColor(mN.mSmallIcon, contentView);
}
@@ -3579,6 +3589,8 @@ public class Notification implements Parcelable
mStyle = null;
Icon largeIcon = mN.mLargeIcon;
mN.mLargeIcon = null;
+ Bitmap largeIconLegacy = mN.largeIcon;
+ mN.largeIcon = null;
Bundle publicExtras = new Bundle();
publicExtras.putBoolean(EXTRA_SHOW_WHEN,
savedBundle.getBoolean(EXTRA_SHOW_WHEN));
@@ -3592,6 +3604,7 @@ public class Notification implements Parcelable
final RemoteViews publicView = applyStandardTemplate(getBaseLayoutResource());
mN.extras = savedBundle;
mN.mLargeIcon = largeIcon;
+ mN.largeIcon = largeIconLegacy;
mStyle = style;
return publicView;
}
@@ -3888,6 +3901,10 @@ public class Notification implements Parcelable
}
}
+ private boolean hasLargeIcon() {
+ return mLargeIcon != null || largeIcon != null;
+ }
+
/**
* @return true if the notification will show the time; false otherwise
* @hide
@@ -4194,7 +4211,7 @@ public class Notification implements Parcelable
contentView.setTextViewText(R.id.text, mBuilder.processLegacyText(mSummaryText));
contentView.setViewVisibility(R.id.text, View.VISIBLE);
}
- mBuilder.setContentMinHeight(contentView, mBuilder.mN.mLargeIcon != null);
+ mBuilder.setContentMinHeight(contentView, mBuilder.mN.hasLargeIcon());
if (mBigLargeIconSet) {
mBuilder.mN.mLargeIcon = oldLargeIcon;
@@ -4349,7 +4366,7 @@ public class Notification implements Parcelable
contentView.setViewVisibility(R.id.big_text,
TextUtils.isEmpty(bigTextText) ? View.GONE : View.VISIBLE);
contentView.setInt(R.id.big_text, "setMaxLines", calculateMaxLines(builder));
- contentView.setBoolean(R.id.big_text, "setHasImage", builder.mN.mLargeIcon != null);
+ contentView.setBoolean(R.id.big_text, "setHasImage", builder.mN.hasLargeIcon());
}
private static int calculateMaxLines(Builder builder) {
@@ -4622,7 +4639,7 @@ public class Notification implements Parcelable
contentView.setViewLayoutMarginBottomDimen(R.id.line1,
hasTitle ? R.dimen.notification_messaging_spacing : 0);
contentView.setInt(R.id.notification_messaging, "setNumIndentLines",
- mBuilder.mN.mLargeIcon == null ? 0 : (hasTitle ? 1 : 2));
+ !mBuilder.mN.hasLargeIcon() ? 0 : (hasTitle ? 1 : 2));
int contractedChildId = View.NO_ID;
Message contractedMessage = findLatestIncomingMessage();
@@ -4995,7 +5012,7 @@ public class Notification implements Parcelable
final int max = mBuilder.mN.extras.getInt(EXTRA_PROGRESS_MAX, 0);
final boolean ind = mBuilder.mN.extras.getBoolean(EXTRA_PROGRESS_INDETERMINATE);
boolean hasProgress = max != 0 || ind;
- if (mBuilder.mN.mLargeIcon != null && !hasProgress) {
+ if (mBuilder.mN.hasLargeIcon() && !hasProgress) {
endMargin = R.dimen.notification_content_picture_margin;
}
}
@@ -5185,7 +5202,7 @@ public class Notification implements Parcelable
handleImage(view);
// handle the content margin
int endMargin = R.dimen.notification_content_margin_end;
- if (mBuilder.mN.mLargeIcon != null) {
+ if (mBuilder.mN.hasLargeIcon()) {
endMargin = R.dimen.notification_content_plus_picture_margin_end;
}
view.setViewLayoutMarginEndDimen(R.id.notification_main_column, endMargin);
@@ -5198,7 +5215,7 @@ public class Notification implements Parcelable
int actionsInCompact = mActionsToShowInCompact == null
? 0
: Math.min(mActionsToShowInCompact.length, MAX_MEDIA_BUTTONS_IN_COMPACT);
- if (mBuilder.mN.mLargeIcon == null && actionCount <= actionsInCompact) {
+ if (!mBuilder.mN.hasLargeIcon() && actionCount <= actionsInCompact) {
return null;
}
RemoteViews big = mBuilder.applyStandardTemplate(
@@ -5218,7 +5235,7 @@ public class Notification implements Parcelable
}
private void handleImage(RemoteViews contentView) {
- if (mBuilder.mN.mLargeIcon != null) {
+ if (mBuilder.mN.hasLargeIcon()) {
contentView.setViewLayoutMarginEndDimen(R.id.line1, 0);
contentView.setViewLayoutMarginEndDimen(R.id.text, 0);
}
@@ -5336,7 +5353,7 @@ public class Notification implements Parcelable
}
// also update the end margin if there is an image
int endMargin = R.dimen.notification_content_margin_end;
- if (mBuilder.mN.mLargeIcon != null) {
+ if (mBuilder.mN.hasLargeIcon()) {
endMargin = R.dimen.notification_content_plus_picture_margin_end;
}
remoteViews.setViewLayoutMarginEndDimen(R.id.notification_main_column, endMargin);