Compare commits

3 Commits

Author SHA1 Message Date
乌堆小透明
509fef5e06 Update version to 1.5.3 2022-03-22 20:16:50 +08:00
乌堆小透明
f88ff6db15 New Crowdin updates (#102)
* New translations strings.xml (Russian)
[ci skip] New translations from Crowdin

* New translations strings.xml (Chinese Traditional)
[ci skip] New translations from Crowdin

* New translations strings.xml (Spanish)
[ci skip] New translations from Crowdin

* New translations strings.xml (Spanish)
[ci skip] New translations from Crowdin
2022-03-22 20:16:15 +08:00
乌堆小透明
2b352738f5 重构大移动类型功能,使其自适应 2022-03-22 20:15:15 +08:00
5 changed files with 81 additions and 39 deletions

View File

@@ -12,8 +12,8 @@ android {
applicationId = "com.lt2333.simplicitytools" applicationId = "com.lt2333.simplicitytools"
minSdk = 31 minSdk = 31
targetSdk = 32 targetSdk = 32
versionCode = 53 versionCode = 54
versionName = "1.5.2" versionName = "1.5.3"
} }
buildTypes { buildTypes {

View File

@@ -2,16 +2,18 @@ package com.lt2333.simplicitytools.hook.app.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.util.TypedValue
import android.view.Gravity import android.view.Gravity
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView import android.widget.ImageView
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import cn.fkj233.ui.activity.dp2px
import com.lt2333.simplicitytools.util.hasEnable import com.lt2333.simplicitytools.util.hasEnable
import com.lt2333.simplicitytools.util.hookAfterMethod import com.lt2333.simplicitytools.util.hookAfterMethod
import com.lt2333.simplicitytools.util.hookBeforeMethod
import de.robv.android.xposed.IXposedHookLoadPackage import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.XposedHelpers
import de.robv.android.xposed.callbacks.XC_LoadPackage import de.robv.android.xposed.callbacks.XC_LoadPackage
@@ -25,58 +27,89 @@ class StatusBarBigMobileTypeIcon : IXposedHookLoadPackage {
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 mobile_container_left_ID: Int = val mobile_container_left_ID: Int =
res.getIdentifier("mobile_container_left", "id", "com.android.systemui") res.getIdentifier("mobile_container_left", "id", "com.android.systemui")
val mobile_container_left =
StatusBarMobileView.findViewById<ViewGroup>(mobile_container_left_ID)
val mobile_type_ID: Int =
res.getIdentifier("mobile_type", "id", "com.android.systemui")
val mobile_type = StatusBarMobileView.findViewById<TextView>(mobile_type_ID)
val mobile_left_mobile_inout_ID: Int = res.getIdentifier( val mobile_left_mobile_inout_ID: Int = res.getIdentifier(
"mobile_left_mobile_inout", "mobile_left_mobile_inout",
"id", "id",
"com.android.systemui" "com.android.systemui"
) )
val mobile_left_mobile_inout =
StatusBarMobileView.findViewById<ImageView>(mobile_left_mobile_inout_ID)
//获取插入位置
val mobile_container_right_ID: Int = res.getIdentifier( val mobile_container_right_ID: Int = res.getIdentifier(
"mobile_container_right", "mobile_container_right",
"id", "id",
"com.android.systemui" "com.android.systemui"
) )
val mobile_type_ID: Int =
res.getIdentifier("mobile_type", "id", "com.android.systemui")
val TextAppearance_StatusBar_Carrier_ID: Int = res.getIdentifier(
"TextAppearance.StatusBar.Carrier",
"style",
"com.android.systemui"
)
//获取mobile_container_left并在父布局中删除
val mobile_container_left =
StatusBarMobileView.findViewById<ViewGroup>(mobile_container_left_ID)
val mobile_container_left_fl =
mobile_container_left.layoutParams as LinearLayout.LayoutParams
(mobile_container_left.parent as ViewGroup).removeView(mobile_container_left)
//获取mobile_container_right的父布局并在mobile_container_right前添加mobile_container_left
val mobile_container_right = val mobile_container_right =
StatusBarMobileView.findViewById<ViewGroup>(mobile_container_right_ID) StatusBarMobileView.findViewById<ViewGroup>(mobile_container_right_ID)
val RightParentLayout = mobile_container_right.parent as ViewGroup val RightParentLayout = mobile_container_right.parent as ViewGroup
val mobile_container_right_Index = val mobile_container_right_Index =
RightParentLayout.indexOfChild(mobile_container_left) RightParentLayout.indexOfChild(mobile_container_right)
RightParentLayout.addView(
mobile_container_left, //创建新布局
mobile_container_right_Index - 1 val newLinearLayoutLP = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.MATCH_PARENT
) )
mobile_container_left_fl.topMargin = dp2px(context, 1.5f) val newLinearlayout = LinearLayout(context).also {
mobile_container_left.layoutParams = mobile_container_left_fl it.layoutParams = newLinearLayoutLP
val mobile_type = StatusBarMobileView.findViewById<TextView>(mobile_type_ID) it.id = mobile_container_left_ID
mobile_type.setTextAppearance(TextAppearance_StatusBar_Carrier_ID) }
val mobile_type_fl = mobile_type.layoutParams as FrameLayout.LayoutParams XposedHelpers.setObjectField(it.thisObject, "mMobileLeftContainer", newLinearlayout)
mobile_type_fl.width = dp2px(context, 25f) RightParentLayout.addView(
mobile_type_fl.gravity = Gravity.CENTER or Gravity.START newLinearlayout,
mobile_type.layoutParams = mobile_type_fl mobile_container_right_Index
val mobile_left_mobile_inout = )
StatusBarMobileView.findViewById<ImageView>(mobile_left_mobile_inout_ID)
val mobile_left_mobile_inout_fl = //将组件插入新的布局
mobile_left_mobile_inout.layoutParams as FrameLayout.LayoutParams (mobile_type.parent as ViewGroup).removeView(mobile_type)
mobile_left_mobile_inout_fl.width = dp2px(context, 8f) (mobile_left_mobile_inout.parent as ViewGroup).removeView(mobile_left_mobile_inout)
mobile_left_mobile_inout_fl.marginStart = dp2px(context, 16f) (mobile_container_left.parent as ViewGroup).removeView(mobile_container_left)
mobile_left_mobile_inout_fl.bottomMargin = dp2px(context, 3f)
mobile_left_mobile_inout.layoutParams = mobile_left_mobile_inout_fl
newLinearlayout.addView(mobile_type) //类型
val mobile_type_lp = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT
).also {
it.gravity = Gravity.CENTER_VERTICAL
}
mobile_type.also {
it.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12.5F)
it.typeface = Typeface.DEFAULT_BOLD
it.layoutParams = mobile_type_lp
}
newLinearlayout.addView(mobile_left_mobile_inout) //箭头
val mobile_left_mobile_inout_lp = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.MATCH_PARENT
)
mobile_left_mobile_inout.also {
it.layoutParams = mobile_left_mobile_inout_lp
}
//屏蔽更新布局
"com.android.systemui.statusbar.StatusBarMobileView".hookBeforeMethod(
lpparam.classLoader,
"updateMobileTypeLayout", String::class.java
) {
it.result = null
}
} }
} }
} }

View File

@@ -173,4 +173,8 @@
<string name="status_bar_network_speed_dual_row_size">Tamaño de fila dual (0: no cambiar)</string> <string name="status_bar_network_speed_dual_row_size">Tamaño de fila dual (0: no cambiar)</string>
<string name="status_bar_network_speed_dual_row_icon">Icono de fila dual</string> <string name="status_bar_network_speed_dual_row_icon">Icono de fila dual</string>
<string name="none">Ninguno</string> <string name="none">Ninguno</string>
<string name="status_bar_network_speed_dual_row_gravity">Alineación de icono en fila dual</string>
<string name="left">Izquierda</string>
<string name="right">Derecha</string>
<string name="big_mobile_type_icon">Icono grande de red móvil</string>
</resources> </resources>

View File

@@ -180,4 +180,5 @@
<string name="status_bar_network_speed_dual_row_gravity">Выравнивание скорости сети в 2 ряда</string> <string name="status_bar_network_speed_dual_row_gravity">Выравнивание скорости сети в 2 ряда</string>
<string name="left">Влево</string> <string name="left">Влево</string>
<string name="right">Вправо</string> <string name="right">Вправо</string>
<string name="big_mobile_type_icon">Большая иконка типа сети</string>
</resources> </resources>

View File

@@ -173,4 +173,8 @@
<string name="status_bar_network_speed_dual_row_size">雙排大小0不更改</string> <string name="status_bar_network_speed_dual_row_size">雙排大小0不更改</string>
<string name="status_bar_network_speed_dual_row_icon">雙行圖示</string> <string name="status_bar_network_speed_dual_row_icon">雙行圖示</string>
<string name="none"></string> <string name="none"></string>
<string name="status_bar_network_speed_dual_row_gravity">雙行網速對齊</string>
<string name="left">置左</string>
<string name="right">置右</string>
<string name="big_mobile_type_icon">大行動網路圖示</string>
</resources> </resources>