Эх сурвалжийг харах

make bottom_sheets initial state collapsed for the rounded top corners

Resolves #2035

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 жил өмнө
parent
commit
c7ac8a3074

+ 1 - 1
app/src/main/java/com/nextcloud/talk/ui/dialog/AttachmentDialog.kt

@@ -90,6 +90,6 @@ class AttachmentDialog(val activity: Activity, var chatController: ChatControlle
         super.onStart()
         val bottomSheet = findViewById<View>(R.id.design_bottom_sheet)
         val behavior = BottomSheetBehavior.from(bottomSheet as View)
-        behavior.state = BottomSheetBehavior.STATE_EXPANDED
+        behavior.state = BottomSheetBehavior.STATE_COLLAPSED
     }
 }

+ 1 - 1
app/src/main/java/com/nextcloud/talk/ui/dialog/AudioOutputDialog.kt

@@ -158,7 +158,7 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
         super.onStart()
         val bottomSheet = findViewById<View>(R.id.design_bottom_sheet)
         val behavior = BottomSheetBehavior.from(bottomSheet as View)
-        behavior.state = BottomSheetBehavior.STATE_EXPANDED
+        behavior.state = BottomSheetBehavior.STATE_COLLAPSED
     }
 
     companion object {

+ 2 - 2
app/src/main/java/com/nextcloud/talk/ui/dialog/ContactsBottomDialog.kt

@@ -40,7 +40,7 @@ import com.nextcloud.talk.databinding.DialogBottomContactsBinding
 class ContactsBottomDialog(
     val activity: Activity,
     val bundle: Bundle
-) : BottomSheetDialog(activity, R.style.BottomSheetDialogThemeNoFloating) {
+) : BottomSheetDialog(activity) {
 
     private var dialogRouter: Router? = null
 
@@ -73,7 +73,7 @@ class ContactsBottomDialog(
         super.onStart()
         val bottomSheet = findViewById<View>(R.id.design_bottom_sheet)
         val behavior = BottomSheetBehavior.from(bottomSheet as View)
-        behavior.state = BottomSheetBehavior.STATE_EXPANDED
+        behavior.state = BottomSheetBehavior.STATE_COLLAPSED
     }
 
     companion object {

+ 2 - 2
app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt

@@ -72,7 +72,7 @@ class ConversationsListBottomDialog(
     val controller: ConversationsListController,
     val currentUser: UserEntity,
     val conversation: Conversation
-) : BottomSheetDialog(activity, R.style.BottomSheetDialogThemeNoFloating) {
+) : BottomSheetDialog(activity) {
 
     private var dialogRouter: Router? = null
 
@@ -309,7 +309,7 @@ class ConversationsListBottomDialog(
         super.onStart()
         val bottomSheet = findViewById<View>(R.id.design_bottom_sheet)
         val behavior = BottomSheetBehavior.from(bottomSheet as View)
-        behavior.state = BottomSheetBehavior.STATE_EXPANDED
+        behavior.state = BottomSheetBehavior.STATE_COLLAPSED
     }
 
     companion object {

+ 2 - 2
app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt

@@ -60,7 +60,7 @@ class MessageActionsDialog(
     private val showMessageDeletionButton: Boolean,
     private val hasChatPermission: Boolean,
     private val ncApi: NcApi
-) : BottomSheetDialog(chatController.activity!!, R.style.BottomSheetDialogThemeNoFloating) {
+) : BottomSheetDialog(chatController.activity!!) {
 
     private lateinit var dialogMessageActionsBinding: DialogMessageActionsBinding
 
@@ -97,7 +97,7 @@ class MessageActionsDialog(
         super.onStart()
         val bottomSheet = findViewById<View>(R.id.design_bottom_sheet)
         val behavior = BottomSheetBehavior.from(bottomSheet as View)
-        behavior.state = BottomSheetBehavior.STATE_EXPANDED
+        behavior.state = BottomSheetBehavior.STATE_COLLAPSED
     }
 
     private fun hasUserId(user: UserEntity?): Boolean {

+ 2 - 3
app/src/main/java/com/nextcloud/talk/ui/dialog/ScopeDialog.kt

@@ -38,8 +38,7 @@ class ScopeDialog(
     private val userInfoAdapter: ProfileController.UserInfoAdapter,
     private val field: ProfileController.Field,
     private val position: Int
-) :
-    BottomSheetDialog(con) {
+) : BottomSheetDialog(con) {
 
     private lateinit var dialogScopeBinding: DialogScopeBinding
 
@@ -79,6 +78,6 @@ class ScopeDialog(
         super.onStart()
         val bottomSheet = findViewById<View>(R.id.design_bottom_sheet)
         val behavior = BottomSheetBehavior.from(bottomSheet as View)
-        behavior.state = BottomSheetBehavior.STATE_EXPANDED
+        behavior.state = BottomSheetBehavior.STATE_COLLAPSED
     }
 }

+ 9 - 0
app/src/main/java/com/nextcloud/talk/ui/dialog/ShowReactionsDialog.kt

@@ -29,10 +29,12 @@ package com.nextcloud.talk.ui.dialog
 import android.app.Activity
 import android.os.Bundle
 import android.util.Log
+import android.view.View
 import android.view.ViewGroup
 import androidx.annotation.NonNull
 import androidx.recyclerview.widget.LinearLayoutManager
 import autodagger.AutoInjector
+import com.google.android.material.bottomsheet.BottomSheetBehavior
 import com.google.android.material.bottomsheet.BottomSheetDialog
 import com.google.android.material.tabs.TabLayout
 import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
@@ -84,6 +86,13 @@ class ShowReactionsDialog(
         initEmojiReactions()
     }
 
+    override fun onStart() {
+        super.onStart()
+        val bottomSheet = findViewById<View>(R.id.design_bottom_sheet)
+        val behavior = BottomSheetBehavior.from(bottomSheet as View)
+        behavior.state = BottomSheetBehavior.STATE_COLLAPSED
+    }
+
     private fun initEmojiReactions() {
         adapter?.list?.clear()
         if (chatMessage.reactions != null && chatMessage.reactions.isNotEmpty()) {

+ 7 - 4
app/src/main/res/values/styles.xml

@@ -62,6 +62,7 @@
 
     <style name="Talk.BottomSheetDialog" parent="Widget.MaterialComponents.BottomSheet.Modal">
         <item name="backgroundTint">@color/bg_bottom_sheet</item>
+        <item name="shapeAppearanceOverlay">@style/CustomShapeAppearanceBottomSheetDialog</item>
     </style>
 
     <style name="TransparentTheme" parent="Theme.MaterialComponents.NoActionBar.Bridge">
@@ -244,9 +245,12 @@
         <item name="android:colorControlNormal">#ffffff</item>
     </style>
 
-    <style name="BottomSheetDialogThemeNoFloating" parent="ThemeOverlay.MaterialComponents.DayNight.BottomSheetDialog">
-        <item name="android:windowIsFloating">false</item>
-        <item name="android:windowSoftInputMode">adjustResize</item>
+    <style name="CustomShapeAppearanceBottomSheetDialog" parent="">
+        <item name="cornerFamily">rounded</item>
+        <item name="cornerSizeTopRight">16dp</item>
+        <item name="cornerSizeTopLeft">16dp</item>
+        <item name="cornerSizeBottomRight">0dp</item>
+        <item name="cornerSizeBottomLeft">0dp</item>
     </style>
 
     <style name="OutlinedButton" parent="Widget.MaterialComponents.Button.OutlinedButton">
@@ -262,5 +266,4 @@
         <item name="android:textAllCaps">false</item>
     </style>
 
-
 </resources>