From 4b3a918e7c382afb22941d1b234f8d3e322e8a3d Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 9 Nov 2018 14:07:34 +0100 Subject: [PATCH] Added start secured chat from contact info --- res/layout/contact_control_row.xml | 33 +++++++++++++++---- .../contacts/ContactDetailsFragment.java | 24 +++++++++++--- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/res/layout/contact_control_row.xml b/res/layout/contact_control_row.xml index e29168062..e52bc63b2 100644 --- a/res/layout/contact_control_row.xml +++ b/res/layout/contact_control_row.xml @@ -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"/> + android:layout_margin="10dp" /> + + + + + + + + diff --git a/src/android/org/linphone/contacts/ContactDetailsFragment.java b/src/android/org/linphone/contacts/ContactDetailsFragment.java index b5a705820..c5188a2e7 100644 --- a/src/android/org/linphone/contacts/ContactDetailsFragment.java +++ b/src/android/org/linphone/contacts/ContactDetailsFragment.java @@ -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) {