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

Commit 82404bc0 authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge "Deprecated the contentinfo and the number" into nyc-dev

parents f5582005 0f9dd1e2
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -4979,7 +4979,7 @@ package android.app {
    field public int ledARGB;
    field public int ledARGB;
    field public int ledOffMS;
    field public int ledOffMS;
    field public int ledOnMS;
    field public int ledOnMS;
    field public int number;
    field public deprecated int number;
    field public int priority;
    field public int priority;
    field public android.app.Notification publicVersion;
    field public android.app.Notification publicVersion;
    field public android.net.Uri sound;
    field public android.net.Uri sound;
@@ -5072,7 +5072,7 @@ package android.app {
    method public android.app.Notification.Builder setChronometerCountsDown(boolean);
    method public android.app.Notification.Builder setChronometerCountsDown(boolean);
    method public android.app.Notification.Builder setColor(int);
    method public android.app.Notification.Builder setColor(int);
    method public deprecated android.app.Notification.Builder setContent(android.widget.RemoteViews);
    method public deprecated android.app.Notification.Builder setContent(android.widget.RemoteViews);
    method public android.app.Notification.Builder setContentInfo(java.lang.CharSequence);
    method public deprecated android.app.Notification.Builder setContentInfo(java.lang.CharSequence);
    method public android.app.Notification.Builder setContentIntent(android.app.PendingIntent);
    method public android.app.Notification.Builder setContentIntent(android.app.PendingIntent);
    method public android.app.Notification.Builder setContentText(java.lang.CharSequence);
    method public android.app.Notification.Builder setContentText(java.lang.CharSequence);
    method public android.app.Notification.Builder setContentTitle(java.lang.CharSequence);
    method public android.app.Notification.Builder setContentTitle(java.lang.CharSequence);
@@ -5089,7 +5089,7 @@ package android.app {
    method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
    method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
    method public android.app.Notification.Builder setLights(int, int, int);
    method public android.app.Notification.Builder setLights(int, int, int);
    method public android.app.Notification.Builder setLocalOnly(boolean);
    method public android.app.Notification.Builder setLocalOnly(boolean);
    method public android.app.Notification.Builder setNumber(int);
    method public deprecated android.app.Notification.Builder setNumber(int);
    method public android.app.Notification.Builder setOngoing(boolean);
    method public android.app.Notification.Builder setOngoing(boolean);
    method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
    method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
    method public android.app.Notification.Builder setPriority(int);
    method public android.app.Notification.Builder setPriority(int);
+3 −3
Original line number Original line Diff line number Diff line
@@ -5112,7 +5112,7 @@ package android.app {
    field public int ledARGB;
    field public int ledARGB;
    field public int ledOffMS;
    field public int ledOffMS;
    field public int ledOnMS;
    field public int ledOnMS;
    field public int number;
    field public deprecated int number;
    field public int priority;
    field public int priority;
    field public android.app.Notification publicVersion;
    field public android.app.Notification publicVersion;
    field public android.net.Uri sound;
    field public android.net.Uri sound;
@@ -5205,7 +5205,7 @@ package android.app {
    method public android.app.Notification.Builder setChronometerCountsDown(boolean);
    method public android.app.Notification.Builder setChronometerCountsDown(boolean);
    method public android.app.Notification.Builder setColor(int);
    method public android.app.Notification.Builder setColor(int);
    method public deprecated android.app.Notification.Builder setContent(android.widget.RemoteViews);
    method public deprecated android.app.Notification.Builder setContent(android.widget.RemoteViews);
    method public android.app.Notification.Builder setContentInfo(java.lang.CharSequence);
    method public deprecated android.app.Notification.Builder setContentInfo(java.lang.CharSequence);
    method public android.app.Notification.Builder setContentIntent(android.app.PendingIntent);
    method public android.app.Notification.Builder setContentIntent(android.app.PendingIntent);
    method public android.app.Notification.Builder setContentText(java.lang.CharSequence);
    method public android.app.Notification.Builder setContentText(java.lang.CharSequence);
    method public android.app.Notification.Builder setContentTitle(java.lang.CharSequence);
    method public android.app.Notification.Builder setContentTitle(java.lang.CharSequence);
@@ -5222,7 +5222,7 @@ package android.app {
    method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
    method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
    method public android.app.Notification.Builder setLights(int, int, int);
    method public android.app.Notification.Builder setLights(int, int, int);
    method public android.app.Notification.Builder setLocalOnly(boolean);
    method public android.app.Notification.Builder setLocalOnly(boolean);
    method public android.app.Notification.Builder setNumber(int);
    method public deprecated android.app.Notification.Builder setNumber(int);
    method public android.app.Notification.Builder setOngoing(boolean);
    method public android.app.Notification.Builder setOngoing(boolean);
    method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
    method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
    method public android.app.Notification.Builder setPriority(int);
    method public android.app.Notification.Builder setPriority(int);
+3 −3
Original line number Original line Diff line number Diff line
@@ -4979,7 +4979,7 @@ package android.app {
    field public int ledARGB;
    field public int ledARGB;
    field public int ledOffMS;
    field public int ledOffMS;
    field public int ledOnMS;
    field public int ledOnMS;
    field public int number;
    field public deprecated int number;
    field public int priority;
    field public int priority;
    field public android.app.Notification publicVersion;
    field public android.app.Notification publicVersion;
    field public android.net.Uri sound;
    field public android.net.Uri sound;
@@ -5072,7 +5072,7 @@ package android.app {
    method public android.app.Notification.Builder setChronometerCountsDown(boolean);
    method public android.app.Notification.Builder setChronometerCountsDown(boolean);
    method public android.app.Notification.Builder setColor(int);
    method public android.app.Notification.Builder setColor(int);
    method public deprecated android.app.Notification.Builder setContent(android.widget.RemoteViews);
    method public deprecated android.app.Notification.Builder setContent(android.widget.RemoteViews);
    method public android.app.Notification.Builder setContentInfo(java.lang.CharSequence);
    method public deprecated android.app.Notification.Builder setContentInfo(java.lang.CharSequence);
    method public android.app.Notification.Builder setContentIntent(android.app.PendingIntent);
    method public android.app.Notification.Builder setContentIntent(android.app.PendingIntent);
    method public android.app.Notification.Builder setContentText(java.lang.CharSequence);
    method public android.app.Notification.Builder setContentText(java.lang.CharSequence);
    method public android.app.Notification.Builder setContentTitle(java.lang.CharSequence);
    method public android.app.Notification.Builder setContentTitle(java.lang.CharSequence);
@@ -5089,7 +5089,7 @@ package android.app {
    method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
    method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
    method public android.app.Notification.Builder setLights(int, int, int);
    method public android.app.Notification.Builder setLights(int, int, int);
    method public android.app.Notification.Builder setLocalOnly(boolean);
    method public android.app.Notification.Builder setLocalOnly(boolean);
    method public android.app.Notification.Builder setNumber(int);
    method public deprecated android.app.Notification.Builder setNumber(int);
    method public android.app.Notification.Builder setOngoing(boolean);
    method public android.app.Notification.Builder setOngoing(boolean);
    method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
    method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
    method public android.app.Notification.Builder setPriority(int);
    method public android.app.Notification.Builder setPriority(int);
+40 −43
Original line number Original line Diff line number Diff line
@@ -206,6 +206,8 @@ public class Notification implements Parcelable
     * {@link Notification.Builder} has displayed the number in the expanded notification view.
     * {@link Notification.Builder} has displayed the number in the expanded notification view.
     *
     *
     * If the number is 0 or negative, it is never shown.
     * If the number is 0 or negative, it is never shown.
     *
     * @deprecated this number is not shown anymore
     */
     */
    public int number;
    public int number;


@@ -2304,9 +2306,22 @@ public class Notification implements Parcelable
        }
        }


        /**
        /**
         * Set the third line of text in the platform notification template.
         * This provides some additional information that is displayed in the notification. No
         * Don't use if you're also using {@link #setProgress(int, int, boolean)}; they occupy the
         * guarantees are given where exactly it is displayed.
         * same location in the standard template.
         *
         * <p>This information should only be provided if it provides an essential
         * benefit to the understanding of the notification. The more text you provide the
         * less readable it becomes. For example, an email client should only provide the account
         * name here if more than one email account has been added.</p>
         *
         * <p>As of {@link android.os.Build.VERSION_CODES#N} this information is displayed in the
         * notification header area.
         *
         * On Android versions before {@link android.os.Build.VERSION_CODES#N}
         * this will be shown in the third line of text in the platform notification template.
         * You should not be using {@link #setProgress(int, int, boolean)} at the
         * same time on those versions; they occupy the same place.
         * </p>
         */
         */
        public Builder setSubText(CharSequence text) {
        public Builder setSubText(CharSequence text) {
            mN.extras.putCharSequence(EXTRA_SUB_TEXT, safeCharSequence(text));
            mN.extras.putCharSequence(EXTRA_SUB_TEXT, safeCharSequence(text));
@@ -2345,6 +2360,8 @@ public class Notification implements Parcelable
         * Set the large number at the right-hand side of the notification.  This is
         * Set the large number at the right-hand side of the notification.  This is
         * equivalent to setContentInfo, although it might show the number in a different
         * equivalent to setContentInfo, although it might show the number in a different
         * font size for readability.
         * font size for readability.
         *
         * @deprecated this number is not shown anywhere anymore
         */
         */
        public Builder setNumber(int number) {
        public Builder setNumber(int number) {
            mN.number = number;
            mN.number = number;
@@ -2356,6 +2373,10 @@ public class Notification implements Parcelable
         *
         *
         * The platform template will draw this on the last line of the notification, at the far
         * The platform template will draw this on the last line of the notification, at the far
         * right (to the right of a smallIcon if it has been placed there).
         * right (to the right of a smallIcon if it has been placed there).
         *
         * @deprecated use {@link #setSubText(CharSequence)} instead to set a text in the header.
         * For legacy apps targeting a version below {@link android.os.Build.VERSION_CODES#N} this
         * field will still show up, but the subtext will take precedence.
         */
         */
        public Builder setContentInfo(CharSequence info) {
        public Builder setContentInfo(CharSequence info) {
            mN.extras.putCharSequence(EXTRA_INFO_TEXT, safeCharSequence(info));
            mN.extras.putCharSequence(EXTRA_INFO_TEXT, safeCharSequence(info));
@@ -3009,10 +3030,8 @@ public class Notification implements Parcelable
            contentView.setBoolean(R.id.notification_header, "setExpanded", false);
            contentView.setBoolean(R.id.notification_header, "setExpanded", false);
            contentView.setTextViewText(R.id.app_name_text, null);
            contentView.setTextViewText(R.id.app_name_text, null);
            contentView.setViewVisibility(R.id.chronometer, View.GONE);
            contentView.setViewVisibility(R.id.chronometer, View.GONE);
            contentView.setViewVisibility(R.id.header_sub_text, View.GONE);
            contentView.setViewVisibility(R.id.header_text, View.GONE);
            contentView.setViewVisibility(R.id.header_content_info, View.GONE);
            contentView.setViewVisibility(R.id.header_text_divider, View.GONE);
            contentView.setViewVisibility(R.id.sub_text_divider, View.GONE);
            contentView.setViewVisibility(R.id.content_info_divider, View.GONE);
            contentView.setViewVisibility(R.id.time_divider, View.GONE);
            contentView.setViewVisibility(R.id.time_divider, View.GONE);
            contentView.setImageViewIcon(R.id.profile_badge, null);
            contentView.setImageViewIcon(R.id.profile_badge, null);
            contentView.setViewVisibility(R.id.profile_badge, View.GONE);
            contentView.setViewVisibility(R.id.profile_badge, View.GONE);
@@ -3112,39 +3131,12 @@ public class Notification implements Parcelable
        private void bindNotificationHeader(RemoteViews contentView) {
        private void bindNotificationHeader(RemoteViews contentView) {
            bindSmallIcon(contentView);
            bindSmallIcon(contentView);
            bindHeaderAppName(contentView);
            bindHeaderAppName(contentView);
            bindHeaderSubText(contentView);
            bindHeaderText(contentView);
            bindContentInfo(contentView);
            bindHeaderChronometerAndTime(contentView);
            bindHeaderChronometerAndTime(contentView);
            bindExpandButton(contentView);
            bindExpandButton(contentView);
            bindProfileBadge(contentView);
            bindProfileBadge(contentView);
        }
        }


        private void bindContentInfo(RemoteViews contentView) {
            boolean visible = false;
            if (mN.extras.getCharSequence(EXTRA_INFO_TEXT) != null) {
                contentView.setTextViewText(R.id.header_content_info,
                        processLegacyText(mN.extras.getCharSequence(EXTRA_INFO_TEXT)));
                contentView.setViewVisibility(R.id.header_content_info, View.VISIBLE);
                visible = true;
            } else if (mN.number > 0) {
                final int tooBig = mContext.getResources().getInteger(
                        R.integer.status_bar_notification_info_maxnum);
                if (mN.number > tooBig) {
                    contentView.setTextViewText(R.id.header_content_info, processLegacyText(
                            mContext.getResources().getString(
                                    R.string.status_bar_notification_info_overflow)));
                } else {
                    contentView.setTextViewText(R.id.header_content_info,
                            processLegacyText(String.valueOf(mN.number)));
                }
                contentView.setViewVisibility(R.id.header_content_info, View.VISIBLE);
                visible = true;
            }
            if (visible) {
                contentView.setViewVisibility(R.id.content_info_divider, View.VISIBLE);
            }
        }

        private void bindExpandButton(RemoteViews contentView) {
        private void bindExpandButton(RemoteViews contentView) {
            contentView.setDrawableParameters(R.id.expand_button, false, -1, resolveContrastColor(),
            contentView.setDrawableParameters(R.id.expand_button, false, -1, resolveContrastColor(),
                    PorterDuff.Mode.SRC_ATOP, -1);
                    PorterDuff.Mode.SRC_ATOP, -1);
@@ -3169,17 +3161,22 @@ public class Notification implements Parcelable
            }
            }
        }
        }


        private void bindHeaderSubText(RemoteViews contentView) {
        private void bindHeaderText(RemoteViews contentView) {
            CharSequence subText = mN.extras.getCharSequence(EXTRA_SUB_TEXT);
            CharSequence headerText = mN.extras.getCharSequence(EXTRA_SUB_TEXT);
            if (subText == null && mStyle != null && mStyle.mSummaryTextSet
            if (headerText == null && mStyle != null && mStyle.mSummaryTextSet
                    && mStyle.hasSummaryInHeader()) {
                    && mStyle.hasSummaryInHeader()) {
                subText = mStyle.mSummaryText;
                headerText = mStyle.mSummaryText;
            }
            if (headerText == null
                    && mContext.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.N
                    && mN.extras.getCharSequence(EXTRA_INFO_TEXT) != null) {
                headerText = mN.extras.getCharSequence(EXTRA_INFO_TEXT);
            }
            }
            if (subText != null) {
            if (headerText != null) {
                // TODO: Remove the span entirely to only have the string with propper formating.
                // TODO: Remove the span entirely to only have the string with propper formating.
                contentView.setTextViewText(R.id.header_sub_text, processLegacyText(subText));
                contentView.setTextViewText(R.id.header_text, processLegacyText(headerText));
                contentView.setViewVisibility(R.id.header_sub_text, View.VISIBLE);
                contentView.setViewVisibility(R.id.header_text, View.VISIBLE);
                contentView.setViewVisibility(R.id.sub_text_divider, View.VISIBLE);
                contentView.setViewVisibility(R.id.header_text_divider, View.VISIBLE);
            }
            }
        }
        }


+8 −18
Original line number Original line Diff line number Diff line
@@ -22,7 +22,6 @@ import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.ImageView;
import android.widget.RemoteViews;
import android.widget.RemoteViews;
import android.widget.TextView;


import java.util.ArrayList;
import java.util.ArrayList;


@@ -37,7 +36,7 @@ public class NotificationHeaderView extends ViewGroup {
    private final int mChildMinWidth;
    private final int mChildMinWidth;
    private final int mContentEndMargin;
    private final int mContentEndMargin;
    private View mAppName;
    private View mAppName;
    private View mSubTextView;
    private View mHeaderText;
    private OnClickListener mExpandClickListener;
    private OnClickListener mExpandClickListener;
    private HeaderTouchListener mTouchListener = new HeaderTouchListener();
    private HeaderTouchListener mTouchListener = new HeaderTouchListener();
    private ImageView mExpandButton;
    private ImageView mExpandButton;
@@ -73,11 +72,10 @@ public class NotificationHeaderView extends ViewGroup {
    protected void onFinishInflate() {
    protected void onFinishInflate() {
        super.onFinishInflate();
        super.onFinishInflate();
        mAppName = findViewById(com.android.internal.R.id.app_name_text);
        mAppName = findViewById(com.android.internal.R.id.app_name_text);
        mSubTextView = findViewById(com.android.internal.R.id.header_sub_text);
        mHeaderText = findViewById(com.android.internal.R.id.header_text);
        mExpandButton = (ImageView) findViewById(com.android.internal.R.id.expand_button);
        mExpandButton = (ImageView) findViewById(com.android.internal.R.id.expand_button);
        mIcon = findViewById(com.android.internal.R.id.icon);
        mIcon = findViewById(com.android.internal.R.id.icon);
        mProfileBadge = findViewById(com.android.internal.R.id.profile_badge);
        mProfileBadge = findViewById(com.android.internal.R.id.profile_badge);
        mInfo = findViewById(com.android.internal.R.id.header_content_info);
    }
    }


    @Override
    @Override
@@ -105,15 +103,7 @@ public class NotificationHeaderView extends ViewGroup {
        }
        }
        if (totalWidth > givenWidth) {
        if (totalWidth > givenWidth) {
            int overFlow = totalWidth - givenWidth;
            int overFlow = totalWidth - givenWidth;
            // We are overflowing, lets shrink the info first
            // We are overflowing, lets shrink the app name first
            final int infoWidth = mInfo.getMeasuredWidth();
            if (mInfo.getVisibility() != GONE && infoWidth > mChildMinWidth) {
                int newSize = infoWidth - Math.min(infoWidth - mChildMinWidth, overFlow);
                int childWidthSpec = MeasureSpec.makeMeasureSpec(newSize, MeasureSpec.AT_MOST);
                mInfo.measure(childWidthSpec, wrapContentHeightSpec);
                overFlow -= infoWidth - newSize;
            }
            // still overflowing, lets shrink the app name now
            final int appWidth = mAppName.getMeasuredWidth();
            final int appWidth = mAppName.getMeasuredWidth();
            if (overFlow > 0 && mAppName.getVisibility() != GONE && appWidth > mChildMinWidth) {
            if (overFlow > 0 && mAppName.getVisibility() != GONE && appWidth > mChildMinWidth) {
                int newSize = appWidth - Math.min(appWidth - mChildMinWidth, overFlow);
                int newSize = appWidth - Math.min(appWidth - mChildMinWidth, overFlow);
@@ -121,13 +111,13 @@ public class NotificationHeaderView extends ViewGroup {
                mAppName.measure(childWidthSpec, wrapContentHeightSpec);
                mAppName.measure(childWidthSpec, wrapContentHeightSpec);
                overFlow -= appWidth - newSize;
                overFlow -= appWidth - newSize;
            }
            }
            // still overflowing, finaly we shrink the subtext
            // still overflowing, finaly we shrink the header text
            if (overFlow > 0 && mSubTextView.getVisibility() != GONE) {
            if (overFlow > 0 && mHeaderText.getVisibility() != GONE) {
                // we're still too big
                // we're still too big
                final int subTextWidth = mSubTextView.getMeasuredWidth();
                final int textWidth = mHeaderText.getMeasuredWidth();
                int newSize = Math.max(0, subTextWidth - overFlow);
                int newSize = Math.max(0, textWidth - overFlow);
                int childWidthSpec = MeasureSpec.makeMeasureSpec(newSize, MeasureSpec.AT_MOST);
                int childWidthSpec = MeasureSpec.makeMeasureSpec(newSize, MeasureSpec.AT_MOST);
                mSubTextView.measure(childWidthSpec, wrapContentHeightSpec);
                mHeaderText.measure(childWidthSpec, wrapContentHeightSpec);
            }
            }
        }
        }
        setMeasuredDimension(givenWidth, givenHeight);
        setMeasuredDimension(givenWidth, givenHeight);
Loading