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

Commit 514616b7 authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz
Browse files

[Conversation Notification] match sync/async image loading

Fixes: 329166814
Test: Presubmit + screenshot tests
Flag: None
Change-Id: I02940a15b27f6830fff3c99fdd54c7b9151447be
parent 2153fff8
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -113,7 +113,7 @@ public class CachingIconView extends ImageView {
    }
    }


    @Nullable
    @Nullable
    private Drawable loadSizeRestrictedIcon(@Nullable Icon icon) {
    Drawable loadSizeRestrictedIcon(@Nullable Icon icon) {
        return LocalImageResolver.resolveImage(icon, getContext(), mMaxDrawableWidth,
        return LocalImageResolver.resolveImage(icon, getContext(), mMaxDrawableWidth,
                mMaxDrawableHeight);
                mMaxDrawableHeight);
    }
    }
+18 −8
Original line number Original line Diff line number Diff line
@@ -37,7 +37,6 @@ import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.Icon;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Bundle;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.Parcelable;
import android.text.Spannable;
import android.text.Spannable;
@@ -1216,7 +1215,7 @@ public class ConversationLayout extends FrameLayout
            return new ConversationHeaderData(
            return new ConversationHeaderData(
                    conversationText,
                    conversationText,
                    new OneToOneConversationAvatarData(
                    new OneToOneConversationAvatarData(
                            resolveAvatarImage(conversationIcon)));
                            resolveAvatarImageForOneToOne(conversationIcon)));
        }
        }


        final List<List<Notification.MessagingStyle.Message>> groupMessages = new ArrayList<>();
        final List<List<Notification.MessagingStyle.Message>> groupMessages = new ArrayList<>();
@@ -1283,18 +1282,29 @@ public class ConversationLayout extends FrameLayout


        return new ConversationHeaderData(
        return new ConversationHeaderData(
                conversationText,
                conversationText,
                new GroupConversationAvatarData(resolveAvatarImage(lastIcon),
                new GroupConversationAvatarData(resolveAvatarImageForFacePile(lastIcon),
                        resolveAvatarImage(secondLastIcon)));
                        resolveAvatarImageForFacePile(secondLastIcon)));
    }
    }


    /**
    /**
     * {@link ImageResolver#loadImage(Uri)} accepts Uri to load images. However Conversation Avatars
     * One To One Conversation Avatars is loaded by CachingIconView(conversation icon view).
     * are received as Icon. So, we can't make use of ImageResolver.
     */
     */
    @Nullable
    @Nullable
    private Drawable resolveAvatarImage(Icon conversationIcon) {
    private Drawable resolveAvatarImageForOneToOne(Icon conversationIcon) {
        try {
        try {
            return LocalImageResolver.resolveImage(conversationIcon, getContext());
            return mConversationIconView.loadSizeRestrictedIcon(conversationIcon);
        } catch (Exception ex) {
            return null;
        }
    }

    /**
     * Group Avatar drawables are loaded by Icon.
     */
    @Nullable
    private Drawable resolveAvatarImageForFacePile(Icon conversationIcon) {
        try {
            return conversationIcon.loadDrawable(getContext());
        } catch (Exception ex) {
        } catch (Exception ex) {
            return null;
            return null;
        }
        }