Fixed crash if trying to create a chat room from contact or history without proxy config
This commit is contained in:
parent
807c279e88
commit
b0407645e7
3 changed files with 70 additions and 36 deletions
|
@ -88,7 +88,7 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
versionCode 4211
|
||||
versionCode 4212
|
||||
versionName "${project.version}"
|
||||
applicationId getPackageName()
|
||||
multiDexEnabled true
|
||||
|
|
|
@ -364,6 +364,8 @@ public class ContactDetailsFragment extends Fragment implements ContactsUpdatedL
|
|||
|
||||
private void goToChat(String tag, boolean isSecured) {
|
||||
Core core = LinphoneManager.getCore();
|
||||
if (core == null) return;
|
||||
|
||||
Address participant = Factory.instance().createAddress(tag);
|
||||
ProxyConfig defaultProxyConfig = core.getDefaultProxyConfig();
|
||||
|
||||
|
@ -409,6 +411,18 @@ public class ContactDetailsFragment extends Fragment implements ContactsUpdatedL
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isSecured) {
|
||||
Log.e(
|
||||
"[Contact Details Fragment] Can't create a secured chat room without proxy config");
|
||||
return;
|
||||
}
|
||||
|
||||
ChatRoom room = core.getChatRoom(participant);
|
||||
if (room != null) {
|
||||
((ContactsActivity) getActivity())
|
||||
.showChatRoom(room.getLocalAddress(), room.getPeerAddress());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ public class HistoryDetailFragment extends Fragment {
|
|||
mWaitLayout.setVisibility(View.GONE);
|
||||
((HistoryActivity) getActivity()).displayChatRoomError();
|
||||
Log.e(
|
||||
"Group mChat room for address "
|
||||
"[History Detail Fragment] Group mChat room for address "
|
||||
+ cr.getPeerAddress()
|
||||
+ " has failed !");
|
||||
}
|
||||
|
@ -257,24 +257,29 @@ public class HistoryDetailFragment extends Fragment {
|
|||
|
||||
private void goToChat(boolean isSecured) {
|
||||
Core core = LinphoneManager.getCore();
|
||||
if (core == null) return;
|
||||
|
||||
Address participant = Factory.instance().createAddress(mSipUri);
|
||||
ProxyConfig defaultProxyConfig = core.getDefaultProxyConfig();
|
||||
|
||||
if (defaultProxyConfig != null) {
|
||||
ChatRoom room =
|
||||
core.findOneToOneChatRoom(
|
||||
core.getDefaultProxyConfig().getContact(), participant, isSecured);
|
||||
defaultProxyConfig.getContact(), participant, isSecured);
|
||||
if (room != null) {
|
||||
((HistoryActivity) getActivity())
|
||||
.showChatRoom(room.getLocalAddress(), room.getPeerAddress());
|
||||
} else {
|
||||
ProxyConfig lpc = core.getDefaultProxyConfig();
|
||||
if (lpc != null
|
||||
&& lpc.getConferenceFactoryUri() != null
|
||||
&& (isSecured || !LinphonePreferences.instance().useBasicChatRoomFor1To1())) {
|
||||
if (defaultProxyConfig.getConferenceFactoryUri() != null
|
||||
&& (isSecured
|
||||
|| !LinphonePreferences.instance().useBasicChatRoomFor1To1())) {
|
||||
mWaitLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
ChatRoomParams params = core.createDefaultChatRoomParams();
|
||||
params.enableEncryption(isSecured);
|
||||
params.enableGroup(false);
|
||||
// We don't want a basic chat room
|
||||
// We don't want a basic chat room,
|
||||
// so if isSecured is false we have to set this manually
|
||||
params.setBackend(ChatRoomBackend.FlexisipChat);
|
||||
|
||||
Address[] participants = new Address[1];
|
||||
|
@ -282,7 +287,9 @@ public class HistoryDetailFragment extends Fragment {
|
|||
|
||||
mChatRoom =
|
||||
core.createChatRoom(
|
||||
params, getString(R.string.dummy_group_chat_subject), participants);
|
||||
params,
|
||||
getString(R.string.dummy_group_chat_subject),
|
||||
participants);
|
||||
if (mChatRoom != null) {
|
||||
mChatRoom.addListener(mChatRoomCreationListener);
|
||||
} else {
|
||||
|
@ -297,5 +304,18 @@ public class HistoryDetailFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isSecured) {
|
||||
Log.e(
|
||||
"[History Detail Fragment] Can't create a secured chat room without proxy config");
|
||||
return;
|
||||
}
|
||||
|
||||
ChatRoom room = core.getChatRoom(participant);
|
||||
if (room != null) {
|
||||
((HistoryActivity) getActivity())
|
||||
.showChatRoom(room.getLocalAddress(), room.getPeerAddress());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue