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

Commit 6703e4ec authored by Michael Bestas's avatar Michael Bestas
Browse files

Allow changing screen-off animation (1/2)

* Allow enabling/disabling screen-off animation
* Allow selection between fade & crt effects if the device allows it

Change-Id: If6bb9afd7a753e1df013e88f7f39cea94e8fe565
parent 34f4a8f3
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -1913,11 +1913,19 @@ public final class Settings {
        public static final String BUTTON_BACKLIGHT_TIMEOUT = "button_backlight_timeout";

        /**
         * Whether to enable the electron beam animation when turning screen off
         *
         * @hide */
         * Control whether the screen off animation should be shown
         * @hide
         */
        public static final String SCREEN_OFF_ANIMATION = "screen_off_animation";

        /**
         * Control which animation to use when turning the screen off
         * 0 = electron beam
         * 1 = fade
         * @hide
         */
        public static final String SCREEN_ANIMATION_STYLE = "screen_animation_style";

        /**
         * Control whether the process CPU usage meter should be shown.
         *
+1 −5
Original line number Diff line number Diff line
@@ -1366,11 +1366,7 @@
        <item>353</item>
    </string-array>

    <!-- Values greater or equal to 0 will enable electronbeam screen-on
         animation with the specified delay (in milliseconds), -1 will disable the animation -->
    <integer name="config_screenOnAnimation">-1</integer>

    <!-- True will enable the electron beam screen-off animation. -->
    <!-- True will enable the screen-off animation. -->
    <bool name="config_screenOffAnimation">true</bool>

    <!-- Timeout in MS for how long you have to long-press the back key to
+1 −1
Original line number Diff line number Diff line
@@ -1854,7 +1854,7 @@
  <!-- Gesture Sensor -->
  <java-symbol type="bool" name="config_enableGestureService" />

  <!-- Electron Beam -->
  <!-- Screen off animation -->
  <java-symbol type="bool" name="config_screenOffAnimation" />

  <!-- Privacy Guard -->
+13 −12
Original line number Diff line number Diff line
@@ -237,7 +237,16 @@ final class DisplayPowerController {

    // True if we should fade the screen while turning it off, false if we should play
    // a stylish electron beam animation instead.
    private boolean mElectronBeamFadesConfig;
    private boolean mElectronBeamFadesConfig() {
        return Settings.System.getInt(mContext.getContentResolver(),
                Settings.System.SCREEN_ANIMATION_STYLE, 0) == 1;
    }

    // True if we should allow showing the screen-off animation
    private boolean useScreenOffAnimation() {
        return Settings.System.getInt(mContext.getContentResolver(),
                Settings.System.SCREEN_OFF_ANIMATION, 1) == 1;
    }

    // The pending power request.
    // Initially null until the first call to requestPowerState.
@@ -430,9 +439,6 @@ final class DisplayPowerController {
            updateAutomaticBrightnessSettings();
        }

        mElectronBeamFadesConfig = resources.getBoolean(
                com.android.internal.R.bool.config_animateScreenLights);

        if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) {
            mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
            if (mProximitySensor != null) {
@@ -789,7 +795,7 @@ final class DisplayPowerController {
                                if (mPowerState.getElectronBeamLevel() == 1.0f) {
                                    mPowerState.dismissElectronBeam();
                                } else if (mPowerState.prepareElectronBeam(
                                        mElectronBeamFadesConfig ?
                                        mElectronBeamFadesConfig() ?
                                                ElectronBeam.MODE_FADE :
                                                ElectronBeam.MODE_WARM_UP)) {
                                    mElectronBeamOnAnimator.start();
@@ -812,7 +818,7 @@ final class DisplayPowerController {
                            setScreenOn(false);
                            unblockScreenOn();
                        } else if (mPowerState.prepareElectronBeam(
                                mElectronBeamFadesConfig ?
                                mElectronBeamFadesConfig() ?
                                        ElectronBeam.MODE_FADE :
                                        ElectronBeam.MODE_COOL_DOWN)
                                && mPowerState.isScreenOn()
@@ -1514,9 +1520,4 @@ final class DisplayPowerController {
            updatePowerState();
        }
    };

    private boolean useScreenOffAnimation() {
        return Settings.System.getInt(mContext.getContentResolver(),
                Settings.System.SCREEN_OFF_ANIMATION, 1) == 1;
    }
}