mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-12 03:11:18 +08:00
自定义移动类型文本
This commit is contained in:
@@ -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(
|
||||
SPUtils.getBoolean(
|
||||
activity,
|
||||
|
||||
@@ -40,6 +40,7 @@ object SystemUI: AppRegister() {
|
||||
DoubleLineNetworkSpeed, //双排网速
|
||||
StatusBarBigMobileTypeIcon, //大移动类型
|
||||
BatteryPercentage, //电量百分比
|
||||
CustomMobileTypeText, //自定义移动类型文本
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,4 +200,6 @@
|
||||
<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_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>
|
||||
|
||||
Reference in New Issue
Block a user