Fixed crash due to not using the local address in getChatRooms()

This commit is contained in:
Sylvain Berfini 2021-03-24 13:54:51 +01:00
parent b6445cda7f
commit e97a68dda5
6 changed files with 27 additions and 6 deletions

View file

@ -100,7 +100,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 29 targetSdkVersion 29
versionCode 4319 versionCode 4320
versionName "${project.version}" versionName "${project.version}"
applicationId getPackageName() applicationId getPackageName()
multiDexEnabled true multiDexEnabled true

View file

@ -297,6 +297,7 @@ public class ChatActivity extends MainActivity {
public void showChatRoomGroupInfo( public void showChatRoomGroupInfo(
Address peerAddress, Address peerAddress,
Address localAddress,
ArrayList<ContactAddress> participants, ArrayList<ContactAddress> participants,
String subject, String subject,
boolean encrypted) { boolean encrypted) {
@ -304,6 +305,9 @@ public class ChatActivity extends MainActivity {
if (peerAddress != null) { if (peerAddress != null) {
extras.putSerializable("RemoteSipUri", peerAddress.asStringUriOnly()); extras.putSerializable("RemoteSipUri", peerAddress.asStringUriOnly());
} }
if (localAddress != null) {
extras.putSerializable("LocalSipUri", localAddress.asStringUriOnly());
}
extras.putSerializable("Participants", participants); extras.putSerializable("Participants", participants);
extras.putString("Subject", subject); extras.putString("Subject", subject);
extras.putBoolean("Encrypted", encrypted); extras.putBoolean("Encrypted", encrypted);
@ -313,11 +317,14 @@ public class ChatActivity extends MainActivity {
changeFragment(fragment, "Chat room group info", true); changeFragment(fragment, "Chat room group info", true);
} }
public void showChatRoomEphemeral(Address peerAddress) { public void showChatRoomEphemeral(Address peerAddress, Address localAddress) {
Bundle extras = new Bundle(); Bundle extras = new Bundle();
if (peerAddress != null) { if (peerAddress != null) {
extras.putSerializable("RemoteSipUri", peerAddress.asStringUriOnly()); extras.putSerializable("RemoteSipUri", peerAddress.asStringUriOnly());
} }
if (localAddress != null) {
extras.putSerializable("LocalSipUri", localAddress.asStringUriOnly());
}
EphemeralFragment fragment = new EphemeralFragment(); EphemeralFragment fragment = new EphemeralFragment();
fragment.setArguments(extras); fragment.setArguments(extras);
changeFragment(fragment, "Chat room ephemeral", true); changeFragment(fragment, "Chat room ephemeral", true);

View file

@ -1215,12 +1215,16 @@ public class ChatMessagesFragment extends Fragment
boolean encrypted = mChatRoom.hasCapability(ChatRoomCapabilities.Encrypted.toInt()); boolean encrypted = mChatRoom.hasCapability(ChatRoomCapabilities.Encrypted.toInt());
((ChatActivity) getActivity()) ((ChatActivity) getActivity())
.showChatRoomGroupInfo( .showChatRoomGroupInfo(
mRemoteSipAddress, participants, mChatRoom.getSubject(), encrypted); mRemoteSipAddress,
mLocalSipAddress,
participants,
mChatRoom.getSubject(),
encrypted);
} }
private void goToEphemeral() { private void goToEphemeral() {
if (mChatRoom == null) return; if (mChatRoom == null) return;
((ChatActivity) getActivity()).showChatRoomEphemeral(mRemoteSipAddress); ((ChatActivity) getActivity()).showChatRoomEphemeral(mRemoteSipAddress, mLocalSipAddress);
} }
/* /*

View file

@ -154,6 +154,7 @@ public class ChatRoomCreationFragment extends Fragment
? null ? null
: Factory.instance() : Factory.instance()
.createAddress(mChatRoomAddress), .createAddress(mChatRoomAddress),
mChatRoom == null ? null : mChatRoom.getLocalAddress(),
mSearchAdapter.getContactsSelectedList(), mSearchAdapter.getContactsSelectedList(),
mChatRoomSubject, mChatRoomSubject,
mSecurityToggle.isChecked()); mSecurityToggle.isChecked());

View file

@ -58,12 +58,14 @@ public class EphemeralFragment extends Fragment {
String address = getArguments().getString("RemoteSipUri"); String address = getArguments().getString("RemoteSipUri");
Address peerAddress = null; Address peerAddress = null;
String localSipUri = getArguments().getString("LocalSipUri");
Address localSipAddress = Factory.instance().createAddress(localSipUri);
mChatRoom = null; mChatRoom = null;
if (address != null && address.length() > 0) { if (address != null && address.length() > 0) {
peerAddress = Factory.instance().createAddress(address); peerAddress = Factory.instance().createAddress(address);
} }
if (peerAddress != null) { if (peerAddress != null) {
mChatRoom = LinphoneManager.getCore().getChatRoom(peerAddress); mChatRoom = LinphoneManager.getCore().getChatRoom(peerAddress, localSipAddress);
} }
if (mChatRoom == null) { if (mChatRoom == null) {
return null; return null;

View file

@ -95,9 +95,16 @@ public class GroupInfoFragment extends Fragment {
mGroupChatRoomAddress = Factory.instance().createAddress(address); mGroupChatRoomAddress = Factory.instance().createAddress(address);
} }
Address localSipAddress = null;
String localSipUri = getArguments().getString("LocalSipUri");
if (localSipUri != null && localSipUri.length() > 0) {
localSipAddress = Factory.instance().createAddress(localSipUri);
}
mIsAlreadyCreatedGroup = mGroupChatRoomAddress != null; mIsAlreadyCreatedGroup = mGroupChatRoomAddress != null;
if (mIsAlreadyCreatedGroup) { if (mIsAlreadyCreatedGroup) {
mChatRoom = LinphoneManager.getCore().getChatRoom(mGroupChatRoomAddress); mChatRoom =
LinphoneManager.getCore().getChatRoom(mGroupChatRoomAddress, localSipAddress);
} }
if (mChatRoom == null) { if (mChatRoom == null) {