From bbb0036647a542d2f0df844c29dbf553c5625f98 Mon Sep 17 00:00:00 2001 From: jonnyandrew Date: Thu, 5 Jan 2023 13:07:19 +0000 Subject: [PATCH] [Rich text editor] Add list formatting buttons to the rich text editor (#7887) --- changelog.d/7887.feature | 1 + dependencies.gradle | 2 +- .../src/main/res/values/strings.xml | 2 ++ .../detail/composer/RichTextComposerLayout.kt | 6 +++++ .../res/drawable/ic_composer_bullet_list.xml | 13 ++++++++++ .../drawable/ic_composer_numbered_list.xml | 24 +++++++++++++++++++ .../res/layout/composer_rich_text_layout.xml | 2 ++ 7 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 changelog.d/7887.feature create mode 100644 vector/src/main/res/drawable/ic_composer_bullet_list.xml create mode 100644 vector/src/main/res/drawable/ic_composer_numbered_list.xml diff --git a/changelog.d/7887.feature b/changelog.d/7887.feature new file mode 100644 index 0000000000..1f1c29761a --- /dev/null +++ b/changelog.d/7887.feature @@ -0,0 +1 @@ +"[Rich text editor] Add list formatting buttons to the rich text editor" \ No newline at end of file diff --git a/dependencies.gradle b/dependencies.gradle index d8a97ba0b1..76ff9b0c6f 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -101,7 +101,7 @@ ext.libs = [ ], element : [ 'opusencoder' : "io.element.android:opusencoder:1.1.0", - 'wysiwyg' : "io.element.android:wysiwyg:0.10.0" + 'wysiwyg' : "io.element.android:wysiwyg:0.13.0" ], squareup : [ 'moshi' : "com.squareup.moshi:moshi:$moshi", diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 73cb60bb68..ec707bd39a 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -3485,6 +3485,8 @@ Apply strikethrough format Apply underline format Set link + Toggle numbered list + Toggle bullet list Toggle full screen mode Text diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/RichTextComposerLayout.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/RichTextComposerLayout.kt index 543210e006..1bb82b41fe 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/RichTextComposerLayout.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/RichTextComposerLayout.kt @@ -240,6 +240,12 @@ internal class RichTextComposerLayout @JvmOverloads constructor( } } } + addRichTextMenuItem(R.drawable.ic_composer_bullet_list, R.string.rich_text_editor_bullet_list, ComposerAction.UNORDERED_LIST) { + views.richTextComposerEditText.toggleList(ordered = false) + } + addRichTextMenuItem(R.drawable.ic_composer_numbered_list, R.string.rich_text_editor_numbered_list, ComposerAction.ORDERED_LIST) { + views.richTextComposerEditText.toggleList(ordered = true) + } } fun setLink(link: String?) = diff --git a/vector/src/main/res/drawable/ic_composer_bullet_list.xml b/vector/src/main/res/drawable/ic_composer_bullet_list.xml new file mode 100644 index 0000000000..f6febc88f0 --- /dev/null +++ b/vector/src/main/res/drawable/ic_composer_bullet_list.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/vector/src/main/res/drawable/ic_composer_numbered_list.xml b/vector/src/main/res/drawable/ic_composer_numbered_list.xml new file mode 100644 index 0000000000..d6a860c4c8 --- /dev/null +++ b/vector/src/main/res/drawable/ic_composer_numbered_list.xml @@ -0,0 +1,24 @@ + + + + + + + + diff --git a/vector/src/main/res/layout/composer_rich_text_layout.xml b/vector/src/main/res/layout/composer_rich_text_layout.xml index 3484616c72..7cc2d48cda 100644 --- a/vector/src/main/res/layout/composer_rich_text_layout.xml +++ b/vector/src/main/res/layout/composer_rich_text_layout.xml @@ -180,6 +180,8 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:minHeight="52dp" + android:requiresFadingEdge="horizontal" + android:fadingEdgeLength="28dp" app:layout_constraintTop_toBottomOf="@id/composerEditTextOuterBorder" app:layout_constraintStart_toEndOf="@id/attachmentButton" app:layout_constraintEnd_toStartOf="@id/sendButton"