2013-05-30 12:39:56 -07:00
|
|
|
package org.thoughtcrime.securesms.notifications;
|
|
|
|
|
|
|
|
import android.app.NotificationManager;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.AsyncTask;
|
|
|
|
|
2013-08-17 18:37:18 -07:00
|
|
|
import org.whispersystems.textsecure.crypto.MasterSecret;
|
2013-05-30 12:39:56 -07:00
|
|
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|
|
|
|
|
|
|
public class MarkReadReceiver extends BroadcastReceiver {
|
|
|
|
|
|
|
|
public static final String CLEAR_ACTION = "org.thoughtcrime.securesms.notifications.CLEAR";
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onReceive(final Context context, Intent intent) {
|
|
|
|
if (!intent.getAction().equals(CLEAR_ACTION))
|
|
|
|
return;
|
|
|
|
|
|
|
|
final MasterSecret masterSecret = intent.getParcelableExtra("master_secret");
|
|
|
|
|
2013-12-14 16:55:24 +00:00
|
|
|
if (masterSecret != null) {
|
2013-05-30 12:39:56 -07:00
|
|
|
|
|
|
|
((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
|
|
|
|
.cancel(MessageNotifier.NOTIFICATION_ID);
|
|
|
|
|
|
|
|
new AsyncTask<Void, Void, Void>() {
|
|
|
|
@Override
|
|
|
|
protected Void doInBackground(Void... params) {
|
2013-12-14 16:55:24 +00:00
|
|
|
DatabaseFactory.getThreadDatabase(context).setAllThreadsRead();
|
2013-05-30 12:39:56 -07:00
|
|
|
|
|
|
|
MessageNotifier.updateNotification(context, masterSecret);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}.execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|