Ui adjustments

This commit is contained in:
Koitharu
2022-06-28 12:44:59 +03:00
parent a55ff5ce5a
commit d9459dc8fa
3 changed files with 9 additions and 7 deletions

View File

@@ -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()
}
}

View File

@@ -182,6 +182,7 @@
<item name="android:textColor">?android:textColorPrimary</item>
<item name="strokeWidth">3dp</item>
<item name="android:textSize">9sp</item>
<item name="autoFitTextSize">true</item>
</style>
</resources>

View File

@@ -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" />
<Preference
android:key="pages_cache_clear"
@@ -45,8 +44,7 @@
android:key="cookies_clear"
android:persistent="false"
android:summary="@string/clear_cookies_summary"
android:title="@string/clear_cookies"
app:allowDividerAbove="true" />
android:title="@string/clear_cookies" />
</PreferenceCategory>