mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-02 15:17:03 +02:00
Reorganized options
This commit is contained in:
@@ -31,11 +31,8 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.NumberPicker;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -47,9 +44,6 @@ import androidx.lifecycle.Lifecycle;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
public class FragmentOptionsMisc extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private SwitchCompat swDoubleBack;
|
||||
private NumberPicker npDefaultSnooze;
|
||||
private Spinner spBiometricsTimeout;
|
||||
private SwitchCompat swEnglish;
|
||||
private SwitchCompat swWatchdog;
|
||||
private SwitchCompat swUpdates;
|
||||
@@ -69,7 +63,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
private Group grpDebug;
|
||||
|
||||
private final static String[] RESET_OPTIONS = new String[]{
|
||||
"double_back", "default_snooze", "biometrics_timeout", "english", "watchdog", "updates", "experiments", "crash_reports", "debug"
|
||||
"english", "watchdog", "updates", "experiments", "crash_reports", "debug"
|
||||
};
|
||||
|
||||
private final static String[] RESET_QUESTIONS = new String[]{
|
||||
@@ -88,9 +82,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
|
||||
// Get controls
|
||||
|
||||
swDoubleBack = view.findViewById(R.id.swDoubleBack);
|
||||
npDefaultSnooze = view.findViewById(R.id.npDefaultSnooze);
|
||||
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
|
||||
swEnglish = view.findViewById(R.id.swEnglish);
|
||||
swWatchdog = view.findViewById(R.id.swWatchdog);
|
||||
swUpdates = view.findViewById(R.id.swUpdates);
|
||||
@@ -109,42 +100,12 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
|
||||
grpDebug = view.findViewById(R.id.grpDebug);
|
||||
|
||||
npDefaultSnooze.setMinValue(1);
|
||||
npDefaultSnooze.setMaxValue(999);
|
||||
|
||||
setOptions();
|
||||
|
||||
// Wire controls
|
||||
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
swDoubleBack.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("double_back", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
npDefaultSnooze.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
|
||||
prefs.edit().putInt("default_snooze", newVal).apply();
|
||||
}
|
||||
});
|
||||
|
||||
spBiometricsTimeout.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
|
||||
int[] values = getResources().getIntArray(R.array.biometricsTimeoutValues);
|
||||
prefs.edit().putInt("biometrics_timeout", values[position]).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
prefs.edit().remove("biometrics_timeout").apply();
|
||||
}
|
||||
});
|
||||
|
||||
swEnglish.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
@@ -316,17 +277,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
private void setOptions() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
swDoubleBack.setChecked(prefs.getBoolean("double_back", true));
|
||||
npDefaultSnooze.setValue(prefs.getInt("default_snooze", 1));
|
||||
|
||||
int biometrics_timeout = prefs.getInt("biometrics_timeout", 2);
|
||||
int[] biometricTimeoutValues = getResources().getIntArray(R.array.biometricsTimeoutValues);
|
||||
for (int pos = 0; pos < biometricTimeoutValues.length; pos++)
|
||||
if (biometricTimeoutValues[pos] == biometrics_timeout) {
|
||||
spBiometricsTimeout.setSelection(pos);
|
||||
break;
|
||||
}
|
||||
|
||||
swEnglish.setChecked(prefs.getBoolean("english", false));
|
||||
swWatchdog.setChecked(prefs.getBoolean("watchdog", true));
|
||||
swUpdates.setChecked(prefs.getBoolean("updates", true));
|
||||
|
||||
Reference in New Issue
Block a user