mirror of https://github.com/M66B/FairEmail.git
Use number picker for default snooze time
This commit is contained in:
parent
2d4eb2b96b
commit
ca670c6732
|
@ -25,8 +25,6 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -36,7 +34,7 @@ import android.view.ViewGroup;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.NumberPicker;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
@ -50,7 +48,7 @@ import androidx.preference.PreferenceManager;
|
|||
|
||||
public class FragmentOptionsMisc extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private SwitchCompat swDoubleBack;
|
||||
private EditText etDefaultSnooze;
|
||||
private NumberPicker npDefaultSnooze;
|
||||
private Spinner spBiometricsTimeout;
|
||||
private SwitchCompat swEnglish;
|
||||
private SwitchCompat swWatchdog;
|
||||
|
@ -90,7 +88,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
// Get controls
|
||||
|
||||
swDoubleBack = view.findViewById(R.id.swDoubleBack);
|
||||
etDefaultSnooze = view.findViewById(R.id.etDefaultSnooze);
|
||||
npDefaultSnooze = view.findViewById(R.id.npDefaultSnooze);
|
||||
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
|
||||
swEnglish = view.findViewById(R.id.swEnglish);
|
||||
swWatchdog = view.findViewById(R.id.swWatchdog);
|
||||
|
@ -109,6 +107,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
|
||||
grpDebug = view.findViewById(R.id.grpDebug);
|
||||
|
||||
npDefaultSnooze.setMinValue(1);
|
||||
npDefaultSnooze.setMaxValue(999);
|
||||
|
||||
setOptions();
|
||||
|
||||
// Wire controls
|
||||
|
@ -122,22 +123,10 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
}
|
||||
});
|
||||
|
||||
etDefaultSnooze.addTextChangedListener(new TextWatcher() {
|
||||
npDefaultSnooze.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
try {
|
||||
int hours = Integer.parseInt(editable.toString());
|
||||
prefs.edit().putInt("default_snooze", hours).apply();
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
|
||||
prefs.edit().putInt("default_snooze", newVal).apply();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -326,7 +315,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
swDoubleBack.setChecked(prefs.getBoolean("double_back", true));
|
||||
etDefaultSnooze.setText(Integer.toString(prefs.getInt("default_snooze", 1)));
|
||||
npDefaultSnooze.setValue(prefs.getInt("default_snooze", 1));
|
||||
|
||||
int biometrics_timeout = prefs.getInt("biometrics_timeout", 2);
|
||||
int[] biometricTimeoutValues = getResources().getIntArray(R.array.biometricsTimeoutValues);
|
||||
|
|
|
@ -36,25 +36,22 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swDoubleBack" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etDefaultSnooze"
|
||||
android:layout_width="60dp"
|
||||
<NumberPicker
|
||||
android:id="@+id/npDefaultSnooze"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="end"
|
||||
android:inputType="number"
|
||||
android:text="1"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDefaultSnooze" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvDefaultSnooze" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:text="@string/title_hours"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/etDefaultSnooze"
|
||||
app:layout_constraintStart_toEndOf="@+id/etDefaultSnooze"
|
||||
app:layout_constraintTop_toTopOf="@+id/etDefaultSnooze" />
|
||||
app:layout_constraintBottom_toBottomOf="@+id/npDefaultSnooze"
|
||||
app:layout_constraintStart_toEndOf="@+id/npDefaultSnooze"
|
||||
app:layout_constraintTop_toTopOf="@+id/npDefaultSnooze" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBiometricsTimeout"
|
||||
|
@ -67,7 +64,7 @@
|
|||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/etDefaultSnooze" />
|
||||
app:layout_constraintTop_toBottomOf="@id/npDefaultSnooze" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spBiometricsTimeout"
|
||||
|
|
Loading…
Reference in New Issue