Added start secured chat from contact info

This commit is contained in:
Sylvain Berfini 2018-11-09 14:07:34 +01:00
parent a6beb9df07
commit 4b3a918e7c
2 changed files with 47 additions and 10 deletions

View file

@ -79,9 +79,7 @@
android:contentDescription="@string/content_description_call"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_margin="10dp"
android:adjustViewBounds="true"
android:layout_centerInParent="true"/>
android:layout_margin="10dp"/>
<ImageView
android:id="@+id/contact_chat"
@ -90,9 +88,32 @@
android:contentDescription="@string/content_description_chat"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_margin="10dp"
android:adjustViewBounds="true"
android:layout_centerInParent="true" />
android:layout_margin="10dp" />
<RelativeLayout
android:id="@+id/contact_chat_secured"
android:layout_width="65dp"
android:layout_height="60dp"
android:layout_margin="10dp">
<ImageView
android:src="@drawable/chat_start_default"
android:background="@drawable/round_orange_button_background"
android:contentDescription="@string/content_description_chat"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"/>
<ImageView
android:id="@+id/security_level"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/security_toogle_icon_green"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>

View file

@ -78,16 +78,20 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
Core lc = LinphoneManager.getLc();
Address participant = Factory.instance().createAddress(tag);
ProxyConfig defaultProxyConfig = lc.getDefaultProxyConfig();
boolean isSecured = v.getId() == R.id.contact_chat_secured;
if (defaultProxyConfig != null) {
ChatRoom room = lc.findOneToOneChatRoom(defaultProxyConfig.getContact(), participant, false);
ChatRoom room = lc.findOneToOneChatRoom(defaultProxyConfig.getContact(), participant, isSecured);
if (room != null) {
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly(), null, room.getLocalAddress().asString());
} else {
if (defaultProxyConfig.getConferenceFactoryUri() != null && !LinphonePreferences.instance().useBasicChatRoomFor1To1()) {
if (defaultProxyConfig.getConferenceFactoryUri() != null && (isSecured || !LinphonePreferences.instance().useBasicChatRoomFor1To1())) {
mWaitLayout.setVisibility(View.VISIBLE);
mChatRoom = lc.createClientGroupChatRoom(getString(R.string.dummy_group_chat_subject), true);
mChatRoom = lc.createClientGroupChatRoom(getString(R.string.dummy_group_chat_subject), !isSecured, isSecured);
mChatRoom.addListener(mChatRoomCreationListener);
mChatRoom.addParticipant(participant);
Address participants[] = new Address[1];
participants[0] = participant;
mChatRoom.addParticipants(participants);
} else {
room = lc.getChatRoom(participant);
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly(), null, room.getLocalAddress().asString());
@ -243,14 +247,26 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
}
v.findViewById(R.id.contact_chat).setOnClickListener(chatListener);
v.findViewById(R.id.contact_chat_secured).setOnClickListener(chatListener);
if (contactAddress != null) {
v.findViewById(R.id.contact_chat).setTag(contactAddress);
v.findViewById(R.id.contact_chat_secured).setTag(contactAddress);
} else {
v.findViewById(R.id.contact_chat).setTag(value);
v.findViewById(R.id.contact_chat_secured).setTag(value);
}
if (v.findViewById(R.id.friendLinphone).getVisibility() == View.VISIBLE /* TODO Does contact have LIME capability ?*/
&& lpc.getConferenceFactoryUri() != null) {
v.findViewById(R.id.contact_chat_secured).setVisibility(View.VISIBLE);
} else {
v.findViewById(R.id.contact_chat_secured).setVisibility(View.GONE);
}
if (getResources().getBoolean(R.bool.disable_chat)) {
v.findViewById(R.id.contact_chat).setVisibility(View.GONE);
v.findViewById(R.id.contact_chat_secured).setVisibility(View.GONE);
}
if (!skip) {