mirror of
https://github.com/fankes/ColorOSNotifyIcon.git
synced 2025-09-06 02:35:41 +08:00
Modify merge all store methods to ConfigData and fix module activation status problem
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
package com.fankes.coloros.notify.application
|
package com.fankes.coloros.notify.application
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
|
import com.fankes.coloros.notify.data.ConfigData
|
||||||
import com.highcapable.yukihookapi.hook.xposed.application.ModuleApplication
|
import com.highcapable.yukihookapi.hook.xposed.application.ModuleApplication
|
||||||
|
|
||||||
class CNNApplication : ModuleApplication() {
|
class CNNApplication : ModuleApplication() {
|
||||||
@@ -33,5 +34,7 @@ class CNNApplication : ModuleApplication() {
|
|||||||
super.onCreate()
|
super.onCreate()
|
||||||
/** 跟随系统夜间模式 */
|
/** 跟随系统夜间模式 */
|
||||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||||
|
/** 装载存储控制类 */
|
||||||
|
ConfigData.init(instance = this)
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -18,16 +18,33 @@
|
|||||||
* and eula along with this software. If not, see
|
* and eula along with this software. If not, see
|
||||||
* <https://www.gnu.org/licenses/>
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/24.
|
* This file is Created by fankes on 2023/2/2.
|
||||||
*/
|
*/
|
||||||
package com.fankes.coloros.notify.hook
|
package com.fankes.coloros.notify.const
|
||||||
|
|
||||||
object HookConst {
|
/**
|
||||||
|
* 包名常量定义类
|
||||||
|
*/
|
||||||
|
object PackageName {
|
||||||
|
|
||||||
const val TYPE_SOURCE_SYNC_WAY_1 = 1000
|
/** 系统框架 */
|
||||||
const val TYPE_SOURCE_SYNC_WAY_2 = 2000
|
const val SYSTEM_FRAMEWORK = "android"
|
||||||
const val TYPE_SOURCE_SYNC_WAY_3 = 3000
|
|
||||||
|
|
||||||
const val ANDROID_PACKAGE_NAME = "android"
|
/** 系统界面 (系统 UI) */
|
||||||
const val SYSTEMUI_PACKAGE_NAME = "com.android.systemui"
|
const val SYSTEMUI = "com.android.systemui"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知图标优化名单同步方式定义类
|
||||||
|
*/
|
||||||
|
object IconRuleSourceSyncType {
|
||||||
|
|
||||||
|
/** Github Raw (代理) */
|
||||||
|
const val GITHUB_RAW_PROXY = 1000
|
||||||
|
|
||||||
|
/** Github Raw (直连) */
|
||||||
|
const val GITHUB_RAW_DIRECT = 2000
|
||||||
|
|
||||||
|
/** 自定义地址 */
|
||||||
|
const val CUSTOM_URL = 3000
|
||||||
}
|
}
|
363
app/src/main/java/com/fankes/coloros/notify/data/ConfigData.kt
Normal file
363
app/src/main/java/com/fankes/coloros/notify/data/ConfigData.kt
Normal file
@@ -0,0 +1,363 @@
|
|||||||
|
/*
|
||||||
|
* ColorOSNotifyIcon - Optimize notification icons for ColorOS and adapt to native notification icon specifications.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/ColorOSNotifyIcon
|
||||||
|
*
|
||||||
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
* This file is Created by fankes on 2023/2/2.
|
||||||
|
*/
|
||||||
|
@file:Suppress("MemberVisibilityCanBePrivate")
|
||||||
|
|
||||||
|
package com.fankes.coloros.notify.data
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.fankes.coloros.notify.const.IconRuleSourceSyncType
|
||||||
|
import com.fankes.coloros.notify.utils.factory.isUpperOfAndroidS
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
||||||
|
import com.highcapable.yukihookapi.hook.log.loggerW
|
||||||
|
import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||||
|
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局配置存储控制类
|
||||||
|
*/
|
||||||
|
object ConfigData {
|
||||||
|
|
||||||
|
/** 启用模块 */
|
||||||
|
val ENABLE_MODULE = PrefsData("_enable_module", true)
|
||||||
|
|
||||||
|
/** 启用模块日志 */
|
||||||
|
val ENABLE_MODULE_LOG = PrefsData("_enable_module_log", false)
|
||||||
|
|
||||||
|
/** 启用通知图标兼容模式 */
|
||||||
|
val ENABLE_COLOR_ICON_COMPAT = PrefsData("_color_icon_compat", false)
|
||||||
|
|
||||||
|
/** 移除开发者选项警告通知 */
|
||||||
|
val ENABLE_REMOVE_DEV_NOTIFY = PrefsData("_remove_dev_notify", true)
|
||||||
|
|
||||||
|
/** 移除充电完成通知 */
|
||||||
|
val ENABLE_REMOVE_CHANGE_COMPLETE_NOTIFY = PrefsData("_remove_charge_complete_notify", false)
|
||||||
|
|
||||||
|
/** 移除免打扰通知 */
|
||||||
|
val ENABLE_REMOVE_DND_ALERT_NOTIFY = PrefsData("_remove_dndalert_notify", false)
|
||||||
|
|
||||||
|
/** 启用 Material 3 通知图标风格 */
|
||||||
|
val ENABLE_MD3_NOTIFY_ICON_STYLE = PrefsData("_notify_icon_md3_style", isUpperOfAndroidS)
|
||||||
|
|
||||||
|
/** 通知栏中的通知图标圆角程度 */
|
||||||
|
val NOTIFY_ICON_CORNER_SIZE = PrefsData("_notify_icon_corner", 15)
|
||||||
|
|
||||||
|
/** 强制通知栏中的通知图标为 APP 图标 */
|
||||||
|
val ENABLE_NOTIFY_ICON_FORCE_APP_ICON = PrefsData("_notify_icon_force_app_icon", false)
|
||||||
|
|
||||||
|
/** 启用媒体通知播放时自动展开 */
|
||||||
|
val ENABLE_NOTIFY_MEDIA_PANEL_AUTO_EXP = PrefsData("_enable_notify_media_panel_auto_exp", false)
|
||||||
|
|
||||||
|
/** 启用自定义通知面板背景透明度 */
|
||||||
|
val ENABLE_NOTIFY_PANEL_ALPHA = PrefsData("_enable_notify_panel_alpha", false)
|
||||||
|
|
||||||
|
/** 自定义通知面板背景透明度 */
|
||||||
|
val NOTIFY_PANEL_ALPHA_LEVEL = PrefsData("_notify_panel_alpha_pst", 75)
|
||||||
|
|
||||||
|
/** 启用通知图标优化 */
|
||||||
|
val ENABLE_NOTIFY_ICON_FIX = PrefsData("_notify_icon_fix", true)
|
||||||
|
|
||||||
|
/** 提醒未适配通知图标的新安装应用 */
|
||||||
|
val ENABLE_NOTIFY_ICON_FIX_NOTIFY = PrefsData("_notify_icon_fix_notify", true)
|
||||||
|
|
||||||
|
/** 启用通知图标优化名单自动更新 */
|
||||||
|
val ENABLE_NOTIFY_ICON_FIX_AUTO = PrefsData("_enable_notify_icon_fix_auto", true)
|
||||||
|
|
||||||
|
/** 通知图标优化名单自动更新时间 */
|
||||||
|
val NOTIFY_ICON_FIX_AUTO_TIME = PrefsData("_notify_icon_fix_auto_time", "07:00")
|
||||||
|
|
||||||
|
/** 通知图标优化适配数据 */
|
||||||
|
val NOTIFY_ICONS_DATA = PrefsData("_notify_icon_datas", "")
|
||||||
|
|
||||||
|
/** 通知图标优化名单同步方式 */
|
||||||
|
val ICON_RULE_SOURCE_SYNC_TYPE = PrefsData("_rule_source_sync_way", IconRuleSourceSyncType.GITHUB_RAW_PROXY)
|
||||||
|
|
||||||
|
/** 通知图标优化名单同步地址 */
|
||||||
|
val ICON_RULE_SOURCE_SYNC_CUSTOM_URL = PrefsData("_rule_source_sync_way_custom_url", "")
|
||||||
|
|
||||||
|
/** 当前实例 - [Context] or [PackageParam] */
|
||||||
|
private var instance: Any? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化存储控制类
|
||||||
|
* @param instance 实例 - 只能是 [Context] or [PackageParam]
|
||||||
|
* @throws IllegalStateException 如果类型错误
|
||||||
|
*/
|
||||||
|
fun init(instance: Any) {
|
||||||
|
when (instance) {
|
||||||
|
is Context, is PackageParam -> this.instance = instance
|
||||||
|
else -> error("Unknown type for init ConfigData")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取 [Int] 数据
|
||||||
|
* @param data 键值数据模板
|
||||||
|
* @return [Int]
|
||||||
|
*/
|
||||||
|
private fun getInt(data: PrefsData<Int>) = when (instance) {
|
||||||
|
is Context -> (instance as Context).modulePrefs.get(data)
|
||||||
|
is PackageParam -> (instance as PackageParam).prefs.get(data)
|
||||||
|
else -> error("Unknown type for get prefs data")
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存入 [Int] 数据
|
||||||
|
* @param data 键值数据模板
|
||||||
|
* @param value 键值内容
|
||||||
|
*/
|
||||||
|
private fun putInt(data: PrefsData<Int>, value: Int) {
|
||||||
|
when (instance) {
|
||||||
|
is Context -> (instance as Context).modulePrefs.put(data, value)
|
||||||
|
is PackageParam -> loggerW(msg = "Not support for this method")
|
||||||
|
else -> error("Unknown type for put prefs data")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取 [String] 数据
|
||||||
|
* @param data 键值数据模板
|
||||||
|
* @return [String]
|
||||||
|
*/
|
||||||
|
private fun getString(data: PrefsData<String>) = when (instance) {
|
||||||
|
is Context -> (instance as Context).modulePrefs.get(data)
|
||||||
|
is PackageParam -> (instance as PackageParam).prefs.get(data)
|
||||||
|
else -> error("Unknown type for get prefs data")
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存入 [String] 数据
|
||||||
|
* @param data 键值数据模板
|
||||||
|
* @param value 键值内容
|
||||||
|
*/
|
||||||
|
private fun putString(data: PrefsData<String>, value: String) {
|
||||||
|
when (instance) {
|
||||||
|
is Context -> (instance as Context).modulePrefs.put(data, value)
|
||||||
|
is PackageParam -> loggerW(msg = "Not support for this method")
|
||||||
|
else -> error("Unknown type for put prefs data")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取 [Boolean] 数据
|
||||||
|
* @param data 键值数据模板
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
internal fun getBoolean(data: PrefsData<Boolean>) = when (instance) {
|
||||||
|
is Context -> (instance as Context).modulePrefs.get(data)
|
||||||
|
is PackageParam -> (instance as PackageParam).prefs.get(data)
|
||||||
|
else -> error("Unknown type for get prefs data")
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存入 [Boolean] 数据
|
||||||
|
* @param data 键值数据模板
|
||||||
|
* @param value 键值内容
|
||||||
|
*/
|
||||||
|
internal fun putBoolean(data: PrefsData<Boolean>, value: Boolean) {
|
||||||
|
when (instance) {
|
||||||
|
is Context -> (instance as Context).modulePrefs.put(data, value)
|
||||||
|
is PackageParam -> loggerW(msg = "Not support for this method")
|
||||||
|
else -> error("Unknown type for put prefs data")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用模块
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
var isEnableModule
|
||||||
|
get() = getBoolean(ENABLE_MODULE)
|
||||||
|
set(value) {
|
||||||
|
putBoolean(ENABLE_MODULE, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用模块日志
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
var isEnableModuleLog
|
||||||
|
get() = getBoolean(ENABLE_MODULE_LOG)
|
||||||
|
set(value) {
|
||||||
|
putBoolean(ENABLE_MODULE_LOG, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用通知图标兼容模式
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
var isEnableColorIconCompat
|
||||||
|
get() = getBoolean(ENABLE_COLOR_ICON_COMPAT)
|
||||||
|
set(value) {
|
||||||
|
putBoolean(ENABLE_COLOR_ICON_COMPAT, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否移除开发者选项警告通知
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
var isEnableRemoveDevNotify
|
||||||
|
get() = getBoolean(ENABLE_REMOVE_DEV_NOTIFY)
|
||||||
|
set(value) {
|
||||||
|
putBoolean(ENABLE_REMOVE_DEV_NOTIFY, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否移除充电完成通知
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
var isEnableRemoveChangeCompleteNotify
|
||||||
|
get() = getBoolean(ENABLE_REMOVE_CHANGE_COMPLETE_NOTIFY)
|
||||||
|
set(value) {
|
||||||
|
putBoolean(ENABLE_REMOVE_CHANGE_COMPLETE_NOTIFY, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否移除免打扰通知
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
var isEnableRemoveDndAlertNotify
|
||||||
|
get() = getBoolean(ENABLE_REMOVE_DND_ALERT_NOTIFY)
|
||||||
|
set(value) {
|
||||||
|
putBoolean(ENABLE_REMOVE_DND_ALERT_NOTIFY, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用 material 3 通知图标风格
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
var isEnableMd3NotifyIconStyle
|
||||||
|
get() = getBoolean(ENABLE_MD3_NOTIFY_ICON_STYLE)
|
||||||
|
set(value) {
|
||||||
|
putBoolean(ENABLE_MD3_NOTIFY_ICON_STYLE, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知栏中的通知图标圆角程度
|
||||||
|
* @return [Int]
|
||||||
|
*/
|
||||||
|
var notifyIconCornerSize
|
||||||
|
get() = getInt(NOTIFY_ICON_CORNER_SIZE)
|
||||||
|
set(value) {
|
||||||
|
putInt(NOTIFY_ICON_CORNER_SIZE, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否强制通知栏中的通知图标为 APP 图标
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
var isEnableNotifyIconForceAppIcon
|
||||||
|
get() = getBoolean(ENABLE_NOTIFY_ICON_FORCE_APP_ICON)
|
||||||
|
set(value) {
|
||||||
|
putBoolean(ENABLE_NOTIFY_ICON_FORCE_APP_ICON, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用媒体通知播放时自动展开
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
var isEnableNotifyMediaPanelAutoExp
|
||||||
|
get() = getBoolean(ENABLE_NOTIFY_MEDIA_PANEL_AUTO_EXP)
|
||||||
|
set(value) {
|
||||||
|
putBoolean(ENABLE_NOTIFY_MEDIA_PANEL_AUTO_EXP, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用自定义通知面板背景透明度
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
var isEnableNotifyPanelAlpha
|
||||||
|
get() = getBoolean(ENABLE_NOTIFY_PANEL_ALPHA)
|
||||||
|
set(value) {
|
||||||
|
putBoolean(ENABLE_NOTIFY_PANEL_ALPHA, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义通知面板背景透明度
|
||||||
|
* @return [Int]
|
||||||
|
*/
|
||||||
|
var notifyPanelAlphaLevel
|
||||||
|
get() = getInt(NOTIFY_PANEL_ALPHA_LEVEL)
|
||||||
|
set(value) {
|
||||||
|
putInt(NOTIFY_PANEL_ALPHA_LEVEL, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用通知图标优化
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
var isEnableNotifyIconFix
|
||||||
|
get() = getBoolean(ENABLE_NOTIFY_ICON_FIX)
|
||||||
|
set(value) {
|
||||||
|
putBoolean(ENABLE_NOTIFY_ICON_FIX, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否提醒未适配通知图标的新安装应用
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
var isEnableNotifyIconFixNotify
|
||||||
|
get() = getBoolean(ENABLE_NOTIFY_ICON_FIX_NOTIFY)
|
||||||
|
set(value) {
|
||||||
|
putBoolean(ENABLE_NOTIFY_ICON_FIX_NOTIFY, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用通知图标优化名单自动更新
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
var isEnableNotifyIconFixAuto
|
||||||
|
get() = getBoolean(ENABLE_NOTIFY_ICON_FIX_AUTO)
|
||||||
|
set(value) {
|
||||||
|
putBoolean(ENABLE_NOTIFY_ICON_FIX_AUTO, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知图标优化名单自动更新时间
|
||||||
|
* @return [String]
|
||||||
|
*/
|
||||||
|
var notifyIconFixAutoTime
|
||||||
|
get() = getString(NOTIFY_ICON_FIX_AUTO_TIME)
|
||||||
|
set(value) {
|
||||||
|
putString(NOTIFY_ICON_FIX_AUTO_TIME, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知图标优化名单同步方式
|
||||||
|
* @return [Int]
|
||||||
|
*/
|
||||||
|
var iconRuleSourceSyncType
|
||||||
|
get() = getInt(ICON_RULE_SOURCE_SYNC_TYPE)
|
||||||
|
set(value) {
|
||||||
|
putInt(ICON_RULE_SOURCE_SYNC_TYPE, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知图标优化名单同步地址
|
||||||
|
* @return [String]
|
||||||
|
*/
|
||||||
|
var iconRuleSourceSyncCustomUrl
|
||||||
|
get() = getString(ICON_RULE_SOURCE_SYNC_CUSTOM_URL)
|
||||||
|
set(value) {
|
||||||
|
putString(ICON_RULE_SOURCE_SYNC_CUSTOM_URL, value)
|
||||||
|
}
|
||||||
|
}
|
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* ColorOSNotifyIcon - Optimize notification icons for ColorOS and adapt to native notification icon specifications.
|
|
||||||
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
|
||||||
* https://github.com/fankes/ColorOSNotifyIcon
|
|
||||||
*
|
|
||||||
* This software is non-free but opensource software: you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Affero General Public License
|
|
||||||
* as published by the Free Software Foundation; either
|
|
||||||
* version 3 of the License, or any later version.
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* This software is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* and eula along with this software. If not, see
|
|
||||||
* <https://www.gnu.org/licenses/>
|
|
||||||
*
|
|
||||||
* This file is Created by fankes on 2022/3/28.
|
|
||||||
*/
|
|
||||||
package com.fankes.coloros.notify.data
|
|
||||||
|
|
||||||
import com.fankes.coloros.notify.hook.HookConst
|
|
||||||
import com.fankes.coloros.notify.utils.factory.isUpperOfAndroidS
|
|
||||||
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
|
|
||||||
|
|
||||||
object DataConst {
|
|
||||||
|
|
||||||
val ENABLE_MODULE = PrefsData("_enable_module", true)
|
|
||||||
val ENABLE_MODULE_LOG = PrefsData("_enable_module_log", false)
|
|
||||||
val ENABLE_COLOR_ICON_COMPAT = PrefsData("_color_icon_compat", false)
|
|
||||||
val ENABLE_MD3_NOTIFY_ICON_STYLE = PrefsData("_notify_icon_md3_style", isUpperOfAndroidS)
|
|
||||||
val ENABLE_NOTIFY_ICON_FIX = PrefsData("_notify_icon_fix", true)
|
|
||||||
val ENABLE_NOTIFY_ICON_FORCE_APP_ICON = PrefsData("_notify_icon_force_app_icon", false)
|
|
||||||
val ENABLE_NOTIFY_ICON_FIX_NOTIFY = PrefsData("_notify_icon_fix_notify", true)
|
|
||||||
val REMOVE_DEV_NOTIFY = PrefsData("_remove_dev_notify", true)
|
|
||||||
val REMOVE_CHANGECP_NOTIFY = PrefsData("_remove_charge_complete_notify", false)
|
|
||||||
val REMOVE_DNDALERT_NOTIFY = PrefsData("_remove_dndalert_notify", false)
|
|
||||||
val ENABLE_NOTIFY_ICON_FIX_AUTO = PrefsData("_enable_notify_icon_fix_auto", true)
|
|
||||||
val ENABLE_NOTIFY_PANEL_ALPHA = PrefsData("_enable_notify_panel_alpha", false)
|
|
||||||
val ENABLE_NOTIFY_MEDIA_PANEL_AUTO_EXP = PrefsData("_enable_notify_media_panel_auto_exp", false)
|
|
||||||
val NOTIFY_ICON_CORNER = PrefsData("_notify_icon_corner", 10)
|
|
||||||
val NOTIFY_PANEL_ALPHA = PrefsData("_notify_panel_alpha_pst", 75)
|
|
||||||
val NOTIFY_ICON_DATAS = PrefsData("_notify_icon_datas", "")
|
|
||||||
val NOTIFY_ICON_FIX_AUTO_TIME = PrefsData("_notify_icon_fix_auto_time", "07:00")
|
|
||||||
|
|
||||||
val SOURCE_SYNC_WAY = PrefsData("_rule_source_sync_way", HookConst.TYPE_SOURCE_SYNC_WAY_1)
|
|
||||||
val SOURCE_SYNC_WAY_CUSTOM_URL = PrefsData("_rule_source_sync_way_custom_url", "")
|
|
||||||
}
|
|
@@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* ColorOSNotifyIcon - Optimize notification icons for ColorOS and adapt to native notification icon specifications.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/ColorOSNotifyIcon
|
||||||
|
*
|
||||||
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
* This file is Created by fankes on 2023/2/3.
|
||||||
|
*/
|
||||||
|
@file:Suppress("unused", "MemberVisibilityCanBePrivate")
|
||||||
|
|
||||||
|
package com.fankes.coloros.notify.data.factory
|
||||||
|
|
||||||
|
import android.widget.CompoundButton
|
||||||
|
import com.fankes.coloros.notify.data.ConfigData
|
||||||
|
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定到 [CompoundButton] 自动设置选中状态
|
||||||
|
* @param data 键值数据模板
|
||||||
|
* @param initiate 方法体
|
||||||
|
*/
|
||||||
|
fun CompoundButton.bind(data: PrefsData<Boolean>, initiate: CompoundButtonDataBinder.(CompoundButton) -> Unit = {}) {
|
||||||
|
val binder = CompoundButtonDataBinder(button = this).also { initiate(it, this) }
|
||||||
|
isChecked = ConfigData.getBoolean(data).also { binder.initializeCallback?.invoke(it) }
|
||||||
|
binder.applyChangesCallback = { ConfigData.putBoolean(data, it) }
|
||||||
|
setOnCheckedChangeListener { button, isChecked ->
|
||||||
|
if (button.isPressed) {
|
||||||
|
if (binder.isAutoApplyChanges) binder.applyChangesCallback?.invoke(isChecked)
|
||||||
|
binder.changedCallback?.invoke(isChecked)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [CompoundButton] 数据绑定管理器实例
|
||||||
|
* @param button 当前实例
|
||||||
|
*/
|
||||||
|
class CompoundButtonDataBinder(private val button: CompoundButton) {
|
||||||
|
|
||||||
|
/** 状态初始化回调事件 */
|
||||||
|
internal var initializeCallback: ((Boolean) -> Unit)? = null
|
||||||
|
|
||||||
|
/** 状态改变回调事件 */
|
||||||
|
internal var changedCallback: ((Boolean) -> Unit)? = null
|
||||||
|
|
||||||
|
/** 应用更改回调事件 */
|
||||||
|
internal var applyChangesCallback: ((Boolean) -> Unit)? = null
|
||||||
|
|
||||||
|
/** 是否启用自动应用更改 */
|
||||||
|
var isAutoApplyChanges = true
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听状态初始化
|
||||||
|
* @param result 回调结果
|
||||||
|
*/
|
||||||
|
fun onInitialize(result: (Boolean) -> Unit) {
|
||||||
|
initializeCallback = result
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听状态改变
|
||||||
|
* @param result 回调结果
|
||||||
|
*/
|
||||||
|
fun onChanged(result: (Boolean) -> Unit) {
|
||||||
|
changedCallback = result
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重新初始化 */
|
||||||
|
fun reinitialize() {
|
||||||
|
initializeCallback?.invoke(button.isChecked)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 应用更改并重新初始化 */
|
||||||
|
fun applyChangesAndReinitialize() {
|
||||||
|
applyChanges()
|
||||||
|
reinitialize()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 应用更改 */
|
||||||
|
fun applyChanges() {
|
||||||
|
applyChangesCallback?.invoke(button.isChecked)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 取消更改 */
|
||||||
|
fun cancelChanges() {
|
||||||
|
button.isChecked = button.isChecked.not()
|
||||||
|
}
|
||||||
|
}
|
@@ -22,8 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.fankes.coloros.notify.hook
|
package com.fankes.coloros.notify.hook
|
||||||
|
|
||||||
import com.fankes.coloros.notify.data.DataConst
|
import com.fankes.coloros.notify.const.PackageName
|
||||||
import com.fankes.coloros.notify.hook.HookConst.SYSTEMUI_PACKAGE_NAME
|
import com.fankes.coloros.notify.data.ConfigData
|
||||||
import com.fankes.coloros.notify.hook.entity.SystemUIHooker
|
import com.fankes.coloros.notify.hook.entity.SystemUIHooker
|
||||||
import com.fankes.coloros.notify.utils.factory.isNotColorOS
|
import com.fankes.coloros.notify.utils.factory.isNotColorOS
|
||||||
import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed
|
import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed
|
||||||
@@ -41,13 +41,11 @@ object HookEntry : IYukiHookXposedInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onHook() = encase {
|
override fun onHook() = encase {
|
||||||
loadApp(SYSTEMUI_PACKAGE_NAME) {
|
loadApp(PackageName.SYSTEMUI) {
|
||||||
|
ConfigData.init(instance = this)
|
||||||
when {
|
when {
|
||||||
/** 不是 ColorOS 系统停止 Hook */
|
|
||||||
isNotColorOS -> loggerW(msg = "Aborted Hook -> This System is not ColorOS")
|
isNotColorOS -> loggerW(msg = "Aborted Hook -> This System is not ColorOS")
|
||||||
/** Hook 被手动关闭停止 Hook */
|
ConfigData.isEnableModule.not() -> loggerW(msg = "Aborted Hook -> Hook Closed")
|
||||||
prefs.get(DataConst.ENABLE_MODULE).not() -> loggerW(msg = "Aborted Hook -> Hook Closed")
|
|
||||||
/** 开始 Hook */
|
|
||||||
else -> loadHooker(SystemUIHooker)
|
else -> loadHooker(SystemUIHooker)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,12 +45,11 @@ import androidx.core.graphics.drawable.toBitmap
|
|||||||
import androidx.core.view.children
|
import androidx.core.view.children
|
||||||
import com.fankes.coloros.notify.R
|
import com.fankes.coloros.notify.R
|
||||||
import com.fankes.coloros.notify.bean.IconDataBean
|
import com.fankes.coloros.notify.bean.IconDataBean
|
||||||
import com.fankes.coloros.notify.data.DataConst
|
import com.fankes.coloros.notify.const.PackageName
|
||||||
import com.fankes.coloros.notify.hook.HookConst.ANDROID_PACKAGE_NAME
|
import com.fankes.coloros.notify.data.ConfigData
|
||||||
import com.fankes.coloros.notify.hook.HookConst.SYSTEMUI_PACKAGE_NAME
|
|
||||||
import com.fankes.coloros.notify.hook.factory.isAppNotifyHookAllOf
|
|
||||||
import com.fankes.coloros.notify.hook.factory.isAppNotifyHookOf
|
|
||||||
import com.fankes.coloros.notify.param.IconPackParams
|
import com.fankes.coloros.notify.param.IconPackParams
|
||||||
|
import com.fankes.coloros.notify.param.factory.isAppNotifyHookAllOf
|
||||||
|
import com.fankes.coloros.notify.param.factory.isAppNotifyHookOf
|
||||||
import com.fankes.coloros.notify.utils.factory.*
|
import com.fankes.coloros.notify.utils.factory.*
|
||||||
import com.fankes.coloros.notify.utils.tool.BitmapCompatTool
|
import com.fankes.coloros.notify.utils.tool.BitmapCompatTool
|
||||||
import com.fankes.coloros.notify.utils.tool.IconAdaptationTool
|
import com.fankes.coloros.notify.utils.tool.IconAdaptationTool
|
||||||
@@ -77,31 +76,31 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
private const val ContrastColorUtilClass = "com.android.internal.util.ContrastColorUtil"
|
private const val ContrastColorUtilClass = "com.android.internal.util.ContrastColorUtil"
|
||||||
|
|
||||||
/** 原生存在的类 */
|
/** 原生存在的类 */
|
||||||
private const val NotificationUtilsClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.NotificationUtils"
|
private const val NotificationUtilsClass = "${PackageName.SYSTEMUI}.statusbar.notification.NotificationUtils"
|
||||||
|
|
||||||
/** 原生存在的类 */
|
/** 原生存在的类 */
|
||||||
private const val NotificationEntryClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.collection.NotificationEntry"
|
private const val NotificationEntryClass = "${PackageName.SYSTEMUI}.statusbar.notification.collection.NotificationEntry"
|
||||||
|
|
||||||
/** 原生存在的类 */
|
/** 原生存在的类 */
|
||||||
private const val StatusBarIconClass = "com.android.internal.statusbar.StatusBarIcon"
|
private const val StatusBarIconClass = "com.android.internal.statusbar.StatusBarIcon"
|
||||||
|
|
||||||
/** 原生存在的类 */
|
/** 原生存在的类 */
|
||||||
private const val StatusBarIconViewClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.StatusBarIconView"
|
private const val StatusBarIconViewClass = "${PackageName.SYSTEMUI}.statusbar.StatusBarIconView"
|
||||||
|
|
||||||
/** 原生存在的类 */
|
/** 原生存在的类 */
|
||||||
private const val IconBuilderClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.icon.IconBuilder"
|
private const val IconBuilderClass = "${PackageName.SYSTEMUI}.statusbar.notification.icon.IconBuilder"
|
||||||
|
|
||||||
/** 原生存在的类 */
|
/** 原生存在的类 */
|
||||||
private const val IconManagerClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.icon.IconManager"
|
private const val IconManagerClass = "${PackageName.SYSTEMUI}.statusbar.notification.icon.IconManager"
|
||||||
|
|
||||||
/** 原生存在的类 */
|
/** 原生存在的类 */
|
||||||
private const val NotificationBackgroundViewClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.NotificationBackgroundView"
|
private const val NotificationBackgroundViewClass = "${PackageName.SYSTEMUI}.statusbar.notification.row.NotificationBackgroundView"
|
||||||
|
|
||||||
/** 原生存在的类 */
|
/** 原生存在的类 */
|
||||||
private const val PlayerViewHolderClass = "$SYSTEMUI_PACKAGE_NAME.media.PlayerViewHolder"
|
private const val PlayerViewHolderClass = "${PackageName.SYSTEMUI}.media.PlayerViewHolder"
|
||||||
|
|
||||||
/** 原生存在的类 */
|
/** 原生存在的类 */
|
||||||
private const val MediaDataClass = "$SYSTEMUI_PACKAGE_NAME.media.MediaData"
|
private const val MediaDataClass = "${PackageName.SYSTEMUI}.media.MediaData"
|
||||||
|
|
||||||
/** ColorOS 存在的类 - 旧版本不存在 */
|
/** ColorOS 存在的类 - 旧版本不存在 */
|
||||||
private const val OplusContrastColorUtilClass = "com.oplusos.util.OplusContrastColorUtil"
|
private const val OplusContrastColorUtilClass = "com.oplusos.util.OplusContrastColorUtil"
|
||||||
@@ -158,26 +157,26 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
|
|
||||||
/** 根据多个版本存在不同的包名相同的类 */
|
/** 根据多个版本存在不同的包名相同的类 */
|
||||||
private val StatusBarNotificationPresenterClass = VariousClass(
|
private val StatusBarNotificationPresenterClass = VariousClass(
|
||||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.phone.StatusBarNotificationPresenter",
|
"${PackageName.SYSTEMUI}.statusbar.phone.StatusBarNotificationPresenter",
|
||||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.phone.StatusBar"
|
"${PackageName.SYSTEMUI}.statusbar.phone.StatusBar"
|
||||||
)
|
)
|
||||||
|
|
||||||
/** 根据多个版本存在不同的包名相同的类 */
|
/** 根据多个版本存在不同的包名相同的类 */
|
||||||
private val ExpandableNotificationRowClass = VariousClass(
|
private val ExpandableNotificationRowClass = VariousClass(
|
||||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.ExpandableNotificationRow",
|
"${PackageName.SYSTEMUI}.statusbar.notification.row.ExpandableNotificationRow",
|
||||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.ExpandableNotificationRow"
|
"${PackageName.SYSTEMUI}.statusbar.ExpandableNotificationRow"
|
||||||
)
|
)
|
||||||
|
|
||||||
/** 根据多个版本存在不同的包名相同的类 */
|
/** 根据多个版本存在不同的包名相同的类 */
|
||||||
private val NotificationViewWrapperClass = VariousClass(
|
private val NotificationViewWrapperClass = VariousClass(
|
||||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.wrapper.NotificationViewWrapper",
|
"${PackageName.SYSTEMUI}.statusbar.notification.row.wrapper.NotificationViewWrapper",
|
||||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.NotificationViewWrapper"
|
"${PackageName.SYSTEMUI}.statusbar.notification.NotificationViewWrapper"
|
||||||
)
|
)
|
||||||
|
|
||||||
/** 根据多个版本存在不同的包名相同的类 */
|
/** 根据多个版本存在不同的包名相同的类 */
|
||||||
private val NotificationHeaderViewWrapperClass = VariousClass(
|
private val NotificationHeaderViewWrapperClass = VariousClass(
|
||||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.wrapper.NotificationHeaderViewWrapper",
|
"${PackageName.SYSTEMUI}.statusbar.notification.row.wrapper.NotificationHeaderViewWrapper",
|
||||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.NotificationHeaderViewWrapper"
|
"${PackageName.SYSTEMUI}.statusbar.notification.NotificationHeaderViewWrapper"
|
||||||
)
|
)
|
||||||
|
|
||||||
/** 缓存的彩色 APP 图标 */
|
/** 缓存的彩色 APP 图标 */
|
||||||
@@ -204,19 +203,11 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
/** 是否已经使用过缓存刷新功能 */
|
/** 是否已经使用过缓存刷新功能 */
|
||||||
private var isUsingCachingMethod = false
|
private var isUsingCachingMethod = false
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否启用通知图标优化功能
|
|
||||||
* @param isHooking 是否判断启用通知功能 - 默认:是
|
|
||||||
* @return [Boolean]
|
|
||||||
*/
|
|
||||||
private fun isEnableHookColorNotifyIcon(isHooking: Boolean = true) =
|
|
||||||
prefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX) && (if (isHooking) prefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_NOTIFY) else true)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断通知是否来自系统推送
|
* 判断通知是否来自系统推送
|
||||||
* @return [Boolean]
|
* @return [Boolean]
|
||||||
*/
|
*/
|
||||||
private val StatusBarNotification.isOplusPush get() = opPkg == ANDROID_PACKAGE_NAME && opPkg != packageName
|
private val StatusBarNotification.isOplusPush get() = opPkg == PackageName.SYSTEM_FRAMEWORK && opPkg != packageName
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断通知背景是否为旧版本
|
* 判断通知背景是否为旧版本
|
||||||
@@ -243,7 +234,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
isCustom: Boolean,
|
isCustom: Boolean,
|
||||||
isGrayscale: Boolean
|
isGrayscale: Boolean
|
||||||
) {
|
) {
|
||||||
if (prefs.get(DataConst.ENABLE_MODULE_LOG)) loggerD(
|
if (ConfigData.isEnableModuleLog) loggerD(
|
||||||
msg = "$tag --> [${context.appNameOf(packageName)}][$packageName] " +
|
msg = "$tag --> [${context.appNameOf(packageName)}][$packageName] " +
|
||||||
"custom [$isCustom] " +
|
"custom [$isCustom] " +
|
||||||
"grayscale [$isGrayscale]"
|
"grayscale [$isGrayscale]"
|
||||||
@@ -322,7 +313,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
* @return [Boolean]
|
* @return [Boolean]
|
||||||
*/
|
*/
|
||||||
private fun isGrayscaleIcon(context: Context, drawable: Drawable) =
|
private fun isGrayscaleIcon(context: Context, drawable: Drawable) =
|
||||||
if (prefs.get(DataConst.ENABLE_COLOR_ICON_COMPAT).not()) safeOfFalse {
|
if (ConfigData.isEnableColorIconCompat.not()) safeOfFalse {
|
||||||
ContrastColorUtilClass.toClass().let {
|
ContrastColorUtilClass.toClass().let {
|
||||||
it.method {
|
it.method {
|
||||||
name = "isGrayscaleIcon"
|
name = "isGrayscaleIcon"
|
||||||
@@ -362,10 +353,10 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
}.getOrNull() ?: context.resources.drawableOf(R.drawable.ic_unsupported)
|
}.getOrNull() ?: context.resources.drawableOf(R.drawable.ic_unsupported)
|
||||||
when {
|
when {
|
||||||
/** 替换系统图标为 Android 默认 */
|
/** 替换系统图标为 Android 默认 */
|
||||||
(packageName == ANDROID_PACKAGE_NAME || packageName == SYSTEMUI_PACKAGE_NAME) && isGrayscaleIcon.not() ->
|
(packageName == PackageName.SYSTEM_FRAMEWORK || packageName == PackageName.SYSTEMUI) && isGrayscaleIcon.not() ->
|
||||||
customPair = Pair(statSysAdbIcon, 0)
|
customPair = Pair(statSysAdbIcon, 0)
|
||||||
/** 替换自定义通知图标 */
|
/** 替换自定义通知图标 */
|
||||||
prefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX) -> run {
|
ConfigData.isEnableNotifyIconFix -> run {
|
||||||
iconDatas.takeIf { it.isNotEmpty() }?.forEach {
|
iconDatas.takeIf { it.isNotEmpty() }?.forEach {
|
||||||
if (packageName == it.packageName && isAppNotifyHookOf(it)) {
|
if (packageName == it.packageName && isAppNotifyHookOf(it)) {
|
||||||
if (isGrayscaleIcon.not() || isAppNotifyHookAllOf(it))
|
if (isGrayscaleIcon.not() || isAppNotifyHookAllOf(it))
|
||||||
@@ -428,22 +419,18 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
/** 清除之前图标可能存在的背景 */
|
/** 清除之前图标可能存在的背景 */
|
||||||
iconView.background = null
|
iconView.background = null
|
||||||
when {
|
when {
|
||||||
prefs.get(DataConst.ENABLE_NOTIFY_ICON_FORCE_APP_ICON) ->
|
ConfigData.isEnableNotifyIconForceAppIcon -> placeholderView.apply {
|
||||||
placeholderView.apply {
|
/** 重新设置图标 */
|
||||||
/** 重新设置图标 */
|
setImageDrawable(appIcons[packageName] ?: context.appIconOf(packageName))
|
||||||
setImageDrawable(appIcons[packageName] ?: context.appIconOf(packageName))
|
/** 设置默认样式 */
|
||||||
/** 设置默认样式 */
|
setDefaultNotifyIconViewStyle()
|
||||||
setDefaultNotifyIconViewStyle()
|
}
|
||||||
}
|
|
||||||
customPair.first != null || isGrayscaleIcon -> placeholderView.apply {
|
customPair.first != null || isGrayscaleIcon -> placeholderView.apply {
|
||||||
/** 设置不要裁切到边界 */
|
/** 设置不要裁切到边界 */
|
||||||
clipToOutline = false
|
clipToOutline = false
|
||||||
/** 重新设置图标 */
|
/** 重新设置图标 */
|
||||||
setImageDrawable(customPair.first ?: drawable)
|
setImageDrawable(customPair.first ?: drawable)
|
||||||
|
|
||||||
/** 是否开启 Material 3 风格 */
|
|
||||||
val isMaterial3Style = prefs.get(DataConst.ENABLE_MD3_NOTIFY_ICON_STYLE)
|
|
||||||
|
|
||||||
/** 旧版风格 */
|
/** 旧版风格 */
|
||||||
val oldStyle = (if (context.isSystemInDarkMode) 0xffdcdcdc else 0xff707173).toInt()
|
val oldStyle = (if (context.isSystemInDarkMode) 0xffdcdcdc else 0xff707173).toInt()
|
||||||
|
|
||||||
@@ -461,11 +448,11 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
val newApplyColor = customPair.second.takeIf { it != 0 } ?: iconColor.takeIf { it != 0 } ?: md3Style
|
val newApplyColor = customPair.second.takeIf { it != 0 } ?: iconColor.takeIf { it != 0 } ?: md3Style
|
||||||
|
|
||||||
/** 判断风格并开始 Hook */
|
/** 判断风格并开始 Hook */
|
||||||
if (isMaterial3Style) {
|
if (ConfigData.isEnableMd3NotifyIconStyle) {
|
||||||
/** 通知图标边框圆角大小 */
|
/** 通知图标边框圆角大小 */
|
||||||
background = DrawableBuilder()
|
background = DrawableBuilder()
|
||||||
.rectangle()
|
.rectangle()
|
||||||
.cornerRadius(prefs.get(DataConst.NOTIFY_ICON_CORNER).dp(context))
|
.cornerRadius(ConfigData.notifyIconCornerSize.dp(context))
|
||||||
.solidColor(newApplyColor)
|
.solidColor(newApplyColor)
|
||||||
.build()
|
.build()
|
||||||
setColorFilter(newStyle)
|
setColorFilter(newStyle)
|
||||||
@@ -495,26 +482,25 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
* @param isTint 是否着色 [view]
|
* @param isTint 是否着色 [view]
|
||||||
*/
|
*/
|
||||||
private fun modifyNotifyPanelAlpha(view: View?, drawable: Drawable? = null, isTint: Boolean = false) {
|
private fun modifyNotifyPanelAlpha(view: View?, drawable: Drawable? = null, isTint: Boolean = false) {
|
||||||
prefs.get(DataConst.ENABLE_NOTIFY_PANEL_ALPHA).also { isEnabled ->
|
val isEnable = ConfigData.isEnableNotifyPanelAlpha
|
||||||
val currentAlpha = prefs.get(DataConst.NOTIFY_PANEL_ALPHA)
|
val currentAlpha = ConfigData.notifyPanelAlphaLevel
|
||||||
val currendColor = if (view?.context?.isSystemInDarkMode == true) 0xFF404040.toInt() else 0xFFFAFAFA.toInt()
|
val currendColor = if (view?.context?.isSystemInDarkMode == true) 0xFF404040.toInt() else 0xFFFAFAFA.toInt()
|
||||||
/** 设置通知面板背景透明度 */
|
/** 设置通知面板背景透明度 */
|
||||||
when {
|
when {
|
||||||
isEnabled.not() -> {
|
isEnable.not() -> {
|
||||||
if (isTint) view?.backgroundTintList = ColorStateList.valueOf(currendColor)
|
if (isTint) view?.backgroundTintList = ColorStateList.valueOf(currendColor)
|
||||||
else drawable?.setTint(currendColor)
|
else drawable?.setTint(currendColor)
|
||||||
}
|
}
|
||||||
isTint.not() && view?.parent?.parent?.javaClass?.name?.contains("ChildrenContainer") == true -> drawable?.alpha = 0
|
isTint.not() && view?.parent?.parent?.javaClass?.name?.contains("ChildrenContainer") == true -> drawable?.alpha = 0
|
||||||
else -> {
|
else -> {
|
||||||
currendColor.colorAlphaOf(currentAlpha / 100f).also {
|
currendColor.colorAlphaOf(currentAlpha / 100f).also {
|
||||||
if (isTint) view?.backgroundTintList = ColorStateList.valueOf(it)
|
if (isTint) view?.backgroundTintList = ColorStateList.valueOf(it)
|
||||||
else drawable?.setTint(it)
|
else drawable?.setTint(it)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 移除阴影效果 */
|
|
||||||
if (isEnabled) view?.elevation = 0f
|
|
||||||
}
|
}
|
||||||
|
/** 移除阴影效果 */
|
||||||
|
if (isEnable) view?.elevation = 0f
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 设置默认通知栏通知图标样式 */
|
/** 设置默认通知栏通知图标样式 */
|
||||||
@@ -545,8 +531,8 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
registerReceiver(Intent.ACTION_USER_PRESENT) { _, _ -> if (isUsingCachingMethod) refreshStatusBarIcons() }
|
registerReceiver(Intent.ACTION_USER_PRESENT) { _, _ -> if (isUsingCachingMethod) refreshStatusBarIcons() }
|
||||||
/** 注册定时监听 */
|
/** 注册定时监听 */
|
||||||
registerReceiver(Intent.ACTION_TIME_TICK) { context, _ ->
|
registerReceiver(Intent.ACTION_TIME_TICK) { context, _ ->
|
||||||
if (isEnableHookColorNotifyIcon() && prefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_AUTO))
|
if (ConfigData.isEnableNotifyIconFix && ConfigData.isEnableNotifyIconFixNotify && ConfigData.isEnableNotifyIconFixAuto)
|
||||||
IconAdaptationTool.prepareAutoUpdateIconRule(context, prefs.get(DataConst.NOTIFY_ICON_FIX_AUTO_TIME))
|
IconAdaptationTool.prepareAutoUpdateIconRule(context, ConfigData.notifyIconFixAutoTime)
|
||||||
}
|
}
|
||||||
/** 注册发送适配新的 APP 图标通知监听 */
|
/** 注册发送适配新的 APP 图标通知监听 */
|
||||||
registerReceiver(IntentFilter().apply {
|
registerReceiver(IntentFilter().apply {
|
||||||
@@ -555,21 +541,21 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
addAction(Intent.ACTION_PACKAGE_REPLACED)
|
addAction(Intent.ACTION_PACKAGE_REPLACED)
|
||||||
addAction(Intent.ACTION_PACKAGE_REMOVED)
|
addAction(Intent.ACTION_PACKAGE_REMOVED)
|
||||||
}) { context, intent ->
|
}) { context, intent ->
|
||||||
if (isEnableHookColorNotifyIcon().not()) return@registerReceiver
|
|
||||||
if (intent.action.equals(Intent.ACTION_PACKAGE_REPLACED).not() &&
|
if (intent.action.equals(Intent.ACTION_PACKAGE_REPLACED).not() &&
|
||||||
intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)
|
intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)
|
||||||
) return@registerReceiver
|
) return@registerReceiver
|
||||||
intent.data?.schemeSpecificPart?.also { packageName ->
|
if (ConfigData.isEnableNotifyIconFix && ConfigData.isEnableNotifyIconFixNotify)
|
||||||
when (intent.action) {
|
intent.data?.schemeSpecificPart?.also { packageName ->
|
||||||
Intent.ACTION_PACKAGE_ADDED -> {
|
when (intent.action) {
|
||||||
if (iconDatas.takeIf { e -> e.isNotEmpty() }
|
Intent.ACTION_PACKAGE_ADDED -> {
|
||||||
?.filter { e -> e.packageName == packageName }
|
if (iconDatas.takeIf { e -> e.isNotEmpty() }
|
||||||
.isNullOrEmpty()
|
?.filter { e -> e.packageName == packageName }
|
||||||
) IconAdaptationTool.pushNewAppSupportNotify(context, packageName)
|
.isNullOrEmpty()
|
||||||
|
) IconAdaptationTool.pushNewAppSupportNotify(context, packageName)
|
||||||
|
}
|
||||||
|
Intent.ACTION_PACKAGE_REMOVED -> IconAdaptationTool.removeNewAppSupportNotify(context, packageName)
|
||||||
}
|
}
|
||||||
Intent.ACTION_PACKAGE_REMOVED -> IconAdaptationTool.removeNewAppSupportNotify(context, packageName)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/** 注入模块资源 */
|
/** 注入模块资源 */
|
||||||
onCreate { injectModuleAppResources() }
|
onCreate { injectModuleAppResources() }
|
||||||
@@ -581,12 +567,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
/** 缓存图标数据 */
|
/** 缓存图标数据 */
|
||||||
private fun cachingIconDatas() {
|
private fun cachingIconDatas() {
|
||||||
iconDatas.clear()
|
iconDatas.clear()
|
||||||
IconPackParams(param = this).iconDatas.apply {
|
IconPackParams(param = this).iconDatas.apply { if (isNotEmpty()) forEach { iconDatas.add(it) } }
|
||||||
when {
|
|
||||||
isNotEmpty() -> forEach { iconDatas.add(it) }
|
|
||||||
isEmpty() && isEnableHookColorNotifyIcon(isHooking = false) -> loggerW(msg = "NotifyIconSupportData is empty!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -619,7 +600,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
method { name = "updateDeveloperMode" }
|
method { name = "updateDeveloperMode" }
|
||||||
beforeHook {
|
beforeHook {
|
||||||
/** 是否移除 */
|
/** 是否移除 */
|
||||||
if (prefs.get(DataConst.REMOVE_DEV_NOTIFY)) resultNull()
|
if (ConfigData.isEnableRemoveDevNotify) resultNull()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -632,7 +613,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
}
|
}
|
||||||
beforeHook {
|
beforeHook {
|
||||||
/** 是否移除 */
|
/** 是否移除 */
|
||||||
if (args().first().int() == 7 && prefs.get(DataConst.REMOVE_CHANGECP_NOTIFY)) resultNull()
|
if (args().first().int() == 7 && ConfigData.isEnableRemoveChangeCompleteNotify) resultNull()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -645,7 +626,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
}
|
}
|
||||||
beforeHook {
|
beforeHook {
|
||||||
/** 是否移除 */
|
/** 是否移除 */
|
||||||
if (prefs.get(DataConst.REMOVE_DNDALERT_NOTIFY)) resultNull()
|
if (ConfigData.isEnableRemoveDndAlertNotify) resultNull()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -785,8 +766,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
emptyParam()
|
emptyParam()
|
||||||
}
|
}
|
||||||
beforeHook {
|
beforeHook {
|
||||||
if (prefs.get(DataConst.ENABLE_NOTIFY_PANEL_ALPHA))
|
if (ConfigData.isEnableNotifyPanelAlpha) field { name = "mShowGroupBackgroundWhenExpanded" }.get(instance).setTrue()
|
||||||
field { name = "mShowGroupBackgroundWhenExpanded" }.get(instance).setTrue()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -822,7 +802,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
emptyParam()
|
emptyParam()
|
||||||
}?.get(field { name = "mOplusMediaViewController" }.get(instance).any())?.boolean() ?: false
|
}?.get(field { name = "mOplusMediaViewController" }.get(instance).any())?.boolean() ?: false
|
||||||
/** 符合条件后执行 */
|
/** 符合条件后执行 */
|
||||||
if (prefs.get(DataConst.ENABLE_NOTIFY_MEDIA_PANEL_AUTO_EXP).not() || isExpanded || isPlaying.not()) return@afterHook
|
if (ConfigData.isEnableNotifyMediaPanelAutoExp.not() || isExpanded || isPlaying.not()) return@afterHook
|
||||||
/** 模拟手动展开通知 */
|
/** 模拟手动展开通知 */
|
||||||
BasePlayViewHolderClass.toClassOrNull()?.method {
|
BasePlayViewHolderClass.toClassOrNull()?.method {
|
||||||
name = "getExpandButton"
|
name = "getExpandButton"
|
||||||
|
@@ -27,7 +27,7 @@ package com.fankes.coloros.notify.param
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import com.fankes.coloros.notify.bean.IconDataBean
|
import com.fankes.coloros.notify.bean.IconDataBean
|
||||||
import com.fankes.coloros.notify.data.DataConst
|
import com.fankes.coloros.notify.data.ConfigData
|
||||||
import com.fankes.coloros.notify.utils.factory.*
|
import com.fankes.coloros.notify.utils.factory.*
|
||||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
||||||
import com.highcapable.yukihookapi.hook.param.PackageParam
|
import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||||
@@ -47,7 +47,7 @@ class IconPackParams(private val context: Context? = null, private val param: Pa
|
|||||||
* 已存储的 JSON 数据
|
* 已存储的 JSON 数据
|
||||||
* @return [String]
|
* @return [String]
|
||||||
*/
|
*/
|
||||||
internal val storageDataJson get() = (context?.modulePrefs ?: param?.prefs)?.direct()?.get(DataConst.NOTIFY_ICON_DATAS)
|
internal val storageDataJson get() = (context?.modulePrefs ?: param?.prefs)?.direct()?.get(ConfigData.NOTIFY_ICONS_DATA)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取图标数据
|
* 获取图标数据
|
||||||
@@ -134,5 +134,5 @@ class IconPackParams(private val context: Context? = null, private val param: Pa
|
|||||||
* 保存图标数据
|
* 保存图标数据
|
||||||
* @param dataJson 图标数据 JSON
|
* @param dataJson 图标数据 JSON
|
||||||
*/
|
*/
|
||||||
fun save(dataJson: String) = context?.modulePrefs?.put(DataConst.NOTIFY_ICON_DATAS, dataJson)
|
fun save(dataJson: String) = context?.modulePrefs?.put(ConfigData.NOTIFY_ICONS_DATA, dataJson)
|
||||||
}
|
}
|
||||||
|
@@ -19,8 +19,9 @@
|
|||||||
* <https://www.gnu.org/licenses/>
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/2/15.
|
* This file is Created by fankes on 2022/2/15.
|
||||||
|
* This file is Modified by fankes on 2023/2/3.
|
||||||
*/
|
*/
|
||||||
package com.fankes.coloros.notify.hook.factory
|
package com.fankes.coloros.notify.param.factory
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.fankes.coloros.notify.bean.IconDataBean
|
import com.fankes.coloros.notify.bean.IconDataBean
|
@@ -30,10 +30,10 @@ import com.fankes.coloros.notify.bean.IconDataBean
|
|||||||
import com.fankes.coloros.notify.databinding.ActivityConfigBinding
|
import com.fankes.coloros.notify.databinding.ActivityConfigBinding
|
||||||
import com.fankes.coloros.notify.databinding.AdapterConfigBinding
|
import com.fankes.coloros.notify.databinding.AdapterConfigBinding
|
||||||
import com.fankes.coloros.notify.databinding.DiaIconFilterBinding
|
import com.fankes.coloros.notify.databinding.DiaIconFilterBinding
|
||||||
import com.fankes.coloros.notify.hook.factory.isAppNotifyHookAllOf
|
import com.fankes.coloros.notify.param.factory.isAppNotifyHookAllOf
|
||||||
import com.fankes.coloros.notify.hook.factory.isAppNotifyHookOf
|
import com.fankes.coloros.notify.param.factory.isAppNotifyHookOf
|
||||||
import com.fankes.coloros.notify.hook.factory.putAppNotifyHookAllOf
|
import com.fankes.coloros.notify.param.factory.putAppNotifyHookAllOf
|
||||||
import com.fankes.coloros.notify.hook.factory.putAppNotifyHookOf
|
import com.fankes.coloros.notify.param.factory.putAppNotifyHookOf
|
||||||
import com.fankes.coloros.notify.param.IconPackParams
|
import com.fankes.coloros.notify.param.IconPackParams
|
||||||
import com.fankes.coloros.notify.ui.activity.base.BaseActivity
|
import com.fankes.coloros.notify.ui.activity.base.BaseActivity
|
||||||
import com.fankes.coloros.notify.utils.factory.*
|
import com.fankes.coloros.notify.utils.factory.*
|
||||||
|
@@ -29,7 +29,8 @@ import android.widget.SeekBar.OnSeekBarChangeListener
|
|||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.fankes.coloros.notify.BuildConfig
|
import com.fankes.coloros.notify.BuildConfig
|
||||||
import com.fankes.coloros.notify.R
|
import com.fankes.coloros.notify.R
|
||||||
import com.fankes.coloros.notify.data.DataConst
|
import com.fankes.coloros.notify.data.ConfigData
|
||||||
|
import com.fankes.coloros.notify.data.factory.bind
|
||||||
import com.fankes.coloros.notify.databinding.ActivityMainBinding
|
import com.fankes.coloros.notify.databinding.ActivityMainBinding
|
||||||
import com.fankes.coloros.notify.param.IconPackParams
|
import com.fankes.coloros.notify.param.IconPackParams
|
||||||
import com.fankes.coloros.notify.ui.activity.base.BaseActivity
|
import com.fankes.coloros.notify.ui.activity.base.BaseActivity
|
||||||
@@ -38,7 +39,6 @@ import com.fankes.coloros.notify.utils.tool.GithubReleaseTool
|
|||||||
import com.fankes.coloros.notify.utils.tool.SystemUITool
|
import com.fankes.coloros.notify.utils.tool.SystemUITool
|
||||||
import com.fankes.coloros.notify.utils.tool.YukiPromoteTool
|
import com.fankes.coloros.notify.utils.tool.YukiPromoteTool
|
||||||
import com.highcapable.yukihookapi.YukiHookAPI
|
import com.highcapable.yukihookapi.YukiHookAPI
|
||||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
|
||||||
|
|
||||||
class MainActivity : BaseActivity<ActivityMainBinding>() {
|
class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||||
|
|
||||||
@@ -63,9 +63,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
/** 设置可用性 */
|
/** 设置可用性 */
|
||||||
isActivityLive = true
|
isActivityLive = true
|
||||||
/** 设置文本 */
|
|
||||||
binding.mainTextVersion.text = "模块版本:$moduleVersion $pendingFlag"
|
|
||||||
binding.mainTextColorOsVersion.text = "系统版本:$colorOSFullVersion"
|
|
||||||
/** 检查更新 */
|
/** 检查更新 */
|
||||||
GithubReleaseTool.checkingForUpdate(context = this, moduleVersion) { version, function ->
|
GithubReleaseTool.checkingForUpdate(context = this, moduleVersion) { version, function ->
|
||||||
binding.mainTextReleaseVersion.apply {
|
binding.mainTextReleaseVersion.apply {
|
||||||
@@ -89,7 +86,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
}
|
}
|
||||||
/** 判断是否 Hook */
|
/** 判断是否 Hook */
|
||||||
YukiHookAPI.Status.isXposedModuleActive -> {
|
YukiHookAPI.Status.isXposedModuleActive -> {
|
||||||
if (IconPackParams(context = this).iconDatas.isEmpty() && modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX))
|
if (IconPackParams(context = this).iconDatas.isEmpty() && ConfigData.isEnableNotifyIconFix)
|
||||||
showDialog {
|
showDialog {
|
||||||
title = "配置通知图标优化名单"
|
title = "配置通知图标优化名单"
|
||||||
msg = "模块需要获取在线规则以更新“通知图标优化名单”,它现在是空的,这看起来是你第一次使用模块,请首先进行配置才可以使用相关功能。\n" +
|
msg = "模块需要获取在线规则以更新“通知图标优化名单”,它现在是空的,这看起来是你第一次使用模块,请首先进行配置才可以使用相关功能。\n" +
|
||||||
@@ -98,7 +95,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
cancelButton()
|
cancelButton()
|
||||||
noCancelable()
|
noCancelable()
|
||||||
}
|
}
|
||||||
if (isNotNoificationEnabled && modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX))
|
if (isNotNoificationEnabled && ConfigData.isEnableNotifyIconFix)
|
||||||
showDialog {
|
showDialog {
|
||||||
title = "模块的通知权限已关闭"
|
title = "模块的通知权限已关闭"
|
||||||
msg = "请开启通知权限,以确保你能收到通知优化图标在线规则的更新。"
|
msg = "请开启通知权限,以确保你能收到通知优化图标在线规则的更新。"
|
||||||
@@ -120,142 +117,123 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
noCancelable()
|
noCancelable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var notifyIconAutoSyncTime = modulePrefs.get(DataConst.NOTIFY_ICON_FIX_AUTO_TIME)
|
binding.mainTextVersion.text = "模块版本:$moduleVersion $pendingFlag"
|
||||||
binding.devNotifyConfigItem.isVisible = modulePrefs.get(DataConst.ENABLE_MODULE)
|
binding.mainTextColorOsVersion.text = "系统版本:$colorOSFullVersion"
|
||||||
binding.notifyStyleConfigItem.isVisible = modulePrefs.get(DataConst.ENABLE_MODULE)
|
|
||||||
binding.notifyIconConfigItem.isVisible = modulePrefs.get(DataConst.ENABLE_MODULE)
|
|
||||||
binding.notifyIconFixButton.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
|
||||||
binding.notifyIconCustomCornerItem.isVisible = modulePrefs.get(DataConst.ENABLE_MD3_NOTIFY_ICON_STYLE) &&
|
|
||||||
modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FORCE_APP_ICON).not()
|
|
||||||
binding.notifyIconFixNotifyItem.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
|
||||||
binding.notifyIconAutoSyncItem.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
|
||||||
binding.notifyIconAutoSyncChildItem.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_AUTO)
|
|
||||||
binding.notifyPanelConfigSeekbar.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_PANEL_ALPHA)
|
|
||||||
binding.notifyPanelConfigTextPanel.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_PANEL_ALPHA)
|
|
||||||
binding.notifyPanelConfigWarnPanel.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_PANEL_ALPHA)
|
|
||||||
binding.devNotifyConfigSwitch.isChecked = modulePrefs.get(DataConst.REMOVE_DEV_NOTIFY)
|
|
||||||
binding.crcpNotifyConfigSwitch.isChecked = modulePrefs.get(DataConst.REMOVE_CHANGECP_NOTIFY)
|
|
||||||
binding.dndNotifyConfigSwitch.isChecked = modulePrefs.get(DataConst.REMOVE_DNDALERT_NOTIFY)
|
|
||||||
binding.md3StyleConfigSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MD3_NOTIFY_ICON_STYLE)
|
|
||||||
binding.notifyMediaPanelAutoExpSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_MEDIA_PANEL_AUTO_EXP)
|
|
||||||
binding.moduleEnableSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MODULE)
|
|
||||||
binding.moduleEnableLogSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MODULE_LOG)
|
|
||||||
binding.colorIconCompatSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_COLOR_ICON_COMPAT)
|
|
||||||
binding.notifyIconFixSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
|
||||||
binding.notifyIconForceAppIconSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FORCE_APP_ICON)
|
|
||||||
binding.notifyIconFixNotifySwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_NOTIFY)
|
|
||||||
binding.notifyIconAutoSyncSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_AUTO)
|
|
||||||
binding.notifyPanelConfigSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_PANEL_ALPHA)
|
|
||||||
binding.notifyPanelConfigSeekbar.progress = modulePrefs.get(DataConst.NOTIFY_PANEL_ALPHA)
|
|
||||||
binding.notifyIconCustomCornerSeekbar.progress = modulePrefs.get(DataConst.NOTIFY_ICON_CORNER)
|
|
||||||
binding.notifyPanelConfigText.text = "${modulePrefs.get(DataConst.NOTIFY_PANEL_ALPHA)}%"
|
|
||||||
binding.notifyIconCustomCornerText.text = "${modulePrefs.get(DataConst.NOTIFY_ICON_CORNER)} dp"
|
|
||||||
binding.notifyIconAutoSyncText.text = notifyIconAutoSyncTime
|
|
||||||
/** 媒体通知自动展开仅支持 12.1 - 旧版本适配过于复杂已放弃 */
|
/** 媒体通知自动展开仅支持 12.1 - 旧版本适配过于复杂已放弃 */
|
||||||
if (colorOSNumberVersion != "V12.1") {
|
if (colorOSNumberVersion != "V12.1") {
|
||||||
binding.notifyMediaPanelAutoExpSwitch.isVisible = false
|
binding.notifyMediaPanelAutoExpSwitch.isVisible = false
|
||||||
binding.notifyMediaPanelAutoExpText.isVisible = false
|
binding.notifyMediaPanelAutoExpText.isVisible = false
|
||||||
}
|
}
|
||||||
binding.moduleEnableSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.notifyPanelConfigSeekbar.progress = ConfigData.notifyPanelAlphaLevel
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
binding.notifyIconCustomCornerSeekbar.progress = ConfigData.notifyIconCornerSize
|
||||||
modulePrefs.put(DataConst.ENABLE_MODULE, b)
|
binding.notifyPanelConfigText.text = "${ConfigData.notifyPanelAlphaLevel}%"
|
||||||
binding.moduleEnableLogSwitch.isVisible = b
|
binding.notifyIconCustomCornerText.text = "${ConfigData.notifyIconCornerSize} dp"
|
||||||
binding.notifyIconConfigItem.isVisible = b
|
binding.notifyIconAutoSyncText.text = ConfigData.notifyIconFixAutoTime
|
||||||
binding.devNotifyConfigItem.isVisible = b
|
binding.moduleEnableSwitch.bind(ConfigData.ENABLE_MODULE) {
|
||||||
binding.notifyStyleConfigItem.isVisible = b
|
onInitialize {
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
binding.moduleEnableLogSwitch.isVisible = it
|
||||||
}
|
binding.notifyIconConfigItem.isVisible = it
|
||||||
binding.moduleEnableLogSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.devNotifyConfigItem.isVisible = it
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
binding.notifyStyleConfigItem.isVisible = it
|
||||||
modulePrefs.put(DataConst.ENABLE_MODULE_LOG, b)
|
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
|
||||||
}
|
|
||||||
binding.colorIconCompatSwitch.setOnCheckedChangeListener { btn, b ->
|
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
|
||||||
/** 保存当前配置并生效 */
|
|
||||||
fun saveConfigs() {
|
|
||||||
modulePrefs.put(DataConst.ENABLE_COLOR_ICON_COMPAT, b)
|
|
||||||
SystemUITool.refreshSystemUI(context = this)
|
|
||||||
}
|
}
|
||||||
if (b) showDialog {
|
onChanged {
|
||||||
title = "启用兼容模式"
|
reinitialize()
|
||||||
msg = "启用兼容模式可修复部分系统版本可能出现无法判定通知图标反色的问题," +
|
refreshModuleStatus()
|
||||||
"但是这也可能会导致新的问题,一般情况下不建议开启,确定要继续吗?\n\n" +
|
SystemUITool.showNeedRestartSnake(context = this@MainActivity)
|
||||||
"如果系统界面刷新后通知图标颜色发生错误,请尝试重启一次系统界面。"
|
|
||||||
confirmButton { saveConfigs() }
|
|
||||||
cancelButton { btn.isChecked = false }
|
|
||||||
noCancelable()
|
|
||||||
} else saveConfigs()
|
|
||||||
}
|
|
||||||
binding.notifyIconFixSwitch.setOnCheckedChangeListener { btn, b ->
|
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
|
||||||
modulePrefs.put(DataConst.ENABLE_NOTIFY_ICON_FIX, b)
|
|
||||||
binding.notifyIconFixButton.isVisible = b
|
|
||||||
binding.notifyIconFixNotifyItem.isVisible = b
|
|
||||||
binding.notifyIconAutoSyncItem.isVisible = b
|
|
||||||
SystemUITool.refreshSystemUI(context = this)
|
|
||||||
}
|
|
||||||
binding.notifyIconForceAppIconSwitch.setOnCheckedChangeListener { btn, b ->
|
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
|
||||||
fun saveState() {
|
|
||||||
binding.notifyIconCustomCornerItem.isVisible = b.not() && modulePrefs.get(DataConst.ENABLE_MD3_NOTIFY_ICON_STYLE)
|
|
||||||
modulePrefs.put(DataConst.ENABLE_NOTIFY_ICON_FORCE_APP_ICON, b)
|
|
||||||
SystemUITool.refreshSystemUI(context = this)
|
|
||||||
}
|
}
|
||||||
if (b) showDialog {
|
|
||||||
title = "破坏性功能警告"
|
|
||||||
msg = "开启这个功能后,任何通知栏中的通知图标都会被强制替换为当前推送通知的 APP 的图标," +
|
|
||||||
"某些系统级别的 APP 通知图标可能会显示异常或发生图标丢失。\n\n" +
|
|
||||||
"此功能仅面向一些追求图标美观度的用户,我们不推荐开启这个功能,且发生任何 BUG 都不会去修复,仍然继续开启吗?"
|
|
||||||
confirmButton { saveState() }
|
|
||||||
cancelButton { btn.isChecked = btn.isChecked.not() }
|
|
||||||
noCancelable()
|
|
||||||
} else saveState()
|
|
||||||
}
|
}
|
||||||
binding.notifyIconFixNotifySwitch.setOnCheckedChangeListener { btn, b ->
|
binding.moduleEnableLogSwitch.bind(ConfigData.ENABLE_MODULE_LOG) {
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
onChanged { SystemUITool.showNeedRestartSnake(context = this@MainActivity) }
|
||||||
modulePrefs.put(DataConst.ENABLE_NOTIFY_ICON_FIX_NOTIFY, b)
|
|
||||||
SystemUITool.refreshSystemUI(context = this, isRefreshCacheOnly = true)
|
|
||||||
}
|
}
|
||||||
binding.devNotifyConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.devNotifyConfigSwitch.bind(ConfigData.ENABLE_REMOVE_DEV_NOTIFY) {
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
onChanged { SystemUITool.refreshSystemUI(context = this@MainActivity, isRefreshCacheOnly = true) }
|
||||||
modulePrefs.put(DataConst.REMOVE_DEV_NOTIFY, b)
|
|
||||||
SystemUITool.refreshSystemUI(context = this, isRefreshCacheOnly = true)
|
|
||||||
}
|
}
|
||||||
binding.crcpNotifyConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.crcpNotifyConfigSwitch.bind(ConfigData.ENABLE_REMOVE_CHANGE_COMPLETE_NOTIFY) {
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
onChanged { SystemUITool.refreshSystemUI(context = this@MainActivity, isRefreshCacheOnly = true) }
|
||||||
modulePrefs.put(DataConst.REMOVE_CHANGECP_NOTIFY, b)
|
|
||||||
SystemUITool.refreshSystemUI(context = this, isRefreshCacheOnly = true)
|
|
||||||
}
|
}
|
||||||
binding.dndNotifyConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.dndNotifyConfigSwitch.bind(ConfigData.ENABLE_REMOVE_DND_ALERT_NOTIFY) {
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
onChanged { SystemUITool.refreshSystemUI(context = this@MainActivity, isRefreshCacheOnly = true) }
|
||||||
modulePrefs.put(DataConst.REMOVE_DNDALERT_NOTIFY, b)
|
|
||||||
SystemUITool.refreshSystemUI(context = this, isRefreshCacheOnly = true)
|
|
||||||
}
|
}
|
||||||
binding.md3StyleConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.colorIconCompatSwitch.bind(ConfigData.ENABLE_COLOR_ICON_COMPAT) {
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
isAutoApplyChanges = false
|
||||||
binding.notifyIconCustomCornerItem.isVisible = b && modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FORCE_APP_ICON).not()
|
onChanged {
|
||||||
modulePrefs.put(DataConst.ENABLE_MD3_NOTIFY_ICON_STYLE, b)
|
/** 应用更改并刷新系统界面 */
|
||||||
SystemUITool.refreshSystemUI(context = this)
|
fun applyChangesAndRefresh() {
|
||||||
|
applyChanges()
|
||||||
|
SystemUITool.refreshSystemUI(context = this@MainActivity)
|
||||||
|
}
|
||||||
|
if (it) showDialog {
|
||||||
|
title = "启用兼容模式"
|
||||||
|
msg = "启用兼容模式可修复部分系统版本可能出现无法判定通知图标反色的问题," +
|
||||||
|
"但是这也可能会导致新的问题,一般情况下不建议开启,确定要继续吗?\n\n" +
|
||||||
|
"如果系统界面刷新后通知图标颜色发生错误,请尝试重启一次系统界面。"
|
||||||
|
confirmButton { applyChangesAndRefresh() }
|
||||||
|
cancelButton { cancelChanges() }
|
||||||
|
noCancelable()
|
||||||
|
} else applyChangesAndRefresh()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
binding.notifyMediaPanelAutoExpSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.md3StyleConfigSwitch.bind(ConfigData.ENABLE_MD3_NOTIFY_ICON_STYLE) {
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
onInitialize { binding.notifyIconCustomCornerItem.isVisible = it && ConfigData.isEnableNotifyIconForceAppIcon.not() }
|
||||||
modulePrefs.put(DataConst.ENABLE_NOTIFY_MEDIA_PANEL_AUTO_EXP, b)
|
onChanged {
|
||||||
SystemUITool.refreshSystemUI(context = this, isRefreshCacheOnly = true)
|
reinitialize()
|
||||||
|
SystemUITool.refreshSystemUI(context = this@MainActivity)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
binding.notifyPanelConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.notifyIconForceAppIconSwitch.bind(ConfigData.ENABLE_NOTIFY_ICON_FORCE_APP_ICON) {
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
isAutoApplyChanges = false
|
||||||
modulePrefs.put(DataConst.ENABLE_NOTIFY_PANEL_ALPHA, b)
|
onInitialize { binding.notifyIconCustomCornerItem.isVisible = it.not() && ConfigData.isEnableMd3NotifyIconStyle }
|
||||||
binding.notifyPanelConfigTextPanel.isVisible = b
|
onChanged {
|
||||||
binding.notifyPanelConfigWarnPanel.isVisible = b
|
/** 应用更改并刷新系统界面 */
|
||||||
binding.notifyPanelConfigSeekbar.isVisible = b
|
fun applyChangesAndRefresh() {
|
||||||
SystemUITool.refreshSystemUI(context = this)
|
applyChangesAndReinitialize()
|
||||||
|
SystemUITool.refreshSystemUI(context = this@MainActivity)
|
||||||
|
}
|
||||||
|
if (it) showDialog {
|
||||||
|
title = "破坏性功能警告"
|
||||||
|
msg = "开启这个功能后,任何通知栏中的通知图标都会被强制替换为当前推送通知的 APP 的图标," +
|
||||||
|
"某些系统级别的 APP 通知图标可能会显示异常或发生图标丢失。\n\n" +
|
||||||
|
"此功能仅面向一些追求图标美观度的用户,我们不推荐开启这个功能,且发生任何 BUG 都不会去修复,仍然继续开启吗?"
|
||||||
|
confirmButton { applyChangesAndRefresh() }
|
||||||
|
cancelButton { cancelChanges() }
|
||||||
|
noCancelable()
|
||||||
|
} else applyChangesAndRefresh()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
binding.notifyIconAutoSyncSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.notifyPanelConfigSwitch.bind(ConfigData.ENABLE_NOTIFY_PANEL_ALPHA) {
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
onInitialize {
|
||||||
modulePrefs.put(DataConst.ENABLE_NOTIFY_ICON_FIX_AUTO, b)
|
binding.notifyPanelConfigTextPanel.isVisible = it
|
||||||
binding.notifyIconAutoSyncChildItem.isVisible = b
|
binding.notifyPanelConfigWarnPanel.isVisible = it
|
||||||
SystemUITool.refreshSystemUI(context = this, isRefreshCacheOnly = true)
|
binding.notifyPanelConfigSeekbar.isVisible = it
|
||||||
|
}
|
||||||
|
onChanged {
|
||||||
|
reinitialize()
|
||||||
|
SystemUITool.refreshSystemUI(context = this@MainActivity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
binding.notifyMediaPanelAutoExpSwitch.bind(ConfigData.ENABLE_NOTIFY_MEDIA_PANEL_AUTO_EXP) {
|
||||||
|
onChanged { SystemUITool.refreshSystemUI(context = this@MainActivity, isRefreshCacheOnly = true) }
|
||||||
|
}
|
||||||
|
binding.notifyIconFixSwitch.bind(ConfigData.ENABLE_NOTIFY_ICON_FIX) {
|
||||||
|
onInitialize {
|
||||||
|
binding.notifyIconFixButton.isVisible = it
|
||||||
|
binding.notifyIconFixNotifyItem.isVisible = it
|
||||||
|
binding.notifyIconAutoSyncItem.isVisible = it
|
||||||
|
}
|
||||||
|
onChanged {
|
||||||
|
reinitialize()
|
||||||
|
SystemUITool.refreshSystemUI(context = this@MainActivity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
binding.notifyIconFixNotifySwitch.bind(ConfigData.ENABLE_NOTIFY_ICON_FIX_NOTIFY) {
|
||||||
|
onChanged { SystemUITool.refreshSystemUI(context = this@MainActivity, isRefreshCacheOnly = true) }
|
||||||
|
}
|
||||||
|
binding.notifyIconAutoSyncSwitch.bind(ConfigData.ENABLE_NOTIFY_ICON_FIX_AUTO) {
|
||||||
|
onInitialize { binding.notifyIconAutoSyncChildItem.isVisible = it }
|
||||||
|
onChanged {
|
||||||
|
reinitialize()
|
||||||
|
SystemUITool.refreshSystemUI(context = this@MainActivity, isRefreshCacheOnly = true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
binding.notifyPanelConfigSeekbar.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
|
binding.notifyPanelConfigSeekbar.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
|
||||||
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
||||||
@@ -263,7 +241,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||||
modulePrefs.put(DataConst.NOTIFY_PANEL_ALPHA, seekBar.progress)
|
ConfigData.notifyPanelAlphaLevel = seekBar.progress
|
||||||
SystemUITool.refreshSystemUI(context = this@MainActivity)
|
SystemUITool.refreshSystemUI(context = this@MainActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,23 +253,17 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||||
modulePrefs.put(DataConst.NOTIFY_ICON_CORNER, seekBar.progress)
|
ConfigData.notifyIconCornerSize = seekBar.progress
|
||||||
SystemUITool.refreshSystemUI(context = this@MainActivity)
|
SystemUITool.refreshSystemUI(context = this@MainActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
|
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
|
||||||
})
|
})
|
||||||
/** 设置桌面图标显示隐藏 */
|
|
||||||
binding.hideIconInLauncherSwitch.isChecked = isLauncherIconShowing.not()
|
|
||||||
binding.hideIconInLauncherSwitch.setOnCheckedChangeListener { btn, b ->
|
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
|
||||||
hideOrShowLauncherIcon(b)
|
|
||||||
}
|
|
||||||
/** 通知图标优化名单按钮点击事件 */
|
/** 通知图标优化名单按钮点击事件 */
|
||||||
binding.notifyIconFixButton.setOnClickListener { navigate<ConfigureActivity>() }
|
binding.notifyIconFixButton.setOnClickListener { navigate<ConfigureActivity>() }
|
||||||
/** 自动更新在线规则修改时间按钮点击事件 */
|
/** 自动更新在线规则修改时间按钮点击事件 */
|
||||||
binding.notifyIconAutoSyncButton.setOnClickListener {
|
binding.notifyIconAutoSyncButton.setOnClickListener {
|
||||||
showTimePicker(notifyIconAutoSyncTime) {
|
showTimePicker(ConfigData.notifyIconFixAutoTime) {
|
||||||
showDialog {
|
showDialog {
|
||||||
title = "每天 $it 自动更新"
|
title = "每天 $it 自动更新"
|
||||||
msg = "设置保存后将在每天 $it 自动同步名单到最新云端数据,若数据已是最新则不会显示任何提示,否则会发送一条通知。\n\n" +
|
msg = "设置保存后将在每天 $it 自动同步名单到最新云端数据,若数据已是最新则不会显示任何提示,否则会发送一条通知。\n\n" +
|
||||||
@@ -301,9 +273,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
"3.模块的系统通知权限已开启\n\n" +
|
"3.模块的系统通知权限已开启\n\n" +
|
||||||
"模块无需保持在后台运行,到达同步时间后会自动启动,如果到达时间后模块正在运行则会自动取消本次计划任务。"
|
"模块无需保持在后台运行,到达同步时间后会自动启动,如果到达时间后模块正在运行则会自动取消本次计划任务。"
|
||||||
confirmButton(text = "保存设置") {
|
confirmButton(text = "保存设置") {
|
||||||
notifyIconAutoSyncTime = it
|
ConfigData.notifyIconFixAutoTime = it
|
||||||
this@MainActivity.binding.notifyIconAutoSyncText.text = it
|
this@MainActivity.binding.notifyIconAutoSyncText.text = it
|
||||||
modulePrefs.put(DataConst.NOTIFY_ICON_FIX_AUTO_TIME, it)
|
|
||||||
SystemUITool.refreshSystemUI(context, isRefreshCacheOnly = true)
|
SystemUITool.refreshSystemUI(context, isRefreshCacheOnly = true)
|
||||||
}
|
}
|
||||||
cancelButton()
|
cancelButton()
|
||||||
@@ -319,25 +290,32 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
binding.linkWithFollowMe.setOnClickListener {
|
binding.linkWithFollowMe.setOnClickListener {
|
||||||
openBrowser(url = "https://www.coolapk.com/u/876977", packageName = "com.coolapk.market")
|
openBrowser(url = "https://www.coolapk.com/u/876977", packageName = "com.coolapk.market")
|
||||||
}
|
}
|
||||||
|
/** 设置桌面图标显示隐藏 */
|
||||||
|
binding.hideIconInLauncherSwitch.isChecked = isLauncherIconShowing.not()
|
||||||
|
binding.hideIconInLauncherSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
|
hideOrShowLauncherIcon(b)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 刷新模块状态 */
|
/** 刷新模块状态 */
|
||||||
private fun refreshModuleStatus() {
|
private fun refreshModuleStatus() {
|
||||||
binding.mainLinStatus.setBackgroundResource(
|
binding.mainLinStatus.setBackgroundResource(
|
||||||
when {
|
when {
|
||||||
YukiHookAPI.Status.isXposedModuleActive && (isModuleRegular.not() || isModuleValied.not()) -> R.drawable.bg_yellow_round
|
YukiHookAPI.Status.isXposedModuleActive &&
|
||||||
|
(isModuleRegular.not() || isModuleValied.not() || ConfigData.isEnableModule.not()) -> R.drawable.bg_yellow_round
|
||||||
YukiHookAPI.Status.isXposedModuleActive -> R.drawable.bg_green_round
|
YukiHookAPI.Status.isXposedModuleActive -> R.drawable.bg_green_round
|
||||||
else -> R.drawable.bg_dark_round
|
else -> R.drawable.bg_dark_round
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
binding.mainImgStatus.setImageResource(
|
binding.mainImgStatus.setImageResource(
|
||||||
when {
|
when {
|
||||||
YukiHookAPI.Status.isXposedModuleActive -> R.drawable.ic_success
|
YukiHookAPI.Status.isXposedModuleActive && ConfigData.isEnableModule -> R.drawable.ic_success
|
||||||
else -> R.drawable.ic_warn
|
else -> R.drawable.ic_warn
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
binding.mainTextStatus.text = when {
|
binding.mainTextStatus.text = when {
|
||||||
YukiHookAPI.Status.isXposedModuleActive && isModuleRegular.not() && modulePrefs.get(DataConst.ENABLE_MODULE).not() -> "模块已停用"
|
YukiHookAPI.Status.isXposedModuleActive && ConfigData.isEnableModule.not() -> "模块已停用"
|
||||||
YukiHookAPI.Status.isXposedModuleActive && isModuleRegular.not() -> "模块已激活,请重启系统界面"
|
YukiHookAPI.Status.isXposedModuleActive && isModuleRegular.not() -> "模块已激活,请重启系统界面"
|
||||||
YukiHookAPI.Status.isXposedModuleActive && isModuleValied.not() -> "模块已更新,请重启系统界面"
|
YukiHookAPI.Status.isXposedModuleActive && isModuleValied.not() -> "模块已更新,请重启系统界面"
|
||||||
YukiHookAPI.Status.isXposedModuleActive -> "模块已激活"
|
YukiHookAPI.Status.isXposedModuleActive -> "模块已激活"
|
||||||
|
@@ -39,18 +39,15 @@ import androidx.core.content.getSystemService
|
|||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
import com.fankes.coloros.notify.R
|
import com.fankes.coloros.notify.R
|
||||||
import com.fankes.coloros.notify.data.DataConst
|
import com.fankes.coloros.notify.const.IconRuleSourceSyncType
|
||||||
|
import com.fankes.coloros.notify.data.ConfigData
|
||||||
import com.fankes.coloros.notify.databinding.DiaSourceFromBinding
|
import com.fankes.coloros.notify.databinding.DiaSourceFromBinding
|
||||||
import com.fankes.coloros.notify.databinding.DiaSourceFromStringBinding
|
import com.fankes.coloros.notify.databinding.DiaSourceFromStringBinding
|
||||||
import com.fankes.coloros.notify.hook.HookConst.TYPE_SOURCE_SYNC_WAY_1
|
|
||||||
import com.fankes.coloros.notify.hook.HookConst.TYPE_SOURCE_SYNC_WAY_2
|
|
||||||
import com.fankes.coloros.notify.hook.HookConst.TYPE_SOURCE_SYNC_WAY_3
|
|
||||||
import com.fankes.coloros.notify.param.IconPackParams
|
import com.fankes.coloros.notify.param.IconPackParams
|
||||||
import com.fankes.coloros.notify.ui.activity.ConfigureActivity
|
import com.fankes.coloros.notify.ui.activity.ConfigureActivity
|
||||||
import com.fankes.coloros.notify.utils.factory.safeOfNull
|
import com.fankes.coloros.notify.utils.factory.safeOfNull
|
||||||
import com.fankes.coloros.notify.utils.factory.showDialog
|
import com.fankes.coloros.notify.utils.factory.showDialog
|
||||||
import com.fankes.coloros.notify.utils.factory.snake
|
import com.fankes.coloros.notify.utils.factory.snake
|
||||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
|
||||||
import com.highcapable.yukihookapi.hook.log.loggerD
|
import com.highcapable.yukihookapi.hook.log.loggerD
|
||||||
import okhttp3.*
|
import okhttp3.*
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@@ -70,7 +67,13 @@ object IconRuleManagerTool {
|
|||||||
private const val OS_TAG = "ColorOS"
|
private const val OS_TAG = "ColorOS"
|
||||||
|
|
||||||
/** 当前规则的通知图标颜色 */
|
/** 当前规则的通知图标颜色 */
|
||||||
private const val OS_COLOR = 0xFF4E8A5A
|
private const val OS_COLOR = 0xFF4E8A5A.toInt()
|
||||||
|
|
||||||
|
/** 同步地址 - Github Raw (代理) */
|
||||||
|
private const val SYNC_URL_PROXY = "https://raw.githubusercontentS.com/fankes/AndroidNotifyIconAdapt/main"
|
||||||
|
|
||||||
|
/** 同步地址 - Github Raw (直连) */
|
||||||
|
private const val SYNC_URL_DIRECT = "https://raw.githubusercontent.com/fankes/AndroidNotifyIconAdapt/main"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从在线地址手动同步规则
|
* 从在线地址手动同步规则
|
||||||
@@ -80,8 +83,8 @@ object IconRuleManagerTool {
|
|||||||
fun syncByHand(context: Context, callback: () -> Unit) =
|
fun syncByHand(context: Context, callback: () -> Unit) =
|
||||||
context.showDialog<DiaSourceFromBinding> {
|
context.showDialog<DiaSourceFromBinding> {
|
||||||
title = "同步列表"
|
title = "同步列表"
|
||||||
var sourceType = context.modulePrefs.get(DataConst.SOURCE_SYNC_WAY)
|
var sourceType = ConfigData.iconRuleSourceSyncType
|
||||||
var customUrl = context.modulePrefs.get(DataConst.SOURCE_SYNC_WAY_CUSTOM_URL)
|
var customUrl = ConfigData.iconRuleSourceSyncCustomUrl
|
||||||
binding.sourceUrlEdit.apply {
|
binding.sourceUrlEdit.apply {
|
||||||
if (customUrl.isNotBlank()) {
|
if (customUrl.isNotBlank()) {
|
||||||
setText(customUrl)
|
setText(customUrl)
|
||||||
@@ -89,25 +92,25 @@ object IconRuleManagerTool {
|
|||||||
}
|
}
|
||||||
doOnTextChanged { text, _, _, _ -> customUrl = text.toString() }
|
doOnTextChanged { text, _, _, _ -> customUrl = text.toString() }
|
||||||
}
|
}
|
||||||
binding.sourceFromTextLin.isVisible = sourceType == TYPE_SOURCE_SYNC_WAY_3
|
binding.sourceFromTextLin.isVisible = sourceType == IconRuleSourceSyncType.CUSTOM_URL
|
||||||
binding.sourceRadio1.isChecked = sourceType == TYPE_SOURCE_SYNC_WAY_1
|
binding.sourceRadio1.isChecked = sourceType == IconRuleSourceSyncType.GITHUB_RAW_PROXY
|
||||||
binding.sourceRadio2.isChecked = sourceType == TYPE_SOURCE_SYNC_WAY_2
|
binding.sourceRadio2.isChecked = sourceType == IconRuleSourceSyncType.GITHUB_RAW_DIRECT
|
||||||
binding.sourceRadio3.isChecked = sourceType == TYPE_SOURCE_SYNC_WAY_3
|
binding.sourceRadio3.isChecked = sourceType == IconRuleSourceSyncType.CUSTOM_URL
|
||||||
binding.sourceRadio1.setOnClickListener {
|
binding.sourceRadio1.setOnClickListener {
|
||||||
binding.sourceFromTextLin.isVisible = false
|
binding.sourceFromTextLin.isVisible = false
|
||||||
sourceType = TYPE_SOURCE_SYNC_WAY_1
|
sourceType = IconRuleSourceSyncType.GITHUB_RAW_PROXY
|
||||||
}
|
}
|
||||||
binding.sourceRadio2.setOnClickListener {
|
binding.sourceRadio2.setOnClickListener {
|
||||||
binding.sourceFromTextLin.isVisible = false
|
binding.sourceFromTextLin.isVisible = false
|
||||||
sourceType = TYPE_SOURCE_SYNC_WAY_2
|
sourceType = IconRuleSourceSyncType.GITHUB_RAW_DIRECT
|
||||||
}
|
}
|
||||||
binding.sourceRadio3.setOnClickListener {
|
binding.sourceRadio3.setOnClickListener {
|
||||||
binding.sourceFromTextLin.isVisible = true
|
binding.sourceFromTextLin.isVisible = true
|
||||||
sourceType = TYPE_SOURCE_SYNC_WAY_3
|
sourceType = IconRuleSourceSyncType.CUSTOM_URL
|
||||||
}
|
}
|
||||||
confirmButton {
|
confirmButton {
|
||||||
context.modulePrefs.put(DataConst.SOURCE_SYNC_WAY, sourceType)
|
ConfigData.iconRuleSourceSyncType = sourceType
|
||||||
context.modulePrefs.put(DataConst.SOURCE_SYNC_WAY_CUSTOM_URL, customUrl)
|
ConfigData.iconRuleSourceSyncCustomUrl = customUrl
|
||||||
sync(context, sourceType, customUrl, callback)
|
sync(context, sourceType, customUrl, callback)
|
||||||
}
|
}
|
||||||
cancelButton()
|
cancelButton()
|
||||||
@@ -165,16 +168,14 @@ object IconRuleManagerTool {
|
|||||||
*/
|
*/
|
||||||
fun sync(
|
fun sync(
|
||||||
context: Context,
|
context: Context,
|
||||||
sourceType: Int = context.modulePrefs.get(DataConst.SOURCE_SYNC_WAY),
|
sourceType: Int = ConfigData.iconRuleSourceSyncType,
|
||||||
customUrl: String = context.modulePrefs.get(DataConst.SOURCE_SYNC_WAY_CUSTOM_URL),
|
customUrl: String = ConfigData.iconRuleSourceSyncCustomUrl,
|
||||||
callback: () -> Unit
|
callback: () -> Unit
|
||||||
) {
|
) {
|
||||||
when (sourceType) {
|
when (sourceType) {
|
||||||
TYPE_SOURCE_SYNC_WAY_1 ->
|
IconRuleSourceSyncType.GITHUB_RAW_PROXY -> onRefreshing(context, SYNC_URL_PROXY, callback)
|
||||||
onRefreshing(context, url = "https://raw.githubusercontentS.com/fankes/AndroidNotifyIconAdapt/main", callback)
|
IconRuleSourceSyncType.GITHUB_RAW_DIRECT -> onRefreshing(context, SYNC_URL_DIRECT, callback)
|
||||||
TYPE_SOURCE_SYNC_WAY_2 ->
|
IconRuleSourceSyncType.CUSTOM_URL ->
|
||||||
onRefreshing(context, url = "https://raw.githubusercontent.com/fankes/AndroidNotifyIconAdapt/main", callback)
|
|
||||||
TYPE_SOURCE_SYNC_WAY_3 ->
|
|
||||||
if (customUrl.isNotBlank())
|
if (customUrl.isNotBlank())
|
||||||
if (customUrl.startsWith("http://") || customUrl.startsWith("https://"))
|
if (customUrl.startsWith("http://") || customUrl.startsWith("https://"))
|
||||||
onRefreshingCustom(context, customUrl, callback)
|
onRefreshingCustom(context, customUrl, callback)
|
||||||
@@ -384,7 +385,7 @@ object IconRuleManagerTool {
|
|||||||
notify(0, NotificationCompat.Builder(context, NOTIFY_CHANNEL).apply {
|
notify(0, NotificationCompat.Builder(context, NOTIFY_CHANNEL).apply {
|
||||||
setContentTitle(title)
|
setContentTitle(title)
|
||||||
setContentText(msg)
|
setContentText(msg)
|
||||||
color = OS_COLOR.toInt()
|
color = OS_COLOR
|
||||||
setAutoCancel(true)
|
setAutoCancel(true)
|
||||||
setSmallIcon(R.drawable.ic_nf_icon_update)
|
setSmallIcon(R.drawable.ic_nf_icon_update)
|
||||||
setSound(null)
|
setSound(null)
|
||||||
|
@@ -24,7 +24,7 @@ package com.fankes.coloros.notify.utils.tool
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.fankes.coloros.notify.hook.HookConst.SYSTEMUI_PACKAGE_NAME
|
import com.fankes.coloros.notify.const.PackageName
|
||||||
import com.fankes.coloros.notify.utils.factory.delayedRun
|
import com.fankes.coloros.notify.utils.factory.delayedRun
|
||||||
import com.fankes.coloros.notify.utils.factory.execShell
|
import com.fankes.coloros.notify.utils.factory.execShell
|
||||||
import com.fankes.coloros.notify.utils.factory.showDialog
|
import com.fankes.coloros.notify.utils.factory.showDialog
|
||||||
@@ -64,7 +64,7 @@ object SystemUITool {
|
|||||||
* @param result 成功后回调
|
* @param result 成功后回调
|
||||||
*/
|
*/
|
||||||
fun checkingActivated(context: Context, result: (Boolean) -> Unit) =
|
fun checkingActivated(context: Context, result: (Boolean) -> Unit) =
|
||||||
context.dataChannel(SYSTEMUI_PACKAGE_NAME).checkingVersionEquals(result = result)
|
context.dataChannel(PackageName.SYSTEMUI).checkingVersionEquals(result = result)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重启系统界面
|
* 重启系统界面
|
||||||
@@ -107,7 +107,7 @@ object SystemUITool {
|
|||||||
* @param result 回调结果
|
* @param result 回调结果
|
||||||
*/
|
*/
|
||||||
fun doRefresh(result: (Boolean) -> Unit) {
|
fun doRefresh(result: (Boolean) -> Unit) {
|
||||||
context?.dataChannel(SYSTEMUI_PACKAGE_NAME)?.with {
|
context?.dataChannel(PackageName.SYSTEMUI)?.with {
|
||||||
wait(CALL_MODULE_REFRESH_RESULT) { result(it) }
|
wait(CALL_MODULE_REFRESH_RESULT) { result(it) }
|
||||||
put(CALL_HOST_REFRESH_CACHING, isRefreshCacheOnly)
|
put(CALL_HOST_REFRESH_CACHING, isRefreshCacheOnly)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user