summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Selim Cinek <cinek@google.com> 2019-04-16 17:25:06 -0700
committer Selim Cinek <cinek@google.com> 2019-04-25 16:54:58 -0700
commit09f17b7988a99972ac8abf16c44abf02c4637f94 (patch)
tree55572411b1005a8f073af9637a473531b689c1e5
parent07806b3d78feed97f6631b151fe4ae03f57a497f (diff)
Minor adjustments to the edge back gesture
The arrow now comes out a bit above the finger instead of right on it. This is also a preparation for a larger back arrow redesign Bug: 130682266 Test: atest SystemUITests Change-Id: I58c80fc939934b185929f9b0245999ec0902d652
-rw-r--r--packages/SystemUI/res/values/dimens.xml4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java22
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarEdgePanel.java49
3 files changed, 65 insertions, 10 deletions
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index df6bc20bbad8..a1ae95250565 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -45,6 +45,10 @@
<dimen name="navigation_edge_panel_height">52dp</dimen>
<!-- The threshold to drag to trigger the edge action -->
<dimen name="navigation_edge_action_drag_threshold">16dp</dimen>
+ <!-- The minimum display position of the arrow on the screen -->
+ <dimen name="navigation_edge_arrow_min_y">64dp</dimen>
+ <!-- The amount by which the arrow is shifted to avoid the finger-->
+ <dimen name="navigation_edge_finger_offset">48dp</dimen>
<!-- Luminance threshold to determine black/white contrast for the navigation affordances -->
<item name="navigation_luminance_threshold" type="dimen" format="float">0.5</item>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java
index 9b3f05e3e8d3..066efe49fa27 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java
@@ -126,6 +126,12 @@ public class EdgeBackGestureHandler implements DisplayListener {
private final float mTouchSlop;
// Minimum distance to move so that is can be considerd as a back swipe
private final float mSwipeThreshold;
+ // The threshold where the touch needs to be at most, such that the arrow is displayed above the
+ // finger, otherwise it will be below
+ private final int mMinArrowPosition;
+ // The amount by which the arrow is shifted to avoid the finger
+ private final int mFingerOffset;
+
private final int mNavBarHeight;
@@ -163,6 +169,9 @@ public class EdgeBackGestureHandler implements DisplayListener {
mSwipeThreshold = res.getDimension(R.dimen.navigation_edge_action_drag_threshold);
mNavBarHeight = res.getDimensionPixelSize(R.dimen.navigation_bar_frame_height);
+ mMinArrowPosition = res.getDimensionPixelSize(
+ R.dimen.navigation_edge_arrow_min_y);
+ mFingerOffset = res.getDimensionPixelSize(R.dimen.navigation_edge_finger_offset);
}
/**
@@ -291,7 +300,7 @@ public class EdgeBackGestureHandler implements DisplayListener {
// Verify if this is in within the touch region and we aren't in immersive mode, and
// either the bouncer is showing or the notification panel is hidden
int stateFlags = mOverviewProxyService.getSystemUiStateFlags();
- mIsOnLeftEdge = ev.getX() < mEdgeWidth;
+ mIsOnLeftEdge = ev.getX() <= mEdgeWidth;
mAllowGesture = (stateFlags & SYSUI_STATE_NAV_BAR_HIDDEN) == 0
&& ((stateFlags & SYSUI_STATE_BOUNCER_SHOWING) == SYSUI_STATE_BOUNCER_SHOWING
|| (stateFlags & SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED) == 0)
@@ -301,9 +310,7 @@ public class EdgeBackGestureHandler implements DisplayListener {
? (Gravity.LEFT | Gravity.TOP)
: (Gravity.RIGHT | Gravity.TOP);
mEdgePanel.setIsLeftPanel(mIsOnLeftEdge);
- mEdgePanelLp.y = MathUtils.constrain(
- (int) (ev.getY() - mEdgePanelLp.height / 2),
- 0, mDisplaySize.y);
+ mEdgePanelLp.y = positionEdgePanelonDown(ev.getY());
mWm.updateViewLayout(mEdgePanel, mEdgePanelLp);
mDownPoint.set(ev.getX(), ev.getY());
@@ -350,6 +357,13 @@ public class EdgeBackGestureHandler implements DisplayListener {
}
}
+ private int positionEdgePanelonDown(float touchY) {
+ float position = touchY - mFingerOffset;
+ position = Math.max(position, mMinArrowPosition);
+ position = (position - mEdgePanelLp.height / 2.0f);
+ return MathUtils.constrain((int) position, 0, mDisplaySize.y);
+ }
+
@Override
public void onDisplayAdded(int displayId) { }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarEdgePanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarEdgePanel.java
index 86b53445468c..fefc360c8497 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarEdgePanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarEdgePanel.java
@@ -24,10 +24,12 @@ import android.os.SystemClock;
import android.os.VibrationEffect;
import android.util.FloatProperty;
import android.util.MathUtils;
+import android.view.ContextThemeWrapper;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
import android.view.View;
+import com.android.settingslib.Utils;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.VibratorHelper;
@@ -35,9 +37,6 @@ import com.android.systemui.statusbar.VibratorHelper;
public class NavigationBarEdgePanel extends View {
// TODO: read from resources once drawing is finalized.
- private static final boolean SHOW_PROTECTION_STROKE = true;
- private static final int PROTECTION_COLOR = 0xffc0c0c0;
- private static final int STROKE_COLOR = 0xffe5e5e5;
private static final int PROTECTION_WIDTH_PX = 4;
private static final int BASE_EXTENT = 32;
private static final int ARROW_HEIGHT_DP = 32;
@@ -65,6 +64,15 @@ public class NavigationBarEdgePanel extends View {
private final float mSwipeThreshold;
+ private boolean mIsDark = false;
+ private boolean mShowProtection = false;
+ private int mProtectionColorLight;
+ private int mArrowColorLight;
+ private int mProtectionColorDark;
+ private int mArrowColorDark;
+ private int mProtectionColor;
+ private int mArrowColor;
+
private boolean mIsLeftPanel;
private float mStartX;
@@ -128,14 +136,13 @@ public class NavigationBarEdgePanel extends View {
mPaint.setStrokeWidth(mStrokeThickness);
mPaint.setStrokeCap(Paint.Cap.ROUND);
- mPaint.setColor(STROKE_COLOR);
mPaint.setAntiAlias(true);
mProtectionPaint.setStrokeWidth(mStrokeThickness + PROTECTION_WIDTH_PX);
mProtectionPaint.setStrokeCap(Paint.Cap.ROUND);
- mProtectionPaint.setColor(PROTECTION_COLOR);
mProtectionPaint.setAntiAlias(true);
+ loadColors(context);
// Both panels arrow point the same way
mArrowsPointLeft = getLayoutDirection() == LAYOUT_DIRECTION_LTR;
@@ -144,6 +151,36 @@ public class NavigationBarEdgePanel extends View {
setVisibility(GONE);
}
+ private void loadColors(Context context) {
+ final int dualToneDarkTheme = Utils.getThemeAttr(context, R.attr.darkIconTheme);
+ final int dualToneLightTheme = Utils.getThemeAttr(context, R.attr.lightIconTheme);
+ Context lightContext = new ContextThemeWrapper(context, dualToneLightTheme);
+ Context darkContext = new ContextThemeWrapper(context, dualToneDarkTheme);
+ mArrowColorLight = Utils.getColorAttrDefaultColor(lightContext, R.attr.singleToneColor);
+ mArrowColorDark = Utils.getColorAttrDefaultColor(darkContext, R.attr.singleToneColor);
+ mProtectionColorDark = mArrowColorLight;
+ mProtectionColorLight = mArrowColorDark;
+ updateIsDark(false /* animate */);
+ }
+
+ private void updateIsDark(boolean animate) {
+ mArrowColor = mIsDark ? mArrowColorDark : mArrowColorLight;
+ mProtectionColor = mIsDark ? mProtectionColorDark : mProtectionColorLight;
+ mProtectionPaint.setColor(mProtectionColor);
+ mPaint.setColor(mArrowColor);
+ // TODO: add animation
+ }
+
+ public void setIsDark(boolean isDark, boolean animate) {
+ mIsDark = isDark;
+ updateIsDark(animate);
+ }
+
+ public void setShowProtection(boolean showProtection) {
+ mShowProtection = showProtection;
+ invalidate();
+ }
+
public void setIsLeftPanel(boolean isLeftPanel) {
mIsLeftPanel = isLeftPanel;
}
@@ -160,7 +197,7 @@ public class NavigationBarEdgePanel extends View {
float outsideX = mArrowsPointLeft ? animatedOffset : 0;
float middleX = mArrowsPointLeft ? 0 : animatedOffset;
- if (SHOW_PROTECTION_STROKE) {
+ if (mShowProtection) {
canvas.drawLine(outsideX, 0, middleX, mHeight * 0.5f, mProtectionPaint);
canvas.drawLine(middleX, mHeight * 0.5f, outsideX, mHeight, mProtectionPaint);
}