自定义移动类型文本

This commit is contained in:
LittleTurtle2333
2022-04-02 22:39:59 +08:00
parent 3aca588693
commit 1a15df5822
4 changed files with 92 additions and 0 deletions

View File

@@ -752,6 +752,73 @@ class SettingsActivity : MIUIActivity() {
) )
) )
) )
val customMobileTypeTextBinding = getDataBinding(
SPUtils.getBoolean(
activity,
"custom_mobile_type_text_switch",
false
)
) { view, flags, data ->
when (flags) {
1 -> (view as Switch).isEnabled = data as Boolean
2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE
}
}
add(
TextSummaryWithSwitchV(
TextSummaryV(
textId = R.string.custom_mobile_type_text_switch
),
SwitchV(
"custom_mobile_type_text_switch",
dataBindingSend = customMobileTypeTextBinding.bindingSend
)
)
)
add(
TextSummaryArrowV(
TextSummaryV(
textId = R.string.custom_mobile_type_text
) {
MIUIDialog(activity).apply {
setTitle(R.string.custom_mobile_type_text)
setEditText(
"${
OwnSP.ownSP.getString(
"custom_mobile_type_text", "5G"
)
}",
""
)
setLButton(textId = R.string.cancel) {
dismiss()
}
setRButton(textId = R.string.Done) {
if (getEditText().isNotEmpty()) {
try {
OwnSP.ownSP.edit().run {
putString(
"custom_mobile_type_text",
getEditText()
)
apply()
}
dismiss()
return@setRButton
} catch (_: Throwable) {
}
}
Toast.makeText(
activity,
R.string.input_error,
Toast.LENGTH_SHORT
).show()
}
show()
}
},dataBindingRecv = customMobileTypeTextBinding.binding.getRecv(2)
)
)
val bigMobileTypeIconBinding = getDataBinding( val bigMobileTypeIconBinding = getDataBinding(
SPUtils.getBoolean( SPUtils.getBoolean(
activity, activity,

View File

@@ -40,6 +40,7 @@ object SystemUI: AppRegister() {
DoubleLineNetworkSpeed, //双排网速 DoubleLineNetworkSpeed, //双排网速
StatusBarBigMobileTypeIcon, //大移动类型 StatusBarBigMobileTypeIcon, //大移动类型
BatteryPercentage, //电量百分比 BatteryPercentage, //电量百分比
CustomMobileTypeText, //自定义移动类型文本
) )
} }
} }

View File

@@ -0,0 +1,22 @@
package com.lt2333.simplicitytools.hook.app.systemui
import com.lt2333.simplicitytools.util.XSPUtils
import com.lt2333.simplicitytools.util.hasEnable
import com.lt2333.simplicitytools.util.hookAfterMethod
import com.lt2333.simplicitytools.util.hookBeforeMethod
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
object CustomMobileTypeText : HookRegister() {
override fun init() {
hasEnable("custom_mobile_type_text_switch") {
"com.android.systemui.statusbar.policy.MobileSignalController".hookAfterMethod(
getDefaultClassLoader(),
"getMobileTypeName",
Int::class.java
) {
it.result = XSPUtils.getString("custom_mobile_type_text","5G")
}
}
}
}

View File

@@ -200,4 +200,6 @@
<string name="clock_center_and_icon_left">Clock Center and Icon Left</string> <string name="clock_center_and_icon_left">Clock Center and Icon Left</string>
<string name="maximum_number_of_notification_icons">Maximum number of notification icons</string> <string name="maximum_number_of_notification_icons">Maximum number of notification icons</string>
<string name="maximum_number_of_notification_dots">Maximum number of notification dots</string> <string name="maximum_number_of_notification_dots">Maximum number of notification dots</string>
<string name="custom_mobile_type_text">Custom mobile type text</string>
<string name="custom_mobile_type_text_switch">Custom mobile type text switch</string>
</resources> </resources>