wait to load security settings until successful authentication (#1196)

This commit is contained in:
Patrick Demers 2022-11-02 07:11:46 -05:00 committed by GitHub
parent 9b4ee0018e
commit 9703a46f5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -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);
}

View File

@ -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();