Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b178c342 authored by Tyler Freeman's avatar Tyler Freeman
Browse files

fix(force invert): fix app not redrawing when Force Invert enabled

Sometimes, the app doesn't respond immediately when you turn on force
invert. This uses the same technique as High-contrast text to force
everything to redraw.

Bug: 282821643
Flag: android.view.accessibility.force_invert_color
Test: manual:
1. Activate force invert from Settings
2. Switch to a light theme app
3. The app should immediately redraw to be dark

Change-Id: I710ba56fe4ea4e98f1d6d59b4c3c8405dc3a77a7
parent 02d33275
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -2068,9 +2068,13 @@ public final class ViewRootImpl implements ViewParent,
        if (mAttachInfo.mThreadedRenderer == null) return;
        if (mAttachInfo.mThreadedRenderer.setForceDark(determineForceDarkType())) {
            // TODO: Don't require regenerating all display lists to apply this setting
            if (forceInvertColor()) {
                destroyAndInvalidate();
            } else {
                invalidateWorld(mView);
            }
        }
    }
    @UnsupportedAppUsage
    public View getView() {
@@ -11922,13 +11926,21 @@ public final class ViewRootImpl implements ViewParent,
        public void onHighTextContrastStateChanged(boolean enabled) {
            ThreadedRenderer.setHighContrastText(enabled);
            // Destroy Displaylists so they can be recreated with high contrast recordings
            destroyAndInvalidate();
        }
    }
    /**
     * Destroy Displaylists so they can be recreated with new recordings, in case you are changing
     * the way things are rendered (e.g. high contrast, force dark), then invalidate to trigger a
     * redraw.
     */
    private void destroyAndInvalidate() {
        destroyHardwareResources();
        // Schedule redraw, which will rerecord + redraw all text
        invalidate();
    }
    }
    /**
     * This class is an interface this ViewAncestor provides to the