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

Commit 15181072 authored by Jorge Ruesga's avatar Jorge Ruesga Committed by Gerrit Code Review
Browse files

systemui: left hand navigation ring



Fix navigation ring position when navbar is set to left hand mode

Change-Id: I5a6fb634b8aafe90fa7fd18f35ce521f150556ce
Signed-off-by: default avatarJorge Ruesga <jorge@ruesga.com>
parent 5c6f6b13
Loading
Loading
Loading
Loading
+31 −9
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ public class SearchPanelCircleView extends FrameLayout {
    private float mOffset;
    private float mCircleSize, mLeftCircleSize, mRightCircleSize;
    private boolean mHorizontal;
    private boolean mLeftNavbar;
    private boolean mCircleHidden;
    private ImageView mLogo;
    private boolean mDraggedFarEnough;
@@ -332,7 +333,11 @@ public class SearchPanelCircleView extends FrameLayout {
        float t = (mStaticOffset - mOffset) / (float) mStaticOffset;
        if (!exitAnimationRunning) {
            if (mHorizontal) {
                if (mLeftNavbar) {
                    translationX -= t * mStaticOffset * 0.3f;
                } else {
                    translationX += t * mStaticOffset * 0.3f;
                }
            } else {
                translationY += t * mStaticOffset * 0.3f;
            }
@@ -358,7 +363,11 @@ public class SearchPanelCircleView extends FrameLayout {
        int left, top;
        float circleSize = useStaticSize ? mCircleMinSize : mRightCircleSize;
        if (mHorizontal) {
            if (mLeftNavbar) {
                left = (int) (circleSize / 2);
            } else {
                left = (int) (getWidth() - circleSize / 2 - offset);
            }
            top = (int) (getHeight() - circleSize) / 2;
            top = (int) ((top / 2) - (circleSize / 2));
        } else {
@@ -373,7 +382,11 @@ public class SearchPanelCircleView extends FrameLayout {
        int left, top;
        float circleSize = useStaticSize ? mCircleMinSize : mLeftCircleSize;
        if (mHorizontal) {
            if (mLeftNavbar) {
                left = (int) (circleSize / 2);
            } else {
                left = (int) (getWidth() - circleSize / 2 - offset);
            }
            top = (int) ((getHeight() / 4) - ((3 * circleSize) / 4));
            top = (int) (getHeight() - top - circleSize);
        } else {
@@ -388,7 +401,11 @@ public class SearchPanelCircleView extends FrameLayout {
        int left, top;
        float circleSize = useStaticSize ? mCircleMinSize : mCircleSize;
        if (mHorizontal) {
            if (mLeftNavbar) {
                left = (int) (mBaseMargin + offset - circleSize / 2);
            } else {
                left = (int) (getWidth() - circleSize / 2 - mBaseMargin - offset);
            }
            top = (int) ((getHeight() - circleSize) / 2);
        } else {
            left = (int) (getWidth() - circleSize) / 2;
@@ -398,11 +415,19 @@ public class SearchPanelCircleView extends FrameLayout {
    }

    public void setHorizontal(boolean horizontal) {
        startAbortAnimation(null);
        mHorizontal = horizontal;
        updateCircleRect(mStaticRect, mStaticOffset, true);
        updateLayout();
    }

    public void setLeftNavbar(boolean leftNavbar) {
        startAbortAnimation(null);
        mLeftNavbar = leftNavbar;
        updateCircleRect(mStaticRect, mStaticOffset, true);
        updateLayout();
    }

    public void setDragDistance(float distance) {
        if (!mAnimatingOut && (!mCircleHidden || mDraggedFarEnough)) {
            float circleSize = mCircleMinSize + rubberband(distance);
@@ -664,7 +689,7 @@ public class SearchPanelCircleView extends FrameLayout {
            return true;
        }
        if (mHorizontal) {
            return x <= rect.right &&
            return ((x <= rect.right && !mLeftNavbar) || (x >= rect.left && mLeftNavbar)) &&
                    (y >= rect.top - rect.height() / 2)
                    && (y <= rect.bottom + rect.height() / 2);
        } else {
@@ -677,17 +702,14 @@ public class SearchPanelCircleView extends FrameLayout {
    public int isIntersecting(MotionEvent event) {
        if (isRectConsideredActive(mCircleRect, event)) {
            mIntersectIndex = 1;
            return 1;
        } else if (isRectConsideredActive(mCircleRectLeft, event)) {
            mIntersectIndex = 0;
            return 0;
        } else if (isRectConsideredActive(mCircleRectRight, event)) {
            mIntersectIndex = 2;
            return 2;
        } else {
            mIntersectIndex = -1;
            return -1;
        }
        return mIntersectIndex;
    }

    public void initializeAdditionalTargets(SearchPanelView panelView) {
+8 −1
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ public class SearchPanelView extends FrameLayout implements StatusBarPanel,

    private int mThreshold;
    private boolean mHorizontal;
    private boolean mLeftNavbar;

    private boolean mLaunching;
    private boolean mDragging;
@@ -345,7 +346,8 @@ public class SearchPanelView extends FrameLayout implements StatusBarPanel,
                    mDragging = true;
                }
                if (mDragging) {
                    float offset = Math.max(mStartDrag - currentTouch, 0.0f);
                    float offset = Math.max(mHorizontal && mLeftNavbar
                            ? currentTouch - mStartTouch : mStartTouch - currentTouch, 0.0f);
                    mCircle.setDragDistance(offset);
                    int indexOfIntersect = mCircle.isIntersecting(event);
                    mDraggedFarEnough = indexOfIntersect != -1;
@@ -407,6 +409,11 @@ public class SearchPanelView extends FrameLayout implements StatusBarPanel,
        mCircle.setHorizontal(horizontal);
    }

    public void setLeftNavbar(boolean leftNavbar) {
        mLeftNavbar = leftNavbar;
        mCircle.setLeftNavbar(mLeftNavbar);
    }

    @Override
    public void onClick(View v) {
        if (mInEditMode) {
+5 −2
Original line number Diff line number Diff line
@@ -532,11 +532,14 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                }
            }

            if (mNavigationBarView != null) {
            boolean navLeftInLandscape = Settings.System.getIntForUser(resolver,
                    Settings.System.NAVBAR_LEFT_IN_LANDSCAPE, 0, UserHandle.USER_CURRENT) == 1;
            if (mNavigationBarView != null) {
                mNavigationBarView.setLeftInLandscape(navLeftInLandscape);
            }
            if (mSearchPanelView != null) {
                mSearchPanelView.setLeftNavbar(navLeftInLandscape);
            }

            // This method reads Settings.Secure.RECENTS_LONG_PRESS_ACTIVITY
            updateCustomRecentsLongPressHandler(false);