Prevent crash when trying to display Contact Support bottom sheet multiple times.

This commit is contained in:
Nicholas Tinsley
2024-07-08 10:23:59 -04:00
committed by Cody Henthorne
parent a3d1197aef
commit 414368e251
3 changed files with 12 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ import androidx.compose.ui.text.withStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.fragment.app.FragmentManager
import org.signal.core.ui.BottomSheets
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.compose.ComposeBottomSheetDialogFragment
@@ -158,6 +159,12 @@ class ContactSupportBottomSheetFragment : ComposeBottomSheetDialogFragment() {
)
}
fun showSafely(fm: FragmentManager, tag: String) {
if (!isAdded) {
show(fm, tag)
}
}
companion object {
private const val TROUBLESHOOTING_STEPS_KEY = "troubleshooting"
private const val CONTACT_SUPPORT_KEY = "contact_support"

View File

@@ -80,7 +80,7 @@ class EnterCodeFragment : LoggingFragment(R.layout.fragment_registration_enter_c
}
binding.havingTroubleButton.setOnClickListener {
bottomSheet.show(childFragmentManager, BOTTOM_SHEET_TAG)
bottomSheet.showSafely(childFragmentManager, BOTTOM_SHEET_TAG)
}
binding.callMeCountDown.apply {
@@ -263,7 +263,7 @@ class EnterCodeFragment : LoggingFragment(R.layout.fragment_registration_enter_c
private inner class PhoneStateCallback : SignalStrengthPhoneStateListener.Callback {
override fun onNoCellSignalPresent() {
bottomSheet.show(childFragmentManager, BOTTOM_SHEET_TAG)
bottomSheet.showSafely(childFragmentManager, BOTTOM_SHEET_TAG)
}
override fun onCellSignalPresent() {