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

Commit 0c8cc6f0 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Never show the large icon in MessagingStyle

Also documented this behavior, and improved the consistency of the
Style javadocs a little bit.

Fix: 403535357
Test: manually verified the large icon is not shown, but is still being
used as a fallback when there's no shortcut icon
Flag: EXEMPT BUGFIX

Change-Id: Ib6f3c435a3ea257724160e52f0beca1f90897dce
parent 5ead43ff
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -9280,21 +9280,23 @@ public class Notification implements Parcelable
     * This class is a "rebuilder": It attaches to a Builder object and modifies its behavior.
     * Here's an example of how this may be used:
     * <pre class="prettyprint">
     *
     * Person user = new Person.Builder().setIcon(userIcon).setName(userName).build();
     * MessagingStyle style = new MessagingStyle(user)
     *      .addMessage(messages[1].getText(), messages[1].getTime(), messages[1].getPerson())
     *      .addMessage(messages[2].getText(), messages[2].getTime(), messages[2].getPerson())
     *      .setGroupConversation(hasMultiplePeople());
     *
     * Notification noti = new Notification.Builder()
     * Notification notif = new Notification.Builder()
     *     .setContentTitle(&quot;2 new messages with &quot; + sender.toString())
     *     .setContentText(subject)
     *     .setSmallIcon(R.drawable.new_message)
     *     .setLargeIcon(aBitmap)
     *     .setStyle(style)
     *     .build();
     * </pre>
     *
     * Note that this style doesn't display the large icon set via
     * {@link Builder#setLargeIcon(Icon)}, except as a fallback group icon if the shortcut doesn't
     * include one. It can, however, display images set via {@link MessagingStyle.Message#setData}.
     */
    public static class MessagingStyle extends Style {
@@ -9895,7 +9897,6 @@ public class Notification implements Parcelable
        @NonNull
        private RemoteViews makeMessagingView(int viewType) {
            boolean isCollapsed = viewType != StandardTemplateParams.VIEW_TYPE_EXPANDED;
            boolean hideRightIcons = viewType != StandardTemplateParams.VIEW_TYPE_NORMAL;
            boolean isConversationLayout = mConversationType != CONVERSATION_TYPE_LEGACY;
            boolean isImportantConversation = mConversationType == CONVERSATION_TYPE_IMPORTANT;
            boolean isLegacyHeaderless = !isConversationLayout && isCollapsed;
@@ -9930,8 +9931,8 @@ public class Notification implements Parcelable
                    .viewType(viewType)
                    .highlightExpander(isConversationLayout)
                    .hideProgress(true)
                    .hideLeftIcon(isOneToOne)
                    .hideRightIcon(hideRightIcons || isOneToOne);
                    .hideLeftIcon(true)
                    .hideRightIcon(true);
            if (notificationsRedesignTemplates()) {
                String lastMessage = !mMessages.isEmpty()
                        ? mMessages.getLast().mText.toString() : null;
@@ -11071,6 +11072,9 @@ public class Notification implements Parcelable
     *     .setStyle(Notification.CallStyle.forIncomingCall(caller, declineIntent, answerIntent))
     *     .build();
     * </pre>
     *
     * <p>Note that this style doesn't display the large icon set via
     * {@link Builder#setLargeIcon(Icon)}.
     */
    public static class CallStyle extends Style {
        /**
@@ -11639,7 +11643,7 @@ public class Notification implements Parcelable
     * <p>To use this style with your Notification, feed it to
     * {@link Notification.Builder#setStyle(android.app.Notification.Style)} like so:
     * <pre class="prettyprint">
     * new Notification.Builder(context)
     * Notification notif = new Notification.Builder(context)
     *   .setStyle(new MetricStyle()
     *       .addMetric(new Metric(new Metric.FixedInt(1979), "Steps"))
     *       .addMetric(new Metric(
@@ -11649,6 +11653,9 @@ public class Notification implements Parcelable
     *
     * <p>A MetricStyle must contain at least one {@link Metric} object to be valid; an invalid
     * style will be rejected when {@link Builder#build()} is called.
     *
     * <p>Note that this style doesn't display the large icon set via
     * {@link Builder#setLargeIcon(Icon)}.
     */
    @FlaggedApi(Flags.FLAG_API_METRIC_STYLE)
    public static final class MetricStyle extends Style {
@@ -13918,7 +13925,7 @@ public class Notification implements Parcelable
     * <p>To use this style with your Notification, feed it to
     * {@link Notification.Builder#setStyle(android.app.Notification.Style)} like so:
     * <pre class="prettyprint">
     * Notification noti = new Notification.Builder()
     * Notification notif = new Notification.Builder()
     *     .setSmallIcon(R.drawable.ic_stat_player)
     *     .setLargeIcon(albumArtBitmap))
     *     .setCustomContentView(contentView);