From 55083a5602f39c30c36990b6882b16a8b6a915b9 Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 24 Mar 2021 14:37:45 +0100 Subject: [PATCH] Design review changes --- .../relationship/RoomChildRelationInfo.kt | 16 ++++---- .../app/core/ui/list/GenericFooterItem.kt | 10 ++++- .../im/vector/app/core/ui/list/GenericItem.kt | 4 +- .../form/FormMultiLineEditTextItem.kt | 2 +- .../home/room/list/RoomListViewModel.kt | 2 + .../home/room/list/RoomListViewState.kt | 2 + .../features/spaces/ShareSpaceBottomSheet.kt | 9 +++-- .../features/spaces/SpaceCreationActivity.kt | 1 + .../spaces/SpaceSettingsMenuBottomSheet.kt | 4 +- .../create/CreateSpaceDefaultRoomsFragment.kt | 14 +++++-- .../create/CreateSpaceDetailsFragment.kt | 11 ++++- .../create/SpaceDefaultRoomEpoxyController.kt | 32 +++++++++++---- .../create/SpaceDetailEpoxyController.kt | 16 +++++++- .../spaces/create/WizardButtonView.kt | 4 +- .../res/drawable/rounded_rect_shape_16.xml | 11 +++++ .../res/layout/bottom_sheet_space_invite.xml | 40 ++++++++++++------- .../fragment_space_create_choose_type.xml | 30 +++++++++----- ...agment_space_create_generic_epoxy_form.xml | 4 +- .../layout/item_editable_square_avatar.xml | 2 +- .../res/layout/view_space_type_button.xml | 8 ++-- vector/src/main/res/values/strings.xml | 6 ++- 21 files changed, 166 insertions(+), 62 deletions(-) create mode 100644 vector/src/main/res/drawable/rounded_rect_shape_16.xml diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relationship/RoomChildRelationInfo.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relationship/RoomChildRelationInfo.kt index 06ab21d8db..5c478c9b25 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relationship/RoomChildRelationInfo.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relationship/RoomChildRelationInfo.kt @@ -59,9 +59,10 @@ internal class RoomChildRelationInfo(private val realm: Realm, */ fun getDirectChildrenDescriptions(): List { return CurrentStateEventEntity.whereType(realm, roomId, EventType.STATE_SPACE_CHILD) - .findAll().also { - Timber.v("## Space: Found ${it.count()} m.space.child state events for $roomId") - } + .findAll() +// .also { +// Timber.v("## Space: Found ${it.count()} m.space.child state events for $roomId") +// } .mapNotNull { ContentMapper.map(it.root?.content).toModel()?.let { scc -> Timber.v("## Space child desc state event $scc") @@ -81,12 +82,13 @@ internal class RoomChildRelationInfo(private val realm: Realm, fun getParentDescriptions(): List { return CurrentStateEventEntity.whereType(realm, roomId, EventType.STATE_SPACE_PARENT) - .findAll().also { - Timber.v("## Space: Found ${it.count()} m.space.parent state events for $roomId") - } + .findAll() +// .also { +// Timber.v("## Space: Found ${it.count()} m.space.parent state events for $roomId") +// } .mapNotNull { ContentMapper.map(it.root?.content).toModel()?.let { scc -> - Timber.v("## Space parent desc state event $scc") +// Timber.v("## Space parent desc state event $scc") // Parent where via is not present are ignored. scc.via?.let { via -> SpaceParentInfo( diff --git a/vector/src/main/java/im/vector/app/core/ui/list/GenericFooterItem.kt b/vector/src/main/java/im/vector/app/core/ui/list/GenericFooterItem.kt index 2539e59ae4..c0d309fe5b 100644 --- a/vector/src/main/java/im/vector/app/core/ui/list/GenericFooterItem.kt +++ b/vector/src/main/java/im/vector/app/core/ui/list/GenericFooterItem.kt @@ -15,6 +15,7 @@ */ package im.vector.app.core.ui.list +import android.graphics.Typeface import android.view.Gravity import android.widget.TextView import androidx.annotation.ColorInt @@ -36,7 +37,7 @@ import im.vector.app.features.themes.ThemeUtils abstract class GenericFooterItem : VectorEpoxyModel() { @EpoxyAttribute - var text: String? = null + var text: CharSequence? = null @EpoxyAttribute var style: GenericItem.STYLE = GenericItem.STYLE.NORMAL_TEXT @@ -53,10 +54,17 @@ abstract class GenericFooterItem : VectorEpoxyModel() override fun bind(holder: Holder) { super.bind(holder) + holder.text.setTextOrHide(text) + holder.text.typeface = Typeface.DEFAULT when (style) { GenericItem.STYLE.BIG_TEXT -> holder.text.textSize = 18f GenericItem.STYLE.NORMAL_TEXT -> holder.text.textSize = 14f + GenericItem.STYLE.SUBHEADER -> holder.text.textSize = 16f + GenericItem.STYLE.TITLE -> { + holder.text.textSize = 20f + holder.text.typeface = Typeface.DEFAULT_BOLD + } } holder.text.gravity = if (centered) Gravity.CENTER_HORIZONTAL else Gravity.START diff --git a/vector/src/main/java/im/vector/app/core/ui/list/GenericItem.kt b/vector/src/main/java/im/vector/app/core/ui/list/GenericItem.kt index 3a1337e78c..65e80bf7f4 100644 --- a/vector/src/main/java/im/vector/app/core/ui/list/GenericItem.kt +++ b/vector/src/main/java/im/vector/app/core/ui/list/GenericItem.kt @@ -40,7 +40,9 @@ abstract class GenericItem : VectorEpoxyModel() { enum class STYLE { BIG_TEXT, - NORMAL_TEXT + NORMAL_TEXT, + TITLE, + SUBHEADER } class Action(var title: String) { diff --git a/vector/src/main/java/im/vector/app/features/form/FormMultiLineEditTextItem.kt b/vector/src/main/java/im/vector/app/features/form/FormMultiLineEditTextItem.kt index 4ba668a051..6c6f6d284d 100644 --- a/vector/src/main/java/im/vector/app/features/form/FormMultiLineEditTextItem.kt +++ b/vector/src/main/java/im/vector/app/features/form/FormMultiLineEditTextItem.kt @@ -73,7 +73,7 @@ abstract class FormMultiLineEditTextItem : VectorEpoxyModel = emptyMap() + val asyncSuggestedRooms: Async> = Uninitialized, + val suggestedRoomJoiningState: Map> = emptyMap() ) : MvRxState { constructor(args: RoomListParams) : this(displayMode = args.displayMode) diff --git a/vector/src/main/java/im/vector/app/features/spaces/ShareSpaceBottomSheet.kt b/vector/src/main/java/im/vector/app/features/spaces/ShareSpaceBottomSheet.kt index 2a6e3dace9..2f69ba89b9 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/ShareSpaceBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/ShareSpaceBottomSheet.kt @@ -21,6 +21,7 @@ import android.os.Parcelable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.view.isVisible import androidx.fragment.app.FragmentManager import im.vector.app.R import im.vector.app.core.di.ActiveSessionHolder @@ -64,6 +65,8 @@ class ShareSpaceBottomSheet : VectorBaseBottomSheetDialogFragment(), SpaceDefaultRoomEpoxyController.Listener { +) : VectorBaseFragment(), + SpaceDefaultRoomEpoxyController.Listener, + OnBackPressed { private val sharedViewModel: CreateSpaceViewModel by activityViewModel() @@ -46,6 +50,7 @@ class CreateSpaceDefaultRoomsFragment @Inject constructor( } views.nextButton.debouncedClicks { + view.hideKeyboard() sharedViewModel.handle(CreateSpaceAction.NextFromDefaultRooms) } } @@ -54,7 +59,8 @@ class CreateSpaceDefaultRoomsFragment @Inject constructor( sharedViewModel.handle(CreateSpaceAction.DefaultRoomNameChanged(index, newName)) } - // ----------------------------- - // Epoxy controller listener methods - // ----------------------------- + override fun onBackPressed(toolbarButton: Boolean): Boolean { + sharedViewModel.handle(CreateSpaceAction.OnBackPressed) + return true + } } diff --git a/vector/src/main/java/im/vector/app/features/spaces/create/CreateSpaceDetailsFragment.kt b/vector/src/main/java/im/vector/app/features/spaces/create/CreateSpaceDetailsFragment.kt index 670876fdf1..3e420ee632 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/create/CreateSpaceDetailsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/create/CreateSpaceDetailsFragment.kt @@ -24,6 +24,8 @@ import android.view.ViewGroup import com.airbnb.mvrx.activityViewModel import im.vector.app.core.dialogs.GalleryOrCameraDialogHelper import im.vector.app.core.extensions.configureWith +import im.vector.app.core.extensions.hideKeyboard +import im.vector.app.core.platform.OnBackPressed import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.core.resources.ColorProvider import im.vector.app.databinding.FragmentSpaceCreateGenericEpoxyFormBinding @@ -33,7 +35,7 @@ class CreateSpaceDetailsFragment @Inject constructor( private val epoxyController: SpaceDetailEpoxyController, private val colorProvider: ColorProvider ) : VectorBaseFragment(), SpaceDetailEpoxyController.Listener, - GalleryOrCameraDialogHelper.Listener { + GalleryOrCameraDialogHelper.Listener, OnBackPressed { private val sharedViewModel: CreateSpaceViewModel by activityViewModel() @@ -53,6 +55,7 @@ class CreateSpaceDetailsFragment @Inject constructor( } views.nextButton.debouncedClicks { + view.hideKeyboard() sharedViewModel.handle(CreateSpaceAction.NextFromDetails) } } @@ -60,6 +63,7 @@ class CreateSpaceDetailsFragment @Inject constructor( override fun onImageReady(uri: Uri?) { sharedViewModel.handle(CreateSpaceAction.SetAvatar(uri)) } + // ----------------------------- // Epoxy controller listener methods // ----------------------------- @@ -79,4 +83,9 @@ class CreateSpaceDetailsFragment @Inject constructor( override fun onTopicChange(newTopic: String) { sharedViewModel.handle(CreateSpaceAction.TopicChanged(newTopic)) } + + override fun onBackPressed(toolbarButton: Boolean): Boolean { + sharedViewModel.handle(CreateSpaceAction.OnBackPressed) + return true + } } diff --git a/vector/src/main/java/im/vector/app/features/spaces/create/SpaceDefaultRoomEpoxyController.kt b/vector/src/main/java/im/vector/app/features/spaces/create/SpaceDefaultRoomEpoxyController.kt index a1e46457e3..aa4b2beae4 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/create/SpaceDefaultRoomEpoxyController.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/create/SpaceDefaultRoomEpoxyController.kt @@ -33,10 +33,12 @@ class SpaceDefaultRoomEpoxyController @Inject constructor( var listener: Listener? = null +// var shouldForceFocusOnce = true + override fun buildModels(data: CreateSpaceState?) { genericFooterItem { id("info_help_header") - style(GenericItem.STYLE.BIG_TEXT) + style(GenericItem.STYLE.TITLE) text(stringProvider.getString(R.string.create_spaces_room_public_header, data?.name)) textColor(colorProvider.getColorFromAttribute(R.attr.riot_primary_text_color)) } @@ -47,10 +49,12 @@ class SpaceDefaultRoomEpoxyController @Inject constructor( textColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_secondary)) } + val firstRoomName = data?.defaultRooms?.get(0) formEditTextItem { id("roomName1") enabled(true) - value(data?.defaultRooms?.get(0)) + value(firstRoomName) + singleLine(true) hint(stringProvider.getString(R.string.create_room_name_section)) endIconMode(TextInputLayout.END_ICON_CLEAR_TEXT) showBottomSeparator(false) @@ -59,10 +63,12 @@ class SpaceDefaultRoomEpoxyController @Inject constructor( } } + val secondRoomName = data?.defaultRooms?.get(1) formEditTextItem { id("roomName2") enabled(true) - value(data?.defaultRooms?.get(1)) + value(secondRoomName) + singleLine(true) hint(stringProvider.getString(R.string.create_room_name_section)) endIconMode(TextInputLayout.END_ICON_CLEAR_TEXT) showBottomSeparator(false) @@ -71,23 +77,35 @@ class SpaceDefaultRoomEpoxyController @Inject constructor( } } + val thirdRoomName = data?.defaultRooms?.get(2) formEditTextItem { id("roomName3") enabled(true) - value(data?.defaultRooms?.get(2)) + value(thirdRoomName) + singleLine(true) hint(stringProvider.getString(R.string.create_room_name_section)) endIconMode(TextInputLayout.END_ICON_CLEAR_TEXT) showBottomSeparator(false) onTextChange { text -> listener?.onNameChange(2, text) } +// onBind { _, view, _ -> +// if (shouldForceFocusOnce +// && thirdRoomName.isNullOrBlank() +// && firstRoomName.isNullOrBlank().not() +// && secondRoomName.isNullOrBlank().not() +// ) { +// shouldForceFocusOnce = false +// // sad face :( +// view.textInputEditText.post { +// view.textInputEditText.showKeyboard(true) +// } +// } +// } } } interface Listener { - // fun onAvatarDelete() -// fun onAvatarChange() fun onNameChange(index: Int, newName: String) -// fun onTopicChange(newTopic: String) } } diff --git a/vector/src/main/java/im/vector/app/features/spaces/create/SpaceDetailEpoxyController.kt b/vector/src/main/java/im/vector/app/features/spaces/create/SpaceDetailEpoxyController.kt index 357b741ff4..96e5ec24c4 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/create/SpaceDetailEpoxyController.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/create/SpaceDetailEpoxyController.kt @@ -34,6 +34,8 @@ class SpaceDetailEpoxyController @Inject constructor( var listener: Listener? = null +// var shouldForceFocusOnce = true + override fun buildModels(data: CreateSpaceState?) { genericFooterItem { id("info_help") @@ -61,8 +63,18 @@ class SpaceDetailEpoxyController @Inject constructor( enabled(true) value(data?.name) hint(stringProvider.getString(R.string.create_room_name_hint)) + singleLine(true) showBottomSeparator(false) errorMessage(data?.nameInlineError) +// onBind { _, view, _ -> +// if (shouldForceFocusOnce && data?.name.isNullOrBlank()) { +// shouldForceFocusOnce = false +// // sad face :( +// view.textInputEditText.post { +// view.textInputEditText.showKeyboard(true) +// } +// } +// } onTextChange { text -> listener?.onNameChange(text) } @@ -72,9 +84,9 @@ class SpaceDetailEpoxyController @Inject constructor( id("topic") enabled(true) value(data?.topic) - hint(stringProvider.getString(R.string.create_room_topic_hint)) + hint(stringProvider.getString(R.string.create_space_topic_hint)) showBottomSeparator(false) - textSizeSp(15) + textSizeSp(16) onTextChange { text -> listener?.onTopicChange(text) } diff --git a/vector/src/main/java/im/vector/app/features/spaces/create/WizardButtonView.kt b/vector/src/main/java/im/vector/app/features/spaces/create/WizardButtonView.kt index a6b9b1978a..ade2b4b00c 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/create/WizardButtonView.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/create/WizardButtonView.kt @@ -69,8 +69,8 @@ class WizardButtonView @JvmOverloads constructor(context: Context, attrs: Attrib // var action: (() -> Unit)? = null init { - inflate(context, R.layout.view_space_type_button, this) - views = ViewSpaceTypeButtonBinding.bind(this) + val content = inflate(context, R.layout.view_space_type_button, this) + views = ViewSpaceTypeButtonBinding.bind(content) views.subTitle.setTextOrHide(null) diff --git a/vector/src/main/res/drawable/rounded_rect_shape_16.xml b/vector/src/main/res/drawable/rounded_rect_shape_16.xml new file mode 100644 index 0000000000..1f456e4c1f --- /dev/null +++ b/vector/src/main/res/drawable/rounded_rect_shape_16.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/layout/bottom_sheet_space_invite.xml b/vector/src/main/res/layout/bottom_sheet_space_invite.xml index c8d29b2f7d..bf985dbcbb 100644 --- a/vector/src/main/res/layout/bottom_sheet_space_invite.xml +++ b/vector/src/main/res/layout/bottom_sheet_space_invite.xml @@ -14,11 +14,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="16dp" - android:layout_marginBottom="16dp" + android:layout_marginBottom="12dp" android:gravity="center" android:text="@string/invite_people_to_your_space" android:textColor="?riotx_text_primary" - android:textSize="18sp" + android:textSize="16sp" android:textStyle="bold" app:layout_constraintTop_toTopOf="parent" /> @@ -26,10 +26,10 @@ android:id="@+id/descriptionText" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="16dp" + android:layout_marginBottom="20dp" android:gravity="center" android:textColor="?riotx_text_secondary" - android:textSize="18sp" + android:textSize="16sp" app:layout_constraintBottom_toTopOf="@id/joinInfoHelpText" app:layout_constraintTop_toBottomOf="@id/headerText" app:layout_constraintVertical_bias="1" @@ -40,40 +40,50 @@ android:id="@+id/inviteByMailButton" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="16dp" app:icon="@drawable/ic_mail" app:iconTint="?riotx_text_secondary" app:title="@string/invite_by_email" /> + + + + - + android:layout_height="20dp" /> + + + + + + + + + + diff --git a/vector/src/main/res/layout/fragment_space_create_choose_type.xml b/vector/src/main/res/layout/fragment_space_create_choose_type.xml index ddf61aabf8..73e6044a37 100644 --- a/vector/src/main/res/layout/fragment_space_create_choose_type.xml +++ b/vector/src/main/res/layout/fragment_space_create_choose_type.xml @@ -17,17 +17,17 @@ android:gravity="center" android:text="@string/create_spaces_type_header" android:textColor="?riotx_text_secondary" - android:textSize="18sp" + android:textSize="16sp" app:layout_constraintTop_toTopOf="parent" /> + + \ No newline at end of file diff --git a/vector/src/main/res/layout/fragment_space_create_generic_epoxy_form.xml b/vector/src/main/res/layout/fragment_space_create_generic_epoxy_form.xml index 3097664e02..7652a540dc 100644 --- a/vector/src/main/res/layout/fragment_space_create_generic_epoxy_form.xml +++ b/vector/src/main/res/layout/fragment_space_create_generic_epoxy_form.xml @@ -21,7 +21,6 @@ android:layout_height="wrap_content" android:background="?riotx_background" android:elevation="2dp" - android:padding="8dp" app:layout_constraintBottom_toBottomOf="parent"> diff --git a/vector/src/main/res/layout/item_editable_square_avatar.xml b/vector/src/main/res/layout/item_editable_square_avatar.xml index 3112b36a65..9fa2cdbbf1 100644 --- a/vector/src/main/res/layout/item_editable_square_avatar.xml +++ b/vector/src/main/res/layout/item_editable_square_avatar.xml @@ -13,7 +13,7 @@ android:id="@+id/itemEditableAvatarImageContainer" android:layout_width="80dp" android:layout_height="80dp" - android:background="@drawable/rounded_rect_shape_8" + android:background="@drawable/rounded_rect_shape_16" android:contentDescription="@string/a11y_change_avatar" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" diff --git a/vector/src/main/res/layout/view_space_type_button.xml b/vector/src/main/res/layout/view_space_type_button.xml index 6ddb126469..d48f123bdc 100644 --- a/vector/src/main/res/layout/view_space_type_button.xml +++ b/vector/src/main/res/layout/view_space_type_button.xml @@ -6,12 +6,13 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/rounded_rect_shape_8" - android:padding="4dp"> + android:padding="8dp"> @@ -44,7 +44,6 @@ android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginEnd="4dp" - android:layout_marginBottom="8dp" android:gravity="start" android:textColor="?riotx_text_secondary" android:textSize="12sp" @@ -53,7 +52,6 @@ app:layout_constraintEnd_toStartOf="@id/rightChevron" app:layout_constraintStart_toEndOf="@id/buttonImageView" app:layout_constraintTop_toBottomOf="@id/title" - app:layout_goneMarginBottom="8dp" tools:text="Open to anyone, best for communities" tools:visibility="visible" /> diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 3e357b3b89..80052f91a3 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3266,6 +3266,7 @@ Your public space Spaces are a new way to group rooms and people What type of space do you want to create? + You can change this later To join an existing space, you need an invite. Public Open to anyone, best for communities @@ -3276,10 +3277,11 @@ Add some details to help people identify it. You can change these at any point. Give it a name to continue. What are some discussions you want to have in %s? - We’ll create rooms for them, and auto-join everyone. You can add more later too. + We’ll create rooms for them. You can add more later too. General Random Creating Space… + Description Invite people to your space Invite people It’s just you at the moment. %s will be even better with others. @@ -3294,6 +3296,8 @@ This alias is not accessible at this time.\nTry again later, or ask a room admin to check if you have access. You’re not in any rooms yet. Below are some suggested rooms, but you can see more with the green button bottom right. + + Welcome to %1$s, %2$s. Explore rooms Leave Space