Skip to content

Commit 5f94f22

Browse files
NoahCodeGGhamjin
authored andcommitted
feat(design): implement real-time update for exclude from recents setting
- Add OnChangedListener to excludeFromRecents setting item - Update exclude from recents status for all app tasks when setting changes - Use ActivityManager to access and modify app tasks Signed-off-by: hamjin <jinham@qq.com>
1 parent ceee863 commit 5f94f22

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

design/src/main/java/com/github/kr328/clash/design/AppSettingsDesign.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.kr328.clash.design
22

3+
import android.app.ActivityManager
34
import android.content.Context
45
import android.view.View
56
import com.github.kr328.clash.design.databinding.DesignSettingsCommonBinding
@@ -82,7 +83,15 @@ class AppSettingsDesign(
8283
icon = R.drawable.eye_off,
8384
title = R.string.exclude_from_recents,
8485
summary = R.string.exclude_from_recents_summary,
85-
)
86+
) {
87+
listener = OnChangedListener {
88+
(context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager).let { manager ->
89+
manager.appTasks.forEach { task ->
90+
task?.setExcludeFromRecents(uiStore.excludeFromRecents)
91+
}
92+
}
93+
}
94+
}
8695

8796
category(R.string.service)
8897

0 commit comments

Comments
 (0)