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

Commit 9248708f authored by Abhisek Devkota's avatar Abhisek Devkota Committed by Gerrit Code Review
Browse files

Merge "[2/2] Left handed navbar during landscape mode" into cm-11.0

parents b729d862 a6fb5ad9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2883,6 +2883,13 @@ public final class Settings {
         */
        public static final String NAV_BUTTONS = "nav_buttons";

        /**
         * Whether navigation bar is placed on the left side in landscape mode
         *
         * @hide
         */
        public static final String NAVBAR_LEFT_IN_LANDSCAPE = "navigation_bar_left";

        /**
        * Notification Power Widget - Custom Brightness Mode
        * @hide
+8 −1
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ public class NavigationBarView extends LinearLayout {
    int mBarSize;
    boolean mVertical;
    boolean mScreenOn;
    boolean mLeftInLandscape;

    boolean mShowMenu;
    int mDisabledFlags = 0;
@@ -222,6 +223,7 @@ public class NavigationBarView extends LinearLayout {
        mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size);
        mVertical = false;
        mShowMenu = false;
        mLeftInLandscape = false;
        mDelegateHelper = new DelegateViewHelper(this);

        getIcons(res);
@@ -593,6 +595,11 @@ public class NavigationBarView extends LinearLayout {
        return mVertical;
    }

    public void setLeftInLandscape(boolean leftInLandscape) {
        mLeftInLandscape = leftInLandscape;
        mDeadZone.setStartFromRight(leftInLandscape);
    }

    public void reorient() {
        int orientation = mContext.getResources().getConfiguration().orientation;
        mRotatedViews[Configuration.ORIENTATION_PORTRAIT].setVisibility(View.GONE);
@@ -610,6 +617,7 @@ public class NavigationBarView extends LinearLayout {
        updateSettings();

        mDeadZone = (DeadZone) mCurrentView.findViewById(R.id.deadzone);
        mDeadZone.setStartFromRight(mLeftInLandscape);

        // force the low profile & disabled states into compliance
        mBarTransitions.init(mVertical);
@@ -755,5 +763,4 @@ public class NavigationBarView extends LinearLayout {
        }
        pw.println();
    }

}
+8 −0
Original line number Diff line number Diff line
@@ -375,6 +375,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                    Settings.System.STATUS_BAR_CLOCK), false, this);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.STATUS_BAR_SIGNAL_TEXT), false, this);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.NAVBAR_LEFT_IN_LANDSCAPE), false, this);
            updateSettings();
        }

@@ -2981,6 +2983,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        mDockBatteryView.setShowPercent(showPercent);
        mDockBatteryController.onBatteryMeterShowPercent(showPercent);

        if (mNavigationBarView != null) {
            boolean navLeftInLandscape = Settings.System.getInt(resolver,
                    Settings.System.NAVBAR_LEFT_IN_LANDSCAPE, 0) == 1;
            mNavigationBarView.setLeftInLandscape(navLeftInLandscape);
        }

        mClockEnabled = Settings.System.getIntForUser(resolver,
                Settings.System.STATUS_BAR_CLOCK, 1, mCurrentUserId) != 0;
        updateClockVisibility();
+32 −3
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ public class DeadZone extends View {
    // mHold ms, then move back over the course of mDecay ms
    private int mHold, mDecay;
    private boolean mVertical;
    private boolean mStartFromRight;
    private long mLastPokeTime;

    private final Runnable mDebugFlash = new Runnable() {
@@ -73,6 +74,7 @@ public class DeadZone extends View {

        int index = a.getInt(R.styleable.DeadZone_orientation, -1);
        mVertical = (index == VERTICAL);
        mStartFromRight = false; // Assume deadzone is starting from the left side of the zone

        if (DEBUG)
            Slog.v(TAG, this + " size=[" + mSizeMin + "-" + mSizeMax + "] hold=" + mHold
@@ -98,7 +100,7 @@ public class DeadZone extends View {

    public void setFlashOnTouchCapture(boolean dbg) {
        mShouldFlash = dbg;
        mFlashFrac = 0f;
        mFlashFrac = dbg ? 1f : 0f;
        postInvalidate();
    }

@@ -117,7 +119,19 @@ public class DeadZone extends View {
                Slog.v(TAG, this + " ACTION_DOWN: " + event.getX() + "," + event.getY());
            }
            int size = (int) getSize(event.getEventTime());
            if ((mVertical && event.getX() < size) || event.getY() < size) {
            boolean isCaptured;
            if (mVertical && mStartFromRight) {
                // Landscape on the left side of the screen
                float pixelsFromRight = getWidth() - event.getX();
                isCaptured = 0 <= pixelsFromRight && pixelsFromRight < size;
            } else if (mVertical) {
                // Landscape
                isCaptured = event.getX() < size;
            } else {
                // Portrait
                isCaptured = event.getY() < size;
            }
            if (isCaptured) {
                if (CHATTY) {
                    Slog.v(TAG, "consuming errant click: (" + event.getX() + "," + event.getY() + ")");
                }
@@ -147,6 +161,11 @@ public class DeadZone extends View {
        return mFlashFrac;
    }

    public void setStartFromRight(boolean startFromRight) {
        mStartFromRight = startFromRight;
        if (mShouldFlash) postInvalidate();
    }

    @Override
    public void onDraw(Canvas can) {
        if (!mShouldFlash || mFlashFrac <= 0f) {
@@ -154,7 +173,17 @@ public class DeadZone extends View {
        }

        final int size = (int) getSize(SystemClock.uptimeMillis());
        can.clipRect(0, 0, mVertical ? size : can.getWidth(), mVertical ? can.getHeight() : size);
        if (mVertical && mStartFromRight) {
            // Landscape on the left side of the screen
            can.clipRect(can.getWidth() - size, 0, can.getWidth(), can.getHeight());
        } else if (mVertical) {
            // Landscape
            can.clipRect(0, 0, size, can.getHeight());
        } else {
            // Portrait
            can.clipRect(0, 0, can.getWidth(), size);
        }

        final float frac = DEBUG ? (mFlashFrac - 0.5f) + 0.5f : mFlashFrac;
        can.drawARGB((int) (frac * 0xFF), 0xDD, 0xEE, 0xAA);

+49 −7
Original line number Diff line number Diff line
@@ -277,6 +277,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    boolean mCanHideNavigationBar = false;
    boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side?
    boolean mNavigationBarOnBottom = true; // is the navigation bar on the bottom *right now*?
    boolean mNavigationBarLeftInLandscape = false; // Navigation bar left handed?
    int[] mNavigationBarHeightForRotation = new int[4];
    int[] mNavigationBarWidthForRotation = new int[4];

@@ -675,7 +676,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION), false, this,
                    UserHandle.USER_ALL);

            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.NAVBAR_LEFT_IN_LANDSCAPE), false, this,
                    UserHandle.USER_ALL);
            updateSettings();
        }

@@ -1493,6 +1496,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                mExpandedDesktopStyle = 0;
            }

            mNavigationBarLeftInLandscape = Settings.System.getInt(resolver,
                    Settings.System.NAVBAR_LEFT_IN_LANDSCAPE, 0) == 1;

            updateKeyAssignments();

            // Configure rotation lock.
@@ -2184,7 +2190,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                return R.anim.dock_top_enter;
            }
        } else if (win == mNavigationBar) {
            // This can be on either the bottom or the right.
            // This can be on either the bottom, left, or the right.
            if (mNavigationBarOnBottom) {
                if (transit == TRANSIT_EXIT
                        || transit == TRANSIT_HIDE) {
@@ -2196,10 +2202,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            } else {
                if (transit == TRANSIT_EXIT
                        || transit == TRANSIT_HIDE) {
                    return R.anim.dock_right_exit;
                    return mNavigationBarLeftInLandscape
                            ? R.anim.dock_left_exit : R.anim.dock_right_exit;
                } else if (transit == TRANSIT_ENTER
                        || transit == TRANSIT_SHOW) {
                    return R.anim.dock_right_enter;
                    return mNavigationBarLeftInLandscape
                            ? R.anim.dock_left_enter : R.anim.dock_right_enter;
                }
            }
        }
@@ -3269,10 +3277,43 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        // we can tell the app that it is covered by it.
                        mSystemBottom = mTmpNavigationFrame.top;
                    }
                } else if (mNavigationBarLeftInLandscape) {
                    // Landscape screen; nav bar goes to the left.
                    int right = overscanLeft + mNavigationBarWidthForRotation[displayRotation];
                    mTmpNavigationFrame.set(0, 0, right, displayHeight);
                    mStableLeft = mTmpNavigationFrame.right;
                    if (!expandedDesktopHidesNavigationBar()) {
                        mStableFullscreenLeft = mTmpNavigationFrame.right;
                    }
                    if (transientNavBarShowing
                            || (navVisible && expandedDesktopHidesNavigationBar())) {
                        mNavigationBarController.setBarShowingLw(true);
                    } else if (navVisible) {
                        mNavigationBarController.setBarShowingLw(true);
                        mDockLeft = mTmpNavigationFrame.right;
                        mRestrictedScreenLeft = mDockLeft;
                        mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft;
                        mRestrictedOverscanScreenLeft = mRestrictedScreenLeft;
                        mRestrictedOverscanScreenWidth = mDockRight
                                - mRestrictedOverscanScreenLeft;
                    } else {
                        // We currently want to hide the navigation UI.
                        mNavigationBarController.setBarShowingLw(false);
                    }

                    if (navVisible && !navTranslucent && !mNavigationBar.isAnimatingLw()
                            && !mNavigationBarController.wasRecentlyTranslucent()) {
                        // If the nav bar is currently requested to be visible,
                        // and not in the process of animating on or off, then
                        // we can tell the app that it is covered by it.
                        mSystemLeft = mTmpNavigationFrame.right;
                    }
                } else {
                    // Landscape screen; nav bar goes to the right.
                    int left = displayWidth - overscanRight - mNavigationBarWidthForRotation[displayRotation];
                    mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight);
                    int left = displayWidth - overscanRight
                            - mNavigationBarWidthForRotation[displayRotation];
                    mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight,
                            displayHeight);
                    mStableRight = mTmpNavigationFrame.left;
                    if (!expandedDesktopHidesNavigationBar()) {
                        mStableFullscreenRight = mTmpNavigationFrame.left;
@@ -3284,7 +3325,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        mNavigationBarController.setBarShowingLw(true);
                        mDockRight = mTmpNavigationFrame.left;
                        mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft;
                        mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft;
                        mRestrictedOverscanScreenWidth = mDockRight
                                - mRestrictedOverscanScreenLeft;
                    } else {
                        // We currently want to hide the navigation UI.
                        mNavigationBarController.setBarShowingLw(false);