Follow applied status bar tint

This commit is contained in:
ajp_anton
2026-06-07 07:25:13 +00:00
parent 6d42eb13d7
commit ebbfad2524
3 changed files with 26 additions and 6 deletions
@@ -12,6 +12,7 @@ import java.util.function.BooleanSupplier;
import se.ajpanton.statusbartweak.runtime.features.RuntimeContext; import se.ajpanton.statusbartweak.runtime.features.RuntimeContext;
import se.ajpanton.statusbartweak.runtime.hooks.ReflectionSupport; import se.ajpanton.statusbartweak.runtime.hooks.ReflectionSupport;
import se.ajpanton.statusbartweak.runtime.hooks.XposedHookSupport; import se.ajpanton.statusbartweak.runtime.hooks.XposedHookSupport;
import se.ajpanton.statusbartweak.runtime.render.StatusBarTintTarget;
final class DarkIconDispatcherGuard { final class DarkIconDispatcherGuard {
private final RuntimeContext runtimeContext; private final RuntimeContext runtimeContext;
@@ -51,6 +52,7 @@ final class DarkIconDispatcherGuard {
forceLightState(dispatcher); forceLightState(dispatcher);
} }
Object result = chain.proceed(); Object result = chain.proceed();
updateTintTarget(dispatcher);
refreshAllRoots.run(); refreshAllRoots.run();
return result; return result;
}); });
@@ -89,6 +91,26 @@ final class DarkIconDispatcherGuard {
} }
} }
private void updateTintTarget(Object dispatcher) {
Object intensity = ReflectionSupport.getFieldValue(dispatcher, "mDarkIntensity");
if (intensity instanceof Number number) {
StatusBarTintTarget.setDarkIcons(number.floatValue() > 0.5f);
return;
}
Object tint = ReflectionSupport.getFieldValue(dispatcher, "mIconTint");
if (tint instanceof Integer color) {
StatusBarTintTarget.setColor(isDarkColor(color) ? Color.BLACK : Color.WHITE);
}
}
private boolean isDarkColor(int color) {
int red = Color.red(color);
int green = Color.green(color);
int blue = Color.blue(color);
double luminance = 0.2126d * red + 0.7152d * green + 0.0722d * blue;
return luminance < 128d;
}
private State captureState(Object dispatcher) { private State captureState(Object dispatcher) {
return dispatcher != null return dispatcher != null
? new State( ? new State(
@@ -49,7 +49,6 @@ import se.ajpanton.statusbartweak.runtime.render.LockscreenCardsNotificationStri
import se.ajpanton.statusbartweak.runtime.notifications.NotificationActiveKeyStore; import se.ajpanton.statusbartweak.runtime.notifications.NotificationActiveKeyStore;
import se.ajpanton.statusbartweak.runtime.notifications.NotificationUnreadTracker; import se.ajpanton.statusbartweak.runtime.notifications.NotificationUnreadTracker;
import se.ajpanton.statusbartweak.runtime.render.OwnedIconHostManager; import se.ajpanton.statusbartweak.runtime.render.OwnedIconHostManager;
import se.ajpanton.statusbartweak.runtime.render.StatusBarTintTarget;
import se.ajpanton.statusbartweak.runtime.render.UnlockedIconSnapshotRenderController; import se.ajpanton.statusbartweak.runtime.render.UnlockedIconSnapshotRenderController;
import se.ajpanton.statusbartweak.runtime.render.UnlockedIconSnapshotRenderController.RenderResult; import se.ajpanton.statusbartweak.runtime.render.UnlockedIconSnapshotRenderController.RenderResult;
import se.ajpanton.statusbartweak.runtime.settings.RuntimeSettingsCache; import se.ajpanton.statusbartweak.runtime.settings.RuntimeSettingsCache;
@@ -570,11 +569,6 @@ final class StockLayoutCanvasController {
chain -> { chain -> {
List<Object> args = chain.getArgs(); List<Object> args = chain.getArgs();
Object result = chain.proceed(); Object result = chain.proceed();
if (args.size() >= 1
&& args.get(0) instanceof Boolean value
&& StatusBarTintTarget.setDarkIcons(value)) {
scheduleUnlockedAppearanceRefreshForAllRoots(true);
}
return result; return result;
}); });
} }
@@ -11,6 +11,10 @@ public final class StatusBarTintTarget {
public static boolean setDarkIcons(boolean darkIcons) { public static boolean setDarkIcons(boolean darkIcons) {
int nextColor = darkIcons ? Color.BLACK : Color.WHITE; int nextColor = darkIcons ? Color.BLACK : Color.WHITE;
return setColor(nextColor);
}
public static boolean setColor(int nextColor) {
if (color == nextColor) { if (color == nextColor) {
return false; return false;
} }