11 Commits
2.15 ... 2.16

8 changed files with 86 additions and 62 deletions

2
.idea/gradle.xml generated
View File

@@ -7,7 +7,7 @@
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="Embedded JDK" />
<option name="gradleJvm" value="11" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />

1
.idea/misc.xml generated
View File

@@ -6,6 +6,7 @@
<entry key="app/src/main/res/drawable-night/dark_round.xml" value="0.256" />
<entry key="app/src/main/res/drawable-night/permotion_round.xml" value="0.256" />
<entry key="app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.44871794871794873" />
<entry key="app/src/main/res/drawable/bg_dark_round.xml" value="0.2325" />
<entry key="app/src/main/res/drawable/bg_green_round.xml" value="0.255" />
<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" />

View File

@@ -2,7 +2,8 @@
![Eclipse Marketplace](https://img.shields.io/badge/build-passing-brightgreen)
![Eclipse Marketplace](https://img.shields.io/badge/license-AGPL3.0-blue)
![Eclipse Marketplace](https://img.shields.io/badge/version-v2.15-green)
![Eclipse Marketplace](https://img.shields.io/badge/version-v2.16-green)
[![Telegram](https://img.shields.io/static/v1?label=Telegram&message=交流讨论&color=0088cc)](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/>
@@ -12,7 +13,7 @@ Fix the native notification bar icon function abandoned by the MIUI development
# 开始使用
点击下载最新版本
<a href='https://github.com/fankes/MIUINativeNotifyIcon/releases'>![Eclipse Marketplace](https://img.shields.io/badge/download-v2.15-green)</a>
<a href='https://github.com/fankes/MIUINativeNotifyIcon/releases'>![Eclipse Marketplace](https://img.shields.io/badge/download-v2.16-green)</a>
<br/><br/>
⚠️ 适配说明<br/>

View File

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

View File

@@ -122,10 +122,6 @@ class HookEntry : YukiHookXposedInitProxy {
/** 是否显示通知图标 - 跟随 Hook 保存 */
private var isShowNotificationIcons = true
/** 是否有最大图标设置功能 */
private val PackageParam.hasMaxStaticIcons
get() = safeOfFalse { NotificationIconContainerClass.clazz.hasField(name = "MAX_STATIC_ICONS") }
/**
* - 这个是修复彩色图标的关键核心代码判断
*
@@ -469,19 +465,12 @@ class HookEntry : YukiHookXposedInitProxy {
} else false.also { printLogcat(tag = "IconColor", context, expandedNf, isCustom = false, isGrayscale = true) }
else true.also { printLogcat(tag = "IconColor", context, expandedNf, isCustom = false, isGrayscale = false) }
override fun onHook() {
runConfig()
runHook()
}
/** 配置 Hook */
private fun runConfig() = configs {
override fun onInit() = configs {
debugTag = "MIUINativeNotifyIcon"
isDebug = false
}
/** 开始 Hook */
private fun runHook() = encase {
override fun onHook() = encase {
loadApp(SYSTEMUI_PACKAGE_NAME) {
when {
/** 不是 MIUI 系统停止 Hook */
@@ -544,16 +533,24 @@ class HookEntry : YukiHookXposedInitProxy {
afterHook {
instance<ImageView>().also {
if (hasIgnoreStatusBarIconColor(it.context, field { name = "mNotification" }
.of<StatusBarNotification>(instance))) it.colorFilter = null
/** 防止图标不是纯黑的问题 */
else it.setColorFilter(
field { name = "mCurrentSetColor" }.of<Int>(instance)
?.let { color -> if (color == -419430401) color else Color.BLACK } ?: 0)
.of<StatusBarNotification>(instance))) it.apply {
alpha = 1f
colorFilter = null
}
/**
* 防止图标不是纯黑的问题
* 图标在任何场景下跟随状态栏其它图标保持半透明
*/
else it.apply {
field { name = "mCurrentSetColor" }.of<Int>(instance)?.also { color ->
alpha = if (color.isWhite) 0.95f else 0.8f
setColorFilter(if (color.isWhite) color else Color.BLACK)
}
}
}
}
}
}
if (hasMaxStaticIcons)
NotificationIconContainerClass.hook {
injectMember {
method { name = "calculateIconTranslations" }
@@ -579,7 +576,7 @@ class HookEntry : YukiHookXposedInitProxy {
param(IntType)
beforeHook { isShowNotificationIcons = firstArgs as Int > 0 }
}
}.ignoredHookingFailure()
}.ignoredNoSuchMemberFailure()
/** 新版方法 - 旧版不存在 */
injectMember {
method {
@@ -587,8 +584,8 @@ class HookEntry : YukiHookXposedInitProxy {
param(BooleanType)
}
beforeHook { isShowNotificationIcons = firstArgs as Boolean }
}.ignoredHookingFailure()
}
}.ignoredNoSuchMemberFailure()
}.by { safeOfFalse { NotificationIconContainerClass.clazz.hasField(name = "MAX_STATIC_ICONS") } }
NotificationHeaderViewWrapperClass.hook {
/** 修复下拉通知图标自动设置回 APP 图标的方法 */
injectMember {
@@ -650,14 +647,14 @@ class HookEntry : YukiHookXposedInitProxy {
}
}
intercept()
}.ignoredHookingFailure()
}.ignoredNoSuchMemberFailure()
injectMember {
method {
name = "resetIconBgAndPaddings"
param(ImageViewClass, ExpandedNotificationClass.clazz)
}
intercept()
}.ignoredHookingFailure()
}.ignoredNoSuchMemberFailure()
}.ignoredHookClassNotFoundFailure()
}
}

View File

@@ -45,6 +45,7 @@ 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_NOTIFY_ICON_FIX
import com.fankes.miui.notify.hook.HookConst.HOOK_STATUS_ICON_COUNT
import com.fankes.miui.notify.params.IconPackParams
import com.fankes.miui.notify.ui.base.BaseActivity
import com.fankes.miui.notify.utils.factory.*
import com.fankes.miui.notify.utils.tool.SystemUITool
@@ -97,7 +98,18 @@ class MainActivity : BaseActivity() {
noCancelable()
}
/** 判断是否 Hook */
YukiHookModuleStatus.isActive() -> {}
YukiHookModuleStatus.isActive() -> {
if (IconPackParams(context = this).iconDatas.isEmpty()
&& modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)
) showDialog {
title = "配置通知图标优化名单"
msg = "模块需要获取在线规则以更新“通知图标优化名单”,它现在是空的,这看起来是你第一次使用模块,请首先进行配置才可以使用相关功能。\n" +
"你可以随时在本页面下方找到“配置通知图标优化名单”手动前往。"
confirmButton(text = "前往") { startActivity(Intent(this@MainActivity, ConfigureActivity::class.java)) }
cancelButton()
noCancelable()
}
}
else ->
showDialog {
title = "模块没有激活"

View File

@@ -51,6 +51,7 @@ import com.highcapable.yukihookapi.hook.type.java.StringType
import com.topjohnwu.superuser.Shell
import java.io.ByteArrayOutputStream
/**
* 系统深色模式是否开启
* @return [Boolean] 是否开启
@@ -223,6 +224,18 @@ val Context.versionCode get() = packageInfo.versionCode
*/
fun Number.dp(context: Context) = (toFloat() * context.resources.displayMetrics.density)
/**
* 是否为白色
* @return [Boolean]
*/
val Int.isWhite
get() = safeOfTrue {
val r = this and 0xff0000 shr 16
val g = this and 0x00ff00 shr 8
val b = this and 0x0000ff
(0.2126 * r + 0.7152 * g + 0.0722 * b) >= 128
}
/**
* Base64 加密
* @return [String]

View File

@@ -5,8 +5,8 @@ plugins {
}
ext {
appVersionName = "2.15"
appVersionCode = 25
appVersionName = "2.16"
appVersionCode = 26
}
task clean(type: Delete) {