Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/ui: add option to exclude app from recent tasks #396

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ gradle-app.setting
!/core/src/foss/golang/.idea/codeStyles
/core/src/premium/golang/.idea/*
!/core/src/premium/golang/.idea/codeStyles
/core/src/main/cpp/version.h

# Ignore builtin geofiles
app/src/main/assets
Expand Down
18 changes: 17 additions & 1 deletion app/src/main/java/com/github/kr328/clash/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
package com.github.kr328.clash

import android.app.ActivityManager
import android.os.Bundle
import androidx.activity.result.contract.ActivityResultContracts
import androidx.lifecycle.lifecycleScope
import com.github.kr328.clash.common.util.intent
import com.github.kr328.clash.common.util.ticker
import com.github.kr328.clash.core.bridge.Bridge
import com.github.kr328.clash.design.MainDesign
import com.github.kr328.clash.design.ui.ToastDuration
import com.github.kr328.clash.util.startClashService
import com.github.kr328.clash.util.stopClashService
import com.github.kr328.clash.util.withClash
import com.github.kr328.clash.util.withProfile
import com.github.kr328.clash.core.bridge.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.selects.select
import kotlinx.coroutines.withContext
import java.util.concurrent.TimeUnit

class MainActivity : BaseActivity<MainDesign>() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

lifecycleScope.launch {
(getSystemService(ACTIVITY_SERVICE) as ActivityManager).let { manager ->
manager.appTasks.forEach { task ->
task?.setExcludeFromRecents(uiStore.excludeFromRecents)
}
}
}
}

override suspend fun main() {
val design = MainDesign(this)

Expand Down
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 @@ -65,6 +66,21 @@ class AppSettingsDesign(
}
}

switch(
value = uiStore::excludeFromRecents,
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)

switch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class UiStore(context: Context) {
defaultValue = false,
)

var excludeFromRecents: Boolean by store.boolean(
key = "exclude_from_recents",
defaultValue = false
)

companion object {
private const val PREFERENCE_NAME = "ui"
}
Expand Down
34 changes: 34 additions & 0 deletions design/src/main/res/drawable/eye_off.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M10.733,5.076a10.744,10.744 0,0 1,11.205 6.575,1 1,0 0,1 0,0.696 10.747,10.747 0,0 1,-1.444 2.49"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#ffffff"
android:strokeLineCap="round"/>
<path
android:pathData="M14.084,14.158a3,3 0,0 1,-4.242 -4.242"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#ffffff"
android:strokeLineCap="round"/>
<path
android:pathData="M17.479,17.499a10.75,10.75 0,0 1,-15.417 -5.151,1 1,0 0,1 0,-0.696 10.75,10.75 0,0 1,4.446 -5.143"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#ffffff"
android:strokeLineCap="round"/>
<path
android:pathData="m2,2 l20,20"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#ffffff"
android:strokeLineCap="round"/>
</vector>
4 changes: 0 additions & 4 deletions design/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@
<string name="tun_stack_mixed">Mixed</string>
<string name="tun_stack_mode">Chế độ xếp chồng dữ liệu</string>
<string name="tun_stack_system">Hệ thống</string>
<string name="application_name_alpha">Clash Meta</string>
<string name="application_name_meta">Clash Meta</string>
<string name="clash_meta_core">Clash Meta Core</string>
<string name="clash_meta_for_android">Clash Meta</string>
<string name="clash_meta_wiki">Clash Meta Wiki</string>
<string name="launch_name_alpha">Clash Meta</string>
<string name="launch_name_meta">Clash Meta</string>
<string name="_new">Mới</string>
<string name="about">Thông tin</string>
<string name="accept_http_content">Chỉ chấp nhận http(s)</string>
Expand Down
2 changes: 2 additions & 0 deletions design/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
<string name="properties">参数</string>
<string name="proxy">代理</string>
<string name="recently">近期</string>
<string name="exclude_from_recents">后台隐藏</string>
<string name="exclude_from_recents_summary">在[最近任务]中隐藏本应用</string>
<string name="route_system_traffic">自动路由系统流量</string>
<string name="routing_via_vpn_service">通过 VpnService 自动路由所有系统流量</string>
<string name="rule_mode">规则模式</string>
Expand Down
11 changes: 7 additions & 4 deletions design/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="PluralsCandidate">
<string name="launch_name_meta">Clash Meta</string>
<string name="launch_name_alpha">Clash Meta Alpha</string>
<string name="application_name_meta">Clash Meta for Android</string>
<string name="application_name_alpha">Clash Meta for Android Alpha</string>
<string name="launch_name_meta" translatable="false">Clash Meta</string>
<string name="launch_name_alpha" translatable="false">Clash Meta Alpha</string>
<string name="application_name_meta" translatable="false">Clash Meta for Android</string>
<string name="application_name_alpha" translatable="false">Clash Meta for Android Alpha</string>

<string name="stopped">Stopped</string>
<string name="tap_to_start">Tap to start</string>
Expand Down Expand Up @@ -112,6 +112,9 @@
<string name="auto_restart">Auto Restart</string>
<string name="allow_clash_auto_restart">Allow clash auto restart</string>

<string name="exclude_from_recents">Exclude From Recents</string>
<string name="exclude_from_recents_summary">Hide this app in Recent Tasks</string>

<string name="route_system_traffic">Route System Traffic</string>
<string name="routing_via_vpn_service">Auto routing all system traffic via VpnService</string>

Expand Down
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ distributionSha256Sum=fe696c020f241a5f69c30f763c5a7f38eec54b490db19cd2b0962dda42
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=fe696c020f241a5f69c30f763c5a7f38eec54b490db19cd2b0962dda420d7d12
zipStorePath=wrapper/dists