Add Lime integration
This commit is contained in:
parent
885cc3c59f
commit
8df31138f3
5 changed files with 62 additions and 4 deletions
|
@ -12,6 +12,9 @@ Group changes to describe their impact on the project, as follows:
|
|||
|
||||
## [Incomming]
|
||||
|
||||
### Added
|
||||
- Lime integration
|
||||
|
||||
### Fixed
|
||||
- Rotation after screen locking
|
||||
|
||||
|
|
|
@ -186,6 +186,7 @@
|
|||
<string name="image_saved">Image saved</string>
|
||||
<string name="image_not_saved">Error, image not saved</string>
|
||||
<string name="wait">Please wait...</string>
|
||||
<string name="lime_not_verified">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.</string>
|
||||
<string name="processing_image">Processing image, can take up to a few seconds depending on the size of the file</string>
|
||||
|
||||
<!-- Status Bar -->
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7ab1893afb60756ad3bd02f65b352f2a00de29ab
|
||||
Subproject commit 2c5d691045bc8cab1c177c6396b5843da1254d41
|
Loading…
Reference in a new issue