update dialog buttons with primary color

This commit is contained in:
tibbi 2016-12-14 21:39:07 +01:00
parent 3e0d74506e
commit 33a3ecbfad
2 changed files with 16 additions and 7 deletions

View file

@ -3,6 +3,7 @@ package com.simplemobiletools.commons.dialogs
import android.app.AlertDialog
import android.content.Context
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.helpers.BaseConfig
/**
* A simple dialog without any view, just a messageId, a positive button and optionally a negative button
@ -30,9 +31,13 @@ class ConfirmationDialog(context: Context, message: String = "", messageId: Int
if (negative != 0)
builder.setNegativeButton(negative, null)
dialog = builder.create()
dialog!!.setCanceledOnTouchOutside(true)
dialog!!.show()
val primaryColor = BaseConfig.newInstance(context).primaryColor
dialog = builder.create().apply {
setCanceledOnTouchOutside(true)
show()
getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(primaryColor)
getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(primaryColor)
}
}
private fun dialogConfirmed() {

View file

@ -8,20 +8,25 @@ import com.simplemobiletools.commons.helpers.BaseConfig
import com.simplemobiletools.commons.models.Release
import kotlinx.android.synthetic.main.dialog_whats_new.view.*
class WhatsNewDialog(val activity: Activity, val releases: List<Release>) {
var dialog: AlertDialog? = null
init {
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_whats_new, null)
view.whats_new_content.text = getNewReleases()
val builder = AlertDialog.Builder(activity)
.setTitle(R.string.whats_new)
.setView(view)
.setPositiveButton(R.string.ok, null)
dialog = builder.create()
dialog!!.setCanceledOnTouchOutside(true)
dialog!!.show()
val primaryColor = BaseConfig.newInstance(activity).primaryColor
dialog = builder.create().apply {
setCanceledOnTouchOutside(true)
show()
getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(primaryColor)
}
}
fun getNewReleases(): String {
@ -39,7 +44,6 @@ class WhatsNewDialog(val activity: Activity, val releases: List<Release>) {
}
config.lastVersion = if (releases.isEmpty()) 0 else releases.last().id
return sb.toString()
}
}