summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2015-05-01 10:39:26 -0400
committerChris Wren <cwren@android.com>2015-05-04 17:03:48 -0400
commit42d5dd4690dfee8addb87f3030f8dfef1c919232 (patch)
tree3720e166733787516dbb21fd6ce1c1f51007a2b1 /packages
parent5551aca2b8ec9fe7ab5ffda8dad82ee104556962 (diff)
downloadframeworks_base-42d5dd4690dfee8addb87f3030f8dfef1c919232.zip
frameworks_base-42d5dd4690dfee8addb87f3030f8dfef1c919232.tar.gz
frameworks_base-42d5dd4690dfee8addb87f3030f8dfef1c919232.tar.bz2
eliminate notification clicker garbage.
Bug: 9739772 Change-Id: If05079cb0f956e03f26c7780c318452f73c3e849
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java73
1 files changed, 38 insertions, 35 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 26c3b4e..588ec26 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -238,6 +238,8 @@ public abstract class BaseStatusBar extends SystemUI implements
protected DismissView mDismissView;
protected EmptyShadeView mEmptyShadeView;
+ private NotificationClicker mNotificationClicker = new NotificationClicker();
+
@Override // NotificationData.Environment
public boolean isDeviceProvisioned() {
return mDeviceProvisioned;
@@ -1292,13 +1294,7 @@ public abstract class BaseStatusBar extends SystemUI implements
row.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
}
- PendingIntent contentIntent = sbn.getNotification().contentIntent;
- if (contentIntent != null) {
- final View.OnClickListener listener = makeClicker(contentIntent, sbn.getKey());
- row.setOnClickListener(listener);
- } else {
- row.setOnClickListener(null);
- }
+ mNotificationClicker.register(row, sbn);
// set up the adaptive layout
View contentViewLocal = null;
@@ -1559,35 +1555,38 @@ public abstract class BaseStatusBar extends SystemUI implements
}
}
- public NotificationClicker makeClicker(PendingIntent intent, String notificationKey) {
- return new NotificationClicker(intent, notificationKey);
- }
+ private final class NotificationClicker implements View.OnClickListener {
+ public void onClick(final View v) {
+ if (!(v instanceof ExpandableNotificationRow)) {
+ Log.e(TAG, "NotificationClicker called on a view that is not a notification row.");
+ return;
+ }
- protected class NotificationClicker implements View.OnClickListener {
- private PendingIntent mIntent;
- private final String mNotificationKey;
+ final ExpandableNotificationRow row = (ExpandableNotificationRow) v;
+ final StatusBarNotification sbn = row.getStatusBarNotification();
+ if (sbn == null) {
+ Log.e(TAG, "NotificationClicker called on an unclickable notification,");
+ return;
+ }
- public NotificationClicker(PendingIntent intent, String notificationKey) {
- mIntent = intent;
- mNotificationKey = notificationKey;
- }
+ final PendingIntent intent = sbn.getNotification().contentIntent;
+ final String notificationKey = sbn.getKey();
- public void onClick(final View v) {
if (NOTIFICATION_CLICK_DEBUG) {
- Log.d(TAG, "Clicked on content of " + mNotificationKey);
+ Log.d(TAG, "Clicked on content of " + notificationKey);
}
final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
- final boolean afterKeyguardGone = mIntent.isActivity()
- && PreviewInflater.wouldLaunchResolverActivity(mContext, mIntent.getIntent(),
+ final boolean afterKeyguardGone = intent.isActivity()
+ && PreviewInflater.wouldLaunchResolverActivity(mContext, intent.getIntent(),
mCurrentUserId);
dismissKeyguardThenExecute(new OnDismissAction() {
public boolean onDismiss() {
- if (mHeadsUpManager != null && mHeadsUpManager.isHeadsUp(mNotificationKey)) {
+ if (mHeadsUpManager != null && mHeadsUpManager.isHeadsUp(notificationKey)) {
// Release the HUN notification to the shade.
//
// In most cases, when FLAG_AUTO_CANCEL is set, the notification will
// become canceled shortly by NoMan, but we can't assume that.
- mHeadsUpManager.releaseImmediately(mNotificationKey);
+ mHeadsUpManager.releaseImmediately(notificationKey);
}
new Thread() {
@Override
@@ -1606,9 +1605,9 @@ public abstract class BaseStatusBar extends SystemUI implements
} catch (RemoteException e) {
}
- if (mIntent != null) {
+ if (intent != null) {
try {
- mIntent.send();
+ intent.send();
} catch (PendingIntent.CanceledException e) {
// the stack trace isn't very helpful here.
// Just log the exception message.
@@ -1616,14 +1615,14 @@ public abstract class BaseStatusBar extends SystemUI implements
// TODO: Dismiss Keyguard.
}
- if (mIntent.isActivity()) {
+ if (intent.isActivity()) {
overrideActivityPendingAppTransition(keyguardShowing
&& !afterKeyguardGone);
}
}
try {
- mBarService.onNotificationClick(mNotificationKey);
+ mBarService.onNotificationClick(notificationKey);
} catch (RemoteException ex) {
// system process is dead if we're here.
}
@@ -1635,10 +1634,19 @@ public abstract class BaseStatusBar extends SystemUI implements
true /* force */, true /* delayed */);
visibilityChanged(false);
- return mIntent != null && mIntent.isActivity();
+ return intent != null && intent.isActivity();
}
}, afterKeyguardGone);
}
+
+ public void register(ExpandableNotificationRow row, StatusBarNotification sbn) {
+ final PendingIntent contentIntent = sbn.getNotification().contentIntent;
+ if (contentIntent != null) {
+ row.setOnClickListener(this);
+ } else {
+ row.setOnClickListener(null);
+ }
+ }
}
public void animateCollapsePanels(int flags, boolean force) {
@@ -2037,13 +2045,8 @@ public abstract class BaseStatusBar extends SystemUI implements
publicContentView.reapply(mContext, entry.getPublicContentView(), mOnClickHandler);
}
// update the contentIntent
- final PendingIntent contentIntent = notification.getNotification().contentIntent;
- if (contentIntent != null) {
- final View.OnClickListener listener = makeClicker(contentIntent, notification.getKey());
- entry.row.setOnClickListener(listener);
- } else {
- entry.row.setOnClickListener(null);
- }
+ mNotificationClicker.register(entry.row, notification);
+
entry.row.setStatusBarNotification(notification);
entry.row.notifyContentUpdated();
entry.row.resetHeight();