Skip to content

Commit

Permalink
Improve iOS batteries #92
Browse files Browse the repository at this point in the history
Signed-off-by: DHD2280 <[email protected]>
  • Loading branch information
DHD2280 committed Nov 29, 2024
1 parent 095c253 commit 2516faf
Showing 1 changed file with 11 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ public class BatteryStyleManager extends XposedMods {
private int mBatteryPercSize = 12;
private Class<?> DarkIconDispatcher = null;
private Class<?> DualToneHandler = null;
private View mQsBattery = null;
private final List<String> batteryCharging = new ArrayList<>() {{
add("battery_dash_charge_view");
add("battery_charge_icon");
Expand Down Expand Up @@ -295,16 +294,16 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th
QuickStatusBarHeader = findClass("com.android.systemui.qs.QuickStatusBarHeader", lpparam.classLoader);
}

hookAllMethods(QuickStatusBarHeader, "onFinishInflate", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
mQsBattery = (View) getObjectField(param.thisObject, "mBatteryView");
} catch (Throwable t) {
mQsBattery = null;
}
}
});
// hookAllMethods(QuickStatusBarHeader, "onFinishInflate", new XC_MethodHook() {
// @Override
// protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// try {
// mQsBattery = (View) getObjectField(param.thisObject, "mBatteryView");
// } catch (Throwable t) {
// mQsBattery = null;
// }
// }
// });

if (Build.VERSION.SDK_INT >= 34) {
hookBattery(lpparam); // OOS 14
Expand Down Expand Up @@ -408,16 +407,7 @@ public void onDarkChanged(@NotNull ArrayList<Rect> areas, float f, int i) {
int foregroundColor = (int) callMethod(dualToneHandler, "getFillColor", darkIntensity);
int backgroundColor = (int) callMethod(dualToneHandler, "getBackgroundColor", darkIntensity);

boolean isOS = (BatteryStyle == BATTERY_STYLE_LANDSCAPE_IOS_15 || BatteryStyle == BATTERY_STYLE_LANDSCAPE_IOS_16);
boolean nightMode = (c.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
int iosColorForeground = nightMode ? Color.WHITE : Color.BLACK;

if (mQsBattery != null && v == mQsBattery) {
updateIconColor(v, singleToneColor, isOS ? iosColorForeground : foregroundColor, isOS ? Color.parseColor("#ff4c4c4c") : backgroundColor);
} else {
updateIconColor(v, singleToneColor, foregroundColor, backgroundColor);
}
updateIconColor(v, singleToneColor, foregroundColor, backgroundColor);
updateBatteryViewValues(v);

}
Expand Down

0 comments on commit 2516faf

Please sign in to comment.