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

@ -30,7 +30,6 @@ import org.thoughtcrime.securesms.registration.data.network.VerificationCodeRequ
import org.thoughtcrime.securesms.registration.fragments.ContactSupportBottomSheetFragment
import org.thoughtcrime.securesms.registration.fragments.RegistrationViewDelegate
import org.thoughtcrime.securesms.registration.fragments.SignalStrengthPhoneStateListener
import org.thoughtcrime.securesms.util.BottomSheetUtil
import org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener
import org.thoughtcrime.securesms.util.navigation.safeNavigate
import org.thoughtcrime.securesms.util.visible
@ -42,6 +41,7 @@ class ChangeNumberEnterCodeFragment : LoggingFragment(R.layout.fragment_change_n
companion object {
private val TAG: String = Log.tag(ChangeNumberEnterCodeFragment::class.java)
private const val BOTTOM_SHEET_TAG = "support_bottom_sheet"
}
private val viewModel by activityViewModels<ChangeNumberViewModel>()
@ -95,7 +95,7 @@ class ChangeNumberEnterCodeFragment : LoggingFragment(R.layout.fragment_change_n
}
binding.codeEntryLayout.havingTroubleButton.setOnClickListener {
bottomSheet.show(childFragmentManager, BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG)
bottomSheet.showSafely(childFragmentManager, BOTTOM_SHEET_TAG)
}
binding.codeEntryLayout.callMeCountDown.apply {
@ -291,7 +291,7 @@ class ChangeNumberEnterCodeFragment : LoggingFragment(R.layout.fragment_change_n
private inner class PhoneStateCallback : SignalStrengthPhoneStateListener.Callback {
override fun onNoCellSignalPresent() {
bottomSheet.show(childFragmentManager, BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG)
bottomSheet.showSafely(childFragmentManager, BOTTOM_SHEET_TAG)
}
override fun onCellSignalPresent() {

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() {