Skip to content

Commit

Permalink
feat/ui: Added background hide feature and optimized application sett…
Browse files Browse the repository at this point in the history
…ings

- 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
  • Loading branch information
NoahCodeGG committed Nov 25, 2024
1 parent 94489d1 commit 48a17d6
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 12 deletions.
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
Expand Up @@ -65,6 +65,13 @@ class AppSettingsDesign(
}
}

switch(
value = uiStore::excludeFromRecents,
icon = R.drawable.eye_off,
title = R.string.exclude_from_recents,
summary = R.string.exclude_from_recents_summary,
)

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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx4g -XX:+UseZGC -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
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

0 comments on commit 48a17d6

Please sign in to comment.