Merge remote-tracking branch 'origin/develop' into bugfix/eric/dismiss-new-chat

# Conflicts:
#	vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt
This commit is contained in:
ericdecanini 2022-09-15 10:05:13 -04:00
commit 13b1722060
4 changed files with 39 additions and 15 deletions

1
changelog.d/7103.bugfix Normal file
View File

@ -0,0 +1 @@
Fixes space list and new chat bottom sheets showing too small in New App Layout (especially evident in landscape)

View File

@ -25,6 +25,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.annotation.CallSuper
import androidx.annotation.FloatRange
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import androidx.viewbinding.ViewBinding
@ -39,6 +40,7 @@ import im.vector.app.core.extensions.toMvRxBundle
import im.vector.app.core.utils.DimensionConverter
import im.vector.app.features.analytics.AnalyticsTracker
import im.vector.app.features.analytics.plan.MobileScreen
import io.github.hyuwah.draggableviewlib.Utils
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import reactivecircus.flowbinding.android.view.clicks
@ -165,6 +167,13 @@ abstract class VectorBaseBottomSheetDialogFragment<VB : ViewBinding> : BottomShe
forceExpandState()
}
protected fun setPeekHeightAsScreenPercentage(@FloatRange(from = 0.0, to = 1.0) percentage: Float) {
context?.let {
val screenHeight = Utils.getScreenHeight(it)
bottomSheetBehavior?.setPeekHeight((screenHeight * percentage).toInt(), true)
}
}
protected fun forceExpandState() {
if (showExpanded) {
// Force the bottom sheet to be expanded

View File

@ -16,46 +16,53 @@
package im.vector.app.features.home.room.list.home
import android.app.Dialog
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.core.platform.VectorBaseBottomSheetDialogFragment
import im.vector.app.databinding.FragmentNewChatBottomSheetBinding
import im.vector.app.features.navigation.Navigator
import javax.inject.Inject
@AndroidEntryPoint
class NewChatBottomSheet : BottomSheetDialogFragment() {
class NewChatBottomSheet : VectorBaseBottomSheetDialogFragment<FragmentNewChatBottomSheetBinding>() {
@Inject lateinit var navigator: Navigator
private lateinit var binding: FragmentNewChatBottomSheetBinding
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentNewChatBottomSheetBinding {
return FragmentNewChatBottomSheetBinding.inflate(inflater, container, false)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentNewChatBottomSheetBinding.inflate(inflater, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
initFABs()
return binding.root
}
private fun initFABs() {
binding.startChat.setOnClickListener {
views.startChat.debouncedClicks {
dismiss()
navigator.openCreateDirectRoom(requireActivity())
}
binding.createRoom.setOnClickListener {
views.createRoom.debouncedClicks {
dismiss()
navigator.openCreateRoom(requireActivity())
}
binding.exploreRooms.setOnClickListener {
views.exploreRooms.debouncedClicks {
dismiss()
navigator.openRoomDirectory(requireContext())
}
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return super.onCreateDialog(savedInstanceState).apply {
setPeekHeightAsScreenPercentage(0.5f)
}
}
companion object {
const val TAG = "NewChatBottomSheet"
}

View File

@ -16,25 +16,32 @@
package im.vector.app.features.spaces
import android.app.Dialog
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import im.vector.app.R
import im.vector.app.core.extensions.replaceChildFragment
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
import im.vector.app.databinding.FragmentSpacesBottomSheetBinding
class SpaceListBottomSheet : BottomSheetDialogFragment() {
class SpaceListBottomSheet : VectorBaseBottomSheetDialogFragment<FragmentSpacesBottomSheetBinding>() {
private lateinit var binding: FragmentSpacesBottomSheetBinding
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentSpacesBottomSheetBinding {
return FragmentSpacesBottomSheetBinding.inflate(inflater, container, false)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentSpacesBottomSheetBinding.inflate(inflater, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
if (savedInstanceState == null) {
replaceChildFragment(R.id.space_list, SpaceListFragment::class.java)
}
return binding.root
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return super.onCreateDialog(savedInstanceState).apply {
setPeekHeightAsScreenPercentage(0.75f)
}
}
companion object {