mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-12 19:31:17 +08:00
优化自定义媒体音量步数功能
This commit is contained in:
@@ -976,14 +976,33 @@ class SettingsActivity : MIUIActivity() {
|
||||
)
|
||||
Line()
|
||||
TitleText(resId = R.string.sound)
|
||||
Text(
|
||||
resId = R.string.media_volume_steps,
|
||||
val mediaVolumeStepsSwitchBinding = GetDataBinding(
|
||||
object : DefValue {
|
||||
override fun getValue(): Any {
|
||||
return getSP().getBoolean("media_volume_steps_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
|
||||
}
|
||||
}
|
||||
TextSummaryWithSwitch(
|
||||
TextSummaryV(
|
||||
textId = R.string.media_volume_steps_switch,
|
||||
tips = "${getString(R.string.take_effect_after_reboot)}\n${getString(R.string.media_volume_steps_summary)}"
|
||||
),
|
||||
SwitchV(
|
||||
"media_volume_steps_switch",
|
||||
dataBindingSend = mediaVolumeStepsSwitchBinding.bindingSend
|
||||
)
|
||||
)
|
||||
SeekBarWithText(
|
||||
"media_volume_steps",
|
||||
15,
|
||||
29,
|
||||
15
|
||||
15, dataBindingRecv = mediaVolumeStepsSwitchBinding.binding.getRecv(2)
|
||||
)
|
||||
}
|
||||
register("scope_other", getString(R.string.scope_other), false) {
|
||||
|
||||
@@ -5,8 +5,10 @@ import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
object SystemPropertiesHook : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
val mediaStepsSwitch = XSPUtils.getBoolean("media_volume_steps_switch", false)
|
||||
val mediaSteps = XSPUtils.getInt("media_volume_steps", 15)
|
||||
|
||||
"android.os.SystemProperties".hookBeforeMethod(
|
||||
getDefaultClassLoader(),
|
||||
"getInt",
|
||||
@@ -14,8 +16,9 @@ object SystemPropertiesHook : HookRegister() {
|
||||
Int::class.java
|
||||
) {
|
||||
when (it.args[0] as String) {
|
||||
"ro.config.media_vol_steps" -> it.result = XSPUtils.getInt("media_volume_steps",15)
|
||||
"ro.config.media_vol_steps" -> if (mediaStepsSwitch) it.result = mediaSteps
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user