From f3bb40e0242847e73198b756a0700d54f3e8abbf Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Fri, 28 Aug 2020 17:38:19 +1000 Subject: [PATCH] Loading indicator for message thumbnail view. --- res/layout/conversation_item_thumbnail.xml | 15 +++++++- .../components/ConversationItemThumbnail.java | 37 ++++++++++++++----- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/res/layout/conversation_item_thumbnail.xml b/res/layout/conversation_item_thumbnail.xml index 23544e8e68..fe438060da 100644 --- a/res/layout/conversation_item_thumbnail.xml +++ b/res/layout/conversation_item_thumbnail.xml @@ -42,7 +42,18 @@ android:layout_marginStart="@dimen/message_bubble_horizontal_padding" android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" android:layout_marginBottom="@dimen/message_bubble_bottom_padding" - app:footer_text_color="@color/core_white" - app:footer_icon_color="@color/core_white"/> + app:footer_text_color="@android:color/white" + app:footer_icon_color="@android:color/white"/> + + diff --git a/src/org/thoughtcrime/securesms/components/ConversationItemThumbnail.java b/src/org/thoughtcrime/securesms/components/ConversationItemThumbnail.java index 4b4e791ab2..ef7db1abb1 100644 --- a/src/org/thoughtcrime/securesms/components/ConversationItemThumbnail.java +++ b/src/org/thoughtcrime/securesms/components/ConversationItemThumbnail.java @@ -3,15 +3,16 @@ package org.thoughtcrime.securesms.components; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; +import android.util.AttributeSet; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.ProgressBar; + import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.UiThread; -import android.util.AttributeSet; -import android.widget.FrameLayout; -import android.widget.ImageView; -import network.loki.messenger.R; import org.thoughtcrime.securesms.attachments.Attachment; import org.thoughtcrime.securesms.mms.GlideRequests; import org.thoughtcrime.securesms.mms.Slide; @@ -21,12 +22,15 @@ import org.thoughtcrime.securesms.util.ThemeUtil; import java.util.List; +import network.loki.messenger.R; + public class ConversationItemThumbnail extends FrameLayout { private ThumbnailView thumbnail; private AlbumThumbnailView album; private ImageView shade; private ConversationItemFooter footer; + private ProgressBar loadIndicator; private CornerMask cornerMask; private Outliner outliner; private boolean borderless; @@ -49,12 +53,13 @@ public class ConversationItemThumbnail extends FrameLayout { private void init(@Nullable AttributeSet attrs) { inflate(getContext(), R.layout.conversation_item_thumbnail, this); - this.thumbnail = findViewById(R.id.conversation_thumbnail_image); - this.album = findViewById(R.id.conversation_thumbnail_album); - this.shade = findViewById(R.id.conversation_thumbnail_shade); - this.footer = findViewById(R.id.conversation_thumbnail_footer); - this.cornerMask = new CornerMask(this); - this.outliner = new Outliner(); + this.thumbnail = findViewById(R.id.conversation_thumbnail_image); + this.album = findViewById(R.id.conversation_thumbnail_album); + this.shade = findViewById(R.id.conversation_thumbnail_shade); + this.footer = findViewById(R.id.conversation_thumbnail_footer); + this.loadIndicator = findViewById(R.id.conversation_thumbnail_load_indicator); + this.cornerMask = new CornerMask(this); + this.outliner = new Outliner(); outliner.setColor(ThemeUtil.getThemedColor(getContext(), R.attr.conversation_item_image_outline_color)); @@ -136,6 +141,18 @@ public class ConversationItemThumbnail extends FrameLayout { album.setSlides(glideRequests, slides, showControls); setTouchDelegate(album.getTouchDelegate()); } + + // Display loading indicator if any attachment is in loading state. + { + boolean anyLoading = false; + for (int i = 0; i < slides.size(); i++) { + if (slides.get(i).asAttachment().isInProgress()) { + anyLoading = true; + break; + } + } + loadIndicator.setVisibility(anyLoading ? VISIBLE : GONE); + } } public void setConversationColor(@ColorInt int color) {