mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-24 10:51:27 +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:
@@ -154,7 +154,7 @@ public final class RegistrationLockDialog {
|
||||
if (s == null) return;
|
||||
String pin = s.toString();
|
||||
if (TextUtils.isEmpty(pin)) return;
|
||||
if (pin.length() < KbsConstants.LEGACY_MINIMUM_PIN_LENGTH) return;
|
||||
if (pin.length() < KbsConstants.MINIMUM_PIN_LENGTH) return;
|
||||
|
||||
if (PinHashing.verifyLocalPinHash(localPinHash, pin)) {
|
||||
dialog.dismiss();
|
||||
@@ -186,9 +186,9 @@ public final class RegistrationLockDialog {
|
||||
String pinValue = pin.getText().toString().replace(" ", "");
|
||||
String repeatValue = repeat.getText().toString().replace(" ", "");
|
||||
|
||||
if (pinValue.length() < KbsConstants.LEGACY_MINIMUM_PIN_LENGTH) {
|
||||
if (pinValue.length() < KbsConstants.MINIMUM_PIN_LENGTH) {
|
||||
Toast.makeText(context,
|
||||
context.getString(R.string.RegistrationLockDialog_the_registration_lock_pin_must_be_at_least_d_digits, KbsConstants.LEGACY_MINIMUM_PIN_LENGTH),
|
||||
context.getString(R.string.RegistrationLockDialog_the_registration_lock_pin_must_be_at_least_d_digits, KbsConstants.MINIMUM_PIN_LENGTH),
|
||||
Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public final class SignalPinReminderDialog {
|
||||
}
|
||||
});
|
||||
|
||||
switch (SignalStore.kbsValues().getKeyboardType()) {
|
||||
switch (SignalStore.pinValues().getKeyboardType()) {
|
||||
case NUMERIC:
|
||||
pinEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
|
||||
break;
|
||||
@@ -115,7 +115,7 @@ public final class SignalPinReminderDialog {
|
||||
pinEditText.addTextChangedListener(new SimpleTextWatcher() {
|
||||
@Override
|
||||
public void onTextChanged(String text) {
|
||||
if (text.length() >= KbsConstants.minimumPossiblePinLength()) {
|
||||
if (text.length() >= KbsConstants.MINIMUM_PIN_LENGTH) {
|
||||
submit.setEnabled(true);
|
||||
} else {
|
||||
submit.setEnabled(false);
|
||||
@@ -192,7 +192,7 @@ public final class SignalPinReminderDialog {
|
||||
if (pin == null) return;
|
||||
if (TextUtils.isEmpty(pin)) return;
|
||||
|
||||
if (pin.length() < KbsConstants.minimumPossiblePinLength()) return;
|
||||
if (pin.length() < KbsConstants.MINIMUM_PIN_LENGTH) return;
|
||||
|
||||
if (PinHashing.verifyLocalPinHash(localPinHash, pin)) {
|
||||
callback.onPinCorrect();
|
||||
|
||||
@@ -48,7 +48,7 @@ final class ConfirmKbsPinRepository {
|
||||
TextSecurePreferences.clearOldRegistrationLockPin(context);
|
||||
TextSecurePreferences.setRegistrationLockLastReminderTime(context, System.currentTimeMillis());
|
||||
TextSecurePreferences.setRegistrationLockNextReminderInterval(context, RegistrationLockReminders.INITIAL_INTERVAL);
|
||||
SignalStore.kbsValues().setKeyboardType(keyboard);
|
||||
SignalStore.pinValues().setKeyboardType(keyboard);
|
||||
ApplicationDependencies.getMegaphoneRepository().markFinished(Megaphones.Event.PINS_FOR_ALL);
|
||||
|
||||
Log.i(TAG, "Pin set on KBS");
|
||||
|
||||
@@ -2,12 +2,7 @@ package org.thoughtcrime.securesms.lock.v2;
|
||||
|
||||
public final class KbsConstants {
|
||||
|
||||
public static final int MINIMUM_PIN_LENGTH = 6;
|
||||
public static final int LEGACY_MINIMUM_PIN_LENGTH = 4;
|
||||
public static final int MINIMUM_PIN_LENGTH = 4;
|
||||
|
||||
private KbsConstants() { }
|
||||
|
||||
public static int minimumPossiblePinLength() {
|
||||
return LEGACY_MINIMUM_PIN_LENGTH;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,4 @@ public final class PinUtil {
|
||||
public static boolean userHasPin(@NonNull Context context) {
|
||||
return TextSecurePreferences.isV1RegistrationLockEnabled(context) || SignalStore.kbsValues().isV2RegistrationLockEnabled();
|
||||
}
|
||||
|
||||
public static boolean shouldShowPinCreationDuringRegistration(@NonNull Context context) {
|
||||
return FeatureFlags.pinsForAll() && !PinUtil.userHasPin(context);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user