diff options
author | Danesh M <danesh@cyngn.com> | 2016-05-13 11:09:07 -0700 |
---|---|---|
committer | Danesh M <daneshm90@gmail.com> | 2016-05-13 11:39:01 -0700 |
commit | f7caedcf6cc68cfc9fba18343f695c48163980b9 (patch) | |
tree | 4f2e4a895c2c211aaa44370373e6a22fa8de0091 /core | |
parent | 32b90fc34417250a625a3c273a3bb3af0563e258 (diff) | |
download | frameworks_base-f7caedcf6cc68cfc9fba18343f695c48163980b9.zip frameworks_base-f7caedcf6cc68cfc9fba18343f695c48163980b9.tar.gz frameworks_base-f7caedcf6cc68cfc9fba18343f695c48163980b9.tar.bz2 |
SpamFilter : Hide option if notification cannot be filtered
Hide option to filter notification if its a completely custom notification
which did not invoke setContentTitle/Message...etc.
NOTES-85
Change-Id: Ieec799dba589329b994f7add703babece13b6d14
Diffstat (limited to 'core')
-rw-r--r-- | core/java/com/android/internal/util/cm/SpamFilter.java | 19 |
1 files changed, 18 insertions, 1 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)); } } |