Username search UI tweak.

This commit is contained in:
Alex Hart
2022-09-07 14:48:51 -03:00
committed by Greyson Parrelli
parent d458ddba55
commit 993e49db48
8 changed files with 83 additions and 23 deletions

View File

@@ -24,7 +24,8 @@ public enum AvatarColor {
A190("A190", 0xFFEAE6D5),
A200("A200", 0xFFD2D2DC),
A210("A210", 0xFFD7D7D9),
UNKNOWN("UNKNOWN", 0x00000000);
UNKNOWN("UNKNOWN", 0x00000000),
ON_SURFACE_VARIANT("ON_SURFACE_VARIANT", 0x00000000);
/** Fast map of name to enum, while also giving us a location to map old colors to new ones. */
private static final Map<String, AvatarColor> NAME_MAP = new HashMap<>();

View File

@@ -0,0 +1,32 @@
package org.thoughtcrime.securesms.conversation.colors
import android.content.Context
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.avatar.Avatars
class AvatarColorPair private constructor(
@ColorInt val foregroundColor: Int,
@ColorInt val backgroundColor: Int
) {
companion object {
@JvmStatic
fun create(context: Context, avatarColor: AvatarColor): AvatarColorPair {
return when (avatarColor) {
AvatarColor.UNKNOWN -> AvatarColorPair(
foregroundColor = ContextCompat.getColor(context, R.color.signal_colorOnSurface),
backgroundColor = ContextCompat.getColor(context, R.color.signal_colorSurfaceVariant)
)
AvatarColor.ON_SURFACE_VARIANT -> AvatarColorPair(
foregroundColor = ContextCompat.getColor(context, R.color.signal_colorOnSurfaceVariant),
backgroundColor = ContextCompat.getColor(context, R.color.signal_colorSurfaceVariant)
)
else -> AvatarColorPair(
foregroundColor = Avatars.getForegroundColor(avatarColor).colorInt,
backgroundColor = avatarColor.colorInt()
)
}
}
}
}