diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c1882d20..89b97e415 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ Group changes to describe their impact on the project, as follows: ## [Incomming] +### Added +- Lime integration + ### Fixed - Rotation after screen locking diff --git a/res/values/strings.xml b/res/values/strings.xml index 60a9fe1e4..daf5510e4 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -186,6 +186,7 @@ Image saved Error, image not saved Please wait... + You are trying to send a message using LIME to a contact not verified by ZRTP.\nPlease call this contact and verify his ZRTP key before sending your messages. Processing image, can take up to a few seconds depending on the size of the file diff --git a/src/org/linphone/ChatFragment.java b/src/org/linphone/ChatFragment.java index 5e0bc96a3..c0de6e861 100644 --- a/src/org/linphone/ChatFragment.java +++ b/src/org/linphone/ChatFragment.java @@ -42,6 +42,7 @@ import org.linphone.core.LinphoneCore; import org.linphone.core.LinphoneCoreFactory; import org.linphone.core.LinphoneCoreListenerBase; import org.linphone.mediastream.Log; +import org.linphone.ui.AddressText; import android.Manifest; import android.annotation.SuppressLint; @@ -205,6 +206,11 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC sendImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + if (LinphoneManager.getLc().getLimeEncryption() == LinphoneCore.LinphoneLimeState.Mandatory + && (chatRoom == null || !chatRoom.islimeAvailable())){ + askingForLimeCall(); + return; + } pickImage(); LinphoneActivity.instance().checkAndRequestPermissionsToSendImage(); } @@ -350,7 +356,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC try { lAddress = lc.interpretUrl(sipUri); } catch (Exception e) { - //TODO Error popup and quit chat + //TODO Error popup + LinphoneActivity.instance().goToDialerFragment(); } if (lAddress != null) { @@ -633,8 +640,20 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC } private void sendTextMessage() { - sendTextMessage(message.getText().toString()); - message.setText(""); + if (!LinphoneManager.isInstanciated() || LinphoneManager.getLc() == null) + return; + LinphoneCore.LinphoneLimeState state = LinphoneManager.getLc().getLimeEncryption(); + + if ((state == LinphoneCore.LinphoneLimeState.Disabled + || state == LinphoneCore.LinphoneLimeState.Preferred) + || (state == LinphoneCore.LinphoneLimeState.Mandatory + && chatRoom != null && chatRoom.islimeAvailable())){ + sendTextMessage(message.getText().toString()); + message.setText(""); + return; + } + + askingForLimeCall(); } private void sendTextMessage(String messageToSend) { @@ -699,6 +718,38 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC } } + private void askingForLimeCall() { + final Dialog dialog = LinphoneActivity.instance().displayDialog(getString(R.string.lime_not_verified)); + Button delete = (Button) dialog.findViewById(R.id.delete_button); + delete.setText(getString(R.string.call)); + Button cancel = (Button) dialog.findViewById(R.id.cancel); + cancel.setText(getString(R.string.no)); + + delete.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + //Start new conversation in fast chat + if(newChatConversation && chatRoom == null) { + String address = searchContactField.getText().toString().toLowerCase(Locale.getDefault()); + if (address != null && !address.equals("")) { + initChatRoom(address); + } + } + LinphoneManager.getInstance().newOutgoingCall(chatRoom.getPeerAddress().asStringUriOnly() + , chatRoom.getPeerAddress().getDisplayName()); + dialog.dismiss(); + } + }); + + cancel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dialog.dismiss(); + } + }); + dialog.show(); + } + private LinphoneChatMessage getMessageForId(int id) { if (adapter == null) return null; for (int i = 0; i < adapter.getCount(); i++) { @@ -1125,6 +1176,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC if (status == LinphoneChatMessage.State.NotDelivered) { holder.messageStatus.setVisibility(View.VISIBLE); holder.messageStatus.setImageResource(R.drawable.chat_message_not_delivered); + } else if (status == LinphoneChatMessage.State.InProgress) { holder.messageSendingInProgress.setVisibility(View.VISIBLE); } diff --git a/src/org/linphone/SettingsFragment.java b/src/org/linphone/SettingsFragment.java index 5ef7abf75..166010922 100644 --- a/src/org/linphone/SettingsFragment.java +++ b/src/org/linphone/SettingsFragment.java @@ -988,8 +988,10 @@ public class SettingsFragment extends PreferencesListFragment { if (lime == LinphoneLimeState.Disabled) { preference.setSummary(getString(R.string.lime_encryption_entry_disabled)); } else if (lime == LinphoneLimeState.Mandatory) { + mPrefs.setMediaEncryption(MediaEncryption.ZRTP); preference.setSummary(getString(R.string.lime_encryption_entry_mandatory)); } else if (lime == LinphoneLimeState.Preferred) { + mPrefs.setMediaEncryption(MediaEncryption.ZRTP); preference.setSummary(getString(R.string.lime_encryption_entry_preferred)); } diff --git a/submodules/linphone b/submodules/linphone index 7ab1893af..2c5d69104 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 7ab1893afb60756ad3bd02f65b352f2a00de29ab +Subproject commit 2c5d691045bc8cab1c177c6396b5843da1254d41