Skip to content

Commit d5fb4e3

Browse files
committed
Update
1 parent 3a736e4 commit d5fb4e3

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,14 @@ class ThemeConfig(private val context: Context) {
1313
const val KEY_NOTIFICATION_UI = "NotificationUI"
1414
}
1515

16-
// Lưu theme mode 0–5
1716
fun getThemeMode(): Int {
18-
return config.getInt(KEY_THEME_MODE, 0)
17+
return config.getInt(KEY_THEME_MODE, 3)
1918
}
2019

2120
fun setThemeMode(mode: Int) {
2221
val newMode = mode.coerceIn(0, 5)
23-
// Chỉ xử lý nếu mode thực sự thay đổi
2422
if (getThemeMode() != newMode) {
2523
config.edit { putInt(KEY_THEME_MODE, newMode) }
26-
27-
// Recreate chỉ hoạt động nếu context là Activity
2824
if (context is Activity) {
2925
context.recreate()
3026
}
@@ -37,19 +33,13 @@ class ThemeConfig(private val context: Context) {
3733

3834
fun setAllowNotificationUI(allow: Boolean) {
3935
val current = getAllowNotificationUI()
40-
if (current == allow) return // Không có thay đổi thì không làm gì cả
41-
36+
if (current == allow) return
4237
config.edit { putBoolean(KEY_NOTIFICATION_UI, allow) }
43-
4438
val appContext = context.applicationContext
4539
if (allow) {
46-
// Khi bật, khởi động Service để hiện thông báo
4740
WakeLockService.startService(appContext)
4841
} else {
49-
// Khi tắt, dừng hoàn toàn Service
5042
WakeLockService.stopService(appContext)
51-
// Nếu bạn muốn xóa cả thông báo từ NotiService:
52-
// context.stopService(Intent(context, NotiService::class.java))
5343
}
5444
}
5545
}

0 commit comments

Comments
 (0)