diff options
author | Daniel Sandler <dsandler@google.com> | 2010-12-16 19:06:46 -0500 |
---|---|---|
committer | Daniel Sandler <dsandler@google.com> | 2010-12-16 19:40:06 -0500 |
commit | c51451a318af8e7076e7789bc1fcd91454f1e5a9 (patch) | |
tree | 3019a819a331b277a343ad7fcef75d60165cb23a /packages/SystemUI/src/com | |
parent | d0a2d701f1374ac73a3202f87021a9fc9ca4711e (diff) | |
download | frameworks_base-c51451a318af8e7076e7789bc1fcd91454f1e5a9.zip frameworks_base-c51451a318af8e7076e7789bc1fcd91454f1e5a9.tar.gz frameworks_base-c51451a318af8e7076e7789bc1fcd91454f1e5a9.tar.bz2 |
Improvements to ticker:
- Ticker view can be tapped immediately
- Ticker views animate in/out smoothly
Bug: 3274655
Bug: 3293680
Change-Id: I504dae65d91cc26a81a2a18f7bc71d6b3271f06d
Diffstat (limited to 'packages/SystemUI/src/com')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java | 8 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java | 53 |
2 files changed, 52 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java index 06c058b..64de588 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java @@ -154,6 +154,8 @@ public class TabletStatusBar extends StatusBar { boolean mNotificationsOn = true; private RecentAppsPanel mRecentsPanel; + public Context getContext() { return mContext; } + protected void addPanelWindows() { final Context context = mContext; @@ -322,7 +324,7 @@ public class TabletStatusBar extends StatusBar { mNotificationPeekTapDuration = vc.getTapTimeout(); mNotificationFlingVelocity = 300; // px/s - mTicker = new TabletTicker(context); + mTicker = new TabletTicker(this); // The icons mBatteryController = new BatteryController(mContext); @@ -844,6 +846,10 @@ public class TabletStatusBar extends StatusBar { } } + public NotificationClicker makeClicker(PendingIntent intent, String pkg, String tag, int id) { + return new NotificationClicker(intent, pkg, tag, id); + } + private class NotificationClicker implements View.OnClickListener { private PendingIntent mIntent; private String mPkg; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java index b3aed03..bc8dedc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java @@ -18,7 +18,9 @@ package com.android.systemui.statusbar.tablet; import java.util.Arrays; +import android.animation.LayoutTransition; import android.app.Notification; +import android.app.PendingIntent; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; @@ -45,9 +47,14 @@ import com.android.internal.statusbar.StatusBarNotification; import com.android.systemui.R; import com.android.systemui.statusbar.StatusBarIconView; -public class TabletTicker extends Handler { +public class TabletTicker + extends Handler + implements LayoutTransition.TransitionListener { + private static final String TAG = "StatusBar.TabletTicker"; + private static final boolean CLICKABLE_TICKER = true; + // 3 is enough to let us see most cases, but not get so far behind that it's too annoying. private static final int QUEUE_LENGTH = 3; @@ -66,8 +73,14 @@ public class TabletTicker extends Handler { private StatusBarNotification[] mQueue = new StatusBarNotification[QUEUE_LENGTH]; private int mQueuePos; - public TabletTicker(Context context) { - mContext = context; + private TabletStatusBar mBar; + + private LayoutTransition mLayoutTransition; + private boolean mWindowShouldClose; + + public TabletTicker(TabletStatusBar bar) { + mBar = bar; + mContext = bar.getContext(); } public void add(IBinder key, StatusBarNotification notification) { @@ -170,11 +183,7 @@ public class TabletTicker extends Handler { } // if there's nothing left, close the window - // TODO: Do this when the animation is done instead - if (mCurrentView == null && mWindow != null) { - WindowManagerImpl.getDefault().removeView(mWindow); - mWindow = null; - } + mWindowShouldClose = (mCurrentView == null && mWindow != null); } private void dequeue() { @@ -208,11 +217,28 @@ public class TabletTicker extends Handler { | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT); lp.gravity = Gravity.BOTTOM | Gravity.RIGHT; +// lp.windowAnimations = com.android.internal.R.style.Animation_Toast; + + mLayoutTransition = new LayoutTransition(); + mLayoutTransition.addTransitionListener(this); + view.setLayoutTransition(mLayoutTransition); lp.setTitle("NotificationTicker"); view.setLayoutParams(lp); return view; } + public void startTransition(LayoutTransition transition, ViewGroup container, + View view, int transitionType) {} + + public void endTransition(LayoutTransition transition, ViewGroup container, + View view, int transitionType) { + if (mWindowShouldClose) { + WindowManagerImpl.getDefault().removeView(mWindow); + mWindow = null; + mWindowShouldClose = false; + } + } + private View makeTickerView(StatusBarNotification notification) { final Notification n = notification.notification; @@ -266,6 +292,17 @@ public class TabletTicker extends Handler { largeIcon.setImageBitmap(n.largeIcon); largeIcon.setVisibility(View.VISIBLE); } + + if (CLICKABLE_TICKER) { + PendingIntent contentIntent = notification.notification.contentIntent; + if (contentIntent != null) { + group.setOnClickListener(mBar.makeClicker(contentIntent, + notification.pkg, notification.tag, notification.id)); + } else { + group.setOnClickListener(null); + } + } + return group; } } |