From d9459dc8fa1fd455b5484ee48902c7d73c5ab9b3 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Tue, 28 Jun 2022 12:44:59 +0300 Subject: [PATCH] Ui adjustments --- .../kotatsu/history/ui/util/ReadingProgressDrawable.kt | 7 +++++-- app/src/main/res/values/styles.xml | 3 ++- app/src/main/res/xml/pref_history.xml | 6 ++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/koitharu/kotatsu/history/ui/util/ReadingProgressDrawable.kt b/app/src/main/java/org/koitharu/kotatsu/history/ui/util/ReadingProgressDrawable.kt index 3500d9398..1e985b9f1 100644 --- a/app/src/main/java/org/koitharu/kotatsu/history/ui/util/ReadingProgressDrawable.kt +++ b/app/src/main/java/org/koitharu/kotatsu/history/ui/util/ReadingProgressDrawable.kt @@ -20,6 +20,7 @@ class ReadingProgressDrawable( private val textColor: Int private val textPattern = context.getString(R.string.percent_string_pattern) private val textBounds = Rect() + private val tempRect = Rect() private val hasBackground: Boolean private val hasOutline: Boolean private val hasText: Boolean @@ -63,6 +64,8 @@ class ReadingProgressDrawable( if (autoFitTextSize) { val innerWidth = bounds.width() - (paint.strokeWidth * 2f) paint.textSize = getTextSizeForWidth(innerWidth, "100%") + paint.getTextBounds(text, 0, text.length, textBounds) + invalidateSelf() } } @@ -122,7 +125,7 @@ class ReadingProgressDrawable( private fun getTextSizeForWidth(width: Float, text: String): Float { val testTextSize = 48f paint.textSize = testTextSize - paint.getTextBounds(text, 0, text.length, textBounds) - return testTextSize * width / textBounds.width() + paint.getTextBounds(text, 0, text.length, tempRect) + return testTextSize * width / tempRect.width() } } \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index b3f122cec..ba37673c2 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -182,6 +182,7 @@ ?android:textColorPrimary 3dp 9sp + true - + diff --git a/app/src/main/res/xml/pref_history.xml b/app/src/main/res/xml/pref_history.xml index 38000e3f4..e046bf8fa 100644 --- a/app/src/main/res/xml/pref_history.xml +++ b/app/src/main/res/xml/pref_history.xml @@ -32,8 +32,7 @@ android:key="thumbs_cache_clear" android:persistent="false" android:summary="@string/computing_" - android:title="@string/clear_thumbs_cache" - app:allowDividerAbove="true" /> + android:title="@string/clear_thumbs_cache" /> + android:title="@string/clear_cookies" />