summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@android.com>2011-08-25 14:35:53 -0700
committerDaniel Sandler <dsandler@android.com>2011-08-25 14:35:53 -0700
commitdc940eaa67db0108f8a8629826dbb3c5c7d779e9 (patch)
tree0b1f514355e8ecce8197df00325fe141fb02cb7c /packages
parent12bde60b39affbfdcb7ef6317e0a5f99c3f41b10 (diff)
downloadframeworks_base-dc940eaa67db0108f8a8629826dbb3c5c7d779e9.zip
frameworks_base-dc940eaa67db0108f8a8629826dbb3c5c7d779e9.tar.gz
frameworks_base-dc940eaa67db0108f8a8629826dbb3c5c7d779e9.tar.bz2
Scale windowshade gesture parameters for screen density.
This has been broken since 2.0 but we didn't really notice until now. Flinging the windowshade should now feel less janky (the window's motion once flung will be more continuous with your finger motion while flinging). Bug: 5210198 Change-Id: Ieae0cabf5def46004f98a6dcb2337b2648f5e9ab
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/res/values/dimens.xml24
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java63
2 files changed, 73 insertions, 14 deletions
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 6db5fc4..f633825 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -63,4 +63,28 @@
<!-- thickness (height) of dividers between each notification row -->
<dimen name="notification_divider_height">1dp</dimen>
+
+ <!-- Notification drawer tuning parameters (phone UI) -->
+ <!-- Initial velocity of the shade when expanding on its own -->
+ <dimen name="self_expand_velocity">2000dp</dimen>
+ <!-- Initial velocity of the shade when collapsing on its own -->
+ <dimen name="self_collapse_velocity">2000dp</dimen>
+ <!-- Minimum final velocity of gestures interpreted as expand requests -->
+ <dimen name="fling_expand_min_velocity">200dp</dimen>
+ <!-- Minimum final velocity of gestures interpreted as collapse requests -->
+ <dimen name="fling_collapse_min_velocity">200dp</dimen>
+ <!-- Cap on contribution of x dimension of gesture to overall velocity -->
+ <dimen name="fling_gesture_max_x_velocity">200dp</dimen>
+
+ <!-- Minimum fraction of the display a gesture must travel, at any velocity, to qualify as a
+ collapse request -->
+ <item type="dimen" name="collapse_min_display_fraction">10%</item>
+ <!-- Minimum fraction of the display a gesture must travel to qualify as an expand request -->
+ <item type="dimen" name="expand_min_display_fraction">50%</item>
+
+ <!-- Initial acceleration of an expand animation after fling -->
+ <dimen name="expand_accel">2000dp</dimen>
+ <!-- Initial acceleration of an collapse animation after fling -->
+ <dimen name="collapse_accel">2000dp</dimen>
+
</resources>
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 dd8e3e8..6e6567b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -112,6 +112,18 @@ public class PhoneStatusBar extends StatusBar {
// will likely move to a resource or other tunable param at some point
private static final int INTRUDER_ALERT_DECAY_MS = 10000;
+ // fling gesture tuning parameters, scaled to display density
+ private float mSelfExpandVelocityPx; // classic value: 2000px/s
+ private float mSelfCollapseVelocityPx; // classic value: 2000px/s (will be negated to collapse "up")
+ private float mFlingExpandMinVelocityPx; // classic value: 200px/s
+ private float mFlingCollapseMinVelocityPx; // classic value: 200px/s
+ private float mCollapseMinDisplayFraction; // classic value: 0.08 (25px/min(320px,480px) on G1)
+ private float mExpandMinDisplayFraction; // classic value: 0.5 (drag open halfway to expand)
+ private float mFlingGestureMaxXVelocityPx; // classic value: 150px/s
+
+ private float mExpandAccelPx; // classic value: 2000px/s/s
+ private float mCollapseAccelPx; // classic value: 2000px/s/s (will be negated to collapse "up")
+
PhoneStatusBarPolicy mIconPolicy;
// These are no longer handled by the policy, because we need custom strategies for them
@@ -1179,7 +1191,7 @@ public class PhoneStatusBar extends StatusBar {
}
prepareTracking(0, true);
- performFling(0, 2000.0f, true);
+ performFling(0, mSelfExpandVelocityPx, true);
}
public void animateCollapse() {
@@ -1215,7 +1227,7 @@ public class PhoneStatusBar extends StatusBar {
// and doesn't try to re-open the windowshade.
mExpanded = true;
prepareTracking(y, false);
- performFling(y, -2000.0f, true);
+ performFling(y, -mSelfCollapseVelocityPx, true);
}
void performExpand() {
@@ -1331,8 +1343,8 @@ public class PhoneStatusBar extends StatusBar {
mTracking = true;
mVelocityTracker = VelocityTracker.obtain();
if (opening) {
- mAnimAccel = 2000.0f;
- mAnimVel = 200;
+ mAnimAccel = mExpandAccelPx;
+ mAnimVel = mFlingExpandMinVelocityPx;
mAnimY = mStatusBarView.getHeight();
updateExpandedViewPos((int)mAnimY);
mAnimating = true;
@@ -1370,29 +1382,31 @@ public class PhoneStatusBar extends StatusBar {
if (mExpanded) {
if (!always && (
- vel > 200.0f
- || (y > (mDisplayMetrics.heightPixels-25) && vel > -200.0f))) {
+ vel > mFlingCollapseMinVelocityPx
+ || (y > (mDisplayMetrics.heightPixels*(1f-mCollapseMinDisplayFraction)) &&
+ vel > -mFlingExpandMinVelocityPx))) {
// We are expanded, but they didn't move sufficiently to cause
// us to retract. Animate back to the expanded position.
- mAnimAccel = 2000.0f;
+ mAnimAccel = mExpandAccelPx;
if (vel < 0) {
mAnimVel = 0;
}
}
else {
// We are expanded and are now going to animate away.
- mAnimAccel = -2000.0f;
+ mAnimAccel = -mCollapseAccelPx;
if (vel > 0) {
mAnimVel = 0;
}
}
} else {
if (always || (
- vel > 200.0f
- || (y > (mDisplayMetrics.heightPixels/2) && vel > -200.0f))) {
+ vel > mFlingExpandMinVelocityPx
+ || (y > (mDisplayMetrics.heightPixels*(1f-mExpandMinDisplayFraction)) &&
+ vel > -mFlingCollapseMinVelocityPx))) {
// We are collapsed, and they moved enough to allow us to
// expand. Animate in the notifications.
- mAnimAccel = 2000.0f;
+ mAnimAccel = mExpandAccelPx;
if (vel < 0) {
mAnimVel = 0;
}
@@ -1400,7 +1414,7 @@ public class PhoneStatusBar extends StatusBar {
else {
// We are collapsed, but they didn't move sufficiently to cause
// us to retract. Animate back to the collapsed position.
- mAnimAccel = -2000.0f;
+ mAnimAccel = -mCollapseAccelPx;
if (vel > 0) {
mAnimVel = 0;
}
@@ -1480,8 +1494,8 @@ public class PhoneStatusBar extends StatusBar {
if (xVel < 0) {
xVel = -xVel;
}
- if (xVel > 150.0f) {
- xVel = 150.0f; // limit how much we care about the x axis
+ if (xVel > mFlingGestureMaxXVelocityPx) {
+ xVel = mFlingGestureMaxXVelocityPx; // limit how much we care about the x axis
}
float vel = (float)Math.hypot(yVel, xVel);
@@ -1489,6 +1503,14 @@ public class PhoneStatusBar extends StatusBar {
vel = -vel;
}
+ if (CHATTY) {
+ Slog.d(TAG, String.format("gesture: vraw=(%f,%f) vnorm=(%f,%f) vlinear=%f",
+ mVelocityTracker.getXVelocity(),
+ mVelocityTracker.getYVelocity(),
+ xVel, yVel,
+ vel));
+ }
+
performFling((int)event.getRawY(), vel, false);
}
@@ -2133,6 +2155,19 @@ public class PhoneStatusBar extends StatusBar {
mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore);
+ mSelfExpandVelocityPx = res.getDimension(R.dimen.self_expand_velocity);
+ mSelfCollapseVelocityPx = res.getDimension(R.dimen.self_collapse_velocity);
+ mFlingExpandMinVelocityPx = res.getDimension(R.dimen.fling_expand_min_velocity);
+ mFlingCollapseMinVelocityPx = res.getDimension(R.dimen.fling_collapse_min_velocity);
+
+ mCollapseMinDisplayFraction = res.getFraction(R.dimen.collapse_min_display_fraction, 1, 1);
+ mExpandMinDisplayFraction = res.getFraction(R.dimen.expand_min_display_fraction, 1, 1);
+
+ mExpandAccelPx = res.getDimension(R.dimen.expand_accel);
+ mCollapseAccelPx = res.getDimension(R.dimen.collapse_accel);
+
+ mFlingGestureMaxXVelocityPx = res.getDimension(R.dimen.fling_gesture_max_x_velocity);
+
if (false) Slog.v(TAG, "updateResources");
}