diff --git a/app/src/main/java/com/owncloud/android/utils/DrawableUtil.kt b/app/src/main/java/com/owncloud/android/utils/DrawableUtil.kt index a0288df259..286089dc35 100644 --- a/app/src/main/java/com/owncloud/android/utils/DrawableUtil.kt +++ b/app/src/main/java/com/owncloud/android/utils/DrawableUtil.kt @@ -1,9 +1,12 @@ package com.owncloud.android.utils +import android.content.Context import android.graphics.drawable.Drawable import android.graphics.drawable.LayerDrawable import android.view.Gravity import androidx.core.graphics.drawable.DrawableCompat +import com.nextcloud.utils.extensions.isLowDensityScreen +import com.nextcloud.utils.extensions.setLayerSizeWithInsetTop class DrawableUtil { @@ -13,10 +16,16 @@ class DrawableUtil { return drawable } - fun addDrawableAsOverlay(backgroundDrawable: Drawable, overlayDrawable: Drawable, topMargin: Int = 3): LayerDrawable { + fun addDrawableAsOverlay(context: Context, backgroundDrawable: Drawable, overlayDrawable: Drawable): LayerDrawable { + val isLowDensityScreen = context.resources.displayMetrics.isLowDensityScreen() + + val overlayIconSize = if (isLowDensityScreen) { 12 } else { 24 } + val overlayIconTopMargin = if (isLowDensityScreen) { 3 } else { 6 } + val layerDrawable = LayerDrawable(arrayOf(backgroundDrawable, overlayDrawable)) + layerDrawable.setLayerSizeWithInsetTop(1, overlayIconSize, overlayIconTopMargin) layerDrawable.setLayerGravity(1, Gravity.CENTER) - layerDrawable.setLayerInsetTop(1, topMargin) + return layerDrawable } } \ No newline at end of file