add internal panic starter

This commit is contained in:
lucky 2022-01-14 10:27:43 +03:00
parent 768c99c93d
commit de385837c1
3 changed files with 21 additions and 0 deletions

View File

@ -120,6 +120,21 @@ open class MainActivity : AppCompatActivity() {
false -> setOff()
}
}
toggle.setOnLongClickListener {
if (!toggle.isChecked) return@setOnLongClickListener false
MaterialAlertDialogBuilder(this@MainActivity)
.setTitle(R.string.dialog_confirm_panic_title)
.setMessage(R.string.dialog_confirm_panic_message)
.setPositiveButton(R.string.yes) { _, _ ->
try {
admin.lockNow()
if (prefs.isWipeData) admin.wipeData()
} catch (exc: SecurityException) {}
}
.setNegativeButton(R.string.cancel, null)
.show()
true
}
}
}

View File

@ -24,4 +24,7 @@
<string name="wipe_job_service_start_failed_popup">Не удалось запустить сервис стирания данных</string>
<string name="unlock_service_description">Получать события разблокировки</string>
<string name="unlock_service_notification_title">Служба Разблокировки</string>
<string name="dialog_confirm_panic_title">Подтвердите</string>
<string name="dialog_confirm_panic_message">Активировать тревогу\? Это заблокирует устройство и опционально сотрёт его данные.</string>
<string name="yes">Да</string>
</resources>

View File

@ -24,4 +24,7 @@
<string name="wipe_job_service_start_failed_popup">Failed to start a wipe service</string>
<string name="unlock_service_description">Receive unlock events</string>
<string name="unlock_service_notification_title">Unlock Service</string>
<string name="dialog_confirm_panic_title">Confirm</string>
<string name="dialog_confirm_panic_message">Activate panic\? This will lock a device and optionally wipe its data.</string>
<string name="yes">Yes</string>
</resources>