Skip to content
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 app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ dependencies {
implementation(libs.sonner)
implementation(libs.timber)
implementation(libs.okhttp)
implementation(libs.androidsvg)
implementation(libs.angus.mail)
implementation(libs.angus.activation)
implementation(libs.jakarta.activation.api)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ object Routes {
const val SCHEDULE_EDIT = "schedule_edit/{strategyId}"
const val SCHEDULE_TRIGGER_LOG = "schedule_trigger_log"
const val NOTIFICATION = "notification"
const val LIVE_UPDATE = "live_update"
const val TASK_OVERRIDE_EDITOR = "task_override_editor"
}
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,130 @@ class AppSettingsManager(
}
}

// Live Updates 通知自定义
enum class LiveUpdateChipContent(@param:androidx.annotation.StringRes val labelRes: Int) {
BOTH(R.string.live_update_chip_both),
PROGRESS(R.string.live_update_chip_progress),
TASK(R.string.live_update_chip_task),
LOG(R.string.live_update_chip_log),
NONE(R.string.live_update_chip_none),
}

enum class LiveUpdateColorScheme(@param:androidx.annotation.StringRes val labelRes: Int) {
DEFAULT(R.string.live_update_color_default),
BLUE(R.string.live_update_color_blue),
GREEN(R.string.live_update_color_green),
ORANGE(R.string.live_update_color_orange),
PURPLE(R.string.live_update_color_purple),
PINK(R.string.live_update_color_pink),
TEAL(R.string.live_update_color_teal),
CUSTOM(R.string.live_update_color_custom),
}

val liveUpdateCustomColor: StateFlow<String> = settings
.map { it.liveUpdateCustomColor }
.distinctUntilChanged()
.stateIn(
scope, SharingStarted.Eagerly,
initialSettings.liveUpdateCustomColor
)

val liveUpdateEnabled: StateFlow<Boolean> = settings
.map { it.liveUpdateEnabled.toBooleanStrictOrNull() ?: true }
.distinctUntilChanged()
.stateIn(
scope, SharingStarted.Eagerly,
initialSettings.liveUpdateEnabled.toBooleanStrictOrNull() ?: true
)

val liveUpdateChipContent: StateFlow<LiveUpdateChipContent> = settings
.map {
runCatching { LiveUpdateChipContent.valueOf(it.liveUpdateChipContent) }
.getOrDefault(LiveUpdateChipContent.BOTH)
}
.distinctUntilChanged()
.stateIn(
scope, SharingStarted.Eagerly,
runCatching { LiveUpdateChipContent.valueOf(initialSettings.liveUpdateChipContent) }
.getOrDefault(LiveUpdateChipContent.BOTH)
)

val liveUpdateColorScheme: StateFlow<LiveUpdateColorScheme> = settings
.map {
runCatching { LiveUpdateColorScheme.valueOf(it.liveUpdateColorScheme) }
.getOrDefault(LiveUpdateColorScheme.DEFAULT)
}
.distinctUntilChanged()
.stateIn(
scope, SharingStarted.Eagerly,
runCatching { LiveUpdateColorScheme.valueOf(initialSettings.liveUpdateColorScheme) }
.getOrDefault(LiveUpdateColorScheme.DEFAULT)
)

suspend fun setLiveUpdateEnabled(enabled: Boolean) {
with(AppSettingsSchema) {
context.dataStore.edit { it[liveUpdateEnabled] = enabled.toString() }
}
}

suspend fun setLiveUpdateChipContent(content: LiveUpdateChipContent) {
with(AppSettingsSchema) {
context.dataStore.edit { it[liveUpdateChipContent] = content.name }
}
}

suspend fun setLiveUpdateColorScheme(scheme: LiveUpdateColorScheme) {
with(AppSettingsSchema) {
context.dataStore.edit { it[liveUpdateColorScheme] = scheme.name }
}
}

suspend fun setLiveUpdateCustomColor(color: String) {
with(AppSettingsSchema) {
context.dataStore.edit { it[liveUpdateCustomColor] = color }
}
}

// Live Updates 进度条追踪图标
enum class LiveUpdateTrackerIcon(@param:androidx.annotation.StringRes val labelRes: Int) {
DEFAULT(R.string.live_update_icon_default),
LOGO(R.string.live_update_icon_logo),
DOT(R.string.live_update_icon_dot),
CUSTOM(R.string.live_update_icon_custom),
}

val liveUpdateTrackerIcon: StateFlow<LiveUpdateTrackerIcon> = settings
.map {
runCatching { LiveUpdateTrackerIcon.valueOf(it.liveUpdateTrackerIcon) }
.getOrDefault(LiveUpdateTrackerIcon.DEFAULT)
}
.distinctUntilChanged()
.stateIn(
scope, SharingStarted.Eagerly,
runCatching { LiveUpdateTrackerIcon.valueOf(initialSettings.liveUpdateTrackerIcon) }
.getOrDefault(LiveUpdateTrackerIcon.DEFAULT)
)

suspend fun setLiveUpdateTrackerIcon(icon: LiveUpdateTrackerIcon) {
with(AppSettingsSchema) {
context.dataStore.edit { it[liveUpdateTrackerIcon] = icon.name }
}
}

val liveUpdateCustomTrackerPath: StateFlow<String> = settings
.map { it.liveUpdateCustomTrackerPath }
.distinctUntilChanged()
.stateIn(
scope, SharingStarted.Eagerly,
initialSettings.liveUpdateCustomTrackerPath
)

suspend fun setLiveUpdateCustomTrackerPath(path: String) {
with(AppSettingsSchema) {
context.dataStore.edit { it[liveUpdateCustomTrackerPath] = path }
}
}

// 后台虚拟屏分辨率
val backgroundResolution: StateFlow<DefaultDisplayConfig.ResolutionPreference> = settings
.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,29 @@ class ConfigBackupManager(

/**
* 导出时剥离设备本地字段:CDK 与解锁 PIN 属敏感信息;
* 自定义背景的开关与令牌对应本机 filesDir 下的图片文件,在其他设备上不存在。
* 自定义背景的开关与令牌对应本机 filesDir 下的图片文件,在其他设备上不存在;
* 自定义图标路径同样指向本机 filesDir,跨设备无效,一并清除。
*/
private fun AppSettings.sanitized() = copy(
mirrorChyanCdk = "",
wakeCredential = "",
customBackgroundEnabled = "false",
customBackgroundToken = "",
liveUpdateCustomTrackerPath = "",
// 自定义图标路径已清空,回退到内置方案
liveUpdateTrackerIcon = if (this.liveUpdateTrackerIcon == "custom") "default" else this.liveUpdateTrackerIcon,
)

/**
* 导入时对已废弃或非法的旧值做归一化,避免后续读取时违反非空约束。
* 自定义图标路径指向本机 filesDir,来自其他设备的备份必须丢弃,
* 若此时图标类型为 CUSTOM 则回退到内置方案。
*/
private fun AppSettings.normalizedForImport() = copy(
shizukuLaunchPackage = shizukuLaunchPackage.ifBlank { OFFICIAL_SHIZUKU_PACKAGE }
shizukuLaunchPackage = shizukuLaunchPackage.ifBlank { OFFICIAL_SHIZUKU_PACKAGE },
liveUpdateCustomTrackerPath = "",
// 路径已无条件清空,CUSTOM 必定无文件,直接回退内置方案
liveUpdateTrackerIcon = if (this.liveUpdateTrackerIcon == "custom") "default" else this.liveUpdateTrackerIcon,
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@ data class AppSettings(
@PrefKey(default = "DEFAULT")
val eventNotificationLevel: String = "DEFAULT",

/** Live Updates 通知是否启用(Android 16+ promoted ongoing / ProgressStyle 展示)。 */
@PrefKey(default = "true")
val liveUpdateEnabled: String = "true",

/** Live Updates 状态栏 chip 短关键文本内容:both=进度+任务名 / progress=仅进度 / task=仅任务名 / none=不显示。 */
@PrefKey(default = "both")
val liveUpdateChipContent: String = "both",

/** Live Updates 进度条颜色方案:default/blue/green/orange/purple/pink/teal/custom。 */
@PrefKey(default = "default")
val liveUpdateColorScheme: String = "default",

/** Live Updates 自定义主色 HEX(如 "#2196F3"),仅 liveUpdateColorScheme=custom 时使用。 */
@PrefKey(default = "")
val liveUpdateCustomColor: String = "",

/** Live Updates 进度条追踪图标:default=菱形 / logo=MAA 图标 / dot=圆点 / custom=自定义图片。 */
@PrefKey(default = "default")
val liveUpdateTrackerIcon: String = "default",

/** Live Updates 自定义追踪图标文件路径,仅 liveUpdateTrackerIcon=custom 时使用。 */
@PrefKey(default = "")
val liveUpdateCustomTrackerPath: String = "",

@PrefKey(default = "P720")
val backgroundResolution: String = "P720",

Expand Down
Loading
Loading