diff --git a/app/src/main/java/org/thoughtcrime/securesms/keyvalue/RegistrationValues.java b/app/src/main/java/org/thoughtcrime/securesms/keyvalue/RegistrationValues.java index f56c23c6ba..a85be18f28 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/keyvalue/RegistrationValues.java +++ b/app/src/main/java/org/thoughtcrime/securesms/keyvalue/RegistrationValues.java @@ -32,7 +32,7 @@ public final class RegistrationValues { } @CheckResult - public synchronized boolean isPinRequired() { + public synchronized boolean pinWasRequiredAtRegistration() { return store.getBoolean(PIN_REQUIRED, false); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/megaphone/PinsForAllSchedule.java b/app/src/main/java/org/thoughtcrime/securesms/megaphone/PinsForAllSchedule.java index 1c831e1381..bce2442dea 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/megaphone/PinsForAllSchedule.java +++ b/app/src/main/java/org/thoughtcrime/securesms/megaphone/PinsForAllSchedule.java @@ -17,7 +17,6 @@ class PinsForAllSchedule implements MegaphoneSchedule { static final long DAYS_REMAINING_MAX = DAYS_UNTIL_FULLSCREEN - 1; private final MegaphoneSchedule schedule = new RecurringSchedule(TimeUnit.DAYS.toMillis(2)); - private final boolean enabled = !SignalStore.registrationValues().isPinRequired() || FeatureFlags.pinsForAll(); static boolean shouldDisplayFullScreen(long firstVisible, long currentTime) { if (firstVisible == 0L) { @@ -37,7 +36,7 @@ class PinsForAllSchedule implements MegaphoneSchedule { @Override public boolean shouldDisplay(int seenCount, long lastSeen, long firstVisible, long currentTime) { - if (!enabled) return false; + if (!isEnabled()) return false; if (shouldDisplayFullScreen(firstVisible, currentTime)) { return true; @@ -45,4 +44,12 @@ class PinsForAllSchedule implements MegaphoneSchedule { return schedule.shouldDisplay(seenCount, lastSeen, firstVisible, currentTime); } } + + private static boolean isEnabled() { + if (FeatureFlags.pinsForAllMegaphoneKillSwitch() || SignalStore.registrationValues().pinWasRequiredAtRegistration()) { + return false; + } + + return FeatureFlags.pinsForAll(); + } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/FeatureFlags.java b/app/src/main/java/org/thoughtcrime/securesms/util/FeatureFlags.java index d713107f3f..fe3bfbab0c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/FeatureFlags.java +++ b/app/src/main/java/org/thoughtcrime/securesms/util/FeatureFlags.java @@ -46,13 +46,14 @@ public final class FeatureFlags { private static final String PREFIX = "android."; private static final long FETCH_INTERVAL = TimeUnit.HOURS.toMillis(2); - private static final String UUIDS = generateKey("uuids"); - private static final String PROFILE_DISPLAY = generateKey("profileDisplay"); - private static final String MESSAGE_REQUESTS = generateKey("messageRequests"); - private static final String USERNAMES = generateKey("usernames"); - private static final String KBS = generateKey("kbs"); - private static final String STORAGE_SERVICE = generateKey("storageService"); - private static final String PINS_FOR_ALL = generateKey("beta.pinsForAll"); // TODO [alex] remove beta prefix + private static final String UUIDS = generateKey("uuids"); + private static final String PROFILE_DISPLAY = generateKey("profileDisplay"); + private static final String MESSAGE_REQUESTS = generateKey("messageRequests"); + private static final String USERNAMES = generateKey("usernames"); + private static final String KBS = generateKey("kbs"); + private static final String STORAGE_SERVICE = generateKey("storageService"); + private static final String PINS_FOR_ALL = generateKey("beta.pinsForAll"); // TODO [alex] remove beta prefix + private static final String PINS_MEGAPHONE_KILL_SWITCH = generateKey("pinsMegaphoneKillSwitch"); /** * Values in this map will take precedence over any value. If you do not wish to have any sort of @@ -75,7 +76,8 @@ public final class FeatureFlags { * more burden on the reader to ensure that the app experience remains consistent. */ private static final Set HOT_SWAPPABLE = Sets.newHashSet( - KBS + KBS, + PINS_MEGAPHONE_KILL_SWITCH ); /** @@ -159,6 +161,11 @@ public final class FeatureFlags { return SignalStore.registrationValues().pinWasRequiredAtRegistration() || getValue(PINS_FOR_ALL, false); } + /** Safety flag to disable Pins for All Megaphone */ + public static boolean pinsForAllMegaphoneKillSwitch() { + return getValue(PINS_MEGAPHONE_KILL_SWITCH, false); + } + /** Only for rendering debug info. */ public static synchronized @NonNull Map getRemoteValues() { return new TreeMap<>(REMOTE_VALUES);