mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Re-enable and clean up Signal PINs.
- Require PINs during registration agian. - Change min length to 4. - Allow the full-screen megaphone to be enabled remotely. - Clean up and remove some code.
This commit is contained in:
@@ -136,40 +136,20 @@ public final class Megaphones {
|
||||
})
|
||||
.build();
|
||||
} else {
|
||||
Megaphone.Builder builder = new Megaphone.Builder(Event.PINS_FOR_ALL, Megaphone.Style.BASIC)
|
||||
.setMandatory(true)
|
||||
.setImage(R.drawable.kbs_pin_megaphone);
|
||||
return new Megaphone.Builder(Event.PINS_FOR_ALL, Megaphone.Style.BASIC)
|
||||
.setMandatory(true)
|
||||
.setImage(R.drawable.kbs_pin_megaphone)
|
||||
.setTitle(R.string.KbsMegaphone__create_a_pin)
|
||||
.setBody(R.string.KbsMegaphone__pins_add_another_layer_of_security_to_your_signal_account)
|
||||
.setActionButton(R.string.KbsMegaphone__create_pin, (megaphone, listener) -> {
|
||||
Intent intent = CreateKbsPinActivity.getIntentForPinCreate(ApplicationDependencies.getApplication());
|
||||
|
||||
if (PinUtil.userHasPin(ApplicationDependencies.getApplication())) {
|
||||
return buildPinsForAllMegaphoneForUserWithPin(builder.enableSnooze(null));
|
||||
} else {
|
||||
return buildPinsForAllMegaphoneForUserWithoutPin(builder.enableSnooze(null));
|
||||
}
|
||||
listener.onMegaphoneNavigationRequested(intent, CreateKbsPinActivity.REQUEST_NEW_PIN);
|
||||
})
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
private static @NonNull Megaphone buildPinsForAllMegaphoneForUserWithPin(@NonNull Megaphone.Builder builder) {
|
||||
return builder.setTitle(R.string.KbsMegaphone__introducing_pins)
|
||||
.setBody(R.string.KbsMegaphone__your_registration_lock_is_now_called_a_pin)
|
||||
.setActionButton(R.string.KbsMegaphone__update_pin, (megaphone, listener) -> {
|
||||
Intent intent = CreateKbsPinActivity.getIntentForPinChangeFromSettings(ApplicationDependencies.getApplication());
|
||||
|
||||
listener.onMegaphoneNavigationRequested(intent, CreateKbsPinActivity.REQUEST_NEW_PIN);
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
private static @NonNull Megaphone buildPinsForAllMegaphoneForUserWithoutPin(@NonNull Megaphone.Builder builder) {
|
||||
return builder.setTitle(R.string.KbsMegaphone__create_a_pin)
|
||||
.setBody(R.string.KbsMegaphone__pins_add_another_layer_of_security_to_your_signal_account)
|
||||
.setActionButton(R.string.KbsMegaphone__create_pin, (megaphone, listener) -> {
|
||||
Intent intent = CreateKbsPinActivity.getIntentForPinCreate(ApplicationDependencies.getApplication());
|
||||
|
||||
listener.onMegaphoneNavigationRequested(intent, CreateKbsPinActivity.REQUEST_NEW_PIN);
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
private static @NonNull Megaphone buildPinReminderMegaphone(@NonNull Context context) {
|
||||
return new Megaphone.Builder(Event.PIN_REMINDER, Megaphone.Style.BASIC)
|
||||
.setTitle(R.string.Megaphones_verify_your_signal_pin)
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
package org.thoughtcrime.securesms.megaphone;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||
import org.thoughtcrime.securesms.util.CensorshipUtil;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -19,36 +14,25 @@ class PinsForAllSchedule implements MegaphoneSchedule {
|
||||
@VisibleForTesting
|
||||
static final long DAYS_UNTIL_FULLSCREEN = 8L;
|
||||
|
||||
@VisibleForTesting
|
||||
static final long DAYS_REMAINING_MAX = DAYS_UNTIL_FULLSCREEN - 1;
|
||||
|
||||
private final MegaphoneSchedule schedule = new RecurringSchedule(TimeUnit.DAYS.toMillis(2));
|
||||
|
||||
static boolean shouldDisplayFullScreen(long firstVisible, long currentTime) {
|
||||
return false;
|
||||
// TODO [greyson] [pins] Maybe re-enable if we ever do a blocking flow again
|
||||
// if (pinCreationFailedDuringRegistration()) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// if (firstVisible == 0L) {
|
||||
// return false;
|
||||
// } else {
|
||||
// return currentTime - firstVisible >= TimeUnit.DAYS.toMillis(DAYS_UNTIL_FULLSCREEN);
|
||||
// }
|
||||
}
|
||||
|
||||
static long getDaysRemaining(long firstVisible, long currentTime) {
|
||||
if (firstVisible == 0L) {
|
||||
return DAYS_REMAINING_MAX;
|
||||
} else {
|
||||
return Util.clamp(DAYS_REMAINING_MAX - TimeUnit.MILLISECONDS.toDays(currentTime - firstVisible), 0, DAYS_REMAINING_MAX);
|
||||
if (!FeatureFlags.pinsForAllMandatory()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (firstVisible == 0L) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return currentTime - firstVisible >= TimeUnit.DAYS.toMillis(DAYS_UNTIL_FULLSCREEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldDisplay(int seenCount, long lastSeen, long firstVisible, long currentTime) {
|
||||
if (!isEnabled()) return false;
|
||||
if (!isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (shouldDisplayFullScreen(firstVisible, currentTime)) {
|
||||
return true;
|
||||
@@ -58,6 +42,10 @@ class PinsForAllSchedule implements MegaphoneSchedule {
|
||||
}
|
||||
|
||||
private static boolean isEnabled() {
|
||||
if (SignalStore.kbsValues().isV2RegistrationLockEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FeatureFlags.pinsForAllMegaphoneKillSwitch()) {
|
||||
return false;
|
||||
}
|
||||
@@ -74,10 +62,6 @@ class PinsForAllSchedule implements MegaphoneSchedule {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SignalStore.kbsValues().hasMigratedToPinsForAll()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return FeatureFlags.pinsForAll();
|
||||
}
|
||||
|
||||
@@ -87,8 +71,7 @@ class PinsForAllSchedule implements MegaphoneSchedule {
|
||||
!TextSecurePreferences.isV1RegistrationLockEnabled(ApplicationDependencies.getApplication());
|
||||
}
|
||||
|
||||
private static final boolean newlyRegisteredV1PinUser() {
|
||||
private static boolean newlyRegisteredV1PinUser() {
|
||||
return SignalStore.registrationValues().pinWasRequiredAtRegistration() && TextSecurePreferences.isV1RegistrationLockEnabled(ApplicationDependencies.getApplication());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user