fix: defer settings fragment transaction until dialog is shown

This commit is contained in:
2026-04-30 12:44:29 -04:00
parent b6da868103
commit 11a368b7c8
@@ -47,14 +47,6 @@ class SettingsDialogFragment : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialogView = LayoutInflater.from(requireContext()).inflate(R.layout.dialog_settings, null) val dialogView = LayoutInflater.from(requireContext()).inflate(R.layout.dialog_settings, null)
childFragmentManager.commitNow {
replace(
R.id.settingsFragmentContainer,
SettingsPreferencesFragment(),
SETTINGS_PREFS_TAG,
)
}
progress = dialogView.findViewById(R.id.settingsApplyProgress) progress = dialogView.findViewById(R.id.settingsApplyProgress)
errorText = dialogView.findViewById(R.id.settingsErrorText) errorText = dialogView.findViewById(R.id.settingsErrorText)
saveButton = dialogView.findViewById(R.id.settingsSaveAndCloseButton) saveButton = dialogView.findViewById(R.id.settingsSaveAndCloseButton)
@@ -69,6 +61,15 @@ class SettingsDialogFragment : DialogFragment() {
dialog.setCanceledOnTouchOutside(false) dialog.setCanceledOnTouchOutside(false)
dialog.setOnShowListener { dialog.setOnShowListener {
if (findPreferencesFragment() == null) {
childFragmentManager.commitNow {
replace(
R.id.settingsFragmentContainer,
SettingsPreferencesFragment(),
SETTINGS_PREFS_TAG,
)
}
}
saveButton?.setOnClickListener { saveButton?.setOnClickListener {
onSaveClicked() onSaveClicked()
} }