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

Commit eb36b65c authored by Danny Baumann's avatar Danny Baumann
Browse files

Re-add lockscreen music controls toggle.

Change-Id: I70fb6c0d20caad7af01a45b4a9374eb107a554a3
parent 80d35e16
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2467,6 +2467,13 @@ public final class Settings {
         */
        public static final String LOCKSCREEN_TARGETS = "lockscreen_targets";

        /**
        * Whether music controls should be shown on the lockscreen if a supporting
        * music player is active.
        * @hide
        */
        public static final String LOCKSCREEN_MUSIC_CONTROLS = "lockscreen_music_controls";

        /**
         * @deprecated Use {@link android.provider.Settings.Global#LOW_BATTERY_SOUND}
         * instead
+6 −2
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ public class KeyguardHostView extends KeyguardViewBase {
    static final int TRANSPORT_VISIBLE = 2;

    private int mTransportState = TRANSPORT_GONE;
    private boolean mTransportShouldBeVisible;

    // Use this to debug all of keyguard
    public static boolean DEBUG = KeyguardViewMediator.DEBUG;
@@ -400,6 +401,9 @@ public class KeyguardHostView extends KeyguardViewBase {

        setBackButtonEnabled(false);

        mTransportShouldBeVisible = Settings.System.getIntForUser(mContext.getContentResolver(),
                Settings.System.LOCKSCREEN_MUSIC_CONTROLS, 1, UserHandle.USER_CURRENT) != 0;

        updateBackground();
        addDefaultWidgets();

@@ -1541,7 +1545,7 @@ public class KeyguardHostView extends KeyguardViewBase {
        final boolean showing = getWidgetPosition(R.id.keyguard_transport_control) != -1;
        final boolean visible = state == TRANSPORT_VISIBLE;
        final boolean shouldBeVisible = state == TRANSPORT_INVISIBLE && isMusicPlaying(state);
        if (!showing && (visible || shouldBeVisible)) {
        if (!showing && mTransportShouldBeVisible && (visible || shouldBeVisible)) {
            if (DEBUGXPORT) Log.v(TAG, "add transport");
            // insert to left of camera if it exists, otherwise after right-most widget
            int lastWidget = mAppWidgetContainer.getChildCount() - 1;
@@ -1551,7 +1555,7 @@ public class KeyguardHostView extends KeyguardViewBase {
                        lastWidget : lastWidget + 1;
            }
            mAppWidgetContainer.addWidget(getOrCreateTransportControl(), position);
        } else if (showing && state == TRANSPORT_GONE) {
        } else if (showing && (state == TRANSPORT_GONE || !mTransportShouldBeVisible)) {
            if (DEBUGXPORT) Log.v(TAG, "remove transport");
            mAppWidgetContainer.removeWidget(getOrCreateTransportControl());
            mTransportControl = null;