13 Commits
2.1 ... 2.16

9 changed files with 98 additions and 41 deletions

2
.idea/gradle.xml generated
View File

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

View File

@@ -2,7 +2,8 @@
![Eclipse Marketplace](https://img.shields.io/badge/build-passing-brightgreen) ![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/license-AGPL3.0-blue)
![Eclipse Marketplace](https://img.shields.io/badge/version-v2.1-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/> <br/><br/>
<img src="https://github.com/fankes/MIUINativeNotifyIcon/blob/master/app/src/main/ic_launcher-playstore.png" width = "100" height = "100"/> <img src="https://github.com/fankes/MIUINativeNotifyIcon/blob/master/app/src/main/ic_launcher-playstore.png" width = "100" height = "100"/>
<br/> <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.1-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/><br/>
⚠️ 适配说明<br/> ⚠️ 适配说明<br/>

View File

@@ -64,8 +64,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.4' implementation 'com.highcapable.yukihookapi:api:1.0.5-fix'
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.4' ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.5-fix'
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

@@ -465,19 +465,12 @@ class HookEntry : YukiHookXposedInitProxy {
} else false.also { printLogcat(tag = "IconColor", context, expandedNf, isCustom = false, isGrayscale = true) } } 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) }
override fun onHook() { override fun onInit() = configs {
runConfig()
runHook()
}
/** 配置 Hook */
private fun runConfig() = configs {
debugTag = "MIUINativeNotifyIcon" debugTag = "MIUINativeNotifyIcon"
isDebug = false isDebug = false
} }
/** 开始 Hook */ override fun onHook() = encase {
private fun runHook() = encase {
loadApp(SYSTEMUI_PACKAGE_NAME) { loadApp(SYSTEMUI_PACKAGE_NAME) {
when { when {
/** 不是 MIUI 系统停止 Hook */ /** 不是 MIUI 系统停止 Hook */
@@ -540,11 +533,20 @@ class HookEntry : YukiHookXposedInitProxy {
afterHook { afterHook {
instance<ImageView>().also { instance<ImageView>().also {
if (hasIgnoreStatusBarIconColor(it.context, field { name = "mNotification" } if (hasIgnoreStatusBarIconColor(it.context, field { name = "mNotification" }
.of<StatusBarNotification>(instance))) it.colorFilter = null .of<StatusBarNotification>(instance))) it.apply {
/** 防止图标不是纯黑的问题 */ alpha = 1f
else it.setColorFilter( colorFilter = null
field { name = "mCurrentSetColor" }.of<Int>(instance) }
?.let { color -> if (color == -419430401) color else Color.BLACK } ?: 0) /**
* 防止图标不是纯黑的问题
* 图标在任何场景下跟随状态栏其它图标保持半透明
*/
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)
}
}
} }
} }
} }
@@ -567,14 +569,23 @@ class HookEntry : YukiHookXposedInitProxy {
.let { if (it in 0..100) it else 5 }) .let { if (it in 0..100) it else 5 })
} }
} }
/** 旧版方法 - 新版不存在 */
injectMember {
method {
name = "setMaxStaticIcons"
param(IntType)
beforeHook { isShowNotificationIcons = firstArgs as Int > 0 }
}
}.ignoredNoSuchMemberFailure()
/** 新版方法 - 旧版不存在 */
injectMember { injectMember {
method { method {
name = "miuiShowNotificationIcons" name = "miuiShowNotificationIcons"
param(BooleanType) param(BooleanType)
} }
beforeHook { isShowNotificationIcons = firstArgs as Boolean } beforeHook { isShowNotificationIcons = firstArgs as Boolean }
} }.ignoredNoSuchMemberFailure()
} }.by { safeOfFalse { NotificationIconContainerClass.clazz.hasField(name = "MAX_STATIC_ICONS") } }
NotificationHeaderViewWrapperClass.hook { NotificationHeaderViewWrapperClass.hook {
/** 修复下拉通知图标自动设置回 APP 图标的方法 */ /** 修复下拉通知图标自动设置回 APP 图标的方法 */
injectMember { injectMember {
@@ -636,14 +647,14 @@ class HookEntry : YukiHookXposedInitProxy {
} }
} }
intercept() intercept()
}.ignoredHookingFailure() }.ignoredNoSuchMemberFailure()
injectMember { injectMember {
method { method {
name = "resetIconBgAndPaddings" name = "resetIconBgAndPaddings"
param(ImageViewClass, ExpandedNotificationClass.clazz) param(ImageViewClass, ExpandedNotificationClass.clazz)
} }
intercept() intercept()
}.ignoredHookingFailure() }.ignoredNoSuchMemberFailure()
}.ignoredHookClassNotFoundFailure() }.ignoredHookClassNotFoundFailure()
} }
} }

View File

@@ -33,6 +33,7 @@ import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.widget.SwitchCompat import androidx.appcompat.widget.SwitchCompat
import androidx.constraintlayout.utils.widget.ImageFilterView import androidx.constraintlayout.utils.widget.ImageFilterView
import androidx.core.view.isGone
import androidx.core.view.isVisible import androidx.core.view.isVisible
import com.fankes.miui.notify.BuildConfig import com.fankes.miui.notify.BuildConfig
import com.fankes.miui.notify.R import com.fankes.miui.notify.R
@@ -44,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_MODULE_LOG
import com.fankes.miui.notify.hook.HookConst.ENABLE_NOTIFY_ICON_FIX 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.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.ui.base.BaseActivity
import com.fankes.miui.notify.utils.factory.* import com.fankes.miui.notify.utils.factory.*
import com.fankes.miui.notify.utils.tool.SystemUITool import com.fankes.miui.notify.utils.tool.SystemUITool
@@ -96,7 +98,18 @@ class MainActivity : BaseActivity() {
noCancelable() noCancelable()
} }
/** 判断是否 Hook */ /** 判断是否 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 -> else ->
showDialog { showDialog {
title = "模块没有激活" title = "模块没有激活"
@@ -192,6 +205,8 @@ class MainActivity : BaseActivity() {
} }
/** 通知图标优化名单按钮点击事件 */ /** 通知图标优化名单按钮点击事件 */
notifyIconFixButton.setOnClickListener { startActivity(Intent(this, ConfigureActivity::class.java)) } notifyIconFixButton.setOnClickListener { startActivity(Intent(this, ConfigureActivity::class.java)) }
/** 设置警告 */
findViewById<View>(R.id.config_warn_s_count_dis_tip).isGone = miuiVersionCode > 12.5
/** 修改状态栏通知图标个数按钮点击事件 */ /** 修改状态栏通知图标个数按钮点击事件 */
findViewById<View>(R.id.config_status_icon_count_button).setOnClickListener { findViewById<View>(R.id.config_status_icon_count_button).setOnClickListener {
showDialog { showDialog {

View File

@@ -51,6 +51,7 @@ import com.highcapable.yukihookapi.hook.type.java.StringType
import com.topjohnwu.superuser.Shell import com.topjohnwu.superuser.Shell
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
/** /**
* 系统深色模式是否开启 * 系统深色模式是否开启
* @return [Boolean] 是否开启 * @return [Boolean] 是否开启
@@ -129,21 +130,26 @@ inline val isNotSupportMiuiVersion get() = !isSupportMiuiVersion
* @return [String] * @return [String]
*/ */
val miuiVersion val miuiVersion
get() = get() = if (isMIUI)
if (isMIUI) findPropString(key = "ro.miui.ui.version.name", default = "V无法获取").let {
findPropString(key = "ro.miui.ui.version.name", default = "V无法获取").let { when (it) {
when (it) { "V110" -> "11"
"V110" -> "11" "V11" -> "11"
"V11" -> "11" "V120" -> "12"
"V120" -> "12" "V12" -> "12"
"V12" -> "12" "V125" -> "12.5"
"V125" -> "12.5" "V130" -> "13"
"V130" -> "13" "V13" -> "13"
"V13" -> "13" else -> it.replace(oldValue = "V", newValue = "")
else -> it.replace(oldValue = "V", newValue = "") }
} }.trim()
}.trim() else "NULL"
else "NULL"
/**
* 获取 MIUI 版本号
* @return [Float]
*/
val miuiVersionCode get() = safeOf(default = 0f) { miuiVersion.toFloat() }
/** /**
* 获取 MIUI 完全版本 * 获取 MIUI 完全版本
@@ -218,6 +224,18 @@ val Context.versionCode get() = packageInfo.versionCode
*/ */
fun Number.dp(context: Context) = (toFloat() * context.resources.displayMetrics.density) 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 加密 * Base64 加密
* @return [String] * @return [String]

View File

@@ -233,6 +233,17 @@
android:textColor="@color/colorTextDark" android:textColor="@color/colorTextDark"
android:textSize="12sp" /> android:textSize="12sp" />
<TextView
android:id="@+id/config_warn_s_count_dis_tip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:alpha="0.6"
android:lineSpacingExtra="6dp"
android:text="⚠️ 仅支持 MIUI 12.5 后期开发版以及最新版本"
android:textColor="@color/colorTextDark"
android:textSize="12sp" />
<LinearLayout <LinearLayout
android:id="@+id/config_item_s_count_child_hook" android:id="@+id/config_item_s_count_child_hook"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

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