diff --git a/changelog.d/6801.wip b/changelog.d/6801.wip new file mode 100644 index 0000000000..bb3bc9d7a1 --- /dev/null +++ b/changelog.d/6801.wip @@ -0,0 +1 @@ +Adds new chat bottom sheet as the click action of the main FAB in the new app layout diff --git a/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt b/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt index 6b8fe735b3..22e1c99ab2 100644 --- a/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt @@ -63,6 +63,7 @@ import im.vector.app.features.home.room.detail.TimelineFragment import im.vector.app.features.home.room.detail.search.SearchFragment import im.vector.app.features.home.room.list.RoomListFragment import im.vector.app.features.home.room.list.home.HomeRoomListFragment +import im.vector.app.features.home.room.list.home.NewChatBottomSheet import im.vector.app.features.home.room.threads.list.views.ThreadListFragment import im.vector.app.features.location.LocationSharingFragment import im.vector.app.features.location.preview.LocationPreviewFragment @@ -191,6 +192,11 @@ interface FragmentModule { @FragmentKey(RoomListFragment::class) fun bindRoomListFragment(fragment: RoomListFragment): Fragment + @Binds + @IntoMap + @FragmentKey(NewChatBottomSheet::class) + fun bindNewChatBottomSheetFragment(fragment: NewChatBottomSheet): Fragment + @Binds @IntoMap @FragmentKey(LocalePickerFragment::class) 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 8cbf760025..1d9342b45b 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 @@ -74,6 +74,8 @@ class HomeRoomListFragment @Inject constructor( private lateinit var stateRestorer: LayoutManagerStateRestorer + private val newChatBottomSheet = NewChatBottomSheet() + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRoomListBinding { return FragmentRoomListBinding.inflate(inflater, container, false) } @@ -166,7 +168,7 @@ class HomeRoomListFragment @Inject constructor( showFABs() views.newLayoutCreateChatButton.setOnClickListener { - // Click action for create chat modal goes here (Issue #6717) + newChatBottomSheet.show(requireActivity().supportFragmentManager, NewChatBottomSheet.TAG) } views.newLayoutOpenSpacesButton.setOnClickListener { diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt new file mode 100644 index 0000000000..05b86f7393 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.home.room.list.home + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.google.android.material.bottomsheet.BottomSheetDialogFragment +import dagger.hilt.android.AndroidEntryPoint +import im.vector.app.databinding.FragmentNewChatBottomSheetBinding +import im.vector.app.features.navigation.Navigator +import javax.inject.Inject + +@AndroidEntryPoint +class NewChatBottomSheet @Inject constructor() : BottomSheetDialogFragment() { + + @Inject lateinit var navigator: Navigator + + private lateinit var binding: FragmentNewChatBottomSheetBinding + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { + binding = FragmentNewChatBottomSheetBinding.inflate(inflater, container, false) + initFABs() + return binding.root + } + + private fun initFABs() { + binding.startChat.setOnClickListener { + navigator.openCreateDirectRoom(requireActivity()) + } + + binding.createRoom.setOnClickListener { + navigator.openCreateRoom(requireActivity()) + } + + binding.exploreRooms.setOnClickListener { + navigator.openRoomDirectory(requireContext()) + } + } + + companion object { + const val TAG = "NewChatBottomSheet" + } +} diff --git a/vector/src/main/res/drawable/ic_chat.xml b/vector/src/main/res/drawable/ic_chat.xml new file mode 100644 index 0000000000..fb10eae9c9 --- /dev/null +++ b/vector/src/main/res/drawable/ic_chat.xml @@ -0,0 +1,10 @@ + + + diff --git a/vector/src/main/res/drawable/ic_room_add.xml b/vector/src/main/res/drawable/ic_room_add.xml new file mode 100644 index 0000000000..8404ff2181 --- /dev/null +++ b/vector/src/main/res/drawable/ic_room_add.xml @@ -0,0 +1,10 @@ + + + diff --git a/vector/src/main/res/drawable/ic_room_explore.xml b/vector/src/main/res/drawable/ic_room_explore.xml new file mode 100644 index 0000000000..9811a09054 --- /dev/null +++ b/vector/src/main/res/drawable/ic_room_explore.xml @@ -0,0 +1,14 @@ + + + + diff --git a/vector/src/main/res/layout/fragment_new_chat_bottom_sheet.xml b/vector/src/main/res/layout/fragment_new_chat_bottom_sheet.xml new file mode 100644 index 0000000000..07c19b43eb --- /dev/null +++ b/vector/src/main/res/layout/fragment_new_chat_bottom_sheet.xml @@ -0,0 +1,50 @@ + + + + + + + + + + diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 483ceb5d2a..4502304cc7 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -137,7 +137,10 @@ All Chats + Start Chat + Create Room Change Space + Explore Rooms