Use background from theme for MaterialAlertDialog

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2023-06-29 17:59:12 +05:30
parent ed64eb3226
commit d4df0b4571
2 changed files with 1 additions and 8 deletions

View File

@@ -21,7 +21,6 @@ package com.aurora.extensions
import android.content.Context
import android.content.DialogInterface
import android.graphics.drawable.ColorDrawable
import androidx.annotation.StringRes
import androidx.fragment.app.Fragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
@@ -41,7 +40,6 @@ fun Context.showDialog(
negativeListener: DialogInterface.OnClickListener?
) {
runOnUiThread {
val backgroundColor: Int = getStyledAttributeColor(android.R.attr.colorBackground)
val builder = MaterialAlertDialogBuilder(this).apply {
setTitle(title)
setMessage(message)
@@ -56,7 +54,6 @@ fun Context.showDialog(
setNegativeButton(android.R.string.cancel, negativeListener)
}
background = ColorDrawable(backgroundColor)
}.create()
builder.show()
@@ -69,4 +66,4 @@ fun Fragment.showDialog(@StringRes titleId: Int, @StringRes messageId: Int) {
fun Fragment.showDialog(title: String, message: String) {
requireContext().showDialog(title, message)
}
}

View File

@@ -19,12 +19,10 @@
package com.aurora.store.view.ui.preferences
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.MenuItem
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.aurora.extensions.getStyledAttributeColor
import com.aurora.extensions.restartApp
import com.aurora.store.R
import com.aurora.store.databinding.ActivitySettingBinding
@@ -144,8 +142,6 @@ class SettingsActivity : BaseActivity(),
restartApp()
}
.setNegativeButton(getString(R.string.action_later)) { dialog, _ -> dialog.dismiss() }
val backGroundColor = getStyledAttributeColor(android.R.attr.colorBackground)
builder.background = ColorDrawable(backGroundColor)
builder.create()
builder.show()
}