Skip to content

Commit 76c25f6

Browse files
committed
Improve code readability of AztecToolbar.selectHeadingMenuItem and selectListMenuItem
1 parent 7af03ae commit 76c25f6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -629,16 +629,17 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
629629
updateHeadingMenuItem(AztecTextFormat.FORMAT_PARAGRAPH, headingButton)
630630
headingMenu?.menu?.findItem(R.id.paragraph)?.isChecked = true
631631
if (textFormats.size != 0) {
632-
textFormats.forEach {
632+
foreach@ for (it in textFormats) {
633633
when (it) {
634634
AztecTextFormat.FORMAT_HEADING_1 -> headingMenu?.menu?.findItem(R.id.heading_1)?.isChecked = true
635635
AztecTextFormat.FORMAT_HEADING_2 -> headingMenu?.menu?.findItem(R.id.heading_2)?.isChecked = true
636636
AztecTextFormat.FORMAT_HEADING_3 -> headingMenu?.menu?.findItem(R.id.heading_3)?.isChecked = true
637637
AztecTextFormat.FORMAT_HEADING_4 -> headingMenu?.menu?.findItem(R.id.heading_4)?.isChecked = true
638638
AztecTextFormat.FORMAT_HEADING_5 -> headingMenu?.menu?.findItem(R.id.heading_5)?.isChecked = true
639639
AztecTextFormat.FORMAT_HEADING_6 -> headingMenu?.menu?.findItem(R.id.heading_6)?.isChecked = true
640-
// TODO: Uncomment when Preformat is to be added back as a feature
641-
// AztecTextFormat.FORMAT_PREFORMAT -> headingMenu?.menu?.findItem(R.id.preformat)?.isChecked = true
640+
// TODO: Uncomment when Preformat is to be added back as a feature
641+
// AztecTextFormat.FORMAT_PREFORMAT -> headingMenu?.menu?.findItem(R.id.preformat)?.isChecked = true
642+
else -> continue@foreach
642643
}
643644

644645
updateHeadingMenuItem(it, headingButton)
@@ -651,10 +652,11 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
651652
updateListMenuItem(AztecTextFormat.FORMAT_NONE, listButton)
652653
listMenu?.menu?.findItem(R.id.list_none)?.isChecked = true
653654
if (textFormats.size != 0) {
654-
textFormats.forEach {
655+
foreach@ for (it in textFormats) {
655656
when (it) {
656657
AztecTextFormat.FORMAT_UNORDERED_LIST -> listMenu?.menu?.findItem(R.id.list_unordered)?.isChecked = true
657658
AztecTextFormat.FORMAT_ORDERED_LIST -> listMenu?.menu?.findItem(R.id.list_ordered)?.isChecked = true
659+
else -> continue@foreach
658660
}
659661
updateListMenuItem(it, listButton)
660662
}
@@ -873,7 +875,7 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
873875
// keep default background and content description
874876
}
875877
else -> {
876-
// ignore for unknown formats
878+
AppLog.w(AppLog.T.EDITOR, "Unknown list menu item - text format")
877879
return
878880
}
879881
}
@@ -916,7 +918,7 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
916918
check = false
917919
}
918920
else -> {
919-
// ignore for unknown textFormats
921+
AppLog.w(AppLog.T.EDITOR, "Unknown heading menu item - text format")
920922
return
921923
}
922924
}

0 commit comments

Comments
 (0)