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

Commit f2b8aa71 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed an issue where the bubble badge was visible independent of the icon

Bug: 150905003
Test: add messaging notification in a group, observe no icon backgrounds
Change-Id: Id06f1a261223f1a5cc67c9657a17c73844aba55c
parent 154f212c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.widget.ImageView;
import android.widget.RemoteViews;

import java.util.Objects;
import java.util.function.Consumer;

/**
 * An ImageView for displaying an Icon. Avoids reloading the Icon when possible.
@@ -44,6 +45,7 @@ public class CachingIconView extends ImageView {
    private boolean mInternalSetDrawable;
    private boolean mForceHidden;
    private int mDesiredVisibility;
    private Consumer<Integer> mOnVisibilityChangedListener;

    @UnsupportedAppUsage
    public CachingIconView(Context context, @Nullable AttributeSet attrs) {
@@ -198,6 +200,13 @@ public class CachingIconView extends ImageView {
    private void updateVisibility() {
        int visibility = mDesiredVisibility == VISIBLE && mForceHidden ? INVISIBLE
                : mDesiredVisibility;
        if (mOnVisibilityChangedListener != null) {
            mOnVisibilityChangedListener.accept(visibility);
        }
        super.setVisibility(visibility);
    }

    public void setOnVisibilityChangedListener(Consumer<Integer> listener) {
        mOnVisibilityChangedListener = listener;
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ public class ConversationLayout extends FrameLayout
    private int mBadgedSideMargins;
    private int mIconSizeBadged;
    private int mIconSizeCentered;
    private View mIcon;
    private CachingIconView mIcon;
    private int mExpandedGroupTopMargin;
    private int mExpandButtonExpandedSize;

@@ -153,6 +153,11 @@ public class ConversationLayout extends FrameLayout
        mConversationIcon = findViewById(R.id.conversation_icon);
        mIcon = findViewById(R.id.icon);
        mConversationIconBadge = findViewById(R.id.conversation_icon_badge);
        mIcon.setOnVisibilityChangedListener((visibility) -> {
            // Always keep the badge visibility in sync with the icon. This is necessary in cases
            // Where the icon is being hidden externally like in group children.
            mConversationIconBadge.setVisibility(visibility);
        });
        mHeaderText = findViewById(R.id.header_text);
        mExpandButtonContainer = findViewById(R.id.expand_button_container);
        mExpandButtonAndContentContainer = findViewById(R.id.expand_button_and_content_container);