mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-25 13:58:40 +00:00
Fully colorize conversations.
1. Switch from 300 to 500 colors. 2. Colorize incoming conversation bubbles. 3. Colorize recipeint preference activity toolbar. 4. Support inverted colors in avatars. 5. Make status bar icons tint according to secondary color. // FREEBIE
This commit is contained in:
@@ -16,7 +16,12 @@ public class BitmapContactPhoto implements ContactPhoto {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable asDrawable(Context context, int background) {
|
||||
public Drawable asDrawable(Context context, int color) {
|
||||
return asDrawable(context, color, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable asDrawable(Context context, int color, boolean inverted) {
|
||||
return RoundedDrawable.fromBitmap(bitmap)
|
||||
.setScaleType(ImageView.ScaleType.CENTER_CROP)
|
||||
.setOval(true);
|
||||
|
||||
@@ -16,40 +16,58 @@ 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_700 = 0xFF303F9F;
|
||||
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;
|
||||
|
||||
private static final List<Integer> MATERIAL_300 = new ArrayList<>(Arrays.asList(
|
||||
@@ -72,6 +90,46 @@ public class ContactColors {
|
||||
BLUE_GREY_300)
|
||||
);
|
||||
|
||||
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)
|
||||
);
|
||||
|
||||
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);
|
||||
}};
|
||||
|
||||
private static final SparseIntArray MATERIAL_300_TO_700 = new SparseIntArray() {{
|
||||
put(RED_300, RED_700);
|
||||
put(PINK_300, PINK_700);
|
||||
@@ -92,15 +150,14 @@ public class ContactColors {
|
||||
put(BLUE_GREY_300, BLUE_GREY_700);
|
||||
}};
|
||||
|
||||
|
||||
private static final ColorGenerator MATERIAL_GENERATOR = ColorGenerator.create(MATERIAL_300);
|
||||
private static final ColorGenerator MATERIAL_GENERATOR = ColorGenerator.create(MATERIAL_500);
|
||||
|
||||
public static int generateFor(@NonNull String name) {
|
||||
return MATERIAL_GENERATOR.getColor(name);
|
||||
}
|
||||
|
||||
public static Optional<Integer> getStatusTinted(int color) {
|
||||
int statusTinted = MATERIAL_300_TO_700.get(color, -1);
|
||||
int statusTinted = MATERIAL_500_TO_700.get(color, -1);
|
||||
return statusTinted == -1 ? Optional.<Integer>absent() : Optional.of(statusTinted);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ import android.graphics.drawable.Drawable;
|
||||
|
||||
public interface ContactPhoto {
|
||||
|
||||
public Drawable asDrawable(Context context, int background);
|
||||
public Drawable asDrawable(Context context, int color);
|
||||
public Drawable asDrawable(Context context, int color, boolean inverted);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.contacts.avatars;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
@@ -18,14 +19,20 @@ public class GeneratedContactPhoto implements ContactPhoto {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable asDrawable(Context context, int background) {
|
||||
public Drawable asDrawable(Context context, int color) {
|
||||
return asDrawable(context, color, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable asDrawable(Context context, int color, boolean inverted) {
|
||||
int targetSize = context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size);
|
||||
|
||||
return TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.width(targetSize)
|
||||
.height(targetSize)
|
||||
.textColor(inverted ? color : Color.WHITE)
|
||||
.endConfig()
|
||||
.buildRound(String.valueOf(name.charAt(0)), background);
|
||||
.buildRound(String.valueOf(name.charAt(0)), inverted ? Color.WHITE : color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package org.thoughtcrime.securesms.contacts.avatars;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.support.v4.graphics.ColorUtils;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
@@ -17,11 +21,21 @@ public class ResourceContactPhoto implements ContactPhoto {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable asDrawable(Context context, int backgroundColor) {
|
||||
Drawable background = TextDrawable.builder().buildRound(" ", backgroundColor);
|
||||
public Drawable asDrawable(Context context, int color) {
|
||||
return asDrawable(context, color, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable asDrawable(Context context, int color, boolean inverted) {
|
||||
Drawable background = TextDrawable.builder().buildRound(" ", inverted ? Color.WHITE : color);
|
||||
RoundedDrawable foreground = (RoundedDrawable) RoundedDrawable.fromDrawable(context.getResources().getDrawable(resourceId));
|
||||
|
||||
foreground.setScaleType(ImageView.ScaleType.CENTER);
|
||||
|
||||
if (inverted) {
|
||||
foreground.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
|
||||
}
|
||||
|
||||
return new ExpandingLayerDrawable(new Drawable[] {background, foreground});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,12 @@ public class TransparentContactPhoto implements ContactPhoto {
|
||||
TransparentContactPhoto() {}
|
||||
|
||||
@Override
|
||||
public Drawable asDrawable(Context context, int background) {
|
||||
public Drawable asDrawable(Context context, int color) {
|
||||
return asDrawable(context, color, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable asDrawable(Context context, int color, boolean inverted) {
|
||||
return RoundedDrawable.fromDrawable(context.getResources().getDrawable(android.R.color.transparent));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user