mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-22 02:36:55 +00:00
Colorize conversations.
// FREEBIE
This commit is contained in:
@@ -29,6 +29,7 @@ public class RecipientPreferenceDatabase extends Database {
|
||||
private static final String NOTIFICATION = "notification";
|
||||
private static final String VIBRATE = "vibrate";
|
||||
private static final String MUTE_UNTIL = "mute_until";
|
||||
private static final String COLOR = "color";
|
||||
|
||||
public enum VibrateState {
|
||||
DEFAULT(0), ENABLED(1), DISABLED(2);
|
||||
@@ -55,7 +56,8 @@ public class RecipientPreferenceDatabase extends Database {
|
||||
BLOCK + " INTEGER DEFAULT 0," +
|
||||
NOTIFICATION + " TEXT DEFAULT NULL, " +
|
||||
VIBRATE + " INTEGER DEFAULT " + VibrateState.DEFAULT.getId() + ", " +
|
||||
MUTE_UNTIL + " INTEGER DEFAULT 0);";
|
||||
MUTE_UNTIL + " INTEGER DEFAULT 0, " +
|
||||
COLOR + " INTEGER DEFAULT -1);";
|
||||
|
||||
public RecipientPreferenceDatabase(Context context, SQLiteOpenHelper databaseHelper) {
|
||||
super(context, databaseHelper);
|
||||
@@ -87,13 +89,16 @@ public class RecipientPreferenceDatabase extends Database {
|
||||
String notification = cursor.getString(cursor.getColumnIndexOrThrow(NOTIFICATION));
|
||||
int vibrateState = cursor.getInt(cursor.getColumnIndexOrThrow(VIBRATE));
|
||||
long muteUntil = cursor.getLong(cursor.getColumnIndexOrThrow(MUTE_UNTIL));
|
||||
int color = cursor.getInt(cursor.getColumnIndexOrThrow(COLOR));
|
||||
Uri notificationUri = notification == null ? null : Uri.parse(notification);
|
||||
|
||||
Log.w(TAG, "Muted until: " + muteUntil);
|
||||
|
||||
return Optional.of(new RecipientsPreferences(blocked, muteUntil,
|
||||
VibrateState.fromId(vibrateState),
|
||||
notificationUri));
|
||||
notificationUri,
|
||||
color == -1 ? Optional.<Integer>absent() :
|
||||
Optional.of(color)));
|
||||
}
|
||||
|
||||
return Optional.absent();
|
||||
@@ -102,6 +107,12 @@ public class RecipientPreferenceDatabase extends Database {
|
||||
}
|
||||
}
|
||||
|
||||
public void setColor(Recipients recipients, int color) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(COLOR, color);
|
||||
updateOrInsert(recipients, values);
|
||||
}
|
||||
|
||||
public void setBlocked(Recipients recipients, boolean blocked) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(BLOCK, blocked ? 1 : 0);
|
||||
@@ -147,16 +158,24 @@ public class RecipientPreferenceDatabase extends Database {
|
||||
}
|
||||
|
||||
public static class RecipientsPreferences {
|
||||
private final boolean blocked;
|
||||
private final long muteUntil;
|
||||
private final VibrateState vibrateState;
|
||||
private final Uri notification;
|
||||
private final boolean blocked;
|
||||
private final long muteUntil;
|
||||
private final VibrateState vibrateState;
|
||||
private final Uri notification;
|
||||
private final Optional<Integer> color;
|
||||
|
||||
public RecipientsPreferences(boolean blocked, long muteUntil, VibrateState vibrateState, Uri notification) {
|
||||
public RecipientsPreferences(boolean blocked, long muteUntil, VibrateState vibrateState,
|
||||
Uri notification, Optional<Integer> color)
|
||||
{
|
||||
this.blocked = blocked;
|
||||
this.muteUntil = muteUntil;
|
||||
this.vibrateState = vibrateState;
|
||||
this.notification = notification;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public Optional<Integer> getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public boolean isBlocked() {
|
||||
|
||||
Reference in New Issue
Block a user