mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-12 11:21:18 +08:00
Compare commits
7 Commits
0a6b114354
...
8bcb89b04d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8bcb89b04d | ||
|
|
f2df033393 | ||
|
|
ab41dea173 | ||
|
|
7d9f45b92f | ||
|
|
8c08466ed6 | ||
|
|
801ade5859 | ||
|
|
984b909197 |
@@ -12,8 +12,8 @@ android {
|
||||
applicationId = "com.lt2333.simplicitytools"
|
||||
minSdk = 31
|
||||
targetSdk = 32
|
||||
versionCode = 51
|
||||
versionName = "1.5.0"
|
||||
versionCode = 52
|
||||
versionName = "1.5.1"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
||||
@@ -498,6 +498,14 @@ class SettingsActivity : MIUIActivity() {
|
||||
menuButton.visibility = View.VISIBLE
|
||||
return ArrayList<BaseView>().apply {
|
||||
add(TitleTextV(resId = R.string.statusbar))
|
||||
add(
|
||||
TextSummaryWithSwitchV(
|
||||
TextSummaryV(
|
||||
textId = R.string.big_mobile_type_icon
|
||||
),
|
||||
SwitchV("big_mobile_type_icon")
|
||||
)
|
||||
)
|
||||
add(
|
||||
TextSummaryWithSwitchV(
|
||||
TextSummaryV(
|
||||
@@ -768,6 +776,40 @@ class SettingsActivity : MIUIActivity() {
|
||||
)
|
||||
)
|
||||
)
|
||||
val align: HashMap<Int, String> = hashMapOf()
|
||||
align[0] = getString(R.string.left)
|
||||
align[1] = getString(R.string.right)
|
||||
add(
|
||||
TextWithSpinnerV(
|
||||
TextV(resId = R.string.status_bar_network_speed_dual_row_gravity),
|
||||
SpinnerV(
|
||||
arrayListOf<MIUIPopupData>().apply {
|
||||
add(MIUIPopupData(getString(R.string.left)) {
|
||||
OwnSP.ownSP.edit().run {
|
||||
putInt(
|
||||
"status_bar_network_speed_dual_row_gravity",
|
||||
0
|
||||
)
|
||||
apply()
|
||||
}
|
||||
})
|
||||
add(MIUIPopupData(getString(R.string.right)) {
|
||||
OwnSP.ownSP.edit().run {
|
||||
putInt(
|
||||
"status_bar_network_speed_dual_row_gravity",
|
||||
1
|
||||
)
|
||||
apply()
|
||||
}
|
||||
})
|
||||
}, currentValue = align[OwnSP.ownSP.getInt(
|
||||
"status_bar_network_speed_dual_row_gravity",
|
||||
0
|
||||
)].toString()
|
||||
),
|
||||
dataBindingRecv = status_bar_dual_row_network_speed_binding.binding.getRecv(2)
|
||||
)
|
||||
)
|
||||
add(
|
||||
TextWithSpinnerV(
|
||||
TextV(resId = R.string.status_bar_network_speed_dual_row_icon),
|
||||
|
||||
@@ -58,6 +58,8 @@ class SystemUI : IXposedHookLoadPackage {
|
||||
OldQSCustom().handleLoadPackage(lpparam)
|
||||
//双排网速
|
||||
DoubleLineNetworkSpeed().handleLoadPackage(lpparam)
|
||||
|
||||
StatusBarBigMobileTypeIcon().handleLoadPackage(lpparam)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ class DoubleLineNetworkSpeed : IXposedHookLoadPackage {
|
||||
private var downIcon = ""
|
||||
|
||||
private val getDualSize = XSPUtils.getInt("status_bar_network_speed_dual_row_size", 0)
|
||||
private val getDualAlign = XSPUtils.getInt("status_bar_network_speed_dual_row_gravity", 0)
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
|
||||
@@ -32,9 +33,9 @@ class DoubleLineNetworkSpeed : IXposedHookLoadPackage {
|
||||
|
||||
if (XSPUtils.getString("status_bar_network_speed_dual_row_icon", none) != none) {
|
||||
upIcon = XSPUtils.getString("status_bar_network_speed_dual_row_icon", none)
|
||||
?.firstOrNull()?.plus(" ") ?: String()
|
||||
?.firstOrNull().toString()
|
||||
downIcon = XSPUtils.getString("status_bar_network_speed_dual_row_icon", none)
|
||||
?.lastOrNull()?.plus(" ") ?: String()
|
||||
?.lastOrNull().toString()
|
||||
}
|
||||
|
||||
hasEnable("status_bar_dual_row_network_speed") {
|
||||
@@ -42,12 +43,16 @@ class DoubleLineNetworkSpeed : IXposedHookLoadPackage {
|
||||
.hookAfterConstructor(Context::class.java, AttributeSet::class.java) {
|
||||
val mView = it.thisObject as TextView
|
||||
mView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 7f)
|
||||
if (getDualSize!=0){
|
||||
if (getDualSize != 0) {
|
||||
mView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, getDualSize.toFloat())
|
||||
}
|
||||
mView.isSingleLine = false
|
||||
mView.setLineSpacing(0F, 0.8F)
|
||||
mView.gravity = Gravity.LEFT or Gravity.CENTER_VERTICAL
|
||||
if (getDualAlign == 0) {
|
||||
mView.gravity = Gravity.LEFT or Gravity.CENTER_VERTICAL
|
||||
} else {
|
||||
mView.gravity = Gravity.RIGHT or Gravity.CENTER_VERTICAL
|
||||
}
|
||||
}
|
||||
|
||||
"com.android.systemui.statusbar.policy.NetworkSpeedController".hookBeforeMethod(
|
||||
@@ -56,13 +61,19 @@ class DoubleLineNetworkSpeed : IXposedHookLoadPackage {
|
||||
Context::class.java,
|
||||
Long::class.java
|
||||
) {
|
||||
it.result = "${upIcon}${getTotalUpSpeed()}\n${downIcon}${getTotalDownloadSpeed()}"
|
||||
if (getDualAlign == 0) {
|
||||
it.result =
|
||||
"${upIcon} ${getTotalUpSpeed(it.args[0]as Context)}\n${downIcon} ${getTotalDownloadSpeed(it.args[0]as Context)}"
|
||||
} else {
|
||||
it.result =
|
||||
"${getTotalUpSpeed(it.args[0]as Context)} ${upIcon}\n${getTotalDownloadSpeed(it.args[0]as Context)} ${downIcon}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//获取总的上行速度
|
||||
fun getTotalUpSpeed(): String {
|
||||
fun getTotalUpSpeed(context: Context): String {
|
||||
var totalUpSpeed = 0F
|
||||
|
||||
val currentTotalTxBytes = TrafficStats.getTotalTxBytes()
|
||||
@@ -76,11 +87,11 @@ class DoubleLineNetworkSpeed : IXposedHookLoadPackage {
|
||||
if (bytes >= 1048576) {
|
||||
totalUpSpeed =
|
||||
DecimalFormat("0.0").format(bytes / 1048576).toFloat()
|
||||
unit = "MB/s"
|
||||
unit = context.resources.getString(context.resources.getIdentifier("megabyte_per_second","string",context.packageName))
|
||||
} else {
|
||||
totalUpSpeed =
|
||||
DecimalFormat("0.0").format(bytes / 1024).toFloat()
|
||||
unit = "KB/s"
|
||||
unit = context.resources.getString(context.resources.getIdentifier("kilobyte_per_second","string",context.packageName))
|
||||
}
|
||||
|
||||
//保存当前的流量总和和上次的时间戳
|
||||
@@ -95,7 +106,7 @@ class DoubleLineNetworkSpeed : IXposedHookLoadPackage {
|
||||
}
|
||||
|
||||
//获取总的下行速度
|
||||
fun getTotalDownloadSpeed(): String {
|
||||
fun getTotalDownloadSpeed(context: Context): String {
|
||||
var totalDownSpeed = 0F
|
||||
val currentTotalRxBytes = TrafficStats.getTotalRxBytes()
|
||||
val nowTimeStampTotalDown = System.currentTimeMillis()
|
||||
@@ -109,11 +120,11 @@ class DoubleLineNetworkSpeed : IXposedHookLoadPackage {
|
||||
if (bytes >= 1048576) {
|
||||
totalDownSpeed =
|
||||
DecimalFormat("0.0").format(bytes / 1048576).toFloat()
|
||||
unit = "MB/s"
|
||||
unit = context.resources.getString(context.resources.getIdentifier("megabyte_per_second","string",context.packageName))
|
||||
} else {
|
||||
totalDownSpeed =
|
||||
DecimalFormat("0.0").format(bytes / 1024).toFloat()
|
||||
unit = "KB/s"
|
||||
unit = context.resources.getString(context.resources.getIdentifier("kilobyte_per_second","string",context.packageName))
|
||||
}
|
||||
//保存当前的流量总和和上次的时间戳
|
||||
mLastTotalDown = currentTotalRxBytes
|
||||
|
||||
@@ -3,29 +3,54 @@ package com.lt2333.simplicitytools.hook.app.systemui
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideMobileTypeIcon : IXposedHookLoadPackage {
|
||||
val isBigType=XSPUtils.getBoolean("big_mobile_type_icon", false)
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val iconState = "com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$MobileIconState"
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(lpparam.classLoader, "initViewState", iconState) {
|
||||
hasEnable("hide_mobile_type_icon") {
|
||||
(it.thisObject.getObjectField("mMobileType") as TextView).visibility = View.INVISIBLE
|
||||
(it.thisObject.getObjectField("mMobileTypeImage") as ImageView).visibility = View.INVISIBLE
|
||||
(it.thisObject.getObjectField("mMobileTypeSingle") as TextView).visibility = View.INVISIBLE
|
||||
}
|
||||
val iconState =
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$MobileIconState"
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(
|
||||
lpparam.classLoader,
|
||||
"initViewState",
|
||||
iconState
|
||||
) {
|
||||
hideMobileTypeIcon(it)
|
||||
}
|
||||
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(lpparam.classLoader, "updateState", iconState) {
|
||||
hasEnable("hide_mobile_type_icon") {
|
||||
(it.thisObject.getObjectField("mMobileType") as TextView).visibility = View.INVISIBLE
|
||||
(it.thisObject.getObjectField("mMobileTypeImage") as ImageView).visibility = View.INVISIBLE
|
||||
(it.thisObject.getObjectField("mMobileTypeSingle") as TextView).visibility = View.INVISIBLE
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(
|
||||
lpparam.classLoader,
|
||||
"updateState",
|
||||
iconState
|
||||
) {
|
||||
hideMobileTypeIcon(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun hideMobileTypeIcon(it: XC_MethodHook.MethodHookParam) {
|
||||
hasEnable("hide_mobile_type_icon") {
|
||||
if (isBigType) {
|
||||
(it.thisObject.getObjectField("mMobileType") as TextView).visibility =
|
||||
View.GONE
|
||||
(it.thisObject.getObjectField("mMobileTypeImage") as ImageView).visibility =
|
||||
View.GONE
|
||||
(it.thisObject.getObjectField("mMobileTypeSingle") as TextView).visibility =
|
||||
View.GONE
|
||||
} else {
|
||||
(it.thisObject.getObjectField("mMobileType") as TextView).visibility =
|
||||
View.INVISIBLE
|
||||
(it.thisObject.getObjectField("mMobileTypeImage") as ImageView).visibility =
|
||||
View.INVISIBLE
|
||||
(it.thisObject.getObjectField("mMobileTypeSingle") as TextView).visibility =
|
||||
View.INVISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.view.Gravity
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import cn.fkj233.ui.activity.dp2px
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
|
||||
class StatusBarBigMobileTypeIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
hasEnable("big_mobile_type_icon") {
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(
|
||||
lpparam.classLoader,
|
||||
"init"
|
||||
) {
|
||||
val StatusBarMobileView = it.thisObject as ViewGroup
|
||||
val context: Context = StatusBarMobileView.context
|
||||
val res: Resources = context.resources
|
||||
val mobile_container_left_ID: Int =
|
||||
res.getIdentifier("mobile_container_left", "id", "com.android.systemui")
|
||||
val mobile_left_mobile_inout_ID: Int = res.getIdentifier(
|
||||
"mobile_left_mobile_inout",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val mobile_container_right_ID: Int = res.getIdentifier(
|
||||
"mobile_container_right",
|
||||
"id",
|
||||
"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 =
|
||||
StatusBarMobileView.findViewById<ViewGroup>(mobile_container_right_ID)
|
||||
val RightParentLayout = mobile_container_right.parent as ViewGroup
|
||||
val mobile_container_right_Index =
|
||||
RightParentLayout.indexOfChild(mobile_container_left)
|
||||
RightParentLayout.addView(
|
||||
mobile_container_left,
|
||||
mobile_container_right_Index - 1
|
||||
)
|
||||
mobile_container_left_fl.topMargin = dp2px(context, 3f)
|
||||
mobile_container_left.layoutParams = mobile_container_left_fl
|
||||
val mobile_type = StatusBarMobileView.findViewById<TextView>(mobile_type_ID)
|
||||
mobile_type.setTextAppearance(TextAppearance_StatusBar_Carrier_ID)
|
||||
val mobile_type_fl = mobile_type.layoutParams as FrameLayout.LayoutParams
|
||||
mobile_type_fl.width = dp2px(context, 30f)
|
||||
mobile_type_fl.gravity = Gravity.CENTER or Gravity.START or Gravity.TOP
|
||||
mobile_type.layoutParams = mobile_type_fl
|
||||
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_left_mobile_inout_fl.width = dp2px(context, 8f)
|
||||
mobile_left_mobile_inout_fl.marginStart = dp2px(context, 16f)
|
||||
mobile_left_mobile_inout_fl.bottomMargin = dp2px(context, 3f)
|
||||
mobile_left_mobile_inout.layoutParams = mobile_left_mobile_inout_fl
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,4 +167,10 @@
|
||||
<string name="qs_custom_rows">Filas</string>
|
||||
<string name="qs_custom_columns">Columnas</string>
|
||||
<string name="qs_custom_rows_horizontal">Filas (horizontal)</string>
|
||||
<string name="status_bar_dual_row_network_speed">Velocidad de red en fila dual</string>
|
||||
<string name="status_bar_dual_row_network_speed_summary">Mostrar velocidad de subida y bajada</string>
|
||||
<string name="status_bar_network_speed">Velocidad de red en barra de estado</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="none">Ninguno</string>
|
||||
</resources>
|
||||
|
||||
@@ -161,4 +161,16 @@
|
||||
<string name="hide_icon">Masquer l\'icône</string>
|
||||
<string name="double_tap_to_sleep">Double tapper pour veille</string>
|
||||
<string name="home_double_tap_to_sleep_summary">Double-tapez l\'espace vide pour mettre en veille</string>
|
||||
<string name="old_quick_settings_panel">Vieux panneau de réglages rapide</string>
|
||||
<string name="old_qs_custom_switch">Lignes et colonnes personnalisés</string>
|
||||
<string name="qs_custom_columns_unexpanded">Colonnes (Inexpansé)</string>
|
||||
<string name="qs_custom_rows">Lignes</string>
|
||||
<string name="qs_custom_columns">Colonnes</string>
|
||||
<string name="qs_custom_rows_horizontal">Lignes (horizontal)</string>
|
||||
<string name="status_bar_dual_row_network_speed">Vitesse du réseau à double ligne</string>
|
||||
<string name="status_bar_dual_row_network_speed_summary">Affichage de download et upload en vitesse de réseau</string>
|
||||
<string name="status_bar_network_speed">Vitesse du réseau en barre d\'état</string>
|
||||
<string name="status_bar_network_speed_dual_row_size">Taille de double ligne (0: ne pas changer)</string>
|
||||
<string name="status_bar_network_speed_dual_row_icon">Icône de double ligne</string>
|
||||
<string name="none">Aucune</string>
|
||||
</resources>
|
||||
|
||||
@@ -173,4 +173,7 @@
|
||||
<string name="status_bar_network_speed_dual_row_size">双排大小(0:不更改)</string>
|
||||
<string name="status_bar_network_speed_dual_row_icon">双排图标</string>
|
||||
<string name="none">无</string>
|
||||
<string name="status_bar_network_speed_dual_row_gravity">双排对齐</string>
|
||||
<string name="left">左边</string>
|
||||
<string name="right">右边</string>
|
||||
</resources>
|
||||
|
||||
@@ -177,4 +177,8 @@
|
||||
<string name="status_bar_network_speed_dual_row_size">Dual row size (0: do not change)</string>
|
||||
<string name="status_bar_network_speed_dual_row_icon">Dual row icon</string>
|
||||
<string name="none">None</string>
|
||||
<string name="status_bar_network_speed_dual_row_gravity">Dual row align</string>
|
||||
<string name="left">Left</string>
|
||||
<string name="right">Right</string>
|
||||
<string name="big_mobile_type_icon">Big Mobile Type Icon</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user