From e01d7569a9f81cdab2f864d14c5aa56f8b693fd2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 14 Dec 2016 19:48:52 +0100 Subject: [PATCH] add colorpicker functionality --- .../activities/CustomizationActivity.kt | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/library/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt b/library/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt index af21a5fd7..d44047590 100644 --- a/library/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt +++ b/library/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt @@ -3,6 +3,7 @@ package com.simplemobiletools.commons.activities import android.os.Bundle import com.simplemobiletools.commons.R import kotlinx.android.synthetic.main.activity_customization.* +import yuku.ambilwarna.AmbilWarnaDialog class CustomizationActivity : BaseSimpleActivity() { @@ -10,12 +11,52 @@ class CustomizationActivity : BaseSimpleActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_customization) + setupColors() + + customization_text_color_holder.setOnClickListener { pickTextColor() } + customization_background_color_holder.setOnClickListener { pickbackgroundColor() } + customization_primary_color_holder.setOnClickListener { pickPrimaryColor() } + } + + private fun setupColors() { customization_text_color.setBackgroundColor(baseConfig.textColor) customization_background_color.setBackgroundColor(baseConfig.backgroundColor) customization_primary_color.setBackgroundColor(baseConfig.primaryColor) + } - customization_text_color_holder.setOnClickListener { } - customization_background_color_holder.setOnClickListener { } - customization_primary_color_holder.setOnClickListener { } + private fun pickTextColor() { + AmbilWarnaDialog(this, baseConfig.textColor, object : AmbilWarnaDialog.OnAmbilWarnaListener { + override fun onCancel(dialog: AmbilWarnaDialog) { + } + + override fun onOk(dialog: AmbilWarnaDialog, color: Int) { + baseConfig.textColor = color + setupColors() + } + }).show() + } + + private fun pickbackgroundColor() { + AmbilWarnaDialog(this, baseConfig.backgroundColor, object : AmbilWarnaDialog.OnAmbilWarnaListener { + override fun onCancel(dialog: AmbilWarnaDialog) { + } + + override fun onOk(dialog: AmbilWarnaDialog, color: Int) { + baseConfig.backgroundColor = color + setupColors() + } + }).show() + } + + private fun pickPrimaryColor() { + AmbilWarnaDialog(this, baseConfig.primaryColor, object : AmbilWarnaDialog.OnAmbilWarnaListener { + override fun onCancel(dialog: AmbilWarnaDialog) { + } + + override fun onOk(dialog: AmbilWarnaDialog, color: Int) { + baseConfig.primaryColor = color + setupColors() + } + }).show() } }