diff --git a/app/src/main/java/org/p2p/wallet/settings/ui/security/SecurityAndPrivacyFragment.kt b/app/src/main/java/org/p2p/wallet/settings/ui/security/SecurityAndPrivacyFragment.kt index 7268d9479a..f13c0281ae 100644 --- a/app/src/main/java/org/p2p/wallet/settings/ui/security/SecurityAndPrivacyFragment.kt +++ b/app/src/main/java/org/p2p/wallet/settings/ui/security/SecurityAndPrivacyFragment.kt @@ -10,12 +10,14 @@ import org.p2p.core.utils.insets.consume import org.p2p.core.utils.insets.doOnApplyWindowInsets import org.p2p.core.utils.insets.systemAndIme import org.p2p.uikit.utils.getColor +import org.p2p.uikit.utils.toPx import org.p2p.wallet.R import org.p2p.wallet.common.mvp.BaseMvpFragment import org.p2p.wallet.databinding.FragmentSecurityAndPrivacyBinding import org.p2p.wallet.intercom.IntercomService import org.p2p.wallet.settings.ui.devices.DevicesFragment import org.p2p.wallet.settings.ui.security.unlock.SeedPhraseUnlockFragment +import org.p2p.wallet.utils.DrawableUtils.getDrawableWithSizes import org.p2p.wallet.utils.popBackStack import org.p2p.wallet.utils.replaceFragment import org.p2p.wallet.utils.showInfoDialog @@ -65,7 +67,14 @@ class SecurityAndPrivacyFragment : binding.recoveryViewDevice.apply { subtitle = deviceName if (showWarning) { - setSubtitleDrawable(left = R.drawable.ic_warning_solid) + val drawableSize = 16.toPx() + val scaledDrawable = getDrawableWithSizes( + context = requireContext(), + drawableId = R.drawable.ic_warning_solid, + width = drawableSize, + height = drawableSize + ) + setSubtitleDrawable(left = scaledDrawable) setSubtitleColor(getColor(R.color.icons_rose)) } } diff --git a/app/src/main/java/org/p2p/wallet/utils/DrawableUtils.kt b/app/src/main/java/org/p2p/wallet/utils/DrawableUtils.kt new file mode 100644 index 0000000000..e070162fe5 --- /dev/null +++ b/app/src/main/java/org/p2p/wallet/utils/DrawableUtils.kt @@ -0,0 +1,26 @@ +package org.p2p.wallet.utils + +import androidx.annotation.Dimension +import androidx.annotation.DrawableRes +import androidx.appcompat.content.res.AppCompatResources +import android.content.Context +import android.graphics.drawable.Drawable +import android.graphics.drawable.LayerDrawable + +object DrawableUtils { + fun getDrawableWithSizes( + context: Context, + @DrawableRes drawableId: Int, + @Dimension(unit = Dimension.DP) + width: Int, + @Dimension(unit = Dimension.DP) + height: Int, + ): Drawable? { + val drawable = AppCompatResources.getDrawable(context, drawableId) ?: return null + return getResizedDrawableUsingSpecificSize(drawable, width, height) + } + + private fun getResizedDrawableUsingSpecificSize(drawable: Drawable, newWidth: Int, newHeight: Int): LayerDrawable { + return LayerDrawable(arrayOf(drawable)).also { it.setLayerSize(0, newWidth, newHeight) } + } +} diff --git a/ui-kit/src/main/kotlin/org/p2p/uikit/atoms/UiKitStartAmountView.kt b/ui-kit/src/main/kotlin/org/p2p/uikit/atoms/UiKitStartAmountView.kt index 5792831539..5ab9f71061 100644 --- a/ui-kit/src/main/kotlin/org/p2p/uikit/atoms/UiKitStartAmountView.kt +++ b/ui-kit/src/main/kotlin/org/p2p/uikit/atoms/UiKitStartAmountView.kt @@ -5,6 +5,7 @@ import androidx.annotation.DrawableRes import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.res.use import android.content.Context +import android.graphics.drawable.Drawable import android.util.AttributeSet import org.p2p.uikit.R import org.p2p.uikit.databinding.WidgetStartAmountViewBinding @@ -53,6 +54,15 @@ class UiKitStartAmountView @JvmOverloads constructor( binding.subtitleTextView.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom) } + fun setSubtitleDrawable( + left: Drawable? = null, + top: Drawable? = null, + right: Drawable? = null, + bottom: Drawable? = null + ) { + binding.subtitleTextView.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom) + } + fun setSubtitleColor(@ColorInt subtitleTextColor: Int) { binding.subtitleTextView.setTextColor(subtitleTextColor) }