From 362106233919ff64cf462efe395f53c33a8ec4bf Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Fri, 24 Feb 2017 18:06:14 -0800 Subject: Use notification counts (instead of assuming all 1) We still ignore group summary headers, which means, for example, we won't get Gmail unread count. But single notifications that have numbers associated, such as messages from a single contact will be included in the badge count. So if you have 2 hangounts threads, one with 10 messages and one with 8, the badge would say 18. Bug: 34939841 Change-Id: I20b9a857d91715e10c0da400a1cee209d7b837b8 --- src/com/android/launcher3/notification/NotificationKeyData.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/com/android/launcher3/notification') diff --git a/src/com/android/launcher3/notification/NotificationKeyData.java b/src/com/android/launcher3/notification/NotificationKeyData.java index b3ff8dadd..bf7ae1a5c 100644 --- a/src/com/android/launcher3/notification/NotificationKeyData.java +++ b/src/com/android/launcher3/notification/NotificationKeyData.java @@ -16,6 +16,7 @@ package com.android.launcher3.notification; +import android.app.Notification; import android.service.notification.StatusBarNotification; import android.support.annotation.NonNull; @@ -31,14 +32,17 @@ import java.util.List; public class NotificationKeyData { public final String notificationKey; public final String shortcutId; + public int count; - private NotificationKeyData(String notificationKey, String shortcutId) { + private NotificationKeyData(String notificationKey, String shortcutId, int count) { this.notificationKey = notificationKey; this.shortcutId = shortcutId; + this.count = Math.max(1, count); } public static NotificationKeyData fromNotification(StatusBarNotification sbn) { - return new NotificationKeyData(sbn.getKey(), sbn.getNotification().getShortcutId()); + Notification notif = sbn.getNotification(); + return new NotificationKeyData(sbn.getKey(), notif.getShortcutId(), notif.number); } public static List extractKeysOnly(@NonNull List notificationKeys) { -- cgit v1.2.3