Follow applied status bar tint
This commit is contained in:
+22
@@ -12,6 +12,7 @@ import java.util.function.BooleanSupplier;
|
||||
import se.ajpanton.statusbartweak.runtime.features.RuntimeContext;
|
||||
import se.ajpanton.statusbartweak.runtime.hooks.ReflectionSupport;
|
||||
import se.ajpanton.statusbartweak.runtime.hooks.XposedHookSupport;
|
||||
import se.ajpanton.statusbartweak.runtime.render.StatusBarTintTarget;
|
||||
|
||||
final class DarkIconDispatcherGuard {
|
||||
private final RuntimeContext runtimeContext;
|
||||
@@ -51,6 +52,7 @@ final class DarkIconDispatcherGuard {
|
||||
forceLightState(dispatcher);
|
||||
}
|
||||
Object result = chain.proceed();
|
||||
updateTintTarget(dispatcher);
|
||||
refreshAllRoots.run();
|
||||
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) {
|
||||
return dispatcher != null
|
||||
? new State(
|
||||
|
||||
-6
@@ -49,7 +49,6 @@ import se.ajpanton.statusbartweak.runtime.render.LockscreenCardsNotificationStri
|
||||
import se.ajpanton.statusbartweak.runtime.notifications.NotificationActiveKeyStore;
|
||||
import se.ajpanton.statusbartweak.runtime.notifications.NotificationUnreadTracker;
|
||||
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.RenderResult;
|
||||
import se.ajpanton.statusbartweak.runtime.settings.RuntimeSettingsCache;
|
||||
@@ -570,11 +569,6 @@ final class StockLayoutCanvasController {
|
||||
chain -> {
|
||||
List<Object> args = chain.getArgs();
|
||||
Object result = chain.proceed();
|
||||
if (args.size() >= 1
|
||||
&& args.get(0) instanceof Boolean value
|
||||
&& StatusBarTintTarget.setDarkIcons(value)) {
|
||||
scheduleUnlockedAppearanceRefreshForAllRoots(true);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,6 +11,10 @@ public final class StatusBarTintTarget {
|
||||
|
||||
public static boolean setDarkIcons(boolean darkIcons) {
|
||||
int nextColor = darkIcons ? Color.BLACK : Color.WHITE;
|
||||
return setColor(nextColor);
|
||||
}
|
||||
|
||||
public static boolean setColor(int nextColor) {
|
||||
if (color == nextColor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user