diff options
author | Shuhao Wu <shuhao@shuhaowu.com> | 2014-12-23 16:30:14 +0000 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-10-26 02:34:23 -0700 |
commit | 2a2cc073b2b8918b5bd18c535f53de73d578db81 (patch) | |
tree | f08741d63774978c3ac5588e651b66e97eb55bc2 /packages/SystemUI/src/com | |
parent | b16a02f9a3648fc27de3f17884a5e880c44dd1c1 (diff) | |
download | frameworks_base-2a2cc073b2b8918b5bd18c535f53de73d578db81.zip frameworks_base-2a2cc073b2b8918b5bd18c535f53de73d578db81.tar.gz frameworks_base-2a2cc073b2b8918b5bd18c535f53de73d578db81.tar.bz2 |
Left handed navbar during landscape mode
This patch allows for the navbar to be moved to the left side of the
screen during landscape mode. Left handed people are more used to this
option.
This patch must go with another patch that changes
packages/apps/Settings
Screenshot: http://i.imgur.com/jWqJcEV.png
Change-Id: Ic95e3fda1f55efd2ec908c8d7226e638ec0ab80a
Expanded Desktop : Fix Left handed navbar during landscape mode
from http://review.cyanogenmod.org/#/c/57454
when you enable expanded desktop and left handed navbar.
you need to swipe from right edge to show navbar.
but this patch will change to swipe from left edge to show navbar.
Video avalible at http://youtu.be/rUy14LQj9iE
Patchset2 : change tab to whitespace
Patchset3 : remove \r after @override in PhoneWindowManager.java
Patchset4 : Update commit message
Patchset5 : Address code formating comments
Patchset6 : Whitespace
Altaf-Mahdi
Add left gesture for edge gesture service
Change-Id: I65a15c6f5e662e429a818484de6b71e81c7ae713
Diffstat (limited to 'packages/SystemUI/src/com')
3 files changed, 45 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index cbb686c..6c6e207 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -69,6 +69,7 @@ public class NavigationBarView extends LinearLayout { int mBarSize; boolean mVertical; boolean mScreenOn; + boolean mLeftInLandscape; boolean mShowMenu; int mDisabledFlags = 0; @@ -451,6 +452,11 @@ public class NavigationBarView extends LinearLayout { return mVertical; } + public void setLeftInLandscape(boolean leftInLandscape) { + mLeftInLandscape = leftInLandscape; + mDeadZone.setStartFromRight(leftInLandscape); + } + public void reorient() { final int rot = mDisplay.getRotation(); for (int i=0; i<4; i++) { @@ -463,6 +469,7 @@ public class NavigationBarView extends LinearLayout { getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener); mDeadZone = (DeadZone) mCurrentView.findViewById(R.id.deadzone); + mDeadZone.setStartFromRight(mLeftInLandscape); // force the low profile & disabled states into compliance mBarTransitions.init(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index e957ab8..b541416 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -418,6 +418,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mAutomaticBrightness = mode != Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL; mBrightnessControl = Settings.System.getInt( resolver, Settings.System.STATUS_BAR_BRIGHTNESS_CONTROL, 0) == 1; + + if (mNavigationBarView != null) { + boolean navLeftInLandscape = Settings.System.getInt(resolver, + Settings.System.NAVBAR_LEFT_IN_LANDSCAPE, 0) == 1; + mNavigationBarView.setLeftInLandscape(navLeftInLandscape); + } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java index 6eb88be..9864a0a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java @@ -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 @@ -100,6 +102,7 @@ public class DeadZone extends View { mShouldFlash = dbg; mFlashFrac = 0f; postInvalidate(); + mFlashFrac = dbg ? 1f : 0f; } // I made you a touch event... @@ -117,7 +120,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 +162,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 +174,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); |