Room directory : more cleanup and more tests

This commit is contained in:
ganfra
2024-03-28 18:07:48 +01:00
parent 6c44d34027
commit 6fd3f9c5f1
7 changed files with 113 additions and 27 deletions

View File

@@ -29,7 +29,11 @@
<string name="screen_room_change_role_confirm_demote_self_action">"Demote"</string>
<string name="screen_room_change_role_confirm_demote_self_description">"You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the room it will be impossible to regain privileges."</string>
<string name="screen_room_change_role_confirm_demote_self_title">"Demote yourself?"</string>
<string name="screen_room_change_role_invited_member_name">"%1$s (Pending)"</string>
<string name="screen_room_change_role_moderators_title">"Edit Moderators"</string>
<string name="screen_room_change_role_section_administrators">"Admins"</string>
<string name="screen_room_change_role_section_moderators">"Moderators"</string>
<string name="screen_room_change_role_section_users">"Members"</string>
<string name="screen_room_change_role_unsaved_changes_description">"You have unsaved changes."</string>
<string name="screen_room_change_role_unsaved_changes_title">"Save changes?"</string>
<string name="screen_room_details_add_topic_title">"Add topic"</string>

View File

@@ -32,7 +32,22 @@ open class RoomDirectoryStateProvider : PreviewParameterProvider<RoomDirectorySt
aRoomDirectoryState(
query = "Element",
roomDescriptions = aRoomDescriptionList(),
)
),
aRoomDirectoryState(
query = "Element",
roomDescriptions = aRoomDescriptionList(),
displayLoadMoreIndicator = true,
),
aRoomDirectoryState(
query = "Element",
roomDescriptions = aRoomDescriptionList(),
joinRoomAction = AsyncAction.Loading,
),
aRoomDirectoryState(
query = "Element",
roomDescriptions = aRoomDescriptionList(),
joinRoomAction = AsyncAction.Failure(Exception("Failed to join room")),
),
)
}

View File

@@ -48,6 +48,7 @@ import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.features.roomdirectory.api.RoomDescription
import io.element.android.features.roomdirectory.impl.R
import io.element.android.libraries.designsystem.components.async.AsyncActionView
import io.element.android.libraries.designsystem.components.avatar.Avatar
import io.element.android.libraries.designsystem.components.button.BackButton
@@ -87,8 +88,8 @@ fun RoomDirectoryView(
state = state,
onResultClicked = ::joinRoom,
modifier = Modifier
.padding(padding)
.consumeWindowInsets(padding)
.padding(padding)
.consumeWindowInsets(padding)
)
}
)
@@ -97,6 +98,9 @@ fun RoomDirectoryView(
onSuccess = onRoomJoined,
onErrorDismiss = {
state.eventSink(RoomDirectoryEvents.JoinRoomDismissError)
},
errorMessage = {
stringResource(id = CommonStrings.error_unknown)
}
)
}
@@ -114,7 +118,7 @@ private fun RoomDirectoryTopBar(
},
title = {
Text(
text = "Room directory",
text = stringResource(id = R.string.screen_room_directory_search_title),
style = ElementTheme.typography.aliasScreenTitle,
)
}
@@ -184,10 +188,10 @@ private fun RoomDirectoryRoomList(
@Composable
private fun LoadMoreIndicator(modifier: Modifier = Modifier) {
Box(
modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(24.dp),
modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(24.dp),
contentAlignment = Alignment.Center,
) {
CircularProgressIndicator(
@@ -257,14 +261,16 @@ private fun RoomDirectoryRoomRow(
) {
Row(
modifier = modifier
.fillMaxWidth()
.clickable { onClick(roomDescription.roomId) }
.padding(
top = 12.dp,
bottom = 12.dp,
start = 16.dp,
)
.height(IntrinsicSize.Min),
.fillMaxWidth()
.clickable(enabled = roomDescription.canBeJoined) {
onClick(roomDescription.roomId)
}
.padding(
top = 12.dp,
bottom = 12.dp,
start = 16.dp,
)
.height(IntrinsicSize.Min),
) {
Avatar(
avatarData = roomDescription.avatarData,
@@ -272,8 +278,8 @@ private fun RoomDirectoryRoomRow(
)
Column(
modifier = Modifier
.weight(1f)
.padding(start = 16.dp)
.weight(1f)
.padding(start = 16.dp)
) {
Text(
text = roomDescription.name,
@@ -295,8 +301,8 @@ private fun RoomDirectoryRoomRow(
text = stringResource(id = CommonStrings.action_join),
color = ElementTheme.colors.textSuccessPrimary,
modifier = Modifier
.align(Alignment.CenterVertically)
.padding(start = 4.dp, end = 12.dp)
.align(Alignment.CenterVertically)
.padding(start = 4.dp, end = 12.dp)
)
} else {
Spacer(modifier = Modifier.width(24.dp))

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="screen_room_directory_search_loading_error">"Failed loading"</string>
<string name="screen_room_directory_search_title">"Room directory"</string>
</resources>

View File

@@ -43,6 +43,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.features.roomlist.impl.R
import io.element.android.features.roomlist.impl.components.RoomSummaryRow
import io.element.android.features.roomlist.impl.contentType
import io.element.android.features.roomlist.impl.model.RoomListRoomSummary
@@ -131,8 +132,8 @@ private fun RoomListSearchContent(
val focusRequester = FocusRequester()
TextField(
modifier = Modifier
.fillMaxWidth()
.focusRequester(focusRequester),
.fillMaxWidth()
.focusRequester(focusRequester),
value = filter,
singleLine = true,
onValueChange = { state.eventSink(RoomListSearchEvents.QueryChanged(it)) },
@@ -171,8 +172,8 @@ private fun RoomListSearchContent(
) { padding ->
Column(
modifier = Modifier
.padding(padding)
.consumeWindowInsets(padding)
.padding(padding)
.consumeWindowInsets(padding)
) {
if (state.displayRoomDirectorySearch) {
RoomDirectorySearchButton(
@@ -206,7 +207,7 @@ private fun RoomDirectorySearchButton(
modifier: Modifier = Modifier
) {
Button(
text = "Browse all rooms",
text = stringResource(id = R.string.screen_roomlist_room_directory_button_title),
leadingIcon = IconSource.Vector(CompoundIcons.ListBulleted()),
onClick = onClick,
modifier = modifier,

View File

@@ -254,8 +254,6 @@
<string name="screen_media_picker_error_failed_selection">"Failed selecting media, please try again."</string>
<string name="screen_media_upload_preview_error_failed_processing">"Failed processing media to upload, please try again."</string>
<string name="screen_media_upload_preview_error_failed_sending">"Failed uploading media, please try again."</string>
<string name="screen_room_directory_search_loading_error">"Failed loading"</string>
<string name="screen_room_directory_search_title">"Room directory"</string>
<string name="screen_room_error_failed_processing_media">"Failed processing media to upload, please try again."</string>
<string name="screen_room_error_failed_retrieving_user_details">"Could not retrieve user details"</string>
<string name="screen_room_member_details_block_alert_action">"Block"</string>
@@ -274,4 +272,55 @@
<string name="settings_version_number">"Version: %1$s (%2$s)"</string>
<string name="test_language_identifier">"en"</string>
<string name="test_untranslated_default_language_identifier">"en"</string>
<string name="troubleshoot_notifications_entry_point_section">"Troubleshoot"</string>
<string name="troubleshoot_notifications_entry_point_title">"Troubleshoot notifications"</string>
<string name="troubleshoot_notifications_screen_action">"Run tests"</string>
<string name="troubleshoot_notifications_screen_action_again">"Run tests again"</string>
<string name="troubleshoot_notifications_screen_failure">"Some tests failed. Please check the details."</string>
<string name="troubleshoot_notifications_screen_notice">"Run the tests to detect any issue in your configuration that may make notifications not behave as expected."</string>
<string name="troubleshoot_notifications_screen_quick_fix_action">"Attempt to fix"</string>
<string name="troubleshoot_notifications_screen_success">"All tests passed successfully."</string>
<string name="troubleshoot_notifications_screen_title">"Troubleshoot notifications"</string>
<string name="troubleshoot_notifications_screen_waiting">"Some tests require your attention. Please check the details."</string>
<string name="troubleshoot_notifications_test_check_permission_description">"Check that the application can show notifications."</string>
<string name="troubleshoot_notifications_test_check_permission_title">"Check permissions"</string>
<string name="troubleshoot_notifications_test_current_push_provider_description">"Get the name of the current provider."</string>
<string name="troubleshoot_notifications_test_current_push_provider_failure">"No push providers selected."</string>
<string name="troubleshoot_notifications_test_current_push_provider_success">"Current push provider: %1$s."</string>
<string name="troubleshoot_notifications_test_current_push_provider_title">"Current push provider"</string>
<string name="troubleshoot_notifications_test_detect_push_provider_description">"Ensure that the application has at least one push provider."</string>
<string name="troubleshoot_notifications_test_detect_push_provider_failure">"No push providers found."</string>
<plurals name="troubleshoot_notifications_test_detect_push_provider_success">
<item quantity="one">"Found %1$d push provider: %2$s"</item>
<item quantity="other">"Found %1$d push providers: %2$s"</item>
</plurals>
<string name="troubleshoot_notifications_test_detect_push_provider_title">"Detect push providers"</string>
<string name="troubleshoot_notifications_test_display_notification_description">"Check that the application can display notification."</string>
<string name="troubleshoot_notifications_test_display_notification_failure">"The notification has not been clicked."</string>
<string name="troubleshoot_notifications_test_display_notification_permission_failure">"Cannot display the notification."</string>
<string name="troubleshoot_notifications_test_display_notification_success">"The notification has been clicked!"</string>
<string name="troubleshoot_notifications_test_display_notification_title">"Display notification"</string>
<string name="troubleshoot_notifications_test_display_notification_waiting">"Please click on the notification to continue the test."</string>
<string name="troubleshoot_notifications_test_firebase_availability_description">"Ensure that Firebase is available."</string>
<string name="troubleshoot_notifications_test_firebase_availability_failure">"Firebase is not available."</string>
<string name="troubleshoot_notifications_test_firebase_availability_success">"Firebase is available."</string>
<string name="troubleshoot_notifications_test_firebase_availability_title">"Check Firebase"</string>
<string name="troubleshoot_notifications_test_firebase_token_description">"Ensure that Firebase token is available."</string>
<string name="troubleshoot_notifications_test_firebase_token_failure">"Firebase token is not known."</string>
<string name="troubleshoot_notifications_test_firebase_token_success">"Firebase token: %1$s."</string>
<string name="troubleshoot_notifications_test_firebase_token_title">"Check Firebase token"</string>
<string name="troubleshoot_notifications_test_push_loop_back_description">"Ensure that the application is receiving push."</string>
<string name="troubleshoot_notifications_test_push_loop_back_failure_1">"Error: pusher has rejected the request."</string>
<string name="troubleshoot_notifications_test_push_loop_back_failure_2">"Error: %1$s."</string>
<string name="troubleshoot_notifications_test_push_loop_back_failure_3">"Error, cannot test push."</string>
<string name="troubleshoot_notifications_test_push_loop_back_failure_4">"Error, timeout waiting for push."</string>
<string name="troubleshoot_notifications_test_push_loop_back_success">"Push loop back took %1$d ms."</string>
<string name="troubleshoot_notifications_test_push_loop_back_title">"Test Push loop back"</string>
<string name="troubleshoot_notifications_test_unified_push_description">"Ensure that UnifiedPush distributors are available."</string>
<string name="troubleshoot_notifications_test_unified_push_failure">"No push distributors found."</string>
<plurals name="troubleshoot_notifications_test_unified_push_success">
<item quantity="one">"%1$d distributor found: %2$s."</item>
<item quantity="other">"%1$d distributors found: %2$s."</item>
</plurals>
<string name="troubleshoot_notifications_test_unified_push_title">"Check UnifiedPush"</string>
</resources>

View File

@@ -197,6 +197,12 @@
"screen_app_lock_.*",
"screen_signout_in_progress_dialog_content"
]
},
{
"name" : ":features:roomdirectory:impl",
"includeRegex" : [
"screen_room_directory_.*"
]
}
]
}