Skip to content

Commit

Permalink
fix: Statusbar battery style for Android 15
Browse files Browse the repository at this point in the history
  • Loading branch information
lingqiqi5211 committed Oct 6, 2024
1 parent 5ae73d9 commit 0fcf7b0
Showing 1 changed file with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
import com.sevtinge.hyperceiler.module.base.*
import com.sevtinge.hyperceiler.utils.devicesdk.*
import com.sevtinge.hyperceiler.utils.devicesdk.DisplayUtils.*
import de.robv.android.xposed.*

Expand Down Expand Up @@ -62,16 +63,24 @@ object BatteryStyle : BaseHook() {
}

override fun init() {
mBatteryMeterViewClass.methodFinder()
.filterByName("updateAll")
.single().createHook {
after { param ->
hookStatusBattery(param)
}
if (isMoreAndroidVersion(35)) {
mBatteryMeterViewClass.methodFinder()
.filterByName("updateAll\$1")
} else {
mBatteryMeterViewClass.methodFinder()
.filterByName("updateAll")
}.single().createHook {
after { param ->
hookStatusBattery(param)
}
}
}

private fun changeLocation(batteryView: LinearLayout, mBatteryPercentView: TextView, mBatteryPercentMarkView: TextView) {
private fun changeLocation(
batteryView: LinearLayout,
mBatteryPercentView: TextView,
mBatteryPercentMarkView: TextView
) {
batteryView.removeView(mBatteryPercentView)
batteryView.removeView(mBatteryPercentMarkView)
batteryView.addView(mBatteryPercentMarkView, 0)
Expand Down Expand Up @@ -125,7 +134,7 @@ object BatteryStyle : BaseHook() {

private fun hookStatusBattery(param: XC_MethodHook.MethodHookParam) {
val batteryView = param.thisObject as LinearLayout
val mBatteryPercentView=
val mBatteryPercentView =
XposedHelpers.getObjectField(param.thisObject, "mBatteryPercentView") as TextView
val mBatteryPercentMarkView =
XposedHelpers.getObjectField(param.thisObject, "mBatteryPercentMarkView") as TextView
Expand Down Expand Up @@ -153,7 +162,7 @@ object BatteryStyle : BaseHook() {
}

// 设置边距
setMargin(mBatteryPercentView, mBatteryPercentMarkView)
setMargin(mBatteryPercentView, mBatteryPercentMarkView)
}
}
}

0 comments on commit 0fcf7b0

Please sign in to comment.