1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-07-04 11:13:36 +00:00

Option to auto lock immediately

This commit is contained in:
世界 2021-04-13 13:04:49 +08:00
parent 865e4b9b9a
commit a0bce539d3
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
6 changed files with 28 additions and 15 deletions

View File

@ -2116,7 +2116,7 @@ public class AndroidUtilities {
FileLog.d("wasInBackground = " + wasInBackground + " appLocked = " + SharedConfig.appLocked + " autoLockIn = " + SharedConfig.autoLockIn + " lastPauseTime = " + SharedConfig.lastPauseTime + " uptime = " + uptime);
}
return SharedConfig.passcodeHash.length() > 0 && wasInBackground &&
(SharedConfig.appLocked ||
(SharedConfig.appLocked || SharedConfig.autoLockIn == 1 ||
SharedConfig.autoLockIn != 0 && SharedConfig.lastPauseTime != 0 && !SharedConfig.appLocked && (SharedConfig.lastPauseTime + SharedConfig.autoLockIn) <= uptime ||
uptime + 5 < SharedConfig.lastPauseTime);
}

View File

@ -269,7 +269,11 @@ public class BubbleActivity extends Activity implements ActionBarLayout.ActionBa
if (SharedConfig.appLocked) {
AndroidUtilities.runOnUIThread(lockRunnable, 1000);
} else if (SharedConfig.autoLockIn != 0) {
AndroidUtilities.runOnUIThread(lockRunnable, (long) SharedConfig.autoLockIn * 1000 + 1000);
if (SharedConfig.autoLockIn == 1) {
AndroidUtilities.runOnUIThread(lockRunnable, 1000);
} else {
AndroidUtilities.runOnUIThread(lockRunnable, (long) SharedConfig.autoLockIn * 1000 + 1000);
}
}
} else {
SharedConfig.lastPauseTime = 0;

View File

@ -566,7 +566,7 @@ public class ExternalActionActivity extends Activity implements ActionBarLayout.
}
}
};
if (SharedConfig.appLocked) {
if (SharedConfig.appLocked || SharedConfig.autoLockIn == 1) {
AndroidUtilities.runOnUIThread(lockRunnable, 1000);
} else if (SharedConfig.autoLockIn != 0) {
AndroidUtilities.runOnUIThread(lockRunnable, (long) SharedConfig.autoLockIn * 1000 + 1000);

View File

@ -4873,7 +4873,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
}
};
if (SharedConfig.appLocked) {
if (SharedConfig.appLocked || SharedConfig.autoLockIn == 1) {
AndroidUtilities.runOnUIThread(lockRunnable, 1000);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("schedule app lock in " + 1000);

View File

@ -330,28 +330,32 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
builder.setTitle(LocaleController.getString("AutoLock", R.string.AutoLock));
final NumberPicker numberPicker = new NumberPicker(getParentActivity());
numberPicker.setMinValue(0);
numberPicker.setMaxValue(4);
numberPicker.setMaxValue(5);
if (SharedConfig.autoLockIn == 0) {
numberPicker.setValue(0);
} else if (SharedConfig.autoLockIn == 60) {
} else if (SharedConfig.autoLockIn == 1) {
numberPicker.setValue(1);
} else if (SharedConfig.autoLockIn == 60 * 5) {
} else if (SharedConfig.autoLockIn == 60) {
numberPicker.setValue(2);
} else if (SharedConfig.autoLockIn == 60 * 60) {
} else if (SharedConfig.autoLockIn == 60 * 5) {
numberPicker.setValue(3);
} else if (SharedConfig.autoLockIn == 60 * 60 * 5) {
} else if (SharedConfig.autoLockIn == 60 * 60) {
numberPicker.setValue(4);
} else if (SharedConfig.autoLockIn == 60 * 60 * 5) {
numberPicker.setValue(5);
}
numberPicker.setFormatter(value -> {
if (value == 0) {
return LocaleController.getString("AutoLockDisabled", R.string.AutoLockDisabled);
} 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) {
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) {
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) {
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 "";
@ -362,12 +366,14 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
if (which == 0) {
SharedConfig.autoLockIn = 0;
} else if (which == 1) {
SharedConfig.autoLockIn = 60;
SharedConfig.autoLockIn = 1;
} else if (which == 2) {
SharedConfig.autoLockIn = 60 * 5;
SharedConfig.autoLockIn = 60;
} else if (which == 3) {
SharedConfig.autoLockIn = 60 * 60;
SharedConfig.autoLockIn = 60 * 5;
} else if (which == 4) {
SharedConfig.autoLockIn = 60 * 60;
} else if (which == 5) {
SharedConfig.autoLockIn = 60 * 60 * 5;
}
listAdapter.notifyItemChanged(position);
@ -676,6 +682,8 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
String val;
if (SharedConfig.autoLockIn == 0) {
val = LocaleController.formatString("AutoLockDisabled", R.string.AutoLockDisabled);
} else if (SharedConfig.autoLockIn == 1) {
val = LocaleController.formatString("AutoLockImmediately", R.string.AutoLockImmediately);
} else if (SharedConfig.autoLockIn < 60 * 60) {
val = LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", SharedConfig.autoLockIn / 60));
} else if (SharedConfig.autoLockIn < 60 * 60 * 24) {

View File

@ -231,4 +231,5 @@
<string name="AddProxyWs">Add WebSocket Relay</string>
<string name="ProxyInfoWS">WebSocket Relay Settings</string>
<string name="WsPayload">Payload</string>
<string name="AutoLockImmediately">Immediately</string>
</resources>