diff options
Diffstat (limited to 'News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/NotificationActionReceiver.java')
-rw-r--r-- | News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/NotificationActionReceiver.java | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/NotificationActionReceiver.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/NotificationActionReceiver.java index 237a65e1..43672dc9 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/NotificationActionReceiver.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/NotificationActionReceiver.java @@ -1,22 +1,38 @@ package de.luhmer.owncloudnewsreader.helper; +import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.util.Log; import org.greenrobot.eventbus.EventBus; -import de.luhmer.owncloudnewsreader.services.events.StopWebArchiveDownloadEvent; +import de.luhmer.owncloudnewsreader.database.DatabaseConnectionOrm; +import de.luhmer.owncloudnewsreader.services.events.SyncFinishedEvent; -import static de.luhmer.owncloudnewsreader.Constants.NOTIFICATION_ACTION_STOP_STRING; +import static android.app.Notification.EXTRA_NOTIFICATION_ID; +import static de.luhmer.owncloudnewsreader.Constants.NOTIFICATION_ACTION_MARK_ALL_AS_READ_STRING; public class NotificationActionReceiver extends BroadcastReceiver { + private static final String TAG = NotificationActionReceiver.class.getCanonicalName(); @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); - if (NOTIFICATION_ACTION_STOP_STRING.equals(action)) { - EventBus.getDefault().post(new StopWebArchiveDownloadEvent()); + if (NOTIFICATION_ACTION_MARK_ALL_AS_READ_STRING.equals(action)) { + DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(context); + Log.d(TAG, "NOTIFICATION_ACTION_MARK_ALL_AS_READ_STRING"); + dbConn.markAllItemsAsRead(); + EventBus.getDefault().post(new SyncFinishedEvent()); + + Integer notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1); + if (notificationId != -1) { + NotificationManager nMgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + nMgr.cancel(notificationId); + } + } else { + Log.d(TAG, action); } } } |