fix: Auto Lock Immediately

Co-authored-by: =?UTF-8?q?=E4=B8=96=E7=95=8C?= <sekai@neko.services>
This commit is contained in:
xtaodada 2022-10-15 21:32:57 +08:00
parent cb5621bc6d
commit 4729c8f3c9
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -315,28 +315,32 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
builder.setTitle(LocaleController.getString("AutoLock", R.string.AutoLock)); builder.setTitle(LocaleController.getString("AutoLock", R.string.AutoLock));
final NumberPicker numberPicker = new NumberPicker(getParentActivity()); final NumberPicker numberPicker = new NumberPicker(getParentActivity());
numberPicker.setMinValue(0); numberPicker.setMinValue(0);
numberPicker.setMaxValue(4); numberPicker.setMaxValue(5);
if (SharedConfig.autoLockIn == 0) { if (SharedConfig.autoLockIn == 0) {
numberPicker.setValue(0); numberPicker.setValue(0);
} else if (SharedConfig.autoLockIn == 60) { } else if (SharedConfig.autoLockIn == 1) {
numberPicker.setValue(1); numberPicker.setValue(1);
} else if (SharedConfig.autoLockIn == 60 * 5) { } else if (SharedConfig.autoLockIn == 60) {
numberPicker.setValue(2); numberPicker.setValue(2);
} else if (SharedConfig.autoLockIn == 60 * 60) { } else if (SharedConfig.autoLockIn == 60 * 5) {
numberPicker.setValue(3); numberPicker.setValue(3);
} else if (SharedConfig.autoLockIn == 60 * 60 * 5) { } else if (SharedConfig.autoLockIn == 60 * 60) {
numberPicker.setValue(4); numberPicker.setValue(4);
} else if (SharedConfig.autoLockIn == 60 * 60 * 5) {
numberPicker.setValue(5);
} }
numberPicker.setFormatter(value -> { numberPicker.setFormatter(value -> {
if (value == 0) { if (value == 0) {
return LocaleController.getString("AutoLockDisabled", R.string.AutoLockDisabled); return LocaleController.getString("AutoLockDisabled", R.string.AutoLockDisabled);
} else if (value == 1) { } else if (value == 1) {
return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 1)); return LocaleController.getString("AutoLockImmediately", R.string.AutoLockImmediately);
} else if (value == 2) { } else if (value == 2) {
return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 5)); return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 1));
} else if (value == 3) { } else if (value == 3) {
return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 1)); return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 5));
} else if (value == 4) { } else if (value == 4) {
return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 1));
} else if (value == 5) {
return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 5)); return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 5));
} }
return ""; return "";
@ -347,12 +351,14 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
if (which == 0) { if (which == 0) {
SharedConfig.autoLockIn = 0; SharedConfig.autoLockIn = 0;
} else if (which == 1) { } else if (which == 1) {
SharedConfig.autoLockIn = 60; SharedConfig.autoLockIn = 1;
} else if (which == 2) { } else if (which == 2) {
SharedConfig.autoLockIn = 60 * 5; SharedConfig.autoLockIn = 60;
} else if (which == 3) { } else if (which == 3) {
SharedConfig.autoLockIn = 60 * 60; SharedConfig.autoLockIn = 60 * 5;
} else if (which == 4) { } else if (which == 4) {
SharedConfig.autoLockIn = 60 * 60;
} else if (which == 5) {
SharedConfig.autoLockIn = 60 * 60 * 5; SharedConfig.autoLockIn = 60 * 60 * 5;
} }
listAdapter.notifyItemChanged(position); listAdapter.notifyItemChanged(position);