summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@android.com>2011-08-11 00:19:49 -0400
committerDaniel Sandler <dsandler@android.com>2011-08-11 00:19:49 -0400
commit0761e4cd95b6968dd4b1659a766ef504d13f6d50 (patch)
tree6bb5b77d242530d8733a1ee7e0bbaf219435bdb4 /packages
parent542f0510d42e225546acc01842adfafb27f627b6 (diff)
downloadframeworks_base-0761e4cd95b6968dd4b1659a766ef504d13f6d50.zip
frameworks_base-0761e4cd95b6968dd4b1659a766ef504d13f6d50.tar.gz
frameworks_base-0761e4cd95b6968dd4b1659a766ef504d13f6d50.tar.bz2
Clean up some effects in the phone notification panel.
* Clear-all button (X) fades in and out * "No notifications" text fades in after a few sec * Swipe-out velocity can be much higher, dramatically reducing perceived jankiness in clearing notifications Bug: 5150699 Change-Id: Ic7e5254fee57724c42b6437d1c4ed8a700615208
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/res/layout/status_bar_expanded.xml35
-rw-r--r--packages/SystemUI/src/com/android/systemui/SwipeHelper.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java48
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java35
4 files changed, 59 insertions, 62 deletions
diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml
index dbbaf96..b63afbe 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded.xml
@@ -86,6 +86,16 @@
android:layout_height="wrap_content"
android:layout_weight="1"
>
+ <TextView android:id="@+id/noNotificationsTitle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="@android:style/TextAppearance.Large"
+ android:padding="8dp"
+ android:layout_gravity="top"
+ android:gravity="center"
+ android:text="@string/status_bar_no_notifications_title"
+ />
+
<ScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
@@ -93,29 +103,12 @@
android:fadingEdge="none"
android:overScrollMode="ifContentScrolls"
>
- <LinearLayout
- android:id="@+id/notificationLinearLayout"
+ <com.android.systemui.statusbar.policy.NotificationRowLayout
+ android:id="@+id/latestItems"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- >
-
- <TextView android:id="@+id/noNotificationsTitle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textAppearance="@android:style/TextAppearance.Large"
- android:padding="8dp"
- android:gravity="center"
- android:text="@string/status_bar_no_notifications_title"
- />
-
- <com.android.systemui.statusbar.policy.NotificationRowLayout
- android:id="@+id/latestItems"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- systemui:rowHeight="@dimen/notification_height"
- />
- </LinearLayout>
+ systemui:rowHeight="@dimen/notification_height"
+ />
</ScrollView>
<ImageView
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index 6ecfd94..2818f87 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -43,6 +43,7 @@ public class SwipeHelper {
private float SWIPE_ESCAPE_VELOCITY = 100f; // dp/sec
private int MAX_ESCAPE_ANIMATION_DURATION = 500; // ms
+ private int MAX_DISMISS_VELOCITY = 1000; // dp/sec
private static final int SNAP_ANIM_LEN = SLOW_ANIMATIONS ? 1000 : 250; // ms
public static float ALPHA_FADE_START = 0.8f; // fraction of thumbnail width
@@ -281,7 +282,7 @@ public class SwipeHelper {
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
if (mCurrView != null) {
- float maxVelocity = 1000; // px/sec
+ float maxVelocity = MAX_DISMISS_VELOCITY * mDensityScale;
mVelocityTracker.computeCurrentVelocity(1000 /* px/sec */, maxVelocity);
float escapeVelocity = SWIPE_ESCAPE_VELOCITY * mDensityScale;
float velocity = getVelocity(mVelocityTracker);
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 e14317b..ec7be15 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.phone;
+import android.animation.ObjectAnimator;
import android.app.ActivityManagerNative;
import android.app.Dialog;
import android.app.Notification;
@@ -136,7 +137,6 @@ public class PhoneStatusBar extends StatusBar {
ExpandedView mExpandedView;
WindowManager.LayoutParams mExpandedParams;
ScrollView mScrollView;
- View mNotificationLinearLayout;
View mExpandedContents;
// top bar
TextView mNoNotificationsTitle;
@@ -305,16 +305,18 @@ public class PhoneStatusBar extends StatusBar {
mExpandedDialog = new ExpandedDialog(context);
mExpandedView = expanded;
- mExpandedContents = expanded.findViewById(R.id.notificationLinearLayout);
mPile = (ViewGroup)expanded.findViewById(R.id.latestItems);
+ mExpandedContents = mPile; // was: expanded.findViewById(R.id.notificationLinearLayout);
mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle);
+ mNoNotificationsTitle.setAlpha(0f);
+ mNoNotificationsTitle.setVisibility(View.VISIBLE);
mClearButton = expanded.findViewById(R.id.clear_all_button);
mClearButton.setOnClickListener(mClearButtonListener);
+ mClearButton.setAlpha(0f);
mDateView = (DateView)expanded.findViewById(R.id.date);
mSettingsButton = expanded.findViewById(R.id.settings_button);
mSettingsButton.setOnClickListener(mSettingsButtonListener);
mScrollView = (ScrollView)expanded.findViewById(R.id.scroll);
- mNotificationLinearLayout = expanded.findViewById(R.id.notificationLinearLayout);
mTicker = new MyTicker(context, sb);
@@ -701,9 +703,10 @@ public class PhoneStatusBar extends StatusBar {
mTicker.removeEntry(old);
// Recalculate the position of the sliding windows and the titles.
- setAreThereNotifications();
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
}
+
+ setAreThereNotifications();
}
@Override
@@ -1008,13 +1011,37 @@ public class PhoneStatusBar extends StatusBar {
}
private void setAreThereNotifications() {
- mClearButton.setVisibility(mNotificationData.hasClearableItems()
- ? View.VISIBLE
- : View.INVISIBLE);
+ final boolean any = mNotificationData.size() > 0;
- mNoNotificationsTitle.setVisibility(mNotificationData.size() > 0
- ? View.GONE
- : View.VISIBLE);
+ final boolean clearable = any && mNotificationData.hasClearableItems();
+
+ if (DEBUG) {
+ Slog.d(TAG, "setAreThereNotifications: N=" + mNotificationData.size()
+ + " any=" + any + " clearable=" + clearable);
+ }
+
+ if (mClearButton.isShown()) {
+ if (clearable != (mClearButton.getAlpha() == 1.0f)) {
+ ObjectAnimator.ofFloat(mClearButton, "alpha",
+ clearable ? 1.0f : 0.0f)
+ .setDuration(250)
+ .start();
+ }
+ } else {
+ mClearButton.setAlpha(clearable ? 1.0f : 0.0f);
+ }
+
+ if (mNoNotificationsTitle.isShown()) {
+ if (any != (mNoNotificationsTitle.getAlpha() == 0.0f)) {
+ ObjectAnimator a = ObjectAnimator.ofFloat(mNoNotificationsTitle, "alpha",
+ (any ? 0.0f : 0.75f));
+ a.setDuration(any ? 0 : 500);
+ a.setStartDelay(any ? 250 : 1000);
+ a.start();
+ }
+ } else {
+ mNoNotificationsTitle.setAlpha(any ? 0.0f : 0.75f);
+ }
}
@@ -1653,7 +1680,6 @@ public class PhoneStatusBar extends StatusBar {
pw.println(" mTickerView: " + viewInfo(mTickerView));
pw.println(" mScrollView: " + viewInfo(mScrollView)
+ " scroll " + mScrollView.getScrollX() + "," + mScrollView.getScrollY());
- pw.println("mNotificationLinearLayout: " + viewInfo(mNotificationLinearLayout));
}
/*
synchronized (mNotificationData) {
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 2a0dfb5..469b462 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
@@ -166,20 +166,16 @@ public class NotificationRowLayout extends ViewGroup implements SwipeHelper.Call
mAppearingViews.add(child);
child.setPivotY(0);
- AnimatorSet a = new AnimatorSet();
- a.playTogether(
- ObjectAnimator.ofFloat(child, "alpha", 0f, 1f)
-// ,ObjectAnimator.ofFloat(child, "scaleY", 0f, 1f)
- );
- a.setDuration(APPEAR_ANIM_LEN);
- a.addListener(new AnimatorListenerAdapter() {
+ final ObjectAnimator alphaFade = ObjectAnimator.ofFloat(child, "alpha", 0f, 1f);
+ alphaFade.setDuration(APPEAR_ANIM_LEN);
+ alphaFade.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mAppearingViews.remove(childF);
requestLayout(); // pick up any final changes in position
}
});
- a.start();
+ alphaFade.start();
requestLayout(); // start the container animation
}
}
@@ -195,23 +191,10 @@ public class NotificationRowLayout extends ViewGroup implements SwipeHelper.Call
child.setPivotY(0);
- //final float velocity = (mSlidingChild == child)
- // ? Math.min(mLiftoffVelocity, SWIPE_ANIM_VELOCITY_MIN)
- // : SWIPE_ESCAPE_VELOCITY;
- final float velocity = 0f;
- final TimeAnimator zoom = new TimeAnimator();
- zoom.setTimeListener(new TimeAnimator.TimeListener() {
- @Override
- public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
- childF.setTranslationX(childF.getTranslationX() + deltaTime / 1000f * velocity);
- }
- });
-
final ObjectAnimator alphaFade = ObjectAnimator.ofFloat(child, "alpha", 0f);
alphaFade.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- zoom.cancel(); // it won't end on its own
if (DEBUG) Slog.d(TAG, "actually removing child: " + childF);
NotificationRowLayout.super.removeView(childF);
childF.setAlpha(1f);
@@ -220,14 +203,8 @@ public class NotificationRowLayout extends ViewGroup implements SwipeHelper.Call
}
});
- AnimatorSet a = new AnimatorSet();
- a.playTogether(alphaFade, zoom);
-
-// ,ObjectAnimator.ofFloat(child, "scaleY", 0f)
-// ,ObjectAnimator.ofFloat(child, "translationX", child.getTranslationX() + 300f)
-
- a.setDuration(DISAPPEAR_ANIM_LEN);
- a.start();
+ alphaFade.setDuration(DISAPPEAR_ANIM_LEN);
+ alphaFade.start();
requestLayout(); // start the container animation
} else {
super.removeView(child);