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

Commit 2dd3e72a authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed Messaging style with empty senders

Empty senders were treaded badly before, leading to empty
space and a bad layout. Now the conversation title is taken
as the name of the other sender.

Bug: 63708826
Test: add message with empty senders, observe layout
Change-Id: I6d3ce84c421ddbcd55260f34e8ff5bf46437c2b6
parent 90d11a16
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -6469,8 +6469,11 @@ public class Notification implements Parcelable
                    ? super.mBigContentTitle
                    : mConversationTitle;
            boolean isOneToOne = TextUtils.isEmpty(conversationTitle);
            CharSequence nameReplacement = null;
            if (hasOnlyWhiteSpaceSenders()) {
                isOneToOne = true;
                nameReplacement = conversationTitle;
                conversationTitle = null;
            }
            RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(
                    mBuilder.getMessagingLayoutResource(),
@@ -6489,6 +6492,8 @@ public class Notification implements Parcelable
                    mBuilder.resolveContrastColor());
            contentView.setIcon(R.id.status_bar_latest_event_content, "setLargeIcon",
                    mBuilder.mN.mLargeIcon);
            contentView.setCharSequence(R.id.status_bar_latest_event_content, "setNameReplacement",
                    nameReplacement);
            contentView.setBoolean(R.id.status_bar_latest_event_content, "setIsOneToOne",
                    isOneToOne);
            contentView.setBundle(R.id.status_bar_latest_event_content, "setData",
+5 −2
Original line number Diff line number Diff line
@@ -89,9 +89,12 @@ public class MessagingGroup extends LinearLayout implements MessagingLinearLayou
        mAvatarView = findViewById(R.id.message_icon);
    }

    public void setSender(Notification.Person sender) {
    public void setSender(Notification.Person sender, CharSequence nameOverride) {
        mSender = sender;
        mSenderName.setText(sender.getName());
        if (nameOverride == null) {
            nameOverride = sender.getName();
        }
        mSenderName.setText(nameOverride);
        mNeedsGeneratedAvatar = sender.getIcon() == null;
        if (!mNeedsGeneratedAvatar) {
            setAvatar(sender.getIcon());
+12 −1
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ public class MessagingLayout extends FrameLayout {
    private boolean mIsOneToOne;
    private ArrayList<MessagingGroup> mAddedGroups = new ArrayList<>();
    private Notification.Person mUser;
    private CharSequence mNameReplacement;

    public MessagingLayout(@NonNull Context context) {
        super(context);
@@ -120,6 +121,11 @@ public class MessagingLayout extends FrameLayout {
        mLargeIcon = icon;
    }

    @RemotableViewMethod
    public void setNameReplacement(CharSequence nameReplacement) {
        mNameReplacement = nameReplacement;
    }

    @RemotableViewMethod
    public void setData(Bundle extras) {
        Parcelable[] messages = extras.getParcelableArray(Notification.EXTRA_MESSAGES);
@@ -326,7 +332,12 @@ public class MessagingLayout extends FrameLayout {
                mAddedGroups.add(newGroup);
            }
            newGroup.setLayoutColor(mLayoutColor);
            newGroup.setSender(senders.get(groupIndex));
            Notification.Person sender = senders.get(groupIndex);
            CharSequence nameOverride = null;
            if (sender != mUser && mNameReplacement != null) {
                nameOverride = mNameReplacement;
            }
            newGroup.setSender(sender, nameOverride);
            mGroups.add(newGroup);

            if (mMessagingLinearLayout.indexOfChild(newGroup) != groupIndex) {