mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 01:00:49 +00:00
Support for syncing contact colors and block lists
Closes #5638 // FREEBIE
This commit is contained in:
@@ -11,6 +11,7 @@ import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
@@ -80,6 +81,10 @@ public class RecipientPreferenceDatabase extends Database {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
public BlockedReader readerForBlocked(Cursor cursor) {
|
||||
return new BlockedReader(context, cursor);
|
||||
}
|
||||
|
||||
public Optional<RecipientsPreferences> getRecipientsPreferences(@NonNull long[] recipients) {
|
||||
Arrays.sort(recipients);
|
||||
|
||||
@@ -255,4 +260,28 @@ public class RecipientPreferenceDatabase extends Database {
|
||||
return expireMessages;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BlockedReader {
|
||||
|
||||
private final Context context;
|
||||
private final Cursor cursor;
|
||||
|
||||
public BlockedReader(Context context, Cursor cursor) {
|
||||
this.context = context;
|
||||
this.cursor = cursor;
|
||||
}
|
||||
|
||||
public @NonNull Recipients getCurrent() {
|
||||
String recipientIds = cursor.getString(cursor.getColumnIndexOrThrow(RECIPIENT_IDS));
|
||||
return RecipientFactory.getRecipientsForIds(context, recipientIds, false);
|
||||
}
|
||||
|
||||
public @Nullable Recipients getNext() {
|
||||
if (!cursor.moveToNext()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return getCurrent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user