自定义移动类型文本

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(
SPUtils.getBoolean(
activity,