Permalink
Browse files

SystemUI: add quick settings pull down with one finger

Squashed:
SystemUI: fix right hand side gestures on lockscreen
CyanogenMod/android_frameworks_base@5ff043d

SystemUI: add Settings.System toggle for quick-quick settings pulldown
CyanogenMod/android_frameworks_base@50eab7e

Logic is currently set to use 1/3 of right hand side of the statusbar to
trigger a quick settings quick pull down, quickly.

Change-Id: I3f536496f724f07d2419a5b2db5fa8f8261609e7
Signed-off-by: Roman Birg <roman@cyngn.com>

* Adapted for Marshmallow by @KreAch3R
TeamTwisted/platform_frameworks_base@9279f83

SystemUI: Reduce activation area a bit of quick pulldown

SlimRoms/frameworks_base@b661a10
Change-Id: I06b3a50982930491c6fd4e70ceda3b1ceee28f87
  • Loading branch information...
romanbb authored and akhilnarang committed Nov 10, 2014
1 parent 71fddd8 commit ab80fac14affaca736d577ed1678604bb37cb78f
@@ -4388,6 +4388,12 @@ public boolean validate(String value) {
*/
public static final String DND_WHEN_CALL = "dnd_when_call";
/** Whether to allow one finger quick settings expansion on the right side of the statusbar.
*
* @hide
*/
public static final String STATUS_BAR_QUICK_QS_PULLDOWN = "status_bar_quick_qs_pulldown";
/**
* Whether to show QS footer warnings
* @hide
@@ -22,13 +22,18 @@
import android.animation.ValueAnimator;
import android.app.ActivityManager;
import android.app.StatusBarManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Handler;
import android.provider.Settings;
import android.util.AttributeSet;
import android.util.MathUtils;
import android.view.MotionEvent;
@@ -181,6 +186,10 @@
private boolean mQsTouchAboveFalsingThreshold;
private int mQsFalsingThreshold;
private Handler mHandler = new Handler();
private SettingsObserver mSettingsObserver;
private boolean mOneFingerQuickSettingsIntercept;
private float mKeyguardStatusBarAnimateAlpha = 1f;
private int mOldLayoutDirection;
private HeadsUpTouchHelper mHeadsUpTouchHelper;
@@ -262,6 +271,19 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom,
mNotificationStackScroller.setQsContainer(mQsContainer);
}
});
mSettingsObserver = new SettingsObserver(mHandler);
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
mSettingsObserver.observe();
}
@Override
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
mSettingsObserver.unobserve();
}
@Override
@@ -815,6 +837,10 @@ private boolean isOpenQsEvent(MotionEvent event) {
final int pointerCount = event.getPointerCount();
final int action = event.getActionMasked();
final boolean oneFingerDrag = action == MotionEvent.ACTION_DOWN
&& mOneFingerQuickSettingsIntercept && shouldQuickSettingsIntercept
(event.getX(), event.getY(), -1, false);
final boolean twoFingerDrag = action == MotionEvent.ACTION_POINTER_DOWN
&& pointerCount == 2;
@@ -826,7 +852,7 @@ private boolean isOpenQsEvent(MotionEvent event) {
&& (event.isButtonPressed(MotionEvent.BUTTON_SECONDARY)
|| event.isButtonPressed(MotionEvent.BUTTON_TERTIARY));
return twoFingerDrag || stylusButtonClickDrag || mouseButtonClickDrag;
return oneFingerDrag || twoFingerDrag || stylusButtonClickDrag || mouseButtonClickDrag;
}
private void handleQsDown(MotionEvent event) {
@@ -1352,17 +1378,30 @@ public void onAnimationEnd(Animator animation) {
* @return Whether we should intercept a gesture to open Quick Settings.
*/
private boolean shouldQuickSettingsIntercept(float x, float y, float yDiff) {
if (!mQsExpansionEnabled || mCollapsedOnDown) {
return shouldQuickSettingsIntercept(x, y, yDiff, true);
}
/**
* @return Whether we should intercept a gesture to open Quick Settings.
*/
private boolean shouldQuickSettingsIntercept(float x, float y, float yDiff, boolean useHeader) {
if (!mQsExpansionEnabled) {
return false;
}
View header = mKeyguardShowing ? mKeyguardStatusBar : mQsContainer.getHeader();
boolean onHeader = x >= mQsAutoReinflateContainer.getX()
boolean onHeader = useHeader && x >= mQsAutoReinflateContainer.getX()
&& x <= mQsAutoReinflateContainer.getX() + mQsAutoReinflateContainer.getWidth()
&& y >= header.getTop() && y <= header.getBottom();
final float w = (header.getX() + header.getWidth());
float region = (w * (1.f/4.f)); // TODO overlay region fraction?
boolean showQsOverride = isLayoutRtl() ? (x < region) : (w - region < x);
if (mQsExpanded) {
return onHeader || (yDiff < 0 && isInQsArea(x, y));
} else {
return onHeader;
return onHeader || (showQsOverride && mStatusBarState == StatusBarState.SHADE);
}
}
@@ -2352,4 +2391,38 @@ private boolean isForegroundApp(String pkgName) {
public void setGroupManager(NotificationGroupManager groupManager) {
mGroupManager = groupManager;
}
class SettingsObserver extends ContentObserver {
SettingsObserver(Handler handler) {
super(handler);
}
void observe() {
ContentResolver resolver = mContext.getContentResolver();
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.STATUS_BAR_QUICK_QS_PULLDOWN), false, this);
update();
}
void unobserve() {
ContentResolver resolver = mContext.getContentResolver();
resolver.unregisterContentObserver(this);
}
@Override
public void onChange(boolean selfChange) {
update();
}
@Override
public void onChange(boolean selfChange, Uri uri) {
update();
}
public void update() {
ContentResolver resolver = mContext.getContentResolver();
mOneFingerQuickSettingsIntercept = Settings.System.getInt(
resolver, Settings.System.STATUS_BAR_QUICK_QS_PULLDOWN, 1) == 1;
}
}
}

0 comments on commit ab80fac

Please sign in to comment.