Commit 1192ff74 authored by Bastien Le Querrec's avatar Bastien Le Querrec

use ContentProviders for recipient preferences and identities

parent c8e73c32
......@@ -380,6 +380,10 @@
android:authorities="org.smssecure.smssecure.database.attachment"
android:exported="false" />
<provider android:name=".database.DatabaseContentProviders$Identities"
android:authorities="org.smssecure.smssecure.database.identities"
android:exported="false" />
<receiver android:name=".service.RegistrationNotifier"
android:exported="false">
<intent-filter>
......
......@@ -29,6 +29,14 @@ public class DatabaseContentProviders {
public static final Uri CONTENT_URI = Uri.parse("content://org.smssecure.smssecure.database.attachment");
}
public static class Identities extends NoopContentProvider {
public static final Uri CONTENT_URI = Uri.parse("content://org.smssecure.smssecure.database.identities");
}
public static class RecipientPreference extends NoopContentProvider {
public static final Uri CONTENT_URI = Uri.parse("content://org.smssecure.smssecure.database.recipients/");
}
private static abstract class NoopContentProvider extends ContentProvider {
@Override
......
......@@ -24,6 +24,7 @@ import android.database.sqlite.SQLiteOpenHelper;
import android.net.Uri;
import android.util.Log;
import org.smssecure.smssecure.database.DatabaseContentProviders;
import org.smssecure.smssecure.recipients.RecipientFactory;
import org.smssecure.smssecure.recipients.Recipients;
import org.smssecure.smssecure.util.Base64;
......@@ -36,7 +37,7 @@ import java.io.IOException;
public class IdentityDatabase extends Database {
private static final Uri CHANGE_URI = Uri.parse("content://textsecure/identities");
private static final Uri CHANGE_URI = DatabaseContentProviders.Identities.CONTENT_URI;
private static final String TABLE_NAME = "identities";
private static final String ID = "_id";
......
......@@ -11,6 +11,7 @@ import android.support.annotation.Nullable;
import android.util.Log;
import org.smssecure.smssecure.color.MaterialColor;
import org.smssecure.smssecure.database.DatabaseContentProviders;
import org.smssecure.smssecure.recipients.Recipients;
import org.smssecure.smssecure.util.Util;
import org.whispersystems.libsignal.util.guava.Optional;
......@@ -21,7 +22,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 Uri RECIPIENT_PREFERENCES_URI = DatabaseContentProviders.RecipientPreference.CONTENT_URI;
private static final String TABLE_NAME = "recipient_preferences";
private static final String ID = "_id";
......@@ -71,7 +72,7 @@ public class RecipientPreferenceDatabase extends Database {
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));
cursor.setNotificationUri(context.getContentResolver(), RECIPIENT_PREFERENCES_URI);
return cursor;
}
......@@ -172,7 +173,7 @@ public class RecipientPreferenceDatabase extends Database {
database.setTransactionSuccessful();
database.endTransaction();
context.getContentResolver().notifyChange(Uri.parse(RECIPIENT_PREFERENCES_URI), null);
context.getContentResolver().notifyChange(RECIPIENT_PREFERENCES_URI, null);
}
public static class RecipientsPreferences {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment