From 093529baeafdc377e32f62f39f4e51909064fc4f Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Sat, 4 Jun 2022 02:16:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=91=E5=87=A1=E7=9A=84?= =?UTF-8?q?=20MIUI=20=E9=80=9A=E7=9F=A5=E6=A0=B7=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E7=9A=84=E9=80=9A=E7=9F=A5=E5=9B=BE=E6=A0=87=E5=9C=A8=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=9C=80=E6=96=B0=E7=9A=84=E5=BC=80=E5=8F=91=E7=89=88?= =?UTF-8?q?=E4=B8=AD=E5=87=BA=E7=8E=B0=E9=BB=91=E7=99=BD=E5=9D=97=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../miui/notify/hook/entity/SystemUIHooker.kt | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/fankes/miui/notify/hook/entity/SystemUIHooker.kt b/app/src/main/java/com/fankes/miui/notify/hook/entity/SystemUIHooker.kt index c454332..d70eeda 100644 --- a/app/src/main/java/com/fankes/miui/notify/hook/entity/SystemUIHooker.kt +++ b/app/src/main/java/com/fankes/miui/notify/hook/entity/SystemUIHooker.kt @@ -43,6 +43,7 @@ import android.view.ViewOutlineProvider import android.widget.ImageView import androidx.core.graphics.drawable.toBitmap import androidx.core.view.children +import androidx.core.view.isVisible import com.fankes.miui.notify.bean.IconDataBean import com.fankes.miui.notify.data.DataConst import com.fankes.miui.notify.hook.HookConst.SYSTEMUI_PACKAGE_NAME @@ -589,6 +590,30 @@ object SystemUIHooker : YukiBaseHooker() { .get(NotificationViewWrapperClass.clazz.field { name = "mRow" }.get(this).self) .invoke() + /** + * 根据当前 [ImageView] 的父布局克隆一个新的 [ImageView] + * @param initiate 新的 [ImageView] 方法体 - 失败会返回当前 [ImageView] + */ + private fun ImageView.clone(initiate: ImageView.() -> Unit) { + (parent as? ViewGroup?)?.also { parent -> + /** 将之前的 [ImageView] 调为全透明且隐藏 */ + alpha = 0f + isVisible = false + /** 将内容清空 */ + setImageDrawable(null) + setBackgroundColor(Color.TRANSPARENT) + /** 创建一个傀儡 */ + parent.findViewWithTag("new_view").also { base -> + if (base == null) parent.addView(ImageView(context).also { new -> + new.tag = "new_view" + /** 克隆它的 [ViewGroup.LayoutParams] */ + new.layoutParams = layoutParams + initiate(new) + }) else initiate(base) + } + } ?: initiate(this) + } + /** 注册 */ private fun register() { /** 解锁后重新刷新状态栏图标防止系统重新设置它 */ @@ -802,7 +827,7 @@ object SystemUIHooker : YukiBaseHooker() { injectMember { method { name = "handleAppIcon" } replaceUnit { - field { name = "mAppIcon" }.get(instance).cast()?.apply { + field { name = "mAppIcon" }.get(instance).cast()?.clone { compatNotifyIcon( context = context, expandedNf = instance.getRowPair().second.getSbn(),