mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-01-22 13:58:07 -05:00
27 lines
956 B
Java
27 lines
956 B
Java
package protect.card_locker;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Color;
|
|
|
|
import androidx.core.graphics.ColorUtils;
|
|
|
|
public class Utils {
|
|
static final double LUMINANCE_MIDPOINT = 0.5;
|
|
|
|
static public LetterBitmap generateIcon(Context context, String store, Integer backgroundColor) {
|
|
if (store.length() == 0) {
|
|
return null;
|
|
}
|
|
|
|
int tileLetterFontSize = context.getResources().getDimensionPixelSize(R.dimen.tileLetterFontSize);
|
|
int pixelSize = context.getResources().getDimensionPixelSize(R.dimen.cardThumbnailSize);
|
|
|
|
return new LetterBitmap(context, store, store,
|
|
tileLetterFontSize, pixelSize, pixelSize, backgroundColor, needsDarkForeground(backgroundColor) ? Color.BLACK : Color.WHITE);
|
|
}
|
|
|
|
static public boolean needsDarkForeground(Integer backgroundColor) {
|
|
return ColorUtils.calculateLuminance(backgroundColor) > LUMINANCE_MIDPOINT;
|
|
}
|
|
}
|