mirror of https://github.com/x13a/Wasted.git
reschedule wipe job on days change
This commit is contained in:
parent
0b5933ef28
commit
6bf789e31b
|
@ -101,7 +101,7 @@
|
|||
<service
|
||||
android:name=".WipeJobService"
|
||||
android:exported="true"
|
||||
android:description="@string/wipe_job_service_description"
|
||||
android:description="@string/wipe_job_description"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE">
|
||||
</service>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package me.lucky.wasted
|
||||
|
||||
import android.app.job.JobScheduler
|
||||
import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
|
@ -109,7 +110,7 @@ open class MainActivity : AppCompatActivity() {
|
|||
wipeOnInactivitySwitch.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (!setWipeOnInactivityComponentsState(prefs.isServiceEnabled && isChecked)) {
|
||||
wipeOnInactivitySwitch.isChecked = false
|
||||
showWipeJobServiceStartFailedPopup()
|
||||
showWipeJobScheduleFailedPopup()
|
||||
return@setOnCheckedChangeListener
|
||||
}
|
||||
prefs.isWipeOnInactivity = isChecked
|
||||
|
@ -184,6 +185,8 @@ open class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
.setPositiveButton(R.string.ok) { _, _ ->
|
||||
prefs.wipeOnInactivityDays = days
|
||||
if (prefs.isServiceEnabled && job.schedule() == JobScheduler.RESULT_FAILURE)
|
||||
showWipeJobScheduleFailedPopup()
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
@ -197,7 +200,7 @@ open class MainActivity : AppCompatActivity() {
|
|||
private fun setOn() {
|
||||
if (!setWipeOnInactivityComponentsState(prefs.isWipeOnInactivity)) {
|
||||
binding.toggle.isChecked = false
|
||||
showWipeJobServiceStartFailedPopup()
|
||||
showWipeJobScheduleFailedPopup()
|
||||
return
|
||||
}
|
||||
prefs.isServiceEnabled = true
|
||||
|
@ -220,10 +223,10 @@ open class MainActivity : AppCompatActivity() {
|
|||
updateCodeColorState()
|
||||
}
|
||||
|
||||
private fun showWipeJobServiceStartFailedPopup() {
|
||||
private fun showWipeJobScheduleFailedPopup() {
|
||||
Snackbar.make(
|
||||
binding.toggle,
|
||||
R.string.wipe_job_service_start_failed_popup,
|
||||
R.string.wipe_job_schedule_failed_popup,
|
||||
Snackbar.LENGTH_LONG,
|
||||
).show()
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
<string name="wipe_on_inactivity_days">Дней</string>
|
||||
<string name="notification_channel_default_name">Дефолт</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="wipe_job_service_description">Стереть данные при неактивности</string>
|
||||
<string name="wipe_job_service_start_failed_popup">Не удалось запустить сервис стирания данных</string>
|
||||
<string name="wipe_job_description">Стереть данные при неактивности</string>
|
||||
<string name="wipe_job_schedule_failed_popup">Не удалось запланировать сервис стирания данных</string>
|
||||
<string name="unlock_service_description">Получать события разблокировки</string>
|
||||
<string name="unlock_service_notification_title">Служба Разблокировки</string>
|
||||
<string name="dialog_confirm_panic_title">Подтвердите</string>
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
<string name="wipe_on_inactivity_days">Days</string>
|
||||
<string name="notification_channel_default_name">Default</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="wipe_job_service_description">Wipe a device on inactivity</string>
|
||||
<string name="wipe_job_service_start_failed_popup">Failed to start a wipe service</string>
|
||||
<string name="wipe_job_description">Wipe a device on inactivity</string>
|
||||
<string name="wipe_job_schedule_failed_popup">Failed to schedule 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>
|
||||
|
|
Loading…
Reference in New Issue