|
|
@ -5,7 +5,32 @@ import android.view.View;
|
|
|
|
import com.amulyakhare.textdrawable.TextDrawable;
|
|
|
|
import com.amulyakhare.textdrawable.TextDrawable;
|
|
|
|
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
|
|
|
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
|
|
|
|
public class TextDrawableHelper {
|
|
|
|
public class TextDrawableHelper {
|
|
|
|
|
|
|
|
// taken from: https://materialuicolors.co (level 700)
|
|
|
|
|
|
|
|
private static ColorGenerator _generator = ColorGenerator.create(Arrays.asList(
|
|
|
|
|
|
|
|
0xFFD32F2F,
|
|
|
|
|
|
|
|
0xFFC2185B,
|
|
|
|
|
|
|
|
0xFF7B1FA2,
|
|
|
|
|
|
|
|
0xFF512DA8,
|
|
|
|
|
|
|
|
0xFF303F9F,
|
|
|
|
|
|
|
|
0xFF1976D2,
|
|
|
|
|
|
|
|
0xFF0288D1,
|
|
|
|
|
|
|
|
0xFF0097A7,
|
|
|
|
|
|
|
|
0xFF00796B,
|
|
|
|
|
|
|
|
0xFF388E3C,
|
|
|
|
|
|
|
|
0xFF689F38,
|
|
|
|
|
|
|
|
0xFFAFB42B,
|
|
|
|
|
|
|
|
0xFFFBC02D,
|
|
|
|
|
|
|
|
0xFFFFA000,
|
|
|
|
|
|
|
|
0xFFF57C00,
|
|
|
|
|
|
|
|
0xFFE64A19,
|
|
|
|
|
|
|
|
0xFF5D4037,
|
|
|
|
|
|
|
|
0xFF616161,
|
|
|
|
|
|
|
|
0xFF455A64
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
private TextDrawableHelper() {
|
|
|
|
private TextDrawableHelper() {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -18,7 +43,7 @@ public class TextDrawableHelper {
|
|
|
|
text = fallback;
|
|
|
|
text = fallback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int color = ColorGenerator.MATERIAL.getColor(text);
|
|
|
|
int color = _generator.getColor(text);
|
|
|
|
return TextDrawable.builder().beginConfig()
|
|
|
|
return TextDrawable.builder().beginConfig()
|
|
|
|
.width(view.getLayoutParams().width)
|
|
|
|
.width(view.getLayoutParams().width)
|
|
|
|
.height(view.getLayoutParams().height)
|
|
|
|
.height(view.getLayoutParams().height)
|
|
|
|