add a function for updating textview colors
This commit is contained in:
parent
5277947130
commit
8dd58b4835
2 changed files with 18 additions and 2 deletions
|
@ -8,6 +8,8 @@ import android.os.Build
|
|||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.view.MenuItem
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.simplemobiletools.commons.helpers.APP_LICENSES
|
||||
import com.simplemobiletools.commons.helpers.APP_NAME
|
||||
import com.simplemobiletools.commons.helpers.BaseConfig
|
||||
|
@ -38,6 +40,18 @@ open class BaseSimpleActivity : AppCompatActivity() {
|
|||
window.decorView.setBackgroundColor(baseConfig.backgroundColor)
|
||||
}
|
||||
|
||||
fun updateTextColors(viewGroup: ViewGroup) {
|
||||
val cnt = viewGroup.childCount
|
||||
(0..cnt - 1).map { viewGroup.getChildAt(it) }
|
||||
.forEach {
|
||||
if (it is TextView) {
|
||||
it.setTextColor(baseConfig.textColor)
|
||||
} else if (it is ViewGroup) {
|
||||
updateTextColors(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, resultData)
|
||||
if (requestCode == OPEN_DOCUMENT_TREE && resultCode == Activity.RESULT_OK && resultData != null) {
|
||||
|
|
|
@ -12,9 +12,10 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
setContentView(R.layout.activity_customization)
|
||||
|
||||
setupColors()
|
||||
updateTextColors(customization_holder)
|
||||
|
||||
customization_text_color_holder.setOnClickListener { pickTextColor() }
|
||||
customization_background_color_holder.setOnClickListener { pickbackgroundColor() }
|
||||
customization_background_color_holder.setOnClickListener { pickBackgroundColor() }
|
||||
customization_primary_color_holder.setOnClickListener { pickPrimaryColor() }
|
||||
}
|
||||
|
||||
|
@ -32,11 +33,12 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
override fun onOk(dialog: AmbilWarnaDialog, color: Int) {
|
||||
baseConfig.textColor = color
|
||||
setupColors()
|
||||
updateTextColors(customization_holder)
|
||||
}
|
||||
}).show()
|
||||
}
|
||||
|
||||
private fun pickbackgroundColor() {
|
||||
private fun pickBackgroundColor() {
|
||||
AmbilWarnaDialog(this, baseConfig.backgroundColor, object : AmbilWarnaDialog.OnAmbilWarnaListener {
|
||||
override fun onCancel(dialog: AmbilWarnaDialog) {
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue