diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java index 421bc07d14..01c01526e7 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java @@ -479,7 +479,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo footer.setIconColor(colorizer.getOutgoingFooterIconColor(context)); footer.setRevealDotColor(colorizer.getOutgoingFooterIconColor(context)); footer.setOnlyShowSendingStatus(false, messageRecord); - } else if (messageRecord.isRemoteDelete() || (isViewOnceMessage(messageRecord) && ViewOnceUtil.isViewed((MmsMessageRecord) messageRecord))) { + } else if (messageRecord.isRemoteDelete()) { if (hasWallpaper) { bodyBubble.getBackground().setColorFilter(ContextCompat.getColor(context, R.color.wallpaper_bubble_color), PorterDuff.Mode.SRC_IN); } else { @@ -597,8 +597,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo if (hasWallpaper) { return false; } else { - boolean isIncomingViewedOnce = !messageRecord.isOutgoing() && isViewOnceMessage(messageRecord) && ViewOnceUtil.isViewed((MmsMessageRecord) messageRecord); - return isIncomingViewedOnce || messageRecord.isRemoteDelete(); + return messageRecord.isRemoteDelete(); } } @@ -765,10 +764,12 @@ public final class ConversationItem extends RelativeLayout implements BindableCo if (linkPreviewStub.resolved()) linkPreviewStub.get().setVisibility(GONE); if (stickerStub.resolved()) stickerStub.get().setVisibility(View.GONE); - revealableStub.get().setMessage((MmsMessageRecord) messageRecord); + revealableStub.get().setMessage((MmsMessageRecord) messageRecord, hasWallpaper); revealableStub.get().setOnClickListener(revealableClickListener); revealableStub.get().setOnLongClickListener(passthroughClickListener); + updateRevealableMargins(messageRecord, previousRecord, nextRecord, isGroupThread); + footer.setVisibility(VISIBLE); } else if (hasSharedContact(messageRecord)) { sharedContactStub.get().setVisibility(VISIBLE); @@ -976,6 +977,24 @@ public final class ConversationItem extends RelativeLayout implements BindableCo } } + private void updateRevealableMargins(MessageRecord messageRecord, Optional previous, Optional next, boolean isGroupThread) { + int bigMargin = readDimen(R.dimen.message_bubble_revealable_padding); + int smallMargin = readDimen(R.dimen.message_bubble_top_padding); + + //noinspection ConstantConditions + if (messageRecord.isOutgoing() || !isStartOfMessageCluster(messageRecord, previous, isGroupThread)) { + ViewUtil.setTopMargin(revealableStub.get(), bigMargin); + } else { + ViewUtil.setTopMargin(revealableStub.get(), smallMargin); + } + + if (isFooterVisible(messageRecord, next, isGroupThread)) { + ViewUtil.setBottomMargin(revealableStub.get(), smallMargin); + } else { + ViewUtil.setBottomMargin(revealableStub.get(), bigMargin); + } + } + private void setThumbnailCorners(@NonNull MessageRecord current, @NonNull Optional previous, @NonNull Optional next, @@ -1234,10 +1253,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo if (sharedContactStub.resolved()) sharedContactStub.get().getFooter().setVisibility(GONE); if (mediaThumbnailStub.resolved()) mediaThumbnailStub.require().getFooter().setVisibility(GONE); - boolean differentTimestamps = next.isPresent() && !DateUtils.isSameExtendedRelativeTimestamp(next.get().getTimestamp(), current.getTimestamp()); - - if (forceFooter(messageRecord) || current.getExpiresIn() > 0 || !current.isSecure() || current.isPending() || current.isPendingInsecureSmsFallback() || - current.isFailed() || current.isRateLimited() || differentTimestamps || isEndOfMessageCluster(current, next, isGroupThread)) + if (isFooterVisible(current, next, isGroupThread)) { ConversationItemFooter activeFooter = getActiveFooter(current); activeFooter.setVisibility(VISIBLE); @@ -1439,6 +1455,13 @@ public final class ConversationItem extends RelativeLayout implements BindableCo return isStartOfMessageCluster(current, previous, isGroupThread) && isEndOfMessageCluster(current, next, isGroupThread); } + private boolean isFooterVisible(@NonNull MessageRecord current, @NonNull Optional next, boolean isGroupThread) { + boolean differentTimestamps = next.isPresent() && !DateUtils.isSameExtendedRelativeTimestamp(next.get().getTimestamp(), current.getTimestamp()); + + return forceFooter(messageRecord) || current.getExpiresIn() > 0 || !current.isSecure() || current.isPending() || current.isPendingInsecureSmsFallback() || + current.isFailed() || current.isRateLimited() || differentTimestamps || isEndOfMessageCluster(current, next, isGroupThread); + } + private void setMessageSpacing(@NonNull Context context, @NonNull MessageRecord current, @NonNull Optional previous, @NonNull Optional next, boolean isGroupThread) { int spacingTop = readDimen(context, R.dimen.conversation_vertical_message_spacing_collapse); int spacingBottom = spacingTop; diff --git a/app/src/main/java/org/thoughtcrime/securesms/revealable/ViewOnceMessageView.java b/app/src/main/java/org/thoughtcrime/securesms/revealable/ViewOnceMessageView.java index 3875ceae3e..04fc926900 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/revealable/ViewOnceMessageView.java +++ b/app/src/main/java/org/thoughtcrime/securesms/revealable/ViewOnceMessageView.java @@ -1,8 +1,11 @@ package org.thoughtcrime.securesms.revealable; import android.content.Context; +import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.graphics.Color; +import android.graphics.PorterDuff; +import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.widget.ImageView; import android.widget.LinearLayout; @@ -11,6 +14,9 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; +import androidx.appcompat.widget.AppCompatImageView; +import androidx.core.content.ContextCompat; +import androidx.core.widget.ImageViewCompat; import com.pnikosis.materialishprogress.ProgressWheel; @@ -24,6 +30,8 @@ import org.thoughtcrime.securesms.database.AttachmentDatabase; import org.thoughtcrime.securesms.database.model.MmsMessageRecord; import org.thoughtcrime.securesms.events.PartProgressEvent; import org.thoughtcrime.securesms.mms.Slide; +import org.thoughtcrime.securesms.util.ContextUtil; +import org.thoughtcrime.securesms.util.DrawableUtil; import org.thoughtcrime.securesms.util.MediaUtil; import org.thoughtcrime.securesms.util.Util; @@ -31,13 +39,15 @@ public class ViewOnceMessageView extends LinearLayout { private static final String TAG = Log.tag(ViewOnceMessageView.class); - private ImageView icon; - private ProgressWheel progress; - private TextView text; - private Attachment attachment; - private int unopenedForegroundColor; - private int openedForegroundColor; - private int foregroundColor; + private AppCompatImageView icon; + private ProgressWheel progress; + private TextView text; + private Attachment attachment; + private int textColor; + private int openedIconColor; + private int unopenedIconColor; + private int circleColor; + private int circleColorWithWallpaper; public ViewOnceMessageView(Context context) { super(context); @@ -54,10 +64,12 @@ public class ViewOnceMessageView extends LinearLayout { setOrientation(LinearLayout.HORIZONTAL); if (attrs != null) { - TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.ViewOnceMessageView, 0, 0); - - unopenedForegroundColor = typedArray.getColor(R.styleable.ViewOnceMessageView_revealable_unopenedForegroundColor, Color.BLACK); - openedForegroundColor = typedArray.getColor(R.styleable.ViewOnceMessageView_revealable_openedForegroundColor, Color.BLACK); + TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.ViewOnceMessageView, 0, 0); + textColor = typedArray.getColor(R.styleable.ViewOnceMessageView_revealable_textColor, Color.BLACK); + openedIconColor = typedArray.getColor(R.styleable.ViewOnceMessageView_revealable_openedIconColor, Color.BLACK); + unopenedIconColor = typedArray.getColor(R.styleable.ViewOnceMessageView_revealable_unopenedIconColor, Color.BLACK); + circleColor = typedArray.getColor(R.styleable.ViewOnceMessageView_revealable_circleColor, Color.BLACK); + circleColorWithWallpaper = typedArray.getColor(R.styleable.ViewOnceMessageView_revealable_circleColorWithWallpaper, Color.BLACK); typedArray.recycle(); } @@ -91,53 +103,70 @@ public class ViewOnceMessageView extends LinearLayout { attachment.getTransferState() == AttachmentDatabase.TRANSFER_PROGRESS_PENDING; } - public void setMessage(@NonNull MmsMessageRecord message) { + public void setMessage(@NonNull MmsMessageRecord message, boolean hasWallpaper) { this.attachment = message.getSlideDeck().getThumbnailSlide() != null ? message.getSlideDeck().getThumbnailSlide().asAttachment() : null; - presentMessage(message); + presentMessage(message, hasWallpaper); } - public void presentMessage(@NonNull MmsMessageRecord message) { - presentText(message); + public void presentMessage(@NonNull MmsMessageRecord message, boolean hasWallpaper) { + presentText(message, hasWallpaper); } - private void presentText(@NonNull MmsMessageRecord messageRecord) { + private void presentText(@NonNull MmsMessageRecord messageRecord, boolean hasWallpaper) { + int iconColor; + boolean showProgress = false; + if (messageRecord.isOutgoing() && networkInProgress(messageRecord)) { - foregroundColor = openedForegroundColor; + iconColor = openedIconColor; text.setText(R.string.RevealableMessageView_media); icon.setImageResource(0); - progress.setVisibility(VISIBLE); + showProgress = true; } else if (messageRecord.isOutgoing()) { - foregroundColor = openedForegroundColor; - text.setText(R.string.RevealableMessageView_media); - icon.setImageResource(R.drawable.ic_viewed_once_24); - progress.setVisibility(GONE); + if (messageRecord.isRemoteViewed()) { + iconColor = openedIconColor; + text.setText(R.string.RevealableMessageView_viewed); + icon.setImageResource(R.drawable.ic_viewed_once_24); + } else { + iconColor = unopenedIconColor; + text.setText(R.string.RevealableMessageView_media); + icon.setImageResource(R.drawable.ic_view_once_24); + } } else if (ViewOnceUtil.isViewable(messageRecord)) { - foregroundColor = unopenedForegroundColor; + iconColor = unopenedIconColor; text.setText(getDescriptionId(messageRecord)); icon.setImageResource(R.drawable.ic_view_once_24); - progress.setVisibility(GONE); } else if (networkInProgress(messageRecord)) { - foregroundColor = unopenedForegroundColor; + iconColor = unopenedIconColor; text.setText(""); icon.setImageResource(0); - progress.setVisibility(VISIBLE); + showProgress = true; } else if (requiresTapToDownload(messageRecord)) { - foregroundColor = unopenedForegroundColor; + iconColor = unopenedIconColor; text.setText(formatFileSize(messageRecord)); icon.setImageResource(R.drawable.ic_arrow_down_circle_outline_24); - progress.setVisibility(GONE); } else { - foregroundColor = openedForegroundColor; + iconColor = openedIconColor; text.setText(R.string.RevealableMessageView_viewed); icon.setImageResource(R.drawable.ic_viewed_once_24); - progress.setVisibility(GONE); } - text.setTextColor(foregroundColor); - icon.setColorFilter(foregroundColor); - progress.setBarColor(foregroundColor); + text.setTextColor(textColor); + icon.setColorFilter(iconColor); + icon.setBackgroundDrawable(getBackgroundDrawable(hasWallpaper)); + progress.setBarColor(iconColor); progress.setRimColor(Color.TRANSPARENT); + if (showProgress) { + progress.setVisibility(VISIBLE); + } else { + progress.setVisibility(GONE); + } + } + + private Drawable getBackgroundDrawable(boolean hasWallpaper) { + int backgroundColor = hasWallpaper ? circleColorWithWallpaper : circleColor; + Drawable drawable = ContextUtil.requireDrawable(getContext(), R.drawable.circle_tintable); + return DrawableUtil.tint(drawable, backgroundColor); } private boolean networkInProgress(@NonNull MmsMessageRecord messageRecord) { diff --git a/app/src/main/res/drawable/ic_view_once_24.xml b/app/src/main/res/drawable/ic_view_once_24.xml index 47b179e0da..cad17d0643 100644 --- a/app/src/main/res/drawable/ic_view_once_24.xml +++ b/app/src/main/res/drawable/ic_view_once_24.xml @@ -5,5 +5,5 @@ android:viewportHeight="24"> + android:pathData="M13.25,7.75v7.87a0.88,0.88 0,1 1,-1.75 0V9.5H10.25A0.74,0.74 0,0 1,10.13 8V8A2.34,2.34 0,0 0,12 7.22,0.73 0.73,0 0,1 12.5,7 0.76,0.76 0,0 1,13.25 7.75ZM12,1a11,11 0,1 0,7.31 19.21l-0.19,1.09V22a0.88,0.88 0,0 0,1.76 0V18a0.89,0.89 0,0 0,-0.88 -0.88H16a0.88,0.88 0,0 0,0 1.76h1.34l1,-0.18A9.24,9.24 0,1 1,21.25 12a9.37,9.37 0,0 1,-0.41 2.74,0.87 0.87,0 1,0 1.67,0.52A11.19,11.19 0,0 0,23 12,11 11,0 0,0 12,1Z"/> diff --git a/app/src/main/res/drawable/ic_viewed_once_24.xml b/app/src/main/res/drawable/ic_viewed_once_24.xml index f500ddc6fc..a1849f8f57 100644 --- a/app/src/main/res/drawable/ic_viewed_once_24.xml +++ b/app/src/main/res/drawable/ic_viewed_once_24.xml @@ -5,5 +5,5 @@ android:viewportHeight="24"> + android:pathData="M13.25,7.75v7.87a0.88,0.88 0,1 1,-1.75 0L11.5,9.5L10.25,9.5A0.74,0.74 0,0 1,10.13 8L10.13,8A2.34,2.34 0,0 0,12 7.22,0.73 0.73,0 0,1 12.5,7 0.76,0.76 0,0 1,13.25 7.75ZM8.89,3.29a9.18,9.18 0,0 1,2.65 -0.53L12,2.76A0.88,0.88 0,1 0,12 1h-0.54a11.3,11.3 0,0 0,-3.16 0.63,0.88 0.88,0 0,0 0.29,1.7A1,1 0,0 0,8.89 3.29ZM3.64,8a9.2,9.2 0,0 1,1.5 -2.25A0.87,0.87 0,1 0,3.85 4.61,11.11 11.11,0 0,0 2.06,7.29a0.88,0.88 0,0 0,0.41 1.17,0.84 0.84,0 0,0 0.38,0.08A0.87,0.87 0,0 0,3.64 8ZM2.76,16.19a0.87,0.87 0,0 0,0.53 -1.11,9.31 9.31,0 0,1 -0.53,-2.66c0,-0.15 0,-0.31 0,-0.46A0.88,0.88 0,1 0,1 12c0,0.18 0,0.36 0,0.54a11.3,11.3 0,0 0,0.63 3.16,0.87 0.87,0 0,0 0.82,0.58A0.79,0.79 0,0 0,2.76 16.23ZM8.46,21.49A0.88,0.88 0,0 0,8 20.36a9.2,9.2 0,0 1,-2.25 -1.5,0.87 0.87,0 1,0 -1.17,1.29 10.86,10.86 0,0 0,2.67 1.79,0.85 0.85,0 0,0 0.38,0.09A0.89,0.89 0,0 0,8.46 21.53ZM12.54,23a11.3,11.3 0,0 0,3.16 -0.63,0.86 0.86,0 0,0 0.53,-1.12 0.87,0.87 0,0 0,-1.11 -0.53,9.31 9.31,0 0,1 -2.66,0.53L12,21.25A0.88,0.88 0,1 0,12 23ZM20.15,19.39a10.86,10.86 0,0 0,1.79 -2.67A0.87,0.87 0,1 0,20.36 16a9.2,9.2 0,0 1,-1.5 2.25,0.86 0.86,0 0,0 0.06,1.23 0.81,0.81 0,0 0,0.58 0.23A0.84,0.84 0,0 0,20.15 19.38ZM23,12c0,-0.18 0,-0.36 0,-0.54a11.3,11.3 0,0 0,-0.63 -3.16,0.87 0.87,0 0,0 -1.65,0.58 9.31,9.31 0,0 1,0.53 2.66c0,0.15 0,0.31 0,0.46A0.88,0.88 0,1 0,23 12ZM19.45,5.08a0.87,0.87 0,0 0,-0.07 -1.23,10.86 10.86,0 0,0 -2.67,-1.79A0.87,0.87 0,1 0,16 3.64a9.2,9.2 0,0 1,2.25 1.5,0.85 0.85,0 0,0 0.59,0.23A0.89,0.89 0,0 0,19.45 5.08Z"/> diff --git a/app/src/main/res/layout/conversation_item_received_revealable.xml b/app/src/main/res/layout/conversation_item_received_revealable.xml index 916085d890..c1bff92ef1 100644 --- a/app/src/main/res/layout/conversation_item_received_revealable.xml +++ b/app/src/main/res/layout/conversation_item_received_revealable.xml @@ -7,6 +7,9 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" - app:revealable_unopenedForegroundColor="@color/signal_text_primary" - app:revealable_openedForegroundColor="@color/signal_text_primary" + app:revealable_textColor="@color/signal_text_primary" + app:revealable_openedIconColor="@color/conversation_item_incoming_view_once_opened" + app:revealable_unopenedIconColor="@color/conversation_item_incoming_view_once_unopened" + app:revealable_circleColor="@color/conversation_item_incoming_view_once_circle" + app:revealable_circleColorWithWallpaper="@color/conversation_item_incoming_view_once_circle_wallpaper" tools:visibility="visible"/> diff --git a/app/src/main/res/layout/conversation_item_sent_revealable.xml b/app/src/main/res/layout/conversation_item_sent_revealable.xml index 21b7bf7d09..357e1f4af9 100644 --- a/app/src/main/res/layout/conversation_item_sent_revealable.xml +++ b/app/src/main/res/layout/conversation_item_sent_revealable.xml @@ -7,6 +7,9 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" - app:revealable_unopenedForegroundColor="@color/conversation_item_sent_text_primary_color" - app:revealable_openedForegroundColor="@color/conversation_item_sent_text_primary_color" + app:revealable_textColor="@color/conversation_item_sent_text_primary_color" + app:revealable_openedIconColor="@color/conversation_item_sent_view_once_opened" + app:revealable_unopenedIconColor="@color/conversation_item_sent_view_once_unopened" + app:revealable_circleColor="@color/conversation_item_sent_view_once_circle" + app:revealable_circleColorWithWallpaper="@color/conversation_item_sent_view_once_circle_wallpaper" tools:visibility="visible"/> diff --git a/app/src/main/res/layout/revealable_message_view.xml b/app/src/main/res/layout/revealable_message_view.xml index 39235120a5..65d0cf87d1 100644 --- a/app/src/main/res/layout/revealable_message_view.xml +++ b/app/src/main/res/layout/revealable_message_view.xml @@ -6,24 +6,28 @@ tools:parentTag="android.widget.LinearLayout"> + android:layout_gravity="center" + tools:background="#1D8663"> - + android:layout_width="40dp" + android:layout_height="40dp" + android:scaleType="center" + tools:background="@color/transparent_white_20" + tools:src="@drawable/ic_viewed_once_24"/> @color/core_grey_15 @color/core_grey_60 @color/core_grey_80 + @color/core_grey_60 + @color/core_grey_75 + @color/core_grey_05 + @color/transparent_white_80 + @color/transparent_white_20 + @color/transparent_white_20 + @color/core_grey_05 + @color/transparent_white_80 @color/transparent_black_80 diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 94a8eee3d9..1603656aa5 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -203,8 +203,11 @@ - - + + + + + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 8d5df3075d..b1ad262683 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -42,6 +42,7 @@ 6dp 32dp 7dp + 12dp 24dp 24dp 210dp diff --git a/app/src/main/res/values/light_colors.xml b/app/src/main/res/values/light_colors.xml index 09ea4a7f02..766bfbcfaa 100644 --- a/app/src/main/res/values/light_colors.xml +++ b/app/src/main/res/values/light_colors.xml @@ -83,6 +83,14 @@ @color/core_grey_60 @color/transparent_white_80 @color/core_grey_05 + @color/transparent_white_80 + @color/core_grey_05 + @color/core_grey_90 + @color/core_grey_50 + @color/transparent_white_20 + @color/transparent_white_20 + @color/core_white + @color/transparent_white_90 @color/transparent_white_80