diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/MobileTypeSingle2Hook.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/MobileTypeSingle2Hook.kt index 5e8fb15f3..8b5d920f2 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/MobileTypeSingle2Hook.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/MobileTypeSingle2Hook.kt @@ -23,6 +23,7 @@ import android.graphics.* import android.telephony.* import android.view.* import android.widget.* +import androidx.core.view.* import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder @@ -49,6 +50,7 @@ import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.Mobi import com.sevtinge.hyperceiler.utils.* import com.sevtinge.hyperceiler.utils.StateFlowHelper.newReadonlyStateFlow import com.sevtinge.hyperceiler.utils.devicesdk.DisplayUtils.* +import com.sevtinge.hyperceiler.utils.extension.* import java.lang.reflect.* import java.util.ArrayList @@ -58,7 +60,6 @@ object MobileTypeSingle2Hook : BaseHook() { } var method: Method? = null var method2: Method? = null - private var mobileId = -1 private var get0: Float = 0.0f private var get1: Int = 0 private var get2: Int = 0 @@ -86,7 +87,6 @@ object MobileTypeSingle2Hook : BaseHook() { updateIconState(param, "volteVisibleGlobal", "system_ui_status_bar_icon_big_hd") // 显示逻辑 hookMobileView(cellularIcon) - setMobileType(cellularIcon) } } ) @@ -99,16 +99,11 @@ object MobileTypeSingle2Hook : BaseHook() { val getView = it.args[0] as ViewGroup if ("mobile" == getView.getObjectFieldAs("slot")) { // 大 5G 的 View - val textView: TextView = - getView.findViewById( - getView.resources.getIdentifier("mobile_type_single", "id", "com.android.systemui") - ) + val textView = + getView.findViewByIdName("mobile_type_single") as TextView val layout = textView.parent as LinearLayout - val getView2: ViewGroup = - getView.findViewById( - getView.resources.getIdentifier("mobile_container_left", "id", "com.android.systemui") - ) - + val getView2 = + getView.findViewByIdName("mobile_container_left") as ViewGroup if (!getLocation) { layout.removeView(textView) layout.addView(textView) @@ -168,10 +163,7 @@ object MobileTypeSingle2Hook : BaseHook() { val num = it.args[2] as Int val getBoolean = it.args[5] as Boolean val getView = it.thisObject as ViewGroup - if (mobileId < 1) { - mobileId = getView.resources.getIdentifier("mobile_type_single", "id", "com.android.systemui") - } - val textView: TextView = getView.findViewById(mobileId) + val textView: TextView = getView.findViewByIdName("mobile_type_single") as TextView if (getBoolean) { method2?.invoke(null, it.args[0], textView, num)?.let { it1 -> textView.setTextColor(it1.hashCode()) @@ -216,18 +208,33 @@ object MobileTypeSingle2Hook : BaseHook() { val mobileGroupParent = mobileGroup.parent as ViewGroup val subId = rootView.getIntField("subId") val getSlotIndex = SubscriptionManager.getSlotIndex(subId) + val getCard1 = mobileGroupParent.findViewByIdName("mobile_container_left") as View + val getCard2 = mobileGroupParent.findViewByIdName("mobile_container_right") as View if (mobileSignalViewMap[subId] == null) { mobileSignalViewMap[subId] = mutableListOf() } mobileSignalViewMap[subId]?.add(mobileGroupParent) - if (showMobileType && (mobileNetworkType == 0 || mobileNetworkType == 2)) { + if (showMobileType && mobileNetworkType != 4) { + // 大 5G 显示逻辑 cellularIcon.setObjectField("mobileTypeSingleVisible", newReadonlyStateFlow(true)) - showWifi(mobileGroupParent) - } /*else if (!showMobileType && mobileNetworkType == 4) { - smallMobileType(mobileGroupParent, subId) - }*/ + if (mobileNetworkType == 0 || mobileNetworkType == 2) { + showWifi(mobileGroupParent) + } + } else if (!showMobileType) { + // 小 5G 显示逻辑 + if (mobileNetworkType == 1) { + cellularIcon.setObjectField("mobileTypeVisible", newReadonlyStateFlow(true)) + } else if (mobileNetworkType == 3) { + cellularIcon.setObjectField("mobileTypeVisible", newReadonlyStateFlow(false)) + // 调整隐藏后的布局 + getCard1.setPadding(20,0,0,0) + getCard2.setPadding(20,0,0,0) + } /*else if (!showMobileType && mobileNetworkType == 4) { + smallMobileType(mobileGroupParent, subId) + }*/ + } // 隐藏 Sim 卡图标 mobileSignalViewMap[subId]?.forEach { @@ -296,25 +303,4 @@ object MobileTypeSingle2Hook : BaseHook() { } } } - - private fun setMobileType(cellularIcon: Any) { - if (showMobileType) { - // 大 5G 显示逻辑 - if (mobileNetworkType == 1) { - cellularIcon.setObjectField("mobileTypeSingleVisible", newReadonlyStateFlow(true)) - } - } else { - // 小 5G 显示逻辑 - when (mobileNetworkType) { - 1 -> { - cellularIcon.setObjectField("mobileTypeVisible", newReadonlyStateFlow(true)) - } - 3 -> { - // 需要解决信号图标错位问题 - cellularIcon.setObjectField("mobileTypeVisible", newReadonlyStateFlow(false)) - } - // 0 和 2 保持一致 - } - } - } } \ No newline at end of file