再次修复通知图标个数对旧版本 MIUI 不生效的问题

This commit is contained in:
2022-03-17 11:32:44 +08:00
parent ef47eef989
commit 4699eb137e
4 changed files with 71 additions and 38 deletions

View File

@@ -122,6 +122,10 @@ class HookEntry : YukiHookXposedInitProxy {
/** 是否显示通知图标 - 跟随 Hook 保存 */
private var isShowNotificationIcons = true
/** 是否有最大图标设置功能 */
private val PackageParam.hasMaxStaticIcons
get() = safeOfFalse { NotificationIconContainerClass.clazz.hasField(name = "MAX_STATIC_ICONS") }
/**
* - 这个是修复彩色图标的关键核心代码判断
*
@@ -549,32 +553,42 @@ class HookEntry : YukiHookXposedInitProxy {
}
}
}
NotificationIconContainerClass.hook {
injectMember {
method { name = "calculateIconTranslations" }
afterHook {
/** 修复最新开发版状态栏图标只能显示一个的问题 */
instance<ViewGroup>().layoutParams.width = 9999
if (hasMaxStaticIcons)
NotificationIconContainerClass.hook {
injectMember {
method { name = "calculateIconTranslations" }
afterHook {
/** 修复最新开发版状态栏图标只能显示一个的问题 */
instance<ViewGroup>().layoutParams.width = 9999
}
}
}
injectMember {
method { name = "updateState" }
beforeHook {
/** 解除状态栏通知图标个数限制 */
if (isShowNotificationIcons && prefs.getBoolean(ENABLE_HOOK_STATUS_ICON_COUNT, default = true))
field { name = "MAX_STATIC_ICONS" }
.get(instance).set(prefs.getInt(HOOK_STATUS_ICON_COUNT, default = 5)
.let { if (it in 0..100) it else 5 })
injectMember {
method { name = "updateState" }
beforeHook {
/** 解除状态栏通知图标个数限制 */
if (isShowNotificationIcons && prefs.getBoolean(ENABLE_HOOK_STATUS_ICON_COUNT, default = true))
field { name = "MAX_STATIC_ICONS" }
.get(instance).set(prefs.getInt(HOOK_STATUS_ICON_COUNT, default = 5)
.let { if (it in 0..100) it else 5 })
}
}
/** 旧版方法 - 新版不存在 */
injectMember {
method {
name = "setMaxStaticIcons"
param(IntType)
beforeHook { isShowNotificationIcons = firstArgs as Int > 0 }
}
}.ignoredHookingFailure()
/** 新版方法 - 旧版不存在 */
injectMember {
method {
name = "miuiShowNotificationIcons"
param(BooleanType)
}
beforeHook { isShowNotificationIcons = firstArgs as Boolean }
}.ignoredHookingFailure()
}
injectMember {
method {
name = "miuiShowNotificationIcons"
param(BooleanType)
}
beforeHook { isShowNotificationIcons = firstArgs as Boolean }
}
}
NotificationHeaderViewWrapperClass.hook {
/** 修复下拉通知图标自动设置回 APP 图标的方法 */
injectMember {

View File

@@ -33,6 +33,7 @@ import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.widget.SwitchCompat
import androidx.constraintlayout.utils.widget.ImageFilterView
import androidx.core.view.isGone
import androidx.core.view.isVisible
import com.fankes.miui.notify.BuildConfig
import com.fankes.miui.notify.R
@@ -192,6 +193,8 @@ class MainActivity : BaseActivity() {
}
/** 通知图标优化名单按钮点击事件 */
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 {
showDialog {

View File

@@ -129,21 +129,26 @@ inline val isNotSupportMiuiVersion get() = !isSupportMiuiVersion
* @return [String]
*/
val miuiVersion
get() =
if (isMIUI)
findPropString(key = "ro.miui.ui.version.name", default = "V无法获取").let {
when (it) {
"V110" -> "11"
"V11" -> "11"
"V120" -> "12"
"V12" -> "12"
"V125" -> "12.5"
"V130" -> "13"
"V13" -> "13"
else -> it.replace(oldValue = "V", newValue = "")
}
}.trim()
else "NULL"
get() = if (isMIUI)
findPropString(key = "ro.miui.ui.version.name", default = "V无法获取").let {
when (it) {
"V110" -> "11"
"V11" -> "11"
"V120" -> "12"
"V12" -> "12"
"V125" -> "12.5"
"V130" -> "13"
"V13" -> "13"
else -> it.replace(oldValue = "V", newValue = "")
}
}.trim()
else "NULL"
/**
* 获取 MIUI 版本号
* @return [Float]
*/
val miuiVersionCode get() = safeOf(default = 0f) { miuiVersion.toFloat() }
/**
* 获取 MIUI 完全版本

View File

@@ -233,6 +233,17 @@
android:textColor="@color/colorTextDark"
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
android:id="@+id/config_item_s_count_child_hook"
android:layout_width="match_parent"