mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-06 02:35:32 +08:00
增加状态栏通知图标动态更新,取消对新的开发版修复通知图标只有一个的问题
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -12,6 +12,8 @@
|
|||||||
<entry key="app/src/main/res/drawable/bg_orange_round.xml" value="0.2325" />
|
<entry key="app/src/main/res/drawable/bg_orange_round.xml" value="0.2325" />
|
||||||
<entry key="app/src/main/res/drawable/bg_warn_round.xml" value="0.2325" />
|
<entry key="app/src/main/res/drawable/bg_warn_round.xml" value="0.2325" />
|
||||||
<entry key="app/src/main/res/drawable/bg_yellow_round.xml" value="0.255" />
|
<entry key="app/src/main/res/drawable/bg_yellow_round.xml" value="0.255" />
|
||||||
|
<entry key="app/src/main/res/drawable/ic_nf_icon_refresh.xml" value="0.2325" />
|
||||||
|
<entry key="app/src/main/res/drawable/ic_nf_icon_update.xml" value="0.2325" />
|
||||||
<entry key="app/src/main/res/drawable/permotion_round.xml" value="0.256" />
|
<entry key="app/src/main/res/drawable/permotion_round.xml" value="0.256" />
|
||||||
<entry key="app/src/main/res/drawable/white_round.xml" value="0.256" />
|
<entry key="app/src/main/res/drawable/white_round.xml" value="0.256" />
|
||||||
<entry key="app/src/main/res/layout-w1240dp/dia_source_from.xml" value="0.36484375" />
|
<entry key="app/src/main/res/layout-w1240dp/dia_source_from.xml" value="0.36484375" />
|
||||||
|
@@ -29,7 +29,6 @@ object HookConst {
|
|||||||
const val ENABLE_MODULE = "_enable_module"
|
const val ENABLE_MODULE = "_enable_module"
|
||||||
const val ENABLE_MODULE_LOG = "_enable_module_log"
|
const val ENABLE_MODULE_LOG = "_enable_module_log"
|
||||||
const val ENABLE_HIDE_ICON = "_hide_icon"
|
const val ENABLE_HIDE_ICON = "_hide_icon"
|
||||||
const val ENABLE_COLOR_ICON_HOOK = "_color_icon_hook"
|
|
||||||
const val ENABLE_COLOR_ICON_COMPAT = "_color_icon_compat"
|
const val ENABLE_COLOR_ICON_COMPAT = "_color_icon_compat"
|
||||||
const val ENABLE_NOTIFY_ICON_FIX = "_notify_icon_fix"
|
const val ENABLE_NOTIFY_ICON_FIX = "_notify_icon_fix"
|
||||||
const val ENABLE_NOTIFY_ICON_FIX_NOTIFY = "_notify_icon_fix_notify"
|
const val ENABLE_NOTIFY_ICON_FIX_NOTIFY = "_notify_icon_fix_notify"
|
||||||
|
@@ -28,6 +28,7 @@ import android.content.Intent
|
|||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.Outline
|
import android.graphics.Outline
|
||||||
|
import android.graphics.drawable.BitmapDrawable
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.graphics.drawable.Icon
|
import android.graphics.drawable.Icon
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
@@ -40,7 +41,6 @@ import androidx.core.graphics.drawable.toBitmap
|
|||||||
import com.fankes.miui.notify.application.MNNApplication.Companion.MODULE_PACKAGE_NAME
|
import com.fankes.miui.notify.application.MNNApplication.Companion.MODULE_PACKAGE_NAME
|
||||||
import com.fankes.miui.notify.bean.IconDataBean
|
import com.fankes.miui.notify.bean.IconDataBean
|
||||||
import com.fankes.miui.notify.hook.HookConst.ENABLE_COLOR_ICON_COMPAT
|
import com.fankes.miui.notify.hook.HookConst.ENABLE_COLOR_ICON_COMPAT
|
||||||
import com.fankes.miui.notify.hook.HookConst.ENABLE_COLOR_ICON_HOOK
|
|
||||||
import com.fankes.miui.notify.hook.HookConst.ENABLE_HOOK_STATUS_ICON_COUNT
|
import com.fankes.miui.notify.hook.HookConst.ENABLE_HOOK_STATUS_ICON_COUNT
|
||||||
import com.fankes.miui.notify.hook.HookConst.ENABLE_MODULE
|
import com.fankes.miui.notify.hook.HookConst.ENABLE_MODULE
|
||||||
import com.fankes.miui.notify.hook.HookConst.ENABLE_MODULE_LOG
|
import com.fankes.miui.notify.hook.HookConst.ENABLE_MODULE_LOG
|
||||||
@@ -62,10 +62,7 @@ import com.highcapable.yukihookapi.hook.factory.*
|
|||||||
import com.highcapable.yukihookapi.hook.log.loggerD
|
import com.highcapable.yukihookapi.hook.log.loggerD
|
||||||
import com.highcapable.yukihookapi.hook.log.loggerW
|
import com.highcapable.yukihookapi.hook.log.loggerW
|
||||||
import com.highcapable.yukihookapi.hook.param.PackageParam
|
import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||||
import com.highcapable.yukihookapi.hook.type.android.ContextClass
|
import com.highcapable.yukihookapi.hook.type.android.*
|
||||||
import com.highcapable.yukihookapi.hook.type.android.DrawableClass
|
|
||||||
import com.highcapable.yukihookapi.hook.type.android.ImageViewClass
|
|
||||||
import com.highcapable.yukihookapi.hook.type.android.IntentClass
|
|
||||||
import com.highcapable.yukihookapi.hook.type.java.BooleanType
|
import com.highcapable.yukihookapi.hook.type.java.BooleanType
|
||||||
import com.highcapable.yukihookapi.hook.type.java.IntType
|
import com.highcapable.yukihookapi.hook.type.java.IntType
|
||||||
import com.highcapable.yukihookapi.hook.xposed.proxy.YukiHookXposedInitProxy
|
import com.highcapable.yukihookapi.hook.xposed.proxy.YukiHookXposedInitProxy
|
||||||
@@ -82,9 +79,6 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
private const val NotificationHeaderViewWrapperInjectorClass =
|
private const val NotificationHeaderViewWrapperInjectorClass =
|
||||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.wrapper.NotificationHeaderViewWrapperInjector"
|
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.wrapper.NotificationHeaderViewWrapperInjector"
|
||||||
|
|
||||||
/** MIUI 大部分版本存在的类 */
|
|
||||||
private const val MiuiClockClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.views.MiuiClock"
|
|
||||||
|
|
||||||
/** 原生存在的类 */
|
/** 原生存在的类 */
|
||||||
private const val ContrastColorUtilClass = "com.android.internal.util.ContrastColorUtil"
|
private const val ContrastColorUtilClass = "com.android.internal.util.ContrastColorUtil"
|
||||||
|
|
||||||
@@ -97,6 +91,12 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
/** 原生存在的类 */
|
/** 原生存在的类 */
|
||||||
private const val PluginManagerImplClass = "$SYSTEMUI_PACKAGE_NAME.shared.plugins.PluginManagerImpl"
|
private const val PluginManagerImplClass = "$SYSTEMUI_PACKAGE_NAME.shared.plugins.PluginManagerImpl"
|
||||||
|
|
||||||
|
/** 根据多个版本存在不同的包名相同的类 */
|
||||||
|
private val MiuiClockClass = VariousClass(
|
||||||
|
"$SYSTEMUI_PACKAGE_NAME.statusbar.views.MiuiClock",
|
||||||
|
"$SYSTEMUI_PACKAGE_NAME.statusbar.policy.MiuiClock"
|
||||||
|
)
|
||||||
|
|
||||||
/** 根据多个版本存在不同的包名相同的类 */
|
/** 根据多个版本存在不同的包名相同的类 */
|
||||||
private val ExpandableNotificationRowClass = VariousClass(
|
private val ExpandableNotificationRowClass = VariousClass(
|
||||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.ExpandableNotificationRow",
|
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.ExpandableNotificationRow",
|
||||||
@@ -134,13 +134,18 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
/** 是否显示通知图标 - 跟随 Hook 保存 */
|
/** 是否显示通知图标 - 跟随 Hook 保存 */
|
||||||
private var isShowNotificationIcons = true
|
private var isShowNotificationIcons = true
|
||||||
|
|
||||||
|
/** 缓存的状态栏小图标实例 */
|
||||||
|
private var statusBarIconViews = HashSet<ImageView>()
|
||||||
|
|
||||||
|
/** 缓存的通知小图标包装纸实例 */
|
||||||
|
private var notificationViewWrappers = HashSet<Any>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否启用忽略彩色图标和启用通知图标优化功能
|
* 是否启用忽略彩色图标和启用通知图标优化功能
|
||||||
* @param isHooking 是否判断启用通知功能 - 默认:是
|
* @param isHooking 是否判断启用通知功能 - 默认:是
|
||||||
* @return [Boolean]
|
* @return [Boolean]
|
||||||
*/
|
*/
|
||||||
private fun PackageParam.isEnableHookColorNotifyIcon(isHooking: Boolean = true) =
|
private fun PackageParam.isEnableHookColorNotifyIcon(isHooking: Boolean = true) =
|
||||||
prefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true) &&
|
|
||||||
prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true) &&
|
prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true) &&
|
||||||
(if (isHooking) prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX_NOTIFY, default = true) else true)
|
(if (isHooking) prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX_NOTIFY, default = true) else true)
|
||||||
|
|
||||||
@@ -286,6 +291,29 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
SystemUIApplicationClass.clazz.method { name = "getContext" }.ignoredError().get().invoke<Context>()
|
SystemUIApplicationClass.clazz.method { name = "getContext" }.ignoredError().get().invoke<Context>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 刷新状态栏小图标 */
|
||||||
|
private fun PackageParam.refreshStatusBarIcons() = runInSafe {
|
||||||
|
StatusBarIconViewClass.clazz.field { name = "mNotification" }.also { result ->
|
||||||
|
statusBarIconViews.takeIf { it.isNotEmpty() }?.forEach {
|
||||||
|
/** 得到通知实例 */
|
||||||
|
val nf = result.of<StatusBarNotification>(it) ?: return
|
||||||
|
/** 刷新状态栏图标 */
|
||||||
|
compatStatusIcon(it.context, nf, nf.notification.smallIcon.loadDrawable(it.context)) { icon, _ ->
|
||||||
|
it.setImageDrawable(icon)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 刷新通知小图标 */
|
||||||
|
private fun PackageParam.refreshNotificationIcons() = runInSafe {
|
||||||
|
(if (hasHandleHeaderViews)
|
||||||
|
NotificationHeaderViewWrapperClass.clazz.method { name = "handleHeaderViews" }
|
||||||
|
else NotificationHeaderViewWrapperClass.clazz.method { name = "resolveHeaderViews" }).also { result ->
|
||||||
|
notificationViewWrappers.takeIf { it.isNotEmpty() }?.forEach { result.get(it).call() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自动适配状态栏、通知栏自定义小图标
|
* 自动适配状态栏、通知栏自定义小图标
|
||||||
* @param isGrayscaleIcon 是否为灰度图标
|
* @param isGrayscaleIcon 是否为灰度图标
|
||||||
@@ -294,8 +322,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
*/
|
*/
|
||||||
private fun PackageParam.compatCustomIcon(isGrayscaleIcon: Boolean, packageName: String): Pair<Bitmap?, Int> {
|
private fun PackageParam.compatCustomIcon(isGrayscaleIcon: Boolean, packageName: String): Pair<Bitmap?, Int> {
|
||||||
var customPair: Pair<Bitmap?, Int>? = null
|
var customPair: Pair<Bitmap?, Int>? = null
|
||||||
if (prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true))
|
if (prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)) run {
|
||||||
run {
|
|
||||||
if (iconDatas.isNotEmpty())
|
if (iconDatas.isNotEmpty())
|
||||||
iconDatas.forEach {
|
iconDatas.forEach {
|
||||||
if (packageName == it.packageName && isAppNotifyHookOf(it)) {
|
if (packageName == it.packageName && isAppNotifyHookOf(it)) {
|
||||||
@@ -315,22 +342,20 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
* @param context 实例
|
* @param context 实例
|
||||||
* @param expandedNf 通知实例
|
* @param expandedNf 通知实例
|
||||||
* @param iconDrawable 小图标 [Drawable]
|
* @param iconDrawable 小图标 [Drawable]
|
||||||
* @param it 回调小图标 - ([Bitmap] 小图标)
|
* @param it 回调小图标 - ([Drawable] 小图标,[Boolean] 是否替换)
|
||||||
*/
|
*/
|
||||||
private fun PackageParam.hookSmallIconOnSet(
|
private fun PackageParam.compatStatusIcon(
|
||||||
context: Context,
|
context: Context,
|
||||||
expandedNf: StatusBarNotification?,
|
expandedNf: StatusBarNotification?,
|
||||||
iconDrawable: Drawable?,
|
iconDrawable: Drawable?,
|
||||||
it: (Bitmap) -> Unit
|
it: (Drawable, Boolean) -> Unit
|
||||||
) = runInSafe(msg = "GetSmallIconOnSet") {
|
) = runInSafe(msg = "compatStatusIcon") {
|
||||||
if (iconDrawable == null) return@runInSafe
|
if (iconDrawable == null) return@runInSafe
|
||||||
/** 如果没开启修复 APP 的彩色图标 */
|
|
||||||
if (!prefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)) return@runInSafe
|
|
||||||
/** 获取通知对象 - 由于 MIUI 的版本迭代不规范性可能是空的 */
|
/** 获取通知对象 - 由于 MIUI 的版本迭代不规范性可能是空的 */
|
||||||
expandedNf?.also { notifyInstance ->
|
expandedNf?.also { notifyInstance ->
|
||||||
/** 判断是 MIUI 样式就停止 Hook */
|
/** 判断是 MIUI 样式就停止 Hook */
|
||||||
if (context.isMiuiNotifyStyle) {
|
if (context.isMiuiNotifyStyle) {
|
||||||
it(notifyInstance.findAppIcon(context).toBitmap())
|
it(notifyInstance.findAppIcon(context), true)
|
||||||
return@runInSafe
|
return@runInSafe
|
||||||
}
|
}
|
||||||
/** 判断是否不是灰度图标 */
|
/** 判断是否不是灰度图标 */
|
||||||
@@ -342,9 +367,11 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
printLogcat(tag = "StatusIcon", context, notifyInstance, isCustom = customIcon != null, !isNotGrayscaleIcon)
|
printLogcat(tag = "StatusIcon", context, notifyInstance, isCustom = customIcon != null, !isNotGrayscaleIcon)
|
||||||
when {
|
when {
|
||||||
/** 处理自定义通知图标优化 */
|
/** 处理自定义通知图标优化 */
|
||||||
customIcon != null -> it(customIcon)
|
customIcon != null -> it(BitmapDrawable(context.resources, customIcon), true)
|
||||||
/** 若不是灰度图标自动处理为圆角 */
|
/** 若不是灰度图标自动处理为圆角 */
|
||||||
isNotGrayscaleIcon -> it(notifyInstance.compatNotifyIcon(context, iconDrawable).toBitmap())
|
isNotGrayscaleIcon -> it(notifyInstance.compatNotifyIcon(context, iconDrawable), true)
|
||||||
|
/** 否则返回原始小图标 */
|
||||||
|
else -> it(notifyInstance.notification.smallIcon.loadDrawable(context), false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -356,18 +383,18 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
* @param context 实例
|
* @param context 实例
|
||||||
* @param expandedNf 通知实例
|
* @param expandedNf 通知实例
|
||||||
* @param iconImageView 通知图标实例
|
* @param iconImageView 通知图标实例
|
||||||
|
* @param origColor 通知图标系统默认颜色 - Android >= 12
|
||||||
* @param isExpanded 通知是否展开 - 可做最小化通知处理
|
* @param isExpanded 通知是否展开 - 可做最小化通知处理
|
||||||
*/
|
*/
|
||||||
private fun PackageParam.hookNotifyIconOnSet(
|
private fun PackageParam.compatNotifyIcon(
|
||||||
context: Context,
|
context: Context,
|
||||||
expandedNf: StatusBarNotification?,
|
expandedNf: StatusBarNotification?,
|
||||||
iconImageView: ImageView,
|
iconImageView: ImageView,
|
||||||
|
origColor: Int,
|
||||||
isExpanded: Boolean
|
isExpanded: Boolean
|
||||||
) = runInSafe(msg = "AutoSetAppIconOnSet") {
|
) = runInSafe(msg = "compatNotifyIcon") {
|
||||||
/** 判断是 MIUI 样式就停止 Hook */
|
/** 判断是 MIUI 样式就停止 Hook */
|
||||||
if (context.isMiuiNotifyStyle) return@runInSafe
|
if (context.isMiuiNotifyStyle) return@runInSafe
|
||||||
/** 如果没开启修复 APP 的彩色图标 */
|
|
||||||
if (!prefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)) return@runInSafe
|
|
||||||
/** 获取通知对象 - 由于 MIUI 的版本迭代不规范性可能是空的 */
|
/** 获取通知对象 - 由于 MIUI 的版本迭代不规范性可能是空的 */
|
||||||
expandedNf?.let { notifyInstance ->
|
expandedNf?.let { notifyInstance ->
|
||||||
|
|
||||||
@@ -410,8 +437,9 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
/** 打印日志 */
|
/** 打印日志 */
|
||||||
printLogcat(tag = "NotifyIcon", context, notifyInstance, isCustom = customIcon != null, isGrayscaleIcon)
|
printLogcat(tag = "NotifyIcon", context, notifyInstance, isCustom = customIcon != null, isGrayscaleIcon)
|
||||||
/** 处理自定义通知图标优化 */
|
/** 处理自定义通知图标优化 */
|
||||||
if (customIcon != null)
|
if (customIcon != null) iconImageView.apply {
|
||||||
iconImageView.apply {
|
/** 设置不要裁切到边界 */
|
||||||
|
clipToOutline = false
|
||||||
/** 设置自定义小图标 */
|
/** 设置自定义小图标 */
|
||||||
setImageBitmap(customIcon)
|
setImageBitmap(customIcon)
|
||||||
/** 上色 */
|
/** 上色 */
|
||||||
@@ -419,17 +447,22 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
/** Android 12 设置图标外圈颜色 */
|
/** Android 12 设置图标外圈颜色 */
|
||||||
if (isUpperOfAndroidS && customIconColor != 0)
|
if (isUpperOfAndroidS && customIconColor != 0)
|
||||||
background = DrawableBuilder().rounded().solidColor(customIconColor).build()
|
background = DrawableBuilder().rounded().solidColor(customIconColor).build()
|
||||||
}
|
/** 设置原生的背景边距 */
|
||||||
else {
|
if (isUpperOfAndroidS) setPadding(4.dp(context), 4.dp(context), 4.dp(context), 4.dp(context))
|
||||||
|
} else {
|
||||||
/** 重新设置图标 - 防止系统更改它 */
|
/** 重新设置图标 - 防止系统更改它 */
|
||||||
iconImageView.setImageDrawable(iconDrawable)
|
iconImageView.setImageDrawable(iconDrawable)
|
||||||
/** 判断如果是灰度图标就给他设置一个白色颜色遮罩 */
|
/** 判断如果是灰度图标就给他设置一个白色颜色遮罩 */
|
||||||
if (isGrayscaleIcon) iconImageView.apply {
|
if (isGrayscaleIcon) iconImageView.apply {
|
||||||
|
/** 设置不要裁切到边界 */
|
||||||
|
clipToOutline = false
|
||||||
/** 设置图标着色 */
|
/** 设置图标着色 */
|
||||||
setColorFilter(supportColor)
|
setColorFilter(supportColor)
|
||||||
/** Android 12 设置图标外圈颜色 */
|
/** Android 12 设置图标外圈颜色 */
|
||||||
if (isUpperOfAndroidS && hasIconColor)
|
if (isUpperOfAndroidS) background =
|
||||||
background = DrawableBuilder().rounded().solidColor(iconColor).build()
|
DrawableBuilder().rounded().solidColor(if (hasIconColor) iconColor else origColor).build()
|
||||||
|
/** 设置原生的背景边距 */
|
||||||
|
if (isUpperOfAndroidS) setPadding(4.dp(context), 4.dp(context), 4.dp(context), 4.dp(context))
|
||||||
} else iconImageView.apply {
|
} else iconImageView.apply {
|
||||||
/** 重新设置图标 */
|
/** 重新设置图标 */
|
||||||
setImageDrawable(notifyInstance.compatNotifyIcon(context, iconDrawable))
|
setImageDrawable(notifyInstance.compatNotifyIcon(context, iconDrawable))
|
||||||
@@ -444,10 +477,14 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 清除原生的背景边距设置 */
|
if (isUpperOfAndroidS) {
|
||||||
if (isUpperOfAndroidS) setPadding(0, 0, 0, 0)
|
/** 清除原生的背景边距 */
|
||||||
|
setPadding(0, 0, 0, 0)
|
||||||
/** 清除原生的主题色背景圆圈颜色 */
|
/** 清除原生的主题色背景圆圈颜色 */
|
||||||
if (isUpperOfAndroidS) background = null
|
background = null
|
||||||
|
}
|
||||||
|
/** 清除遮罩颜色 */
|
||||||
|
colorFilter = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -462,8 +499,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
* @return [Boolean] 是否忽略通知图标颜色
|
* @return [Boolean] 是否忽略通知图标颜色
|
||||||
*/
|
*/
|
||||||
private fun PackageParam.hasIgnoreStatusBarIconColor(context: Context, expandedNf: StatusBarNotification?) =
|
private fun PackageParam.hasIgnoreStatusBarIconColor(context: Context, expandedNf: StatusBarNotification?) =
|
||||||
if (!context.isMiuiNotifyStyle)
|
if (!context.isMiuiNotifyStyle) safeOfFalse {
|
||||||
if (prefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)) safeOfFalse {
|
|
||||||
/** 获取通知对象 - 由于 MIUI 的版本迭代不规范性可能是空的 */
|
/** 获取通知对象 - 由于 MIUI 的版本迭代不规范性可能是空的 */
|
||||||
expandedNf?.let { notifyInstance ->
|
expandedNf?.let { notifyInstance ->
|
||||||
/** 获取通知小图标 */
|
/** 获取通知小图标 */
|
||||||
@@ -482,8 +518,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
printLogcat(tag = "IconColor", context, expandedNf, isTargetFixApp, !isNotGrayscaleIcon)
|
printLogcat(tag = "IconColor", context, expandedNf, isTargetFixApp, !isNotGrayscaleIcon)
|
||||||
}
|
}
|
||||||
} ?: true.also { printLogcat(tag = "IconColor", context, expandedNf = null, isCustom = false, isGrayscale = false) }
|
} ?: true.also { printLogcat(tag = "IconColor", context, expandedNf = null, isCustom = false, isGrayscale = false) }
|
||||||
} else false.also { printLogcat(tag = "IconColor", context, expandedNf, isCustom = false, isGrayscale = true) }
|
} else true.also { printLogcat(tag = "IconColor", context, expandedNf, isCustom = false, isGrayscale = false) }
|
||||||
else true.also { printLogcat(tag = "IconColor", context, expandedNf, isCustom = false, isGrayscale = false) }
|
|
||||||
|
|
||||||
/** 缓存图标数据 */
|
/** 缓存图标数据 */
|
||||||
private fun PackageParam.cachingIconDatas() {
|
private fun PackageParam.cachingIconDatas() {
|
||||||
@@ -496,6 +531,14 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 刷新缓存数据 */
|
||||||
|
private fun PackageParam.recachingPrefs() {
|
||||||
|
prefs.clearCache()
|
||||||
|
cachingIconDatas()
|
||||||
|
refreshStatusBarIcons()
|
||||||
|
refreshNotificationIcons()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onInit() = configs {
|
override fun onInit() = configs {
|
||||||
debugTag = "MIUINativeNotifyIcon"
|
debugTag = "MIUINativeNotifyIcon"
|
||||||
isDebug = false
|
isDebug = false
|
||||||
@@ -550,15 +593,15 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
(globalContext ?: firstArgs as Context).also { context ->
|
(globalContext ?: firstArgs as Context).also { context ->
|
||||||
val expandedNf = args[if (isUseLegacy) 1 else 0] as? StatusBarNotification?
|
val expandedNf = args[if (isUseLegacy) 1 else 0] as? StatusBarNotification?
|
||||||
/** Hook 状态栏小图标 */
|
/** Hook 状态栏小图标 */
|
||||||
hookSmallIconOnSet(
|
compatStatusIcon(
|
||||||
context = context,
|
context = context,
|
||||||
expandedNf,
|
expandedNf,
|
||||||
(result as Icon).loadDrawable(context)
|
(result as Icon).loadDrawable(context)
|
||||||
) { icon -> result = Icon.createWithBitmap(icon) }
|
) { icon, isReplace -> if (isReplace) result = Icon.createWithBitmap(icon.toBitmap()) }
|
||||||
/** 刷新图标缓存 */
|
/** 刷新缓存 */
|
||||||
if (expandedNf?.compatOpPkgName == MODULE_PACKAGE_NAME &&
|
if (expandedNf?.compatOpPkgName == MODULE_PACKAGE_NAME &&
|
||||||
expandedNf.notification?.channelId == IconRuleManagerTool.NOTIFY_CHANNEL
|
expandedNf.notification?.channelId == IconRuleManagerTool.NOTIFY_CHANNEL
|
||||||
) cachingIconDatas()
|
) recachingPrefs()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -594,15 +637,31 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/** 记录实例 */
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "setNotification"
|
||||||
|
param(StatusBarNotificationClass)
|
||||||
|
}.remedys {
|
||||||
|
method {
|
||||||
|
name = "setNotification"
|
||||||
|
param(ExpandedNotificationClass.clazz)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
afterHook { if (firstArgs != null) statusBarIconViews.add(instance()) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
NotificationIconContainerClass.hook {
|
NotificationIconContainerClass.hook {
|
||||||
injectMember {
|
injectMember {
|
||||||
method { name = "calculateIconTranslations" }
|
method { name = "calculateIconTranslations" }
|
||||||
afterHook {
|
afterHook {
|
||||||
/** 修复最新开发版状态栏图标只能显示一个的问题 */
|
/** 修复部分开发版状态栏图标只能显示一个的问题 */
|
||||||
|
when (miuiIncrementalVersion.lowercase()) {
|
||||||
|
"22.3.14", "22.3.15", "22.3.16", "v13.0.1.1.16.dev", "22.3.18" ->
|
||||||
instance<ViewGroup>().layoutParams.width = 9999
|
instance<ViewGroup>().layoutParams.width = 9999
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
injectMember {
|
injectMember {
|
||||||
method { name = "updateState" }
|
method { name = "updateState" }
|
||||||
beforeHook {
|
beforeHook {
|
||||||
@@ -637,6 +696,12 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
method { name = "handleHeaderViews" }
|
method { name = "handleHeaderViews" }
|
||||||
else method { name = "resolveHeaderViews" }
|
else method { name = "resolveHeaderViews" }
|
||||||
afterHook {
|
afterHook {
|
||||||
|
/** 获取通知图标系统默认颜色 */
|
||||||
|
val origColor =
|
||||||
|
NotificationHeaderViewWrapperClass.clazz.method { name = "getOriginalIconColor" }
|
||||||
|
.ignoredError()
|
||||||
|
.get(instance).invoke<Int>() ?: 0
|
||||||
|
|
||||||
/** 获取小图标 */
|
/** 获取小图标 */
|
||||||
val iconImageView =
|
val iconImageView =
|
||||||
NotificationHeaderViewWrapperClass.clazz
|
NotificationHeaderViewWrapperClass.clazz
|
||||||
@@ -674,13 +739,14 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
/** 非最小化优先级的通知全部设置为展开状态 */
|
/** 非最小化优先级的通知全部设置为展开状态 */
|
||||||
if (importance != 1) isExpanded = true
|
if (importance != 1) isExpanded = true
|
||||||
/** 执行 Hook */
|
/** 执行 Hook */
|
||||||
hookNotifyIconOnSet(iconImageView.context, expandedNf, iconImageView, isExpanded)
|
compatNotifyIcon(iconImageView.context, expandedNf, iconImageView, origColor, isExpanded)
|
||||||
/** 刷新图标缓存 */
|
|
||||||
if (expandedNf?.compatOpPkgName == MODULE_PACKAGE_NAME &&
|
|
||||||
expandedNf.notification?.channelId == IconRuleManagerTool.NOTIFY_CHANNEL
|
|
||||||
) cachingIconDatas()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/** 记录实例 */
|
||||||
|
injectMember {
|
||||||
|
constructor { param(ContextClass, ViewClass, ExpandableNotificationRowClass.clazz) }
|
||||||
|
afterHook { notificationViewWrappers.add(instance) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/** 干掉下拉通知图标自动设置回 APP 图标的方法 */
|
/** 干掉下拉通知图标自动设置回 APP 图标的方法 */
|
||||||
NotificationHeaderViewWrapperInjectorClass.hook {
|
NotificationHeaderViewWrapperInjectorClass.hook {
|
||||||
|
@@ -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")
|
||||||
}
|
}
|
||||||
|
@@ -36,7 +36,6 @@ import com.fankes.miui.notify.R
|
|||||||
import com.fankes.miui.notify.databinding.ActivityMainBinding
|
import com.fankes.miui.notify.databinding.ActivityMainBinding
|
||||||
import com.fankes.miui.notify.databinding.DiaStatusIconCountBinding
|
import com.fankes.miui.notify.databinding.DiaStatusIconCountBinding
|
||||||
import com.fankes.miui.notify.hook.HookConst.ENABLE_COLOR_ICON_COMPAT
|
import com.fankes.miui.notify.hook.HookConst.ENABLE_COLOR_ICON_COMPAT
|
||||||
import com.fankes.miui.notify.hook.HookConst.ENABLE_COLOR_ICON_HOOK
|
|
||||||
import com.fankes.miui.notify.hook.HookConst.ENABLE_HIDE_ICON
|
import com.fankes.miui.notify.hook.HookConst.ENABLE_HIDE_ICON
|
||||||
import com.fankes.miui.notify.hook.HookConst.ENABLE_HOOK_STATUS_ICON_COUNT
|
import com.fankes.miui.notify.hook.HookConst.ENABLE_HOOK_STATUS_ICON_COUNT
|
||||||
import com.fankes.miui.notify.hook.HookConst.ENABLE_MODULE
|
import com.fankes.miui.notify.hook.HookConst.ENABLE_MODULE
|
||||||
@@ -151,10 +150,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
var statusBarIconCount = modulePrefs.getInt(HOOK_STATUS_ICON_COUNT, default = 5)
|
var statusBarIconCount = modulePrefs.getInt(HOOK_STATUS_ICON_COUNT, default = 5)
|
||||||
binding.colorIconHookItem.isVisible = modulePrefs.getBoolean(ENABLE_MODULE, default = true)
|
binding.colorIconHookItem.isVisible = modulePrefs.getBoolean(ENABLE_MODULE, default = true)
|
||||||
binding.statusIconCountItem.isVisible = modulePrefs.getBoolean(ENABLE_MODULE, default = true)
|
binding.statusIconCountItem.isVisible = modulePrefs.getBoolean(ENABLE_MODULE, default = true)
|
||||||
binding.colorIconCompatSwitch.isVisible = modulePrefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)
|
binding.notifyIconConfigItem.isVisible = modulePrefs.getBoolean(ENABLE_MODULE, default = true)
|
||||||
binding.colorIconCompatText.isVisible = modulePrefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)
|
|
||||||
binding.notifyIconConfigItem.isVisible = modulePrefs.getBoolean(ENABLE_MODULE, default = true) &&
|
|
||||||
modulePrefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)
|
|
||||||
binding.notifyIconFixButton.isVisible = modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)
|
binding.notifyIconFixButton.isVisible = modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)
|
||||||
binding.notifyIconFixNotifyItem.isVisible = modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)
|
binding.notifyIconFixNotifyItem.isVisible = modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)
|
||||||
binding.statusIconCountSwitch.isChecked = modulePrefs.getBoolean(ENABLE_HOOK_STATUS_ICON_COUNT, default = true)
|
binding.statusIconCountSwitch.isChecked = modulePrefs.getBoolean(ENABLE_HOOK_STATUS_ICON_COUNT, default = true)
|
||||||
@@ -162,7 +158,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
binding.moduleEnableSwitch.isChecked = modulePrefs.getBoolean(ENABLE_MODULE, default = true)
|
binding.moduleEnableSwitch.isChecked = modulePrefs.getBoolean(ENABLE_MODULE, default = true)
|
||||||
binding.moduleEnableLogSwitch.isChecked = modulePrefs.getBoolean(ENABLE_MODULE_LOG)
|
binding.moduleEnableLogSwitch.isChecked = modulePrefs.getBoolean(ENABLE_MODULE_LOG)
|
||||||
binding.hideIconInLauncherSwitch.isChecked = modulePrefs.getBoolean(ENABLE_HIDE_ICON)
|
binding.hideIconInLauncherSwitch.isChecked = modulePrefs.getBoolean(ENABLE_HIDE_ICON)
|
||||||
binding.colorIconHookSwitch.isChecked = modulePrefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)
|
|
||||||
binding.colorIconCompatSwitch.isChecked = modulePrefs.getBoolean(ENABLE_COLOR_ICON_COMPAT)
|
binding.colorIconCompatSwitch.isChecked = modulePrefs.getBoolean(ENABLE_COLOR_ICON_COMPAT)
|
||||||
binding.notifyIconFixSwitch.isChecked = modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)
|
binding.notifyIconFixSwitch.isChecked = modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)
|
||||||
binding.notifyIconFixNotifySwitch.isChecked = modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX_NOTIFY, default = true)
|
binding.notifyIconFixNotifySwitch.isChecked = modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX_NOTIFY, default = true)
|
||||||
@@ -173,7 +168,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
binding.moduleEnableLogSwitch.isVisible = b
|
binding.moduleEnableLogSwitch.isVisible = b
|
||||||
binding.colorIconHookItem.isVisible = b
|
binding.colorIconHookItem.isVisible = b
|
||||||
binding.statusIconCountItem.isVisible = b
|
binding.statusIconCountItem.isVisible = b
|
||||||
binding.notifyIconConfigItem.isVisible = b && binding.colorIconHookSwitch.isChecked
|
binding.notifyIconConfigItem.isVisible = b
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.showNeedRestartSnake(context = this)
|
||||||
}
|
}
|
||||||
binding.moduleEnableLogSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.moduleEnableLogSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
@@ -196,30 +191,22 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
binding.statusIconCountChildItem.isVisible = b
|
binding.statusIconCountChildItem.isVisible = b
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.showNeedRestartSnake(context = this)
|
||||||
}
|
}
|
||||||
binding.colorIconHookSwitch.setOnCheckedChangeListener { btn, b ->
|
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
|
||||||
modulePrefs.putBoolean(ENABLE_COLOR_ICON_HOOK, b)
|
|
||||||
binding.notifyIconConfigItem.isVisible = b
|
|
||||||
binding.colorIconCompatSwitch.isVisible = b
|
|
||||||
binding.colorIconCompatText.isVisible = b
|
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
|
||||||
}
|
|
||||||
binding.colorIconCompatSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.colorIconCompatSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(ENABLE_COLOR_ICON_COMPAT, b)
|
modulePrefs.putBoolean(ENABLE_COLOR_ICON_COMPAT, b)
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.refreshSystemUI(context = this)
|
||||||
}
|
}
|
||||||
binding.notifyIconFixSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.notifyIconFixSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
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.notifyIconFixButton.setOnClickListener { navigate<ConfigureActivity>() }
|
binding.notifyIconFixButton.setOnClickListener { navigate<ConfigureActivity>() }
|
||||||
|
@@ -152,12 +152,18 @@ val miuiVersion
|
|||||||
*/
|
*/
|
||||||
val miuiVersionCode get() = safeOf(default = 0f) { miuiVersion.toFloat() }
|
val miuiVersionCode get() = safeOf(default = 0f) { miuiVersion.toFloat() }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 MIUI 次版本号
|
||||||
|
* @return [String]
|
||||||
|
*/
|
||||||
|
val miuiIncrementalVersion get() = findPropString(key = "ro.system.build.version.incremental").trim()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取 MIUI 完全版本
|
* 获取 MIUI 完全版本
|
||||||
* @return [String]
|
* @return [String]
|
||||||
*/
|
*/
|
||||||
val miuiFullVersion
|
val miuiFullVersion
|
||||||
get() = if (isMIUI) findPropString(key = "ro.system.build.version.incremental").let {
|
get() = if (isMIUI) miuiIncrementalVersion.let {
|
||||||
if (it.lowercase().contains("a") ||
|
if (it.lowercase().contains("a") ||
|
||||||
it.lowercase().contains("b") ||
|
it.lowercase().contains("b") ||
|
||||||
it.lowercase().contains("c") ||
|
it.lowercase().contains("c") ||
|
||||||
|
@@ -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,16 +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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -404,16 +423,14 @@ object IconRuleManagerTool {
|
|||||||
setContentText(msg)
|
setContentText(msg)
|
||||||
color = OS_COLOR.toInt()
|
color = OS_COLOR.toInt()
|
||||||
setAutoCancel(true)
|
setAutoCancel(true)
|
||||||
setSmallIcon(R.drawable.ic_nf_icon_update)
|
setSmallIcon(if (isAction) R.drawable.ic_nf_icon_update else R.drawable.ic_nf_icon_refresh)
|
||||||
setSound(null)
|
setSound(null)
|
||||||
setDefaults(NotificationCompat.DEFAULT_ALL)
|
setDefaults(NotificationCompat.DEFAULT_ALL)
|
||||||
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())
|
||||||
|
@@ -51,6 +51,12 @@ object SystemUITool {
|
|||||||
cancelButton()
|
cancelButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新系统界面状态栏与通知图标
|
||||||
|
* @param context 实例
|
||||||
|
*/
|
||||||
|
fun refreshSystemUI(context: Context) = IconRuleManagerTool.refreshSystemUI(context)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示需要重启系统界面的 [Snackbar]
|
* 显示需要重启系统界面的 [Snackbar]
|
||||||
* @param context 实例
|
* @param context 实例
|
||||||
@@ -68,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 = "模块没有激活,更改不会生效")
|
||||||
}
|
}
|
12
app/src/main/res/drawable/ic_nf_icon_refresh.xml
Normal file
12
app/src/main/res/drawable/ic_nf_icon_refresh.xml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:autoMirrored="true"
|
||||||
|
android:tint="@color/white"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M9.01,14H2v2h7.01v3L13,15l-3.99,-4V14zM14.99,13v-3H22V8h-7.01V5L11,9L14.99,13z" />
|
||||||
|
</vector>
|
@@ -1,5 +1,11 @@
|
|||||||
<vector android:height="24dp" android:tint="#FFFFFF"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:viewportHeight="24" android:viewportWidth="24"
|
android:width="24dp"
|
||||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
android:height="24dp"
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM14,13v4h-4v-4H7l5,-5 5,5h-3z"/>
|
android:tint="@color/white"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM14,13v4h-4v-4H7l5,-5 5,5h-3z" />
|
||||||
</vector>
|
</vector>
|
||||||
|
@@ -419,35 +419,15 @@
|
|||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<com.fankes.miui.notify.ui.view.MaterialSwitch
|
|
||||||
android:id="@+id/color_icon_hook_switch"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="忽略彩色通知图标"
|
|
||||||
android:textColor="@color/colorTextGray"
|
|
||||||
android:textSize="15sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="5dp"
|
|
||||||
android:alpha="0.6"
|
|
||||||
android:lineSpacingExtra="6dp"
|
|
||||||
android:text="此选项默认开启,开启后将自动对 APP 通知图标进行判断,保持高版本 API 的 APP 不规范的彩色图标不被着色为白、黑色块并对图标进行圆角优化,关闭后将按照 Android API 规范对 APP 通知进行图标着色,可能会出现着色为黑白、色块情况。"
|
|
||||||
android:textColor="@color/colorTextDark"
|
|
||||||
android:textSize="12sp" />
|
|
||||||
|
|
||||||
<com.fankes.miui.notify.ui.view.MaterialSwitch
|
<com.fankes.miui.notify.ui.view.MaterialSwitch
|
||||||
android:id="@+id/color_icon_compat_switch"
|
android:id="@+id/color_icon_compat_switch"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="35dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="5dp"
|
|
||||||
android:text="启用兼容模式"
|
android:text="启用兼容模式"
|
||||||
android:textColor="@color/colorTextGray"
|
android:textColor="@color/colorTextGray"
|
||||||
android:textSize="15sp" />
|
android:textSize="15sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/color_icon_compat_text"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
|
Reference in New Issue
Block a user