mirror of
https://github.com/fankes/ColorOSNotifyIcon.git
synced 2025-09-06 02:35:41 +08:00
Merge code
This commit is contained in:
@@ -141,6 +141,12 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
/** 缓存的通知优化图标数组 */
|
/** 缓存的通知优化图标数组 */
|
||||||
private var iconDatas = ArrayList<IconDataBean>()
|
private var iconDatas = ArrayList<IconDataBean>()
|
||||||
|
|
||||||
|
/** 缓存的状态栏小图标实例 */
|
||||||
|
private var statusBarIconViews = HashSet<ImageView>()
|
||||||
|
|
||||||
|
/** 缓存的通知小图标包装纸实例 */
|
||||||
|
private var notificationViewWrappers = HashSet<Any>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否启用通知图标优化功能
|
* 是否启用通知图标优化功能
|
||||||
* @param isHooking 是否判断启用通知功能 - 默认:是
|
* @param isHooking 是否判断启用通知功能 - 默认:是
|
||||||
@@ -172,6 +178,16 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 刷新状态栏小图标 */
|
||||||
|
private fun PackageParam.refreshStatusBarIcons() = runInSafe {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 刷新通知小图标 */
|
||||||
|
private fun PackageParam.refreshNotificationIcons() = runInSafe {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* - 这个是修复彩色图标的关键核心代码判断
|
* - 这个是修复彩色图标的关键核心代码判断
|
||||||
*
|
*
|
||||||
@@ -301,6 +317,14 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 刷新缓存数据 */
|
||||||
|
private fun PackageParam.recachingPrefs() {
|
||||||
|
prefs.clearCache()
|
||||||
|
cachingIconDatas()
|
||||||
|
refreshStatusBarIcons()
|
||||||
|
refreshNotificationIcons()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onInit() = configs {
|
override fun onInit() = configs {
|
||||||
debugTag = "ColorOSNotify"
|
debugTag = "ColorOSNotify"
|
||||||
isDebug = false
|
isDebug = false
|
||||||
@@ -387,10 +411,10 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
name = "icon"
|
name = "icon"
|
||||||
type = IconClass
|
type = IconClass
|
||||||
}.get(result).set(Icon.createWithBitmap(pair.first.toBitmap()))
|
}.get(result).set(Icon.createWithBitmap(pair.first.toBitmap()))
|
||||||
/** 刷新图标缓存 */
|
/** 刷新缓存 */
|
||||||
if (nf.packageName == MODULE_PACKAGE_NAME &&
|
if (nf.packageName == MODULE_PACKAGE_NAME &&
|
||||||
nf.notification.channelId == IconRuleManagerTool.NOTIFY_CHANNEL
|
nf.notification.channelId == IconRuleManagerTool.NOTIFY_CHANNEL
|
||||||
) cachingIconDatas()
|
) recachingPrefs()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -423,10 +447,6 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
iconView = this
|
iconView = this
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/** 刷新图标缓存 */
|
|
||||||
if (context.packageName == MODULE_PACKAGE_NAME &&
|
|
||||||
nf.channelId == IconRuleManagerTool.NOTIFY_CHANNEL
|
|
||||||
) cachingIconDatas()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -56,7 +56,7 @@ class ConfigureActivity : BaseActivity<ActivityConfigBinding>() {
|
|||||||
/** 回调滚动事件改变 */
|
/** 回调滚动事件改变 */
|
||||||
private var onScrollEvent: ((Boolean) -> Unit)? = null
|
private var onScrollEvent: ((Boolean) -> Unit)? = null
|
||||||
|
|
||||||
/** 全部的通知优化图标数据 */
|
/** 全部的通知图标优化数据 */
|
||||||
private var iconAllDatas = ArrayList<IconDataBean>()
|
private var iconAllDatas = ArrayList<IconDataBean>()
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
@@ -149,13 +149,13 @@ class ConfigureActivity : BaseActivity<ActivityConfigBinding>() {
|
|||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
putAppNotifyHookOf(it, b)
|
putAppNotifyHookOf(it, b)
|
||||||
holder.adpAppAllSwitch.isEnabled = b
|
holder.adpAppAllSwitch.isEnabled = b
|
||||||
SystemUITool.showNeedRestartSnake(context = this@ConfigureActivity)
|
SystemUITool.refreshSystemUI(context = this@ConfigureActivity)
|
||||||
}
|
}
|
||||||
holder.adpAppAllSwitch.isChecked = isAppNotifyHookAllOf(it)
|
holder.adpAppAllSwitch.isChecked = isAppNotifyHookAllOf(it)
|
||||||
holder.adpAppAllSwitch.setOnCheckedChangeListener { btn, b ->
|
holder.adpAppAllSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
putAppNotifyHookAllOf(it, b)
|
putAppNotifyHookAllOf(it, b)
|
||||||
SystemUITool.showNeedRestartSnake(context = this@ConfigureActivity)
|
SystemUITool.refreshSystemUI(context = this@ConfigureActivity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cView!!
|
return cView!!
|
||||||
@@ -182,14 +182,6 @@ class ConfigureActivity : BaseActivity<ActivityConfigBinding>() {
|
|||||||
mockLocalData()
|
mockLocalData()
|
||||||
/** 更新数据 */
|
/** 更新数据 */
|
||||||
when {
|
when {
|
||||||
intent?.getBooleanExtra("isShowNeedRestart", false) == true ->
|
|
||||||
showDialog {
|
|
||||||
title = "规则列表已同步至最新"
|
|
||||||
msg = "同步完成,部分通知图标可能需要重新启动系统界面才能生效。"
|
|
||||||
confirmButton(text = "重新启动") { SystemUITool.restartSystemUI(context) }
|
|
||||||
cancelButton()
|
|
||||||
noCancelable()
|
|
||||||
}
|
|
||||||
intent?.getBooleanExtra("isNewAppSupport", false) == true ->
|
intent?.getBooleanExtra("isNewAppSupport", false) == true ->
|
||||||
showDialog {
|
showDialog {
|
||||||
val appName = intent?.getStringExtra("appName") ?: ""
|
val appName = intent?.getStringExtra("appName") ?: ""
|
||||||
@@ -209,7 +201,6 @@ class ConfigureActivity : BaseActivity<ActivityConfigBinding>() {
|
|||||||
}
|
}
|
||||||
/** 清除数据 */
|
/** 清除数据 */
|
||||||
intent?.apply {
|
intent?.apply {
|
||||||
removeExtra("isShowNeedRestart")
|
|
||||||
removeExtra("isNewAppSupport")
|
removeExtra("isNewAppSupport")
|
||||||
removeExtra("isShowUpdDialog")
|
removeExtra("isShowUpdDialog")
|
||||||
}
|
}
|
||||||
|
@@ -170,32 +170,32 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
modulePrefs.putBoolean(ENABLE_NOTIFY_ICON_FIX, b)
|
modulePrefs.putBoolean(ENABLE_NOTIFY_ICON_FIX, b)
|
||||||
binding.notifyIconFixButton.isVisible = b
|
binding.notifyIconFixButton.isVisible = b
|
||||||
binding.notifyIconFixNotifyItem.isVisible = b
|
binding.notifyIconFixNotifyItem.isVisible = b
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.refreshSystemUI(context = this)
|
||||||
}
|
}
|
||||||
binding.notifyIconFixNotifySwitch.setOnCheckedChangeListener { btn, b ->
|
binding.notifyIconFixNotifySwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(ENABLE_NOTIFY_ICON_FIX_NOTIFY, b)
|
modulePrefs.putBoolean(ENABLE_NOTIFY_ICON_FIX_NOTIFY, b)
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.refreshSystemUI(context = this)
|
||||||
}
|
}
|
||||||
binding.devNotifyConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.devNotifyConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(REMOVE_DEV_NOTIFY, b)
|
modulePrefs.putBoolean(REMOVE_DEV_NOTIFY, b)
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.refreshSystemUI(context = this)
|
||||||
}
|
}
|
||||||
binding.crcpNotifyConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.crcpNotifyConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(REMOVE_CHANGECP_NOTIFY, b)
|
modulePrefs.putBoolean(REMOVE_CHANGECP_NOTIFY, b)
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.refreshSystemUI(context = this)
|
||||||
}
|
}
|
||||||
binding.dndNotifyConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.dndNotifyConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(REMOVE_DNDALERT_NOTIFY, b)
|
modulePrefs.putBoolean(REMOVE_DNDALERT_NOTIFY, b)
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.refreshSystemUI(context = this)
|
||||||
}
|
}
|
||||||
binding.a12StyleConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.a12StyleConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(ENABLE_ANDROID12_STYLE, b)
|
modulePrefs.putBoolean(ENABLE_ANDROID12_STYLE, b)
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.refreshSystemUI(context = this)
|
||||||
}
|
}
|
||||||
/** 通知图标优化名单按钮点击事件 */
|
/** 通知图标优化名单按钮点击事件 */
|
||||||
binding.notifyIconFixButton.setOnClickListener { navigate<ConfigureActivity>() }
|
binding.notifyIconFixButton.setOnClickListener { navigate<ConfigureActivity>() }
|
||||||
|
@@ -141,7 +141,7 @@ object IconRuleManagerTool {
|
|||||||
dataJson2 = jsonString.takeIf { params.isJsonArray(it) } ?: "[$jsonString]"
|
dataJson2 = jsonString.takeIf { params.isJsonArray(it) } ?: "[$jsonString]"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
pushWithRefresh(context)
|
pushAndNotifyRefresh(context)
|
||||||
it()
|
it()
|
||||||
}
|
}
|
||||||
else -> context.snake(msg = "请输入有效内容")
|
else -> context.snake(msg = "请输入有效内容")
|
||||||
@@ -154,7 +154,7 @@ object IconRuleManagerTool {
|
|||||||
jsonString.isNotBlank() && params.isNotVaildJson(jsonString) -> context.snake(msg = "不是有效的 JSON 数据")
|
jsonString.isNotBlank() && params.isNotVaildJson(jsonString) -> context.snake(msg = "不是有效的 JSON 数据")
|
||||||
jsonString.isNotBlank() -> {
|
jsonString.isNotBlank() -> {
|
||||||
params.save(dataJson = jsonString.takeIf { params.isJsonArray(it) } ?: "[$jsonString]")
|
params.save(dataJson = jsonString.takeIf { params.isJsonArray(it) } ?: "[$jsonString]")
|
||||||
pushWithRefresh(context)
|
pushAndNotifyRefresh(context)
|
||||||
it()
|
it()
|
||||||
}
|
}
|
||||||
else -> context.snake(msg = "请输入有效内容")
|
else -> context.snake(msg = "请输入有效内容")
|
||||||
@@ -218,7 +218,7 @@ object IconRuleManagerTool {
|
|||||||
params.isCompareDifferent(it) -> {
|
params.isCompareDifferent(it) -> {
|
||||||
params.save(it)
|
params.save(it)
|
||||||
pushNotify(context, title = "同步完成", msg = "已更新通知图标优化名单,点击查看")
|
pushNotify(context, title = "同步完成", msg = "已更新通知图标优化名单,点击查看")
|
||||||
pushWithRefresh(context)
|
pushAndNotifyRefresh(context)
|
||||||
it()
|
it()
|
||||||
}
|
}
|
||||||
else -> (if (context is AppCompatActivity) context.snake(msg = "列表数据已是最新"))
|
else -> (if (context is AppCompatActivity) context.snake(msg = "列表数据已是最新"))
|
||||||
@@ -267,7 +267,7 @@ object IconRuleManagerTool {
|
|||||||
params.isCompareDifferent(content) -> {
|
params.isCompareDifferent(content) -> {
|
||||||
params.save(content)
|
params.save(content)
|
||||||
pushNotify(context, title = "同步完成", msg = "已更新通知图标优化名单,点击查看")
|
pushNotify(context, title = "同步完成", msg = "已更新通知图标优化名单,点击查看")
|
||||||
pushWithRefresh(context)
|
pushAndNotifyRefresh(context)
|
||||||
it()
|
it()
|
||||||
}
|
}
|
||||||
else -> (if (context is AppCompatActivity) context.snake(msg = "列表数据已是最新"))
|
else -> (if (context is AppCompatActivity) context.snake(msg = "列表数据已是最新"))
|
||||||
@@ -360,17 +360,35 @@ object IconRuleManagerTool {
|
|||||||
})
|
})
|
||||||
}.onFailure { it(false, "URL 无效") }
|
}.onFailure { it(false, "URL 无效") }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新系统界面状态栏与通知图标
|
||||||
|
* @param context 实例
|
||||||
|
*/
|
||||||
|
fun refreshSystemUI(context: Context) {
|
||||||
|
if (context !is AppCompatActivity) return
|
||||||
|
context.showDialog {
|
||||||
|
title = "请稍后"
|
||||||
|
progressContent = "正在刷新系统界面改变"
|
||||||
|
/** 发送通知提醒宿主更新图标缓存 */
|
||||||
|
pushNotify(appContext, title = "请稍后", msg = "正在等待系统界面响应", isAction = false)
|
||||||
|
/** 刷新成功后取消通知 */
|
||||||
|
Handler().postDelayed({
|
||||||
|
context.getSystemService<NotificationManager>()?.cancel(1)
|
||||||
|
cancel()
|
||||||
|
}, 500)
|
||||||
|
noCancelable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送通知图标更新通知
|
* 推送通知图标更新通知
|
||||||
* @param context 实例
|
* @param context 实例
|
||||||
*/
|
*/
|
||||||
private fun pushWithRefresh(context: Context) {
|
private fun pushAndNotifyRefresh(context: Context) {
|
||||||
if (context !is AppCompatActivity) return
|
if (context !is AppCompatActivity) return
|
||||||
SystemUITool.showNeedUpdateApplySnake(context)
|
SystemUITool.showNeedUpdateApplySnake(context)
|
||||||
/** 发送通知提醒宿主更新图标缓存 */
|
/** 刷新改变 */
|
||||||
pushNotify(appContext, title = "请稍后", msg = "正在动态刷新通知图标改变", isAction = false)
|
refreshSystemUI(context)
|
||||||
/** 刷新成功后取消通知 */
|
|
||||||
Handler().postDelayed({ context.getSystemService<NotificationManager>()?.cancel(1) }, 1500)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -411,10 +429,8 @@ object IconRuleManagerTool {
|
|||||||
if (isAction) setContentIntent(
|
if (isAction) setContentIntent(
|
||||||
PendingIntent.getActivity(
|
PendingIntent.getActivity(
|
||||||
context, msg.hashCode(),
|
context, msg.hashCode(),
|
||||||
Intent(context, ConfigureActivity::class.java).apply {
|
Intent(context, ConfigureActivity::class.java).apply { putExtra("isShowUpdDialog", false) },
|
||||||
putExtra("isShowNeedRestart", true)
|
if (Build.VERSION.SDK_INT < 31) PendingIntent.FLAG_UPDATE_CURRENT else PendingIntent.FLAG_IMMUTABLE
|
||||||
putExtra("isShowUpdDialog", false)
|
|
||||||
}, if (Build.VERSION.SDK_INT < 31) PendingIntent.FLAG_UPDATE_CURRENT else PendingIntent.FLAG_IMMUTABLE
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}.build())
|
}.build())
|
||||||
|
@@ -39,7 +39,8 @@ object SystemUITool {
|
|||||||
fun restartSystemUI(context: Context) =
|
fun restartSystemUI(context: Context) =
|
||||||
context.showDialog {
|
context.showDialog {
|
||||||
title = "重启系统界面"
|
title = "重启系统界面"
|
||||||
msg = "你确定要立即重启系统界面吗?"
|
msg = "你确定要立即重启系统界面吗?\n\n" +
|
||||||
|
"部分 MIUI 系统使用了状态栏主题可能会发生主题失效的情况,这种情况请再重启一次即可。"
|
||||||
confirmButton {
|
confirmButton {
|
||||||
execShellSu(cmd = "pgrep systemui").also { pid ->
|
execShellSu(cmd = "pgrep systemui").also { pid ->
|
||||||
if (pid.isNotBlank())
|
if (pid.isNotBlank())
|
||||||
@@ -50,6 +51,12 @@ object SystemUITool {
|
|||||||
cancelButton()
|
cancelButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新系统界面状态栏与通知图标
|
||||||
|
* @param context 实例
|
||||||
|
*/
|
||||||
|
fun refreshSystemUI(context: Context) = IconRuleManagerTool.refreshSystemUI(context)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示需要重启系统界面的 [Snackbar]
|
* 显示需要重启系统界面的 [Snackbar]
|
||||||
* @param context 实例
|
* @param context 实例
|
||||||
@@ -67,6 +74,6 @@ object SystemUITool {
|
|||||||
if (isXposedModuleActive)
|
if (isXposedModuleActive)
|
||||||
if (isNotNoificationEnabled)
|
if (isNotNoificationEnabled)
|
||||||
context.snake(msg = "无通知权限,请重启系统界面使更改生效", actionText = "立即重启") { restartSystemUI(context) }
|
context.snake(msg = "无通知权限,请重启系统界面使更改生效", actionText = "立即重启") { restartSystemUI(context) }
|
||||||
else context.snake(msg = "数据已更新,已推送的通知将在下次生效", actionText = "立即重启") { restartSystemUI(context) }
|
else context.snake(msg = "通知图标优化名单已完成同步")
|
||||||
else context.snake(msg = "模块没有激活,更改不会生效")
|
else context.snake(msg = "模块没有激活,更改不会生效")
|
||||||
}
|
}
|
Reference in New Issue
Block a user