From fe6a16fdc89f4c0f40d59b8266eae98ad793b2fb Mon Sep 17 00:00:00 2001 From: Jakob Nixdorf Date: Wed, 29 Jan 2020 11:03:59 +0100 Subject: [PATCH] Scale the LetterBitmap with the tile size --- .../flocke/andotp/Utilities/LetterBitmap.java | 15 ++++++--------- app/src/main/res/values/dimens.xml | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/LetterBitmap.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/LetterBitmap.java index a0b18314..d2909d72 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/LetterBitmap.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/LetterBitmap.java @@ -27,13 +27,13 @@ import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.Typeface; import android.text.TextPaint; +import android.util.TypedValue; import org.shadowice.flocke.andotp.R; @@ -76,11 +76,7 @@ class LetterBitmap { /** * The font size used to display the letter */ - private final int mTileLetterFontSize; - /** - * The default image to display - */ - private final Bitmap mDefaultBitmap; + private final float mTileLetterFontSizeScale; /** * Constructor for LetterTileProvider @@ -96,9 +92,10 @@ class LetterBitmap { mPaint.setAntiAlias(true); mColors = res.obtainTypedArray(R.array.letter_tile_colors); - mTileLetterFontSize = res.getDimensionPixelSize(R.dimen.tile_letter_font_size); - mDefaultBitmap = BitmapFactory.decodeResource(res, android.R.drawable.sym_def_app_icon); + TypedValue typedValue = new TypedValue(); + res.getValue(R.dimen.tile_letter_font_size_scale, typedValue, true); + mTileLetterFontSizeScale = typedValue.getFloat(); } /** @@ -123,7 +120,7 @@ class LetterBitmap { c.drawColor(pickColor(key)); mFirstChar[0] = Character.toUpperCase(firstChar); - mPaint.setTextSize(mTileLetterFontSize); + mPaint.setTextSize(mTileLetterFontSizeScale * height); mPaint.getTextBounds(mFirstChar, 0, 1, mBounds); c.drawText(mFirstChar, 0, 1, width / 2, height / 2 + (mBounds.bottom - mBounds.top) / 2, mPaint); diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 635094e0..ca7a6651 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -14,8 +14,8 @@ 64dp - - 33sp + + 0.75 200dp 1dp