8 Commits
2.3 ... 2.35

Author SHA1 Message Date
2e5284ebe9 Update version to 2.35 2022-04-04 13:55:10 +08:00
abffc4d853 Update version to 2.35 2022-04-04 13:54:42 +08:00
5d81b8ff87 尝试修复 MIUI 12 的问题 2022-04-04 13:48:54 +08:00
d91d2736e6 修复图标缓存过大造成系统界面停止运行的问题 2022-04-04 13:38:38 +08:00
72169989f2 Merge code 2022-04-04 12:04:12 +08:00
c85da002f5 Update YukiHookAPI 2022-04-04 03:13:19 +08:00
c09a1b5760 Update README.md 2022-03-30 20:56:52 +08:00
c30e56c5aa Update YukiHookAPI 2022-03-30 14:13:48 +08:00
8 changed files with 50 additions and 45 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/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/license-AGPL3.0-blue)](https://github.com/fankes/MIUINativeNotifyIcon/blob/master/LICENSE)
[![Blank](https://img.shields.io/badge/version-v2.3-green)](https://github.com/fankes/MIUINativeNotifyIcon/releases) [![Blank](https://img.shields.io/badge/version-v2.35-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/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) [![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/static/v1?label=Telegram&message=交流讨论&color=0088cc)](https://t.me/XiaofangInternet) [![Telegram](https://img.shields.io/static/v1?label=Telegram&message=交流讨论&color=0088cc)](https://t.me/XiaofangInternet)
@@ -85,6 +85,11 @@ ContrastColorUtil.getInstance().isGrayscaleIcon(drawable)
特地的把自己能有的小米手机刷成各种 MIUI 版本去为酷友做专项适配,我也是很累了,也希望你们能够多多支持,也能让 MIUI 做得更好。<br/><br/> 特地的把自己能有的小米手机刷成各种 MIUI 版本去为酷友做专项适配,我也是很累了,也希望你们能够多多支持,也能让 MIUI 做得更好。<br/><br/>
MIUI 再不重写,怕是永远会变成安卓之光。雷军,金凡!! MIUI 再不重写,怕是永远会变成安卓之光。雷军,金凡!!
# 捐赠支持
- 工作不易,无意外情况此项目将继续维护下去,提供更多可能,欢迎打赏。<br/><br/>
<img src="https://github.com/fankes/YuKiHookAPI/blob/master/img-src/wechat_code.jpg" width = "200" height = "200"/>
# 许可证 # 许可证
- [AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.html) - [AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.html)

View File

@@ -72,8 +72,8 @@ tasks.whenTaskAdded {
dependencies { dependencies {
compileOnly 'de.robv.android.xposed:api:82' compileOnly 'de.robv.android.xposed:api:82'
implementation 'com.highcapable.yukihookapi:api:1.0.68' implementation 'com.highcapable.yukihookapi:api:1.0.70'
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.68' ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.70'
implementation "com.github.topjohnwu.libsu:core:3.1.2" implementation "com.github.topjohnwu.libsu:core:3.1.2"
implementation 'androidx.annotation:annotation:1.3.0' implementation 'androidx.annotation:annotation:1.3.0'
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0' implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'

View File

@@ -41,7 +41,7 @@ object Const {
const val MODULE_VERSION_CODE = BuildConfig.VERSION_CODE const val MODULE_VERSION_CODE = BuildConfig.VERSION_CODE
/** 当前模块的版本校验 */ /** 当前模块的版本校验 */
const val MODULE_VERSION_VERIFY = "${MODULE_VERSION_NAME}_${MODULE_VERSION_CODE}_202203292350" const val MODULE_VERSION_VERIFY = "${MODULE_VERSION_NAME}_${MODULE_VERSION_CODE}_202204041350"
/** 当前模块的版本校验标签 */ /** 当前模块的版本校验标签 */
const val MODULE_VERSION_VERIFY_TAG = "module_version_verify" const val MODULE_VERSION_VERIFY_TAG = "module_version_verify"

View File

@@ -36,11 +36,13 @@ import android.graphics.drawable.Drawable
import android.graphics.drawable.Icon import android.graphics.drawable.Icon
import android.os.Build import android.os.Build
import android.service.notification.StatusBarNotification import android.service.notification.StatusBarNotification
import android.util.ArraySet
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewOutlineProvider import android.view.ViewOutlineProvider
import android.widget.ImageView import android.widget.ImageView
import androidx.core.graphics.drawable.toBitmap import androidx.core.graphics.drawable.toBitmap
import androidx.core.view.children
import com.fankes.miui.notify.bean.IconDataBean import com.fankes.miui.notify.bean.IconDataBean
import com.fankes.miui.notify.const.Const import com.fankes.miui.notify.const.Const
import com.fankes.miui.notify.data.DataConst import com.fankes.miui.notify.data.DataConst
@@ -148,17 +150,17 @@ class SystemUIHooker : YukiBaseHooker() {
/** 是否已经使用过缓存刷新功能 */ /** 是否已经使用过缓存刷新功能 */
private var isUsingCachingMethod = false private var isUsingCachingMethod = false
/** 缓存的状态栏小图标实例 */ /** 状态栏通知图标容器 */
private var statusBarIconViews = HashSet<ImageView>() private var notificationIconContainer: ViewGroup? = null
/** 缓存的通知小图标包装纸实例 */ /** 缓存的通知小图标包装纸实例 */
private var notificationViewWrappers = HashSet<Any>() private var notificationViewWrappers = ArraySet<Any>()
/** MIUI 样式下的缓存的通知小图标包装纸实例 */ /** MIUI 样式下的缓存的通知小图标包装纸实例 */
private var miuiNotificationViewWrappers = HashSet<Any>() private var miuiNotificationViewWrappers = ArraySet<Any>()
/** MIUI 样式下的缓存的通知小图标折叠通知实例 */ /** MIUI 样式下的缓存的通知小图标折叠通知实例 */
private var miuiNotificationChildrenContainers = HashSet<ViewGroup>() private var miuiNotificationChildrenContainers = ArraySet<ViewGroup>()
/** 仅监听一次主题壁纸颜色变化 */ /** 仅监听一次主题壁纸颜色变化 */
private var isWallpaperColorListenerSetUp = false private var isWallpaperColorListenerSetUp = false
@@ -268,19 +270,10 @@ class SystemUIHooker : YukiBaseHooker() {
get() = safeOfFalse { get() = safeOfFalse {
NotificationUtilClass.clazz.hasMethod { NotificationUtilClass.clazz.hasMethod {
name = "ignoreStatusBarIconColor" name = "ignoreStatusBarIconColor"
param(ExpandedNotificationClass.clazz) param(ExpandedNotificationClass)
} }
} }
/**
* 获取当前通知栏的样式
*
* - ❗新版本可能不存在这个方法
* @return [Boolean]
*/
private val isShowMiuiStyle
get() = safeOfFalse { NotificationUtilClass.clazz.method { name = "showMiuiStyle" }.get().invoke() ?: false }
/** /**
* 处理为圆角图标 * 处理为圆角图标
* @return [Drawable] * @return [Drawable]
@@ -385,12 +378,12 @@ class SystemUIHooker : YukiBaseHooker() {
/** 刷新状态栏小图标 */ /** 刷新状态栏小图标 */
private fun refreshStatusBarIcons() = runInSafe { private fun refreshStatusBarIcons() = runInSafe {
StatusBarIconViewClass.clazz.field { name = "mNotification" }.also { result -> StatusBarIconViewClass.clazz.field { name = "mNotification" }.also { result ->
statusBarIconViews.takeIf { it.isNotEmpty() }?.forEach { notificationIconContainer?.children?.forEach {
/** 得到通知实例 */ /** 得到通知实例 */
val nf = result.get(it).cast<StatusBarNotification>() ?: return val nf = result.get(it).cast<StatusBarNotification>() ?: return
/** 刷新状态栏图标 */ /** 刷新状态栏图标 */
compatStatusIcon(it.context, nf, nf.notification.smallIcon.loadDrawable(it.context)).also { pair -> compatStatusIcon(it.context, nf, nf.notification.smallIcon.loadDrawable(it.context)).also { pair ->
pair.first.let { e -> it.setImageDrawable(e) } pair.first.let { e -> (it as? ImageView?)?.setImageDrawable(e) }
} }
} }
} }
@@ -685,28 +678,24 @@ class SystemUIHooker : YukiBaseHooker() {
injectMember { injectMember {
method { method {
name = "shouldSubstituteSmallIcon" name = "shouldSubstituteSmallIcon"
param(ExpandedNotificationClass.clazz) param(ExpandedNotificationClass)
} }
/** replaceToFalse()
* MIUI 12 在非原生样式下 MIPUSH 的图标着色异常
* 所以判断是 MIUI 样式就停止 Hook 状态栏图标
*/
replaceAny { hasIgnoreStatusBarIconColor.not() && isShowMiuiStyle }
} }
/** 强制回写系统的状态栏图标样式为原生 */ /** 强制回写系统的状态栏图标样式为原生 */
injectMember { injectMember {
var isUseLegacy = false var isUseLegacy = false
method { method {
name = "getSmallIcon" name = "getSmallIcon"
param(ExpandedNotificationClass.clazz, IntType) param(ExpandedNotificationClass, IntType)
}.remedys { }.remedys {
method { method {
name = "getSmallIcon" name = "getSmallIcon"
param(ExpandedNotificationClass.clazz) param(ExpandedNotificationClass)
} }
method { method {
name = "getSmallIcon" name = "getSmallIcon"
param(ContextClass, ExpandedNotificationClass.clazz) param(ContextClass, ExpandedNotificationClass)
}.onFind { isUseLegacy = true } }.onFind { isUseLegacy = true }
} }
afterHook { afterHook {
@@ -757,7 +746,7 @@ class SystemUIHooker : YukiBaseHooker() {
}.remedys { }.remedys {
method { method {
name = "setNotification" name = "setNotification"
param(ExpandedNotificationClass.clazz) param(ExpandedNotificationClass)
} }
} }
afterHook { afterHook {
@@ -766,8 +755,6 @@ class SystemUIHooker : YukiBaseHooker() {
registerWallpaperColorChanged(it) registerWallpaperColorChanged(it)
/** 注册广播 */ /** 注册广播 */
registerReceiver(it.context) registerReceiver(it.context)
/** 缓存实例 */
statusBarIconViews.add(it)
} }
} }
} }
@@ -777,6 +764,8 @@ class SystemUIHooker : YukiBaseHooker() {
injectMember { injectMember {
method { name = "calculateIconTranslations" } method { name = "calculateIconTranslations" }
afterHook { afterHook {
/** 缓存实例 */
notificationIconContainer = instance<ViewGroup>()
/** 修复部分开发版状态栏图标只能显示一个的问题 */ /** 修复部分开发版状态栏图标只能显示一个的问题 */
when (miuiIncrementalVersion.lowercase()) { when (miuiIncrementalVersion.lowercase()) {
"22.3.14", "22.3.15", "22.3.16", "v13.0.1.1.16.dev", "22.3.18" -> "22.3.14", "22.3.15", "22.3.16", "v13.0.1.1.16.dev", "22.3.18" ->
@@ -793,7 +782,7 @@ class SystemUIHooker : YukiBaseHooker() {
.get(instance).set(prefs.get(DataConst.HOOK_STATUS_ICON_COUNT) .get(instance).set(prefs.get(DataConst.HOOK_STATUS_ICON_COUNT)
.let { if (it in 0..100) it else 5 }) .let { if (it in 0..100) it else 5 })
} }
} }.by { NotificationIconContainerClass.clazz.hasField { name = "MAX_STATIC_ICONS" } }
/** 旧版方法 - 新版不存在 */ /** 旧版方法 - 新版不存在 */
injectMember { injectMember {
method { method {
@@ -810,7 +799,7 @@ class SystemUIHooker : YukiBaseHooker() {
} }
beforeHook { isShowNotificationIcons = firstArgs<Boolean>() ?: false } beforeHook { isShowNotificationIcons = firstArgs<Boolean>() ?: false }
}.ignoredNoSuchMemberFailure() }.ignoredNoSuchMemberFailure()
}.by { NotificationIconContainerClass.clazz.hasField { name = "MAX_STATIC_ICONS" } } }
/** 注入原生通知包装纸实例 */ /** 注入原生通知包装纸实例 */
NotificationHeaderViewWrapperClass.hook { NotificationHeaderViewWrapperClass.hook {
/** 修复下拉通知图标自动设置回 APP 图标的方法 */ /** 修复下拉通知图标自动设置回 APP 图标的方法 */
@@ -845,7 +834,7 @@ class SystemUIHooker : YukiBaseHooker() {
} }
/** 记录实例 */ /** 记录实例 */
injectMember { injectMember {
constructor { param(ContextClass, ViewClass, ExpandableNotificationRowClass.clazz) } constructor { param(ContextClass, ViewClass, ExpandableNotificationRowClass) }
afterHook { notificationViewWrappers.add(instance) } afterHook { notificationViewWrappers.add(instance) }
} }
} }
@@ -867,7 +856,7 @@ class SystemUIHooker : YukiBaseHooker() {
} }
/** 记录实例 */ /** 记录实例 */
injectMember { injectMember {
constructor { param(ContextClass, ViewClass, ExpandableNotificationRowClass.clazz) } constructor { param(ContextClass, ViewClass, ExpandableNotificationRowClass) }
afterHook { miuiNotificationViewWrappers.add(instance) } afterHook { miuiNotificationViewWrappers.add(instance) }
} }
}.ignoredHookClassNotFoundFailure() }.ignoredHookClassNotFoundFailure()
@@ -899,11 +888,11 @@ class SystemUIHooker : YukiBaseHooker() {
injectMember { injectMember {
method { method {
name = "setAppIcon" name = "setAppIcon"
param(ContextClass, ImageViewClass, ExpandedNotificationClass.clazz) param(ContextClass, ImageViewClass, ExpandedNotificationClass)
}.remedys { }.remedys {
method { method {
name = "setAppIcon" name = "setAppIcon"
param(ImageViewClass, ExpandedNotificationClass.clazz) param(ImageViewClass, ExpandedNotificationClass)
} }
} }
intercept() intercept()
@@ -911,7 +900,7 @@ class SystemUIHooker : YukiBaseHooker() {
injectMember { injectMember {
method { method {
name = "resetIconBgAndPaddings" name = "resetIconBgAndPaddings"
param(ImageViewClass, ExpandedNotificationClass.clazz) param(ImageViewClass, ExpandedNotificationClass)
} }
intercept() intercept()
}.ignoredNoSuchMemberFailure() }.ignoredNoSuchMemberFailure()

View File

@@ -39,7 +39,7 @@ import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.viewbinding.ViewBinding import androidx.viewbinding.ViewBinding
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.highcapable.yukihookapi.annotation.DoNotUseField import com.highcapable.yukihookapi.annotation.CauseProblemsApi
import com.highcapable.yukihookapi.hook.factory.method import com.highcapable.yukihookapi.hook.factory.method
import com.highcapable.yukihookapi.hook.type.android.LayoutInflaterClass import com.highcapable.yukihookapi.hook.type.android.LayoutInflaterClass
@@ -71,7 +71,7 @@ class DialogBuilder(val context: Context, private val isUseBlackTheme: Boolean)
private var dialogInstance: Dialog? = null // 对话框实例 private var dialogInstance: Dialog? = null // 对话框实例
@DoNotUseField @CauseProblemsApi
var customLayoutView: View? = null // 自定义布局 var customLayoutView: View? = null // 自定义布局
/** /**

View File

@@ -121,7 +121,7 @@ object IconRuleManagerTool {
cancelButton() cancelButton()
neutralButton(text = "自定义规则") { neutralButton(text = "自定义规则") {
context.showDialog { context.showDialog {
title = "自定义规则" title = "自定义规则(调试)"
val editText = bind<DiaSourceFromStringBinding>().diaSfsInputEdit.apply { val editText = bind<DiaSourceFromStringBinding>().diaSfsInputEdit.apply {
requestFocus() requestFocus()
invalidate() invalidate()

View File

@@ -9,6 +9,17 @@
android:paddingRight="15dp" android:paddingRight="15dp"
tools:ignore="HardcodedText"> tools:ignore="HardcodedText">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="17.5dp"
android:lineSpacingExtra="6dp"
android:text="此功能仅用于调试单条规则或多条规则,同步最新在线规则后这里的内容将会被覆盖清空。"
android:textColor="@color/colorTextDark"
android:textSize="13sp" />
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">

View File

@@ -5,8 +5,8 @@ plugins {
} }
ext { ext {
appVersionName = "2.3" appVersionName = "2.35"
appVersionCode = 28 appVersionCode = 29
} }
task clean(type: Delete) { task clean(type: Delete) {