DroidFS/app/src/main/java/sushi/hardcore/droidfs/widgets/ColoredAlertDialogBuilder.kt

29 lines
937 B
Kotlin
Raw Normal View History

2020-07-17 16:35:39 +02:00
package sushi.hardcore.droidfs.widgets
import androidx.appcompat.app.AlertDialog
import android.content.Context
2020-07-27 16:20:52 +02:00
class ColoredAlertDialogBuilder: AlertDialog.Builder {
constructor(context: Context): super(context)
constructor(context: Context, themeResId: Int): super(context, themeResId)
2020-07-17 16:35:39 +02:00
private fun applyColor(dialog: AlertDialog){
dialog.setOnShowListener{
val themeColor = ThemeColor.getThemeColor(context)
for (i in listOf(AlertDialog.BUTTON_POSITIVE, AlertDialog.BUTTON_NEGATIVE, AlertDialog.BUTTON_NEUTRAL)){
dialog.getButton(i).setTextColor(themeColor)
}
}
}
override fun show(): AlertDialog? {
val dialog = super.create()
applyColor(dialog)
dialog.show()
return null
}
override fun create(): AlertDialog {
val dialog = super.create()
applyColor(dialog)
return dialog
}
}