updating some things related to dialog background colors

This commit is contained in:
tibbi 2016-12-18 23:50:19 +01:00
parent 986bbb9b6c
commit 31d250efa6
4 changed files with 10 additions and 8 deletions

View file

@ -15,9 +15,10 @@ class ConfirmationAdvancedDialog(context: Context, message: String = "", message
init {
val baseConfig = BaseConfig.newInstance(context)
val backgroundColor = baseConfig.backgroundColor
val view = LayoutInflater.from(context).inflate(R.layout.dialog_message, null)
view.message.text = if (message.isEmpty()) context.resources.getString(messageId) else message
view.message.setTextColor(baseConfig.backgroundColor.getContrastColor())
view.message.setTextColor(backgroundColor.getContrastColor())
val builder = AlertDialog.Builder(context)
.setView(view)
@ -30,7 +31,7 @@ class ConfirmationAdvancedDialog(context: Context, message: String = "", message
show()
getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(primaryColor)
getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(primaryColor)
window.setBackgroundDrawable(context.getDialogBackgroundColor(baseConfig))
window.setBackgroundDrawable(context.getDialogBackgroundColor(backgroundColor))
}
}

View file

@ -25,9 +25,10 @@ class ConfirmationDialog(context: Context, message: String = "", messageId: Int
init {
val baseConfig = BaseConfig.newInstance(context)
val backgroundColor = baseConfig.backgroundColor
val view = LayoutInflater.from(context).inflate(R.layout.dialog_message, null)
view.message.text = if (message.isEmpty()) context.resources.getString(messageId) else message
view.message.setTextColor(baseConfig.backgroundColor.getContrastColor())
view.message.setTextColor(backgroundColor.getContrastColor())
val builder = AlertDialog.Builder(context)
.setView(view)
@ -42,7 +43,7 @@ class ConfirmationDialog(context: Context, message: String = "", messageId: Int
show()
getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(primaryColor)
getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(primaryColor)
window.setBackgroundDrawable(context.getDialogBackgroundColor(baseConfig))
window.setBackgroundDrawable(context.getDialogBackgroundColor(backgroundColor))
}
}

View file

@ -4,15 +4,16 @@ import android.app.Activity
import android.app.AlertDialog
import android.view.LayoutInflater
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.extensions.getDialogBackgroundColor
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 baseConfig = BaseConfig.newInstance(activity)
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_whats_new, null)
view.whats_new_content.text = getNewReleases()
@ -26,6 +27,7 @@ class WhatsNewDialog(val activity: Activity, val releases: List<Release>) {
setCanceledOnTouchOutside(true)
show()
getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(primaryColor)
window.setBackgroundDrawable(context.getDialogBackgroundColor(baseConfig.backgroundColor))
}
}

View file

@ -6,7 +6,6 @@ import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.widget.Toast
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.helpers.BaseConfig
import com.simplemobiletools.commons.helpers.PREFS_KEY
fun Context.toast(id: Int, length: Int = Toast.LENGTH_SHORT) = Toast.makeText(this, id, length).show()
@ -15,8 +14,7 @@ fun Context.toast(msg: String, length: Int = Toast.LENGTH_SHORT) = Toast.makeTex
fun Context.getSharedPrefs() = getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE)
fun Context.getDialogBackgroundColor(baseConfig: BaseConfig): Drawable {
val backgroundColor = baseConfig.backgroundColor
fun Context.getDialogBackgroundColor(backgroundColor: Int): Drawable {
return ColorDrawable(if (backgroundColor.getContrastColor() == Color.WHITE) {
getColor(R.color.dark_dialog_background)
} else {