From 9c8d302b44851af32101c728b96bfd973d8230b5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 27 Nov 2017 18:52:06 +0100 Subject: [PATCH] update the theme at changing the primary color --- .../commons/dialogs/LineColorPickerDialog.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/LineColorPickerDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/LineColorPickerDialog.kt index 59cb62385..4d2e758fc 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/LineColorPickerDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/LineColorPickerDialog.kt @@ -5,6 +5,7 @@ import android.view.View import android.view.WindowManager import com.simplemobiletools.commons.R import com.simplemobiletools.commons.activities.BaseSimpleActivity +import com.simplemobiletools.commons.extensions.getThemeId import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.interfaces.LineColorPickerListener import kotlinx.android.synthetic.main.dialog_line_color_picker.view.* @@ -28,16 +29,14 @@ class LineColorPickerDialog(val activity: BaseSimpleActivity, val color: Int, va override fun colorChanged(index: Int, color: Int) { val secondaryColors = getColorsForIndex(index) secondary_line_color_picker.updateColors(secondaryColors) - dialog?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) - activity.updateActionbarColor(secondary_line_color_picker.getCurrentColor()) + colorUpdated(secondary_line_color_picker.getCurrentColor()) } } secondary_line_color_picker.updateColors(getColorsForIndex(indexes.first), indexes.second) secondary_line_color_picker.listener = object : LineColorPickerListener { override fun colorChanged(index: Int, color: Int) { - dialog?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) - activity.updateActionbarColor(color) + colorUpdated(color) } } } @@ -51,6 +50,12 @@ class LineColorPickerDialog(val activity: BaseSimpleActivity, val color: Int, va } } + private fun colorUpdated(color: Int) { + dialog?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) + activity.updateActionbarColor(color) + activity.setTheme(activity.getThemeId(color)) + } + private fun getColorIndexes(color: Int): Pair { if (color == DEFAULT_COLOR_VALUE) { return getDefaultColorPair()