Skip to content

Commit 51e7d49

Browse files
committed
Fix toolbar color button not updated when cursor change
1 parent bd6aa80 commit 51e7d49

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/toolbar/AztecToolbar.kt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ class AztecToolbar : FrameLayout, IAztecToolbar, OnMenuItemClickListener {
393393

394394
editor.setSpanColor(color)
395395
colorPickerView?.setColor(color)
396+
updateToolbarColorButton(color)
396397
}
397398
})
398399

@@ -407,16 +408,7 @@ class AztecToolbar : FrameLayout, IAztecToolbar, OnMenuItemClickListener {
407408
this.colorPickerView = colorPickerView
408409
colorPickerView.setColorPickerListener(object : ColorPickerListener {
409410
override fun onPickColor(color: Int) {
410-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
411-
findViewById<View>(ToolbarAction.TEXTCOLOR.buttonId).apply {
412-
when (this) {
413-
is ImageButton -> {
414-
this.imageTintList = ColorStateList.valueOf(color)
415-
}
416-
else -> this.setBackgroundColor(color)
417-
}
418-
}
419-
}
411+
updateToolbarColorButton(color)
420412

421413
editor?.let {
422414

@@ -458,6 +450,18 @@ class AztecToolbar : FrameLayout, IAztecToolbar, OnMenuItemClickListener {
458450
})
459451
}
460452

453+
private fun updateToolbarColorButton(color: Int?) {
454+
val color2 = color ?: Color.BLACK
455+
findViewById<View>(ToolbarAction.TEXTCOLOR.buttonId).apply {
456+
when (this) {
457+
is ImageButton -> {
458+
this.imageTintList = ColorStateList.valueOf(color2)
459+
}
460+
else -> this.setBackgroundColor(color2)
461+
}
462+
}
463+
}
464+
461465
private fun initView(attrs: AttributeSet?) {
462466
val styles = context.obtainStyledAttributes(attrs, R.styleable.AztecToolbar, 0, R.style.AztecToolbarStyle)
463467
isAdvanced = styles.getBoolean(R.styleable.AztecToolbar_advanced, false)

0 commit comments

Comments
 (0)