mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-06 10:45:20 +08:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
25399cd88b | |||
18691d8b8d | |||
7c61b09054 | |||
7a7e179a2b | |||
dbd7dbf172 | |||
502e5dc04b | |||
ff0c57319a | |||
647a39c327 | |||
04e8d43356 | |||
f85d2db36e | |||
2e5284ebe9 | |||
abffc4d853 | |||
5d81b8ff87 | |||
d91d2736e6 | |||
72169989f2 | |||
c85da002f5 | |||
c09a1b5760 | |||
c30e56c5aa |
72
README.md
72
README.md
@@ -2,52 +2,61 @@
|
||||
|
||||
[](https://github.com/fankes/MIUINativeNotifyIcon)
|
||||
[](https://github.com/fankes/MIUINativeNotifyIcon/blob/master/LICENSE)
|
||||
[](https://github.com/fankes/MIUINativeNotifyIcon/releases)
|
||||
[](https://github.com/fankes/MIUINativeNotifyIcon/releases)
|
||||
[](https://github.com/fankes/MIUINativeNotifyIcon/releases)
|
||||
[](https://github.com/Xposed-Modules-Repo/com.fankes.miui.notify/releases)
|
||||
[](https://t.me/XiaofangInternet)
|
||||
[](https://t.me/XiaofangInternet)
|
||||
<br/><br/>
|
||||
<img src="https://github.com/fankes/MIUINativeNotifyIcon/blob/master/app/src/main/ic_launcher-playstore.png" width = "100" height = "100"/>
|
||||
<br/>
|
||||
Fix the native notification bar icon function abandoned by the MIUI development team.<br/>
|
||||
修复被 MIUI 开发组丢弃的原生通知图标,支持 MIUI 12、12.5、13 以及最新版本。
|
||||
|
||||
# Developer
|
||||
## Developer
|
||||
|
||||
[酷安 @星夜不荟](http://www.coolapk.com/u/876977)
|
||||
|
||||
# 适配说明
|
||||
## 适配说明
|
||||
|
||||
- 此模块仅支持 <b>LSPosed</b>(作用域“系统界面”)、<b>~~EdXposed(随时停止支持)~~</b>、不支持<b>太极、无极</b>
|
||||
|
||||
- 请确保你使用的是 MIUI 官方版本,任何第三方官改包发生的问题,开发者没有义务去解决和修复,请自求多福
|
||||
|
||||
- 目前最低支持基于 Android 9 版本的 MIUI 12 或 MIUI 12.5(最低建议)
|
||||
|
||||
- 建议最低从 MIUI 12.5 `2021-5-18` 开发版以后开始使用模块,之前的版本可能或多或少存在 MIUI 自身 BUG 不生效、黑白块的问题
|
||||
|
||||
- 请始终保持最新版本的 LSPosed,旧版本可能会出现 Hook 不生效的问题,若最新版本依然不生效请在作用域中长按“系统界面”(“系统 UI”)选择重新优化
|
||||
|
||||
# 请勿用于非法用途
|
||||
## 请勿用于非法用途
|
||||
|
||||
- 本模块完全开源免费,如果好用你可以打赏支持开发,但是请不要用于非法用途。
|
||||
|
||||
- 本模块发布地址仅有 [Xposed-Modules-Repo](https://github.com/Xposed-Modules-Repo/com.fankes.miui.notify/releases)、
|
||||
[Release](https://github.com/fankes/MIUINativeNotifyIcon/releases)
|
||||
及 [蓝奏云](https://fankes.lanzouy.com/b030o2e8h),从其他非正规渠道下载到的版本或对您造成任何影响均与我们无关。
|
||||
|
||||
# 贡献通知图标优化名单
|
||||
## 贡献通知图标优化名单
|
||||
|
||||
此项目是 `AndroidNotifyIconAdapt` 项目的一部分,详情请参考下方。<br/>
|
||||
此项目是 `AndroidNotifyIconAdapt` 项目的一部分,详情请参考下方。
|
||||
|
||||
- [Android 通知图标规范适配计划](https://github.com/fankes/AndroidNotifyIconAdapt)
|
||||
|
||||
# 历史背景
|
||||
## 历史背景
|
||||
|
||||
这个模块诞生来源于 MIUI 的乱改和不规范,本来 MIUI 9 之后,官方给出了原生通知图标样式,后面由于用户反应通知栏经常出现黑白块。
|
||||
|
||||
这当然不是系统的错,而是国内 APP 和 `MIPUSH` 的通知极其不规范的通知图标设计。
|
||||
|
||||
但是呢,接到反馈后 MIUI 开发组选择直接忽略这个问题,在 `2021-5-18` 的开发版开始,把全部通知图标都改成了 APP 的彩色图标,使得之前拥有自有样式的原生图标也被破坏。
|
||||
|
||||
对于 Android 开发者来说,官方文档中的 `setSmallIcon` 不再适用于魔改后的 MIUI,这将会严重破坏非常多的状态图标。
|
||||
|
||||
当然,国内的手机生态除了 `MIPUSH` 的营销通知就是社交软件的通知,可能大部分人都不会在意这件事情。
|
||||
|
||||
这个模块诞生来源于 MIUI 的乱改和不规范,本来 MIUI 9 之后,官方给出了原生通知图标样式,后面由于用户反应通知栏经常出现黑白块。<br/><br/>
|
||||
这当然不是系统的错,而是国内 APP 和 `MIPUSH` 的通知极其不规范的通知图标设计。<br/><br/>
|
||||
但是呢,接到反馈后 MIUI 开发组选择直接忽略这个问题,在 `2021-5-18` 的开发版开始,把全部通知图标都改成了 APP 的彩色图标,使得之前拥有自有样式的原生图标也被破坏。<br/><br/>
|
||||
对于 Android 开发者来说,官方文档中的 `setSmallIcon` 不再适用于魔改后的 MIUI,这将会严重破坏非常多的状态图标。<br/><br/>
|
||||
当然,国内的手机生态除了 `MIPUSH` 的营销通知就是社交软件的通知,可能大部分人都不会在意这件事情。<br/><br/>
|
||||
但是,这个模块就是为了修复被 MIUI 开发组忽略的图标问题才诞生的,并完美地给 MIUI 修复了黑白块图标的问题。
|
||||
<br/>
|
||||
|
||||
# 探索历程
|
||||
## 探索历程
|
||||
|
||||
原生 Android 的小图标和通知图标具有状态性。<br/><br/>
|
||||
<img src="https://github.com/fankes/MIUINativeNotifyIcon/blob/master/images/native.jpg" height = "35"/><br/><br/>
|
||||
@@ -59,9 +68,11 @@ Fix the native notification bar icon function abandoned by the MIUI development
|
||||
而 MIUI 做了什么呢?<br/><br/>
|
||||
<img src="https://github.com/fankes/MIUINativeNotifyIcon/blob/master/images/miui_n_1.jpg" height = "100"/><br/>
|
||||
<img src="https://github.com/fankes/MIUINativeNotifyIcon/blob/master/images/miui_n_2.jpg" height = "100"/><br/><br/>
|
||||
不曾记得是什么版本开始,MIUI 把通知图标改成了这个鬼样子,寻找开发组提案也是无人问津,最后转念一想,自己干吧。<br/><br/>
|
||||
不曾记得是什么版本开始,MIUI 把通知图标改成了这个鬼样子,寻找开发组提案也是无人问津,最后转念一想,自己干吧。
|
||||
|
||||
由于目前大量通知图标都来自 `MIPUSH` 发出的营销通知,而 `MIPUSH` 的图标都是统一的彩色应用图标,很多应用也没有适配这一特性, 在通知栏广告满天飞的情况下,MIUI
|
||||
选择放弃原生通知功能,而做出这种违反原生通知规则的做法,而这些彩色图标被设置为单色调图标,也确实会发生黑白块的问题,但是同时又会破坏遵守规范的图标。<br/><br/>
|
||||
选择放弃原生通知功能,而做出这种违反原生通知规则的做法,而这些彩色图标被设置为单色调图标,也确实会发生黑白块的问题,但是同时又会破坏遵守规范的图标。
|
||||
|
||||
真的没有办法了吗?在不断探索下,我找到了原生支持色彩判断的类。
|
||||
|
||||
```kotlin
|
||||
@@ -74,18 +85,28 @@ com.android.internal.util.ContrastColorUtil
|
||||
ContrastColorUtil.getInstance().isGrayscaleIcon(drawable)
|
||||
```
|
||||
|
||||
问题就被解决了,顺便修了一下被 MIUI 破坏的通知图标以及优化了一下应用本身方块图标的圆角......<br/><br/>
|
||||
最后,我想大声问一句 MIUI 开发组:“就这?” 就这么简单的问题为什么拖了这么长时间也没有结论,还要交给用户去修复,这真的是一种负责任的表现吗?<br/><br/>
|
||||
后来一想,也是啊,被国内生态毒害的用户,怎么可能会去想到这些问题呢,最后只能是我自作多情,还对 MIUI 留有一点情怀吧。<br/><br/>
|
||||
问题就被解决了,顺便修了一下被 MIUI 破坏的通知图标以及优化了一下应用本身方块图标的圆角......
|
||||
|
||||
最后,我想大声问一句 MIUI 开发组:“就这?” 就这么简单的问题为什么拖了这么长时间也没有结论,还要交给用户去修复,这真的是一种负责任的表现吗?
|
||||
|
||||
后来一想,也是啊,被国内生态毒害的用户,怎么可能会去想到这些问题呢,最后只能是我自作多情,还对 MIUI 留有一点情怀吧。
|
||||
|
||||
——来自一个无可奈何的 MIUI 老用户
|
||||
|
||||
# 后记
|
||||
## 后记
|
||||
|
||||
近期重新适配了 MIUI 12、12.5、13 版本,每个版本的图标设置方法都不一样,而且改的乱七八糟的,我都要无语了,只能用了很多折中方案,毕竟我也没有那么大精力每个版本去修复,实在是累了。
|
||||
|
||||
特地的把自己能有的小米手机刷成各种 MIUI 版本去为酷友做专项适配,我也是很累了,也希望你们能够多多支持,也能让 MIUI 做得更好。
|
||||
|
||||
近期重新适配了 MIUI 12、12.5、13 版本,每个版本的图标设置方法都不一样,而且改的乱七八糟的,我都要无语了,只能用了很多折中方案,毕竟我也没有那么大精力每个版本去修复,实在是累了。<br/><br/>
|
||||
特地的把自己能有的小米手机刷成各种 MIUI 版本去为酷友做专项适配,我也是很累了,也希望你们能够多多支持,也能让 MIUI 做得更好。<br/><br/>
|
||||
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)
|
||||
|
||||
@@ -106,5 +127,6 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
```
|
||||
|
||||
Powered by [YukiHookAPI](https://github.com/fankes/YukiHookAPI)<br/><br/>
|
||||
Powered by [YukiHookAPI](https://github.com/fankes/YukiHookAPI)
|
||||
|
||||
版权所有 © 2019-2022 Fankes Studio(qzmmcn@163.com)
|
@@ -38,7 +38,7 @@ android {
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled true
|
||||
minifyEnabled rootProject.ext.enableR8
|
||||
signingConfig signingConfigs.debug
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
@@ -72,8 +72,8 @@ tasks.whenTaskAdded {
|
||||
|
||||
dependencies {
|
||||
compileOnly 'de.robv.android.xposed:api:82'
|
||||
implementation 'com.highcapable.yukihookapi:api:1.0.68'
|
||||
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.68'
|
||||
implementation 'com.highcapable.yukihookapi:api:1.0.75'
|
||||
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.75'
|
||||
implementation "com.github.topjohnwu.libsu:core:3.1.2"
|
||||
implementation 'androidx.annotation:annotation:1.3.0'
|
||||
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'
|
||||
|
@@ -41,7 +41,7 @@ object Const {
|
||||
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}_202204140309"
|
||||
|
||||
/** 当前模块的版本校验标签 */
|
||||
const val MODULE_VERSION_VERIFY_TAG = "module_version_verify"
|
||||
|
@@ -41,6 +41,7 @@ import android.view.ViewGroup
|
||||
import android.view.ViewOutlineProvider
|
||||
import android.widget.ImageView
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import androidx.core.view.children
|
||||
import com.fankes.miui.notify.bean.IconDataBean
|
||||
import com.fankes.miui.notify.const.Const
|
||||
import com.fankes.miui.notify.data.DataConst
|
||||
@@ -54,10 +55,7 @@ import com.fankes.miui.notify.utils.tool.BitmapCompatTool
|
||||
import com.fankes.miui.notify.utils.tool.IconAdaptationTool
|
||||
import com.highcapable.yukihookapi.hook.bean.VariousClass
|
||||
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
|
||||
import com.highcapable.yukihookapi.hook.factory.field
|
||||
import com.highcapable.yukihookapi.hook.factory.hasField
|
||||
import com.highcapable.yukihookapi.hook.factory.hasMethod
|
||||
import com.highcapable.yukihookapi.hook.factory.method
|
||||
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.*
|
||||
@@ -108,6 +106,12 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.policy.MiuiClock"
|
||||
)
|
||||
|
||||
/** 根据多个版本存在不同的包名相同的类 */
|
||||
private val StatusBarNotificationPresenterClass = VariousClass(
|
||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.phone.StatusBarNotificationPresenter",
|
||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.phone.StatusBar"
|
||||
)
|
||||
|
||||
/** 根据多个版本存在不同的包名相同的类 */
|
||||
private val ExpandableNotificationRowClass = VariousClass(
|
||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.ExpandableNotificationRow",
|
||||
@@ -148,17 +152,11 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
/** 是否已经使用过缓存刷新功能 */
|
||||
private var isUsingCachingMethod = false
|
||||
|
||||
/** 缓存的状态栏小图标实例 */
|
||||
private var statusBarIconViews = HashSet<ImageView>()
|
||||
/** 状态栏通知图标容器 */
|
||||
private var notificationIconContainer: ViewGroup? = null
|
||||
|
||||
/** 缓存的通知小图标包装纸实例 */
|
||||
private var notificationViewWrappers = HashSet<Any>()
|
||||
|
||||
/** MIUI 样式下的缓存的通知小图标包装纸实例 */
|
||||
private var miuiNotificationViewWrappers = HashSet<Any>()
|
||||
|
||||
/** MIUI 样式下的缓存的通知小图标折叠通知实例 */
|
||||
private var miuiNotificationChildrenContainers = HashSet<ViewGroup>()
|
||||
/** 通知栏通知控制器 */
|
||||
private var notificationPresenter: Any? = null
|
||||
|
||||
/** 仅监听一次主题壁纸颜色变化 */
|
||||
private var isWallpaperColorListenerSetUp = false
|
||||
@@ -268,19 +266,10 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
get() = safeOfFalse {
|
||||
NotificationUtilClass.clazz.hasMethod {
|
||||
name = "ignoreStatusBarIconColor"
|
||||
param(ExpandedNotificationClass.clazz)
|
||||
param(ExpandedNotificationClass)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前通知栏的样式
|
||||
*
|
||||
* - ❗新版本可能不存在这个方法
|
||||
* @return [Boolean]
|
||||
*/
|
||||
private val isShowMiuiStyle
|
||||
get() = safeOfFalse { NotificationUtilClass.clazz.method { name = "showMiuiStyle" }.get().invoke() ?: false }
|
||||
|
||||
/**
|
||||
* 处理为圆角图标
|
||||
* @return [Drawable]
|
||||
@@ -366,7 +355,7 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
*/
|
||||
private val globalContext
|
||||
get() = safeOfNull {
|
||||
SystemUIApplicationClass.clazz.method { name = "getContext" }.ignoredError().get().invoke<Context>()
|
||||
SystemUIApplicationClass.clazz.method { name = "getContext" }.ignoredError().get().invoke<Context?>() ?: appContext
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -385,12 +374,12 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
/** 刷新状态栏小图标 */
|
||||
private fun refreshStatusBarIcons() = runInSafe {
|
||||
StatusBarIconViewClass.clazz.field { name = "mNotification" }.also { result ->
|
||||
statusBarIconViews.takeIf { it.isNotEmpty() }?.forEach {
|
||||
notificationIconContainer?.children?.forEach {
|
||||
/** 得到通知实例 */
|
||||
val nf = result.get(it).cast<StatusBarNotification>() ?: return
|
||||
/** 刷新状态栏图标 */
|
||||
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) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -398,19 +387,11 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
|
||||
/** 刷新通知小图标 */
|
||||
private fun 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() }
|
||||
}
|
||||
MiuiNotificationViewWrapperClass.clazz.method { name = "handleViews" }.ignoredError().also { result ->
|
||||
miuiNotificationViewWrappers.takeIf { it.isNotEmpty() }?.forEach { result.get(it).call() }
|
||||
}
|
||||
MiuiNotificationChildrenContainerClass.clazz.method {
|
||||
name = "updateAppIcon"
|
||||
param(BooleanType)
|
||||
}.ignoredError().also { result ->
|
||||
miuiNotificationChildrenContainers.takeIf { it.isNotEmpty() }?.forEach { result.get(it).call(true) }
|
||||
notificationPresenter?.current {
|
||||
method {
|
||||
name = "updateNotificationsOnDensityOrFontScaleChanged"
|
||||
emptyParam()
|
||||
}.call()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -685,38 +666,34 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
injectMember {
|
||||
method {
|
||||
name = "shouldSubstituteSmallIcon"
|
||||
param(ExpandedNotificationClass.clazz)
|
||||
param(ExpandedNotificationClass)
|
||||
}
|
||||
/**
|
||||
* MIUI 12 在非原生样式下 MIPUSH 的图标着色异常
|
||||
* 所以判断是 MIUI 样式就停止 Hook 状态栏图标
|
||||
*/
|
||||
replaceAny { hasIgnoreStatusBarIconColor.not() && isShowMiuiStyle }
|
||||
replaceToFalse()
|
||||
}
|
||||
/** 强制回写系统的状态栏图标样式为原生 */
|
||||
injectMember {
|
||||
var isUseLegacy = false
|
||||
method {
|
||||
name = "getSmallIcon"
|
||||
param(ExpandedNotificationClass.clazz, IntType)
|
||||
param(ExpandedNotificationClass, IntType)
|
||||
}.remedys {
|
||||
method {
|
||||
name = "getSmallIcon"
|
||||
param(ExpandedNotificationClass.clazz)
|
||||
param(ExpandedNotificationClass)
|
||||
}
|
||||
method {
|
||||
name = "getSmallIcon"
|
||||
param(ContextClass, ExpandedNotificationClass.clazz)
|
||||
param(ContextClass, ExpandedNotificationClass)
|
||||
}.onFind { isUseLegacy = true }
|
||||
}
|
||||
afterHook {
|
||||
(globalContext ?: firstArgs())?.also { context ->
|
||||
(globalContext ?: args().first().cast())?.also { context ->
|
||||
val expandedNf = args(if (isUseLegacy) 1 else 0).cast<StatusBarNotification?>()
|
||||
/** Hook 状态栏小图标 */
|
||||
compatStatusIcon(
|
||||
context = context,
|
||||
expandedNf,
|
||||
(result as Icon).loadDrawable(context)
|
||||
result<Icon>()?.loadDrawable(context)
|
||||
).also { pair -> if (pair.second) result = Icon.createWithBitmap(pair.first?.toBitmap()) }
|
||||
}
|
||||
}
|
||||
@@ -749,7 +726,7 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
}
|
||||
}
|
||||
}
|
||||
/** 记录实例 */
|
||||
/** 注册广播 */
|
||||
injectMember {
|
||||
method {
|
||||
name = "setNotification"
|
||||
@@ -757,26 +734,33 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
}.remedys {
|
||||
method {
|
||||
name = "setNotification"
|
||||
param(ExpandedNotificationClass.clazz)
|
||||
param(ExpandedNotificationClass)
|
||||
}
|
||||
}
|
||||
afterHook {
|
||||
if (firstArgs != null) instance<ImageView>().also {
|
||||
if (args[0] != null) instance<ImageView>().also {
|
||||
/** 注册壁纸颜色监听 */
|
||||
registerWallpaperColorChanged(it)
|
||||
/** 注册广播 */
|
||||
registerReceiver(it.context)
|
||||
/** 缓存实例 */
|
||||
statusBarIconViews.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/** 注入通知控制器实例 */
|
||||
StatusBarNotificationPresenterClass.hook {
|
||||
injectMember {
|
||||
allConstructors()
|
||||
afterHook { notificationPresenter = instance }
|
||||
}
|
||||
}
|
||||
/** 注入状态栏通知图标容器实例 */
|
||||
NotificationIconContainerClass.hook {
|
||||
injectMember {
|
||||
method { name = "calculateIconTranslations" }
|
||||
afterHook {
|
||||
/** 缓存实例 */
|
||||
notificationIconContainer = instance<ViewGroup>()
|
||||
/** 修复部分开发版状态栏图标只能显示一个的问题 */
|
||||
when (miuiIncrementalVersion.lowercase()) {
|
||||
"22.3.14", "22.3.15", "22.3.16", "v13.0.1.1.16.dev", "22.3.18" ->
|
||||
@@ -793,14 +777,14 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
.get(instance).set(prefs.get(DataConst.HOOK_STATUS_ICON_COUNT)
|
||||
.let { if (it in 0..100) it else 5 })
|
||||
}
|
||||
}
|
||||
}.by { NotificationIconContainerClass.clazz.hasField { name = "MAX_STATIC_ICONS" } }
|
||||
/** 旧版方法 - 新版不存在 */
|
||||
injectMember {
|
||||
method {
|
||||
name = "setMaxStaticIcons"
|
||||
param(IntType)
|
||||
}
|
||||
beforeHook { isShowNotificationIcons = (firstArgs<Int>() ?: 0) > 0 }
|
||||
beforeHook { isShowNotificationIcons = args().first().int() > 0 }
|
||||
}.ignoredNoSuchMemberFailure()
|
||||
/** 新版方法 - 旧版不存在 */
|
||||
injectMember {
|
||||
@@ -808,9 +792,9 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
name = "miuiShowNotificationIcons"
|
||||
param(BooleanType)
|
||||
}
|
||||
beforeHook { isShowNotificationIcons = firstArgs<Boolean>() ?: false }
|
||||
beforeHook { isShowNotificationIcons = args().first().boolean() }
|
||||
}.ignoredNoSuchMemberFailure()
|
||||
}.by { NotificationIconContainerClass.clazz.hasField { name = "MAX_STATIC_ICONS" } }
|
||||
}
|
||||
/** 注入原生通知包装纸实例 */
|
||||
NotificationHeaderViewWrapperClass.hook {
|
||||
/** 修复下拉通知图标自动设置回 APP 图标的方法 */
|
||||
@@ -843,11 +827,6 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
compatNotifyIcon(iconImageView.context, expandedNf, iconImageView, isExpanded)
|
||||
}
|
||||
}
|
||||
/** 记录实例 */
|
||||
injectMember {
|
||||
constructor { param(ContextClass, ViewClass, ExpandableNotificationRowClass.clazz) }
|
||||
afterHook { notificationViewWrappers.add(instance) }
|
||||
}
|
||||
}
|
||||
/** 修改 MIUI 风格通知栏的通知图标 */
|
||||
MiuiNotificationViewWrapperClass.hook {
|
||||
@@ -865,11 +844,6 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
}
|
||||
}
|
||||
}
|
||||
/** 记录实例 */
|
||||
injectMember {
|
||||
constructor { param(ContextClass, ViewClass, ExpandableNotificationRowClass.clazz) }
|
||||
afterHook { miuiNotificationViewWrappers.add(instance) }
|
||||
}
|
||||
}.ignoredHookClassNotFoundFailure()
|
||||
/** 修改 MIUI 风格通知栏的通知图标 - 折叠通知 */
|
||||
MiuiNotificationChildrenContainerClass.hook {
|
||||
@@ -888,22 +862,17 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
}
|
||||
}
|
||||
}
|
||||
/** 记录实例 */
|
||||
injectMember {
|
||||
constructor { param(ContextClass, AttributeSetClass) }
|
||||
afterHook { miuiNotificationChildrenContainers.add(instance()) }
|
||||
}
|
||||
}.ignoredHookClassNotFoundFailure()
|
||||
/** 干掉下拉通知图标自动设置回 APP 图标的方法 */
|
||||
NotificationHeaderViewWrapperInjectorClass.hook {
|
||||
injectMember {
|
||||
method {
|
||||
name = "setAppIcon"
|
||||
param(ContextClass, ImageViewClass, ExpandedNotificationClass.clazz)
|
||||
param(ContextClass, ImageViewClass, ExpandedNotificationClass)
|
||||
}.remedys {
|
||||
method {
|
||||
name = "setAppIcon"
|
||||
param(ImageViewClass, ExpandedNotificationClass.clazz)
|
||||
param(ImageViewClass, ExpandedNotificationClass)
|
||||
}
|
||||
}
|
||||
intercept()
|
||||
@@ -911,7 +880,7 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
injectMember {
|
||||
method {
|
||||
name = "resetIconBgAndPaddings"
|
||||
param(ImageViewClass, ExpandedNotificationClass.clazz)
|
||||
param(ImageViewClass, ExpandedNotificationClass)
|
||||
}
|
||||
intercept()
|
||||
}.ignoredNoSuchMemberFailure()
|
||||
@@ -924,7 +893,7 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
param(ContextClass, IntentClass)
|
||||
}
|
||||
afterHook {
|
||||
if (isEnableHookColorNotifyIcon()) (lastArgs as? Intent)?.also {
|
||||
if (isEnableHookColorNotifyIcon()) args().last().cast<Intent>()?.also {
|
||||
if (it.action.equals(Intent.ACTION_PACKAGE_REPLACED).not() &&
|
||||
it.getBooleanExtra(Intent.EXTRA_REPLACING, false)
|
||||
) return@also
|
||||
@@ -934,11 +903,11 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
if (iconDatas.takeIf { e -> e.isNotEmpty() }
|
||||
?.filter { e -> e.packageName == newPkgName }
|
||||
.isNullOrEmpty()
|
||||
) IconAdaptationTool.pushNewAppSupportNotify(firstArgs()!!, newPkgName)
|
||||
) IconAdaptationTool.pushNewAppSupportNotify(args().first().cast()!!, newPkgName)
|
||||
}
|
||||
Intent.ACTION_PACKAGE_REMOVED ->
|
||||
IconAdaptationTool.removeNewAppSupportNotify(
|
||||
context = firstArgs()!!,
|
||||
context = args().first().cast()!!,
|
||||
packageName = it.data?.schemeSpecificPart ?: ""
|
||||
)
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.viewbinding.ViewBinding
|
||||
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.type.android.LayoutInflaterClass
|
||||
|
||||
@@ -71,7 +71,7 @@ class DialogBuilder(val context: Context, private val isUseBlackTheme: Boolean)
|
||||
|
||||
private var dialogInstance: Dialog? = null // 对话框实例
|
||||
|
||||
@DoNotUseField
|
||||
@CauseProblemsApi
|
||||
var customLayoutView: View? = null // 自定义布局
|
||||
|
||||
/**
|
||||
|
@@ -32,6 +32,7 @@ import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Configuration
|
||||
@@ -57,6 +58,7 @@ import java.io.ByteArrayOutputStream
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
|
||||
/**
|
||||
* 系统深色模式是否开启
|
||||
* @return [Boolean] 是否开启
|
||||
@@ -237,6 +239,14 @@ fun Context.findAppName(name: String) =
|
||||
fun Context.findAppIcon(name: String) =
|
||||
safeOfNull { packageManager?.getPackageInfo(name, 0)?.applicationInfo?.loadIcon(packageManager) }
|
||||
|
||||
/**
|
||||
* 获取 APP 是否为 DEBUG 版本
|
||||
* @param name APP 包名
|
||||
* @return [Boolean]
|
||||
*/
|
||||
fun Context.isAppDebuggable(name: String) =
|
||||
safeOfFalse { (packageManager?.getPackageInfo(name, 0)?.applicationInfo?.flags?.and(ApplicationInfo.FLAG_DEBUGGABLE) ?: 0) != 0 }
|
||||
|
||||
/**
|
||||
* 对数值自动补零
|
||||
* @return [String]
|
||||
@@ -402,12 +412,19 @@ fun findPropString(key: String, default: String = "") = safeOf(default) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行命令 - su
|
||||
* 是否有 Root 权限
|
||||
* @return [Boolean]
|
||||
*/
|
||||
val isRootAccess get() = safeOfFalse { Shell.rootAccess() }
|
||||
|
||||
/**
|
||||
* 执行命令
|
||||
* @param cmd 命令
|
||||
* @param isSu 是否使用 Root 权限执行 - 默认:是
|
||||
* @return [String] 执行结果
|
||||
*/
|
||||
fun execShellSu(cmd: String) = safeOfNothing {
|
||||
Shell.su(cmd).exec().out.let {
|
||||
fun execShell(cmd: String, isSu: Boolean = true) = safeOfNothing {
|
||||
(if (isSu) Shell.su(cmd) else Shell.sh(cmd)).exec().out.let {
|
||||
if (it.isNotEmpty()) it[0].trim() else ""
|
||||
}
|
||||
}
|
||||
|
@@ -116,6 +116,7 @@ object IconAdaptationTool {
|
||||
* @param packageName 安装的 APP 包名
|
||||
*/
|
||||
fun pushNewAppSupportNotify(context: Context, packageName: String) {
|
||||
if (context.isAppDebuggable(packageName)) return
|
||||
context.getSystemService(NotificationManager::class.java)?.apply {
|
||||
createNotificationChannel(
|
||||
NotificationChannel(
|
||||
|
@@ -121,7 +121,7 @@ object IconRuleManagerTool {
|
||||
cancelButton()
|
||||
neutralButton(text = "自定义规则") {
|
||||
context.showDialog {
|
||||
title = "自定义规则"
|
||||
title = "自定义规则(调试)"
|
||||
val editText = bind<DiaSourceFromStringBinding>().diaSfsInputEdit.apply {
|
||||
requestFocus()
|
||||
invalidate()
|
||||
|
@@ -87,9 +87,9 @@ object SystemUITool {
|
||||
"部分 MIUI 内测和开发版中使用了状态栏主题可能会发生主题失效的情况,这种情况请再重启一次即可。\n\n" +
|
||||
"重启过程会黑屏并等待进入锁屏重新解锁。"
|
||||
confirmButton {
|
||||
execShellSu(cmd = "pgrep systemui").also { pid ->
|
||||
execShell(cmd = "pgrep systemui").also { pid ->
|
||||
if (pid.isNotBlank())
|
||||
execShellSu(cmd = "kill -9 $pid")
|
||||
execShell(cmd = "kill -9 $pid")
|
||||
else toast(msg = "ROOT 权限获取失败")
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,17 @@
|
||||
android:paddingRight="15dp"
|
||||
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
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
@@ -1,12 +1,13 @@
|
||||
plugins {
|
||||
id 'com.android.application' version '7.1.2' apply false
|
||||
id 'com.android.library' version '7.1.2' apply false
|
||||
id 'com.android.application' version '7.1.3' apply false
|
||||
id 'com.android.library' version '7.1.3' apply false
|
||||
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
|
||||
}
|
||||
|
||||
ext {
|
||||
appVersionName = "2.3"
|
||||
appVersionCode = 28
|
||||
appVersionName = "2.5"
|
||||
appVersionCode = 30
|
||||
enableR8 = true
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
|
Reference in New Issue
Block a user