mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Update link preview settings and add some UI polish.
This commit is contained in:
@@ -172,6 +172,9 @@ public class Megaphone {
|
||||
/** Specialized style for announcing reactions. */
|
||||
REACTIONS,
|
||||
|
||||
/** Specialized style for announcing link previews. */
|
||||
LINK_PREVIEWS,
|
||||
|
||||
/** Basic bottom of the screen megaphone with optional snooze and action buttons. */
|
||||
BASIC,
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.thoughtcrime.securesms.linkpreview.LinkPreviewsMegaphoneView;
|
||||
import org.thoughtcrime.securesms.reactions.ReactionsMegaphoneView;
|
||||
|
||||
public class MegaphoneViewBuilder {
|
||||
@@ -21,6 +22,8 @@ public class MegaphoneViewBuilder {
|
||||
return null;
|
||||
case REACTIONS:
|
||||
return buildReactionsMegaphone(context, megaphone, listener);
|
||||
case LINK_PREVIEWS:
|
||||
return buildLinkPreviewsMegaphone(context, megaphone, listener);
|
||||
case POPUP:
|
||||
return buildPopupMegaphone(context, megaphone, listener);
|
||||
default:
|
||||
@@ -46,6 +49,15 @@ public class MegaphoneViewBuilder {
|
||||
return view;
|
||||
}
|
||||
|
||||
private static @NonNull View buildLinkPreviewsMegaphone(@NonNull Context context,
|
||||
@NonNull Megaphone megaphone,
|
||||
@NonNull MegaphoneActionController listener)
|
||||
{
|
||||
LinkPreviewsMegaphoneView view = new LinkPreviewsMegaphoneView(context);
|
||||
view.present(megaphone, listener);
|
||||
return view;
|
||||
}
|
||||
|
||||
private static @NonNull View buildPopupMegaphone(@NonNull Context context,
|
||||
@NonNull Megaphone megaphone,
|
||||
@NonNull MegaphoneActionController listener)
|
||||
|
||||
@@ -91,6 +91,7 @@ public final class Megaphones {
|
||||
put(Event.PIN_REMINDER, new SignalPinReminderSchedule());
|
||||
put(Event.MESSAGE_REQUESTS, shouldShowMessageRequestsMegaphone() ? ALWAYS : NEVER);
|
||||
put(Event.MENTIONS, shouldShowMentionsMegaphone() ? ALWAYS : NEVER);
|
||||
put(Event.LINK_PREVIEWS, SignalStore.settings().isLinkPreviewsEnabled() ? NEVER : ALWAYS);
|
||||
}};
|
||||
}
|
||||
|
||||
@@ -106,6 +107,8 @@ public final class Megaphones {
|
||||
return buildMessageRequestsMegaphone(context);
|
||||
case MENTIONS:
|
||||
return buildMentionsMegaphone();
|
||||
case LINK_PREVIEWS:
|
||||
return buildLinkPreviewsMegaphone();
|
||||
default:
|
||||
throw new IllegalArgumentException("Event not handled!");
|
||||
}
|
||||
@@ -196,6 +199,12 @@ public final class Megaphones {
|
||||
.build();
|
||||
}
|
||||
|
||||
private static @NonNull Megaphone buildLinkPreviewsMegaphone() {
|
||||
return new Megaphone.Builder(Event.LINK_PREVIEWS, Megaphone.Style.LINK_PREVIEWS)
|
||||
.setMandatory(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static boolean shouldShowMessageRequestsMegaphone() {
|
||||
return Recipient.self().getProfileName() == ProfileName.EMPTY;
|
||||
}
|
||||
@@ -209,7 +218,8 @@ public final class Megaphones {
|
||||
PINS_FOR_ALL("pins_for_all"),
|
||||
PIN_REMINDER("pin_reminder"),
|
||||
MESSAGE_REQUESTS("message_requests"),
|
||||
MENTIONS("mentions");
|
||||
MENTIONS("mentions"),
|
||||
LINK_PREVIEWS("link_previews");
|
||||
|
||||
private final String key;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user