Skip to content

Commit

Permalink
AOD helper handling adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Chainfire committed Feb 19, 2021
1 parent 8f718c8 commit 1f56664
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ public void updateTSPRect(Rect rect, int overlayBottom) {
Slog.d("AOD_TSP", "Anim " + rect.toString() + " bottom:" + overlayBottom + " apply:" + apply);
if (apply) {
tspRect.set(rect);
tspOverlayBottom = overlayBottom;
if (overlayBottom > 0) tspOverlayBottom = overlayBottom;
spritePlayer.setTSPBlank(rect.height() == 0);
applyDimensions();
}
Expand Down
47 changes: 28 additions & 19 deletions app/src/main/java/eu/chainfire/holeylight/animation/Overlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -484,14 +484,10 @@ public void evaluate(boolean refreshAll, boolean isDelayed) {
if (!lastState || colorsChanged() || renderMode != lastMode || blackFill != lastBlackFill || doze != lastDoze) {
animation.setMode(renderMode, blackFill);
createOverlay();
if (settings.isHideAOD() && doze && allowHideAOD) {
animation.setHideAOD(true, settings.isHideAODFully());
AODControl.setAODEnabled(spritePlayer.getContext(), true, null);
} else {
animation.setHideAOD(spritePlayer.isTSPMode(renderMode), settings.isHideAODFully());
}
animation.setHideAOD(spritePlayer.isTSPMode(renderMode) || (settings.isHideAOD() && doze && allowHideAOD), settings.isHideAODFully());
animation.setDoze(doze);
animation.play(activeHide ? new int[] { Color.BLACK } : colors, settings.isUnholeyLightIcons() ? icons : new Drawable[0], false, (renderMode != lastMode));
if (colors.length > 0) AODControl.setAODEnabled(spritePlayer.getContext(), true, null);
lastColors = colors;
lastState = true;
lastMode = renderMode;
Expand All @@ -500,22 +496,35 @@ public void evaluate(boolean refreshAll, boolean isDelayed) {
}
} else {
if (lastState) {
if (spritePlayer.isTSPMode(lastMode)) {
animation.setHideAOD(false);
}
if (settings.isHideAOD()) {
animation.setHideAOD(false);
final boolean fVisible = visible;
final boolean fDoze = doze;
Runnable goAway = () -> {
if (lastState) {
if (spritePlayer.isTSPMode(lastMode)) {
animation.setHideAOD(false);
}
if (settings.isHideAOD()) {
animation.setHideAOD(false);
}
if (animation.isPlaying()) {
boolean immediately = !fVisible || kill || isDelayed || settings.isAODHelperControl();
animation.stop(immediately);
if (immediately) removeOverlay();
} else {
removeOverlay();
}
lastState = false;
lastDoze = fDoze;
}
};
if (doze && settings.isAODHelperControl()) {
animation.setHideAOD(true, settings.isHideAODFully());
AODControl.setAODEnabled(spritePlayer.getContext(), false, null);
}
if (animation.isPlaying()) {
boolean immediately = !visible || kill || isDelayed;
animation.stop(immediately);
if (immediately) removeOverlay();
pokeWakeLocks(500);
handler.postDelayed(goAway, 250);
} else {
removeOverlay();
goAway.run();
}
lastState = false;
lastDoze = doze;
}
}

Expand Down

0 comments on commit 1f56664

Please sign in to comment.