Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 470c0013 authored by Mady Mellor's avatar Mady Mellor Committed by android-build-merger
Browse files

Merge "Children should have backgrounds" into nyc-dev

am: 31e49b09

* commit '31e49b09':
  Children should have backgrounds

Change-Id: I4c123a7cf9efd38c46ff155a70f5b9c053e4df02
parents 8b1dce71 31e49b09
Loading
Loading
Loading
Loading
+55 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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);
@@ -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
@@ -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();
+3 −0
Original line number Diff line number Diff line
@@ -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>

+1 −0
Original line number Diff line number Diff line
@@ -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" />

+1 −1
Original line number Diff line number Diff line
@@ -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" />
+3 −0
Original line number Diff line number Diff line
@@ -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