Loading core/java/android/view/NotificationHeaderView.java +55 −0 Original line number Diff line number Diff line Loading @@ -18,7 +18,11 @@ package android.view; import android.annotation.Nullable; import android.content.Context; import android.graphics.Canvas; import android.graphics.Outline; import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.widget.ImageView; import android.widget.RemoteViews; Loading Loading @@ -47,6 +51,18 @@ public class NotificationHeaderView extends ViewGroup { private int mOriginalNotificationColor; private boolean mExpanded; private boolean mShowWorkBadgeAtEnd; private Drawable mBackground; private int mHeaderBackgroundHeight; ViewOutlineProvider mProvider = new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (mBackground != null) { outline.setRect(0, 0, getWidth(), mHeaderBackgroundHeight); outline.setAlpha(1f); } } }; public NotificationHeaderView(Context context) { this(context, null); Loading @@ -66,6 +82,8 @@ public class NotificationHeaderView extends ViewGroup { com.android.internal.R.dimen.notification_header_shrink_min_width); mContentEndMargin = getResources().getDimensionPixelSize( com.android.internal.R.dimen.notification_content_margin_end); mHeaderBackgroundHeight = getResources().getDimensionPixelSize( com.android.internal.R.dimen.notification_header_background_height); } @Override Loading Loading @@ -165,6 +183,43 @@ public class NotificationHeaderView extends ViewGroup { return new ViewGroup.MarginLayoutParams(getContext(), attrs); } /** * Set a {@link Drawable} to be displayed as a background on the header. */ public void setHeaderBackgroundDrawable(Drawable drawable) { if (drawable != null) { setWillNotDraw(false); mBackground = drawable; mBackground.setCallback(this); setOutlineProvider(mProvider); } else { setWillNotDraw(true); mBackground = null; setOutlineProvider(null); } invalidate(); } @Override protected void onDraw(Canvas canvas) { if (mBackground != null) { mBackground.setBounds(0, 0, getWidth(), mHeaderBackgroundHeight); mBackground.draw(canvas); } } @Override protected boolean verifyDrawable(Drawable who) { return super.verifyDrawable(who) || who == mBackground; } @Override protected void drawableStateChanged() { if (mBackground != null && mBackground.isStateful()) { mBackground.setState(getDrawableState()); } } private void updateTouchListener() { if (mExpandClickListener != null) { mTouchListener.bindTouchRects(); Loading core/res/res/values/dimens.xml +3 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,9 @@ <!-- height of the content margin on the bottom --> <dimen name="notification_content_margin_bottom">16dp</dimen> <!-- The height of the background for a notification header on a group --> <dimen name="notification_header_background_height">45.5dp</dimen> <!-- Height of a small notification in the status bar --> <dimen name="notification_min_height">92dp</dimen> Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2436,6 +2436,7 @@ <java-symbol type="dimen" name="notification_content_picture_margin" /> <java-symbol type="dimen" name="notification_content_margin_top" /> <java-symbol type="dimen" name="notification_content_margin_bottom" /> <java-symbol type="dimen" name="notification_header_background_height" /> <java-symbol type="string" name="importance_from_user" /> <java-symbol type="string" name="importance_from_person" /> Loading packages/SystemUI/res/layout/notification_children_divider.xml +1 −1 Original line number Diff line number Diff line Loading @@ -20,4 +20,4 @@ android:id="@+id/notification_more_divider" android:layout_width="match_parent" android:layout_height="@dimen/notification_divider_height" android:background="#61000000" /> android:background="#FF616161" /> packages/SystemUI/res/values/dimens.xml +3 −0 Original line number Diff line number Diff line Loading @@ -248,6 +248,9 @@ <!-- The height of the divider between the individual notifications. --> <dimen name="notification_divider_height">0.5dp</dimen> <!-- The height of a notification header --> <dimen name="notification_header_height">53dp</dimen> <!-- The height of the divider between the individual notifications when the notification wants it to be increased. This is currently the case for notification groups --> <dimen name="notification_divider_height_increased">6dp</dimen> Loading Loading
core/java/android/view/NotificationHeaderView.java +55 −0 Original line number Diff line number Diff line Loading @@ -18,7 +18,11 @@ package android.view; import android.annotation.Nullable; import android.content.Context; import android.graphics.Canvas; import android.graphics.Outline; import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.widget.ImageView; import android.widget.RemoteViews; Loading Loading @@ -47,6 +51,18 @@ public class NotificationHeaderView extends ViewGroup { private int mOriginalNotificationColor; private boolean mExpanded; private boolean mShowWorkBadgeAtEnd; private Drawable mBackground; private int mHeaderBackgroundHeight; ViewOutlineProvider mProvider = new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (mBackground != null) { outline.setRect(0, 0, getWidth(), mHeaderBackgroundHeight); outline.setAlpha(1f); } } }; public NotificationHeaderView(Context context) { this(context, null); Loading @@ -66,6 +82,8 @@ public class NotificationHeaderView extends ViewGroup { com.android.internal.R.dimen.notification_header_shrink_min_width); mContentEndMargin = getResources().getDimensionPixelSize( com.android.internal.R.dimen.notification_content_margin_end); mHeaderBackgroundHeight = getResources().getDimensionPixelSize( com.android.internal.R.dimen.notification_header_background_height); } @Override Loading Loading @@ -165,6 +183,43 @@ public class NotificationHeaderView extends ViewGroup { return new ViewGroup.MarginLayoutParams(getContext(), attrs); } /** * Set a {@link Drawable} to be displayed as a background on the header. */ public void setHeaderBackgroundDrawable(Drawable drawable) { if (drawable != null) { setWillNotDraw(false); mBackground = drawable; mBackground.setCallback(this); setOutlineProvider(mProvider); } else { setWillNotDraw(true); mBackground = null; setOutlineProvider(null); } invalidate(); } @Override protected void onDraw(Canvas canvas) { if (mBackground != null) { mBackground.setBounds(0, 0, getWidth(), mHeaderBackgroundHeight); mBackground.draw(canvas); } } @Override protected boolean verifyDrawable(Drawable who) { return super.verifyDrawable(who) || who == mBackground; } @Override protected void drawableStateChanged() { if (mBackground != null && mBackground.isStateful()) { mBackground.setState(getDrawableState()); } } private void updateTouchListener() { if (mExpandClickListener != null) { mTouchListener.bindTouchRects(); Loading
core/res/res/values/dimens.xml +3 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,9 @@ <!-- height of the content margin on the bottom --> <dimen name="notification_content_margin_bottom">16dp</dimen> <!-- The height of the background for a notification header on a group --> <dimen name="notification_header_background_height">45.5dp</dimen> <!-- Height of a small notification in the status bar --> <dimen name="notification_min_height">92dp</dimen> Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2436,6 +2436,7 @@ <java-symbol type="dimen" name="notification_content_picture_margin" /> <java-symbol type="dimen" name="notification_content_margin_top" /> <java-symbol type="dimen" name="notification_content_margin_bottom" /> <java-symbol type="dimen" name="notification_header_background_height" /> <java-symbol type="string" name="importance_from_user" /> <java-symbol type="string" name="importance_from_person" /> Loading
packages/SystemUI/res/layout/notification_children_divider.xml +1 −1 Original line number Diff line number Diff line Loading @@ -20,4 +20,4 @@ android:id="@+id/notification_more_divider" android:layout_width="match_parent" android:layout_height="@dimen/notification_divider_height" android:background="#61000000" /> android:background="#FF616161" />
packages/SystemUI/res/values/dimens.xml +3 −0 Original line number Diff line number Diff line Loading @@ -248,6 +248,9 @@ <!-- The height of the divider between the individual notifications. --> <dimen name="notification_divider_height">0.5dp</dimen> <!-- The height of a notification header --> <dimen name="notification_header_height">53dp</dimen> <!-- The height of the divider between the individual notifications when the notification wants it to be increased. This is currently the case for notification groups --> <dimen name="notification_divider_height_increased">6dp</dimen> Loading