frameworks/base
Revision | 437f0fc916ad62593fc542a94a26ab9e15e7e960 (tree) |
---|---|
Zeit | 2016-10-07 10:00:04 |
Autor | Zhao Wei Liew <zhaoweiliew@gmai...> |
Commiter | Zhao Wei Liew |
SystemUI: statusbar: Fix QS quick pulldown feature
Bring in the fixes from CM 13.
This commit squashes the following patches from CM 13.0:
68c40f32470d66e0f8973d33a4124a2181754fb0 SystemUI: fix QS quick pull down
477f58dc1413943926f2b4428f5873c0bb04dab8 SystemUI: hook up settings observer in notificationpanel
d2bec52c76a3bb2c9a7fa3533e40f782fa592826 SystemUI: Fix quick-quick settings pulldown settings
eb10bc20db37978413362250c8546ae7ed865077 Add left QS quick pulldown (1/3)
Change-Id: Ie122477261d96499c80640cf274d22fba6642a01
@@ -218,7 +218,7 @@ public class NotificationPanelView extends PanelView implements | ||
218 | 218 | private Handler mHandler = new Handler(); |
219 | 219 | private SettingsObserver mSettingsObserver; |
220 | 220 | |
221 | - private boolean mOneFingerQuickSettingsIntercept; | |
221 | + private int mOneFingerQuickSettingsIntercept; | |
222 | 222 | private boolean mDoubleTapToSleepEnabled; |
223 | 223 | private int mStatusBarHeaderHeight; |
224 | 224 | private GestureDetector mDoubleTapGesture; |
@@ -370,13 +370,14 @@ public class NotificationPanelView extends PanelView implements | ||
370 | 370 | } |
371 | 371 | |
372 | 372 | @Override |
373 | - public void onAttachedToWindow() { | |
373 | + protected void onAttachedToWindow() { | |
374 | + super.onAttachedToWindow(); | |
374 | 375 | mSettingsObserver.observe(); |
375 | - | |
376 | 376 | } |
377 | 377 | |
378 | 378 | @Override |
379 | - public void onDetachedFromWindow() { | |
379 | + protected void onDetachedFromWindow() { | |
380 | + super.onDetachedFromWindow(); | |
380 | 381 | mSettingsObserver.unobserve(); |
381 | 382 | } |
382 | 383 |
@@ -833,13 +834,7 @@ public class NotificationPanelView extends PanelView implements | ||
833 | 834 | && mQsExpansionEnabled) { |
834 | 835 | mTwoFingerQsExpandPossible = true; |
835 | 836 | } |
836 | - boolean twoFingerQsEvent = mTwoFingerQsExpandPossible | |
837 | - && (event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN | |
838 | - && event.getPointerCount() == 2); | |
839 | - boolean oneFingerQsOverride = mOneFingerQuickSettingsIntercept | |
840 | - && event.getActionMasked() == MotionEvent.ACTION_DOWN | |
841 | - && shouldQuickSettingsIntercept(event.getX(), event.getY(), -1, false); | |
842 | - if ((twoFingerQsEvent || oneFingerQsOverride) && isOpenQsEvent(event) | |
837 | + if (mTwoFingerQsExpandPossible && isOpenQsEvent(event) | |
843 | 838 | && event.getY(event.getActionIndex()) < mStatusBarMinHeight) { |
844 | 839 | MetricsLogger.count(mContext, COUNTER_PANEL_OPEN_QS, 1); |
845 | 840 | mQsExpandImmediate = true; |
@@ -874,7 +869,22 @@ public class NotificationPanelView extends PanelView implements | ||
874 | 869 | && (event.isButtonPressed(MotionEvent.BUTTON_SECONDARY) |
875 | 870 | || event.isButtonPressed(MotionEvent.BUTTON_TERTIARY)); |
876 | 871 | |
877 | - return twoFingerDrag || stylusButtonClickDrag || mouseButtonClickDrag; | |
872 | + final float w = getMeasuredWidth(); | |
873 | + final float x = event.getX(); | |
874 | + float region = w * 1.f / 4.f; // TODO overlay region fraction? | |
875 | + boolean showQsOverride = false; | |
876 | + | |
877 | + switch (mOneFingerQuickSettingsIntercept) { | |
878 | + case 1: // Right side pulldown | |
879 | + showQsOverride = isLayoutRtl() ? x < region : w - region < x; | |
880 | + break; | |
881 | + case 2: // Left side pulldown | |
882 | + showQsOverride = isLayoutRtl() ? w - region < x : x < region; | |
883 | + break; | |
884 | + } | |
885 | + showQsOverride &= mStatusBarState == StatusBarState.SHADE; | |
886 | + | |
887 | + return twoFingerDrag || showQsOverride || stylusButtonClickDrag || mouseButtonClickDrag; | |
878 | 888 | } |
879 | 889 | |
880 | 890 | private void handleQsDown(MotionEvent event) { |
@@ -1399,30 +1409,18 @@ public class NotificationPanelView extends PanelView implements | ||
1399 | 1409 | * @return Whether we should intercept a gesture to open Quick Settings. |
1400 | 1410 | */ |
1401 | 1411 | private boolean shouldQuickSettingsIntercept(float x, float y, float yDiff) { |
1402 | - return shouldQuickSettingsIntercept(x, y, yDiff, true); | |
1403 | - } | |
1404 | - | |
1405 | - /** | |
1406 | - * @return Whether we should intercept a gesture to open Quick Settings. | |
1407 | - */ | |
1408 | - private boolean shouldQuickSettingsIntercept(float x, float y, float yDiff, boolean useHeader) { | |
1409 | 1412 | if (!mQsExpansionEnabled || mCollapsedOnDown) { |
1410 | 1413 | return false; |
1411 | 1414 | } |
1412 | 1415 | View header = mKeyguardShowing ? mKeyguardStatusBar : mQsContainer.getHeader(); |
1413 | - boolean onHeader = useHeader && x >= mQsAutoReinflateContainer.getX() | |
1416 | + boolean onHeader = x >= mQsAutoReinflateContainer.getX() | |
1414 | 1417 | && x <= mQsAutoReinflateContainer.getX() + mQsAutoReinflateContainer.getWidth() |
1415 | 1418 | && y >= header.getTop() && y <= header.getBottom(); |
1416 | 1419 | |
1417 | - final float w = getMeasuredWidth(); | |
1418 | - float region = (w * (1.f/3.f)); // TODO overlay region fraction? | |
1419 | - final boolean showQsOverride = isLayoutRtl() ? (x < region) : (w - region < x) | |
1420 | - && mStatusBarState == StatusBarState.SHADE; | |
1421 | - | |
1422 | 1420 | if (mQsExpanded) { |
1423 | 1421 | return onHeader || (yDiff < 0 && isInQsArea(x, y)); |
1424 | 1422 | } else { |
1425 | - return onHeader || showQsOverride; | |
1423 | + return onHeader; | |
1426 | 1424 | } |
1427 | 1425 | } |
1428 | 1426 |
@@ -2438,7 +2436,7 @@ public class NotificationPanelView extends PanelView implements | ||
2438 | 2436 | public void update() { |
2439 | 2437 | ContentResolver resolver = mContext.getContentResolver(); |
2440 | 2438 | mOneFingerQuickSettingsIntercept = CMSettings.System.getInt( |
2441 | - resolver, CMSettings.System.STATUS_BAR_QUICK_QS_PULLDOWN, 1) == 1; | |
2439 | + resolver, CMSettings.System.STATUS_BAR_QUICK_QS_PULLDOWN, 1); | |
2442 | 2440 | mDoubleTapToSleepEnabled = CMSettings.System.getInt( |
2443 | 2441 | resolver, CMSettings.System.DOUBLE_TAP_SLEEP_GESTURE, 1) == 1; |
2444 | 2442 | } |