fix: 在[最近任务]界面中隐藏本应用

This commit is contained in:
lliioollzh 2023-10-08 19:42:37 +08:00
parent eeb7380abc
commit 91e1ba2775
No known key found for this signature in database
GPG Key ID: FA7D73CF340440A7

View File

@ -1,5 +1,7 @@
package li.songe.gkd.ui package li.songe.gkd.ui
import android.app.ActivityManager
import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.provider.Settings import android.provider.Settings
@ -53,6 +55,7 @@ import com.blankj.utilcode.util.ZipUtils
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import li.songe.gkd.MainActivity import li.songe.gkd.MainActivity
import li.songe.gkd.app
import li.songe.gkd.appScope import li.songe.gkd.appScope
import li.songe.gkd.ui.component.SettingItem import li.songe.gkd.ui.component.SettingItem
import li.songe.gkd.ui.component.TextSwitch import li.songe.gkd.ui.component.TextSwitch
@ -115,6 +118,12 @@ fun SettingsPage() {
desc = "在[最近任务]界面中隐藏本应用", desc = "在[最近任务]界面中隐藏本应用",
checked = store.excludeFromRecents, checked = store.excludeFromRecents,
onCheckedChange = { onCheckedChange = {
(app.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager).let { manager ->
manager.appTasks.forEach { task ->
task?.setExcludeFromRecents(it)
}
}
updateStorage( updateStorage(
storeFlow, store.copy( storeFlow, store.copy(
excludeFromRecents = it excludeFromRecents = it