mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-27 20:24:32 +01:00
Add ultramarine as a conversation color option.
This commit is contained in:
@@ -8,6 +8,9 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Colors that can be randomly assigned to a contact.
|
||||
*/
|
||||
public class ContactColors {
|
||||
|
||||
public static final MaterialColor UNKNOWN_COLOR = MaterialColor.STEEL;
|
||||
@@ -23,7 +26,8 @@ public class ContactColors {
|
||||
MaterialColor.WINTERGREEN,
|
||||
MaterialColor.TEAL,
|
||||
MaterialColor.BURLAP,
|
||||
MaterialColor.TAUPE
|
||||
MaterialColor.TAUPE,
|
||||
MaterialColor.ULTRAMARINE
|
||||
));
|
||||
|
||||
public static MaterialColor generateFor(@NonNull String name) {
|
||||
|
||||
@@ -2,8 +2,12 @@ package org.thoughtcrime.securesms.contacts.avatars;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Used for migrating legacy colors to modern colors. For normal color generation, use
|
||||
* {@link ContactColors}.
|
||||
@@ -28,6 +32,21 @@ public class ContactColorsLegacy {
|
||||
"blue_grey"
|
||||
};
|
||||
|
||||
private static final String[] LEGACY_PALETTE_2 = new String[]{
|
||||
"pink",
|
||||
"red",
|
||||
"orange",
|
||||
"purple",
|
||||
"blue",
|
||||
"indigo",
|
||||
"green",
|
||||
"light_green",
|
||||
"teal",
|
||||
"brown",
|
||||
"blue_grey"
|
||||
};
|
||||
|
||||
|
||||
public static MaterialColor generateFor(@NonNull String name) {
|
||||
String serialized = LEGACY_PALETTE[Math.abs(name.hashCode()) % LEGACY_PALETTE.length];
|
||||
try {
|
||||
@@ -36,4 +55,13 @@ public class ContactColorsLegacy {
|
||||
return ContactColors.generateFor(name);
|
||||
}
|
||||
}
|
||||
|
||||
public static MaterialColor generateForV2(@NonNull String name) {
|
||||
String serialized = LEGACY_PALETTE_2[Math.abs(name.hashCode()) % LEGACY_PALETTE_2.length];
|
||||
try {
|
||||
return MaterialColor.fromSerialized(serialized);
|
||||
} catch (MaterialColor.UnknownColorException e) {
|
||||
return ContactColors.generateFor(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user