Added use of findOneToOneChatRoom with encryption

This commit is contained in:
Sylvain Berfini 2018-11-02 11:34:50 +01:00
parent 3bb2e3ecdb
commit 32378c3c99
9 changed files with 54 additions and 47 deletions

View file

@ -33,11 +33,11 @@ dependencies {
androidTestCompile group: 'junit', name: 'junit', version: '+'
androidTestCompile group: 'com.jayway.android.robotium', name: 'robotium', version: '+'
androidTestCompile fileTree(dir: 'libs', include: 'android-junit-report*.jar')
compile 'org.apache.commons:commons-compress:1.16.1'
compile group: 'junit', name: 'junit', version: '+'
compile group: 'com.jayway.android.robotium', name: 'robotium-solo', version: '+'
compile fileTree(dir: 'libs', include: 'android-junit-report*.jar')
compile project(":liblinphone-sdk")
implementation 'org.apache.commons:commons-compress:1.16.1'
implementation group: 'junit', name: 'junit', version: '+'
implementation group: 'com.jayway.android.robotium', name: 'robotium-solo', version: '+'
implementation fileTree(dir: 'libs', include: 'android-junit-report*.jar')
implementation project(":liblinphone-sdk")
}
android {

View file

@ -7,7 +7,8 @@
<ImageView
android:id="@+id/pendingImageForUpload"
android:layout_width="match_parent"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<ImageView
@ -15,7 +16,7 @@
android:src="@drawable/clean_field"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"/>
android:layout_alignRight="@id/pendingImageForUpload"
android:layout_alignTop="@id/pendingImageForUpload"/>
</RelativeLayout>

View file

@ -469,15 +469,29 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
boolean createEncryptedChatRoom = mSecurityToggle.isChecked();
if (lpc == null || lpc.getConferenceFactoryUri() == null || mCreateGroupChatRoom == false) {
if (createEncryptedChatRoom && lpc != null && lpc.getConferenceFactoryUri() != null) {
mChatRoom = lc.findOneToOneChatRoom(lpc.getIdentityAddress(), ca.getAddress(), true);
if (mChatRoom != null) {
LinphoneActivity.instance().goToChat(mChatRoom.getPeerAddress().asStringUriOnly(), mShareInfos, mChatRoom.getLocalAddress().asString());
} else {
mChatRoom = lc.createClientGroupChatRoom(getString(R.string.dummy_group_chat_subject), !createEncryptedChatRoom, createEncryptedChatRoom);
mChatRoom.addListener(mChatRoomCreationListener);
Address participants[] = new Address[1];
participants[0] = ca.getAddress();
mChatRoom.addParticipants(participants);
}
} else {
if (lpc != null && lpc.getConferenceFactoryUri() != null && !LinphonePreferences.instance().useBasicChatRoomFor1To1()) {
mWaitLayout.setVisibility(View.VISIBLE);
mChatRoom = lc.createClientGroupChatRoom(getString(R.string.dummy_group_chat_subject), true);
mChatRoom.addListener(mChatRoomCreationListener);
Address participants[] = new Address[1];
participants[0] = ca.getAddress();
mChatRoom.addParticipants(participants);
} else {
ChatRoom chatRoom = lc.getChatRoom(ca.getAddress());
LinphoneActivity.instance().goToChat(chatRoom.getPeerAddress().asStringUriOnly(), mShareInfos, chatRoom.getLocalAddress().asString());
}
}
} else {
addOrRemoveContactFromSelection(ca);
}

View file

@ -39,6 +39,9 @@ import org.linphone.core.Address;
import org.linphone.core.ChatRoom;
import org.linphone.core.ChatRoomCapabilities;
import org.linphone.core.Core;
import org.linphone.core.Factory;
import org.linphone.core.Participant;
import org.linphone.core.ParticipantDevice;
import org.linphone.mediastream.Log;
import java.util.Arrays;
@ -53,6 +56,7 @@ public class DevicesFragment extends Fragment {
private String mRoomUri;
private Address mRoomAddr;
private ChatRoom mRoom;
private boolean mOnlyDisplayChilds;
@Nullable
@Override
@ -67,16 +71,26 @@ public class DevicesFragment extends Fragment {
mInflater = inflater;
View view = mInflater.inflate(R.layout.chat_devices, container, false);
mOnlyDisplayChilds = false;
mExpandableList = view.findViewById(R.id.devices_list);
mExpandableList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView expandableListView, View view, int groupPosition, int childPosition, long l) {
ParticipantDevice device = (ParticipantDevice) mAdapter.getChild(groupPosition, childPosition);
LinphoneManager.getLc().inviteAddress(device.getAddress());
return false;
}
});
mExpandableList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView expandableListView, View view, int groupPosition, long l) {
if (mOnlyDisplayChilds) {
// in this case groups are childs, so call on click
ParticipantDevice device = (ParticipantDevice) mAdapter.getGroup(groupPosition);
LinphoneManager.getLc().inviteAddress(device.getAddress());
return true;
}
return false;
}
});
@ -109,14 +123,8 @@ public class DevicesFragment extends Fragment {
private void initChatRoom() {
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
Address proxyConfigContact = core.getDefaultProxyConfig().getContact();
if (proxyConfigContact != null) {
mRoom = core.findOneToOneChatRoom(proxyConfigContact, mRoomAddr);
}
if (mRoom == null) {
mRoom = core.getChatRoomFromUri(mRoomAddr.asStringUriOnly());
}
}
private void initHeader() {
if (mRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())) {
@ -144,10 +152,9 @@ public class DevicesFragment extends Fragment {
initChatRoom();
}
boolean onlyDisplayChilds = mRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt());
if (mRoom != null && mRoom.getNbParticipants() > 0) {
mAdapter.updateListItems(Arrays.asList(mRoom.getParticipants()), onlyDisplayChilds);
mOnlyDisplayChilds = mRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt());
mAdapter.updateListItems(Arrays.asList(mRoom.getParticipants()), mOnlyDisplayChilds);
}
}
}

View file

@ -580,18 +580,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
return;
}
Address proxyConfigContact = mLocalIdentityAddress;
if (proxyConfigContact == null) {
proxyConfigContact = core.getDefaultProxyConfig() != null ? core.getDefaultProxyConfig().getContact() : null;
}
if (proxyConfigContact != null) {
mChatRoom = core.findOneToOneChatRoom(proxyConfigContact, mRemoteSipAddress);
}
if (mChatRoom == null) {
mChatRoom = core.getChatRoomFromUri(mRemoteSipAddress.asStringUriOnly());
}
mChatRoom.addListener(this);
mChatRoom.markAsRead();
LinphoneManager.getInstance().updateUnreadCountForChatRoom(mChatRoom, 0);

View file

@ -33,6 +33,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import org.linphone.LinphoneManager;
import org.linphone.LinphonePreferences;
import org.linphone.LinphoneUtils;
import org.linphone.R;
import org.linphone.activities.LinphoneActivity;
@ -70,14 +71,9 @@ public class ImdnFragment extends Fragment {
mRoomAddr = LinphoneManager.getLc().createAddress(mRoomUri);
mMessageId = getArguments().getString("MessageId");
}
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
Address proxyConfigContact = core.getDefaultProxyConfig().getContact();
if (proxyConfigContact != null) {
mRoom = core.findOneToOneChatRoom(proxyConfigContact, mRoomAddr);
}
if (mRoom == null) {
mRoom = core.getChatRoomFromUri(mRoomAddr.asStringUriOnly());
}
mInflater = inflater;
mContainer = container;

View file

@ -79,7 +79,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
Address participant = Factory.instance().createAddress(tag);
ProxyConfig defaultProxyConfig = lc.getDefaultProxyConfig();
if (defaultProxyConfig != null) {
ChatRoom room = lc.findOneToOneChatRoom(defaultProxyConfig.getContact(), participant);
ChatRoom room = lc.findOneToOneChatRoom(defaultProxyConfig.getContact(), participant, false);
if (room != null) {
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly(), null, room.getLocalAddress().asString());
} else {

View file

@ -197,7 +197,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
} else if (id == R.id.chat) {
Core lc = LinphoneManager.getLc();
Address participant = Factory.instance().createAddress(sipUri);
ChatRoom room = lc.findOneToOneChatRoom(lc.getDefaultProxyConfig().getContact(), participant);
ChatRoom room = lc.findOneToOneChatRoom(lc.getDefaultProxyConfig().getContact(), participant, false);
if (room != null) {
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly(), null, room.getLocalAddress().asString());
} else {

@ -1 +1 @@
Subproject commit 9b9dcbbc5ec45c637dbbade15fdd64cf56bbd758
Subproject commit fc5cc0c22b7cab831052a17afc699376c64c85bf