summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/com/android/internal/util/cm/SpamFilter.java19
-rwxr-xr-xpackages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java4
2 files changed, 21 insertions, 2 deletions
diff --git a/core/java/com/android/internal/util/cm/SpamFilter.java b/core/java/com/android/internal/util/cm/SpamFilter.java
index 9de4489..c261009 100644
--- a/core/java/com/android/internal/util/cm/SpamFilter.java
+++ b/core/java/com/android/internal/util/cm/SpamFilter.java
@@ -46,10 +46,21 @@ public class SpamFilter {
}
public static String getNotificationContent(Notification notification) {
+ CharSequence notificationTitle = getNotificationTitle(notification);
+ CharSequence notificationMessage = getNotificationMessage(notification);
+ return notificationTitle + "\n" + notificationMessage;
+ }
+
+ private static CharSequence getNotificationTitle(Notification notification) {
Bundle extras = notification.extras;
String titleExtra = extras.containsKey(Notification.EXTRA_TITLE_BIG)
? Notification.EXTRA_TITLE_BIG : Notification.EXTRA_TITLE;
CharSequence notificationTitle = extras.getCharSequence(titleExtra);
+ return notificationTitle;
+ }
+
+ private static CharSequence getNotificationMessage(Notification notification) {
+ Bundle extras = notification.extras;
CharSequence notificationMessage = extras.getCharSequence(Notification.EXTRA_TEXT);
if (TextUtils.isEmpty(notificationMessage)) {
@@ -60,6 +71,12 @@ public class SpamFilter {
notificationMessage = TextUtils.join("\n", inboxLines);
}
}
- return notificationTitle + "\n" + notificationMessage;
+ return notificationMessage;
+ }
+
+ public static boolean hasFilterableContent(Notification notification) {
+ CharSequence notificationTitle = getNotificationTitle(notification);
+ CharSequence notificationMessage = getNotificationMessage(notification);
+ return !(TextUtils.isEmpty(notificationTitle) && TextUtils.isEmpty(notificationMessage));
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index dc0f5f9..3d7d4f6 100755
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -956,7 +956,9 @@ public abstract class BaseStatusBar extends SystemUI implements
}
});
- filterButton.setVisibility(View.VISIBLE);
+ Notification notification = sbn.getNotification();
+ filterButton.setVisibility(SpamFilter.hasFilterableContent(notification)
+ ? View.VISIBLE : View.GONE);
filterButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
AsyncTask.execute(new Runnable() {