mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-13 21:15:08 -05:00
Fix showing unread count in pre-Honeycomb notifications
Fixes issue 4904
This commit is contained in:
parent
140cd2f1fc
commit
92c21ece6d
@ -55,6 +55,7 @@ import com.fsck.k9.activity.setup.AccountSetupIncoming;
|
|||||||
import com.fsck.k9.activity.setup.AccountSetupOutgoing;
|
import com.fsck.k9.activity.setup.AccountSetupOutgoing;
|
||||||
import com.fsck.k9.cache.EmailProviderCache;
|
import com.fsck.k9.cache.EmailProviderCache;
|
||||||
import com.fsck.k9.helper.Contacts;
|
import com.fsck.k9.helper.Contacts;
|
||||||
|
import com.fsck.k9.helper.NotificationBuilder;
|
||||||
import com.fsck.k9.helper.power.TracingPowerManager;
|
import com.fsck.k9.helper.power.TracingPowerManager;
|
||||||
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
|
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
|
||||||
import com.fsck.k9.mail.Address;
|
import com.fsck.k9.mail.Address;
|
||||||
@ -2640,7 +2641,7 @@ public class MessagingController implements Runnable {
|
|||||||
final String title = context.getString(
|
final String title = context.getString(
|
||||||
R.string.notification_certificate_error_text, account.getName());
|
R.string.notification_certificate_error_text, account.getName());
|
||||||
|
|
||||||
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
|
final NotificationCompat.Builder builder = new NotificationBuilder(context);
|
||||||
builder.setSmallIcon(R.drawable.stat_notify_email_generic);
|
builder.setSmallIcon(R.drawable.stat_notify_email_generic);
|
||||||
builder.setWhen(System.currentTimeMillis());
|
builder.setWhen(System.currentTimeMillis());
|
||||||
builder.setAutoCancel(true);
|
builder.setAutoCancel(true);
|
||||||
@ -3332,7 +3333,7 @@ public class MessagingController implements Runnable {
|
|||||||
NotificationManager notifMgr =
|
NotificationManager notifMgr =
|
||||||
(NotificationManager) mApplication.getSystemService(Context.NOTIFICATION_SERVICE);
|
(NotificationManager) mApplication.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(mApplication);
|
NotificationCompat.Builder builder = new NotificationBuilder(mApplication);
|
||||||
builder.setSmallIcon(R.drawable.ic_notify_check_mail);
|
builder.setSmallIcon(R.drawable.ic_notify_check_mail);
|
||||||
builder.setWhen(System.currentTimeMillis());
|
builder.setWhen(System.currentTimeMillis());
|
||||||
builder.setOngoing(true);
|
builder.setOngoing(true);
|
||||||
@ -3382,7 +3383,7 @@ public class MessagingController implements Runnable {
|
|||||||
NotificationManager notifMgr =
|
NotificationManager notifMgr =
|
||||||
(NotificationManager) mApplication.getSystemService(Context.NOTIFICATION_SERVICE);
|
(NotificationManager) mApplication.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(mApplication);
|
NotificationCompat.Builder builder = new NotificationBuilder(mApplication);
|
||||||
builder.setSmallIcon(R.drawable.stat_notify_email_generic);
|
builder.setSmallIcon(R.drawable.stat_notify_email_generic);
|
||||||
builder.setWhen(System.currentTimeMillis());
|
builder.setWhen(System.currentTimeMillis());
|
||||||
builder.setAutoCancel(true);
|
builder.setAutoCancel(true);
|
||||||
@ -3417,7 +3418,7 @@ public class MessagingController implements Runnable {
|
|||||||
final NotificationManager notifMgr =
|
final NotificationManager notifMgr =
|
||||||
(NotificationManager) mApplication.getSystemService(Context.NOTIFICATION_SERVICE);
|
(NotificationManager) mApplication.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(mApplication);
|
NotificationCompat.Builder builder = new NotificationBuilder(mApplication);
|
||||||
builder.setSmallIcon(R.drawable.ic_notify_check_mail);
|
builder.setSmallIcon(R.drawable.ic_notify_check_mail);
|
||||||
builder.setWhen(System.currentTimeMillis());
|
builder.setWhen(System.currentTimeMillis());
|
||||||
builder.setOngoing(true);
|
builder.setOngoing(true);
|
||||||
@ -4802,7 +4803,7 @@ public class MessagingController implements Runnable {
|
|||||||
NotificationManager notifMgr =
|
NotificationManager notifMgr =
|
||||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
|
NotificationCompat.Builder builder = new NotificationBuilder(context);
|
||||||
builder.setSmallIcon(R.drawable.stat_notify_email_generic);
|
builder.setSmallIcon(R.drawable.stat_notify_email_generic);
|
||||||
builder.setWhen(System.currentTimeMillis());
|
builder.setWhen(System.currentTimeMillis());
|
||||||
if (!updateSilently) {
|
if (!updateSilently) {
|
||||||
|
37
src/com/fsck/k9/helper/NotificationBuilder.java
Normal file
37
src/com/fsck/k9/helper/NotificationBuilder.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package com.fsck.k9.helper;
|
||||||
|
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notification builder that will set {@link Notification#number} on pre-Honeycomb devices.
|
||||||
|
*
|
||||||
|
* @see <a href="http://code.google.com/p/android/issues/detail?id=38028">android - Issue 38028</a>
|
||||||
|
*/
|
||||||
|
public class NotificationBuilder extends NotificationCompat.Builder {
|
||||||
|
protected int mNumber;
|
||||||
|
|
||||||
|
|
||||||
|
public NotificationBuilder(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NotificationCompat.Builder setNumber(int number) {
|
||||||
|
mNumber = number;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Notification build() {
|
||||||
|
Notification notification = super.build();
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||||
|
notification.number = mNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
return notification;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user