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

Commit 73e65d42 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Remove setExpanded from the NotificationHeaderView

Test: atest SystemUITests
Change-Id: I296e9d530d2c0ba581828dee0dc2026df0e38c3c
parent df6efd50
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4825,7 +4825,7 @@ public class Notification implements Parcelable
        private void resetNotificationHeader(RemoteViews contentView) {
            // Small icon doesn't need to be reset, as it's always set. Resetting would prevent
            // re-using the drawable when the notification is updated.
            contentView.setBoolean(R.id.notification_header, "setExpanded", false);
            contentView.setBoolean(R.id.expand_button, "setExpanded", false);
            contentView.setTextViewText(R.id.app_name_text, null);
            contentView.setViewVisibility(R.id.chronometer, View.GONE);
            contentView.setViewVisibility(R.id.header_text, View.GONE);
@@ -5569,7 +5569,7 @@ public class Notification implements Parcelable
         */
        public static void makeHeaderExpanded(RemoteViews result) {
            if (result != null) {
                result.setBoolean(R.id.notification_header, "setExpanded", true);
                result.setBoolean(R.id.expand_button, "setExpanded", true);
            }
        }

+0 −22
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ public class NotificationHeaderView extends ViewGroup {
    private CachingIconView mIcon;
    private View mProfileBadge;
    private View mFeedbackIcon;
    private boolean mExpanded;
    private boolean mShowExpandButtonAtEnd;
    private boolean mShowWorkBadgeAtEnd;
    private int mHeaderTextMarginEnd;
@@ -303,27 +302,6 @@ public class NotificationHeaderView extends ViewGroup {
        return mExpandButton.getOriginalNotificationColor();
    }

    @RemotableViewMethod
    public void setExpanded(boolean expanded) {
        mExpanded = expanded;
        updateExpandButton();
    }

    private void updateExpandButton() {
        int drawableId;
        int contentDescriptionId;
        if (mExpanded) {
            drawableId = R.drawable.ic_collapse_notification;
            contentDescriptionId = R.string.expand_button_content_description_expanded;
        } else {
            drawableId = R.drawable.ic_expand_notification;
            contentDescriptionId = R.string.expand_button_content_description_collapsed;
        }
        mExpandButton.setImageDrawable(getContext().getDrawable(drawableId));
        mExpandButton.setColorFilter(getOriginalNotificationColor());
        mExpandButton.setContentDescription(mContext.getText(contentDescriptionId));
    }

    public void setShowWorkBadgeAtEnd(boolean showWorkBadgeAtEnd) {
        if (showWorkBadgeAtEnd != mShowWorkBadgeAtEnd) {
            setClipToPadding(!showWorkBadgeAtEnd);
+27 −0
Original line number Diff line number Diff line
@@ -26,12 +26,15 @@ import android.widget.Button;
import android.widget.ImageView;
import android.widget.RemoteViews;

import com.android.internal.R;

/**
 * An expand button in a notification
 */
@RemoteViews.RemoteView
public class NotificationExpandButton extends ImageView {

    private boolean mExpanded;
    private int mOriginalNotificationColor;

    public NotificationExpandButton(Context context) {
@@ -80,4 +83,28 @@ public class NotificationExpandButton extends ImageView {
        super.onInitializeAccessibilityNodeInfo(info);
        info.setClassName(Button.class.getName());
    }

    /**
     * Update the button's drawable, content description, and color for the given expanded state.
     */
    @RemotableViewMethod
    public void setExpanded(boolean expanded) {
        mExpanded = expanded;
        updateExpandButton();
    }

    private void updateExpandButton() {
        int drawableId;
        int contentDescriptionId;
        if (mExpanded) {
            drawableId = R.drawable.ic_collapse_notification;
            contentDescriptionId = R.string.expand_button_content_description_expanded;
        } else {
            drawableId = R.drawable.ic_expand_notification;
            contentDescriptionId = R.string.expand_button_content_description_collapsed;
        }
        setImageDrawable(getContext().getDrawable(drawableId));
        setColorFilter(mOriginalNotificationColor);
        setContentDescription(mContext.getText(contentDescriptionId));
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -275,6 +275,11 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper {
        }
    }

    @Override
    public void setExpanded(boolean expanded) {
        mExpandButton.setExpanded(expanded);
    }

    @Override
    public void setRecentlyAudiblyAlerted(boolean audiblyAlerted) {
        if (mAudiblyAlertedIcon != null) {
+3 −0
Original line number Diff line number Diff line
@@ -229,6 +229,9 @@ public abstract class NotificationViewWrapper implements TransformableView {
     */
    public void updateExpandability(boolean expandable, View.OnClickListener onClickListener) {}

    /** Set the expanded state on the view wrapper */
    public void setExpanded(boolean expanded) {}

    /**
     * @return the notification header if it exists
     */
Loading