mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-21 06:19:12 +00:00
Merge pull request #1429 from r3dh3ck/fix/preferences_result_location
Remove preferences result
This commit is contained in:
commit
29eccaf9cf
9 changed files with 11 additions and 122 deletions
|
@ -38,12 +38,9 @@ import androidx.appcompat.widget.SearchView;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
import com.beemdevelopment.aegis.AccountNamePosition;
|
|
||||||
import com.beemdevelopment.aegis.CopyBehavior;
|
|
||||||
import com.beemdevelopment.aegis.Preferences;
|
import com.beemdevelopment.aegis.Preferences;
|
||||||
import com.beemdevelopment.aegis.R;
|
import com.beemdevelopment.aegis.R;
|
||||||
import com.beemdevelopment.aegis.SortCategory;
|
import com.beemdevelopment.aegis.SortCategory;
|
||||||
import com.beemdevelopment.aegis.ViewMode;
|
|
||||||
import com.beemdevelopment.aegis.helpers.FabScrollHelper;
|
import com.beemdevelopment.aegis.helpers.FabScrollHelper;
|
||||||
import com.beemdevelopment.aegis.helpers.PermissionHelper;
|
import com.beemdevelopment.aegis.helpers.PermissionHelper;
|
||||||
import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
|
import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
|
||||||
|
@ -136,12 +133,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
});
|
});
|
||||||
|
|
||||||
private final ActivityResultLauncher<Intent> preferenceResultLauncher =
|
private final ActivityResultLauncher<Intent> preferenceResultLauncher =
|
||||||
registerForActivityResult(new StartActivityForResult(), activityResult -> {
|
registerForActivityResult(new StartActivityForResult(), activityResult -> onPreferencesResult());
|
||||||
if (activityResult.getResultCode() != RESULT_OK || activityResult.getData() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
onPreferencesResult(activityResult.getData());
|
|
||||||
});
|
|
||||||
|
|
||||||
private final ActivityResultLauncher<Intent> editEntryResultLauncher =
|
private final ActivityResultLauncher<Intent> editEntryResultLauncher =
|
||||||
registerForActivityResult(new StartActivityForResult(), activityResult -> {
|
registerForActivityResult(new StartActivityForResult(), activityResult -> {
|
||||||
|
@ -299,34 +291,10 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPreferencesResult(Intent data) {
|
private void onPreferencesResult() {
|
||||||
// refresh the entire entry list if needed
|
// refresh the entire entry list if needed
|
||||||
if (_loaded) {
|
if (_loaded) {
|
||||||
if (data.getBooleanExtra("needsRecreate", false)) {
|
|
||||||
recreate();
|
recreate();
|
||||||
} else if (data.getBooleanExtra("needsRefresh", false)) {
|
|
||||||
AccountNamePosition accountNamePosition = _prefs.getAccountNamePosition();
|
|
||||||
boolean showIcons = _prefs.isIconVisible();
|
|
||||||
boolean onlyShowNecessaryAccountNames = _prefs.onlyShowNecessaryAccountNames();
|
|
||||||
Preferences.CodeGrouping codeGroupSize = _prefs.getCodeGroupSize();
|
|
||||||
boolean highlightEntry = _prefs.isEntryHighlightEnabled();
|
|
||||||
boolean pauseFocused = _prefs.isPauseFocusedEnabled();
|
|
||||||
boolean tapToReveal = _prefs.isTapToRevealEnabled();
|
|
||||||
int tapToRevealTime = _prefs.getTapToRevealTime();
|
|
||||||
ViewMode viewMode = _prefs.getCurrentViewMode();
|
|
||||||
CopyBehavior copyBehavior = _prefs.getCopyBehavior();
|
|
||||||
_entryListView.setAccountNamePosition(accountNamePosition);
|
|
||||||
_entryListView.setOnlyShowNecessaryAccountNames(onlyShowNecessaryAccountNames);
|
|
||||||
_entryListView.setShowIcon(showIcons);
|
|
||||||
_entryListView.setCodeGroupSize(codeGroupSize);
|
|
||||||
_entryListView.setHighlightEntry(highlightEntry);
|
|
||||||
_entryListView.setPauseFocused(pauseFocused);
|
|
||||||
_entryListView.setTapToReveal(tapToReveal);
|
|
||||||
_entryListView.setTapToRevealTime(tapToRevealTime);
|
|
||||||
_entryListView.setViewMode(viewMode);
|
|
||||||
_entryListView.setCopyBehavior(copyBehavior);
|
|
||||||
_entryListView.refresh(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,7 +839,9 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
_entryListView.setUsageCounts(_prefs.getUsageCounts());
|
_entryListView.setUsageCounts(_prefs.getUsageCounts());
|
||||||
_entryListView.setLastUsedTimestamps(_prefs.getLastUsedTimestamps());
|
_entryListView.setLastUsedTimestamps(_prefs.getLastUsedTimestamps());
|
||||||
_entryListView.addEntries(_vaultManager.getVault().getEntries());
|
_entryListView.addEntries(_vaultManager.getVault().getEntries());
|
||||||
|
if (!_isRecreated) {
|
||||||
_entryListView.runEntriesAnimation();
|
_entryListView.runEntriesAnimation();
|
||||||
|
}
|
||||||
_loaded = true;
|
_loaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,24 +57,8 @@ public class PreferencesActivity extends AegisActivity implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onRestoreInstanceState(@NonNull final Bundle inState) {
|
|
||||||
if (_fragment instanceof PreferencesFragment) {
|
|
||||||
// pass the stored result intent back to the fragment
|
|
||||||
if (inState.containsKey("result")) {
|
|
||||||
((PreferencesFragment) _fragment).setResult(inState.getParcelable("result"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.onRestoreInstanceState(inState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(@NonNull final Bundle outState) {
|
protected void onSaveInstanceState(@NonNull final Bundle outState) {
|
||||||
if (_fragment instanceof PreferencesFragment) {
|
|
||||||
// save the result intent of the fragment
|
|
||||||
// this is done so we don't lose anything if the fragment calls recreate on this activity
|
|
||||||
outState.putParcelable("result", ((PreferencesFragment) _fragment).getResult());
|
|
||||||
}
|
|
||||||
outState.putCharSequence("prefTitle", _prefTitle);
|
outState.putCharSequence("prefTitle", _prefTitle);
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
super.onCreatePreferences(savedInstanceState, rootKey);
|
|
||||||
addPreferencesFromResource(R.xml.preferences_appearance);
|
addPreferencesFromResource(R.xml.preferences_appearance);
|
||||||
|
|
||||||
_groupsPreference = requirePreference("pref_groups");
|
_groupsPreference = requirePreference("pref_groups");
|
||||||
|
@ -62,7 +61,6 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
getResult().putExtra("needsRecreate", true);
|
|
||||||
requireActivity().recreate();
|
requireActivity().recreate();
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
@ -74,7 +72,6 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
|
||||||
Preference dynamicColorsPreference = requirePreference("pref_dynamic_colors");
|
Preference dynamicColorsPreference = requirePreference("pref_dynamic_colors");
|
||||||
dynamicColorsPreference.setEnabled(DynamicColors.isDynamicColorAvailable());
|
dynamicColorsPreference.setEnabled(DynamicColors.isDynamicColorAvailable());
|
||||||
dynamicColorsPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
dynamicColorsPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
getResult().putExtra("needsRecreate", true);
|
|
||||||
requireActivity().recreate();
|
requireActivity().recreate();
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
@ -96,7 +93,6 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
getResult().putExtra("needsRecreate", true);
|
|
||||||
requireActivity().recreate();
|
requireActivity().recreate();
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
@ -120,7 +116,6 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
|
||||||
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
||||||
_prefs.setCurrentViewMode(ViewMode.fromInteger(i));
|
_prefs.setCurrentViewMode(ViewMode.fromInteger(i));
|
||||||
viewModePreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.view_mode_titles)[i]));
|
viewModePreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.view_mode_titles)[i]));
|
||||||
getResult().putExtra("needsRefresh", true);
|
|
||||||
overrideAccountNamePosition(ViewMode.fromInteger(i) == ViewMode.TILES);
|
overrideAccountNamePosition(ViewMode.fromInteger(i) == ViewMode.TILES);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
})
|
})
|
||||||
|
@ -143,19 +138,12 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
|
||||||
_prefs.setCodeGroupSize(Preferences.CodeGrouping.valueOf(codeGroupings[newCodeGroupingIndex]));
|
_prefs.setCodeGroupSize(Preferences.CodeGrouping.valueOf(codeGroupings[newCodeGroupingIndex]));
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
getResult().putExtra("needsRefresh", true);
|
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.create());
|
.create());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
Preference onlyShowNecessaryAccountNames = requirePreference("pref_shared_issuer_account_name");
|
|
||||||
onlyShowNecessaryAccountNames.setOnPreferenceChangeListener((preference, newValue) -> {
|
|
||||||
getResult().putExtra("needsRefresh", true);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
int currentAccountNamePosition = _prefs.getAccountNamePosition().ordinal();
|
int currentAccountNamePosition = _prefs.getAccountNamePosition().ordinal();
|
||||||
_currentAccountNamePositionPreference = requirePreference("pref_account_name_position");
|
_currentAccountNamePositionPreference = requirePreference("pref_account_name_position");
|
||||||
_currentAccountNamePositionPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.account_name_position_titles)[currentAccountNamePosition]));
|
_currentAccountNamePositionPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.account_name_position_titles)[currentAccountNamePosition]));
|
||||||
|
@ -168,7 +156,6 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
|
||||||
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
||||||
_prefs.setAccountNamePosition(AccountNamePosition.fromInteger(i));
|
_prefs.setAccountNamePosition(AccountNamePosition.fromInteger(i));
|
||||||
_currentAccountNamePositionPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.account_name_position_titles)[i]));
|
_currentAccountNamePositionPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.account_name_position_titles)[i]));
|
||||||
getResult().putExtra("needsRefresh", true);
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
@ -177,12 +164,6 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
Preference showIconsPreference = requirePreference("pref_show_icons");
|
|
||||||
showIconsPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
|
||||||
getResult().putExtra("needsRefresh", true);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
overrideAccountNamePosition(_prefs.getCurrentViewMode() == ViewMode.TILES);
|
overrideAccountNamePosition(_prefs.getCurrentViewMode() == ViewMode.TILES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ public class BackupsPreferencesFragment extends PreferencesFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
super.onCreatePreferences(savedInstanceState, rootKey);
|
|
||||||
addPreferencesFromResource(R.xml.preferences_backups);
|
addPreferencesFromResource(R.xml.preferences_backups);
|
||||||
|
|
||||||
_backupsPasswordWarningPreference = requirePreference("pref_backups_warning_password");
|
_backupsPasswordWarningPreference = requirePreference("pref_backups_warning_password");
|
||||||
|
|
|
@ -11,11 +11,9 @@ import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
|
|
||||||
public class BehaviorPreferencesFragment extends PreferencesFragment {
|
public class BehaviorPreferencesFragment extends PreferencesFragment {
|
||||||
private Preference _entryPausePreference;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
super.onCreatePreferences(savedInstanceState, rootKey);
|
|
||||||
addPreferencesFromResource(R.xml.preferences_behavior);
|
addPreferencesFromResource(R.xml.preferences_behavior);
|
||||||
|
|
||||||
int currentCopyBehavior = _prefs.getCopyBehavior().ordinal();
|
int currentCopyBehavior = _prefs.getCopyBehavior().ordinal();
|
||||||
|
@ -30,7 +28,6 @@ public class BehaviorPreferencesFragment extends PreferencesFragment {
|
||||||
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
||||||
_prefs.setCopyBehavior(CopyBehavior.fromInteger(i));
|
_prefs.setCopyBehavior(CopyBehavior.fromInteger(i));
|
||||||
copyBehaviorPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.copy_behavior_titles)[i]));
|
copyBehaviorPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.copy_behavior_titles)[i]));
|
||||||
getResult().putExtra("needsRefresh", true);
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
@ -39,18 +36,13 @@ public class BehaviorPreferencesFragment extends PreferencesFragment {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Preference entryPausePreference = requirePreference("pref_pause_entry");
|
||||||
|
entryPausePreference.setEnabled(_prefs.isTapToRevealEnabled() || _prefs.isEntryHighlightEnabled());
|
||||||
|
|
||||||
Preference entryHighlightPreference = requirePreference("pref_highlight_entry");
|
Preference entryHighlightPreference = requirePreference("pref_highlight_entry");
|
||||||
entryHighlightPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
entryHighlightPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
getResult().putExtra("needsRefresh", true);
|
entryPausePreference.setEnabled(_prefs.isTapToRevealEnabled() || (boolean) newValue);
|
||||||
_entryPausePreference.setEnabled(_prefs.isTapToRevealEnabled() || (boolean) newValue);
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
_entryPausePreference = requirePreference("pref_pause_entry");
|
|
||||||
_entryPausePreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
|
||||||
getResult().putExtra("needsRefresh", true);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
_entryPausePreference.setEnabled(_prefs.isTapToRevealEnabled() || _prefs.isEntryHighlightEnabled());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.beemdevelopment.aegis.BuildConfig;
|
import com.beemdevelopment.aegis.BuildConfig;
|
||||||
import com.beemdevelopment.aegis.R;
|
import com.beemdevelopment.aegis.R;
|
||||||
import com.beemdevelopment.aegis.database.AuditLogRepository;
|
|
||||||
import com.beemdevelopment.aegis.helpers.DropdownHelper;
|
import com.beemdevelopment.aegis.helpers.DropdownHelper;
|
||||||
import com.beemdevelopment.aegis.importers.DatabaseImporter;
|
import com.beemdevelopment.aegis.importers.DatabaseImporter;
|
||||||
import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
|
import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
|
||||||
|
@ -64,18 +63,12 @@ import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
public class ImportExportPreferencesFragment extends PreferencesFragment {
|
public class ImportExportPreferencesFragment extends PreferencesFragment {
|
||||||
// keep a reference to the type of database converter that was selected
|
// keep a reference to the type of database converter that was selected
|
||||||
private DatabaseImporter.Definition _importerDef;
|
private DatabaseImporter.Definition _importerDef;
|
||||||
private Vault.EntryFilter _exportFilter;
|
private Vault.EntryFilter _exportFilter;
|
||||||
|
|
||||||
private final ActivityResultLauncher<Intent> importResultLauncher =
|
|
||||||
registerForActivityResult(new StartActivityForResult(), activityResult -> {
|
|
||||||
getResult().putExtra("needsRecreate", true);
|
|
||||||
});
|
|
||||||
|
|
||||||
private final ActivityResultLauncher<Intent> importSelectResultLauncher =
|
private final ActivityResultLauncher<Intent> importSelectResultLauncher =
|
||||||
registerForActivityResult(new StartActivityForResult(), activityResult -> {
|
registerForActivityResult(new StartActivityForResult(), activityResult -> {
|
||||||
Intent data = activityResult.getData();
|
Intent data = activityResult.getData();
|
||||||
|
@ -102,7 +95,6 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
super.onCreatePreferences(savedInstanceState, rootKey);
|
|
||||||
addPreferencesFromResource(R.xml.preferences_import_export);
|
addPreferencesFromResource(R.xml.preferences_import_export);
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
|
@ -169,7 +161,7 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
|
||||||
Intent intent = new Intent(requireContext(), ImportEntriesActivity.class);
|
Intent intent = new Intent(requireContext(), ImportEntriesActivity.class);
|
||||||
intent.putExtra("importerDef", importerDef);
|
intent.putExtra("importerDef", importerDef);
|
||||||
intent.putExtra("file", file);
|
intent.putExtra("file", file);
|
||||||
importResultLauncher.launch(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startExport() {
|
private void startExport() {
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.beemdevelopment.aegis.R;
|
||||||
public class MainPreferencesFragment extends PreferencesFragment {
|
public class MainPreferencesFragment extends PreferencesFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
super.onCreatePreferences(savedInstanceState, rootKey);
|
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package com.beemdevelopment.aegis.ui.fragments.preferences;
|
package com.beemdevelopment.aegis.ui.fragments.preferences;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
|
|
||||||
import androidx.annotation.CallSuper;
|
import androidx.annotation.CallSuper;
|
||||||
|
@ -31,8 +29,6 @@ public abstract class PreferencesFragment extends PreferenceFragmentCompat {
|
||||||
public static final int CODE_EXPORT_GOOGLE_URI = 7;
|
public static final int CODE_EXPORT_GOOGLE_URI = 7;
|
||||||
public static final int CODE_EXPORT_HTML = 8;
|
public static final int CODE_EXPORT_HTML = 8;
|
||||||
|
|
||||||
private Intent _result;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Preferences _prefs;
|
Preferences _prefs;
|
||||||
|
|
||||||
|
@ -42,12 +38,6 @@ public abstract class PreferencesFragment extends PreferenceFragmentCompat {
|
||||||
@Inject
|
@Inject
|
||||||
protected AuditLogRepository _auditLogRepository;
|
protected AuditLogRepository _auditLogRepository;
|
||||||
|
|
||||||
@Override
|
|
||||||
@CallSuper
|
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
|
||||||
setResult(new Intent());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CallSuper
|
@CallSuper
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
|
@ -61,10 +51,6 @@ public abstract class PreferencesFragment extends PreferenceFragmentCompat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Intent getResult() {
|
|
||||||
return _result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
|
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
|
||||||
|
@ -75,11 +61,6 @@ public abstract class PreferencesFragment extends PreferenceFragmentCompat {
|
||||||
return super.onCreateAnimation(transit, enter, nextAnim);
|
return super.onCreateAnimation(transit, enter, nextAnim);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResult(Intent result) {
|
|
||||||
_result = result;
|
|
||||||
requireActivity().setResult(Activity.RESULT_OK, _result);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean saveAndBackupVault() {
|
protected boolean saveAndBackupVault() {
|
||||||
try {
|
try {
|
||||||
_vaultManager.saveAndBackup();
|
_vaultManager.saveAndBackup();
|
||||||
|
|
|
@ -55,18 +55,10 @@ public class SecurityPreferencesFragment extends PreferencesFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
super.onCreatePreferences(savedInstanceState, rootKey);
|
|
||||||
addPreferencesFromResource(R.xml.preferences_security);
|
addPreferencesFromResource(R.xml.preferences_security);
|
||||||
|
|
||||||
Preference tapToRevealPreference = requirePreference("pref_tap_to_reveal");
|
|
||||||
tapToRevealPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
|
||||||
getResult().putExtra("needsRefresh", true);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
Preference screenPreference = requirePreference("pref_secure_screen");
|
Preference screenPreference = requirePreference("pref_secure_screen");
|
||||||
screenPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
screenPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
getResult().putExtra("needsRecreate", true);
|
|
||||||
Window window = requireActivity().getWindow();
|
Window window = requireActivity().getWindow();
|
||||||
if ((boolean) newValue) {
|
if ((boolean) newValue) {
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||||
|
@ -82,7 +74,6 @@ public class SecurityPreferencesFragment extends PreferencesFragment {
|
||||||
Dialogs.showTapToRevealTimeoutPickerDialog(requireContext(), _prefs.getTapToRevealTime(), number -> {
|
Dialogs.showTapToRevealTimeoutPickerDialog(requireContext(), _prefs.getTapToRevealTime(), number -> {
|
||||||
_prefs.setTapToRevealTime(number);
|
_prefs.setTapToRevealTime(number);
|
||||||
tapToRevealTimePreference.setSummary(number + " seconds");
|
tapToRevealTimePreference.setSummary(number + " seconds");
|
||||||
getResult().putExtra("needsRefresh", true);
|
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue