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

Commit ac51be5b authored by Selim Cinek's avatar Selim Cinek Committed by android-build-merger
Browse files

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

am: 82404bc0

* commit '82404bc0':
  Deprecated the contentinfo and the number

Change-Id: I4ab5ddb1fa42221377d5603e89dfea84425344fe
parents 9a734801 82404bc0
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -4979,7 +4979,7 @@ package android.app {
    field public int ledARGB;
    field public int ledOffMS;
    field public int ledOnMS;
    field public int number;
    field public deprecated int number;
    field public int priority;
    field public android.app.Notification publicVersion;
    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 setColor(int);
    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 setContentText(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 setLights(int, int, int);
    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 setOnlyAlertOnce(boolean);
    method public android.app.Notification.Builder setPriority(int);
+3 −3
Original line number Diff line number Diff line
@@ -5112,7 +5112,7 @@ package android.app {
    field public int ledARGB;
    field public int ledOffMS;
    field public int ledOnMS;
    field public int number;
    field public deprecated int number;
    field public int priority;
    field public android.app.Notification publicVersion;
    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 setColor(int);
    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 setContentText(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 setLights(int, int, int);
    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 setOnlyAlertOnce(boolean);
    method public android.app.Notification.Builder setPriority(int);
+3 −3
Original line number Diff line number Diff line
@@ -4979,7 +4979,7 @@ package android.app {
    field public int ledARGB;
    field public int ledOffMS;
    field public int ledOnMS;
    field public int number;
    field public deprecated int number;
    field public int priority;
    field public android.app.Notification publicVersion;
    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 setColor(int);
    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 setContentText(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 setLights(int, int, int);
    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 setOnlyAlertOnce(boolean);
    method public android.app.Notification.Builder setPriority(int);
+40 −43
Original line number 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.
     *
     * If the number is 0 or negative, it is never shown.
     *
     * @deprecated this number is not shown anymore
     */
    public int number;

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

        /**
         * Set the third line of text in the platform notification template.
         * Don't use if you're also using {@link #setProgress(int, int, boolean)}; they occupy the
         * same location in the standard template.
         * This provides some additional information that is displayed in the notification. No
         * guarantees are given where exactly it is displayed.
         *
         * <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) {
            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
         * equivalent to setContentInfo, although it might show the number in a different
         * font size for readability.
         *
         * @deprecated this number is not shown anywhere anymore
         */
        public Builder setNumber(int 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
         * 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) {
            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.setTextViewText(R.id.app_name_text, null);
            contentView.setViewVisibility(R.id.chronometer, View.GONE);
            contentView.setViewVisibility(R.id.header_sub_text, View.GONE);
            contentView.setViewVisibility(R.id.header_content_info, View.GONE);
            contentView.setViewVisibility(R.id.sub_text_divider, View.GONE);
            contentView.setViewVisibility(R.id.content_info_divider, View.GONE);
            contentView.setViewVisibility(R.id.header_text, View.GONE);
            contentView.setViewVisibility(R.id.header_text_divider, View.GONE);
            contentView.setViewVisibility(R.id.time_divider, View.GONE);
            contentView.setImageViewIcon(R.id.profile_badge, null);
            contentView.setViewVisibility(R.id.profile_badge, View.GONE);
@@ -3112,39 +3131,12 @@ public class Notification implements Parcelable
        private void bindNotificationHeader(RemoteViews contentView) {
            bindSmallIcon(contentView);
            bindHeaderAppName(contentView);
            bindHeaderSubText(contentView);
            bindContentInfo(contentView);
            bindHeaderText(contentView);
            bindHeaderChronometerAndTime(contentView);
            bindExpandButton(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) {
            contentView.setDrawableParameters(R.id.expand_button, false, -1, resolveContrastColor(),
                    PorterDuff.Mode.SRC_ATOP, -1);
@@ -3169,17 +3161,22 @@ public class Notification implements Parcelable
            }
        }

        private void bindHeaderSubText(RemoteViews contentView) {
            CharSequence subText = mN.extras.getCharSequence(EXTRA_SUB_TEXT);
            if (subText == null && mStyle != null && mStyle.mSummaryTextSet
        private void bindHeaderText(RemoteViews contentView) {
            CharSequence headerText = mN.extras.getCharSequence(EXTRA_SUB_TEXT);
            if (headerText == null && mStyle != null && mStyle.mSummaryTextSet
                    && 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.
                contentView.setTextViewText(R.id.header_sub_text, processLegacyText(subText));
                contentView.setViewVisibility(R.id.header_sub_text, View.VISIBLE);
                contentView.setViewVisibility(R.id.sub_text_divider, View.VISIBLE);
                contentView.setTextViewText(R.id.header_text, processLegacyText(headerText));
                contentView.setViewVisibility(R.id.header_text, View.VISIBLE);
                contentView.setViewVisibility(R.id.header_text_divider, View.VISIBLE);
            }
        }

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

import java.util.ArrayList;

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

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