diff --git a/core/res/res/drawable/notification_quantum_press.xml b/core/res/res/drawable/notification_bg_dim.xml similarity index 77% rename from core/res/res/drawable/notification_quantum_press.xml rename to core/res/res/drawable/notification_bg_dim.xml index 4999f55cc0f62..ec203684e17c5 100644 --- a/core/res/res/drawable/notification_quantum_press.xml +++ b/core/res/res/drawable/notification_bg_dim.xml @@ -15,7 +15,9 @@ ~ limitations under the License --> - - - - \ No newline at end of file + + + \ No newline at end of file diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index f285bced59559..ac708b81cd666 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1092,6 +1092,7 @@ + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index e51b914666aff..d48637d76a618 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -423,9 +423,9 @@ public abstract class BaseStatusBar extends SystemUI implements } - protected void applyLegacyRowBackground(StatusBarNotification sbn, View content) { - if (sbn.getNotification().contentView.getLayoutId() != - com.android.internal.R.layout.notification_template_base) { + protected void applyLegacyRowBackground(StatusBarNotification sbn, + NotificationData.Entry entry) { + if (entry.expanded.getId() != com.android.internal.R.id.status_bar_latest_event_content) { int version = 0; try { ApplicationInfo info = mContext.getPackageManager().getApplicationInfo(sbn.getPackageName(), 0); @@ -434,7 +434,11 @@ public abstract class BaseStatusBar extends SystemUI implements Log.e(TAG, "Failed looking up ApplicationInfo for " + sbn.getPackageName(), ex); } if (version > 0 && version < Build.VERSION_CODES.GINGERBREAD) { - content.setBackgroundResource(R.drawable.notification_row_legacy_bg); + entry.row.setBackgroundResource(R.drawable.notification_row_legacy_bg); + } else if (version < Build.VERSION_CODES.L) { + entry.row.setBackgroundResourceIds( + com.android.internal.R.drawable.notification_bg, + com.android.internal.R.drawable.notification_bg_dim); } } } @@ -869,8 +873,6 @@ public abstract class BaseStatusBar extends SystemUI implements row.setDrawingCacheEnabled(true); - applyLegacyRowBackground(sbn, content); - if (MULTIUSER_DEBUG) { TextView debug = (TextView) row.findViewById(R.id.debug_info); if (debug != null) { @@ -885,6 +887,8 @@ public abstract class BaseStatusBar extends SystemUI implements entry.expandedPublic = publicViewLocal; entry.setBigContentView(bigContentViewLocal); + applyLegacyRowBackground(sbn, entry); + return true; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java index 7bacc13a4c152..a9fda63d33462 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java @@ -219,4 +219,14 @@ public class ExpandableNotificationRow extends FrameLayout { public void setLocked(boolean locked) { mLatestItemView.setLocked(locked); } + + /** + * Sets the resource id for the background of this notification. + * + * @param bgResId The background resource to use in normal state. + * @param dimmedBgResId The background resource to use in dimmed state. + */ + public void setBackgroundResourceIds(int bgResId, int dimmedBgResId) { + mLatestItemView.setBackgroundResourceIds(bgResId, dimmedBgResId); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LatestItemView.java b/packages/SystemUI/src/com/android/systemui/statusbar/LatestItemView.java index ad9028dc860e7..74d837dc2e803 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/LatestItemView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/LatestItemView.java @@ -25,6 +25,8 @@ import android.view.ViewConfiguration; import android.view.accessibility.AccessibilityEvent; import android.widget.FrameLayout; +import com.android.internal.R; + public class LatestItemView extends FrameLayout { private static final long DOUBLETAP_TIMEOUT_MS = 1000; @@ -32,6 +34,9 @@ public class LatestItemView extends FrameLayout { private boolean mDimmed; private boolean mLocked; + private int mBgResId = R.drawable.notification_quantum_bg; + private int mDimmedBgResId = R.drawable.notification_quantum_bg_dim; + /** * Flag to indicate that the notification has been touched once and the second touch will * click it. @@ -148,11 +153,7 @@ public class LatestItemView extends FrameLayout { public void setDimmed(boolean dimmed) { if (mDimmed != dimmed) { mDimmed = dimmed; - if (dimmed) { - setBackgroundResource(com.android.internal.R.drawable.notification_quantum_bg_dim); - } else { - setBackgroundResource(com.android.internal.R.drawable.notification_quantum_bg); - } + updateBackgroundResource(); } } @@ -163,4 +164,20 @@ public class LatestItemView extends FrameLayout { public void setLocked(boolean locked) { mLocked = locked; } + + /** + * Sets the resource id for the background of this notification. + * + * @param bgResId The background resource to use in normal state. + * @param dimmedBgResId The background resource to use in dimmed state. + */ + public void setBackgroundResourceIds(int bgResId, int dimmedBgResId) { + mBgResId = bgResId; + mDimmedBgResId = dimmedBgResId; + updateBackgroundResource(); + } + + private void updateBackgroundResource() { + setBackgroundResource(mDimmed ? mDimmedBgResId : mBgResId); + } }