From 36a5ef08861301c8c7ace25cc3eee96cb86c7eb5 Mon Sep 17 00:00:00 2001 From: lucky <> Date: Sun, 30 Jan 2022 21:02:43 +0300 Subject: [PATCH] ref --- PRIVACY.md | 2 +- README.md | 4 +- app/src/main/AndroidManifest.xml | 2 +- .../java/me/lucky/wasted/ForegroundService.kt | 54 ++++++++++++------- .../main/java/me/lucky/wasted/MainActivity.kt | 23 ++++---- .../wasted/NotificationListenerService.kt | 2 +- .../java/me/lucky/wasted/RestartReceiver.kt | 5 +- app/src/main/res/values-ru/strings.xml | 14 ++--- app/src/main/res/values/arrays.xml | 13 +++++ app/src/main/res/values/string-arrays.xml | 10 ++-- app/src/main/res/values/strings.xml | 14 ++--- 11 files changed, 87 insertions(+), 56 deletions(-) create mode 100644 app/src/main/res/values/arrays.xml diff --git a/PRIVACY.md b/PRIVACY.md index a31be6e..67dd68b 100644 --- a/PRIVACY.md +++ b/PRIVACY.md @@ -1,3 +1,3 @@ # Privacy Policy -The app has nothing to store, but preferences. +The app has nothing to store, but settings. diff --git a/README.md b/README.md index 7e95c48..c3aa415 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,8 @@ message with authentication code. On trigger, using locks a device and optionally runs wipe. Also you can: -- limit the maximum number of failed password attempts -- wipe a device when it was not unlocked for N days +* limit the maximum number of failed password attempts +* wipe a device when it was not unlocked for N days The app works in `Work Profile` too. Use [Shelter](https://github.com/PeterCxy/Shelter) to install risky apps and `Wasted` in it. Then you can wipe this profile data with one click without wiping diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3567163..949a122 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -123,7 +123,7 @@ - val value = launchersValues[index] + val value = values[index] launchers = when (isChecked) { true -> launchers.or(value.flag) false -> launchers.and(value.flag.inv()) @@ -177,7 +177,7 @@ open class MainActivity : AppCompatActivity() { } private fun showWipeOnInactivitySettings() { - val items = arrayOf("1", "2", "3", "5", "7", "10", "15", "30") + val items = resources.getStringArray(R.array.wipe_on_inactivity_days) var days = prefs.wipeOnInactivityDays var checked = items.indexOf(days.toString()) if (checked == -1) checked = items @@ -272,8 +272,9 @@ open class MainActivity : AppCompatActivity() { } private fun setForegroundServiceState(value: Boolean) { - Intent(this, ForegroundService::class.java).also { - if (value) ContextCompat.startForegroundService(this, it) else stopService(it) + Intent(this.applicationContext, ForegroundService::class.java).also { + if (value) ContextCompat.startForegroundService(this.applicationContext, it) + else stopService(it) } } diff --git a/app/src/main/java/me/lucky/wasted/NotificationListenerService.kt b/app/src/main/java/me/lucky/wasted/NotificationListenerService.kt index c8ba31e..2e73257 100644 --- a/app/src/main/java/me/lucky/wasted/NotificationListenerService.kt +++ b/app/src/main/java/me/lucky/wasted/NotificationListenerService.kt @@ -25,7 +25,7 @@ class NotificationListenerService : NotificationListenerService() { val code = prefs.code if (!prefs.isServiceEnabled || code == "" || - sbn.notification.extras.getString(Notification.EXTRA_TEXT) != code) return + sbn.notification.extras.getString(Notification.EXTRA_TEXT)?.trim() != code) return cancelAllNotifications() try { admin.lockNow() diff --git a/app/src/main/java/me/lucky/wasted/RestartReceiver.kt b/app/src/main/java/me/lucky/wasted/RestartReceiver.kt index 3c45364..823c6c4 100644 --- a/app/src/main/java/me/lucky/wasted/RestartReceiver.kt +++ b/app/src/main/java/me/lucky/wasted/RestartReceiver.kt @@ -12,6 +12,9 @@ class RestartReceiver : BroadcastReceiver() { intent.action != Intent.ACTION_MY_PACKAGE_REPLACED) return val prefs = Preferences(context) if (!prefs.isServiceEnabled || !prefs.isWipeOnInactivity) return - ContextCompat.startForegroundService(context, Intent(context, ForegroundService::class.java)) + ContextCompat.startForegroundService( + context.applicationContext, + Intent(context.applicationContext, ForegroundService::class.java), + ) } } diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index ca9a442..f1a8a38 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -22,15 +22,15 @@ Стереть данные при неактивности Не удалось запланировать сервис стирания данных Получать события разблокировки - Служба Разблокировки + Островок Стабильности Активировать тревогу\? Это заблокирует устройство и опционально сотрёт его данные. Да - PanicKit - Плитка - Ярлык - Широковещательное сообщение - Уведомление - Вайпер + PanicKit + Плитка + Ярлык + Широковещательное сообщение + Уведомление + Вайпер Сканирует уведомления на наличие кода аутентификации diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml new file mode 100644 index 0000000..4db1e11 --- /dev/null +++ b/app/src/main/res/values/arrays.xml @@ -0,0 +1,13 @@ + + + + 1 + 2 + 3 + 5 + 7 + 10 + 15 + 30 + + \ No newline at end of file diff --git a/app/src/main/res/values/string-arrays.xml b/app/src/main/res/values/string-arrays.xml index a3b67b6..fd44d2f 100644 --- a/app/src/main/res/values/string-arrays.xml +++ b/app/src/main/res/values/string-arrays.xml @@ -1,10 +1,10 @@ - @string/launchers_array_0 - @string/launchers_array_1 - @string/launchers_array_2 - @string/launchers_array_3 - @string/launchers_array_4 + @string/launchers_array_panic_kit + @string/launchers_array_tile + @string/launchers_array_shortcut + @string/launchers_array_broadcast + @string/launchers_array_notification \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e6907ae..49a2446 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -22,15 +22,15 @@ Wipe a device on inactivity Failed to schedule a wipe job Receive unlock events - Unlock Service + Guard Activate panic\? This will lock a device and optionally wipe its data. Yes - PanicKit - Tile - Shortcut - Broadcast - Notification - Viper + PanicKit + Tile + Shortcut + Broadcast + Notification + Viper Scan notifications for authentication code