Merge pull request #6693 from vector-im/feature/eric/new_fab

New App Layout FABs
This commit is contained in:
Eric Decanini 2022-08-10 08:13:36 +02:00 committed by GitHub
commit ce4ab78f13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 113 additions and 2 deletions

1
changelog.d/6693.feature Normal file
View file

@ -0,0 +1 @@
Adds New App Layout FABs (hidden behind feature flag)

View file

@ -65,4 +65,8 @@
<item name="colorPrimary">?colorOnPrimary</item>
</style>
<style name="Widget.Vector.FloatingActionButton" parent="Widget.MaterialComponents.FloatingActionButton">
<item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.Material3.FloatingActionButton</item>
</style>
</resources>

View file

@ -23,6 +23,7 @@ import android.view.ViewGroup
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
@ -74,7 +75,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) }
@ -93,6 +94,7 @@ class HomeRoomListFragment @Inject constructor(
}
setupRecyclerView()
setupFabs()
}
private fun setupRecyclerView() {
@ -111,6 +113,41 @@ class HomeRoomListFragment @Inject constructor(
views.roomListView.adapter = concatAdapter
}
private fun setupFabs() {
showFABs()
views.newLayoutCreateChatButton.setOnClickListener {
// Click action for create chat modal goes here (Issue #6717)
}
views.newLayoutOpenSpacesButton.setOnClickListener {
// Click action for open spaces modal goes here (Issue #6499)
}
// 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 ->
views.stateView.state = state.state
}

View file

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M9.615,8.501C9.576,8.54 9.549,8.591 9.537,8.646L9.121,10.667C9.08,10.867 9.249,11.046 9.444,11.008L11.412,10.627C11.466,10.617 11.516,10.59 11.555,10.551L19.916,2.131C20.026,2.021 20.028,1.839 19.921,1.726L18.369,0.086C18.262,-0.027 18.086,-0.029 17.976,0.082L9.615,8.501ZM-0,4.686L-0,16.906C-0,17.727 0.319,18.514 0.887,19.094C1.456,19.674 2.226,20 3.03,20L14.996,20C15.8,20 16.57,19.674 17.139,19.094C17.707,18.514 18.026,17.727 18.026,16.906L18.026,9.61C18.026,9.337 17.92,9.075 17.73,8.881C17.541,8.688 17.284,8.579 17.016,8.579C16.748,8.579 16.491,8.688 16.302,8.881C16.113,9.075 16.006,9.337 16.006,9.61L16.006,16.906C16.006,17.18 15.9,17.442 15.71,17.635C15.521,17.829 15.264,17.938 14.996,17.938L3.03,17.938C2.762,17.938 2.505,17.829 2.316,17.635C2.126,17.442 2.02,17.18 2.02,16.906L2.02,4.686C2.02,4.413 2.126,4.15 2.316,3.957C2.505,3.764 2.762,3.655 3.03,3.655L10.174,3.655C10.442,3.655 10.699,3.546 10.888,3.353C11.078,3.16 11.184,2.897 11.184,2.624C11.184,2.35 11.078,2.088 10.888,1.895C10.699,1.701 10.442,1.593 10.174,1.593L3.03,1.593C2.226,1.593 1.456,1.918 0.887,2.499C0.319,3.079 -0,3.866 -0,4.686Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
</vector>

View file

@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<group>
<clip-path
android:pathData="M1,0C0.448,0 0,0.448 0,1V7.889C0,8.441 0.448,8.889 1,8.889H7.889C8.441,8.889 8.889,8.441 8.889,7.889V1C8.889,0.448 8.441,0 7.889,0H1ZM12.111,0C11.559,0 11.111,0.448 11.111,1V7.889C11.111,8.441 11.559,8.889 12.111,8.889H19C19.552,8.889 20,8.441 20,7.889V1C20,0.448 19.552,0 19,0H12.111ZM0,12.111C0,11.559 0.448,11.111 1,11.111H7.889C8.441,11.111 8.889,11.559 8.889,12.111V19C8.889,19.552 8.441,20 7.889,20H1C0.448,20 0,19.552 0,19V12.111ZM12.111,11.111C11.559,11.111 11.111,11.559 11.111,12.111V19C11.111,19.552 11.559,20 12.111,20H19C19.552,20 20,19.552 20,19V12.111C20,11.559 19.552,11.111 19,11.111H12.111Z"
android:fillType="evenOdd"/>
<path
android:pathData="M2,1C2,1.552 1.552,2 1,2V-2C-0.657,-2 -2,-0.657 -2,1H2ZM2,7.889V1H-2V7.889H2ZM1,6.889C1.552,6.889 2,7.337 2,7.889H-2C-2,9.546 -0.657,10.889 1,10.889V6.889ZM7.889,6.889H1V10.889H7.889V6.889ZM6.889,7.889C6.889,7.337 7.337,6.889 7.889,6.889V10.889C9.546,10.889 10.889,9.546 10.889,7.889H6.889ZM6.889,1V7.889H10.889V1H6.889ZM7.889,2C7.337,2 6.889,1.552 6.889,1H10.889C10.889,-0.657 9.546,-2 7.889,-2V2ZM1,2H7.889V-2H1V2ZM13.111,1C13.111,1.552 12.663,2 12.111,2V-2C10.454,-2 9.111,-0.657 9.111,1H13.111ZM13.111,7.889V1H9.111V7.889H13.111ZM12.111,6.889C12.663,6.889 13.111,7.337 13.111,7.889H9.111C9.111,9.546 10.454,10.889 12.111,10.889V6.889ZM19,6.889H12.111V10.889H19V6.889ZM18,7.889C18,7.337 18.448,6.889 19,6.889V10.889C20.657,10.889 22,9.546 22,7.889H18ZM18,1V7.889H22V1H18ZM19,2C18.448,2 18,1.552 18,1H22C22,-0.657 20.657,-2 19,-2V2ZM12.111,2H19V-2H12.111V2ZM1,9.111C-0.657,9.111 -2,10.454 -2,12.111H2C2,12.663 1.552,13.111 1,13.111V9.111ZM7.889,9.111H1V13.111H7.889V9.111ZM10.889,12.111C10.889,10.454 9.546,9.111 7.889,9.111V13.111C7.337,13.111 6.889,12.663 6.889,12.111H10.889ZM10.889,19V12.111H6.889V19H10.889ZM7.889,22C9.546,22 10.889,20.657 10.889,19H6.889C6.889,18.448 7.337,18 7.889,18V22ZM1,22H7.889V18H1V22ZM-2,19C-2,20.657 -0.657,22 1,22V18C1.552,18 2,18.448 2,19H-2ZM-2,12.111V19H2V12.111H-2ZM13.111,12.111C13.111,12.663 12.663,13.111 12.111,13.111V9.111C10.454,9.111 9.111,10.454 9.111,12.111H13.111ZM13.111,19V12.111H9.111V19H13.111ZM12.111,18C12.663,18 13.111,18.448 13.111,19H9.111C9.111,20.657 10.454,22 12.111,22V18ZM19,18H12.111V22H19V18ZM18,19C18,18.448 18.448,18 19,18V22C20.657,22 22,20.657 22,19H18ZM18,12.111V19H22V12.111H18ZM19,13.111C18.448,13.111 18,12.663 18,12.111H22C22,10.454 20.657,9.111 19,9.111V13.111ZM12.111,13.111H19V9.111H12.111V13.111Z"
android:fillColor="#0DBD8B"/>
</group>
</vector>

View file

@ -55,4 +55,47 @@
tools:layout_marginEnd="144dp"
tools:visibility="visible" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|end">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/newLayoutOpenSpacesButton"
style="@style/Widget.Vector.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:accessibilityTraversalAfter="@id/newLayoutCreateChatButton"
android:contentDescription="@string/a11y_open_spaces"
android:src="@drawable/ic_open_spaces"
android:visibility="gone"
app:backgroundTint="?attr/vctr_toolbar_background"
app:fabSize="mini"
app:layout_constraintBottom_toTopOf="@id/newLayoutCreateChatButton"
app:layout_constraintEnd_toEndOf="@id/newLayoutCreateChatButton"
app:layout_constraintStart_toStartOf="@id/newLayoutCreateChatButton"
app:tint="?attr/colorPrimary"
tools:visibility="visible"
tools:targetApi="lollipop_mr1" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/newLayoutCreateChatButton"
style="@style/Widget.Vector.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:accessibilityTraversalBefore="@id/roomListView"
android:contentDescription="@string/a11y_create_message"
android:src="@drawable/ic_new_chat"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:visibility="visible"
tools:targetApi="lollipop_mr1" />
</androidx.constraintlayout.widget.ConstraintLayout>
</im.vector.app.core.platform.StateView>

View file

@ -1811,7 +1811,9 @@
<string name="a11y_create_menu_open">Open the create room menu</string>
<string name="a11y_create_menu_close">Close the create room menu…</string>
<string name="a11y_create_direct_message">Create a new direct conversation</string>
<string name="a11y_create_room">Create a new room</string>
<string name="a11y_create_message">Create a new conversation or room</string>
<string name="a11y_create_room">Create a new room</string> <!-- TODO TO BE REMOVED -->
<string name="a11y_open_spaces">Open spaces list</string>
<string name="a11y_close_keys_backup_banner">Close keys backup banner</string>
<string name="a11y_jump_to_bottom">Jump to bottom</string>