From a5cbee2b45b6f45743406a65eac7091bdfc7b03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Thu, 25 Mar 2021 17:29:43 +0100 Subject: [PATCH] [UI/Settings] Fix profile image button icon background. --- .../ui/dialogs/profile/ProfileConfigDialog.kt | 12 ++++++++++++ app/src/main/res/layout/dialog_profile_config.xml | 12 +++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/profile/ProfileConfigDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/profile/ProfileConfigDialog.kt index 6d51d3a1..dbfdd4e4 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/profile/ProfileConfigDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/profile/ProfileConfigDialog.kt @@ -4,9 +4,12 @@ package pl.szczodrzynski.edziennik.ui.dialogs.profile +import android.content.res.ColorStateList import androidx.appcompat.app.AlertDialog import androidx.core.widget.addTextChangedListener +import com.google.android.material.color.MaterialColors import com.google.android.material.dialog.MaterialAlertDialogBuilder +import com.google.android.material.shape.MaterialShapeDrawable import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -59,6 +62,15 @@ class ProfileConfigDialog( b.profile = profile profile.applyImageTo(b.image) + // I can't believe how simple it is to get the dialog's background color !! + val shape = MaterialShapeDrawable(activity, null, R.attr.alertDialogStyle, R.style.MaterialAlertDialog_MaterialComponents) + val surface = MaterialColors.getColor(activity, R.attr.colorSurface, TAG) + shape.setCornerSize(18.dp.toFloat()) + shape.initializeElevationOverlay(activity) + shape.fillColor = ColorStateList.valueOf(surface) + shape.elevation = 16.dp.toFloat() + b.circleView.background = shape + b.nameEdit.addTextChangedListener { profileChanged = true } diff --git a/app/src/main/res/layout/dialog_profile_config.xml b/app/src/main/res/layout/dialog_profile_config.xml index e83af680..ecba48da 100644 --- a/app/src/main/res/layout/dialog_profile_config.xml +++ b/app/src/main/res/layout/dialog_profile_config.xml @@ -39,16 +39,22 @@ android:scaleType="centerCrop" tools:src="@drawable/face_1" /> + + + app:iiv_padding="5dp" + tools:background="@color/colorSurface_16dp" />