Added use of findOneToOneChatRoom with encryption
This commit is contained in:
parent
3bb2e3ecdb
commit
32378c3c99
9 changed files with 54 additions and 47 deletions
|
@ -33,11 +33,11 @@ dependencies {
|
||||||
androidTestCompile group: 'junit', name: 'junit', version: '+'
|
androidTestCompile group: 'junit', name: 'junit', version: '+'
|
||||||
androidTestCompile group: 'com.jayway.android.robotium', name: 'robotium', version: '+'
|
androidTestCompile group: 'com.jayway.android.robotium', name: 'robotium', version: '+'
|
||||||
androidTestCompile fileTree(dir: 'libs', include: 'android-junit-report*.jar')
|
androidTestCompile fileTree(dir: 'libs', include: 'android-junit-report*.jar')
|
||||||
compile 'org.apache.commons:commons-compress:1.16.1'
|
implementation 'org.apache.commons:commons-compress:1.16.1'
|
||||||
compile group: 'junit', name: 'junit', version: '+'
|
implementation group: 'junit', name: 'junit', version: '+'
|
||||||
compile group: 'com.jayway.android.robotium', name: 'robotium-solo', version: '+'
|
implementation group: 'com.jayway.android.robotium', name: 'robotium-solo', version: '+'
|
||||||
compile fileTree(dir: 'libs', include: 'android-junit-report*.jar')
|
implementation fileTree(dir: 'libs', include: 'android-junit-report*.jar')
|
||||||
compile project(":liblinphone-sdk")
|
implementation project(":liblinphone-sdk")
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/pendingImageForUpload"
|
android:id="@+id/pendingImageForUpload"
|
||||||
android:layout_width="match_parent"
|
android:adjustViewBounds="true"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
@ -15,7 +16,7 @@
|
||||||
android:src="@drawable/clean_field"
|
android:src="@drawable/clean_field"
|
||||||
android:layout_width="20dp"
|
android:layout_width="20dp"
|
||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignRight="@id/pendingImageForUpload"
|
||||||
android:layout_alignParentTop="true"/>
|
android:layout_alignTop="@id/pendingImageForUpload"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
|
@ -469,14 +469,28 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
boolean createEncryptedChatRoom = mSecurityToggle.isChecked();
|
boolean createEncryptedChatRoom = mSecurityToggle.isChecked();
|
||||||
if (lpc == null || lpc.getConferenceFactoryUri() == null || mCreateGroupChatRoom == false) {
|
if (lpc == null || lpc.getConferenceFactoryUri() == null || mCreateGroupChatRoom == false) {
|
||||||
if (createEncryptedChatRoom && lpc != null && lpc.getConferenceFactoryUri() != null) {
|
if (createEncryptedChatRoom && lpc != null && lpc.getConferenceFactoryUri() != null) {
|
||||||
mChatRoom = lc.createClientGroupChatRoom(getString(R.string.dummy_group_chat_subject), !createEncryptedChatRoom, createEncryptedChatRoom);
|
mChatRoom = lc.findOneToOneChatRoom(lpc.getIdentityAddress(), ca.getAddress(), true);
|
||||||
mChatRoom.addListener(mChatRoomCreationListener);
|
if (mChatRoom != null) {
|
||||||
Address participants[] = new Address[1];
|
LinphoneActivity.instance().goToChat(mChatRoom.getPeerAddress().asStringUriOnly(), mShareInfos, mChatRoom.getLocalAddress().asString());
|
||||||
participants[0] = ca.getAddress();
|
} else {
|
||||||
mChatRoom.addParticipants(participants);
|
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 {
|
} else {
|
||||||
ChatRoom chatRoom = lc.getChatRoom(ca.getAddress());
|
if (lpc != null && lpc.getConferenceFactoryUri() != null && !LinphonePreferences.instance().useBasicChatRoomFor1To1()) {
|
||||||
LinphoneActivity.instance().goToChat(chatRoom.getPeerAddress().asStringUriOnly(), mShareInfos, chatRoom.getLocalAddress().asString());
|
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 {
|
} else {
|
||||||
addOrRemoveContactFromSelection(ca);
|
addOrRemoveContactFromSelection(ca);
|
||||||
|
|
|
@ -39,6 +39,9 @@ import org.linphone.core.Address;
|
||||||
import org.linphone.core.ChatRoom;
|
import org.linphone.core.ChatRoom;
|
||||||
import org.linphone.core.ChatRoomCapabilities;
|
import org.linphone.core.ChatRoomCapabilities;
|
||||||
import org.linphone.core.Core;
|
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 org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -53,6 +56,7 @@ public class DevicesFragment extends Fragment {
|
||||||
private String mRoomUri;
|
private String mRoomUri;
|
||||||
private Address mRoomAddr;
|
private Address mRoomAddr;
|
||||||
private ChatRoom mRoom;
|
private ChatRoom mRoom;
|
||||||
|
private boolean mOnlyDisplayChilds;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
|
@ -67,16 +71,26 @@ public class DevicesFragment extends Fragment {
|
||||||
mInflater = inflater;
|
mInflater = inflater;
|
||||||
View view = mInflater.inflate(R.layout.chat_devices, container, false);
|
View view = mInflater.inflate(R.layout.chat_devices, container, false);
|
||||||
|
|
||||||
|
mOnlyDisplayChilds = false;
|
||||||
|
|
||||||
mExpandableList = view.findViewById(R.id.devices_list);
|
mExpandableList = view.findViewById(R.id.devices_list);
|
||||||
mExpandableList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
|
mExpandableList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onChildClick(ExpandableListView expandableListView, View view, int groupPosition, int childPosition, long l) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mExpandableList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
|
mExpandableList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onGroupClick(ExpandableListView expandableListView, View view, int groupPosition, long l) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -109,13 +123,7 @@ public class DevicesFragment extends Fragment {
|
||||||
|
|
||||||
private void initChatRoom() {
|
private void initChatRoom() {
|
||||||
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
Address proxyConfigContact = core.getDefaultProxyConfig().getContact();
|
mRoom = core.getChatRoomFromUri(mRoomAddr.asStringUriOnly());
|
||||||
if (proxyConfigContact != null) {
|
|
||||||
mRoom = core.findOneToOneChatRoom(proxyConfigContact, mRoomAddr);
|
|
||||||
}
|
|
||||||
if (mRoom == null) {
|
|
||||||
mRoom = core.getChatRoomFromUri(mRoomAddr.asStringUriOnly());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initHeader() {
|
private void initHeader() {
|
||||||
|
@ -144,10 +152,9 @@ public class DevicesFragment extends Fragment {
|
||||||
initChatRoom();
|
initChatRoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean onlyDisplayChilds = mRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt());
|
|
||||||
|
|
||||||
if (mRoom != null && mRoom.getNbParticipants() > 0) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -580,18 +580,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Address proxyConfigContact = mLocalIdentityAddress;
|
mChatRoom = core.getChatRoomFromUri(mRemoteSipAddress.asStringUriOnly());
|
||||||
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.addListener(this);
|
||||||
mChatRoom.markAsRead();
|
mChatRoom.markAsRead();
|
||||||
LinphoneManager.getInstance().updateUnreadCountForChatRoom(mChatRoom, 0);
|
LinphoneManager.getInstance().updateUnreadCountForChatRoom(mChatRoom, 0);
|
||||||
|
|
|
@ -33,6 +33,7 @@ import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
|
import org.linphone.LinphonePreferences;
|
||||||
import org.linphone.LinphoneUtils;
|
import org.linphone.LinphoneUtils;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.activities.LinphoneActivity;
|
import org.linphone.activities.LinphoneActivity;
|
||||||
|
@ -70,14 +71,9 @@ public class ImdnFragment extends Fragment {
|
||||||
mRoomAddr = LinphoneManager.getLc().createAddress(mRoomUri);
|
mRoomAddr = LinphoneManager.getLc().createAddress(mRoomUri);
|
||||||
mMessageId = getArguments().getString("MessageId");
|
mMessageId = getArguments().getString("MessageId");
|
||||||
}
|
}
|
||||||
|
|
||||||
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
Address proxyConfigContact = core.getDefaultProxyConfig().getContact();
|
mRoom = core.getChatRoomFromUri(mRoomAddr.asStringUriOnly());
|
||||||
if (proxyConfigContact != null) {
|
|
||||||
mRoom = core.findOneToOneChatRoom(proxyConfigContact, mRoomAddr);
|
|
||||||
}
|
|
||||||
if (mRoom == null) {
|
|
||||||
mRoom = core.getChatRoomFromUri(mRoomAddr.asStringUriOnly());
|
|
||||||
}
|
|
||||||
|
|
||||||
mInflater = inflater;
|
mInflater = inflater;
|
||||||
mContainer = container;
|
mContainer = container;
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
||||||
Address participant = Factory.instance().createAddress(tag);
|
Address participant = Factory.instance().createAddress(tag);
|
||||||
ProxyConfig defaultProxyConfig = lc.getDefaultProxyConfig();
|
ProxyConfig defaultProxyConfig = lc.getDefaultProxyConfig();
|
||||||
if (defaultProxyConfig != null) {
|
if (defaultProxyConfig != null) {
|
||||||
ChatRoom room = lc.findOneToOneChatRoom(defaultProxyConfig.getContact(), participant);
|
ChatRoom room = lc.findOneToOneChatRoom(defaultProxyConfig.getContact(), participant, false);
|
||||||
if (room != null) {
|
if (room != null) {
|
||||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly(), null, room.getLocalAddress().asString());
|
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly(), null, room.getLocalAddress().asString());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -197,7 +197,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
||||||
} else if (id == R.id.chat) {
|
} else if (id == R.id.chat) {
|
||||||
Core lc = LinphoneManager.getLc();
|
Core lc = LinphoneManager.getLc();
|
||||||
Address participant = Factory.instance().createAddress(sipUri);
|
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) {
|
if (room != null) {
|
||||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly(), null, room.getLocalAddress().asString());
|
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly(), null, room.getLocalAddress().asString());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9b9dcbbc5ec45c637dbbade15fdd64cf56bbd758
|
Subproject commit fc5cc0c22b7cab831052a17afc699376c64c85bf
|
Loading…
Reference in a new issue