mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-12 19:31:17 +08:00
新增大移动类型图标自定义
This commit is contained in:
@@ -498,32 +498,6 @@ class SettingsActivity : MIUIActivity() {
|
|||||||
menuButton.visibility = View.VISIBLE
|
menuButton.visibility = View.VISIBLE
|
||||||
return ArrayList<BaseView>().apply {
|
return ArrayList<BaseView>().apply {
|
||||||
add(TitleTextV(resId = R.string.statusbar))
|
add(TitleTextV(resId = R.string.statusbar))
|
||||||
add(
|
|
||||||
TextSummaryWithSwitchV(
|
|
||||||
TextSummaryV(
|
|
||||||
textId = R.string.big_mobile_type_icon
|
|
||||||
),
|
|
||||||
SwitchV("big_mobile_type_icon")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
add(
|
|
||||||
TextSummaryWithSwitchV(
|
|
||||||
TextSummaryV(
|
|
||||||
textId = R.string.hide_battery_percentage_icon,
|
|
||||||
tipsId = R.string.hide_battery_percentage_icon_summary
|
|
||||||
),
|
|
||||||
SwitchV("hide_battery_percentage_icon")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
add(
|
|
||||||
TextSummaryWithSwitchV(
|
|
||||||
TextSummaryV(
|
|
||||||
textId = R.string.remove_the_maximum_number_of_notification_icons,
|
|
||||||
tipsId = R.string.remove_the_maximum_number_of_notification_icons_summary
|
|
||||||
),
|
|
||||||
SwitchV("remove_the_maximum_number_of_notification_icons")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
add(
|
add(
|
||||||
TextSummaryWithSwitchV(
|
TextSummaryWithSwitchV(
|
||||||
TextSummaryV(
|
TextSummaryV(
|
||||||
@@ -725,6 +699,227 @@ class SettingsActivity : MIUIActivity() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
val big_mobile_type_icon_binding = getDataBinding(
|
||||||
|
SPUtils.getBoolean(
|
||||||
|
activity,
|
||||||
|
"big_mobile_type_icon",
|
||||||
|
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.big_mobile_type_icon
|
||||||
|
),
|
||||||
|
SwitchV(
|
||||||
|
"big_mobile_type_icon",
|
||||||
|
dataBindingSend = big_mobile_type_icon_binding.bindingSend
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
add(
|
||||||
|
TextSummaryWithSwitchV(
|
||||||
|
TextSummaryV(
|
||||||
|
textId = R.string.big_mobile_type_icon_bold
|
||||||
|
),
|
||||||
|
SwitchV("big_mobile_type_icon_bold", true),
|
||||||
|
dataBindingRecv = big_mobile_type_icon_binding.binding.getRecv(2)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
add(
|
||||||
|
TextSummaryArrowV(
|
||||||
|
TextSummaryV(
|
||||||
|
textId = R.string.big_mobile_type_icon_size,
|
||||||
|
onClickListener = {
|
||||||
|
MIUIDialog(activity).apply {
|
||||||
|
setTitle(R.string.big_mobile_type_icon_size)
|
||||||
|
setEditText(
|
||||||
|
"",
|
||||||
|
"${activity.getString(R.string.def)}12.5, ${activity.getString(R.string.current)}${
|
||||||
|
OwnSP.ownSP.getFloat(
|
||||||
|
"big_mobile_type_icon_size",
|
||||||
|
12.5f
|
||||||
|
)
|
||||||
|
}"
|
||||||
|
)
|
||||||
|
setLButton(textId = R.string.cancel) {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
setRButton(textId = R.string.Done) {
|
||||||
|
if (getEditText() != "") {
|
||||||
|
OwnSP.ownSP.edit().run {
|
||||||
|
putFloat(
|
||||||
|
"big_mobile_type_icon_size",
|
||||||
|
getEditText().toFloat()
|
||||||
|
)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
show()
|
||||||
|
}
|
||||||
|
}), dataBindingRecv = big_mobile_type_icon_binding.binding.getRecv(2)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
add(
|
||||||
|
TextSummaryArrowV(
|
||||||
|
TextSummaryV(
|
||||||
|
textId = R.string.big_mobile_type_icon_up_and_down_position
|
||||||
|
) {
|
||||||
|
MIUIDialog(activity).apply {
|
||||||
|
setTitle(R.string.big_mobile_type_icon_up_and_down_position)
|
||||||
|
setMessage("${activity.getString(R.string.range)} -15~15")
|
||||||
|
setEditText(
|
||||||
|
"",
|
||||||
|
"${activity.getString(R.string.def)}0, ${activity.getString(R.string.current)}${
|
||||||
|
OwnSP.ownSP.getInt(
|
||||||
|
"big_mobile_type_icon_up_and_down_position",
|
||||||
|
0
|
||||||
|
)
|
||||||
|
}"
|
||||||
|
)
|
||||||
|
setLButton(textId = R.string.cancel) {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
setRButton(textId = R.string.Done) {
|
||||||
|
if (getEditText().isNotEmpty()) {
|
||||||
|
try {
|
||||||
|
val value = getEditText().toInt()
|
||||||
|
if (value in (-15..15)) {
|
||||||
|
OwnSP.ownSP.edit().run {
|
||||||
|
putInt(
|
||||||
|
"big_mobile_type_icon_up_and_down_position",
|
||||||
|
value
|
||||||
|
)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
dismiss()
|
||||||
|
return@setRButton
|
||||||
|
}
|
||||||
|
} catch (_: Throwable) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Toast.makeText(
|
||||||
|
activity,
|
||||||
|
R.string.input_error,
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
show()
|
||||||
|
}
|
||||||
|
}, dataBindingRecv = big_mobile_type_icon_binding.binding.getRecv(2)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
add(
|
||||||
|
TextSummaryArrowV(
|
||||||
|
TextSummaryV(
|
||||||
|
textId = R.string.big_mobile_type_icon_left_and_right_margins
|
||||||
|
) {
|
||||||
|
MIUIDialog(activity).apply {
|
||||||
|
setTitle(R.string.big_mobile_type_icon_left_and_right_margins)
|
||||||
|
setMessage("${activity.getString(R.string.range)} -30~30")
|
||||||
|
setEditText(
|
||||||
|
"",
|
||||||
|
"${activity.getString(R.string.def)}0, ${activity.getString(R.string.current)}${
|
||||||
|
OwnSP.ownSP.getInt(
|
||||||
|
"big_mobile_type_icon_left_and_right_margins",
|
||||||
|
0
|
||||||
|
)
|
||||||
|
}"
|
||||||
|
)
|
||||||
|
setLButton(textId = R.string.cancel) {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
setRButton(textId = R.string.Done) {
|
||||||
|
if (getEditText().isNotEmpty()) {
|
||||||
|
try {
|
||||||
|
val value = getEditText().toInt()
|
||||||
|
if (value in (-30..30)) {
|
||||||
|
OwnSP.ownSP.edit().run {
|
||||||
|
putInt(
|
||||||
|
"big_mobile_type_icon_left_and_right_margins",
|
||||||
|
value
|
||||||
|
)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
dismiss()
|
||||||
|
return@setRButton
|
||||||
|
}
|
||||||
|
} catch (_: Throwable) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Toast.makeText(
|
||||||
|
activity,
|
||||||
|
R.string.input_error,
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
show()
|
||||||
|
}
|
||||||
|
}, dataBindingRecv = big_mobile_type_icon_binding.binding.getRecv(2)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
add(
|
||||||
|
TextSummaryWithSwitchV(
|
||||||
|
TextSummaryV(
|
||||||
|
textId = R.string.remove_the_maximum_number_of_notification_icons,
|
||||||
|
tipsId = R.string.remove_the_maximum_number_of_notification_icons_summary
|
||||||
|
),
|
||||||
|
SwitchV("remove_the_maximum_number_of_notification_icons")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
add(
|
||||||
|
TextSummaryArrowV(
|
||||||
|
TextSummaryV(
|
||||||
|
textId = R.string.battery_percentage_font_size,
|
||||||
|
onClickListener = {
|
||||||
|
MIUIDialog(activity).apply {
|
||||||
|
setTitle(R.string.battery_percentage_font_size)
|
||||||
|
setMessage(R.string.zero_do_no_change)
|
||||||
|
setEditText(
|
||||||
|
"",
|
||||||
|
"${activity.getString(R.string.current)}${
|
||||||
|
OwnSP.ownSP.getFloat(
|
||||||
|
"battery_percentage_font_size",
|
||||||
|
0f
|
||||||
|
)
|
||||||
|
}"
|
||||||
|
)
|
||||||
|
setLButton(textId = R.string.cancel) {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
setRButton(textId = R.string.Done) {
|
||||||
|
if (getEditText() != "") {
|
||||||
|
OwnSP.ownSP.edit().run {
|
||||||
|
putFloat(
|
||||||
|
"battery_percentage_font_size",
|
||||||
|
getEditText().toFloat()
|
||||||
|
)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
show()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
add(
|
||||||
|
TextSummaryWithSwitchV(
|
||||||
|
TextSummaryV(
|
||||||
|
textId = R.string.hide_battery_percentage_icon,
|
||||||
|
tipsId = R.string.hide_battery_percentage_icon_summary
|
||||||
|
),
|
||||||
|
SwitchV("hide_battery_percentage_icon")
|
||||||
|
)
|
||||||
|
)
|
||||||
add(LineV())
|
add(LineV())
|
||||||
add(TitleTextV(resId = R.string.status_bar_network_speed))
|
add(TitleTextV(resId = R.string.status_bar_network_speed))
|
||||||
add(
|
add(
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import android.view.ViewGroup
|
|||||||
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 com.lt2333.simplicitytools.util.XSPUtils
|
||||||
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 com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||||
@@ -18,6 +19,11 @@ import de.robv.android.xposed.callbacks.XC_LoadPackage
|
|||||||
|
|
||||||
|
|
||||||
class StatusBarBigMobileTypeIcon : IXposedHookLoadPackage {
|
class StatusBarBigMobileTypeIcon : IXposedHookLoadPackage {
|
||||||
|
val upAndDownPosition = XSPUtils.getInt("big_mobile_type_icon_up_and_down_position", 0)
|
||||||
|
val leftAndRightMargin = XSPUtils.getInt("big_mobile_type_icon_left_and_right_margins", 0)
|
||||||
|
val isBold = XSPUtils.getBoolean("big_mobile_type_icon_bold", true)
|
||||||
|
val size = XSPUtils.getFloat("big_mobile_type_icon_size", 12.5f)
|
||||||
|
|
||||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||||
hasEnable("big_mobile_type_icon") {
|
hasEnable("big_mobile_type_icon") {
|
||||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(
|
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(
|
||||||
@@ -63,10 +69,13 @@ class StatusBarBigMobileTypeIcon : IXposedHookLoadPackage {
|
|||||||
val newLinearLayoutLP = LinearLayout.LayoutParams(
|
val newLinearLayoutLP = LinearLayout.LayoutParams(
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT
|
LinearLayout.LayoutParams.MATCH_PARENT
|
||||||
)
|
).also {
|
||||||
|
|
||||||
|
}
|
||||||
val newLinearlayout = LinearLayout(context).also {
|
val newLinearlayout = LinearLayout(context).also {
|
||||||
it.layoutParams = newLinearLayoutLP
|
it.layoutParams = newLinearLayoutLP
|
||||||
it.id = mobile_container_left_ID
|
it.id = mobile_container_left_ID
|
||||||
|
it.setPadding(leftAndRightMargin, 0, leftAndRightMargin, 0)
|
||||||
}
|
}
|
||||||
XposedHelpers.setObjectField(it.thisObject, "mMobileLeftContainer", newLinearlayout)
|
XposedHelpers.setObjectField(it.thisObject, "mMobileLeftContainer", newLinearlayout)
|
||||||
RightParentLayout.addView(
|
RightParentLayout.addView(
|
||||||
@@ -86,10 +95,13 @@ class StatusBarBigMobileTypeIcon : IXposedHookLoadPackage {
|
|||||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||||
).also {
|
).also {
|
||||||
it.gravity = Gravity.CENTER_VERTICAL
|
it.gravity = Gravity.CENTER_VERTICAL
|
||||||
|
it.topMargin = upAndDownPosition
|
||||||
}
|
}
|
||||||
mobile_type.also {
|
mobile_type.also {
|
||||||
it.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12.5F)
|
it.setTextSize(TypedValue.COMPLEX_UNIT_DIP, size)
|
||||||
|
if (isBold) {
|
||||||
it.typeface = Typeface.DEFAULT_BOLD
|
it.typeface = Typeface.DEFAULT_BOLD
|
||||||
|
}
|
||||||
it.layoutParams = mobile_type_lp
|
it.layoutParams = mobile_type_lp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -182,4 +182,12 @@
|
|||||||
<string name="right">Right</string>
|
<string name="right">Right</string>
|
||||||
<string name="big_mobile_type_icon">Big Mobile Type Icon</string>
|
<string name="big_mobile_type_icon">Big Mobile Type Icon</string>
|
||||||
<string name="can_notification_slide">Make all notification can be slide to small window</string>
|
<string name="can_notification_slide">Make all notification can be slide to small window</string>
|
||||||
|
<string name="battery_percentage_font_size">Battery percentage font size</string>
|
||||||
|
<string name="zero_do_no_change">0: do not change</string>
|
||||||
|
<string name="big_mobile_type_icon_size">Big mobile type icon size</string>
|
||||||
|
<string name="big_mobile_type_icon_bold">Big mobile type icon bold</string>
|
||||||
|
<string name="big_mobile_type_icon_up_and_down_position">Big mobile type icon up and down position</string>
|
||||||
|
<string name="input_error">Input error</string>
|
||||||
|
<string name="range">Range: </string>
|
||||||
|
<string name="big_mobile_type_icon_left_and_right_margins">Big mobile type icon left and right margins</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user