From 66c3b1388ae6bb000261fb883b132197aa8250bb Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Wed, 2 Jun 2021 16:50:45 -0300 Subject: [PATCH] Add new chat colors megaphone. --- .../securesms/megaphone/BasicMegaphoneView.java | 16 +++++++++++----- .../securesms/megaphone/Megaphones.java | 14 +++++++++++--- app/src/main/res/layout/basic_megaphone_view.xml | 2 +- app/src/main/res/values/strings.xml | 4 ++++ 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/megaphone/BasicMegaphoneView.java b/app/src/main/java/org/thoughtcrime/securesms/megaphone/BasicMegaphoneView.java index 28ffd79f6d..39ce57a08a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/megaphone/BasicMegaphoneView.java +++ b/app/src/main/java/org/thoughtcrime/securesms/megaphone/BasicMegaphoneView.java @@ -10,15 +10,17 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.airbnb.lottie.LottieAnimationView; + import org.thoughtcrime.securesms.R; public class BasicMegaphoneView extends FrameLayout { - private ImageView image; - private TextView titleText; - private TextView bodyText; - private Button actionButton; - private Button secondaryButton; + private LottieAnimationView image; + private TextView titleText; + private TextView bodyText; + private Button actionButton; + private Button secondaryButton; private Megaphone megaphone; private MegaphoneActionController megaphoneListener; @@ -62,6 +64,10 @@ public class BasicMegaphoneView extends FrameLayout { } else if (megaphone.getImageRequest() != null) { image.setVisibility(VISIBLE); megaphone.getImageRequest().into(image); + } else if (megaphone.getLottieRes() != 0) { + image.setVisibility(VISIBLE); + image.setAnimation(megaphone.getLottieRes()); + image.playAnimation(); } else { image.setVisibility(GONE); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/megaphone/Megaphones.java b/app/src/main/java/org/thoughtcrime/securesms/megaphone/Megaphones.java index 0db5fa4bc8..6baffd5d84 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/megaphone/Megaphones.java +++ b/app/src/main/java/org/thoughtcrime/securesms/megaphone/Megaphones.java @@ -33,6 +33,7 @@ import org.thoughtcrime.securesms.util.LocaleFeatureFlags; import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.VersionTracker; import org.thoughtcrime.securesms.util.dynamiclanguage.DynamicLanguageContextWrapper; +import org.thoughtcrime.securesms.wallpaper.ChatWallpaperActivity; import java.util.LinkedHashMap; import java.util.List; @@ -132,7 +133,7 @@ public final class Megaphones { case NOTIFICATIONS: return buildNotificationsMegaphone(context); case CHAT_COLORS: - return buildChatColorsMegaphone(); + return buildChatColorsMegaphone(context); default: throw new IllegalArgumentException("Event not handled!"); } @@ -304,11 +305,18 @@ public final class Megaphones { .build(); } - private static @NonNull Megaphone buildChatColorsMegaphone() { - return new Megaphone.Builder(Event.CHAT_COLORS, Megaphone.Style.POPUP) + private static @NonNull Megaphone buildChatColorsMegaphone(@NonNull Context context) { + return new Megaphone.Builder(Event.CHAT_COLORS, Megaphone.Style.BASIC) .setTitle(R.string.ChatColorsMegaphone__new_chat_colors) .setBody(R.string.ChatColorsMegaphone__we_switched_up_chat_colors) .setLottie(R.raw.color_bubble_64) + .setActionButton(R.string.ChatColorsMegaphone__appearance, (megaphone, listener) -> { + listener.onMegaphoneNavigationRequested(ChatWallpaperActivity.createIntent(context)); + listener.onMegaphoneCompleted(Event.CHAT_COLORS); + }) + .setSecondaryButton(R.string.ChatColorsMegaphone__not_now, (megaphone, listener) -> { + listener.onMegaphoneCompleted(Event.CHAT_COLORS); + }) .build(); } diff --git a/app/src/main/res/layout/basic_megaphone_view.xml b/app/src/main/res/layout/basic_megaphone_view.xml index 66065bf0e2..6b2a002232 100644 --- a/app/src/main/res/layout/basic_megaphone_view.xml +++ b/app/src/main/res/layout/basic_megaphone_view.xml @@ -27,7 +27,7 @@ android:paddingEnd="8dp" android:paddingBottom="8dp"> - Save Auto matches the color to the wallpaper Drag to change the direction of the gradient + + New Chat Colors We switched up chat colors to give you more options and make chats easier to read. + Appearance + Not now