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

Commit 861e0303 authored by Daniel Sandler's avatar Daniel Sandler Committed by Android Git Automerger
Browse files

am 2b207837: am 978f853d: Fix situations where the panel wouldn\'t descend.

* commit '2b207837':
  Fix situations where the panel wouldn't descend.
parents 7e6c9a7c 2b207837
Loading
Loading
Loading
Loading
+39 −7
Original line number Diff line number Diff line
@@ -19,6 +19,16 @@ public class PanelBar extends FrameLayout {
    private PanelHolder mPanelHolder;
    private ArrayList<PanelView> mPanels = new ArrayList<PanelView>();
    protected PanelView mTouchingPanel;
    private static final int STATE_CLOSED = 0;
    private static final int STATE_TRANSITIONING = 1;
    private static final int STATE_OPEN = 2;
    private int mState = STATE_CLOSED;
    private boolean mTracking;

    private void go(int state) {
        LOG("go state: %d -> %d", mState, state);
        mState = state;
    }

    public PanelBar(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -62,9 +72,12 @@ public class PanelBar extends FrameLayout {
            final int i = (int)(N * event.getX() / getMeasuredWidth());
            mTouchingPanel = mPanels.get(i);
            mPanelHolder.setSelectedPanel(mTouchingPanel);
            LOG("PanelBar.onTouch: ACTION_DOWN: panel %d", i);
            LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %d", mState, i);
            if (mState == STATE_CLOSED || mState == STATE_OPEN) {
                go(STATE_TRANSITIONING);
                onPanelPeeked();
            }
        }
        final boolean result = mTouchingPanel.getHandle().dispatchTouchEvent(event);
        return result;
    }
@@ -72,11 +85,13 @@ public class PanelBar extends FrameLayout {
    public void panelExpansionChanged(PanelView panel, float frac) {
        boolean fullyClosed = true;
        PanelView fullyOpenedPanel = null;
        LOG("panelExpansionChanged: start state=%d panel=%s", mState, panel.getName());
        for (PanelView pv : mPanels) {
            // adjust any other panels that may be partially visible
            if (pv.getExpandedHeight() > 0f) {
                fullyClosed = false;
                final float thisFrac = pv.getExpandedFraction();
                LOG("panel %s: f=%.1f", pv, thisFrac);
                LOG("panelExpansionChanged:  -> %s: f=%.1f", pv.getName(), thisFrac);
                if (panel == pv) {
                    if (thisFrac == 1f) fullyOpenedPanel = panel;
                } else {
@@ -84,11 +99,15 @@ public class PanelBar extends FrameLayout {
                }
            }
        }
        if (fullyOpenedPanel != null) onPanelFullyOpened(fullyOpenedPanel);
        if (fullyClosed) onAllPanelsCollapsed();
        else onPanelPeeked();
        if (fullyOpenedPanel != null && !mTracking) {
            go(STATE_OPEN);
            onPanelFullyOpened(fullyOpenedPanel);
        } else if (fullyClosed && !mTracking) {
            go(STATE_CLOSED);
            onAllPanelsCollapsed();
        }

        LOG("panelExpansionChanged: [%s%s ]", 
        LOG("panelExpansionChanged: end state=%d [%s%s ]", mState,
                (fullyOpenedPanel!=null)?" fullyOpened":"", fullyClosed?" fullyClosed":"");
    }

@@ -113,4 +132,17 @@ public class PanelBar extends FrameLayout {
    public void onPanelFullyOpened(PanelView openPanel) {
        LOG("onPanelFullyOpened");
    }

    public void onTrackingStarted(PanelView panel) {
        mTracking = true;
        if (panel != mTouchingPanel) {
            LOG("shouldn't happen: onTrackingStarted(%s) != mTouchingPanel(%s)",
                    panel, mTouchingPanel);
        }
    }

    public void onTrackingStopped(PanelView panel) {
        mTracking = false;
        panelExpansionChanged(panel, panel.getExpandedFraction());
    }
}
+15 −5
Original line number Diff line number Diff line
@@ -16,9 +16,9 @@ import com.android.systemui.R;
public class PanelView extends FrameLayout {
    public static final boolean DEBUG = false;
    public static final String TAG = PanelView.class.getSimpleName();
    public static final void LOG(String fmt, Object... args) {
    public final void LOG(String fmt, Object... args) {
        if (!DEBUG) return;
        Log.v(TAG, String.format(fmt, args));
        Log.v(TAG, (mViewName != null ? (mViewName + ": ") : "") + String.format(fmt, args));
    }

    public static final boolean BRAKES = false;
@@ -61,6 +61,7 @@ public class PanelView extends FrameLayout {

    private float mVel, mAccel;
    private int mFullHeight = 0;
    private String mViewName; 

    private void animationTick(long dtms) {
        if (!mTimeAnimator.isStarted()) {
@@ -69,7 +70,7 @@ public class PanelView extends FrameLayout {
            mTimeAnimator.setTimeListener(mAnimationCallback);

            mTimeAnimator.start();
        } else {
        } else if (dtms > 0) {
            final float dt = dtms * 0.001f;                  // ms -> s
            LOG("tick: v=%.2fpx/s dt=%.4fs", mVel, dt);
            LOG("tick: before: h=%d", (int) mExpandedHeight);
@@ -170,13 +171,16 @@ public class PanelView extends FrameLayout {
                public boolean onTouch(View v, MotionEvent event) {
                    final float y = event.getY();
                    final float rawY = event.getRawY();
                    LOG("handle.onTouch: y=%.1f rawY=%.1f off=%.1f", y, rawY, mTouchOffset);
                    LOG("handle.onTouch: a=%s y=%.1f rawY=%.1f off=%.1f",
                            MotionEvent.actionToString(event.getAction()),
                            y, rawY, mTouchOffset);
                    PanelView.this.getLocationOnScreen(mAbsPos);

                    switch (event.getAction()) {
                        case MotionEvent.ACTION_DOWN:
                            mVelocityTracker = VelocityTracker.obtain();
                            trackMovement(event);
                            mBar.onTrackingStarted(PanelView.this);
                            mTouchOffset = (rawY - mAbsPos[1]) - PanelView.this.getExpandedHeight();
                            break;

@@ -190,6 +194,7 @@ public class PanelView extends FrameLayout {

                        case MotionEvent.ACTION_UP:
                        case MotionEvent.ACTION_CANCEL:
                            mBar.onTrackingStopped(PanelView.this);
                            trackMovement(event);
                            mVelocityTracker.computeCurrentVelocity(1000);

@@ -241,6 +246,11 @@ public class PanelView extends FrameLayout {
    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        mViewName = getResources().getResourceName(getId());
    }

    public String getName() {
        return mViewName;
    }

    @Override