Skip to content

Commit 48a17d6

Browse files
committed
feat/ui: Added background hide feature and optimized application settings
- Added the excludeFromRecents property in UiStore to control whether it is hidden in recent tasks - Added related settings options in AppSettingsDesign - Implemented the hide feature in MainActivity - Updated multilingual string resources - Removed unnecessary gradle-wrapper.properties configuration items - Adjusted JVM parameters in gradle.properties
1 parent 94489d1 commit 48a17d6

File tree

9 files changed

+74
-12
lines changed

9 files changed

+74
-12
lines changed

app/src/main/java/com/github/kr328/clash/MainActivity.kt

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

3+
import android.app.ActivityManager
4+
import android.os.Bundle
35
import androidx.activity.result.contract.ActivityResultContracts
6+
import androidx.lifecycle.lifecycleScope
47
import com.github.kr328.clash.common.util.intent
58
import com.github.kr328.clash.common.util.ticker
9+
import com.github.kr328.clash.core.bridge.Bridge
610
import com.github.kr328.clash.design.MainDesign
711
import com.github.kr328.clash.design.ui.ToastDuration
812
import com.github.kr328.clash.util.startClashService
913
import com.github.kr328.clash.util.stopClashService
1014
import com.github.kr328.clash.util.withClash
1115
import com.github.kr328.clash.util.withProfile
12-
import com.github.kr328.clash.core.bridge.*
1316
import kotlinx.coroutines.Dispatchers
1417
import kotlinx.coroutines.isActive
18+
import kotlinx.coroutines.launch
1519
import kotlinx.coroutines.selects.select
1620
import kotlinx.coroutines.withContext
1721
import java.util.concurrent.TimeUnit
1822

1923
class MainActivity : BaseActivity<MainDesign>() {
24+
override fun onCreate(savedInstanceState: Bundle?) {
25+
super.onCreate(savedInstanceState)
26+
27+
lifecycleScope.launch {
28+
(getSystemService(ACTIVITY_SERVICE) as ActivityManager).let { manager ->
29+
manager.appTasks.forEach { task ->
30+
task?.setExcludeFromRecents(uiStore.excludeFromRecents)
31+
}
32+
}
33+
}
34+
}
35+
2036
override suspend fun main() {
2137
val design = MainDesign(this)
2238

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ class AppSettingsDesign(
6565
}
6666
}
6767

68+
switch(
69+
value = uiStore::excludeFromRecents,
70+
icon = R.drawable.eye_off,
71+
title = R.string.exclude_from_recents,
72+
summary = R.string.exclude_from_recents_summary,
73+
)
74+
6875
category(R.string.service)
6976

7077
switch(

design/src/main/java/com/github/kr328/clash/design/store/UiStore.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ class UiStore(context: Context) {
6262
defaultValue = false,
6363
)
6464

65+
var excludeFromRecents: Boolean by store.boolean(
66+
key = "exclude_from_recents",
67+
defaultValue = false
68+
)
69+
6570
companion object {
6671
private const val PREFERENCE_NAME = "ui"
6772
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
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"
8+
android:strokeLineJoin="round"
9+
android:strokeWidth="2"
10+
android:fillColor="#00000000"
11+
android:strokeColor="#ffffff"
12+
android:strokeLineCap="round"/>
13+
<path
14+
android:pathData="M14.084,14.158a3,3 0,0 1,-4.242 -4.242"
15+
android:strokeLineJoin="round"
16+
android:strokeWidth="2"
17+
android:fillColor="#00000000"
18+
android:strokeColor="#ffffff"
19+
android:strokeLineCap="round"/>
20+
<path
21+
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"
22+
android:strokeLineJoin="round"
23+
android:strokeWidth="2"
24+
android:fillColor="#00000000"
25+
android:strokeColor="#ffffff"
26+
android:strokeLineCap="round"/>
27+
<path
28+
android:pathData="m2,2 l20,20"
29+
android:strokeLineJoin="round"
30+
android:strokeWidth="2"
31+
android:fillColor="#00000000"
32+
android:strokeColor="#ffffff"
33+
android:strokeLineCap="round"/>
34+
</vector>

design/src/main/res/values-vi/strings.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@
1111
<string name="tun_stack_mixed">Mixed</string>
1212
<string name="tun_stack_mode">Chế độ xếp chồng dữ liệu</string>
1313
<string name="tun_stack_system">Hệ thống</string>
14-
<string name="application_name_alpha">Clash Meta</string>
15-
<string name="application_name_meta">Clash Meta</string>
1614
<string name="clash_meta_core">Clash Meta Core</string>
1715
<string name="clash_meta_for_android">Clash Meta</string>
1816
<string name="clash_meta_wiki">Clash Meta Wiki</string>
19-
<string name="launch_name_alpha">Clash Meta</string>
20-
<string name="launch_name_meta">Clash Meta</string>
2117
<string name="_new">Mới</string>
2218
<string name="about">Thông tin</string>
2319
<string name="accept_http_content">Chỉ chấp nhận http(s)</string>

design/src/main/res/values-zh/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
<string name="properties">参数</string>
5757
<string name="proxy">代理</string>
5858
<string name="recently">近期</string>
59+
<string name="exclude_from_recents">后台隐藏</string>
60+
<string name="exclude_from_recents_summary">在[最近任务]中隐藏本应用</string>
5961
<string name="route_system_traffic">自动路由系统流量</string>
6062
<string name="routing_via_vpn_service">通过 VpnService 自动路由所有系统流量</string>
6163
<string name="rule_mode">规则模式</string>

design/src/main/res/values/strings.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="PluralsCandidate">
2-
<string name="launch_name_meta">Clash Meta</string>
3-
<string name="launch_name_alpha">Clash Meta Alpha</string>
4-
<string name="application_name_meta">Clash Meta for Android</string>
5-
<string name="application_name_alpha">Clash Meta for Android Alpha</string>
2+
<string name="launch_name_meta" translatable="false">Clash Meta</string>
3+
<string name="launch_name_alpha" translatable="false">Clash Meta Alpha</string>
4+
<string name="application_name_meta" translatable="false">Clash Meta for Android</string>
5+
<string name="application_name_alpha" translatable="false">Clash Meta for Android Alpha</string>
66

77
<string name="stopped">Stopped</string>
88
<string name="tap_to_start">Tap to start</string>
@@ -112,6 +112,9 @@
112112
<string name="auto_restart">Auto Restart</string>
113113
<string name="allow_clash_auto_restart">Allow clash auto restart</string>
114114

115+
<string name="exclude_from_recents">Exclude From Recents</string>
116+
<string name="exclude_from_recents_summary">Hide this app in Recent Tasks</string>
117+
115118
<string name="route_system_traffic">Route System Traffic</string>
116119
<string name="routing_via_vpn_service">Auto routing all system traffic via VpnService</string>
117120

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# http://www.gradle.org/docs/current/userguide/build_environment.html
77
# Specifies the JVM arguments used for the daemon process.
88
# The setting is particularly useful for tweaking memory settings.
9-
org.gradle.jvmargs=-Xmx4g -XX:+UseZGC -Dfile.encoding=UTF-8
9+
org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8
1010
# When configured, Gradle will run in incubating parallel mode.
1111
# This option should only be used with decoupled projects. More details, visit
1212
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ distributionSha256Sum=fe696c020f241a5f69c30f763c5a7f38eec54b490db19cd2b0962dda42
44
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-all.zip
55
networkTimeout=10000
66
zipStoreBase=GRADLE_USER_HOME
7-
zipStorePath=wrapper/dists
8-
distributionSha256Sum=fe696c020f241a5f69c30f763c5a7f38eec54b490db19cd2b0962dda420d7d12
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)