From 2b36ad29d8eeb1a6c0234a172d4a6c343bc6fd5d Mon Sep 17 00:00:00 2001 From: LittleTurtle2333 Date: Thu, 16 Feb 2023 00:37:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DA13=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E5=A4=A7=E7=A7=BB=E5=8A=A8=E7=B1=BB=E5=9E=8B=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E5=90=8E=E9=9D=9E=E4=B8=8A=E7=BD=91=E5=8D=A1=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=AE=AD=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StatusBarBigMobileTypeIconForT.kt | 53 +++++++++++++------ 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/lt2333/simplicitytools/hooks/rules/t/systemui/StatusBarBigMobileTypeIconForT.kt b/app/src/main/java/com/lt2333/simplicitytools/hooks/rules/t/systemui/StatusBarBigMobileTypeIconForT.kt index b902a0ac..5304ddbf 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hooks/rules/t/systemui/StatusBarBigMobileTypeIconForT.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hooks/rules/t/systemui/StatusBarBigMobileTypeIconForT.kt @@ -3,12 +3,10 @@ package com.lt2333.simplicitytools.hooks.rules.t.systemui import android.content.Context import android.content.res.Resources import android.graphics.Typeface +import android.view.View import android.view.ViewGroup import android.widget.TextView -import com.github.kyuubiran.ezxhelper.utils.findMethod -import com.github.kyuubiran.ezxhelper.utils.hookAfter -import com.github.kyuubiran.ezxhelper.utils.hookBefore -import com.github.kyuubiran.ezxhelper.utils.putObject +import com.github.kyuubiran.ezxhelper.utils.* import com.lt2333.simplicitytools.utils.XSPUtils import com.lt2333.simplicitytools.utils.hasEnable import com.lt2333.simplicitytools.utils.xposed.base.HookRegister @@ -18,10 +16,12 @@ object StatusBarBigMobileTypeIconForT : HookRegister() { private val getLocation = XSPUtils.getInt("big_mobile_type_location", 1) private val upAndDownPosition = XSPUtils.getInt("big_mobile_type_icon_up_and_down_position", 0) - private val leftAndRightMargin = XSPUtils.getInt("big_mobile_type_icon_left_and_right_margins", 0) + private val leftAndRightMargin = + XSPUtils.getInt("big_mobile_type_icon_left_and_right_margins", 0) private val isBold = XSPUtils.getBoolean("big_mobile_type_icon_bold", true) private val size = XSPUtils.getFloat("big_mobile_type_icon_size", 12.5f) - private val isOnlyShowNetwork = XSPUtils.getBoolean("big_mobile_type_only_show_network_card", false) + private val isOnlyShowNetwork = + XSPUtils.getBoolean("big_mobile_type_only_show_network_card", false) override fun init() = hasEnable("big_mobile_type_icon") { //使网络类型单独显示 @@ -30,27 +30,24 @@ object StatusBarBigMobileTypeIconForT : HookRegister() { }.hookBefore { val mobileIconState = it.args[0] mobileIconState.putObject("showMobileDataTypeSingle", true) - if (!isOnlyShowNetwork) mobileIconState.putObject("dataConnected", true) } findMethod("com.android.systemui.statusbar.StatusBarMobileView") { - name == "init" + name == "initViewState" }.hookAfter { + val mobileIconState = it.args[0] val statusBarMobileView = it.thisObject as ViewGroup val context: Context = statusBarMobileView.context val res: Resources = context.resources - //获取组件 val mobileContainerLeftId: Int = res.getIdentifier("mobile_container_left", "id", "com.android.systemui") val mobileContainerLeft = statusBarMobileView.findViewById(mobileContainerLeftId) - val mobileGroupId: Int = - res.getIdentifier("mobile_group", "id", "com.android.systemui") - val mobileGroup = - statusBarMobileView.findViewById(mobileGroupId) + val mobileGroupId: Int = res.getIdentifier("mobile_group", "id", "com.android.systemui") + val mobileGroup = statusBarMobileView.findViewById(mobileGroupId) val mobileTypeSingleId: Int = res.getIdentifier("mobile_type_single", "id", "com.android.systemui") @@ -70,10 +67,34 @@ object StatusBarBigMobileTypeIconForT : HookRegister() { mobileTypeSingle.typeface = Typeface.DEFAULT_BOLD } mobileTypeSingle.setPadding( - leftAndRightMargin, upAndDownPosition, - leftAndRightMargin, 0 + leftAndRightMargin, upAndDownPosition, leftAndRightMargin, 0 ) + //显示非上网卡的大图标 + if (!isOnlyShowNetwork) { + if (!mobileIconState.getObjectAs("dataConnected")) { + mobileTypeSingle.visibility = View.VISIBLE + } + } + } + //显示非上网卡的大图标 + if (!isOnlyShowNetwork) { + findMethod("com.android.systemui.statusbar.StatusBarMobileView") { + name == "updateState" + }.hookAfter { + val mobileIconState = it.args[0] + val statusBarMobileView = it.thisObject as ViewGroup + val context: Context = statusBarMobileView.context + val res: Resources = context.resources + + val mobileTypeSingleId: Int = + res.getIdentifier("mobile_type_single", "id", "com.android.systemui") + val mobileTypeSingle = + statusBarMobileView.findViewById(mobileTypeSingleId) + + if (!mobileIconState.getObjectAs("dataConnected")) { + mobileTypeSingle.visibility = View.VISIBLE + } + } } } - } \ No newline at end of file