Fix crash when choosing join room from FAB

This commit is contained in:
12aw 2024-02-18 16:31:44 +01:00
parent 627688ae4c
commit 9316f83cac
2 changed files with 24 additions and 1 deletions

View file

@ -47,6 +47,17 @@ public class JoinConferenceDialog extends DialogFragment implements OnBackendCon
return dialog; return dialog;
} }
public static JoinConferenceDialog newInstance(String prefilledJid, List<String> accounts, boolean multipleAccounts) {
JoinConferenceDialog dialog = new JoinConferenceDialog();
Bundle bundle = new Bundle();
bundle.putString(PREFILLED_JID_KEY, prefilledJid);
bundle.putBoolean(MULTIPLE_ACCOUNTS, multipleAccounts);
bundle.putStringArrayList(ACCOUNTS_LIST_KEY, (ArrayList<String>) accounts);
dialog.setArguments(bundle);
return dialog;
}
@Override @Override
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);

View file

@ -387,7 +387,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
showPublicChannelDialog(); showPublicChannelDialog();
break; break;
case R.id.join_public_channel: case R.id.join_public_channel:
showJoinConferenceDialog(prefilled, null); showJoinConferenceDialog(prefilled);
break; break;
case R.id.create_contact: case R.id.create_contact:
showCreateContactDialog(prefilled, null); showCreateContactDialog(prefilled, null);
@ -712,6 +712,18 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
joinConferenceFragment.show(ft, FRAGMENT_TAG_DIALOG); joinConferenceFragment.show(ft, FRAGMENT_TAG_DIALOG);
} }
@SuppressLint("InflateParams")
protected void showJoinConferenceDialog(final String prefilledJid) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
Fragment prev = getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG_DIALOG);
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
JoinConferenceDialog joinConferenceFragment = JoinConferenceDialog.newInstance(prefilledJid, mActivatedAccounts, xmppConnectionService.multipleAccounts());
joinConferenceFragment.show(ft, FRAGMENT_TAG_DIALOG);
}
private void showCreatePrivateGroupChatDialog() { private void showCreatePrivateGroupChatDialog() {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
Fragment prev = getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG_DIALOG); Fragment prev = getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG_DIALOG);