Skip to content

Commit

Permalink
feat(design): implement real-time update for exclude from recents set…
Browse files Browse the repository at this point in the history
…ting

- 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
  • Loading branch information
NoahCodeGG committed Nov 26, 2024
1 parent 135cdf7 commit e18adfc
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.kr328.clash.design

import android.app.ActivityManager
import android.content.Context
import android.view.View
import com.github.kr328.clash.design.databinding.DesignSettingsCommonBinding
Expand Down Expand Up @@ -70,7 +71,15 @@ class AppSettingsDesign(
icon = R.drawable.eye_off,
title = R.string.exclude_from_recents,
summary = R.string.exclude_from_recents_summary,
)
) {
listener = OnChangedListener {
(context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager).let { manager ->
manager.appTasks.forEach { task ->
task?.setExcludeFromRecents(uiStore.excludeFromRecents)
}
}
}
}

category(R.string.service)

Expand Down

0 comments on commit e18adfc

Please sign in to comment.