Don't show the link preview megaphone if previously disabled.
This commit is contained in:
parent
29b8fa5897
commit
08d5df70c2
2 changed files with 16 additions and 5 deletions
|
@ -23,6 +23,7 @@ import org.thoughtcrime.securesms.messagerequests.MessageRequestMegaphoneActivit
|
||||||
import org.thoughtcrime.securesms.profiles.ProfileName;
|
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -54,7 +55,7 @@ public final class Megaphones {
|
||||||
static @Nullable Megaphone getNextMegaphone(@NonNull Context context, @NonNull Map<Event, MegaphoneRecord> records) {
|
static @Nullable Megaphone getNextMegaphone(@NonNull Context context, @NonNull Map<Event, MegaphoneRecord> records) {
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
|
|
||||||
List<Megaphone> megaphones = Stream.of(buildDisplayOrder())
|
List<Megaphone> megaphones = Stream.of(buildDisplayOrder(context))
|
||||||
.filter(e -> {
|
.filter(e -> {
|
||||||
MegaphoneRecord record = Objects.requireNonNull(records.get(e.getKey()));
|
MegaphoneRecord record = Objects.requireNonNull(records.get(e.getKey()));
|
||||||
MegaphoneSchedule schedule = e.getValue();
|
MegaphoneSchedule schedule = e.getValue();
|
||||||
|
@ -84,14 +85,14 @@ public final class Megaphones {
|
||||||
* This is when you would hide certain megaphones based on {@link FeatureFlags}. You could
|
* This is when you would hide certain megaphones based on {@link FeatureFlags}. You could
|
||||||
* conditionally set a {@link ForeverSchedule} set to false for disabled features.
|
* conditionally set a {@link ForeverSchedule} set to false for disabled features.
|
||||||
*/
|
*/
|
||||||
private static Map<Event, MegaphoneSchedule> buildDisplayOrder() {
|
private static Map<Event, MegaphoneSchedule> buildDisplayOrder(@NonNull Context context) {
|
||||||
return new LinkedHashMap<Event, MegaphoneSchedule>() {{
|
return new LinkedHashMap<Event, MegaphoneSchedule>() {{
|
||||||
put(Event.REACTIONS, ALWAYS);
|
put(Event.REACTIONS, ALWAYS);
|
||||||
put(Event.PINS_FOR_ALL, new PinsForAllSchedule());
|
put(Event.PINS_FOR_ALL, new PinsForAllSchedule());
|
||||||
put(Event.PIN_REMINDER, new SignalPinReminderSchedule());
|
put(Event.PIN_REMINDER, new SignalPinReminderSchedule());
|
||||||
put(Event.MESSAGE_REQUESTS, shouldShowMessageRequestsMegaphone() ? ALWAYS : NEVER);
|
put(Event.MESSAGE_REQUESTS, shouldShowMessageRequestsMegaphone() ? ALWAYS : NEVER);
|
||||||
put(Event.MENTIONS, shouldShowMentionsMegaphone() ? ALWAYS : NEVER);
|
put(Event.MENTIONS, shouldShowMentionsMegaphone() ? ALWAYS : NEVER);
|
||||||
put(Event.LINK_PREVIEWS, SignalStore.settings().isLinkPreviewsEnabled() ? NEVER : ALWAYS);
|
put(Event.LINK_PREVIEWS, shouldShowLinkPreviewsMegaphone(context) ? ALWAYS : NEVER);
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +214,10 @@ public final class Megaphones {
|
||||||
return FeatureFlags.mentions() && FeatureFlags.groupsV2();
|
return FeatureFlags.mentions() && FeatureFlags.groupsV2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean shouldShowLinkPreviewsMegaphone(@NonNull Context context) {
|
||||||
|
return TextSecurePreferences.wereLinkPreviewsEnabled(context) && !SignalStore.settings().isLinkPreviewsEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
public enum Event {
|
public enum Event {
|
||||||
REACTIONS("reactions"),
|
REACTIONS("reactions"),
|
||||||
PINS_FOR_ALL("pins_for_all"),
|
PINS_FOR_ALL("pins_for_all"),
|
||||||
|
|
|
@ -16,6 +16,7 @@ import androidx.core.app.NotificationCompat;
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraintObserver;
|
import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraintObserver;
|
||||||
|
import org.thoughtcrime.securesms.keyvalue.SettingsValues;
|
||||||
import org.thoughtcrime.securesms.lock.RegistrationLockReminders;
|
import org.thoughtcrime.securesms.lock.RegistrationLockReminders;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
|
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
|
||||||
|
@ -419,8 +420,13 @@ public class TextSecurePreferences {
|
||||||
setBooleanPreference(context, TYPING_INDICATORS, enabled);
|
setBooleanPreference(context, TYPING_INDICATORS, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLinkPreviewsEnabled(Context context, boolean enabled) {
|
/**
|
||||||
setBooleanPreference(context, LINK_PREVIEWS, enabled);
|
* Only kept so that we can avoid showing the megaphone for the new link previews setting
|
||||||
|
* ({@link SettingsValues#isLinkPreviewsEnabled()}) when users upgrade. This can be removed after
|
||||||
|
* we stop showing the link previews megaphone.
|
||||||
|
*/
|
||||||
|
public static boolean wereLinkPreviewsEnabled(Context context) {
|
||||||
|
return getBooleanPreference(context, LINK_PREVIEWS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isGifSearchInGridLayout(Context context) {
|
public static boolean isGifSearchInGridLayout(Context context) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue