mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
wait to load security settings until successful authentication (#1196)
This commit is contained in:
parent
9b4ee0018e
commit
9703a46f5f
@ -8,6 +8,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
|
||||
import ml.docilealligator.infinityforreddit.CustomThemeWrapperReceiver;
|
||||
@ -20,9 +21,13 @@ public abstract class CustomFontPreferenceFragmentCompat extends PreferenceFragm
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
int preferenceCount = getPreferenceScreen().getPreferenceCount();
|
||||
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||
if (preferenceScreen == null)
|
||||
return;
|
||||
|
||||
int preferenceCount = preferenceScreen.getPreferenceCount();
|
||||
for (int i = 0; i < preferenceCount; i++) {
|
||||
Preference preference = getPreferenceScreen().getPreference(i);
|
||||
Preference preference = preferenceScreen.getPreference(i);
|
||||
if (preference instanceof CustomThemeWrapperReceiver) {
|
||||
((CustomThemeWrapperReceiver) preference).setCustomThemeWrapper(activity.customThemeWrapper);
|
||||
}
|
||||
|
@ -34,8 +34,14 @@ public class SecurityPreferenceFragment extends CustomFontPreferenceFragmentComp
|
||||
@Named("default")
|
||||
SharedPreferences sharedPreferences;
|
||||
|
||||
String rootKey;
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
this.rootKey = rootKey;
|
||||
}
|
||||
|
||||
private void createPreferences() {
|
||||
PreferenceManager preferenceManager = getPreferenceManager();
|
||||
preferenceManager.setSharedPreferencesName(SharedPreferencesUtils.SECURITY_SHARED_PREFERENCES_FILE);
|
||||
setPreferencesFromResource(R.xml.security_preferences, rootKey);
|
||||
@ -80,6 +86,12 @@ public class SecurityPreferenceFragment extends CustomFontPreferenceFragmentComp
|
||||
Executor executor = ContextCompat.getMainExecutor(activity);
|
||||
BiometricPrompt biometricPrompt = new BiometricPrompt(SecurityPreferenceFragment.this,
|
||||
executor, new BiometricPrompt.AuthenticationCallback() {
|
||||
@Override
|
||||
public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult result) {
|
||||
super.onAuthenticationSucceeded(result);
|
||||
createPreferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthenticationError(int errorCode, @NonNull CharSequence errString) {
|
||||
activity.onBackPressed();
|
||||
|
Loading…
Reference in New Issue
Block a user