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

Commit cc123a07 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Set avatar visibility based on collapsed state

And not whether it's a single line because the collapsed form
can have multiple lines if a summarization is shown

Also, fix an NPE seen when testing this fix with a group without a
name

Test: manual - collapsed and expanded forms of group and individual
notifications with and without summarization
Test: presubmit screenshot tests
Flag: android.app.nm_summarization_ui
Flag: android.app.notifications_redesign_templates
Fixes: 399841390

Change-Id: I606a94275cf084e3c3da549a38b204fad3fa8f46
parent bdb2c65f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1178,6 +1178,7 @@ public class ConversationLayout extends FrameLayout
            }
            newGroup.setShowingAvatar(!mIsOneToOne && !mIsCollapsed);
            newGroup.setSingleLine(mIsCollapsed && TextUtils.isEmpty(mSummarizedContent));
            newGroup.setIsCollapsed(mIsCollapsed);
            newGroup.setSender(sender, nameOverride);
            newGroup.setSending(groupIndex == (groups.size() - 1) && showSpinner);
            mGroups.add(newGroup);
+11 −2
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@ public class MessagingGroup extends NotificationOptimizedLinearLayout implements
    private boolean mShowingAvatar = true;
    private CharSequence mSenderName;
    private boolean mSingleLine = false;
    private boolean mIsCollapsed = false;
    private LinearLayout mContentContainer;
    private int mRequestedMaxDisplayedLines = Integer.MAX_VALUE;
    private int mSenderTextPaddingSingleLine;
@@ -451,7 +452,7 @@ public class MessagingGroup extends NotificationOptimizedLinearLayout implements
    private void updateIconVisibility() {
        if (Flags.notificationsRedesignTemplates()) {
            // We don't show any icon (other than the app or person icon) in the collapsed form.
            mMessagingIconContainer.setVisibility(mSingleLine ? GONE : VISIBLE);
            mMessagingIconContainer.setVisibility(mIsCollapsed ? GONE : VISIBLE);
        }
    }

@@ -714,10 +715,18 @@ public class MessagingGroup extends NotificationOptimizedLinearLayout implements
            updateMaxDisplayedLines();
            updateClipRect();
            updateSenderVisibility();
            updateIconVisibility();
        }
    }

    /**
     * Sets whether this is in a collapsed layout or not. Certain elements like icons are not shown
     * when the notification is collapsed.
     */
    public void setIsCollapsed(boolean isCollapsed) {
        mIsCollapsed = isCollapsed;
        updateIconVisibility();
    }

    public boolean isSingleLine() {
        return mSingleLine;
    }
+1 −0
Original line number Diff line number Diff line
@@ -551,6 +551,7 @@ public class MessagingLayout extends FrameLayout
            }
            newGroup.setSingleLine(mIsCollapsed && TextUtils.isEmpty(mSummarizedContent));
            newGroup.setShowingAvatar(!mIsCollapsed);
            newGroup.setIsCollapsed(mIsCollapsed);
            newGroup.setSender(sender, nameOverride);
            newGroup.setSending(groupIndex == (groups.size() - 1) && showSpinner);
            mGroups.add(newGroup);
+1 −1
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ public class PeopleHelper {
    @NonNull
    public Icon createAvatarSymbol(@NonNull CharSequence name, @NonNull String symbol,
            @ColorInt int layoutColor) {
        if (symbol.isEmpty() || TextUtils.isDigitsOnly(symbol)
        if (symbol == null || symbol.isEmpty() || TextUtils.isDigitsOnly(symbol)
                || SPECIAL_CHAR_PATTERN.matcher(symbol).find()) {
            Icon avatarIcon = Icon.createWithResource(mContext, R.drawable.messaging_user);
            avatarIcon.setTint(findColor(name, layoutColor));