mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-28 21:36:26 +00:00
Fix MagiskDialog
This commit is contained in:
@@ -6,10 +6,7 @@ import android.graphics.drawable.Drawable
|
||||
import android.view.ContextThemeWrapper
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.PopupMenu
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import android.widget.*
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.view.updateLayoutParams
|
||||
@@ -166,8 +163,8 @@ fun RecyclerView.setDividers(dividerVertical: Drawable?, dividerHorizontal: Draw
|
||||
}
|
||||
|
||||
@BindingAdapter("app:icon")
|
||||
fun MaterialButton.setIconRes(res: Int) {
|
||||
setIconResource(res)
|
||||
fun Button.setIconRes(res: Int) {
|
||||
(this as MaterialButton).setIconResource(res)
|
||||
}
|
||||
|
||||
@BindingAdapter("strokeWidth")
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.view.WindowManager
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AppCompatDialog
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.updatePadding
|
||||
import androidx.databinding.Bindable
|
||||
@@ -77,13 +78,9 @@ class MagiskDialog(
|
||||
override var callbacks: PropertyChangeRegistry? = null
|
||||
|
||||
@get:Bindable
|
||||
var icon = 0
|
||||
var icon: Drawable? = null
|
||||
set(value) = set(value, field, { field = it }, BR.icon)
|
||||
|
||||
@get:Bindable
|
||||
var iconRaw: Drawable? = null
|
||||
set(value) = set(value, field, { field = it }, BR.iconRaw)
|
||||
|
||||
@get:Bindable
|
||||
var title: CharSequence = ""
|
||||
set(value) = set(value, field, { field = it }, BR.title)
|
||||
@@ -185,10 +182,12 @@ class MagiskDialog(
|
||||
apply { data.message = message }
|
||||
|
||||
fun applyIcon(@DrawableRes drawableRes: Int) =
|
||||
apply { data.icon = drawableRes }
|
||||
apply {
|
||||
data.icon = AppCompatResources.getDrawable(context, drawableRes)
|
||||
}
|
||||
|
||||
fun applyIcon(drawable: Drawable) =
|
||||
apply { data.iconRaw = drawable }
|
||||
apply { data.icon = drawable }
|
||||
|
||||
fun applyButton(buttonType: ButtonType, builder: ButtonBuilder.() -> Unit) = apply {
|
||||
val button = when (buttonType) {
|
||||
@@ -269,7 +268,7 @@ class MagiskDialog(
|
||||
|
||||
fun resetTitle() = applyTitle("")
|
||||
fun resetMessage() = applyMessage("")
|
||||
fun resetIcon() = applyIcon(0)
|
||||
fun resetIcon() = apply { data.icon = null }
|
||||
|
||||
fun resetButtons() = apply {
|
||||
ButtonType.values().forEach {
|
||||
|
||||
Reference in New Issue
Block a user