summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/statusbar
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java15
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java44
2 files changed, 49 insertions, 10 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
index dbfbe11..d9d9c06 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
@@ -29,6 +29,8 @@ import android.view.View;
import android.view.ViewDebug;
import android.widget.FrameLayout;
+import java.text.NumberFormat;
+
import com.android.internal.statusbar.StatusBarIcon;
import com.android.systemui.R;
@@ -180,7 +182,18 @@ public class StatusBarIconView extends AnimatedImageView {
}
void placeNumber() {
- final String str = mNumberText = Integer.toString(mIcon.number);
+ final String str;
+ final int tooBig = mContext.getResources().getInteger(
+ android.R.integer.status_bar_notification_info_maxnum);
+ if (mIcon.number > tooBig) {
+ str = mContext.getResources().getString(
+ android.R.string.status_bar_notification_info_overflow);
+ } else {
+ NumberFormat f = NumberFormat.getIntegerInstance();
+ str = f.format(mIcon.number);
+ }
+ mNumberText = str;
+
final int w = getWidth();
final int h = getHeight();
final Rect r = new Rect();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
index b5ea7b2..981fb24 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
@@ -52,11 +52,16 @@ public class NotificationRowLayout extends ViewGroup {
private static final boolean ANIMATE_LAYOUT = true;
+ private static final boolean CLEAR_IF_SWIPED_FAR_ENOUGH = true;
+
+ private static final boolean CONSTRAIN_SWIPE_ON_PERMANENT = true;
+
private static final int APPEAR_ANIM_LEN = SLOW_ANIMATIONS ? 5000 : 250;
private static final int DISAPPEAR_ANIM_LEN = APPEAR_ANIM_LEN;
private static final int SNAP_ANIM_LEN = SLOW_ANIMATIONS ? 1000 : 250;
private static final float SWIPE_ESCAPE_VELOCITY = 1500f;
+ private static final float SWIPE_ANIM_VELOCITY_MIN = 1000f;
Rect mTmpRect = new Rect();
int mNumRows = 0;
@@ -149,6 +154,21 @@ public class NotificationRowLayout extends ViewGroup {
}
return mSlidingChild != null;
}
+
+ protected boolean canBeCleared(View v) {
+ final View veto = v.findViewById(R.id.veto);
+ return (veto != null && veto.getVisibility() != View.GONE);
+ }
+
+ protected boolean clear(View v) {
+ final View veto = v.findViewById(R.id.veto);
+ if (veto != null && veto.getVisibility() != View.GONE) {
+ veto.performClick();
+ return true;
+ }
+ return false;
+ }
+
@Override
public boolean onTouchEvent(MotionEvent ev) {
final int action = ev.getAction();
@@ -159,7 +179,13 @@ public class NotificationRowLayout extends ViewGroup {
case MotionEvent.ACTION_MOVE:
mVT.addMovement(ev);
- mSlidingChild.setTranslationX(ev.getX() - mInitialTouchX);
+ float delta = (ev.getX() - mInitialTouchX);
+ if (CONSTRAIN_SWIPE_ON_PERMANENT && !canBeCleared(mSlidingChild)) {
+ delta = Math.copySign(
+ Math.min(Math.abs(delta),
+ mSlidingChild.getMeasuredWidth() * 0.2f), delta);
+ }
+ mSlidingChild.setTranslationX(delta);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
@@ -168,14 +194,13 @@ public class NotificationRowLayout extends ViewGroup {
if (DEBUG) Slog.d(TAG, "exit velocity: " + mVT.getXVelocity());
boolean restore = true;
mLiftoffVelocity = mVT.getXVelocity();
- if (Math.abs(mLiftoffVelocity) > SWIPE_ESCAPE_VELOCITY) {
- // flingadingy
+ if (Math.abs(mLiftoffVelocity) > SWIPE_ESCAPE_VELOCITY
+ || (CLEAR_IF_SWIPED_FAR_ENOUGH &&
+ (mSlidingChild.getTranslationX() * 2) > mSlidingChild.getMeasuredWidth()))
+ {
- View veto = mSlidingChild.findViewById(R.id.veto);
- if (veto != null && veto.getVisibility() == View.VISIBLE) {
- veto.performClick();
- restore = false;
- }
+ // flingadingy
+ restore = ! clear(mSlidingChild);
}
if (restore) {
// snappity
@@ -230,7 +255,8 @@ public class NotificationRowLayout extends ViewGroup {
child.setPivotY(0);
final float velocity = (mSlidingChild == child)
- ? mLiftoffVelocity : SWIPE_ESCAPE_VELOCITY;
+ ? Math.min(mLiftoffVelocity, SWIPE_ANIM_VELOCITY_MIN)
+ : SWIPE_ESCAPE_VELOCITY;
final TimeAnimator zoom = new TimeAnimator();
zoom.setTimeListener(new TimeAnimator.TimeListener() {
@Override