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

Commit b1f427c7 authored by Adrian Roos's avatar Adrian Roos
Browse files

Fix bad one-line MessagingStyle

The one-line non-group version of MessagingStyle causes
a bug with the action bar and generally looks bad because
it is too short. To fix, show this variant like a BigText
notification.

Change-Id: I8af9e9da8286599b81ccb7c4637471ac01795366
Fixes: 28767094
parent aba6e2c7
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -4319,18 +4319,23 @@ public class Notification implements Parcelable
                // experience
                bigTextText = mBuilder.processLegacyText(text);
            }
            applyBigTextContentView(mBuilder, contentView, bigTextText);

            return contentView;
        }

        static void applyBigTextContentView(Builder builder,
                RemoteViews contentView, CharSequence bigTextText) {
            contentView.setTextViewText(R.id.big_text, bigTextText);
            contentView.setViewVisibility(R.id.big_text,
                    TextUtils.isEmpty(bigTextText) ? View.GONE : View.VISIBLE);
            contentView.setInt(R.id.big_text, "setMaxLines", calculateMaxLines());
            contentView.setBoolean(R.id.big_text, "setHasImage", mBuilder.mN.mLargeIcon != null);

            return contentView;
            contentView.setInt(R.id.big_text, "setMaxLines", calculateMaxLines(builder));
            contentView.setBoolean(R.id.big_text, "setHasImage", builder.mN.mLargeIcon != null);
        }

        private int calculateMaxLines() {
        private static int calculateMaxLines(Builder builder) {
            int lineCount = MAX_LINES;
            boolean hasActions = mBuilder.mActions.size() > 0;
            boolean hasActions = builder.mActions.size() > 0;
            if (hasActions) {
                lineCount -= LINES_CONSUMED_BY_ACTIONS;
            }
@@ -4528,6 +4533,16 @@ public class Notification implements Parcelable
                    : mConversationTitle;
            boolean hasTitle = !TextUtils.isEmpty(title);

            if (!hasTitle && mMessages.size() == 1) {
                CharSequence sender = mMessages.get(0).mSender;
                CharSequence text = mMessages.get(0).mText;
                RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(
                        mBuilder.getBigTextLayoutResource(),
                        false /* progress */, sender, null /* text */);
                BigTextStyle.applyBigTextContentView(mBuilder, contentView, text);
                return contentView;
            }

            RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(
                    mBuilder.getMessagingLayoutResource(),
                    false /* hasProgress */,