Reorganized options

pull/164/head
M66B 5 years ago
parent d0a328c607
commit 57e9a92fee

@ -30,6 +30,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.CompoundButton;
import android.widget.NumberPicker;
import android.widget.Spinner;
import android.widget.Toast;
@ -40,6 +41,7 @@ import androidx.lifecycle.Lifecycle;
import androidx.preference.PreferenceManager;
public class FragmentOptionsBehavior extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private SwitchCompat swDoubleBack;
private SwitchCompat swPull;
private SwitchCompat swAutoScroll;
private SwitchCompat swDoubleTap;
@ -55,11 +57,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swAutoUnflag;
private SwitchCompat swAutoMove;
private SwitchCompat swDiscardDelete;
private NumberPicker npDefaultSnooze;
private final static String[] RESET_OPTIONS = new String[]{
"pull", "autoscroll", "doubletap", "swipenav", "reversed",
"double_back", "pull", "autoscroll", "doubletap", "swipenav", "reversed",
"autoexpand", "expand_all", "expand_one", "collapse_multiple",
"autoclose", "onclose", "autoread", "autounflag", "automove", "discard_delete"
"autoclose", "onclose", "autoread", "autounflag", "automove", "discard_delete",
"default_snooze"
};
@Override
@ -72,6 +76,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
// Get controls
swDoubleBack = view.findViewById(R.id.swDoubleBack);
swPull = view.findViewById(R.id.swPull);
swAutoScroll = view.findViewById(R.id.swAutoScroll);
swDoubleTap = view.findViewById(R.id.swDoubleTap);
@ -87,6 +92,10 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swAutoUnflag = view.findViewById(R.id.swAutoUnflag);
swAutoMove = view.findViewById(R.id.swAutoMove);
swDiscardDelete = view.findViewById(R.id.swDiscardDelete);
npDefaultSnooze = view.findViewById(R.id.npDefaultSnooze);
npDefaultSnooze.setMinValue(1);
npDefaultSnooze.setMaxValue(999);
setOptions();
@ -94,6 +103,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
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();
}
});
swPull.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -213,6 +229,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
}
});
npDefaultSnooze.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
prefs.edit().putInt("default_snooze", newVal).apply();
}
});
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
return view;
@ -259,6 +282,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private void setOptions() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
swDoubleBack.setChecked(prefs.getBoolean("double_back", true));
swPull.setChecked(prefs.getBoolean("pull", true));
swAutoScroll.setChecked(prefs.getBoolean("autoscroll", true));
swDoubleTap.setChecked(prefs.getBoolean("doubletap", false));
@ -288,5 +312,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swAutoUnflag.setChecked(prefs.getBoolean("autounflag", false));
swAutoMove.setChecked(!prefs.getBoolean("automove", false));
swDiscardDelete.setChecked(prefs.getBoolean("discard_delete", false));
npDefaultSnooze.setValue(prefs.getInt("default_snooze", 1));
}
}

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

@ -27,7 +27,9 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.CompoundButton;
import android.widget.Spinner;
import android.widget.Toast;
import androidx.annotation.NonNull;
@ -40,9 +42,10 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
private SwitchCompat swDisableTracking;
private SwitchCompat swDisplayHidden;
private SwitchCompat swNoHistory;
private Spinner spBiometricsTimeout;
private final static String[] RESET_OPTIONS = new String[]{
"disable_tracking", "display_hidden", "no_history"
"disable_tracking", "display_hidden", "no_history", "biometrics_timeout"
};
@Override
@ -58,6 +61,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
swDisableTracking = view.findViewById(R.id.swDisableTracking);
swDisplayHidden = view.findViewById(R.id.swDisplayHidden);
swNoHistory = view.findViewById(R.id.swNoHistory);
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
setOptions();
@ -87,6 +91,19 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
}
});
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();
}
});
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
return view;
@ -136,5 +153,13 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
swDisableTracking.setChecked(prefs.getBoolean("disable_tracking", true));
swDisplayHidden.setChecked(prefs.getBoolean("display_hidden", false));
swNoHistory.setChecked(prefs.getBoolean("no_history", false));
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;
}
}
}

@ -12,15 +12,27 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDoubleBack"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/title_advanced_double_back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swPull"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_pull_refresh"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDoubleBack"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
@ -215,5 +227,36 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAutoMove"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvDefaultSnooze"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_default_snooze"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDiscardDelete" />
<NumberPicker
android:id="@+id/npDefaultSnooze"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvDefaultSnooze" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:text="@string/title_hours"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintBottom_toBottomOf="@+id/npDefaultSnooze"
app:layout_constraintStart_toEndOf="@+id/npDefaultSnooze"
app:layout_constraintTop_toTopOf="@+id/npDefaultSnooze" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

@ -12,78 +12,14 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDoubleBack"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/title_advanced_double_back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvDefaultSnooze"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_default_snooze"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDoubleBack" />
<NumberPicker
android:id="@+id/npDefaultSnooze"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvDefaultSnooze" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:text="@string/title_hours"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintBottom_toBottomOf="@+id/npDefaultSnooze"
app:layout_constraintStart_toEndOf="@+id/npDefaultSnooze"
app:layout_constraintTop_toTopOf="@+id/npDefaultSnooze" />
<TextView
android:id="@+id/tvBiometricsTimeout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_biometrics_timeout"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/npDefaultSnooze" />
<Spinner
android:id="@+id/spBiometricsTimeout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:entries="@array/biometricsTimeoutNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swEnglish"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_english"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spBiometricsTimeout"
app:layout_constraintTop_toTopOf="parent"
app:switchPadding="12dp" />
<TextView

@ -68,5 +68,27 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNoHistory" />
<TextView
android:id="@+id/tvBiometricsTimeout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_biometrics_timeout"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNoHistoryHint" />
<Spinner
android:id="@+id/spBiometricsTimeout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:entries="@array/biometricsTimeoutNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

Loading…
Cancel
Save