From 39fa59fc4907d3c8faad41bf20e1f855dbcda5e6 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Tue, 25 Feb 2014 15:38:45 +0100 Subject: [PATCH] Change appearance of notifications to light theme. Change-Id: Ic15e96582d6b46b4dc195b1c7c0cef38f25f0d38 --- core/java/android/app/Notification.java | 77 ++++- .../android/content/res/ColorStateList.java | 18 ++ .../notification_quantum_background.xml | 21 ++ .../res/drawable/notification_quantum_bg.xml | 21 ++ .../drawable/notification_quantum_press.xml | 21 ++ .../layout/notification_quantum_action.xml | 31 ++ .../notification_quantum_action_list.xml | 30 ++ .../notification_quantum_action_tombstone.xml | 33 +++ .../notification_template_quantum_base.xml | 137 +++++++++ ...notification_template_quantum_big_base.xml | 167 +++++++++++ ...ification_template_quantum_big_picture.xml | 62 ++++ ...notification_template_quantum_big_text.xml | 182 ++++++++++++ .../notification_template_quantum_inbox.xml | 266 ++++++++++++++++++ core/res/res/values/styles.xml | 27 ++ core/res/res/values/symbols.xml | 11 +- .../drawable/notification_icon_legacy_bg.xml | 22 ++ .../notification_icon_legacy_bg_inset.xml | 21 ++ packages/SystemUI/res/values/colors.xml | 2 + .../src/com/android/systemui/ImageUtils.java | 82 ++++++ .../systemui/statusbar/BaseStatusBar.java | 226 ++++++++++++++- 20 files changed, 1439 insertions(+), 18 deletions(-) create mode 100644 core/res/res/drawable/notification_quantum_background.xml create mode 100644 core/res/res/drawable/notification_quantum_bg.xml create mode 100644 core/res/res/drawable/notification_quantum_press.xml create mode 100644 core/res/res/layout/notification_quantum_action.xml create mode 100644 core/res/res/layout/notification_quantum_action_list.xml create mode 100644 core/res/res/layout/notification_quantum_action_tombstone.xml create mode 100644 core/res/res/layout/notification_template_quantum_base.xml create mode 100644 core/res/res/layout/notification_template_quantum_big_base.xml create mode 100644 core/res/res/layout/notification_template_quantum_big_picture.xml create mode 100644 core/res/res/layout/notification_template_quantum_big_text.xml create mode 100644 core/res/res/layout/notification_template_quantum_inbox.xml create mode 100644 packages/SystemUI/res/drawable/notification_icon_legacy_bg.xml create mode 100644 packages/SystemUI/res/drawable/notification_icon_legacy_bg_inset.xml create mode 100644 packages/SystemUI/src/com/android/systemui/ImageUtils.java diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index cd1fbf6fff61f..12a8ff6b98590 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -611,6 +611,13 @@ public class Notification implements Parcelable */ public static final String EXTRA_AS_HEADS_UP = "headsup"; + /** + * Extra added from {@link Notification.Builder} to indicate that the remote views were inflated + * from the builder, as opposed to being created directly from the application. + * @hide + */ + public static final String EXTRA_BUILDER_REMOTE_VIEWS = "android.builderRemoteViews"; + /** * Value for {@link #EXTRA_AS_HEADS_UP}. * @hide @@ -1273,6 +1280,7 @@ public class Notification implements Parcelable private boolean mShowWhen = true; private int mVisibility = VISIBILITY_PRIVATE; private Notification mPublicVersion = null; + private boolean mQuantumTheme; /** * Constructs a new Builder with the defaults: @@ -1300,6 +1308,9 @@ public class Notification implements Parcelable mWhen = System.currentTimeMillis(); mAudioStreamType = STREAM_DEFAULT; mPriority = PRIORITY_DEFAULT; + + // TODO: Decide on targetSdk from calling app whether to use quantum theme. + mQuantumTheme = true; } /** @@ -1807,7 +1818,7 @@ public class Notification implements Parcelable contentView.setImageViewBitmap(R.id.icon, mLargeIcon); smallIconImageViewId = R.id.right_icon; } - if (mPriority < PRIORITY_LOW) { + if (!mQuantumTheme && mPriority < PRIORITY_LOW) { contentView.setInt(R.id.icon, "setBackgroundResource", R.drawable.notification_template_icon_low_bg); contentView.setInt(R.id.status_bar_latest_event_content, @@ -1921,7 +1932,7 @@ public class Notification implements Parcelable if (mContentView != null) { return mContentView; } else { - return applyStandardTemplate(R.layout.notification_template_base, true); // no more special large_icon flavor + return applyStandardTemplate(getBaseLayoutResource(), true); // no more special large_icon flavor } } @@ -1942,21 +1953,21 @@ public class Notification implements Parcelable private RemoteViews makeBigContentView() { if (mActions.size() == 0) return null; - return applyStandardTemplateWithActions(R.layout.notification_template_big_base); + return applyStandardTemplateWithActions(getBigBaseLayoutResource()); } - private RemoteViews makeHEadsUpContentView() { + private RemoteViews makeHeadsUpContentView() { if (mActions.size() == 0) return null; - return applyStandardTemplateWithActions(R.layout.notification_template_big_base); + return applyStandardTemplateWithActions(getBigBaseLayoutResource()); } private RemoteViews generateActionButton(Action action) { final boolean tombstone = (action.actionIntent == null); RemoteViews button = new RemoteViews(mContext.getPackageName(), - tombstone ? R.layout.notification_action_tombstone - : R.layout.notification_action); + tombstone ? getActionTombstoneLayoutResource() + : getActionLayoutResource()); button.setTextViewCompoundDrawablesRelative(R.id.action0, action.icon, 0, 0, 0); button.setTextViewText(R.id.action0, action.title); if (!tombstone) { @@ -1992,7 +2003,7 @@ public class Notification implements Parcelable n.defaults = mDefaults; n.flags = mFlags; n.bigContentView = makeBigContentView(); - n.headsUpContentView = makeHEadsUpContentView(); + n.headsUpContentView = makeHeadsUpContentView(); if (mLedOnMs != 0 || mLedOffMs != 0) { n.flags |= FLAG_SHOW_LIGHTS; } @@ -2037,6 +2048,7 @@ public class Notification implements Parcelable extras.putBoolean(EXTRA_PROGRESS_INDETERMINATE, mProgressIndeterminate); extras.putBoolean(EXTRA_SHOW_CHRONOMETER, mUseChronometer); extras.putBoolean(EXTRA_SHOW_WHEN, mShowWhen); + extras.putBoolean(EXTRA_BUILDER_REMOTE_VIEWS, mContentView == null); if (mLargeIcon != null) { extras.putParcelable(EXTRA_LARGE_ICON, mLargeIcon); } @@ -2080,6 +2092,49 @@ public class Notification implements Parcelable build().cloneInto(n, true); return n; } + + + private int getBaseLayoutResource() { + return mQuantumTheme + ? R.layout.notification_template_quantum_base + : R.layout.notification_template_base; + } + + private int getBigBaseLayoutResource() { + return mQuantumTheme + ? R.layout.notification_template_quantum_big_base + : R.layout.notification_template_big_base; + } + + private int getBigPictureLayoutResource() { + return mQuantumTheme + ? R.layout.notification_template_quantum_big_picture + : R.layout.notification_template_big_picture; + } + + private int getBigTextLayoutResource() { + return mQuantumTheme + ? R.layout.notification_template_quantum_big_text + : R.layout.notification_template_big_text; + } + + private int getInboxLayoutResource() { + return mQuantumTheme + ? R.layout.notification_template_quantum_inbox + : R.layout.notification_template_inbox; + } + + private int getActionLayoutResource() { + return mQuantumTheme + ? R.layout.notification_quantum_action + : R.layout.notification_action; + } + + private int getActionTombstoneLayoutResource() { + return mQuantumTheme + ? R.layout.notification_quantum_action_tombstone + : R.layout.notification_action_tombstone; + } } /** @@ -2249,7 +2304,7 @@ public class Notification implements Parcelable } private RemoteViews makeBigContentView() { - RemoteViews contentView = getStandardView(R.layout.notification_template_big_picture); + RemoteViews contentView = getStandardView(mBuilder.getBigPictureLayoutResource()); contentView.setImageViewBitmap(R.id.big_picture, mPicture); @@ -2348,7 +2403,7 @@ public class Notification implements Parcelable final boolean hadThreeLines = (mBuilder.mContentText != null && mBuilder.mSubText != null); mBuilder.mContentText = null; - RemoteViews contentView = getStandardView(R.layout.notification_template_big_text); + RemoteViews contentView = getStandardView(mBuilder.getBigTextLayoutResource()); if (hadThreeLines) { // vertical centering @@ -2442,7 +2497,7 @@ public class Notification implements Parcelable private RemoteViews makeBigContentView() { // Remove the content text so line3 disappears unless you have a summary mBuilder.mContentText = null; - RemoteViews contentView = getStandardView(R.layout.notification_template_inbox); + RemoteViews contentView = getStandardView(mBuilder.getInboxLayoutResource()); contentView.setViewVisibility(R.id.text2, View.GONE); diff --git a/core/java/android/content/res/ColorStateList.java b/core/java/android/content/res/ColorStateList.java index 2893522d17c58..419abf212379b 100644 --- a/core/java/android/content/res/ColorStateList.java +++ b/core/java/android/content/res/ColorStateList.java @@ -315,6 +315,24 @@ public class ColorStateList implements Parcelable { return mDefaultColor; } + /** + * Return the states in this {@link ColorStateList}. + * @return the states in this {@link ColorStateList} + * @hide + */ + public int[][] getStates() { + return mStateSpecs; + } + + /** + * Return the colors in this {@link ColorStateList}. + * @return the colors in this {@link ColorStateList} + * @hide + */ + public int[] getColors() { + return mColors; + } + @Override public String toString() { return "ColorStateList{" + diff --git a/core/res/res/drawable/notification_quantum_background.xml b/core/res/res/drawable/notification_quantum_background.xml new file mode 100644 index 0000000000000..f33e2e36621c7 --- /dev/null +++ b/core/res/res/drawable/notification_quantum_background.xml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file diff --git a/core/res/res/drawable/notification_quantum_bg.xml b/core/res/res/drawable/notification_quantum_bg.xml new file mode 100644 index 0000000000000..608115e631e9a --- /dev/null +++ b/core/res/res/drawable/notification_quantum_bg.xml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file diff --git a/core/res/res/drawable/notification_quantum_press.xml b/core/res/res/drawable/notification_quantum_press.xml new file mode 100644 index 0000000000000..4999f55cc0f62 --- /dev/null +++ b/core/res/res/drawable/notification_quantum_press.xml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file diff --git a/core/res/res/layout/notification_quantum_action.xml b/core/res/res/layout/notification_quantum_action.xml new file mode 100644 index 0000000000000..775182f4a699f --- /dev/null +++ b/core/res/res/layout/notification_quantum_action.xml @@ -0,0 +1,31 @@ + + + +