From 6159ee36c48ece0b778d4bb494d53de2b395ad01 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Tue, 12 Dec 2023 10:40:59 +0530 Subject: [PATCH] Use TypedValueCompat --- .../org/koitharu/kotatsu/core/util/ext/Resources.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Resources.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Resources.kt index 1d12c85e5..4cfa36ecf 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Resources.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Resources.kt @@ -3,18 +3,18 @@ package org.koitharu.kotatsu.core.util.ext import android.annotation.SuppressLint import android.content.Context import android.content.res.Resources -import android.util.TypedValue import androidx.annotation.Px +import androidx.core.util.TypedValueCompat import kotlin.math.roundToInt @Px -fun Resources.resolveDp(dp: Int) = (dp * displayMetrics.density).roundToInt() +fun Resources.resolveDp(dp: Int) = resolveDp(dp.toFloat()).roundToInt() @Px -fun Resources.resolveDp(dp: Float) = dp * displayMetrics.density +fun Resources.resolveDp(dp: Float) = TypedValueCompat.dpToPx(dp, displayMetrics) @Px -fun Resources.resolveSp(sp: Float) = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, displayMetrics) +fun Resources.resolveSp(sp: Float) = TypedValueCompat.spToPx(sp, displayMetrics) @SuppressLint("DiscouragedApi") fun Context.getSystemBoolean(resName: String, fallback: Boolean): Boolean {