修复A13开启大移动类型图标后非上网卡显示箭头

This commit is contained in:
LittleTurtle2333
2023-02-16 00:37:08 +08:00
parent 3e0d94ab81
commit 2b36ad29d8

View File

@@ -3,12 +3,10 @@ package com.lt2333.simplicitytools.hooks.rules.t.systemui
import android.content.Context import android.content.Context
import android.content.res.Resources import android.content.res.Resources
import android.graphics.Typeface import android.graphics.Typeface
import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import com.github.kyuubiran.ezxhelper.utils.findMethod import com.github.kyuubiran.ezxhelper.utils.*
import com.github.kyuubiran.ezxhelper.utils.hookAfter
import com.github.kyuubiran.ezxhelper.utils.hookBefore
import com.github.kyuubiran.ezxhelper.utils.putObject
import com.lt2333.simplicitytools.utils.XSPUtils import com.lt2333.simplicitytools.utils.XSPUtils
import com.lt2333.simplicitytools.utils.hasEnable import com.lt2333.simplicitytools.utils.hasEnable
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister 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 getLocation = XSPUtils.getInt("big_mobile_type_location", 1)
private val upAndDownPosition = XSPUtils.getInt("big_mobile_type_icon_up_and_down_position", 0) 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 isBold = XSPUtils.getBoolean("big_mobile_type_icon_bold", true)
private val size = XSPUtils.getFloat("big_mobile_type_icon_size", 12.5f) 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") { override fun init() = hasEnable("big_mobile_type_icon") {
//使网络类型单独显示 //使网络类型单独显示
@@ -30,27 +30,24 @@ object StatusBarBigMobileTypeIconForT : HookRegister() {
}.hookBefore { }.hookBefore {
val mobileIconState = it.args[0] val mobileIconState = it.args[0]
mobileIconState.putObject("showMobileDataTypeSingle", true) mobileIconState.putObject("showMobileDataTypeSingle", true)
if (!isOnlyShowNetwork) mobileIconState.putObject("dataConnected", true)
} }
findMethod("com.android.systemui.statusbar.StatusBarMobileView") { findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
name == "init" name == "initViewState"
}.hookAfter { }.hookAfter {
val mobileIconState = it.args[0]
val statusBarMobileView = it.thisObject as ViewGroup val statusBarMobileView = it.thisObject as ViewGroup
val context: Context = statusBarMobileView.context val context: Context = statusBarMobileView.context
val res: Resources = context.resources val res: Resources = context.resources
//获取组件 //获取组件
val mobileContainerLeftId: Int = val mobileContainerLeftId: Int =
res.getIdentifier("mobile_container_left", "id", "com.android.systemui") res.getIdentifier("mobile_container_left", "id", "com.android.systemui")
val mobileContainerLeft = val mobileContainerLeft =
statusBarMobileView.findViewById<ViewGroup>(mobileContainerLeftId) statusBarMobileView.findViewById<ViewGroup>(mobileContainerLeftId)
val mobileGroupId: Int = val mobileGroupId: Int = res.getIdentifier("mobile_group", "id", "com.android.systemui")
res.getIdentifier("mobile_group", "id", "com.android.systemui") val mobileGroup = statusBarMobileView.findViewById<ViewGroup>(mobileGroupId)
val mobileGroup =
statusBarMobileView.findViewById<ViewGroup>(mobileGroupId)
val mobileTypeSingleId: Int = val mobileTypeSingleId: Int =
res.getIdentifier("mobile_type_single", "id", "com.android.systemui") res.getIdentifier("mobile_type_single", "id", "com.android.systemui")
@@ -70,10 +67,34 @@ object StatusBarBigMobileTypeIconForT : HookRegister() {
mobileTypeSingle.typeface = Typeface.DEFAULT_BOLD mobileTypeSingle.typeface = Typeface.DEFAULT_BOLD
} }
mobileTypeSingle.setPadding( mobileTypeSingle.setPadding(
leftAndRightMargin, upAndDownPosition, leftAndRightMargin, upAndDownPosition, leftAndRightMargin, 0
leftAndRightMargin, 0
) )
//显示非上网卡的大图标
if (!isOnlyShowNetwork) {
if (!mobileIconState.getObjectAs<Boolean>("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<TextView>(mobileTypeSingleId)
if (!mobileIconState.getObjectAs<Boolean>("dataConnected")) {
mobileTypeSingle.visibility = View.VISIBLE
}
}
}
}
} }