Merge "Show minimized header text with the correct text weight" into sc-dev

This commit is contained in:
Jeff DeCew
2021-05-12 17:57:57 +00:00
committed by Android (Google) Code Review
2 changed files with 26 additions and 1 deletions

View File

@@ -6048,11 +6048,13 @@ public class Notification implements Parcelable
.viewType(StandardTemplateParams.VIEW_TYPE_MINIMIZED)
.highlightExpander(false)
.fillTextsFrom(this);
if (!useRegularSubtext || TextUtils.isEmpty(mParams.summaryText)) {
if (!useRegularSubtext || TextUtils.isEmpty(p.summaryText)) {
p.summaryText(createSummaryText());
}
RemoteViews header = makeNotificationHeader(p);
header.setBoolean(R.id.notification_header, "setAcceptAllTouches", true);
// The low priority header has no app name and shows the text
header.setBoolean(R.id.notification_header, "styleTextAsTitle", true);
return header;
}

View File

@@ -29,6 +29,7 @@ import android.os.Build;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import android.widget.RemoteViews;
import android.widget.TextView;
import com.android.internal.R;
import com.android.internal.widget.CachingIconView;
@@ -174,6 +175,28 @@ public class NotificationHeaderView extends RelativeLayout {
(int) (extraMarginEndDp * getResources().getDisplayMetrics().density));
}
/**
* This is used to make the low-priority header show the bolded text of a title.
*
* @param styleTextAsTitle true if this header's text is to have the style of a title
*/
@RemotableViewMethod
public void styleTextAsTitle(boolean styleTextAsTitle) {
int styleResId = styleTextAsTitle
? R.style.TextAppearance_DeviceDefault_Notification_Title
: R.style.TextAppearance_DeviceDefault_Notification_Info;
// Most of the time, we're showing text in the minimized state
View headerText = findViewById(R.id.header_text);
if (headerText instanceof TextView) {
((TextView) headerText).setTextAppearance(styleResId);
}
// If there's no summary or text, we show the app name instead of nothing
View appNameText = findViewById(R.id.app_name_text);
if (appNameText instanceof TextView) {
((TextView) appNameText).setTextAppearance(styleResId);
}
}
/**
* Get the current margin end value for the header text.
* Add this to {@link #getTopLineBaseMarginEnd()} to get the total margin of the top line.