Skip to content

Commit c4af95f

Browse files
committed
Update heading menu item icons and selectors
1 parent c40835b commit c4af95f

25 files changed

+375
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,30 +193,37 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
193193
when (item?.itemId) {
194194
R.id.paragraph -> {
195195
editor?.toggleFormatting(TextFormat.FORMAT_PARAGRAPH)
196+
setHeadingMenuSelector(TextFormat.FORMAT_PARAGRAPH)
196197
return true
197198
}
198199
R.id.heading_1 -> {
199200
editor?.toggleFormatting(TextFormat.FORMAT_HEADING_1)
201+
setHeadingMenuSelector(TextFormat.FORMAT_HEADING_1)
200202
return true
201203
}
202204
R.id.heading_2 -> {
203205
editor?.toggleFormatting(TextFormat.FORMAT_HEADING_2)
206+
setHeadingMenuSelector(TextFormat.FORMAT_HEADING_2)
204207
return true
205208
}
206209
R.id.heading_3 -> {
207210
editor?.toggleFormatting(TextFormat.FORMAT_HEADING_3)
211+
setHeadingMenuSelector(TextFormat.FORMAT_HEADING_3)
208212
return true
209213
}
210214
R.id.heading_4 -> {
211215
editor?.toggleFormatting(TextFormat.FORMAT_HEADING_4)
216+
setHeadingMenuSelector(TextFormat.FORMAT_HEADING_4)
212217
return true
213218
}
214219
R.id.heading_5 -> {
215220
editor?.toggleFormatting(TextFormat.FORMAT_HEADING_5)
221+
setHeadingMenuSelector(TextFormat.FORMAT_HEADING_5)
216222
return true
217223
}
218224
R.id.heading_6 -> {
219225
editor?.toggleFormatting(TextFormat.FORMAT_HEADING_6)
226+
setHeadingMenuSelector(TextFormat.FORMAT_HEADING_6)
220227
return true
221228
}
222229
// TODO: Uncomment when Preformat is to be added back as a feature
@@ -368,6 +375,8 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
368375
if (textFormats.size == 0) {
369376
// Select TextFormat.FORMAT_PARAGRAPH by default.
370377
headingMenu?.menu?.getItem(0)?.isChecked = true
378+
// Use unnumbered heading selector by default.
379+
setHeadingMenuSelector(TextFormat.FORMAT_PARAGRAPH)
371380
} else {
372381
textFormats.forEach {
373382
when (it) {
@@ -385,6 +394,8 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
385394
}
386395
}
387396

397+
setHeadingMenuSelector(it)
398+
388399
return
389400
}
390401
}
@@ -400,6 +411,22 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
400411
headingMenu?.inflate(R.menu.heading)
401412
}
402413

414+
private fun setHeadingMenuSelector(textFormat: TextFormat) {
415+
when (textFormat) {
416+
TextFormat.FORMAT_HEADING_1 -> findViewById(R.id.format_bar_button_heading).setBackgroundResource(R.drawable.format_bar_button_heading_1)
417+
TextFormat.FORMAT_HEADING_2 -> findViewById(R.id.format_bar_button_heading).setBackgroundResource(R.drawable.format_bar_button_heading_2)
418+
TextFormat.FORMAT_HEADING_3 -> findViewById(R.id.format_bar_button_heading).setBackgroundResource(R.drawable.format_bar_button_heading_3)
419+
TextFormat.FORMAT_HEADING_4 -> findViewById(R.id.format_bar_button_heading).setBackgroundResource(R.drawable.format_bar_button_heading_4)
420+
TextFormat.FORMAT_HEADING_5 -> findViewById(R.id.format_bar_button_heading).setBackgroundResource(R.drawable.format_bar_button_heading_5)
421+
TextFormat.FORMAT_HEADING_6 -> findViewById(R.id.format_bar_button_heading).setBackgroundResource(R.drawable.format_bar_button_heading_6)
422+
TextFormat.FORMAT_PARAGRAPH -> findViewById(R.id.format_bar_button_heading).setBackgroundResource(R.drawable.format_bar_button_heading)
423+
else -> {
424+
// Use unnumbered heading selector by default.
425+
findViewById(R.id.format_bar_button_heading).setBackgroundResource(R.drawable.format_bar_button_heading)
426+
}
427+
}
428+
}
429+
403430
fun getSelectedHeadingMenuItem(): TextFormat? {
404431
if (headingMenu?.menu?.getItem(0)?.isChecked!!) return TextFormat.FORMAT_PARAGRAPH
405432
else if (headingMenu?.menu?.getItem(1)?.isChecked!!) return TextFormat.FORMAT_HEADING_1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<vector
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
android:height="44dp"
6+
android:width="44dp"
7+
android:viewportHeight="44"
8+
android:viewportWidth="44" >
9+
10+
<!-- @color/grey_darken_20 -->
11+
<path
12+
android:fillColor="#ff4f748e"
13+
android:pathData="M21,17h2v10h-2v-4h-4v4h-2V17h2v4h4V17z M27.6,17c-0.6,0.9-1.5,1.7-2.6,2v1h2v7h2V17H27.6z" >
14+
</path>
15+
16+
</vector>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<vector
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
android:height="44dp"
6+
android:width="44dp"
7+
android:viewportHeight="44"
8+
android:viewportWidth="44" >
9+
10+
<!-- @color/grey_lighten_20 -->
11+
<path
12+
android:fillColor="#ffc8d7e1"
13+
android:pathData="M21,17h2v10h-2v-4h-4v4h-2V17h2v4h4V17z M27.6,17c-0.6,0.9-1.5,1.7-2.6,2v1h2v7h2V17H27.6z" >
14+
</path>
15+
16+
</vector>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<vector
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
android:height="44dp"
6+
android:width="44dp"
7+
android:viewportHeight="44"
8+
android:viewportWidth="44" >
9+
10+
<!-- @color/blue_wordpress -->
11+
<path
12+
android:fillColor="#ff0087be"
13+
android:pathData="M21,17h2v10h-2v-4h-4v4h-2V17h2v4h4V17z M27.6,17c-0.6,0.9-1.5,1.7-2.6,2v1h2v7h2V17H27.6z" >
14+
</path>
15+
16+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<selector
4+
xmlns:android="http://schemas.android.com/apk/res/android" >
5+
6+
<item android:drawable="@drawable/format_bar_button_heading_1_disabled" android:state_enabled="false" />
7+
<item android:drawable="@drawable/format_bar_button_heading_1_highlighted" android:state_focused="true" />
8+
<item android:drawable="@drawable/format_bar_button_heading_1" />
9+
10+
</selector>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<vector
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
android:height="44dp"
6+
android:width="44dp"
7+
android:viewportHeight="44"
8+
android:viewportWidth="44" >
9+
10+
<!-- @color/grey_darken_20 -->
11+
<path
12+
android:fillColor="#ff4f748e"
13+
android:pathData="M19,17h2v10h-2v-4h-4v4h-2V17h2v4h4V17z M27,25c0.5-0.4,0.6-0.6,1.1-1c0.4-0.4,0.8-0.8,1.2-1.3c0.3-0.4,0.6-0.8,0.9-1.3 c0.2-0.4,0.3-0.8,0.3-1.3c0-0.4-0.1-0.9-0.3-1.3c-0.2-0.4-0.4-0.7-0.8-1c-0.3-0.3-0.7-0.5-1.2-0.6c-0.5-0.2-1-0.2-1.5-0.2 c-0.4,0-0.7,0-1.1,0.1c-0.3,0.1-0.7,0.2-1,0.3c-0.3,0.1-0.6,0.3-0.9,0.5c-0.3,0.2-0.6,0.4-0.8,0.7l1.2,1.2c0.3-0.3,0.6-0.5,1-0.7 c0.4-0.2,0.7-0.3,1.1-0.3c0.5,0,0.9,0.1,1.3,0.4c0.3,0.3,0.5,0.7,0.5,1.1c0,0.4-0.1,0.8-0.4,1.1c-0.3,0.5-0.6,0.9-1,1.2 c-0.4,0.4-1,0.9-1.6,1.4s-1.4,1.1-2.2,1.6V27h8v-2H27z" >
14+
</path>
15+
16+
</vector>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<vector
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
android:height="44dp"
6+
android:width="44dp"
7+
android:viewportHeight="44"
8+
android:viewportWidth="44" >
9+
10+
<!-- @color/grey_lighten_20 -->
11+
<path
12+
android:fillColor="#ffc8d7e1"
13+
android:pathData="M19,17h2v10h-2v-4h-4v4h-2V17h2v4h4V17z M27,25c0.5-0.4,0.6-0.6,1.1-1c0.4-0.4,0.8-0.8,1.2-1.3c0.3-0.4,0.6-0.8,0.9-1.3 c0.2-0.4,0.3-0.8,0.3-1.3c0-0.4-0.1-0.9-0.3-1.3c-0.2-0.4-0.4-0.7-0.8-1c-0.3-0.3-0.7-0.5-1.2-0.6c-0.5-0.2-1-0.2-1.5-0.2 c-0.4,0-0.7,0-1.1,0.1c-0.3,0.1-0.7,0.2-1,0.3c-0.3,0.1-0.6,0.3-0.9,0.5c-0.3,0.2-0.6,0.4-0.8,0.7l1.2,1.2c0.3-0.3,0.6-0.5,1-0.7 c0.4-0.2,0.7-0.3,1.1-0.3c0.5,0,0.9,0.1,1.3,0.4c0.3,0.3,0.5,0.7,0.5,1.1c0,0.4-0.1,0.8-0.4,1.1c-0.3,0.5-0.6,0.9-1,1.2 c-0.4,0.4-1,0.9-1.6,1.4s-1.4,1.1-2.2,1.6V27h8v-2H27z" >
14+
</path>
15+
16+
</vector>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<vector
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
android:height="44dp"
6+
android:width="44dp"
7+
android:viewportHeight="44"
8+
android:viewportWidth="44" >
9+
10+
<!-- @color/blue_wordpress -->
11+
<path
12+
android:fillColor="#ff0087be"
13+
android:pathData="M19,17h2v10h-2v-4h-4v4h-2V17h2v4h4V17z M27,25c0.5-0.4,0.6-0.6,1.1-1c0.4-0.4,0.8-0.8,1.2-1.3c0.3-0.4,0.6-0.8,0.9-1.3 c0.2-0.4,0.3-0.8,0.3-1.3c0-0.4-0.1-0.9-0.3-1.3c-0.2-0.4-0.4-0.7-0.8-1c-0.3-0.3-0.7-0.5-1.2-0.6c-0.5-0.2-1-0.2-1.5-0.2 c-0.4,0-0.7,0-1.1,0.1c-0.3,0.1-0.7,0.2-1,0.3c-0.3,0.1-0.6,0.3-0.9,0.5c-0.3,0.2-0.6,0.4-0.8,0.7l1.2,1.2c0.3-0.3,0.6-0.5,1-0.7 c0.4-0.2,0.7-0.3,1.1-0.3c0.5,0,0.9,0.1,1.3,0.4c0.3,0.3,0.5,0.7,0.5,1.1c0,0.4-0.1,0.8-0.4,1.1c-0.3,0.5-0.6,0.9-1,1.2 c-0.4,0.4-1,0.9-1.6,1.4s-1.4,1.1-2.2,1.6V27h8v-2H27z" >
14+
</path>
15+
16+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<selector
4+
xmlns:android="http://schemas.android.com/apk/res/android" >
5+
6+
<item android:drawable="@drawable/format_bar_button_heading_2_disabled" android:state_enabled="false" />
7+
<item android:drawable="@drawable/format_bar_button_heading_2_highlighted" android:state_focused="true" />
8+
<item android:drawable="@drawable/format_bar_button_heading_2" />
9+
10+
</selector>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<vector
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
android:height="44dp"
6+
android:width="44dp"
7+
android:viewportHeight="44"
8+
android:viewportWidth="44" >
9+
10+
<!-- @color/grey_darken_20 -->
11+
<path
12+
android:fillColor="#ff4f748e"
13+
android:pathData="M24.1,24.2c0.4,0.3,0.7,0.5,1.2,0.7c0.4,0.2,0.9,0.3,1.4,0.3c0.5,0,1-0.1,1.4-0.3c0.3-0.1,0.5-0.5,0.5-0.8 c0-0.2,0-0.4-0.1-0.6c-0.1-0.2-0.3-0.3-0.5-0.4c-0.3-0.1-0.7-0.2-1-0.3c-0.5-0.1-1-0.1-1.5-0.1v-1.6c0.7,0.1,1.5-0.1,2.2-0.4 c0.4-0.2,0.6-0.5,0.6-0.9c0-0.3-0.1-0.6-0.4-0.8c-0.3-0.2-0.7-0.3-1.1-0.3c-0.4,0-0.8,0.1-1.1,0.3c-0.4,0.2-0.7,0.4-1.1,0.6 l-1.2-1.4c0.5-0.4,1.1-0.7,1.6-0.9c0.6-0.2,1.3-0.3,1.9-0.3c0.5,0,1,0,1.6,0.2c0.4,0.1,0.8,0.3,1.2,0.5c0.3,0.2,0.6,0.5,0.8,0.8 c0.2,0.3,0.3,0.7,0.3,1.1c0,0.5-0.2,0.9-0.5,1.3c-0.4,0.4-0.9,0.7-1.5,0.9v0.1c0.6,0.1,1.2,0.4,1.6,0.8c0.4,0.4,0.7,0.9,0.7,1.5 c0,0.4-0.1,0.8-0.3,1.2c-0.2,0.4-0.5,0.7-0.9,0.9c-0.4,0.3-0.9,0.4-1.3,0.5c-0.5,0.1-1,0.2-1.6,0.2c-0.8,0-1.6-0.1-2.3-0.4 c-0.6-0.2-1.1-0.6-1.6-1L24.1,24.2z M19,21h-4v-4h-2v10h2v-4h4v4h2V17h-2V21z" >
14+
</path>
15+
16+
</vector>

0 commit comments

Comments
 (0)