Add proper tinting to typing indicator.

This commit is contained in:
Alex Hart
2022-06-06 09:45:31 -03:00
parent b282b775d0
commit 796e5f6f86
9 changed files with 28 additions and 16 deletions
@@ -68,11 +68,13 @@ public class ConversationTypingView extends ConstraintLayout {
}
if (hasWallpaper) {
bubble.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.conversation_item_wallpaper_bubble_color));
typistCount.getBackground().setColorFilter(ContextCompat.getColor(getContext(), R.color.conversation_item_wallpaper_bubble_color), PorterDuff.Mode.SRC_IN);
bubble.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.conversation_item_recv_bubble_color_wallpaper));
typistCount.getBackground().setColorFilter(ContextCompat.getColor(getContext(), R.color.conversation_item_recv_bubble_color_wallpaper), PorterDuff.Mode.SRC_IN);
indicator.setDotTint(ContextCompat.getColor(getContext(), R.color.conversation_typing_indicator_foreground_tint_wallpaper));
} else {
bubble.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.signal_background_secondary));
typistCount.getBackground().setColorFilter(ContextCompat.getColor(getContext(), R.color.signal_background_secondary), PorterDuff.Mode.SRC_IN);
bubble.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.conversation_item_recv_bubble_color_normal));
typistCount.getBackground().setColorFilter(ContextCompat.getColor(getContext(), R.color.conversation_item_recv_bubble_color_normal), PorterDuff.Mode.SRC_IN);
indicator.setDotTint(ContextCompat.getColor(getContext(), R.color.conversation_typing_indicator_foreground_tint_normal));
}
indicator.startAnimation();
@@ -9,6 +9,7 @@ import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import androidx.annotation.ColorInt;
import androidx.annotation.Nullable;
import org.thoughtcrime.securesms.R;
@@ -54,12 +55,16 @@ public class TypingIndicatorView extends LinearLayout {
int tint = typedArray.getColor(R.styleable.TypingIndicatorView_typingIndicator_tint, Color.WHITE);
typedArray.recycle();
dot1.getBackground().setColorFilter(tint, PorterDuff.Mode.MULTIPLY);
dot2.getBackground().setColorFilter(tint, PorterDuff.Mode.MULTIPLY);
dot3.getBackground().setColorFilter(tint, PorterDuff.Mode.MULTIPLY);
setDotTint(tint);
}
}
public void setDotTint(@ColorInt int tint) {
dot1.getBackground().setColorFilter(tint, PorterDuff.Mode.MULTIPLY);
dot2.getBackground().setColorFilter(tint, PorterDuff.Mode.MULTIPLY);
dot3.getBackground().setColorFilter(tint, PorterDuff.Mode.MULTIPLY);
}
@Override
protected void onDraw(Canvas canvas) {
if (!isActive) {
@@ -22,7 +22,6 @@ import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.Typeface;
@@ -611,8 +610,8 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
}
private void initializeAttributes() {
defaultBubbleColor = ContextCompat.getColor(context, R.color.signal_colorSurfaceVariant);
defaultBubbleColorForWallpaper = ContextCompat.getColor(context, R.color.conversation_item_wallpaper_bubble_color);
defaultBubbleColor = ContextCompat.getColor(context, R.color.conversation_item_recv_bubble_color_normal);
defaultBubbleColorForWallpaper = ContextCompat.getColor(context, R.color.conversation_item_recv_bubble_color_wallpaper);
}
private @ColorInt int getDefaultBubbleColor(boolean hasWallpaper) {
@@ -140,7 +140,7 @@ class ChatColorPreviewView @JvmOverloads constructor(
}
val backgroundColor = if (chatWallpaper != null) {
R.color.conversation_item_wallpaper_bubble_color
R.color.conversation_item_recv_bubble_color_wallpaper
} else {
R.color.signal_background_secondary
}
@@ -80,7 +80,7 @@ public class ChatWallpaperFragment extends Fragment {
viewModel.getCurrentWallpaper().observe(getViewLifecycleOwner(), wallpaper -> {
if (wallpaper.isPresent()) {
wallpaper.get().loadInto(chatWallpaperPreview);
ImageViewCompat.setImageTintList(recvBubble, ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.conversation_item_wallpaper_bubble_color)));
ImageViewCompat.setImageTintList(recvBubble, ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.conversation_item_recv_bubble_color_wallpaper)));
} else {
chatWallpaperPreview.setImageDrawable(null);
ImageViewCompat.setImageTintList(recvBubble, ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.signal_background_secondary)));
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/conversation_item_wallpaper_bubble_color" />
<solid android:color="@color/conversation_item_recv_bubble_color_wallpaper" />
<corners android:radius="18dp" />
</shape>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/conversation_item_wallpaper_bubble_color" />
<solid android:color="@color/conversation_item_recv_bubble_color_wallpaper" />
</shape>
@@ -82,7 +82,8 @@
<color name="conversation_item_update_text_color">@color/signal_colorOnSurfaceVariant</color>
<color name="conversation_item_recv_icon_color">@color/core_grey_25</color>
<color name="conversation_item_quote_text_color">@color/core_grey_05</color>
<color name="conversation_item_wallpaper_bubble_color">@color/signal_colorBackground</color>
<color name="conversation_item_recv_bubble_color_normal">@color/signal_colorSurfaceVariant</color>
<color name="conversation_item_recv_bubble_color_wallpaper">@color/signal_colorNeutral</color>
<color name="conversation_item_outgoing_audio_foreground_tint">@color/signal_colorNeutralInverse</color>
<color name="conversation_item_incoming_audio_foreground_tint_normal">@color/signal_colorOnSurface</color>
<color name="conversation_item_incoming_audio_foreground_tint_wallpaper">@color/signal_colorNeutralInverse</color>
@@ -96,6 +97,8 @@
<color name="conversation_item_sent_view_once_circle_wallpaper">@color/transparent_white_20</color>
<color name="conversation_item_sent_view_once_unopened">@color/core_grey_05</color>
<color name="conversation_item_sent_view_once_opened">@color/transparent_white_80</color>
<color name="conversation_typing_indicator_foreground_tint_normal">@color/signal_colorOnSurfaceVariant</color>
<color name="conversation_typing_indicator_foreground_tint_wallpaper">@color/signal_colorNeutralVariantInverse</color>
<color name="wallpaper_bubble_color">@color/signal_colorTransparentInverse4</color>
+4 -1
View File
@@ -84,7 +84,8 @@
<color name="conversation_item_recv_icon_color">@color/core_grey_60</color>
<color name="conversation_item_quote_text_color">@color/signal_colorOnSurface</color>
<color name="conversation_item_quote_text_color_sent">@color/signal_colorOnSurface</color>
<color name="conversation_item_wallpaper_bubble_color">@color/signal_colorBackground</color>
<color name="conversation_item_recv_bubble_color_normal">@color/signal_colorSurfaceVariant</color>
<color name="conversation_item_recv_bubble_color_wallpaper">@color/signal_colorNeutral</color>
<color name="conversation_item_outgoing_audio_foreground_tint">@color/signal_colorNeutral</color>
<color name="conversation_item_incoming_audio_foreground_tint_normal">@color/signal_colorOnSurface</color>
<color name="conversation_item_incoming_audio_foreground_tint_wallpaper">@color/signal_colorNeutralInverse</color>
@@ -98,6 +99,8 @@
<color name="conversation_item_sent_view_once_circle_wallpaper">@color/transparent_white_20</color>
<color name="conversation_item_sent_view_once_unopened">@color/core_white</color>
<color name="conversation_item_sent_view_once_opened">@color/transparent_white_90</color>
<color name="conversation_typing_indicator_foreground_tint_normal">@color/signal_colorOnSurfaceVariant</color>
<color name="conversation_typing_indicator_foreground_tint_wallpaper">@color/signal_colorNeutralVariantInverse</color>
<color name="wallpaper_bubble_color">@color/signal_colorTransparent4</color>
<color name="sticky_header_foreground_wallpaper">@color/signal_colorNeutralVariantInverse</color>