parent
eacfca37f2
commit
ce2f66ad17
@ -0,0 +1,28 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class BlueGreyMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "blue_grey";
|
||||
|
||||
BlueGreyMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFECEFF1);
|
||||
put("100", 0xFFCFD8DC);
|
||||
put("200", 0xFFB0BEC5);
|
||||
put("300", 0xFF90A4AE);
|
||||
put("400", 0xFF78909C);
|
||||
put("500", 0xFF607D8B);
|
||||
put("600", 0xFF546E7A);
|
||||
put("700", 0xFF455A64);
|
||||
put("800", 0xFF37474F);
|
||||
put("900", 0xFF263238);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class BlueMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "blue";
|
||||
|
||||
BlueMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFE3F2FD);
|
||||
put("100", 0xFFBBDEFB);
|
||||
put("200", 0xFF90CAF9);
|
||||
put("300", 0xFF64B5F6);
|
||||
put("400", 0xFF42A5F5);
|
||||
put("500", 0xFF2196F3);
|
||||
put("600", 0xFF1E88E5);
|
||||
put("700", 0xFF1976D2);
|
||||
put("800", 0xFF1565C0);
|
||||
put("900", 0xFF0D47A1);
|
||||
put("A100", 0xFF82B1FF);
|
||||
put("A200", 0xFF448AFF);
|
||||
put("A400", 0xFF2979FF);
|
||||
put("A700", 0xFF2962FF);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class BrownMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "brown";
|
||||
|
||||
BrownMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFEFEBE9);
|
||||
put("100", 0xFFD7CCC8);
|
||||
put("200", 0xFFBCAAA4);
|
||||
put("300", 0xFFA1887F);
|
||||
put("400", 0xFF8D6E63);
|
||||
put("500", 0xFF795548);
|
||||
put("600", 0xFF6D4C41);
|
||||
put("700", 0xFF5D4037);
|
||||
put("800", 0xFF4E342E);
|
||||
put("900", 0xFF3E2723);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class CyanMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "cyan";
|
||||
|
||||
CyanMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFE0F7FA);
|
||||
put("100", 0xFFB2EBF2);
|
||||
put("200", 0xFF80DEEA);
|
||||
put("300", 0xFF4DD0E1);
|
||||
put("400", 0xFF26C6DA);
|
||||
put("500", 0xFF00BCD4);
|
||||
put("600", 0xFF00ACC1);
|
||||
put("700", 0xFF0097A7);
|
||||
put("800", 0xFF00838F);
|
||||
put("900", 0xFF006064);
|
||||
put("A100", 0xFF84FFFF);
|
||||
put("A200", 0xFF18FFFF);
|
||||
put("A400", 0xFF00E5FF);
|
||||
put("A700", 0xFF00B8D4);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class DeepOrangeMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "deep_orange";
|
||||
|
||||
DeepOrangeMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFFBE9E7);
|
||||
put("100", 0xFFFFCCBC);
|
||||
put("200", 0xFFFFAB91);
|
||||
put("300", 0xFFFF8A65);
|
||||
put("400", 0xFFFF7043);
|
||||
put("500", 0xFFFF5722);
|
||||
put("600", 0xFFF4511E);
|
||||
put("700", 0xFFE64A19);
|
||||
put("800", 0xFFD84315);
|
||||
put("900", 0xFFBF360C);
|
||||
put("A100", 0xFFFF9E80);
|
||||
put("A200", 0xFFFF6E40);
|
||||
put("A400", 0xFFFF3D00);
|
||||
put("A700", 0xFFDD2C00);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class DeepPurpleMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "deep_purple";
|
||||
|
||||
DeepPurpleMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50",0xFFEDE7F6);
|
||||
put("100", 0xFFD1C4E9);
|
||||
put("200", 0xFFB39DDB);
|
||||
put("300", 0xFF9575CD);
|
||||
put("400", 0xFF7E57C2);
|
||||
put("500", 0xFF673AB7);
|
||||
put("600", 0xFF5E35B1);
|
||||
put("700", 0xFF512DA8);
|
||||
put("800", 0xFF4527A0);
|
||||
put("900", 0xFF311B92);
|
||||
put("A100", 0xFFB388FF);
|
||||
put("A200", 0xFF7C4DFF);
|
||||
put("A400", 0xFF651FFF);
|
||||
put("A700", 0xFF6200EA);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class GreenMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "green";
|
||||
|
||||
GreenMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFE8F5E9);
|
||||
put("100", 0xFFC8E6C9);
|
||||
put("200", 0xFFA5D6A7);
|
||||
put("300", 0xFF81C784);
|
||||
put("400", 0xFF66BB6A);
|
||||
put("500", 0xFF4CAF50);
|
||||
put("600", 0xFF43A047);
|
||||
put("700", 0xFF388E3C);
|
||||
put("800", 0xFF2E7D32);
|
||||
put("900", 0xFF1B5E20);
|
||||
put("A100", 0xFFB9F6CA);
|
||||
put("A200", 0xFF69F0AE);
|
||||
put("A400", 0xFF00E676);
|
||||
put("A700", 0xFF00C853);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class GreyMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "grey";
|
||||
|
||||
GreyMaterialColor() {
|
||||
super(new HashMap<String, Integer>(){{
|
||||
put("50", 0xFFFAFAFA);
|
||||
put("100", 0xFFF5F5F5);
|
||||
put("200", 0xFFEEEEEE);
|
||||
put("300", 0xFFE0E0E0);
|
||||
put("400", 0xFFBDBDBD);
|
||||
put("500", 0xFF9E9E9E);
|
||||
put("600", 0xFF757575);
|
||||
put("700", 0xFF616161);
|
||||
put("800", 0xFF424242);
|
||||
put("900", 0xFF212121);
|
||||
}});
|
||||
}
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class IndigoMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "indigo";
|
||||
|
||||
IndigoMaterialColor() {
|
||||
super(new HashMap<String, Integer>(){{
|
||||
put("50", 0xFFE8EAF6);
|
||||
put("100", 0xFFC5CAE9);
|
||||
put("200", 0xFF9FA8DA);
|
||||
put("300", 0xFF7986CB);
|
||||
put("400", 0xFF5C6BC0);
|
||||
put("500", 0xFF3F51B5);
|
||||
put("600", 0xFF3949AB);
|
||||
put("700", 0xFF303F9F);
|
||||
put("800", 0xFF283593);
|
||||
put("900", 0xFF1A237E);
|
||||
put("A100", 0xFF8C9EFF);
|
||||
put("A200", 0xFF536DFE);
|
||||
put("A400", 0xFF3D5AFE);
|
||||
put("A700", 0xFF304FFE);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class LightBlueMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "light_blue";
|
||||
|
||||
LightBlueMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFE1F5FE);
|
||||
put("100", 0xFFB3E5FC);
|
||||
put("200", 0xFF81D4FA);
|
||||
put("300", 0xFF4FC3F7);
|
||||
put("400", 0xFF29B6F6);
|
||||
put("500", 0xFF03A9F4);
|
||||
put("600", 0xFF039BE5);
|
||||
put("700", 0xFF0288D1);
|
||||
put("800", 0xFF0277BD);
|
||||
put("900", 0xFF01579B);
|
||||
put("A100", 0xFF80D8FF);
|
||||
put("A200", 0xFF40C4FF);
|
||||
put("A400", 0xFF00B0FF);
|
||||
put("A700", 0xFF0091EA);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class LightGreenMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "light_green";
|
||||
|
||||
LightGreenMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFF1F8E9);
|
||||
put("100", 0xFFDCEDC8);
|
||||
put("200", 0xFFC5E1A5);
|
||||
put("300", 0xFFAED581);
|
||||
put("400", 0xFF9CCC65);
|
||||
put("500", 0xFF8BC34A);
|
||||
put("600", 0xFF7CB342);
|
||||
put("700", 0xFF689F38);
|
||||
put("800", 0xFF558B2F);
|
||||
put("900", 0xFF33691E);
|
||||
put("A100", 0xFFCCFF90);
|
||||
put("A200", 0xFFB2FF59);
|
||||
put("A400", 0xFF76FF03);
|
||||
put("A700", 0xFF64DD17);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class MaterialColor {
|
||||
|
||||
private final Map<String, Integer> colorWeightMap;
|
||||
|
||||
protected MaterialColor(Map<String, Integer> colorWeightMap) {
|
||||
this.colorWeightMap = colorWeightMap;
|
||||
}
|
||||
|
||||
public int toConversationColor(ThemeType themeType) {
|
||||
if (themeType == ThemeType.DARK) return colorWeightMap.get("900");
|
||||
else return colorWeightMap.get("500");
|
||||
}
|
||||
|
||||
public int toActionBarColor(ThemeType themeType) {
|
||||
return toConversationColor(themeType);
|
||||
}
|
||||
|
||||
public int toStatusBarColor(ThemeType themeType) {
|
||||
return colorWeightMap.get("700");
|
||||
}
|
||||
|
||||
public boolean represents(int colorValue) {
|
||||
return colorWeightMap.values().contains(colorValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == null || !(other instanceof MaterialColor)) return false;
|
||||
return serialize().equals(((MaterialColor)other).serialize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Util.hashCode(serialize());
|
||||
}
|
||||
|
||||
public abstract String serialize();
|
||||
|
||||
public static MaterialColor fromSerialized(String serialized) throws UnknownColorException {
|
||||
switch (serialized) {
|
||||
case RedMaterialColor.SERIALIZED_NAME: return new RedMaterialColor();
|
||||
case PinkMaterialColor.SERIALIZED_NAME: return new PinkMaterialColor();
|
||||
case PurpleMaterialColor.SERIALIZED_NAME: return new PurpleMaterialColor();
|
||||
case DeepPurpleMaterialColor.SERIALIZED_NAME: return new DeepPurpleMaterialColor();
|
||||
case IndigoMaterialColor.SERIALIZED_NAME: return new IndigoMaterialColor();
|
||||
case BlueMaterialColor.SERIALIZED_NAME: return new BlueMaterialColor();
|
||||
case LightBlueMaterialColor.SERIALIZED_NAME: return new LightBlueMaterialColor();
|
||||
case CyanMaterialColor.SERIALIZED_NAME: return new CyanMaterialColor();
|
||||
case TealMaterialColor.SERIALIZED_NAME: return new TealMaterialColor();
|
||||
case GreenMaterialColor.SERIALIZED_NAME: return new GreenMaterialColor();
|
||||
case LightGreenMaterialColor.SERIALIZED_NAME: return new LightGreenMaterialColor();
|
||||
case OrangeMaterialColor.SERIALIZED_NAME: return new OrangeMaterialColor();
|
||||
case DeepOrangeMaterialColor.SERIALIZED_NAME: return new DeepOrangeMaterialColor();
|
||||
case BrownMaterialColor.SERIALIZED_NAME: return new BrownMaterialColor();
|
||||
case GreyMaterialColor.SERIALIZED_NAME: return new GreyMaterialColor();
|
||||
case BlueGreyMaterialColor.SERIALIZED_NAME: return new BlueGreyMaterialColor();
|
||||
|
||||
default: throw new UnknownColorException("Unknown color: " + serialized);
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnknownColorException extends Exception {
|
||||
public UnknownColorException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MaterialColors {
|
||||
|
||||
public static final MaterialColor GREY = new GreyMaterialColor();
|
||||
|
||||
public static final MaterialColorList CONVERSATION_PALETTE = new MaterialColorList(new ArrayList<>(Arrays.asList(
|
||||
new RedMaterialColor(),
|
||||
new PinkMaterialColor(),
|
||||
new PurpleMaterialColor(),
|
||||
new DeepPurpleMaterialColor(),
|
||||
new IndigoMaterialColor(),
|
||||
new BlueMaterialColor(),
|
||||
new LightBlueMaterialColor(),
|
||||
new CyanMaterialColor(),
|
||||
new TealMaterialColor(),
|
||||
new GreenMaterialColor(),
|
||||
new LightGreenMaterialColor(),
|
||||
// Lime
|
||||
// Yellow
|
||||
// Amber
|
||||
new OrangeMaterialColor(),
|
||||
new DeepOrangeMaterialColor(),
|
||||
new BrownMaterialColor(),
|
||||
// Grey
|
||||
new BlueGreyMaterialColor()
|
||||
)));
|
||||
|
||||
public static class MaterialColorList {
|
||||
|
||||
private final List<MaterialColor> colors;
|
||||
|
||||
private MaterialColorList(List<MaterialColor> colors) {
|
||||
this.colors = colors;
|
||||
}
|
||||
|
||||
public MaterialColor get(int index) {
|
||||
return colors.get(index);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return colors.size();
|
||||
}
|
||||
|
||||
public @Nullable MaterialColor getByColor(int colorValue) {
|
||||
for (MaterialColor color : colors) {
|
||||
if (color.represents(colorValue)) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int[] asConversationColorArray(ThemeType themeType) {
|
||||
int[] results = new int[colors.size()];
|
||||
int index = 0;
|
||||
|
||||
for (MaterialColor color : colors) {
|
||||
results[index++] = color.toConversationColor(themeType);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class OrangeMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "orange";
|
||||
|
||||
OrangeMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFFFF3E0);
|
||||
put("100", 0xFFFFE0B2);
|
||||
put("200", 0xFFFFCC80);
|
||||
put("300", 0xFFFFB74D);
|
||||
put("400", 0xFFFFA726);
|
||||
put("500", 0xFFFF9800);
|
||||
put("600", 0xFFFB8C00);
|
||||
put("700", 0xFFF57C00);
|
||||
put("800", 0xFFEF6C00);
|
||||
put("900", 0xFFE65100);
|
||||
put("A100", 0xFFFFD180);
|
||||
put("A200", 0xFFFFAB40);
|
||||
put("A400", 0xFFFF9100);
|
||||
put("A700", 0xFFFF6D00);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PinkMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "pink";
|
||||
|
||||
PinkMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFFCE4EC);
|
||||
put("100", 0xFFF8BBD0);
|
||||
put("200", 0xFFF48FB1);
|
||||
put("300", 0xFFF06292);
|
||||
put("400", 0xFFEC407A);
|
||||
put("500", 0xFFE91E63);
|
||||
put("600", 0xFFD81B60);
|
||||
put("700", 0xFFC2185B);
|
||||
put("800", 0xFFAD1457);
|
||||
put("900", 0xFF880E4F);
|
||||
put("A100", 0xFFFF80AB);
|
||||
put("A200", 0xFFFF4081);
|
||||
put("A400", 0xFFF50057);
|
||||
put("A700", 0xFFC51162);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class PurpleMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "purple";
|
||||
|
||||
PurpleMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFF3E5F5);
|
||||
put("100", 0xFFE1BEE7);
|
||||
put("200", 0xFFCE93D8);
|
||||
put("300", 0xFFBA68C8);
|
||||
put("400", 0xFFAB47BC);
|
||||
put("500", 0xFF9C27B0);
|
||||
put("600", 0xFF8E24AA);
|
||||
put("700", 0xFF7B1FA2);
|
||||
put("800", 0xFF6A1B9A);
|
||||
put("900", 0xFF4A148C);
|
||||
put("A100", 0xFFEA80FC);
|
||||
put("A200", 0xFFE040FB);
|
||||
put("A400", 0xFFD500F9);
|
||||
put("A700", 0xFFAA00FF);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RedMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "red";
|
||||
|
||||
RedMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFFFEBEE);
|
||||
put("100", 0xFFFFCDD2);
|
||||
put("200", 0xFFEF9A9A);
|
||||
put("300", 0xFFE57373);
|
||||
put("400", 0xFFEF5350);
|
||||
put("500", 0xFFF44336);
|
||||
put("600", 0xFFE53935);
|
||||
put("700", 0xFFD32F2F);
|
||||
put("800", 0xFFC62828);
|
||||
put("900", 0xFFB71C1C);
|
||||
put("A100", 0xFFFF8A80);
|
||||
put("A200", 0xFFFF5252);
|
||||
put("A400", 0xFFFF1744);
|
||||
put("A700", 0xFFD50000);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class TealMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "teal";
|
||||
|
||||
TealMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFE0F2F1);
|
||||
put("100", 0xFFB2DFDB);
|
||||
put("200", 0xFF80CBC4);
|
||||
put("300", 0xFF4DB6AC);
|
||||
put("400", 0xFF26A69A);
|
||||
put("500", 0xFF009688);
|
||||
put("600", 0xFF00897B);
|
||||
put("700", 0xFF00796B);
|
||||
put("800", 0xFF00695C);
|
||||
put("900", 0xFF004D40);
|
||||
put("A100", 0xFFA7FFEB);
|
||||
put("A200", 0xFF64FFDA);
|
||||
put("A400", 0xFF1DE9B6);
|
||||
put("A700", 0xFF00BFA5);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
public enum ThemeType {
|
||||
LIGHT("light"), DARK("dark");
|
||||
|
||||
private static final String TAG = ThemeType.class.getSimpleName();
|
||||
|
||||
private final String type;
|
||||
|
||||
private ThemeType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static ThemeType getCurrent(Context context) {
|
||||
TypedValue outValue = new TypedValue();
|
||||
context.getTheme().resolveAttribute(R.attr.theme_type, outValue, true);
|
||||
|
||||
if ("dark".equals(outValue.coerceToString())) return ThemeType.DARK;
|
||||
else return ThemeType.LIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
@ -1,164 +1,61 @@
|
||||
package org.thoughtcrime.securesms.contacts.avatars;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
||||
import org.thoughtcrime.securesms.color.MaterialColors;
|
||||
import org.thoughtcrime.securesms.color.ThemeType;
|
||||
import org.whispersystems.libaxolotl.util.guava.Optional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ContactColors {
|
||||
|
||||
public static final int UNKNOWN_COLOR = 0xff9E9E9E;
|
||||
|
||||
private static final int RED_300 = 0xffE57373;
|
||||
private static final int RED_500 = 0xffF44336;
|
||||
private static final int RED_700 = 0xFFD32F2F;
|
||||
private static final int PINK_300 = 0xffF06292;
|
||||
private static final int PINK_500 = 0xffE91E63;
|
||||
private static final int PINK_700 = 0xFFC2185B;
|
||||
private static final int PURPLE_300 = 0xffBA68C8;
|
||||
private static final int PURPLE_500 = 0Xff9C27B0;
|
||||
private static final int PURPLE_700 = 0xFF7B1FA2;
|
||||
private static final int DEEP_PURPLE_300 = 0xff9575CD;
|
||||
private static final int DEEP_PURPLE_500 = 0xff673AB7;
|
||||
private static final int DEEP_PURPLE_700 = 0xFF512DA8;
|
||||
private static final int INDIGO_300 = 0xff7986CB;
|
||||
private static final int INDIGO_500 = 0xff3F51B5;
|
||||
private static final int INDIGO_700 = 0xff303F9F;
|
||||
private static final int BLUE_300 = 0xff64B5F6;
|
||||
private static final int BLUE_500 = 0xff2196F3;
|
||||
private static final int BLUE_700 = 0xFF1976D2;
|
||||
private static final int LIGHT_BLUE_300 = 0xff4FC3F7;
|
||||
private static final int LIGHT_BLUE_500 = 0xff03A9F4;
|
||||
private static final int LIGHT_BLUE_700 = 0xFF0288D1;
|
||||
private static final int CYAN_300 = 0xff4DD0E1;
|
||||
private static final int CYAN_500 = 0xff00BCD4;
|
||||
private static final int CYAN_700 = 0xFF0097A7;
|
||||
private static final int TEAL_300 = 0xFF4DB6AC;
|
||||
private static final int TEAL_500 = 0xff009688;
|
||||
private static final int TEAL_700 = 0xFF00796B;
|
||||
private static final int GREEN_300 = 0xFF81C784;
|
||||
private static final int GREEN_500 = 0xff4CAF50;
|
||||
private static final int GREEN_700 = 0xFF388E3C;
|
||||
private static final int LIGHT_GREEN_300 = 0xFFAED581;
|
||||
private static final int LIGHT_GREEN_500 = 0xff8BC34A;
|
||||
private static final int LIGHT_GREEN_700 = 0xFF689F38;
|
||||
private static final int LIME_300 = 0xFFDCE775;
|
||||
private static final int LIME_500 = 0XFFCDDC39;
|
||||
private static final int LIME_700 = 0xFFAFB42B;
|
||||
private static final int YELLOW_300 = 0xFFFFF176;
|
||||
private static final int YELLOW_500 = 0xffFFEB3B;
|
||||
private static final int YELLOW_700 = 0xFFFBC02D;
|
||||
private static final int AMBER_300 = 0xFFFFD54F;
|
||||
private static final int AMBER_500 = 0XFFFFC107;
|
||||
private static final int AMBER_700 = 0xFFFFA000;
|
||||
private static final int ORANGE_300 = 0xFFFFB74D;
|
||||
private static final int ORANGE_500 = 0xffFF9800;
|
||||
private static final int ORANGE_700 = 0xFFF57C00;
|
||||
private static final int DEEP_ORANGE_300 = 0xFFFF8A65;
|
||||
private static final int DEEP_ORANGE_500 = 0xffFF5722;
|
||||
private static final int DEEP_ORANGE_700 = 0xFFE64A19;
|
||||
private static final int BROWN_300 = 0xFFA1887F;
|
||||
private static final int BROWN_500 = 0xff795548;
|
||||
private static final int BROWN_700 = 0xFF5D4037;
|
||||
private static final int BLUE_GREY_300 = 0xFF90A4AE;
|
||||
private static final int BLUE_GREY_500 = 0xff607D8B;
|
||||
private static final int BLUE_GREY_700 = 0xFF455A64;
|
||||
public static final MaterialColor UNKNOWN_COLOR = MaterialColors.GREY;
|
||||
|
||||
public static MaterialColor generateFor(@NonNull String name) {
|
||||
return MaterialColors.CONVERSATION_PALETTE.get(Math.abs(name.hashCode()) % MaterialColors.CONVERSATION_PALETTE.size());
|
||||
}
|
||||
|
||||
private static final List<Integer> MATERIAL_300 = new ArrayList<>(Arrays.asList(
|
||||
RED_300,
|
||||
PINK_300,
|
||||
PURPLE_300,
|
||||
DEEP_PURPLE_300,
|
||||
INDIGO_300,
|
||||
BLUE_300,
|
||||
LIGHT_BLUE_300,
|
||||
CYAN_300,
|
||||
TEAL_300,
|
||||
GREEN_300,
|
||||
LIGHT_GREEN_300,
|
||||
LIME_300,
|
||||
AMBER_300,
|
||||
ORANGE_300,
|
||||
DEEP_ORANGE_300,
|
||||
BROWN_300,
|
||||
BLUE_GREY_300)
|
||||
);
|
||||
public static MaterialColor getGroupColor(Context context) {
|
||||
final int actionBarColor = context.getResources().getColor(R.color.textsecure_primary);
|
||||
final int statusBarColor = context.getResources().getColor(R.color.textsecure_primary_dark);
|
||||
|
||||
private static final List<Integer> MATERIAL_500 = new ArrayList<>(Arrays.asList(
|
||||
RED_500,
|
||||
PINK_500,
|
||||
PURPLE_500,
|
||||
DEEP_PURPLE_500,
|
||||
INDIGO_500,
|
||||
BLUE_500,
|
||||
LIGHT_BLUE_500,
|
||||
CYAN_500,
|
||||
TEAL_500,
|
||||
GREEN_500,
|
||||
LIGHT_GREEN_500,
|
||||
// LIME_500,
|
||||
AMBER_500,
|
||||
ORANGE_500,
|
||||
DEEP_ORANGE_500,
|
||||
BROWN_500,
|
||||
BLUE_GREY_500)
|
||||
);
|
||||
return new MaterialColor(new HashMap<String, Integer>()) {
|
||||
@Override
|
||||
public int toConversationColor(ThemeType themeType) {
|
||||
return UNKNOWN_COLOR.toConversationColor(themeType);
|
||||
}
|
||||
|
||||
private static final SparseIntArray MATERIAL_500_TO_700 = new SparseIntArray() {{
|
||||
put(RED_500, RED_700);
|
||||
put(PINK_500, PINK_700);
|
||||
put(PURPLE_500, PURPLE_700);
|
||||
put(DEEP_PURPLE_500, DEEP_PURPLE_700);
|
||||
put(INDIGO_500, INDIGO_700);
|
||||
put(BLUE_500, BLUE_700);
|
||||
put(LIGHT_BLUE_500, LIGHT_BLUE_700);
|
||||
put(CYAN_500, CYAN_700);
|
||||
put(TEAL_500, TEAL_700);
|
||||
put(GREEN_500, GREEN_700);
|
||||
put(LIGHT_GREEN_500, LIGHT_GREEN_700);
|
||||
// put(LIME_500, LIME_700);
|
||||
put(AMBER_500, AMBER_700);
|
||||
put(ORANGE_500, ORANGE_700);
|
||||
put(DEEP_ORANGE_500, DEEP_ORANGE_700);
|
||||
put(BROWN_500, BROWN_700);
|
||||
put(BLUE_GREY_500, BLUE_GREY_700);
|
||||
}};
|
||||
@Override
|
||||
public int toActionBarColor(ThemeType themeType) {
|
||||
return actionBarColor;
|
||||
}
|
||||
|
||||
private static final SparseIntArray MATERIAL_300_TO_700 = new SparseIntArray() {{
|
||||
put(RED_300, RED_700);
|
||||
put(PINK_300, PINK_700);
|
||||
put(PURPLE_300, PURPLE_700);
|
||||
put(DEEP_PURPLE_300, DEEP_PURPLE_700);
|
||||
put(INDIGO_300, INDIGO_700);
|
||||
put(BLUE_300, BLUE_700);
|
||||
put(LIGHT_BLUE_300, LIGHT_BLUE_700);
|
||||
put(CYAN_300, CYAN_700);
|
||||
put(TEAL_300, TEAL_700);
|
||||
put(GREEN_300, GREEN_700);
|
||||
put(LIGHT_GREEN_300, LIGHT_GREEN_700);
|
||||
put(LIME_300, LIME_700);
|
||||
put(AMBER_300, AMBER_700);
|
||||
put(ORANGE_300, ORANGE_700);
|
||||
put(DEEP_ORANGE_300, DEEP_ORANGE_700);
|
||||
put(BROWN_300, BROWN_700);
|
||||
put(BLUE_GREY_300, BLUE_GREY_700);
|
||||
}};
|
||||
@Override
|
||||
public int toStatusBarColor(ThemeType themeType) {
|
||||
return statusBarColor;
|
||||
}
|
||||
|
||||
private static final ColorGenerator MATERIAL_GENERATOR = ColorGenerator.create(MATERIAL_500);
|
||||
@Override
|
||||
public String serialize() {
|
||||
return "group_color";
|
||||
}
|
||||
};
|
||||
|
||||
public static int generateFor(@NonNull String name) {
|
||||
return MATERIAL_GENERATOR.getColor(name);
|
||||
}
|
||||
|
||||
public static Optional<Integer> getStatusTinted(int color) {
|
||||
int statusTinted = MATERIAL_500_TO_700.get(color, -1);
|
||||
return statusTinted == -1 ? Optional.<Integer>absent() : Optional.of(statusTinted);
|
||||
}
|
||||
// public static Optional<Integer> getStatusTinted(int color) {
|
||||
// int statusTinted = MATERIAL_500_TO_700.get(color, -1);
|
||||
// return statusTinted == -1 ? Optional.<Integer>absent() : Optional.of(statusTinted);
|
||||
// }
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue