8 Commits
2.9 ... 2.95

11 changed files with 75 additions and 76 deletions

View File

@@ -2,7 +2,7 @@
[![Blank](https://img.shields.io/badge/build-passing-brightgreen)](https://github.com/fankes/MIUINativeNotifyIcon)
[![Blank](https://img.shields.io/badge/license-AGPL3.0-blue)](https://github.com/fankes/MIUINativeNotifyIcon/blob/master/LICENSE)
[![Blank](https://img.shields.io/badge/version-v2.9-green)](https://github.com/fankes/MIUINativeNotifyIcon/releases)
[![Blank](https://img.shields.io/badge/version-v2.95-green)](https://github.com/fankes/MIUINativeNotifyIcon/releases)
[![Blank](https://img.shields.io/github/downloads/fankes/MIUINativeNotifyIcon/total?label=Release)](https://github.com/fankes/MIUINativeNotifyIcon/releases)
[![Blank](https://img.shields.io/github/downloads/Xposed-Modules-Repo/com.fankes.miui.notify/total?label=LSPosed%20Repo&logo=Android&style=flat&labelColor=F48FB1&logoColor=ffffff)](https://github.com/Xposed-Modules-Repo/com.fankes.miui.notify/releases)
[![Telegram](https://img.shields.io/badge/Follow-Telegram-blue.svg?logo=telegram)](https://t.me/XiaofangInternet)
@@ -54,7 +54,7 @@ Fix the native notification bar icon function abandoned by the MIUI development
- [Automatic Build on Commit](https://github.com/fankes/MIUINativeNotifyIcon/actions/workflows/commit_ci.yml)
上述更新为代码 `commit` 后自动触发,具体更新内容可点击上方的文字前往 **Github Actions** 进行查看,本更新由开源的流程自动编译发布,**不保证其稳定性**,所发布的版本**仅供测试**,且不会特殊说明甚至可能会变更版本号或保持与当前稳定版相同的版本号。
上述更新为代码 `commit` 后自动触发,具体更新内容可点击上方的文字前往 **GitHub Actions** 进行查看,本更新由开源的流程自动编译发布,**不保证其稳定性**,所发布的版本**仅供测试**,且不会特殊说明甚至可能会变更版本号或保持与当前稳定版相同的版本号。
- [Release](https://github.com/fankes/MIUINativeNotifyIcon/releases)
- [Xposed-Modules-Repo](https://github.com/Xposed-Modules-Repo/com.fankes.miui.notify/releases)

View File

@@ -36,10 +36,10 @@ object PackageName {
*/
object IconRuleSourceSyncType {
/** Github Raw (代理) */
/** GitHub Raw (代理) */
const val GITHUB_RAW_PROXY = 1000
/** Github Raw (直连) */
/** GitHub Raw (直连) */
const val GITHUB_RAW_DIRECT = 2000
/** 自定义地址 */

View File

@@ -63,9 +63,7 @@ import com.highcapable.yukihookapi.hook.factory.*
import com.highcapable.yukihookapi.hook.log.loggerD
import com.highcapable.yukihookapi.hook.log.loggerW
import com.highcapable.yukihookapi.hook.type.android.*
import com.highcapable.yukihookapi.hook.type.defined.VagueType
import com.highcapable.yukihookapi.hook.type.java.BooleanType
import com.highcapable.yukihookapi.hook.type.java.FloatType
import com.highcapable.yukihookapi.hook.type.java.IntType
import top.defaults.drawabletoolbox.DrawableBuilder
@@ -142,9 +140,6 @@ object SystemUIHooker : YukiBaseHooker() {
/** 缓存的通知图标优化数组 */
private var iconDatas = ArrayList<IconDataBean>()
/** 已缓存的灰度图标 (单色图标) 判断结果数组 */
private val grayscaleIconResults = HashMap<String, Boolean>()
/** 当前是否处于深色图标模式 - 跟随 Hook 保存 */
private var isDarkIconMode = false
@@ -251,22 +246,15 @@ object SystemUIHooker : YukiBaseHooker() {
}
/**
* 判断是否为灰度图标 (单色图标)
* - 这个是修复彩色图标的关键核心代码判断
*
* 判断是否为灰度图标 - 反射执行系统方法
* @param context 实例
* @param drawable 要判断的图标
* @param instance 用于标识缓存的实例
* @return [Boolean]
*/
private fun isGrayscaleIcon(context: Context, drawable: Drawable, instance: Any): Boolean {
/** 从缓存中读取的结果 */
val cachedResult = when (instance) {
is StatusBarNotification -> grayscaleIconResults[instance.notification.toString()]
is Notification -> grayscaleIconResults[instance.toString()]
else -> null
}
/** 当前实时获取的结果 */
val currentResult = if (ConfigData.isEnableColorIconCompat.not()) safeOfFalse {
private fun isGrayscaleIcon(context: Context, drawable: Drawable) =
if (ConfigData.isEnableColorIconCompat.not()) safeOfFalse {
ContrastColorUtilClass.toClass().let {
it.method {
name = "isGrayscaleIcon"
@@ -277,13 +265,6 @@ object SystemUIHooker : YukiBaseHooker() {
}.get().invoke(context)).boolean(drawable)
}
} else BitmapCompatTool.isGrayscaleDrawable(drawable)
return cachedResult ?: currentResult.also {
when (instance) {
is StatusBarNotification -> grayscaleIconResults[instance.notification.toString()] = it
is Notification -> grayscaleIconResults[instance.toString()] = it
}
}
}
/**
* 处理为圆角图标
@@ -362,7 +343,7 @@ object SystemUIHooker : YukiBaseHooker() {
}
}
if (isGrayscaleIcon.not() && ConfigData.isEnableNotifyIconFixPlaceholder)
customPair = Triple(context.resources.drawableOf(R.drawable.ic_unsupported), 0, true)
customPair = Triple(context.resources.drawableOf(R.drawable.ic_message), 0, true)
}
return customPair ?: Triple(null, 0, false)
}
@@ -379,7 +360,7 @@ object SystemUIHooker : YukiBaseHooker() {
private fun compatStatusIcon(context: Context, nf: StatusBarNotification?, iconDrawable: Drawable?) = nf?.let { notifyInstance ->
if (iconDrawable == null) return@let Pair(null, false)
/** 判断是否不是灰度图标 */
val isGrayscaleIcon = notifyInstance.isXmsf.not() && isGrayscaleIcon(context, iconDrawable, notifyInstance)
val isGrayscaleIcon = notifyInstance.isXmsf.not() && isGrayscaleIcon(context, iconDrawable)
/** 目标彩色通知 APP 图标 */
val customTriple = compatCustomIcon(context, isGrayscaleIcon, notifyInstance.nfPkgName)
@@ -473,7 +454,7 @@ object SystemUIHooker : YukiBaseHooker() {
?: return@let loggerW(msg = "compatNotifyIcon got null smallIcon")
/** 判断图标风格 */
val isGrayscaleIcon = notifyInstance.isXmsf.not() && isGrayscaleIcon(context, iconDrawable, notifyInstance)
val isGrayscaleIcon = notifyInstance.isXmsf.not() && isGrayscaleIcon(context, iconDrawable)
/** 自定义默认小图标 */
var customIcon: Drawable? = null
@@ -553,7 +534,7 @@ object SystemUIHooker : YukiBaseHooker() {
?: return loggerW(msg = "isGrayscaleIcon got null smallIcon").let { false }
/** 判断是否不是灰度图标 */
val isGrayscaleIcon = notifyInstance.isXmsf.not() && isGrayscaleIcon(context, iconDrawable, notifyInstance)
val isGrayscaleIcon = notifyInstance.isXmsf.not() && isGrayscaleIcon(context, iconDrawable)
/** 获取目标修复彩色图标的 APP */
val isTargetFixApp = compatCustomIcon(context, isGrayscaleIcon, notifyInstance.nfPkgName).first != null
@@ -601,6 +582,37 @@ object SystemUIHooker : YukiBaseHooker() {
}
}
/**
* Hook 原生通知包装纸实例内容
* @param wrapper 通知包装纸实例
*/
private fun hookNotificationViewWrapper(wrapper: Any) {
/** 忽略较旧版本 - 在没有 MIUI 通知栏样式的时候可能出现奇怪的问题 */
if (isNotHasAbsoluteMiuiStyle && isShowMiuiStyle) return
/** 获取小图标 */
val iconImageView = NotificationHeaderViewWrapperClass.toClassOrNull()
?.field { name = "mIcon" }?.get(wrapper)?.cast<ImageView>() ?: return
/** 获取 [ExpandableNotificationRowClass] */
val rowPair = wrapper.getRowPair()
/** 获取 [StatusBarNotification] */
val expandedNf = rowPair.second.getSbn()
/** 通知是否展开 */
var isExpanded = rowPair.first
/** 获取优先级 */
val importance =
(iconImageView.context.getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager?)
?.getNotificationChannel(expandedNf?.notification?.channelId)?.importance ?: 0
/** 非最小化优先级的通知全部设置为展开状态 */
if (importance != 1) isExpanded = true
/** 执行 Hook */
compatNotifyIcon(iconImageView.context, expandedNf, iconImageView, isExpanded)
}
/**
* 从 [NotificationViewWrapperClass] 中获取 [ExpandableNotificationRowClass]
* @return [Pair] - ([Boolean] 通知是否展开,[Any] 通知 Row 实例)
@@ -706,7 +718,6 @@ object SystemUIHooker : YukiBaseHooker() {
/** 缓存图标数据 */
private fun cachingIconDatas() {
iconDatas.clear()
grayscaleIconResults.clear()
IconPackParams(param = this).iconDatas.apply { if (isNotEmpty()) forEach { iconDatas.add(it) } }
}
@@ -779,7 +790,7 @@ object SystemUIHooker : YukiBaseHooker() {
injectMember {
method {
name = "onDarkChanged"
param(VagueType, FloatType, IntType)
paramCount { it > 0 }
}
afterHook {
field { name = "mNotificationIcons" }.get(instance).cast<ViewGroup>()?.also {
@@ -794,7 +805,7 @@ object SystemUIHooker : YukiBaseHooker() {
isDarkIconMode = false
updateStatusBarIconColor(it, isDarkIconMode = false)
}
else -> updateStatusBarIconColor(it, isDarkIconMode = false, args().last().int())
else -> updateStatusBarIconColor(it, isDarkIconMode = false, args(index = 2).int())
}
}
}
@@ -891,35 +902,13 @@ object SystemUIHooker : YukiBaseHooker() {
}
/** 注入原生通知包装纸实例 */
NotificationHeaderViewWrapperClass.hook {
/** 修复下拉通知图标自动设置回 APP 图标的方法 */
injectMember {
method { name { it == "resolveHeaderViews" || it == "handleHeaderViews" || it == "resolveViews" } }
afterHook {
/** 忽略较旧版本 - 在没有 MIUI 通知栏样式的时候可能出现奇怪的问题 */
if (isNotHasAbsoluteMiuiStyle && isShowMiuiStyle) return@afterHook
/** 获取小图标 */
val iconImageView = NotificationHeaderViewWrapperClass.toClassOrNull()
?.field { name = "mIcon" }?.get(instance)?.cast<ImageView>() ?: return@afterHook
/** 获取 [ExpandableNotificationRowClass] */
val rowPair = instance.getRowPair()
/** 获取 [StatusBarNotification] */
val expandedNf = rowPair.second.getSbn()
/** 通知是否展开 */
var isExpanded = rowPair.first
/** 获取优先级 */
val importance =
(iconImageView.context.getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager?)
?.getNotificationChannel(expandedNf?.notification?.channelId)?.importance ?: 0
/** 非最小化优先级的通知全部设置为展开状态 */
if (importance != 1) isExpanded = true
/** 执行 Hook */
compatNotifyIcon(iconImageView.context, expandedNf, iconImageView, isExpanded)
}
afterHook { hookNotificationViewWrapper(instance) }
}
injectMember {
method { name = "onContentUpdated" }
afterHook { hookNotificationViewWrapper(instance) }
}
}
/** 修改 MIUI 风格通知栏的通知图标 */

View File

@@ -158,7 +158,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
binding.mainTextVersion.text = "模块版本:$moduleVersion $pendingFlag"
binding.mainTextMiuiVersion.text = "系统版本:[$androidVersionCodeName] $miuiFullVersion"
binding.warnSCountDisTip.isGone = miuiVersionCode > 12.5
binding.warnMiuiNotifyStyleTip.isGone = miuiVersionCode > 12
binding.warnMiuiNotifyStyleTip.isGone = miuiVersionCode > 11
binding.statusIconCountText.text = ConfigData.liftedStatusIconCount.toString()
binding.notifyIconAutoSyncText.text = ConfigData.notifyIconFixAutoTime
binding.moduleEnableSwitch.bind(ConfigData.ENABLE_MODULE) {

View File

@@ -356,12 +356,12 @@ val Context.systemAccentColor
/**
* 获取系统壁纸颜色
* @return [Int] 无法获取时返回透明
* @return [Int] 无法获取时返回默认颜
*/
val Context.wallpaperColor
get() = safeOfNan {
WallpaperManager.getInstance(this).getWallpaperColors(WallpaperManager.FLAG_SYSTEM)?.primaryColor?.toArgb() ?: 0
}
get() = runCatching {
WallpaperManager.getInstance(this).getWallpaperColors(WallpaperManager.FLAG_SYSTEM)?.primaryColor?.toArgb()
}.getOrNull() ?: (if (isSystemInDarkMode) 0xFFD8D8D8.toInt() else 0xFF707173.toInt())
/**
* 获取较浅的颜色

View File

@@ -35,7 +35,7 @@ import java.io.Serializable
import java.util.*
/**
* 获取 Github Release 最新版本工具类
* 获取 GitHub Release 最新版本工具类
*/
object GithubReleaseTool {
@@ -129,7 +129,7 @@ object GithubReleaseTool {
}
/**
* Github Release bean
* GitHub Release bean
* @param name 版本名称
* @param htmlUrl 网页地址
* @param content 更新日志

View File

@@ -67,10 +67,10 @@ object IconRuleManagerTool {
/** 当前规则的通知图标颜色 */
private const val OS_COLOR = 0xFFE06818.toInt()
/** 同步地址 - Github Raw (代理) */
/** 同步地址 - GitHub Raw (代理) */
private const val SYNC_PROXY_URL = "https://raw.githubusercontentS.com/fankes/AndroidNotifyIconAdapt/main"
/** 同步地址 - Github Raw (直连) */
/** 同步地址 - GitHub Raw (直连) */
private const val SYNC_DIRECT_URL = "https://raw.githubusercontent.com/fankes/AndroidNotifyIconAdapt/main"
/** 云端规则展示地址 (OS) */

View File

@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:fillColor="#ffffff"
android:pathData="m522.8,93.9c-244.2,0 -442.1,173.2 -442.1,386.9 0,122.1 64.9,230.9 165.8,301.7v195.7l193.7,-117.5c26.8,4.4 54.3,7 82.6,7 244.2,0 442.1,-173.2 442.1,-386.9C965,267.1 767.1,93.9 522.8,93.9Z"
android:strokeWidth="1.10883" />
</vector>

View File

@@ -767,7 +767,7 @@
android:layout_marginRight="15dp"
android:alpha="0.6"
android:lineSpacingExtra="6dp"
android:text="⚠️ 在 MIUI 11、12 上可能需要 Root 权限才能打开。"
android:text="⚠️ 在 MIUI 11 上可能需要 Root 权限才能打开。"
android:textColor="@color/colorTextDark"
android:textSize="12sp"
android:textStyle="bold" />

View File

@@ -28,14 +28,14 @@
android:id="@+id/source_radio_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Github Raw (7ED Services)"
android:text="GitHub Raw (7ED Services)"
app:buttonTint="@color/colorPrimaryAccent" />
<com.google.android.material.radiobutton.MaterialRadioButton
android:id="@+id/source_radio_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Github Raw (直连)"
android:text="GitHub Raw (直连)"
app:buttonTint="@color/colorPrimaryAccent" />
<com.google.android.material.radiobutton.MaterialRadioButton

View File

@@ -5,8 +5,8 @@ plugins {
}
ext {
appVersionName = "2.9"
appVersionCode = 35
appVersionName = "2.95"
appVersionCode = 36
enableR8 = true
}