mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
commit
c488947248
@ -5,7 +5,6 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import org.whispersystems.textsecure.crypto.MasterSecret;
|
import org.whispersystems.textsecure.crypto.MasterSecret;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
@ -19,11 +18,9 @@ public class MarkReadReceiver extends BroadcastReceiver {
|
|||||||
if (!intent.getAction().equals(CLEAR_ACTION))
|
if (!intent.getAction().equals(CLEAR_ACTION))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final long[] threadIds = intent.getLongArrayExtra("thread_ids");
|
|
||||||
final MasterSecret masterSecret = intent.getParcelableExtra("master_secret");
|
final MasterSecret masterSecret = intent.getParcelableExtra("master_secret");
|
||||||
|
|
||||||
if (threadIds != null && masterSecret != null) {
|
if (masterSecret != null) {
|
||||||
Log.w("MarkReadReceiver", "threadIds length: " + threadIds.length);
|
|
||||||
|
|
||||||
((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
|
((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
|
||||||
.cancel(MessageNotifier.NOTIFICATION_ID);
|
.cancel(MessageNotifier.NOTIFICATION_ID);
|
||||||
@ -31,10 +28,7 @@ public class MarkReadReceiver extends BroadcastReceiver {
|
|||||||
new AsyncTask<Void, Void, Void>() {
|
new AsyncTask<Void, Void, Void>() {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
for (long threadId : threadIds) {
|
DatabaseFactory.getThreadDatabase(context).setAllThreadsRead();
|
||||||
Log.w("MarkReadReceiver", "Marking as read: " + threadId);
|
|
||||||
DatabaseFactory.getThreadDatabase(context).setRead(threadId);
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageNotifier.updateNotification(context, masterSecret);
|
MessageNotifier.updateNotification(context, masterSecret);
|
||||||
return null;
|
return null;
|
||||||
|
@ -72,12 +72,11 @@ public class NotificationItem {
|
|||||||
|
|
||||||
if (recipients != null) {
|
if (recipients != null) {
|
||||||
intent.putExtra("recipients", recipients);
|
intent.putExtra("recipients", recipients);
|
||||||
intent.putExtra("thread_id", threadId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
intent.setData((Uri.parse("custom://"+System.currentTimeMillis())));
|
intent.setData((Uri.parse("custom://"+System.currentTimeMillis())));
|
||||||
|
|
||||||
return PendingIntent.getActivity(context, 0, intent, 0);
|
return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import android.app.PendingIntent;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import org.whispersystems.textsecure.crypto.MasterSecret;
|
import org.whispersystems.textsecure.crypto.MasterSecret;
|
||||||
|
|
||||||
@ -43,25 +42,10 @@ public class NotificationState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PendingIntent getMarkAsReadIntent(Context context, MasterSecret masterSecret) {
|
public PendingIntent getMarkAsReadIntent(Context context, MasterSecret masterSecret) {
|
||||||
long[] threadArray = new long[threads.size()];
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
for (long thread : threads) {
|
|
||||||
Log.w("NotificationState", "Added thread: " + thread);
|
|
||||||
threadArray[index++] = thread;
|
|
||||||
}
|
|
||||||
|
|
||||||
Intent intent = new Intent(MarkReadReceiver.CLEAR_ACTION);
|
Intent intent = new Intent(MarkReadReceiver.CLEAR_ACTION);
|
||||||
intent.putExtra("thread_ids", threadArray);
|
|
||||||
intent.putExtra("master_secret", masterSecret);
|
intent.putExtra("master_secret", masterSecret);
|
||||||
intent.setPackage(context.getPackageName());
|
intent.setPackage(context.getPackageName());
|
||||||
|
|
||||||
// XXX : This is an Android bug. If we don't pull off the extra
|
return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
// once before handing off the PendingIntent, the array will be
|
|
||||||
// truncated to one element when the PendingIntent fires. Thanks guys!
|
|
||||||
Log.w("NotificationState", "Pending array off intent length: " +
|
|
||||||
intent.getLongArrayExtra("thread_ids").length);
|
|
||||||
|
|
||||||
return PendingIntent.getBroadcast(context, 0, intent, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user