Search in sources :

Example 31 with NotificationManagerCompat

use of android.preview.support.v4.app.NotificationManagerCompat in project WordPress-Android by wordpress-mobile.

the class GCMMessageService method removeNotificationWithNoteIdFromSystemBar.

// Removes a specific notification from the system bar
public static synchronized void removeNotificationWithNoteIdFromSystemBar(Context context, String noteID) {
    if (context == null || TextUtils.isEmpty(noteID) || !hasNotifications()) {
        return;
    }
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
    // so we need to keep cancelling them and removing them from our activeNotificationsMap as we find it suitable
    for (Iterator<Map.Entry<Integer, Bundle>> it = sActiveNotificationsMap.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry<Integer, Bundle> row = it.next();
        Integer pushId = row.getKey();
        Bundle noteBundle = row.getValue();
        if (noteBundle.getString(PUSH_ARG_NOTE_ID, "").equals(noteID)) {
            notificationManager.cancel(pushId);
            it.remove();
        }
    }
    if (sActiveNotificationsMap.size() == 0) {
        notificationManager.cancel(GCMMessageService.GROUP_NOTIFICATION_ID);
    }
}
Also used : Bundle(android.os.Bundle) NotificationManagerCompat(android.support.v4.app.NotificationManagerCompat) ArrayMap(android.support.v4.util.ArrayMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 32 with NotificationManagerCompat

use of android.preview.support.v4.app.NotificationManagerCompat in project WordPress-Android by wordpress-mobile.

the class GCMMessageService method removeAllNotifications.

// Removes all app notifications from the system bar
public static synchronized void removeAllNotifications(Context context) {
    if (context == null || !hasNotifications()) {
        return;
    }
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
    Bundle authPNBundle = sActiveNotificationsMap.remove(AUTH_PUSH_NOTIFICATION_ID);
    for (Integer pushId : sActiveNotificationsMap.keySet()) {
        notificationManager.cancel(pushId);
    }
    notificationManager.cancel(GCMMessageService.GROUP_NOTIFICATION_ID);
    //reinsert 2fa bundle if it was present
    if (authPNBundle != null) {
        sActiveNotificationsMap.put(AUTH_PUSH_NOTIFICATION_ID, authPNBundle);
    }
    clearNotifications();
}
Also used : Bundle(android.os.Bundle) NotificationManagerCompat(android.support.v4.app.NotificationManagerCompat)

Example 33 with NotificationManagerCompat

use of android.preview.support.v4.app.NotificationManagerCompat in project WordPress-Android by wordpress-mobile.

the class NativeNotificationsUtils method showMessageToUserWithBuilder.

public static void showMessageToUserWithBuilder(NotificationCompat.Builder builder, String message, boolean intermediateMessage, int pushId, Context context) {
    if (!intermediateMessage) {
        builder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
    }
    builder.setProgress(0, 0, intermediateMessage);
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
    notificationManager.notify(pushId, builder.build());
}
Also used : NotificationManagerCompat(android.support.v4.app.NotificationManagerCompat)

Example 34 with NotificationManagerCompat

use of android.preview.support.v4.app.NotificationManagerCompat in project wh-app-android by WhiteHouse.

the class NotificationPublisher method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    final NotificationManagerCompat nm = NotificationManagerCompat.from(context);
    final Notification n = intent.getParcelableExtra(EXTRA_NOTIFICATION);
    final int id = intent.getIntExtra(EXTRA_NOTIFICATION_ID, 0);
    nm.notify(id, n);
}
Also used : NotificationManagerCompat(android.support.v4.app.NotificationManagerCompat) Notification(android.app.Notification)

Example 35 with NotificationManagerCompat

use of android.preview.support.v4.app.NotificationManagerCompat in project wh-app-android by WhiteHouse.

the class LiveService method postLiveItem.

private void postLiveItem(final FeedItem item) {
    final Notification notification = buildLiveNotification(item);
    final NotificationManagerCompat nm = NotificationManagerCompat.from(this);
    nm.notify(0, notification);
}
Also used : NotificationManagerCompat(android.support.v4.app.NotificationManagerCompat) Notification(android.app.Notification)

Aggregations

NotificationManagerCompat (android.support.v4.app.NotificationManagerCompat)38 NotificationCompat (android.support.v4.app.NotificationCompat)17 PendingIntent (android.app.PendingIntent)15 Intent (android.content.Intent)15 SharedPreferences (android.content.SharedPreferences)7 PowerManager (android.os.PowerManager)7 Bitmap (android.graphics.Bitmap)6 AppSettings (com.klinker.android.twitter.settings.AppSettings)6 Notification (android.app.Notification)5 Context (android.content.Context)4 Cursor (android.database.Cursor)4 RemoteInput (android.support.v4.app.RemoteInput)4 Bundle (android.os.Bundle)3 ComponentName (android.content.ComponentName)2 ContentResolver (android.content.ContentResolver)2 ContentValues (android.content.ContentValues)2 Uri (android.net.Uri)2 Builder (android.support.v4.app.NotificationCompat.Builder)2 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)2 ArrayList (java.util.ArrayList)2