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

Commit 9e307565 authored by Jeff DeCew's avatar Jeff DeCew Committed by Android (Google) Code Review
Browse files

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

parents 06aa2b56 9c1f4e12
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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;
        }

+23 −0
Original line number Diff line number Diff line
@@ -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.