summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2014-05-28 17:08:13 +0200
committerJorim Jaggi <jjaggi@google.com>2014-05-31 13:43:44 +0200
commit5d9cc668e16abf1306d82218cd3da29e28a454ae (patch)
treefef183332c6158b84e7e384734d4ed708d3cbe3f /packages/SystemUI/src
parente29b2dbc762bfa66093d76f5a65f55328d8753c9 (diff)
downloadframeworks_base-5d9cc668e16abf1306d82218cd3da29e28a454ae.zip
frameworks_base-5d9cc668e16abf1306d82218cd3da29e28a454ae.tar.gz
frameworks_base-5d9cc668e16abf1306d82218cd3da29e28a454ae.tar.bz2
Update HUN visuals to UX spec
Adds gradient, fixes wrong padding on tablets and adds a callback mode to swipe helper. Bug: 15106201 Change-Id: I9c3f2d24665cb3de8e70904893f56c928b0caabb
Diffstat (limited to 'packages/SystemUI/src')
-rw-r--r--packages/SystemUI/src/com/android/systemui/SwipeHelper.java66
-rw-r--r--packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java18
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java5
6 files changed, 73 insertions, 34 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index 1b12cb0..d153d09 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -51,12 +51,12 @@ public class SwipeHelper implements Gefingerpoken {
private int MAX_DISMISS_VELOCITY = 2000; // dp/sec
private static final int SNAP_ANIM_LEN = SLOW_ANIMATIONS ? 1000 : 150; // ms
- public static float ALPHA_FADE_START = 0f; // fraction of thumbnail width
+ public static float SWIPE_PROGRESS_FADE_START = 0f; // fraction of thumbnail width
// where fade starts
- static final float ALPHA_FADE_END = 0.5f; // fraction of thumbnail width
- // beyond which alpha->0
- private float mMinAlpha = 0f;
- private float mMaxAlpha = 1f;
+ static final float SWIPE_PROGRESS_FADE_END = 0.5f; // fraction of thumbnail width
+ // beyond which swipe progress->0
+ private float mMinSwipeProgress = 0f;
+ private float mMaxSwipeProgress = 1f;
private float mPagingTouchSlop;
private Callback mCallback;
@@ -137,36 +137,39 @@ public class SwipeHelper implements Gefingerpoken {
v.getMeasuredHeight();
}
- public void setMinAlpha(float minAlpha) {
- mMinAlpha = minAlpha;
+ public void setMinSwipeProgress(float minSwipeProgress) {
+ mMinSwipeProgress = minSwipeProgress;
}
- public void setMaxAlpha(float maxAlpha) {
- mMaxAlpha = maxAlpha;
+ public void setMaxSwipeProgress(float maxSwipeProgress) {
+ mMaxSwipeProgress = maxSwipeProgress;
}
- private float getAlphaForOffset(View view) {
+ private float getSwipeProgressForOffset(View view) {
float viewSize = getSize(view);
- final float fadeSize = ALPHA_FADE_END * viewSize;
+ final float fadeSize = SWIPE_PROGRESS_FADE_END * viewSize;
float result = 1.0f;
float pos = getTranslation(view);
- if (pos >= viewSize * ALPHA_FADE_START) {
- result = 1.0f - (pos - viewSize * ALPHA_FADE_START) / fadeSize;
- } else if (pos < viewSize * (1.0f - ALPHA_FADE_START)) {
- result = 1.0f + (viewSize * ALPHA_FADE_START + pos) / fadeSize;
+ if (pos >= viewSize * SWIPE_PROGRESS_FADE_START) {
+ result = 1.0f - (pos - viewSize * SWIPE_PROGRESS_FADE_START) / fadeSize;
+ } else if (pos < viewSize * (1.0f - SWIPE_PROGRESS_FADE_START)) {
+ result = 1.0f + (viewSize * SWIPE_PROGRESS_FADE_START + pos) / fadeSize;
}
- return Math.min(Math.max(mMinAlpha, result), mMaxAlpha);
+ return Math.min(Math.max(mMinSwipeProgress, result), mMaxSwipeProgress);
}
- private void updateAlphaFromOffset(View animView, boolean dismissable) {
- if (FADE_OUT_DURING_SWIPE && dismissable) {
- float alpha = getAlphaForOffset(animView);
- if (alpha != 0f && alpha != 1f) {
- animView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
- } else {
- animView.setLayerType(View.LAYER_TYPE_NONE, null);
+ private void updateSwipeProgressFromOffset(View animView, boolean dismissable) {
+ float swipeProgress = getSwipeProgressForOffset(animView);
+ if (!mCallback.updateSwipeProgress(animView, dismissable, swipeProgress)) {
+ if (FADE_OUT_DURING_SWIPE && dismissable) {
+ float alpha = swipeProgress;
+ if (alpha != 0f && alpha != 1f) {
+ animView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ } else {
+ animView.setLayerType(View.LAYER_TYPE_NONE, null);
+ }
+ animView.setAlpha(getSwipeProgressForOffset(animView));
}
- animView.setAlpha(getAlphaForOffset(animView));
}
invalidateGlobalRegion(animView);
}
@@ -307,7 +310,7 @@ public class SwipeHelper implements Gefingerpoken {
});
anim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
- updateAlphaFromOffset(animView, canAnimViewBeDismissed);
+ updateSwipeProgressFromOffset(animView, canAnimViewBeDismissed);
}
});
anim.start();
@@ -321,12 +324,12 @@ public class SwipeHelper implements Gefingerpoken {
anim.setDuration(duration);
anim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
- updateAlphaFromOffset(animView, canAnimViewBeDismissed);
+ updateSwipeProgressFromOffset(animView, canAnimViewBeDismissed);
}
});
anim.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animator) {
- updateAlphaFromOffset(animView, canAnimViewBeDismissed);
+ updateSwipeProgressFromOffset(animView, canAnimViewBeDismissed);
mCallback.onChildSnappedBack(animView);
}
});
@@ -365,7 +368,7 @@ public class SwipeHelper implements Gefingerpoken {
}
setTranslation(mCurrAnimView, delta);
- updateAlphaFromOffset(mCurrAnimView, mCanCurrViewBeDimissed);
+ updateSwipeProgressFromOffset(mCurrAnimView, mCanCurrViewBeDimissed);
}
break;
case MotionEvent.ACTION_UP:
@@ -415,5 +418,12 @@ public class SwipeHelper implements Gefingerpoken {
void onDragCancelled(View v);
void onChildSnappedBack(View animView);
+
+ /**
+ * Updates the swipe progress on a child.
+ *
+ * @return if true, prevents the default alpha fading.
+ */
+ boolean updateSwipeProgress(View animView, boolean dismissable, float swipeProgress);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
index 0759b8e..72a3341 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
@@ -64,7 +64,7 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
}
public void setMinSwipeAlpha(float minAlpha) {
- mSwipeHelper.setMinAlpha(minAlpha);
+ mSwipeHelper.setMinSwipeProgress(minAlpha);
}
private int scrollPositionOfMostRecent() {
@@ -221,6 +221,11 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
public void onChildSnappedBack(View animView) {
}
+ @Override
+ public boolean updateSwipeProgress(View animView, boolean dismissable, float swipeProgress) {
+ return false;
+ }
+
public View getChildAtPosition(MotionEvent ev) {
final float x = ev.getX() + getScrollX();
final float y = ev.getY() + getScrollY();
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
index c2dde6a..1213375 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
@@ -65,7 +65,7 @@ public class RecentsVerticalScrollView extends ScrollView
}
public void setMinSwipeAlpha(float minAlpha) {
- mSwipeHelper.setMinAlpha(minAlpha);
+ mSwipeHelper.setMinSwipeProgress(minAlpha);
}
private int scrollPositionOfMostRecent() {
@@ -229,6 +229,11 @@ public class RecentsVerticalScrollView extends ScrollView
public void onChildSnappedBack(View animView) {
}
+ @Override
+ public boolean updateSwipeProgress(View animView, boolean dismissable, float swipeProgress) {
+ return false;
+ }
+
public View getChildAtPosition(MotionEvent ev) {
final float x = ev.getX() + getScrollX();
final float y = ev.getY() + getScrollY();
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 f9afcf3..f6e6fa8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -980,8 +980,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}
private void addHeadsUpView() {
+ int headsUpHeight = mContext.getResources()
+ .getDimensionPixelSize(R.dimen.heads_up_window_height);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
- LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
+ LayoutParams.MATCH_PARENT, headsUpHeight,
WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, // above the status bar!
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
index 9271e71..ac26da2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
@@ -47,7 +47,7 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
int[] mTmpTwoArray = new int[2];
private final int mTouchSensitivityDelay;
- private final float mMaxAlpha = 0.95f;
+ private final float mMaxAlpha = 1f;
private SwipeHelper mSwipeHelper;
private EdgeSwipeHelper mEdgeSwipeHelper;
@@ -114,7 +114,7 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
float pagingTouchSlop = viewConfiguration.getScaledPagingTouchSlop();
float touchSlop = viewConfiguration.getScaledTouchSlop();
mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop);
- mSwipeHelper.setMaxAlpha(mMaxAlpha);
+ mSwipeHelper.setMaxSwipeProgress(mMaxAlpha);
mEdgeSwipeHelper = new EdgeSwipeHelper(touchSlop);
int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_min_height);
@@ -184,7 +184,13 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
Outline o = new Outline();
- o.setRect(0, 0, mContentHolder.getWidth(), mContentHolder.getHeight());
+
+ // Apply padding to shadow.
+ int outlineLeft = mContentHolder.getPaddingLeft();
+ int outlineTop = mContentHolder.getPaddingTop();
+ o.setRect(outlineLeft, outlineTop,
+ mContentHolder.getWidth() - outlineLeft - mContentHolder.getPaddingRight(),
+ mContentHolder.getHeight() - outlineTop - mContentHolder.getPaddingBottom());
mContentHolder.setOutline(o);
}
@@ -246,6 +252,12 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
}
@Override
+ public boolean updateSwipeProgress(View animView, boolean dismissable, float swipeProgress) {
+ getBackground().setAlpha((int) (255 * swipeProgress));
+ return false;
+ }
+
+ @Override
public View getChildAtPosition(MotionEvent ev) {
return mContentHolder;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index 58176b9..ef6cedf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -449,6 +449,11 @@ public class NotificationStackScrollLayout extends ViewGroup
}
}
+ @Override
+ public boolean updateSwipeProgress(View animView, boolean dismissable, float swipeProgress) {
+ return false;
+ }
+
public void onBeginDrag(View v) {
setSwipingInProgress(true);
mAmbientState.onBeginDrag(v);