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

Commit e0566da2 authored by Jim Miller's avatar Jim Miller
Browse files

Fill in logic in WidgetPager to ignore music when reordering.

This moves music state management into KeyguardViewStateManager to allow
KeyguardWidgetPager access to it.

Fixes bug 7442977

Change-Id: I113b6d1c8848d60ae53b99e697b33e1e33d67853
parent bdca3c0a
Loading
Loading
Loading
Loading
+9 −14
Original line number Diff line number Diff line
@@ -65,11 +65,6 @@ public class KeyguardHostView extends KeyguardViewBase {
    // also referenced in SecuritySettings.java
    static final int APPWIDGET_HOST_ID = 0x4B455947;

    // transport control states
    private static final int TRANSPORT_GONE = 0;
    private static final int TRANSPORT_INVISIBLE = 1;
    private static final int TRANSPORT_VISIBLE = 2;

    private AppWidgetHost mAppWidgetHost;
    private KeyguardWidgetPager mAppWidgetContainer;
    private KeyguardSecurityViewFlipper mSecurityViewContainer;
@@ -89,7 +84,6 @@ public class KeyguardHostView extends KeyguardViewBase {
    private KeyguardViewStateManager mViewStateManager;

    private Rect mTempRect = new Rect();
    private int mTransportState = TRANSPORT_GONE;

    /*package*/ interface TransportCallback {
        void onListenerDetached();
@@ -914,7 +908,7 @@ public class KeyguardHostView extends KeyguardViewBase {
            // XXX keep view attached so we still get show/hide events from AudioManager
            KeyguardHostView.this.addView(mTransportControl);
            mTransportControl.setVisibility(View.GONE);
            mTransportState = TRANSPORT_GONE;
            mViewStateManager.setTransportState(KeyguardViewStateManager.TRANSPORT_GONE);
            mTransportControl.post(mSwitchPageRunnable);
        }
    }
@@ -1044,7 +1038,7 @@ public class KeyguardHostView extends KeyguardViewBase {
        saveStickyWidgetIndex();
        Parcelable superState = super.onSaveInstanceState();
        SavedState ss = new SavedState(superState);
        ss.transportState = mTransportState;
        ss.transportState = mViewStateManager.getTransportState();
        return ss;
    }

@@ -1057,7 +1051,7 @@ public class KeyguardHostView extends KeyguardViewBase {
        }
        SavedState ss = (SavedState) state;
        super.onRestoreInstanceState(ss.getSuperState());
        mTransportState = ss.transportState;
        mViewStateManager.setTransportState(ss.transportState);
        post(mSwitchPageRunnable);
    }

@@ -1071,13 +1065,14 @@ public class KeyguardHostView extends KeyguardViewBase {
    }

    private void showAppropriateWidgetPage() {
        boolean isMusicPlaying =
                mTransportControl.isMusicPlaying() || mTransportState == TRANSPORT_VISIBLE;
        int state = mViewStateManager.getTransportState();
        boolean isMusicPlaying = mTransportControl.isMusicPlaying()
                || state == KeyguardViewStateManager.TRANSPORT_VISIBLE;
        if (isMusicPlaying) {
            mTransportState = TRANSPORT_VISIBLE;
            mViewStateManager.setTransportState(KeyguardViewStateManager.TRANSPORT_VISIBLE);
            addTransportToWidgetPager();
        } else if (mTransportState == TRANSPORT_VISIBLE) {
            mTransportState = TRANSPORT_INVISIBLE;
        } else if (state == KeyguardViewStateManager.TRANSPORT_VISIBLE) {
            mViewStateManager.setTransportState(KeyguardViewStateManager.TRANSPORT_INVISIBLE);
        }
        int pageToShow = getAppropriateWidgetPage(isMusicPlaying);
        mAppWidgetContainer.setCurrentPage(pageToShow);
+15 −0
Original line number Diff line number Diff line
@@ -32,6 +32,13 @@ public class KeyguardViewStateManager implements SlidingChallengeLayout.OnChalle
    private static final int SCREEN_ON_RING_HINT_DELAY = 300;
    Handler mMainQueue = new Handler(Looper.myLooper());

    // transport control states
    static final int TRANSPORT_GONE = 0;
    static final int TRANSPORT_INVISIBLE = 1;
    static final int TRANSPORT_VISIBLE = 2;

    private int mTransportState = TRANSPORT_GONE;

    int mLastScrollState = SlidingChallengeLayout.SCROLL_STATE_IDLE;

    // Paged view state
@@ -214,4 +221,12 @@ public class KeyguardViewStateManager implements SlidingChallengeLayout.OnChalle

        mMainQueue.postDelayed(mHideHintsRunnable, SCREEN_ON_HINT_DURATION);
    }

    public void setTransportState(int state) {
        mTransportState = state;
    }

    public int getTransportState() {
        return mTransportState;
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -431,8 +431,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
        return true;
    }
    boolean isMusicWidgetVisible() {
        // TODO: Make proper test once we have music in the list
        return false;
        return mViewStateManager.getTransportState() != KeyguardViewStateManager.TRANSPORT_GONE;
    }
    boolean isCameraWidgetVisible() {
        return mCameraWidgetEnabled;