mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Add Chat Colors onboarding.
This commit is contained in:
committed by
Cody Henthorne
parent
1eae360470
commit
fb817e0c3b
@@ -6,6 +6,7 @@ import android.graphics.drawable.Drawable;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RawRes;
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
@@ -25,6 +26,7 @@ public class Megaphone {
|
||||
private final int titleRes;
|
||||
private final int bodyRes;
|
||||
private final int imageRes;
|
||||
private final int lottieRes;
|
||||
private final GlideRequest<Drawable> imageRequest;
|
||||
private final int buttonTextRes;
|
||||
private final EventListener buttonListener;
|
||||
@@ -41,6 +43,7 @@ public class Megaphone {
|
||||
this.titleRes = builder.titleRes;
|
||||
this.bodyRes = builder.bodyRes;
|
||||
this.imageRes = builder.imageRes;
|
||||
this.lottieRes = builder.lottieRes;
|
||||
this.imageRequest = builder.imageRequest;
|
||||
this.buttonTextRes = builder.buttonTextRes;
|
||||
this.buttonListener = builder.buttonListener;
|
||||
@@ -74,6 +77,10 @@ public class Megaphone {
|
||||
return bodyRes;
|
||||
}
|
||||
|
||||
public @RawRes int getLottieRes() {
|
||||
return lottieRes;
|
||||
}
|
||||
|
||||
public @DrawableRes int getImageRes() {
|
||||
return imageRes;
|
||||
}
|
||||
@@ -124,6 +131,7 @@ public class Megaphone {
|
||||
private int titleRes;
|
||||
private int bodyRes;
|
||||
private int imageRes;
|
||||
private int lottieRes;
|
||||
private GlideRequest<Drawable> imageRequest;
|
||||
private int buttonTextRes;
|
||||
private EventListener buttonListener;
|
||||
@@ -174,6 +182,11 @@ public class Megaphone {
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull Builder setLottie(@RawRes int lottieRes) {
|
||||
this.lottieRes = lottieRes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull Builder setImageRequest(@Nullable GlideRequest<Drawable> imageRequest) {
|
||||
this.imageRequest = imageRequest;
|
||||
return this;
|
||||
|
||||
@@ -103,6 +103,7 @@ public final class Megaphones {
|
||||
put(Event.GROUP_CALLING, shouldShowGroupCallingMegaphone() ? ALWAYS : NEVER);
|
||||
put(Event.ONBOARDING, shouldShowOnboardingMegaphone(context) ? ALWAYS : NEVER);
|
||||
put(Event.NOTIFICATIONS, shouldShowNotificationsMegaphone(context) ? RecurringSchedule.every(TimeUnit.DAYS.toMillis(30)) : NEVER);
|
||||
put(Event.CHAT_COLORS, ALWAYS);
|
||||
}};
|
||||
}
|
||||
|
||||
@@ -130,6 +131,8 @@ public final class Megaphones {
|
||||
return buildOnboardingMegaphone();
|
||||
case NOTIFICATIONS:
|
||||
return buildNotificationsMegaphone(context);
|
||||
case CHAT_COLORS:
|
||||
return buildChatColorsMegaphone();
|
||||
default:
|
||||
throw new IllegalArgumentException("Event not handled!");
|
||||
}
|
||||
@@ -301,6 +304,14 @@ public final class Megaphones {
|
||||
.build();
|
||||
}
|
||||
|
||||
private static @NonNull Megaphone buildChatColorsMegaphone() {
|
||||
return new Megaphone.Builder(Event.CHAT_COLORS, Megaphone.Style.POPUP)
|
||||
.setTitle(R.string.ChatColorsMegaphone__new_chat_colors)
|
||||
.setBody(R.string.ChatColorsMegaphone__we_switched_up_chat_colors)
|
||||
.setLottie(R.raw.color_bubble_64)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static boolean shouldShowMessageRequestsMegaphone() {
|
||||
return Recipient.self().getProfileName() == ProfileName.EMPTY;
|
||||
}
|
||||
@@ -355,7 +366,8 @@ public final class Megaphones {
|
||||
DONATE("donate"),
|
||||
GROUP_CALLING("group_calling"),
|
||||
ONBOARDING("onboarding"),
|
||||
NOTIFICATIONS("notifications");
|
||||
NOTIFICATIONS("notifications"),
|
||||
CHAT_COLORS("chat_colors");
|
||||
|
||||
private final String key;
|
||||
|
||||
|
||||
@@ -19,10 +19,12 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.InviteActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.settings.app.AppSettingsActivity;
|
||||
import org.thoughtcrime.securesms.conversationlist.ConversationListFragment;
|
||||
import org.thoughtcrime.securesms.groups.ui.creategroup.CreateGroupActivity;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.util.SmsUtil;
|
||||
import org.thoughtcrime.securesms.wallpaper.ChatWallpaperActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -60,9 +62,10 @@ public class OnboardingMegaphoneView extends FrameLayout {
|
||||
|
||||
private static class CardAdapter extends RecyclerView.Adapter<CardViewHolder> implements ActionClickListener {
|
||||
|
||||
private static final int TYPE_GROUP = 0;
|
||||
private static final int TYPE_INVITE = 1;
|
||||
private static final int TYPE_SMS = 2;
|
||||
private static final int TYPE_GROUP = 0;
|
||||
private static final int TYPE_INVITE = 1;
|
||||
private static final int TYPE_SMS = 2;
|
||||
private static final int TYPE_APPEARANCE = 3;
|
||||
|
||||
private final Context context;
|
||||
private final MegaphoneActionController controller;
|
||||
@@ -95,10 +98,11 @@ public class OnboardingMegaphoneView extends FrameLayout {
|
||||
public @NonNull CardViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.onboarding_megaphone_list_item, parent, false);
|
||||
switch (viewType) {
|
||||
case TYPE_GROUP: return new GroupCardViewHolder(view);
|
||||
case TYPE_INVITE: return new InviteCardViewHolder(view);
|
||||
case TYPE_SMS: return new SmsCardViewHolder(view);
|
||||
default: throw new IllegalStateException("Invalid viewType! " + viewType);
|
||||
case TYPE_GROUP: return new GroupCardViewHolder(view);
|
||||
case TYPE_INVITE: return new InviteCardViewHolder(view);
|
||||
case TYPE_SMS: return new SmsCardViewHolder(view);
|
||||
case TYPE_APPEARANCE: return new AppearanceCardViewHolder(view);
|
||||
default: throw new IllegalStateException("Invalid viewType! " + viewType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +142,10 @@ public class OnboardingMegaphoneView extends FrameLayout {
|
||||
data.add(TYPE_SMS);
|
||||
}
|
||||
|
||||
if (SignalStore.onboarding().shouldShowAppearance()) {
|
||||
data.add(TYPE_APPEARANCE);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -259,4 +267,32 @@ public class OnboardingMegaphoneView extends FrameLayout {
|
||||
SignalStore.onboarding().setShowSms(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static class AppearanceCardViewHolder extends CardViewHolder {
|
||||
|
||||
public AppearanceCardViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
int getButtonStringRes() {
|
||||
return R.string.Megaphones_appearance;
|
||||
}
|
||||
|
||||
@Override
|
||||
int getImageRes() {
|
||||
return R.drawable.ic_signal_appearance;
|
||||
}
|
||||
|
||||
@Override
|
||||
void onActionClicked(@NonNull MegaphoneActionController controller) {
|
||||
controller.onMegaphoneNavigationRequested(ChatWallpaperActivity.createIntent(controller.getMegaphoneActivity()));
|
||||
SignalStore.onboarding().setShowAppearance(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
void onCloseClicked() {
|
||||
SignalStore.onboarding().setShowAppearance(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,16 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.airbnb.lottie.LottieAnimationView;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
public class PopupMegaphoneView extends FrameLayout {
|
||||
|
||||
private ImageView image;
|
||||
private TextView titleText;
|
||||
private TextView bodyText;
|
||||
private View xButton;
|
||||
private LottieAnimationView image;
|
||||
private TextView titleText;
|
||||
private TextView bodyText;
|
||||
private View xButton;
|
||||
|
||||
private Megaphone megaphone;
|
||||
private MegaphoneActionController megaphoneListener;
|
||||
@@ -57,6 +59,9 @@ public class PopupMegaphoneView extends FrameLayout {
|
||||
if (megaphone.getImageRequest() != null) {
|
||||
image.setVisibility(VISIBLE);
|
||||
megaphone.getImageRequest().into(image);
|
||||
} else if (megaphone.getLottieRes() != 0) {
|
||||
image.setVisibility(VISIBLE);
|
||||
image.setAnimation(megaphone.getLottieRes());
|
||||
} else {
|
||||
image.setVisibility(GONE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user