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

Commit ea4bef73 authored by Selim Cinek's avatar Selim Cinek
Browse files

Removed duplicate content from group notification header

Previously the headers all had duplicate content, which is
now optimized to look visually more appealing.

Change-Id: I38ed8db1985fd8a9470888e1b7e1e6b0f2e23b19
parent d427047d
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.NotificationHeaderView;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.RemoteViews;
@@ -3134,6 +3135,8 @@ public class Notification implements Parcelable
        private void bindExpandButton(RemoteViews contentView) {
            contentView.setDrawableParameters(R.id.expand_button, false, -1, resolveColor(),
                    PorterDuff.Mode.SRC_ATOP, -1);
            contentView.setInt(R.id.notification_header, "setOriginalNotificationColor",
                    resolveColor());
        }

        private void bindHeaderChronometerAndTime(RemoteViews contentView) {
@@ -3352,10 +3355,14 @@ public class Notification implements Parcelable
         * Apply any necessariy colors to the small icon
         */
        private void processSmallIconColor(Icon smallIcon, RemoteViews contentView) {
            if (!isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon)) {
            boolean colorable = !isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon);
            if (colorable) {
                contentView.setDrawableParameters(R.id.icon, false, -1, resolveColor(),
                        PorterDuff.Mode.SRC_ATOP, -1);

            }
            contentView.setInt(R.id.notification_header, "setOriginalIconColor",
                    colorable ? resolveColor() : NotificationHeaderView.NO_COLOR);
        }

        /**
+21 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.view;

import android.annotation.Nullable;
import android.app.Notification;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
@@ -34,6 +33,7 @@ import java.util.ArrayList;
 */
@RemoteViews.RemoteView
public class NotificationHeaderView extends LinearLayout {
    public static final int NO_COLOR = -1;
    private final int mHeaderMinWidth;
    private View mAppName;
    private View mSubTextView;
@@ -42,6 +42,8 @@ public class NotificationHeaderView extends LinearLayout {
    private View mExpandButton;
    private View mIcon;
    private TextView mChildCount;
    private int mIconColor;
    private int mOriginalNotificationColor;

    public NotificationHeaderView(Context context) {
        this(context, null);
@@ -146,6 +148,24 @@ public class NotificationHeaderView extends LinearLayout {
        }
    }

    @RemotableViewMethod
    public void setOriginalIconColor(int color) {
        mIconColor = color;
    }

    public int getOriginalIconColor() {
        return mIconColor;
    }

    @RemotableViewMethod
    public void setOriginalNotificationColor(int color) {
        mOriginalNotificationColor = color;
    }

    public int getOriginalNotificationColor() {
        return mOriginalNotificationColor;
    }

    public class HeaderTouchListener implements View.OnTouchListener {

        private final ArrayList<Rect> mTouchRects = new ArrayList<>();
+32 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Objects;

/**
 * An umbrella container for several serializable graphics representations, including Bitmaps,
@@ -458,6 +459,37 @@ public final class Icon implements Parcelable {
        return null;
    }

    /**
     * Compares if this icon is constructed from the same resources as another icon.
     * Note that this is an inexpensive operation and doesn't do deep Bitmap equality comparisons.
     *
     * @param otherIcon the other icon
     * @return whether this icon is the same as the another one
     * @hide
     */
    public boolean sameAs(Icon otherIcon) {
        if (otherIcon == this) {
            return true;
        }
        if (mType != otherIcon.getType()) {
            return false;
        }
        switch (mType) {
            case TYPE_BITMAP:
                return getBitmap() == otherIcon.getBitmap();
            case TYPE_DATA:
                return getDataLength() == otherIcon.getDataLength()
                        && getDataOffset() == otherIcon.getDataOffset()
                        && getDataBytes() == otherIcon.getDataBytes();
            case TYPE_RESOURCE:
                return getResId() == otherIcon.getResId()
                        && Objects.equals(getResPackage(), otherIcon.getResPackage());
            case TYPE_URI:
                return Objects.equals(getUriString(), otherIcon.getUriString());
        }
        return false;
    }

    /**
     * Create an Icon pointing to a drawable resource.
     * @param context The context for the application whose resources should be used to resolve the
+17 −10
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    private boolean mIsSystemChildExpanded;
    private boolean mIsPinned;
    private FalsingManager mFalsingManager;
    private NotificationHeaderUtil mHeaderUtil = new NotificationHeaderUtil(this);

    private boolean mJustClicked;
    private boolean mIconAnimationRunning;
@@ -198,6 +199,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        if (mIconAnimationRunning) {
            setIconAnimationRunning(true);
        }
        if (mNotificationParent != null) {
            mNotificationParent.updateChildrenHeaderAppearance();
        }
        onChildrenCountChanged();
    }

@@ -246,6 +250,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        if (mChildrenContainer != null) {
            mChildrenContainer.removeNotification(row);
        }
        mHeaderUtil.restoreNotificationHeader(row);
        onChildrenCountChanged();
        row.setIsChildInGroup(false, null);
    }
@@ -414,17 +419,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        }
    }

    public CharSequence getSubText() {
        Notification notification = mStatusBarNotification.getNotification();
        CharSequence subText = notification.extras.getCharSequence(Notification.EXTRA_SUMMARY_TEXT);
        if (subText == null) {
            subText = notification.extras.getCharSequence(Notification.EXTRA_SUB_TEXT);
        }
        return subText;
    public NotificationHeaderView getNotificationHeader() {
        if (mNotificationHeader != null) {
            return mNotificationHeader;
        }

    public void setContentSubTextVisible(boolean visible) {
        mPrivateLayout.setSubTextVisible(visible);
        return mPrivateLayout.getNotificationHeader();
    }

    public void setOnExpandClickListener(OnExpandClickListener onExpandClickListener) {
@@ -720,6 +719,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
            }
        }
        mPrivateLayout.updateExpandButtons(isExpandable());
        updateChildrenHeaderAppearance();
        updateHeaderChildCount();
        updateChildrenVisibility(true);
    }
@@ -948,9 +948,16 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        } else {
            header.reapply(getContext(), mNotificationHeader);
        }
        updateChildrenHeaderAppearance();
        updateHeaderChildCount();
    }

    public void updateChildrenHeaderAppearance() {
        if (mIsSummaryWithChildren) {
            mHeaderUtil.updateChildrenHeaderAppearance();
        }
    }

    public boolean isMaxExpandHeightInitialized() {
        return mMaxExpandHeight != 0;
    }
+14 −12
Original line number Diff line number Diff line
@@ -509,18 +509,6 @@ public class NotificationContentView extends FrameLayout {
        }
    }

    public void setSubTextVisible(boolean visible) {
        if (mExpandedChild != null) {
            mExpandedWrapper.setSubTextVisible(visible);
        }
        if (mContractedChild != null) {
            mContractedWrapper.setSubTextVisible(visible);
        }
        if (mHeadsUpChild != null) {
            mHeadsUpWrapper.setSubTextVisible(visible);
        }
    }

    public void setGroupManager(NotificationGroupManager groupManager) {
        mGroupManager = groupManager;
    }
@@ -540,4 +528,18 @@ public class NotificationContentView extends FrameLayout {
            mHeadsUpWrapper.updateExpandability(expandable,  mExpandClickListener);
        }
    }

    public NotificationHeaderView getNotificationHeader() {
        NotificationHeaderView header = null;
        if (mContractedChild != null) {
            header = mContractedWrapper.getNotificationHeader();
        }
        if (header == null && mExpandedChild != null) {
            header = mExpandedWrapper.getNotificationHeader();
        }
        if (header == null && mHeadsUpChild != null) {
            header = mHeadsUpWrapper.getNotificationHeader();
        }
        return header;
    }
}
Loading