From cdea89533213a8cf9129f7fd3981d89edcd3212a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 30 Sep 2024 15:56:33 +0200 Subject: [PATCH 1/5] Add auto-mirrored attribute in imported drawables --- .../res/drawable/ic_compound_arrow_left.xml | 1 + .../res/drawable/ic_compound_arrow_right.xml | 1 + .../drawable/ic_compound_arrow_up_right.xml | 1 + .../res/drawable/ic_compound_attachment.xml | 1 + .../main/res/drawable/ic_compound_block.xml | 1 + .../main/res/drawable/ic_compound_chart.xml | 1 + .../main/res/drawable/ic_compound_chat.xml | 1 + .../res/drawable/ic_compound_chat_new.xml | 1 + .../res/drawable/ic_compound_chat_problem.xml | 1 + .../res/drawable/ic_compound_chat_solid.xml | 1 + .../main/res/drawable/ic_compound_check.xml | 1 + .../res/drawable/ic_compound_check_circle.xml | 1 + .../ic_compound_check_circle_solid.xml | 1 + .../res/drawable/ic_compound_chevron_left.xml | 1 + .../drawable/ic_compound_chevron_right.xml | 1 + .../main/res/drawable/ic_compound_cloud.xml | 1 + .../res/drawable/ic_compound_cloud_solid.xml | 1 + .../res/drawable/ic_compound_collapse.xml | 1 + .../main/res/drawable/ic_compound_company.xml | 1 + .../main/res/drawable/ic_compound_compose.xml | 1 + .../main/res/drawable/ic_compound_copy.xml | 1 + .../res/drawable/ic_compound_dark_mode.xml | 1 + .../main/res/drawable/ic_compound_devices.xml | 1 + .../res/drawable/ic_compound_document.xml | 1 + .../main/res/drawable/ic_compound_edit.xml | 1 + .../res/drawable/ic_compound_edit_solid.xml | 1 + .../main/res/drawable/ic_compound_expand.xml | 1 + .../res/drawable/ic_compound_extensions.xml | 1 + .../drawable/ic_compound_extensions_solid.xml | 1 + .../res/drawable/ic_compound_file_error.xml | 1 + .../main/res/drawable/ic_compound_files.xml | 1 + .../main/res/drawable/ic_compound_forward.xml | 1 + .../main/res/drawable/ic_compound_history.xml | 1 + .../main/res/drawable/ic_compound_host.xml | 1 + .../main/res/drawable/ic_compound_image.xml | 1 + .../res/drawable/ic_compound_image_error.xml | 1 + .../drawable/ic_compound_indent_decrease.xml | 1 + .../drawable/ic_compound_indent_increase.xml | 1 + .../main/res/drawable/ic_compound_italic.xml | 1 + .../src/main/res/drawable/ic_compound_key.xml | 1 + .../main/res/drawable/ic_compound_key_off.xml | 1 + .../drawable/ic_compound_key_off_solid.xml | 1 + .../res/drawable/ic_compound_key_solid.xml | 1 + .../main/res/drawable/ic_compound_leave.xml | 1 + .../main/res/drawable/ic_compound_link.xml | 1 + .../drawable/ic_compound_list_bulleted.xml | 1 + .../res/drawable/ic_compound_lock_off.xml | 1 + .../drawable/ic_compound_mark_as_unread.xml | 1 + .../ic_compound_mark_threads_as_read.xml | 1 + .../ic_compound_marker_read_receipts.xml | 1 + .../main/res/drawable/ic_compound_mic_off.xml | 1 + .../drawable/ic_compound_mic_off_solid.xml | 1 + .../ic_compound_notifications_off.xml | 1 + .../ic_compound_notifications_off_solid.xml | 1 + .../main/res/drawable/ic_compound_offline.xml | 1 + .../main/res/drawable/ic_compound_play.xml | 1 + .../res/drawable/ic_compound_play_solid.xml | 1 + .../main/res/drawable/ic_compound_polls.xml | 1 + .../res/drawable/ic_compound_polls_end.xml | 1 + .../main/res/drawable/ic_compound_pop_out.xml | 1 + .../main/res/drawable/ic_compound_qr_code.xml | 1 + .../main/res/drawable/ic_compound_quote.xml | 1 + .../res/drawable/ic_compound_reaction_add.xml | 1 + .../main/res/drawable/ic_compound_reply.xml | 1 + .../main/res/drawable/ic_compound_restart.xml | 1 + .../main/res/drawable/ic_compound_room.xml | 1 + .../main/res/drawable/ic_compound_search.xml | 1 + .../main/res/drawable/ic_compound_send.xml | 1 + .../res/drawable/ic_compound_send_solid.xml | 1 + .../drawable/ic_compound_share_android.xml | 1 + .../main/res/drawable/ic_compound_sidebar.xml | 1 + .../res/drawable/ic_compound_sign_out.xml | 1 + .../main/res/drawable/ic_compound_spinner.xml | 1 + .../res/drawable/ic_compound_spotlight.xml | 1 + .../ic_compound_switch_camera_solid.xml | 1 + .../main/res/drawable/ic_compound_threads.xml | 1 + .../drawable/ic_compound_threads_solid.xml | 1 + .../main/res/drawable/ic_compound_unpin.xml | 1 + .../res/drawable/ic_compound_user_add.xml | 1 + .../drawable/ic_compound_user_add_solid.xml | 1 + .../res/drawable/ic_compound_verified.xml | 1 + .../res/drawable/ic_compound_video_call.xml | 1 + .../ic_compound_video_call_declined_solid.xml | 1 + .../ic_compound_video_call_missed_solid.xml | 1 + .../drawable/ic_compound_video_call_off.xml | 1 + .../ic_compound_video_call_off_solid.xml | 1 + .../drawable/ic_compound_video_call_solid.xml | 1 + .../drawable/ic_compound_visibility_off.xml | 1 + .../res/drawable/ic_compound_voice_call.xml | 1 + .../res/drawable/ic_compound_volume_off.xml | 1 + .../drawable/ic_compound_volume_off_solid.xml | 1 + .../res/drawable/ic_compound_volume_on.xml | 1 + .../drawable/ic_compound_volume_on_solid.xml | 1 + scripts/addAutoMirrored.py | 119 ++++++++++++++++++ scripts/import_tokens.sh | 3 + 95 files changed, 215 insertions(+) create mode 100644 scripts/addAutoMirrored.py diff --git a/compound/src/main/res/drawable/ic_compound_arrow_left.xml b/compound/src/main/res/drawable/ic_compound_arrow_left.xml index 288f65c..30f33a7 100644 --- a/compound/src/main/res/drawable/ic_compound_arrow_left.xml +++ b/compound/src/main/res/drawable/ic_compound_arrow_left.xml @@ -1,6 +1,7 @@ Date: Mon, 30 Sep 2024 16:17:35 +0200 Subject: [PATCH 2/5] Add RTL preview and test for icons. --- .../screenshots/Compound Icons - Dark.png | 4 +-- .../screenshots/Compound Icons - Light.png | 4 +-- compound/screenshots/Compound Icons - Rtl.png | 3 ++ .../Compound Vector Icons - Dark.png | 4 +-- .../Compound Vector Icons - Light.png | 4 +-- .../compound/previews/CompoundIconsPreview.kt | 30 ++++++++++++++++--- .../compound/screenshot/CompoundIconTests.kt | 4 +++ 7 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 compound/screenshots/Compound Icons - Rtl.png diff --git a/compound/screenshots/Compound Icons - Dark.png b/compound/screenshots/Compound Icons - Dark.png index f2ee670..d78673d 100644 --- a/compound/screenshots/Compound Icons - Dark.png +++ b/compound/screenshots/Compound Icons - Dark.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a2fb56aba248999fb3c3ce2f3ac718ef9bf585d858127edd0269181678c2e422 -size 157547 +oid sha256:b0fa733709e6e2d5f6f4513e4ad069cc9b8af8db544f310b45c2f5917aab9d47 +size 157561 diff --git a/compound/screenshots/Compound Icons - Light.png b/compound/screenshots/Compound Icons - Light.png index 8e7d9a7..069cf96 100644 --- a/compound/screenshots/Compound Icons - Light.png +++ b/compound/screenshots/Compound Icons - Light.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:722be27bd3fc07800aca9736c80b006841d22f49d90560a51385a5953880c63d -size 165072 +oid sha256:be24d4c73a0f14a66c56331ecaf53b66f939deee6b742c1a7e5f4f30dad224ea +size 165069 diff --git a/compound/screenshots/Compound Icons - Rtl.png b/compound/screenshots/Compound Icons - Rtl.png new file mode 100644 index 0000000..61173e7 --- /dev/null +++ b/compound/screenshots/Compound Icons - Rtl.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a16796baa2f095d5b6485cf04743a930b0f464ecb6e5604efb32a0bc1018ece4 +size 165886 diff --git a/compound/screenshots/Compound Vector Icons - Dark.png b/compound/screenshots/Compound Vector Icons - Dark.png index 318bc90..3a95263 100644 --- a/compound/screenshots/Compound Vector Icons - Dark.png +++ b/compound/screenshots/Compound Vector Icons - Dark.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:938e485a937a012dc697fe2c0de5a174dbe91d483739f3f9b9cedf7386a3f04a -size 56148 +oid sha256:68c36b84bfb9ba43bfdd7f2cfe69e6b8fbf72ab5830b6993334b259d8750393d +size 56157 diff --git a/compound/screenshots/Compound Vector Icons - Light.png b/compound/screenshots/Compound Vector Icons - Light.png index 01a505e..6c85181 100644 --- a/compound/screenshots/Compound Vector Icons - Light.png +++ b/compound/screenshots/Compound Vector Icons - Light.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed349bbe5ce21d8784e826383cc0fd0ad94bc122f25648ab9dacae3ce29aa113 -size 60033 +oid sha256:cac1622ab0b594f67086224b16f3f2bc44ff803d7d7abfd7fcdc1cb8288c0c1f +size 60036 diff --git a/compound/src/main/kotlin/io/element/android/compound/previews/CompoundIconsPreview.kt b/compound/src/main/kotlin/io/element/android/compound/previews/CompoundIconsPreview.kt index 96e644a..5930df1 100644 --- a/compound/src/main/kotlin/io/element/android/compound/previews/CompoundIconsPreview.kt +++ b/compound/src/main/kotlin/io/element/android/compound/previews/CompoundIconsPreview.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.IntrinsicSize import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -17,13 +18,16 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.res.vectorResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.dp import io.element.android.compound.theme.ElementTheme import io.element.android.compound.tokens.generated.CompoundIcons @@ -34,6 +38,18 @@ internal fun IconsCompoundPreviewLight() = ElementTheme { IconsCompoundPreview() } +@Preview(widthDp = 730, heightDp = 1600) +@Composable +internal fun IconsCompoundPreviewRtl() = ElementTheme { + CompositionLocalProvider( + LocalLayoutDirection provides LayoutDirection.Rtl, + ) { + IconsCompoundPreview( + title = "Compound Icons Rtl", + ) + } +} + @Preview(widthDp = 730, heightDp = 1600) @Composable internal fun IconsCompoundPreviewDark() = ElementTheme(darkTheme = true) { @@ -41,7 +57,9 @@ internal fun IconsCompoundPreviewDark() = ElementTheme(darkTheme = true) { } @Composable -private fun IconsCompoundPreview() { +private fun IconsCompoundPreview( + title: String = "Compound Icons", +) { val context = LocalContext.current val content: Sequence<@Composable ColumnScope.() -> Unit> = sequence { for (icon in CompoundIcons.allResIds) { @@ -64,7 +82,7 @@ private fun IconsCompoundPreview() { } } IconsPreview( - title = "Compound Icons", + title = title, content = content.toList(), ) } @@ -92,9 +110,10 @@ internal fun IconsPreview( content.chunked(10).forEach { chunk -> Row( modifier = Modifier.height(IntrinsicSize.Max), - horizontalArrangement = Arrangement.spacedBy(6.dp), + // Keep same order of icons for an easier comparison of previews + horizontalArrangement = Arrangement.Absolute.Left, ) { - chunk.forEach { icon -> + chunk.forEachIndexed { index, icon -> Column( modifier = Modifier .background(MaterialTheme.colorScheme.background) @@ -105,6 +124,9 @@ internal fun IconsPreview( ) { icon() } + if (index < chunk.size - 1) { + Spacer(modifier = Modifier.width(6.dp)) + } } } } diff --git a/compound/src/test/kotlin/io/element/android/compound/screenshot/CompoundIconTests.kt b/compound/src/test/kotlin/io/element/android/compound/screenshot/CompoundIconTests.kt index 74bf65f..70a04c2 100644 --- a/compound/src/test/kotlin/io/element/android/compound/screenshot/CompoundIconTests.kt +++ b/compound/src/test/kotlin/io/element/android/compound/screenshot/CompoundIconTests.kt @@ -7,6 +7,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import com.github.takahirom.roborazzi.captureRoboImage import io.element.android.compound.previews.IconsCompoundPreviewDark import io.element.android.compound.previews.IconsCompoundPreviewLight +import io.element.android.compound.previews.IconsCompoundPreviewRtl import io.element.android.compound.previews.IconsPreview import io.element.android.compound.screenshot.utils.screenshotFile import io.element.android.compound.theme.ElementTheme @@ -25,6 +26,9 @@ class CompoundIconTests { captureRoboImage(file = screenshotFile("Compound Icons - Light.png")) { IconsCompoundPreviewLight() } + captureRoboImage(file = screenshotFile("Compound Icons - Rtl.png")) { + IconsCompoundPreviewRtl() + } captureRoboImage(file = screenshotFile("Compound Icons - Dark.png")) { IconsCompoundPreviewDark() } From a02b276d72e4d1e8ef7dfba41e089ca0ab9e4cc5 Mon Sep 17 00:00:00 2001 From: ElementBot Date: Mon, 30 Sep 2024 14:48:13 +0000 Subject: [PATCH 3/5] Update screenshots --- compound/screenshots/Compound Icons - Dark.png | 4 ++-- compound/screenshots/Compound Icons - Light.png | 4 ++-- compound/screenshots/Compound Icons - Rtl.png | 4 ++-- compound/screenshots/Compound Vector Icons - Dark.png | 4 ++-- compound/screenshots/Compound Vector Icons - Light.png | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/compound/screenshots/Compound Icons - Dark.png b/compound/screenshots/Compound Icons - Dark.png index d78673d..f2ee670 100644 --- a/compound/screenshots/Compound Icons - Dark.png +++ b/compound/screenshots/Compound Icons - Dark.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b0fa733709e6e2d5f6f4513e4ad069cc9b8af8db544f310b45c2f5917aab9d47 -size 157561 +oid sha256:a2fb56aba248999fb3c3ce2f3ac718ef9bf585d858127edd0269181678c2e422 +size 157547 diff --git a/compound/screenshots/Compound Icons - Light.png b/compound/screenshots/Compound Icons - Light.png index 069cf96..8e7d9a7 100644 --- a/compound/screenshots/Compound Icons - Light.png +++ b/compound/screenshots/Compound Icons - Light.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:be24d4c73a0f14a66c56331ecaf53b66f939deee6b742c1a7e5f4f30dad224ea -size 165069 +oid sha256:722be27bd3fc07800aca9736c80b006841d22f49d90560a51385a5953880c63d +size 165072 diff --git a/compound/screenshots/Compound Icons - Rtl.png b/compound/screenshots/Compound Icons - Rtl.png index 61173e7..bfa27db 100644 --- a/compound/screenshots/Compound Icons - Rtl.png +++ b/compound/screenshots/Compound Icons - Rtl.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a16796baa2f095d5b6485cf04743a930b0f464ecb6e5604efb32a0bc1018ece4 -size 165886 +oid sha256:874db87eaf63e5fab509b22c0781ea00bf9825c1b778c149b0ecb289fa8f601a +size 165876 diff --git a/compound/screenshots/Compound Vector Icons - Dark.png b/compound/screenshots/Compound Vector Icons - Dark.png index 3a95263..318bc90 100644 --- a/compound/screenshots/Compound Vector Icons - Dark.png +++ b/compound/screenshots/Compound Vector Icons - Dark.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:68c36b84bfb9ba43bfdd7f2cfe69e6b8fbf72ab5830b6993334b259d8750393d -size 56157 +oid sha256:938e485a937a012dc697fe2c0de5a174dbe91d483739f3f9b9cedf7386a3f04a +size 56148 diff --git a/compound/screenshots/Compound Vector Icons - Light.png b/compound/screenshots/Compound Vector Icons - Light.png index 6c85181..01a505e 100644 --- a/compound/screenshots/Compound Vector Icons - Light.png +++ b/compound/screenshots/Compound Vector Icons - Light.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cac1622ab0b594f67086224b16f3f2bc44ff803d7d7abfd7fcdc1cb8288c0c1f -size 60036 +oid sha256:ed349bbe5ce21d8784e826383cc0fd0ad94bc122f25648ab9dacae3ce29aa113 +size 60033 From f1ed7716159d7a4780b348dca69ec151b0bc6363 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 30 Sep 2024 17:46:33 +0200 Subject: [PATCH 4/5] Remove autoMirrored for checks and add it to icons with question mark. --- compound/src/main/res/drawable/ic_compound_check.xml | 1 - compound/src/main/res/drawable/ic_compound_check_circle.xml | 1 - .../main/res/drawable/ic_compound_check_circle_solid.xml | 1 - compound/src/main/res/drawable/ic_compound_unknown.xml | 1 + .../src/main/res/drawable/ic_compound_unknown_solid.xml | 1 + compound/src/main/res/drawable/ic_compound_verified.xml | 1 - scripts/addAutoMirrored.py | 6 ++---- 7 files changed, 4 insertions(+), 8 deletions(-) diff --git a/compound/src/main/res/drawable/ic_compound_check.xml b/compound/src/main/res/drawable/ic_compound_check.xml index 4468e1b..e927330 100644 --- a/compound/src/main/res/drawable/ic_compound_check.xml +++ b/compound/src/main/res/drawable/ic_compound_check.xml @@ -1,7 +1,6 @@ Date: Mon, 30 Sep 2024 15:50:19 +0000 Subject: [PATCH 5/5] Update screenshots --- compound/screenshots/Compound Icons - Rtl.png | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compound/screenshots/Compound Icons - Rtl.png b/compound/screenshots/Compound Icons - Rtl.png index bfa27db..c62c83b 100644 --- a/compound/screenshots/Compound Icons - Rtl.png +++ b/compound/screenshots/Compound Icons - Rtl.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:874db87eaf63e5fab509b22c0781ea00bf9825c1b778c149b0ecb289fa8f601a -size 165876 +oid sha256:5cf83fa752042e5f94e82cd80781ab574c68d228d55ac6d1137d602532f9eb17 +size 165901