mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 12:18:38 +00:00
Fix crash in getIntentForPinCreate(), show 'Create' in prefs.
This commit is contained in:
parent
835ef02872
commit
77caa9e9d4
@ -26,14 +26,16 @@ public class CreateKbsPinActivity extends BaseActionBarActivity {
|
||||
private final DynamicTheme dynamicTheme = new DynamicRegistrationTheme();
|
||||
|
||||
public static Intent getIntentForPinCreate(@NonNull Context context) {
|
||||
return new Intent(context, CreateKbsPinActivity.class);
|
||||
return getIntent(context, true);
|
||||
}
|
||||
|
||||
public static Intent getIntentForPinUpdate(@NonNull Context context) {
|
||||
Intent intent = getIntentForPinCreate(context);
|
||||
|
||||
intent.putExtra(IS_NEW_PIN, true);
|
||||
return getIntent(context, false);
|
||||
}
|
||||
|
||||
private static Intent getIntent(@NonNull Context context, boolean isNewPin) {
|
||||
Intent intent = new Intent(context, CreateKbsPinActivity.class);
|
||||
intent.putExtra(IS_NEW_PIN, isNewPin);
|
||||
return intent;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@ -23,7 +24,6 @@ import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceConfigurationUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.lock.RegistrationLockDialog;
|
||||
import org.thoughtcrime.securesms.lock.v2.CreateKbsPinActivity;
|
||||
import org.thoughtcrime.securesms.lock.v2.PinUtil;
|
||||
@ -56,8 +56,16 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment
|
||||
Preference kbsGroup = this.findPreference("prefs_lock_v2");
|
||||
|
||||
if (FeatureFlags.pinsForAll()) {
|
||||
Preference preference = this.findPreference("pref_kbs_change");
|
||||
regGroup.setVisible(false);
|
||||
kbsPinChange.setOnPreferenceClickListener(new KbsPinChangeListener());
|
||||
|
||||
if (PinUtil.userHasPin(ApplicationDependencies.getApplication())) {
|
||||
kbsPinChange.setOnPreferenceClickListener(new KbsPinUpdateListener());
|
||||
preference.setWidgetLayoutResource(R.layout.kbs_pin_change_preference);
|
||||
} else {
|
||||
kbsPinChange.setOnPreferenceClickListener(new KbsPinCreateListener());
|
||||
preference.setWidgetLayoutResource(R.layout.kbs_pin_create_preference);
|
||||
}
|
||||
} else {
|
||||
kbsGroup.setVisible(false);
|
||||
regLock.setChecked(PinUtil.userHasPin(requireContext()));
|
||||
@ -171,7 +179,7 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment
|
||||
}
|
||||
}
|
||||
|
||||
private class KbsPinChangeListener implements Preference.OnPreferenceClickListener {
|
||||
private class KbsPinUpdateListener implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
startActivityForResult(CreateKbsPinActivity.getIntentForPinUpdate(requireContext()), CreateKbsPinActivity.REQUEST_NEW_PIN);
|
||||
@ -179,6 +187,14 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment
|
||||
}
|
||||
}
|
||||
|
||||
private class KbsPinCreateListener implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
startActivityForResult(CreateKbsPinActivity.getIntentForPinCreate(requireContext()), CreateKbsPinActivity.REQUEST_NEW_PIN);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class AccountLockClickListener implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
|
10
app/src/main/res/layout/kbs_pin_create_preference.xml
Normal file
10
app/src/main/res/layout/kbs_pin_create_preference.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Button xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
android:text="@string/preferences_app_protection__create" />
|
@ -1851,6 +1851,7 @@
|
||||
<string name="preferences_app_protection__signal_pin">Signal PIN</string>
|
||||
<string name="preferences_app_protection__pin">PIN</string>
|
||||
<string name="preferences_app_protection__change">Change</string>
|
||||
<string name="preferences_app_protection__create">Create</string>
|
||||
<string name="preferences_app_protection__your_pin_adds_an_extra_layer_of_security_and_backs">Your PIN adds an extra layer of security and backs up your account. You\'ll be asked for it when you register your phone number with Signal. If you forget your PIN, you\'ll be locked out of your account for 7 days.</string>
|
||||
<string name="AppProtectionPreferenceFragment_none">None</string>
|
||||
<string name="registration_activity__the_registration_lock_pin_is_not_the_same_as_the_sms_verification_code_you_just_received_please_enter_the_pin_you_previously_configured_in_the_application">The Registration Lock PIN is not the same as the SMS verification code you just received. Please enter the PIN you previously configured in the application.</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user