aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml
diff options
context:
space:
mode:
authorPatrick Demers <patrickdemers6@gmail.com>2022-11-02 12:11:46 +0000
committerGitHub <noreply@github.com>2022-11-02 12:11:46 +0000
commit9703a46f5fcdf6973ee19c43ca20d053aef80176 (patch)
tree8c6242911ef03218ee03d19710272379c2eeda5f /app/src/main/java/ml
parent9b4ee0018e0e6cf06f9a8ed1dacef216b0ecd473 (diff)
downloadinfinity-for-reddit-9703a46f5fcdf6973ee19c43ca20d053aef80176.tar
infinity-for-reddit-9703a46f5fcdf6973ee19c43ca20d053aef80176.tar.gz
infinity-for-reddit-9703a46f5fcdf6973ee19c43ca20d053aef80176.tar.bz2
infinity-for-reddit-9703a46f5fcdf6973ee19c43ca20d053aef80176.tar.lz
infinity-for-reddit-9703a46f5fcdf6973ee19c43ca20d053aef80176.tar.xz
infinity-for-reddit-9703a46f5fcdf6973ee19c43ca20d053aef80176.tar.zst
infinity-for-reddit-9703a46f5fcdf6973ee19c43ca20d053aef80176.zip
wait to load security settings until successful authentication (#1196)
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CustomFontPreferenceFragmentCompat.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/SecurityPreferenceFragment.java12
2 files changed, 19 insertions, 2 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CustomFontPreferenceFragmentCompat.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CustomFontPreferenceFragmentCompat.java
index 695131cf..3357918a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CustomFontPreferenceFragmentCompat.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CustomFontPreferenceFragmentCompat.java
@@ -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);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/SecurityPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/SecurityPreferenceFragment.java
index a1d49a82..b62a6b98 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/SecurityPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/SecurityPreferenceFragment.java
@@ -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);
@@ -81,6 +87,12 @@ public class SecurityPreferenceFragment extends CustomFontPreferenceFragmentComp
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();
}