From c05555c290730541b02bb0f8600a150a166c5649 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Thu, 11 Jun 2015 13:00:50 -0700 Subject: [PATCH] Add listener to recipient preferences cursor. Fixes #3398 // FREEBIE --- .../database/RecipientPreferenceDatabase.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/database/RecipientPreferenceDatabase.java b/src/org/thoughtcrime/securesms/database/RecipientPreferenceDatabase.java index c759b931f3..f4ba0dd551 100644 --- a/src/org/thoughtcrime/securesms/database/RecipientPreferenceDatabase.java +++ b/src/org/thoughtcrime/securesms/database/RecipientPreferenceDatabase.java @@ -20,6 +20,7 @@ import java.util.Arrays; public class RecipientPreferenceDatabase extends Database { private static final String TAG = RecipientPreferenceDatabase.class.getSimpleName(); + private static final String RECIPIENT_PREFERENCES_URI = "content://textsecure/recipients/"; private static final String TABLE_NAME = "recipient_preferences"; private static final String ID = "_id"; @@ -63,8 +64,11 @@ public class RecipientPreferenceDatabase extends Database { public Cursor getBlocked() { SQLiteDatabase database = databaseHelper.getReadableDatabase(); - return database.query(TABLE_NAME, new String[] {ID, RECIPIENT_IDS}, BLOCK + " = 1", - null, null, null, null, null); + Cursor cursor = database.query(TABLE_NAME, new String[] {ID, RECIPIENT_IDS}, BLOCK + " = 1", + null, null, null, null, null); + cursor.setNotificationUri(context.getContentResolver(), Uri.parse(RECIPIENT_PREFERENCES_URI)); + + return cursor; } public Optional getRecipientsPreferences(@NonNull long[] recipients) { @@ -138,6 +142,8 @@ public class RecipientPreferenceDatabase extends Database { database.setTransactionSuccessful(); database.endTransaction(); + + context.getContentResolver().notifyChange(Uri.parse(RECIPIENT_PREFERENCES_URI), null); } public static class RecipientsPreferences {