Skip to content

Commit 4eebfe8

Browse files
committed
Update
1 parent dccd878 commit 4eebfe8

File tree

7 files changed

+34
-15
lines changed

7 files changed

+34
-15
lines changed

app/src/main/assets/home/etc/lang/default.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ config_text="Configuration"
4343
time_text="Time"
4444
pin_text="Pin add-on"
4545
unpin_text="Unpin add-on"
46+
dissblur_text="Turn off blur effect"
4647
tool_unpack_text="Decoding tool"
4748

4849
# Home

app/src/main/assets/home/etc/lang/hu.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ alignment_text="Igazítás"
4141
synthetic_text="Szintetikus"
4242
config_text="Konfiguráció"
4343
time_text="Idő"
44+
dissblur_text="Elmosódás effektus kikapcsolása"
4445
tool_unpack_text="Dekódoló eszköz"
4546

4647
# Home

app/src/main/assets/home/etc/lang/ru.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ config_text="Конфигурация"
4343
time_text="Время"
4444
pin_text="Закрепить"
4545
unpin_text="Открепить"
46+
dissblur_text="Отключить эффект размытия"
4647
tool_unpack_text="Инструмент декодирования"
4748

4849
# Home

app/src/main/assets/home/etc/lang/vi.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ config_text="Cấu hình"
4343
time_text="Thời gian"
4444
pin_text="Ghim add-on"
4545
unpin_text="Bỏ ghim"
46+
dissblur_text="Tắt hiệu ứng mờ"
4647
tool_unpack_text="Công cụ giải mã"
4748

4849
# Home

app/src/main/assets/home/etc/lang/zh.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ config_text="配置"
4343
time_text="时间"
4444
pin_text="置顶"
4545
unpin_text="取消置顶"
46+
dissblur_text="关闭模糊效果"
4647
tool_unpack_text="解码工具"
4748

4849
# Home

app/src/main/assets/home/etc/tool-tree.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,10 @@ slog show_infor_text_2 "$show_infor_text_2"
549549
<group>
550550
<action icon="'`urlpng background`'" warning="'$project_text_15'" shell="hidden" auto-restart="true">
551551
<title>'$project_text_14'</title>
552+
<param name="dissblur" label="'$dissblur_text'" value-sh="glog dissblur" type="bool" />
552553
<param name="uri_change_background" type="file" suffix="jpg" value-sh="glog uri_change_background" editable="true" />
553554
<set>
555+
slog dissblur "$dissblur"
554556
slog uri_change_background "$uri_change_background"
555557
[ -f "$uri_change_background" ] && cp -f "$uri_change_background" "$ETC/wallpaper.jpg"
556558
[ -z "$uri_change_background" ] && rm -f "$ETC/wallpaper.jpg"

app/src/main/java/com/tool/tree/ThemeModeState.kt

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ package com.tool.tree
33
import android.app.Activity
44
import android.app.WallpaperManager
55
import android.graphics.Color
6-
import android.graphics.drawable.BitmapDrawable
76
import android.graphics.drawable.Drawable
8-
import android.os.Build
97
import android.view.View
108
import android.view.WindowManager
119
import androidx.appcompat.app.AppCompatDelegate
@@ -24,11 +22,30 @@ object ThemeModeState {
2422
@JvmStatic
2523
fun isDarkMode(): Boolean = themeMode.isDarkMode
2624

25+
/**
26+
* Kiểm tra file cấu hình tắt blur dựa trên đường dẫn tương đối
27+
* Đường dẫn đầy đủ sẽ là: /data/user/0/com.tool.tree/files/home/log/dissblur
28+
*/
29+
private fun isBlurDisabled(activity: Activity): Boolean {
30+
val file = File(activity.filesDir, "home/log/dissblur")
31+
return try {
32+
if (file.exists()) {
33+
file.readText().trim() == "1"
34+
} else {
35+
false
36+
}
37+
} catch (e: Exception) {
38+
false
39+
}
40+
}
41+
2742
fun switchTheme(activity: Activity, themeLevel: Int? = null): ThemeMode {
2843
val level = themeLevel ?: ThemeConfig(activity).getThemeMode()
2944

30-
// Cập nhật logic xác định Night Mode hệ thống nhanh hơn
31-
val isSystemNight = (activity.resources.configuration.uiMode and android.content.res.Configuration.UI_MODE_NIGHT_MASK) == android.content.res.Configuration.UI_MODE_NIGHT_YES
45+
// Xác định chế độ tối của hệ thống
46+
val isSystemNight = (activity.resources.configuration.uiMode and
47+
android.content.res.Configuration.UI_MODE_NIGHT_MASK) ==
48+
android.content.res.Configuration.UI_MODE_NIGHT_YES
3249

3350
when (level.coerceIn(0, 5)) {
3451
0 -> {
@@ -63,10 +80,9 @@ object ThemeModeState {
6380
}
6481
}
6582

66-
// BlurEngine logic
67-
if (level >= 3) {
83+
// Logic xử lý Blur: Chỉ bật khi level >= 3 VÀ file dissblur không phải là 1
84+
if (level >= 3 && !isBlurDisabled(activity)) {
6885
BlurEngine.isPaused = false
69-
// Đảm bảo View đã layout xong trước khi capture
7086
activity.window.decorView.post {
7187
BlurEngine.controller.captureAndBlur(activity)
7288
}
@@ -86,15 +102,14 @@ object ThemeModeState {
86102

87103
try {
88104
if (customWallpaperFile.exists()) {
89-
// Sử dụng createFromPath để tiết kiệm bộ nhớ hơn decode trực tiếp
90105
val drawable = Drawable.createFromPath(customWallpaperFile.absolutePath)
91106
activity.window.setBackgroundDrawable(drawable)
92107
} else if (wallpaper.wallpaperInfo != null) {
93-
// Nếu là Live Wallpaper, dùng flag SHOW_WALLPAPER
108+
// Live Wallpaper
94109
activity.window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER)
95110
activity.window.setBackgroundDrawable(null)
96111
} else {
97-
// Hình nền tĩnh hệ thống
112+
// Hệ thống Wallpaper tĩnh
98113
activity.window.setBackgroundDrawable(wallpaper.drawable)
99114
}
100115
} catch (e: Exception) {
@@ -104,26 +119,23 @@ object ThemeModeState {
104119

105120
private fun applyWindowFlags(activity: Activity) {
106121
val window = activity.window
107-
// Thiết lập Edge-to-Edge chuẩn SDK 23+
108122
WindowCompat.setDecorFitsSystemWindows(window, false)
109123
window.statusBarColor = Color.TRANSPARENT
110124
window.navigationBarColor = Color.TRANSPARENT
111125

112126
val rootView = window.decorView
113-
ViewCompat.setOnApplyWindowInsetsListener(rootView) { view, insets ->
127+
ViewCompat.setOnApplyWindowInsetsListener(rootView) { _, insets ->
114128
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
115129

116-
// Cập nhật padding cho các container nếu tồn tại
117130
activity.findViewById<View>(R.id.blur_top_container)?.setPadding(0, systemBars.top, 0, 0)
118131
activity.findViewById<View>(R.id.file_selector_list)?.setPadding(0, systemBars.top, 0, 0)
119132
activity.findViewById<View>(R.id.main_list)?.setPadding(0, systemBars.top, 0, 0)
120133
activity.findViewById<View>(R.id.blur_bottom_container)?.setPadding(0, 0, 0, systemBars.bottom)
121134
activity.findViewById<View>(R.id.kr_online_webview)?.setPadding(0, systemBars.top, 0, 0)
122135

123-
insets // Trả về insets để các view khác vẫn nhận được
136+
insets
124137
}
125138

126-
// Điều khiển màu icon trên thanh trạng thái
127139
val controller = WindowInsetsControllerCompat(window, rootView)
128140
val useLightIcons = !themeMode.isDarkMode
129141
controller.isAppearanceLightStatusBars = useLightIcons

0 commit comments

Comments
 (0)