From 5a8f7baeeb62ca44114c74987e531c3efef09cd4 Mon Sep 17 00:00:00 2001 From: Ioana Alexandru Date: Wed, 15 Feb 2023 17:25:31 +0000 Subject: Rename summaryText where it's not actually related. summaryText is a property of BigTextStyle notifications, so it's a bit confusing to reuse the same name for things that are... not that. Also had to add an m at the beginning of this and related properties since checkStyle was complaining, and it's now consistent with other properties. Test: presubmit Bug: 269474373 Change-Id: I75d5463fd67afddb4e8f0acc9c12e0a2c8819013 (cherry picked from commit 2311260ab38b098af9746c85930f02ed5599cba2) --- core/java/android/app/Notification.java | 68 ++++++++++++++++----------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index cc9e0ecd9d59..592ca500710a 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -5249,17 +5249,17 @@ public class Notification implements Parcelable boolean hasSecondLine = showProgress; if (p.hasTitle()) { contentView.setViewVisibility(p.mTitleViewId, View.VISIBLE); - contentView.setTextViewText(p.mTitleViewId, processTextSpans(p.title)); + contentView.setTextViewText(p.mTitleViewId, processTextSpans(p.mTitle)); setTextViewColorPrimary(contentView, p.mTitleViewId, p); } else if (p.mTitleViewId != R.id.title) { // This alternate title view ID is not cleared by resetStandardTemplate contentView.setViewVisibility(p.mTitleViewId, View.GONE); contentView.setTextViewText(p.mTitleViewId, null); } - if (p.text != null && p.text.length() != 0 + if (p.mText != null && p.mText.length() != 0 && (!showProgress || p.mAllowTextWithProgress)) { contentView.setViewVisibility(p.mTextViewId, View.VISIBLE); - contentView.setTextViewText(p.mTextViewId, processTextSpans(p.text)); + contentView.setTextViewText(p.mTextViewId, processTextSpans(p.mText)); setTextViewColorSecondary(contentView, p.mTextViewId, p); hasSecondLine = true; } else if (p.mTextViewId != R.id.text) { @@ -5533,20 +5533,20 @@ public class Notification implements Parcelable if (p.mHideSubText) { return false; } - CharSequence summaryText = p.summaryText; - if (summaryText == null && mStyle != null && mStyle.mSummaryTextSet + CharSequence headerText = p.mSubText; + if (headerText == null && mStyle != null && mStyle.mSummaryTextSet && mStyle.hasSummaryInHeader()) { - summaryText = mStyle.mSummaryText; + headerText = mStyle.mSummaryText; } - if (summaryText == null + if (headerText == null && mContext.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.N && mN.extras.getCharSequence(EXTRA_INFO_TEXT) != null) { - summaryText = mN.extras.getCharSequence(EXTRA_INFO_TEXT); + headerText = mN.extras.getCharSequence(EXTRA_INFO_TEXT); } - if (!TextUtils.isEmpty(summaryText)) { + if (!TextUtils.isEmpty(headerText)) { // TODO: Remove the span entirely to only have the string with propper formating. contentView.setTextViewText(R.id.header_text, processTextSpans( - processLegacyText(summaryText))); + processLegacyText(headerText))); setTextViewColorSecondary(contentView, R.id.header_text, p); contentView.setViewVisibility(R.id.header_text, View.VISIBLE); if (hasTextToLeft) { @@ -5566,9 +5566,9 @@ public class Notification implements Parcelable if (p.mHideSubText) { return false; } - if (!TextUtils.isEmpty(p.headerTextSecondary)) { + if (!TextUtils.isEmpty(p.mHeaderTextSecondary)) { contentView.setTextViewText(R.id.header_text_secondary, processTextSpans( - processLegacyText(p.headerTextSecondary))); + processLegacyText(p.mHeaderTextSecondary))); setTextViewColorSecondary(contentView, R.id.header_text_secondary, p); contentView.setViewVisibility(R.id.header_text_secondary, View.VISIBLE); if (hasTextToLeft) { @@ -6175,7 +6175,7 @@ public class Notification implements Parcelable .viewType(StandardTemplateParams.VIEW_TYPE_MINIMIZED) .highlightExpander(false) .fillTextsFrom(this); - if (!useRegularSubtext || TextUtils.isEmpty(p.summaryText)) { + if (!useRegularSubtext || TextUtils.isEmpty(p.mSubText)) { p.summaryText(createSummaryText()); } RemoteViews header = makeNotificationHeader(p); @@ -7192,7 +7192,7 @@ public class Notification implements Parcelable checkBuilder(); if (mBigContentTitle != null) { - p.title = mBigContentTitle; + p.mTitle = mBigContentTitle; } return mBuilder.applyStandardTemplateWithActions(layoutId, p, result); @@ -12455,10 +12455,10 @@ public class Notification implements Parcelable boolean mAllowTextWithProgress; int mTitleViewId; int mTextViewId; - CharSequence title; - CharSequence text; - CharSequence headerTextSecondary; - CharSequence summaryText; + @Nullable CharSequence mTitle; + @Nullable CharSequence mText; + @Nullable CharSequence mHeaderTextSecondary; + @Nullable CharSequence mSubText; int maxRemoteInputHistory = Style.MAX_REMOTE_INPUT_HISTORY_LINES; boolean allowColorization = true; boolean mHighlightExpander = false; @@ -12480,10 +12480,10 @@ public class Notification implements Parcelable mAllowTextWithProgress = false; mTitleViewId = R.id.title; mTextViewId = R.id.text; - title = null; - text = null; - summaryText = null; - headerTextSecondary = null; + mTitle = null; + mText = null; + mSubText = null; + mHeaderTextSecondary = null; maxRemoteInputHistory = Style.MAX_REMOTE_INPUT_HISTORY_LINES; allowColorization = true; mHighlightExpander = false; @@ -12491,7 +12491,7 @@ public class Notification implements Parcelable } final boolean hasTitle() { - return !TextUtils.isEmpty(title) && !mHideTitle; + return !TextUtils.isEmpty(mTitle) && !mHideTitle; } final StandardTemplateParams viewType(int viewType) { @@ -12564,23 +12564,23 @@ public class Notification implements Parcelable return this; } - final StandardTemplateParams title(CharSequence title) { - this.title = title; + final StandardTemplateParams title(@Nullable CharSequence title) { + this.mTitle = title; return this; } - final StandardTemplateParams text(CharSequence text) { - this.text = text; + final StandardTemplateParams text(@Nullable CharSequence text) { + this.mText = text; return this; } - final StandardTemplateParams summaryText(CharSequence text) { - this.summaryText = text; + final StandardTemplateParams summaryText(@Nullable CharSequence text) { + this.mSubText = text; return this; } - final StandardTemplateParams headerTextSecondary(CharSequence text) { - this.headerTextSecondary = text; + final StandardTemplateParams headerTextSecondary(@Nullable CharSequence text) { + this.mHeaderTextSecondary = text; return this; } @@ -12607,9 +12607,9 @@ public class Notification implements Parcelable final StandardTemplateParams fillTextsFrom(Builder b) { Bundle extras = b.mN.extras; - this.title = b.processLegacyText(extras.getCharSequence(EXTRA_TITLE)); - this.text = b.processLegacyText(extras.getCharSequence(EXTRA_TEXT)); - this.summaryText = extras.getCharSequence(EXTRA_SUB_TEXT); + this.mTitle = b.processLegacyText(extras.getCharSequence(EXTRA_TITLE)); + this.mText = b.processLegacyText(extras.getCharSequence(EXTRA_TEXT)); + this.mSubText = extras.getCharSequence(EXTRA_SUB_TEXT); return this; } -- cgit v1.2.3-59-g8ed1b