From 5c12c0aa5664c96d962bf08659a16f182785fba7 Mon Sep 17 00:00:00 2001 From: LittleTurtle2333 Date: Tue, 14 Feb 2023 22:36:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DA13=E4=B8=AD=E5=A4=A7?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=B1=BB=E5=9E=8B=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StatusBarBigMobileTypeIconForT.kt | 110 +++++------------- 1 file changed, 30 insertions(+), 80 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 8f88242a..da34d163 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 @@ -9,10 +9,7 @@ import android.view.ViewGroup import android.widget.ImageView import android.widget.LinearLayout import android.widget.TextView -import com.github.kyuubiran.ezxhelper.utils.findMethod -import com.github.kyuubiran.ezxhelper.utils.hookAfter -import com.github.kyuubiran.ezxhelper.utils.hookReturnConstant -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 @@ -27,97 +24,50 @@ object StatusBarBigMobileTypeIconForT : HookRegister() { private val size = XSPUtils.getFloat("big_mobile_type_icon_size", 12.5f) override fun init() = hasEnable("big_mobile_type_icon") { - // TODO: Android13大移动类型图标不可用 + //使网络类型单独显示 + findMethod("com.android.systemui.statusbar.StatusBarMobileView"){ + name == "applyMobileState" + }.hookBefore { + val mobileIconState = it.args[0] + mobileIconState.putObject("showMobileDataTypeSingle",true) + } + findMethod("com.android.systemui.statusbar.StatusBarMobileView") { name == "init" - }.hookAfter { param -> - val statusBarMobileView = param.thisObject as ViewGroup + }.hookAfter { + 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 mobileTypeId: Int = - res.getIdentifier("mobile_type", "id", "com.android.systemui") - val mobileType = statusBarMobileView.findViewById(mobileTypeId) + val mobileGroupId: Int = + res.getIdentifier("mobile_group", "id", "com.android.systemui") + val mobileGroup = + statusBarMobileView.findViewById(mobileGroupId) - val mobileLeftMobileInoutId: Int = res.getIdentifier( - "mobile_left_mobile_inout", - "id", - "com.android.systemui" - ) - val mobileLeftMobileInout = - statusBarMobileView.findViewById(mobileLeftMobileInoutId) + val mobileTypeSingleId: Int = + res.getIdentifier("mobile_type_single", "id", "com.android.systemui") + val mobileTypeSingle = statusBarMobileView.findViewById(mobileTypeSingleId) + //更改顺序 + mobileGroup.removeView(mobileTypeSingle) + mobileGroup.addView(mobileTypeSingle) + mobileGroup.removeView(mobileContainerLeft) + mobileGroup.addView(mobileContainerLeft) - //获取插入位置 - val mobileContainerRightId: Int = res.getIdentifier( - "mobile_container_right", - "id", - "com.android.systemui" - ) - val mobileContainerRight = - statusBarMobileView.findViewById(mobileContainerRightId) - val rightParentLayout = mobileContainerRight.parent as ViewGroup - val mobileContainerRightIndex = - rightParentLayout.indexOfChild(mobileContainerRight) - - //创建新布局 - val newLinearLayoutLP = LinearLayout.LayoutParams( - LinearLayout.LayoutParams.WRAP_CONTENT, - LinearLayout.LayoutParams.MATCH_PARENT - ) - val newLinearlayout = LinearLayout(context).also { - it.layoutParams = newLinearLayoutLP - it.id = mobileContainerLeftId - it.setPadding(leftAndRightMargin, 0, leftAndRightMargin, 0) + //更改样式 + mobileTypeSingle.textSize = size + if (isBold){ + mobileTypeSingle.typeface = Typeface.DEFAULT_BOLD } - param.thisObject.putObject("mMobileLeftContainer", newLinearlayout) - rightParentLayout.addView( - newLinearlayout, - mobileContainerRightIndex - ) - - //将组件插入新的布局 - (mobileType.parent as ViewGroup).removeView(mobileType) - (mobileLeftMobileInout.parent as ViewGroup).removeView(mobileLeftMobileInout) - (mobileContainerLeft.parent as ViewGroup).removeView(mobileContainerLeft) - - - newLinearlayout.addView(mobileType) //类型 - val mobileTypeLp = LinearLayout.LayoutParams( - LinearLayout.LayoutParams.WRAP_CONTENT, - LinearLayout.LayoutParams.WRAP_CONTENT - ).also { - it.gravity = Gravity.CENTER_VERTICAL - it.topMargin = upAndDownPosition - } - mobileType.also { - it.setTextSize(TypedValue.COMPLEX_UNIT_DIP, size) - if (isBold) { - it.typeface = Typeface.DEFAULT_BOLD - } - it.layoutParams = mobileTypeLp - } - - - newLinearlayout.addView(mobileLeftMobileInout) //箭头 - val mobileLeftMobileInoutLp = LinearLayout.LayoutParams( - LinearLayout.LayoutParams.WRAP_CONTENT, - LinearLayout.LayoutParams.MATCH_PARENT - ) - mobileLeftMobileInout.also { - it.layoutParams = mobileLeftMobileInoutLp - } - - //屏蔽更新布局 - findMethod("com.android.systemui.statusbar.StatusBarMobileView") { - name == "updateMobileTypeLayout" && parameterTypes[0] == String::class.java - }.hookReturnConstant(null) + mobileTypeSingle.setPadding(leftAndRightMargin, upAndDownPosition, + leftAndRightMargin,0) } }