Fix reply-to colors in dark mode to increase contrast.

Fixes #7705
This commit is contained in:
Greyson Parrelli 2018-04-20 15:50:03 -07:00
parent 29af1669e1
commit cbe394025d
4 changed files with 41 additions and 19 deletions

View File

@ -34,6 +34,7 @@
<color name="transparent_white_20">#20ffffff</color>
<color name="transparent_white_30">#30ffffff</color>
<color name="transparent_white_40">#40ffffff</color>
<color name="transparent_white_60">#60ffffff</color>
<color name="transparent_white_70">#70ffffff</color>
<color name="transparent_white_aa">#aaffffff</color>

View File

@ -3,18 +3,19 @@ package org.thoughtcrime.securesms.color;
import android.content.Context;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.util.TypedValue;
import org.thoughtcrime.securesms.R;
import static org.thoughtcrime.securesms.util.ThemeUtil.isDarkTheme;
public enum MaterialColor {
RED (R.color.red_400, R.color.red_700, R.color.red_700, R.color.red_900, "red"),
PINK (R.color.pink_400, R.color.pink_700, R.color.pink_700, R.color.pink_900, "pink"),
PURPLE (R.color.purple_400, R.color.purple_700, R.color.purple_700, R.color.purple_900, "purple"),
DEEP_PURPLE(R.color.deep_purple_400, R.color.deep_purple_700, R.color.deep_purple_700, R.color.deep_purple_900, "deep_purple"),
INDIGO (R.color.indigo_400, R.color.indigo_700, R.color.indigo_700, R.color.indigo_900, "indigo"),
BLUE (R.color.blue_500, R.color.blue_700, R.color.blue_700, R.color.blue_900, "blue"),
LIGHT_BLUE (R.color.light_blue_500, R.color.light_blue_700, R.color.light_blue_700, R.color.light_blue_900, "light_blue"),
BLUE (R.color.blue_500, R.color.blue_800, R.color.blue_700, R.color.blue_900, "blue"),
LIGHT_BLUE (R.color.light_blue_500, R.color.light_blue_800, R.color.light_blue_700, R.color.light_blue_900, "light_blue"),
CYAN (R.color.cyan_500, R.color.cyan_700, R.color.cyan_700, R.color.cyan_900, "cyan"),
TEAL (R.color.teal_500, R.color.teal_700, R.color.teal_700, R.color.teal_900, "teal"),
GREEN (R.color.green_500, R.color.green_700, R.color.green_700, R.color.green_900, "green"),
@ -89,8 +90,12 @@ public enum MaterialColor {
public int toQuoteBackgroundColor(@NonNull Context context, boolean outgoing) {
if (outgoing) {
int color = toConversationColor(context);
return Color.argb(0x44, Color.red(color), Color.green(color), Color.blue(color));
if (isDarkTheme(context)) {
return context.getResources().getColor(R.color.transparent_white_60);
} else {
int color = toConversationColor(context);
return Color.argb(0x44, Color.red(color), Color.green(color), Color.blue(color));
}
}
return context.getResources().getColor(isDarkTheme(context) ? R.color.transparent_white_70
: R.color.transparent_white_aa);
@ -128,20 +133,6 @@ public enum MaterialColor {
return serialized;
}
private String getAttribute(Context context, int attribute, String defaultValue) {
TypedValue outValue = new TypedValue();
if (context.getTheme().resolveAttribute(attribute, outValue, true)) {
return outValue.coerceToString().toString();
} else {
return defaultValue;
}
}
private boolean isDarkTheme(@NonNull Context context) {
return getAttribute(context, R.attr.theme_type, "light").equals("dark");
}
public static MaterialColor fromSerialized(String serialized) throws UnknownColorException {
for (MaterialColor color : MaterialColor.values()) {
if (color.serialized.equals(serialized)) return color;

View File

@ -36,6 +36,7 @@ import org.thoughtcrime.securesms.mms.SlideDeck;
import org.thoughtcrime.securesms.mms.VideoSlide;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
import org.thoughtcrime.securesms.util.ThemeUtil;
import org.thoughtcrime.securesms.util.Util;
import java.util.List;
@ -263,6 +264,10 @@ public class QuoteView extends LinearLayout implements RecipientModifiedListener
attachmentIconContainerView.setVisibility(GONE);
dismissView.setBackgroundDrawable(null);
}
if (ThemeUtil.isDarkTheme(getContext())) {
dismissView.setBackgroundResource(R.drawable.circle_alpha);
}
}
public long getQuoteId() {

View File

@ -0,0 +1,25 @@
package org.thoughtcrime.securesms.util;
import android.content.Context;
import android.support.annotation.NonNull;
import android.util.TypedValue;
import org.thoughtcrime.securesms.R;
public class ThemeUtil {
public static boolean isDarkTheme(@NonNull Context context) {
return getAttribute(context, R.attr.theme_type, "light").equals("dark");
}
private static String getAttribute(Context context, int attribute, String defaultValue) {
TypedValue outValue = new TypedValue();
if (context.getTheme().resolveAttribute(attribute, outValue, true)) {
return outValue.coerceToString().toString();
} else {
return defaultValue;
}
}
}