From d49f10433296c8dc97a1bc5cb4a0a6e0e660e8c6 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Thu, 28 Jul 2022 15:09:57 +0200 Subject: [PATCH 1/6] Adds fab buttons --- .../src/main/res/values/styles_buttons.xml | 4 ++ .../home/room/list/RoomListFragment.kt | 14 +++--- vector/src/main/res/drawable/ic_new_chat.xml | 10 +++++ .../src/main/res/drawable/ic_open_spaces.xml | 14 ++++++ .../main/res/layout/fragment_room_list.xml | 44 +++++++++++++++++++ vector/src/main/res/values/strings.xml | 1 + 6 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 vector/src/main/res/drawable/ic_new_chat.xml create mode 100644 vector/src/main/res/drawable/ic_open_spaces.xml diff --git a/library/ui-styles/src/main/res/values/styles_buttons.xml b/library/ui-styles/src/main/res/values/styles_buttons.xml index c8dcacb8ed..702f427cc0 100644 --- a/library/ui-styles/src/main/res/values/styles_buttons.xml +++ b/library/ui-styles/src/main/res/values/styles_buttons.xml @@ -65,4 +65,8 @@ ?colorOnPrimary + + diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt index c25fe546c3..80f545b166 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt @@ -211,12 +211,14 @@ class RoomListFragment @Inject constructor( } private fun setupCreateRoomButton() { - when (roomListParams.displayMode) { - RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.isVisible = true - RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.isVisible = true - RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.isVisible = true - RoomListDisplayMode.FILTERED -> Unit // No button in this mode - } + // TODO: Uncomment +// when (roomListParams.displayMode) { +// RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.isVisible = true +// RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.isVisible = false +// RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.isVisible = true +// RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.isVisible = true +// RoomListDisplayMode.FILTERED -> Unit // No button in this mode +// } views.createChatRoomButton.debouncedClicks { fabCreateDirectChat() diff --git a/vector/src/main/res/drawable/ic_new_chat.xml b/vector/src/main/res/drawable/ic_new_chat.xml new file mode 100644 index 0000000000..ec3ef46fa4 --- /dev/null +++ b/vector/src/main/res/drawable/ic_new_chat.xml @@ -0,0 +1,10 @@ + + + diff --git a/vector/src/main/res/drawable/ic_open_spaces.xml b/vector/src/main/res/drawable/ic_open_spaces.xml new file mode 100644 index 0000000000..180f71f1cd --- /dev/null +++ b/vector/src/main/res/drawable/ic_open_spaces.xml @@ -0,0 +1,14 @@ + + + + + + diff --git a/vector/src/main/res/layout/fragment_room_list.xml b/vector/src/main/res/layout/fragment_room_list.xml index a8eec6ff3a..97e2725a1f 100644 --- a/vector/src/main/res/layout/fragment_room_list.xml +++ b/vector/src/main/res/layout/fragment_room_list.xml @@ -55,4 +55,48 @@ tools:layout_marginEnd="144dp" tools:visibility="visible" /> + + + + + + + + diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 770df1f770..4157f173c2 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -1810,6 +1810,7 @@ Open the create room menu Close the create room menu… Create a new direct conversation + Create a new conversation or room Create a new room Close keys backup banner Jump to bottom From 8e7e320e40448074d1f36d09005187be2811a9aa Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Fri, 29 Jul 2022 15:28:55 +0200 Subject: [PATCH 2/6] Finalises new layout FABs --- .../home/room/list/RoomListFragment.kt | 14 +++-- .../room/list/home/HomeRoomListFragment.kt | 15 ++++++ .../main/res/layout/fragment_room_list.xml | 51 +++++++++---------- 3 files changed, 46 insertions(+), 34 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt index 80f545b166..c25fe546c3 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt @@ -211,14 +211,12 @@ class RoomListFragment @Inject constructor( } private fun setupCreateRoomButton() { - // TODO: Uncomment -// when (roomListParams.displayMode) { -// RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.isVisible = true -// RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.isVisible = false -// RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.isVisible = true -// RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.isVisible = true -// RoomListDisplayMode.FILTERED -> Unit // No button in this mode -// } + when (roomListParams.displayMode) { + RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.isVisible = true + RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.isVisible = true + RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.isVisible = true + RoomListDisplayMode.FILTERED -> Unit // No button in this mode + } views.createChatRoomButton.debouncedClicks { fabCreateDirectChat() diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt index f0eb027785..cc211a31fa 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt @@ -20,6 +20,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.view.isVisible import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.ConcatAdapter import androidx.recyclerview.widget.LinearLayoutManager @@ -90,6 +91,7 @@ class HomeRoomListFragment @Inject constructor( } setupRecyclerView() + setupFabs() } private fun setupRecyclerView() { @@ -108,6 +110,19 @@ class HomeRoomListFragment @Inject constructor( views.roomListView.adapter = concatAdapter } + private fun setupFabs() { + views.newLayoutCreateChatButton.isVisible = true + views.newLayoutOpenSpacesButton.isVisible = true + + views.newLayoutCreateChatButton.setOnClickListener { + // Click action for create chat modal goes here + } + + views.newLayoutOpenSpacesButton.setOnClickListener { + // Click action for open spaces modal goes here + } + } + override fun invalidate() = withState(roomListViewModel) { state -> views.stateView.state = state.state } diff --git a/vector/src/main/res/layout/fragment_room_list.xml b/vector/src/main/res/layout/fragment_room_list.xml index 97e2725a1f..631602bb14 100644 --- a/vector/src/main/res/layout/fragment_room_list.xml +++ b/vector/src/main/res/layout/fragment_room_list.xml @@ -56,46 +56,45 @@ tools:visibility="visible" /> - - + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="bottom|end"> + tools:visibility="visible" + tools:targetApi="lollipop_mr1" /> + + + From 406a67827c35ef53c9d1004e1d754f0d14d76b6f Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Fri, 29 Jul 2022 15:48:21 +0200 Subject: [PATCH 3/6] Adds scroll behaviour to FABs --- .../room/list/home/HomeRoomListFragment.kt | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt index cc211a31fa..e7882ff36f 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt @@ -20,10 +20,10 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.core.view.isVisible import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.ConcatAdapter import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import com.airbnb.epoxy.EpoxyControllerAdapter import com.airbnb.epoxy.OnModelBuildFinishedListener import com.airbnb.mvrx.fragmentViewModel @@ -72,7 +72,7 @@ class HomeRoomListFragment @Inject constructor( override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - sharedActionViewModel = activityViewModelProvider.get(RoomListQuickActionsSharedActionViewModel::class.java) + sharedActionViewModel = activityViewModelProvider[RoomListQuickActionsSharedActionViewModel::class.java] sharedActionViewModel .stream() .onEach { handleQuickActions(it) } @@ -111,8 +111,7 @@ class HomeRoomListFragment @Inject constructor( } private fun setupFabs() { - views.newLayoutCreateChatButton.isVisible = true - views.newLayoutOpenSpacesButton.isVisible = true + showFABs() views.newLayoutCreateChatButton.setOnClickListener { // Click action for create chat modal goes here @@ -121,6 +120,29 @@ class HomeRoomListFragment @Inject constructor( views.newLayoutOpenSpacesButton.setOnClickListener { // Click action for open spaces modal goes here } + + // Hide FABs when list is scrolling + views.roomListView.addOnScrollListener(object : RecyclerView.OnScrollListener() { + override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { + views.createChatFabMenu.handler.removeCallbacksAndMessages(null) + + when (newState) { + RecyclerView.SCROLL_STATE_IDLE -> views.createChatFabMenu.postDelayed(::showFABs, 250) + RecyclerView.SCROLL_STATE_DRAGGING, + RecyclerView.SCROLL_STATE_SETTLING -> hideFABs() + } + } + }) + } + + private fun showFABs() { + views.newLayoutCreateChatButton.show() + views.newLayoutOpenSpacesButton.show() + } + + private fun hideFABs() { + views.newLayoutCreateChatButton.hide() + views.newLayoutOpenSpacesButton.hide() } override fun invalidate() = withState(roomListViewModel) { state -> From d116d980809c1dd31c25d252a567502b428fd1d4 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Fri, 29 Jul 2022 15:48:58 +0200 Subject: [PATCH 4/6] Adds changelog file --- changelog.d/6693.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6693.feature diff --git a/changelog.d/6693.feature b/changelog.d/6693.feature new file mode 100644 index 0000000000..5e905766a9 --- /dev/null +++ b/changelog.d/6693.feature @@ -0,0 +1 @@ +Adds New App Layout FABs (hidden behind feature flag) From b0a9b482e78ec61514f20ad3d9e352a3517d0789 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 2 Aug 2022 15:18:45 +0200 Subject: [PATCH 5/6] Adds issue numbers to unimplemented FAB clicks --- .../app/features/home/room/list/home/HomeRoomListFragment.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt index e7882ff36f..deaebac4f3 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt @@ -114,11 +114,11 @@ class HomeRoomListFragment @Inject constructor( showFABs() views.newLayoutCreateChatButton.setOnClickListener { - // Click action for create chat modal goes here + // Click action for create chat modal goes here (Issue #6717) } views.newLayoutOpenSpacesButton.setOnClickListener { - // Click action for open spaces modal goes here + // Click action for open spaces modal goes here (Issue #6499) } // Hide FABs when list is scrolling From af04221ad9e0d1eaa0bb6f4546d3b43cf65ff47e Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 9 Aug 2022 14:30:36 +0200 Subject: [PATCH 6/6] Improves content descriptions --- vector/src/main/res/layout/fragment_room_list.xml | 4 ++-- vector/src/main/res/values/strings.xml | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/vector/src/main/res/layout/fragment_room_list.xml b/vector/src/main/res/layout/fragment_room_list.xml index 631602bb14..17d93eb98a 100644 --- a/vector/src/main/res/layout/fragment_room_list.xml +++ b/vector/src/main/res/layout/fragment_room_list.xml @@ -67,7 +67,7 @@ android:layout_height="wrap_content" android:layout_marginBottom="20dp" android:accessibilityTraversalAfter="@id/newLayoutCreateChatButton" - android:contentDescription="@string/a11y_create_room" + android:contentDescription="@string/a11y_open_spaces" android:src="@drawable/ic_open_spaces" android:visibility="gone" app:backgroundTint="?attr/vctr_toolbar_background" @@ -88,7 +88,7 @@ android:layout_marginEnd="16dp" android:layout_marginBottom="16dp" android:accessibilityTraversalBefore="@id/roomListView" - android:contentDescription="@string/a11y_create_room" + android:contentDescription="@string/a11y_create_message" android:src="@drawable/ic_new_chat" android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index bd4f032d0e..9fc9756897 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -1812,7 +1812,8 @@ Close the create room menu… Create a new direct conversation Create a new conversation or room - Create a new room + Create a new room + Open spaces list Close keys backup banner Jump to bottom