From d8d6017f06724f851437d8715a0b326fc99f0baf Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Thu, 2 Feb 2017 15:04:34 +0100 Subject: [PATCH] - Update linphone - Some work on UI for ZRTP --- src/org/linphone/CallActivity.java | 1 + src/org/linphone/LinphoneActivity.java | 7 ++ src/org/linphone/LinphoneManager.java | 60 ++++++++++++- src/org/linphone/SettingsFragment.java | 1 + src/org/linphone/StatusFragment.java | 13 ++- .../tutorials/TutorialCardDavSync.java | 89 ++++++++++--------- submodules/linphone | 2 +- 7 files changed, 128 insertions(+), 45 deletions(-) diff --git a/src/org/linphone/CallActivity.java b/src/org/linphone/CallActivity.java index bd400f5eb..bb08c8d0e 100644 --- a/src/org/linphone/CallActivity.java +++ b/src/org/linphone/CallActivity.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Timer; import java.util.TimerTask; +import org.linphone.core.CallDirection; import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneCall.State; diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java index 3996d6cf5..9a3b2fe45 100644 --- a/src/org/linphone/LinphoneActivity.java +++ b/src/org/linphone/LinphoneActivity.java @@ -137,6 +137,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick private boolean doNotGoToCallActivity = false; private List sideMenuItems; private boolean callTransfer = false; + private boolean isOnBackground = false; static final boolean isInstanciated() { return instance != null; @@ -1126,6 +1127,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick lc.removeListener(mListener); } callTransfer = false; + isOnBackground = true; super.onPause(); } @@ -1385,6 +1387,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick } } doNotGoToCallActivity = false; + isOnBackground = false; } @Override @@ -1463,6 +1466,10 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick } } + public boolean isOnBackground() { + return isOnBackground; + } + public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (currentFragment == FragmentsAvailable.DIALER diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index dcb781799..2c77c0fd9 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -22,7 +22,6 @@ import static android.media.AudioManager.MODE_RINGTONE; import static android.media.AudioManager.STREAM_RING; import static android.media.AudioManager.STREAM_VOICE_CALL; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -152,6 +151,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag private LinphoneAccountCreator accountCreator; private static List mPendingChatFileMessage; private static LinphoneChatMessage mUploadPendingFileMessage; + private boolean mAreDisplayAlertMessage = false; public String wizardLoginViewDomain = null; @@ -1027,6 +1027,64 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag } } + @Override + public void messageReceivedUnableToDecrypted(LinphoneCore lc, LinphoneChatRoom cr, + LinphoneChatMessage message) { + if (mServiceContext.getResources().getBoolean(R.bool.disable_chat)) { + return; + } + + final LinphoneAddress from = message.getFrom(); + try { + final LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(from); + if (LinphoneActivity.instance().isOnBackground()) { + if (!mServiceContext.getResources().getBoolean(R.bool.disable_chat_message_notification)) { + if (contact != null) { + LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), contact.getFullName() + , getString(R.string.message_cant_be_decrypted_notif)); + } else { + LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), from.getUserName() + , getString(R.string.message_cant_be_decrypted_notif)); + } + } + } else if (!mAreDisplayAlertMessage){ + mAreDisplayAlertMessage = true; + final Dialog dialog = LinphoneActivity.instance().displayDialog( + getString(R.string.message_cant_be_decrypted).replace("%s" + , (contact != null) ? contact.getFullName() : from.getUserName())); + 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.ok)); + + delete.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + LinphoneManager.getInstance().newOutgoingCall(from.asStringUriOnly() + , (contact != null) ? contact.getFullName() : from.getUserName()); + dialog.dismiss(); + LinphoneManager.getInstance().setAreDisplayAlertMessage(false); + } + }); + + cancel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dialog.dismiss(); + LinphoneManager.getInstance().setAreDisplayAlertMessage(false); + } + }); + dialog.show(); + } + } catch (Exception e) { + Log.e(e); + } + } + + public void setAreDisplayAlertMessage(boolean b) { + mAreDisplayAlertMessage = b; + } + public String getLastLcStatusMessage() { return lastLcStatusMessage; } diff --git a/src/org/linphone/SettingsFragment.java b/src/org/linphone/SettingsFragment.java index 2661af288..fac2faf1b 100644 --- a/src/org/linphone/SettingsFragment.java +++ b/src/org/linphone/SettingsFragment.java @@ -958,6 +958,7 @@ public class SettingsFragment extends PreferencesListFragment { } private void setEncryptionZrtp() { + LinphoneUtils.displayErrorAlert(getString(R.string.lime_encryption_enable_zrtp), LinphoneActivity.instance()); mPrefs.setMediaEncryption(MediaEncryption.ZRTP); findPreference(getString(R.string.pref_media_encryption_key)).setSummary(mPrefs.getMediaEncryption().toString()); } diff --git a/src/org/linphone/StatusFragment.java b/src/org/linphone/StatusFragment.java index 041a94dad..c5061440e 100644 --- a/src/org/linphone/StatusFragment.java +++ b/src/org/linphone/StatusFragment.java @@ -18,6 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import org.linphone.assistant.AssistantActivity; +import org.linphone.core.CallDirection; import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneContent; import org.linphone.core.LinphoneCore; @@ -393,9 +394,19 @@ public class StatusFragment extends Fragment { ZRTPdialog.setContentView(R.layout.dialog); ZRTPdialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); ZRTPdialog.getWindow().setBackgroundDrawable(d); + String zrtpToRead, zrtpToListen; + + if (call.getDirection().equals(CallDirection.Incoming)) { + zrtpToRead = call.getAuthenticationToken().substring(0,2); + zrtpToListen = call.getAuthenticationToken().substring(2); + } else { + zrtpToListen = call.getAuthenticationToken().substring(0,2); + zrtpToRead = call.getAuthenticationToken().substring(2); + } TextView customText = (TextView) ZRTPdialog.findViewById(R.id.customText); - String newText = getString(R.string.zrtp_dialog).replace("%s", call.getAuthenticationToken()); + String newText = getString(R.string.zrtp_dialog1).replace("%s", zrtpToRead) + + getString(R.string.zrtp_dialog2).replace("%s", zrtpToListen); customText.setText(newText); Button delete = (Button) ZRTPdialog.findViewById(R.id.delete_button); delete.setText(R.string.accept); diff --git a/src/org/linphone/tutorials/TutorialCardDavSync.java b/src/org/linphone/tutorials/TutorialCardDavSync.java index 9959ff594..99739de3f 100644 --- a/src/org/linphone/tutorials/TutorialCardDavSync.java +++ b/src/org/linphone/tutorials/TutorialCardDavSync.java @@ -48,21 +48,21 @@ public class TutorialCardDavSync extends Activity implements OnClickListener, Li private TextView logs; private Timer timer; - + private LinphoneCore lc; private LinphoneFriendList lfl; - + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tuto_carddav); - + username = (EditText) findViewById(R.id.carddav_username); password = (EditText) findViewById(R.id.carddav_pwd); ha1 = (EditText) findViewById(R.id.carddav_ha1); server = (EditText) findViewById(R.id.carddav_server); logs = (TextView) findViewById(R.id.carddav_events); - + synchronize = (Button) findViewById(R.id.carddav_synchronize); synchronize.setOnClickListener(this); @@ -84,10 +84,10 @@ public class TutorialCardDavSync extends Activity implements OnClickListener, Li }; timer = new Timer("Linphone scheduler"); timer.schedule(lTask, 0, 20); - + lfl = lc.createLinphoneFriendList(); lc.addFriendList(lfl); - + LinphoneFriend lf = lc.createFriendWithAddress("sip:ghislain@sip.linphone.org"); lf.setName("Ghislain"); lfl.addLocalFriend(lf); // This is a local friend, it won't be sent to the CardDAV server and will be removed at the next synchronization @@ -95,7 +95,7 @@ public class TutorialCardDavSync extends Activity implements OnClickListener, Li Log.e(e); } } - + @Override protected void onDestroy() { try { @@ -114,13 +114,13 @@ public class TutorialCardDavSync extends Activity implements OnClickListener, Li String serverDomain = serverUrl.replace("http://", "").replace("https://", "").split("/")[0]; // We just want the domain name LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(username.getText().toString(), null, password.getText().toString(), ha1.getText().toString(), "SabreDAV", serverDomain); lc.addAuthInfo(authInfo); - + lfl.setUri(serverUrl); lfl.setListener(this); synchronize.setEnabled(false); lfl.synchronizeFriendsFromServer(); } - + private void myLog(String msg) { Log.d(msg); logs.setText(logs.getText().toString() + "\r\n" + msg); @@ -132,7 +132,7 @@ public class TutorialCardDavSync extends Activity implements OnClickListener, Li // TODO Auto-generated method stub String msg = "Friend created " + lf.getAddress(); myLog(msg); - + LinphoneFriend[] friends = list.getFriendList(); String msg2 = "There are " + friends.length + (friends.length > 1 ? " friends" : " friend") + " in the list"; myLog(msg2); @@ -144,7 +144,7 @@ public class TutorialCardDavSync extends Activity implements OnClickListener, Li // TODO Auto-generated method stub String msg = "Friend updated " + newFriend.getAddress(); myLog(msg); - + LinphoneFriend[] friends = list.getFriendList(); String msg2 = "There are " + friends.length + (friends.length > 1 ? " friends" : " friend") + " in the list"; myLog(msg2); @@ -156,7 +156,7 @@ public class TutorialCardDavSync extends Activity implements OnClickListener, Li // TODO Auto-generated method stub String msg = "Friend removed " + lf.getAddress(); myLog(msg); - + LinphoneFriend[] friends = list.getFriendList(); String msg2 = "There are " + friends.length + (friends.length > 1 ? " friends" : " friend") + " in the list"; myLog(msg2); @@ -177,7 +177,7 @@ public class TutorialCardDavSync extends Activity implements OnClickListener, Li // TODO Auto-generated method stub String msg = "Friend List added"; myLog(msg); - + LinphoneFriendList[] lists = lc.getFriendLists(); String msg2 = "There are " + lists.length + (lists.length > 1 ? " lists" : " list") + " in the core"; myLog(msg2); @@ -188,7 +188,7 @@ public class TutorialCardDavSync extends Activity implements OnClickListener, Li // TODO Auto-generated method stub String msg = "Friend List removed"; myLog(msg); - + LinphoneFriendList[] lists = lc.getFriendLists(); String msg2 = "There are " + lists.length + (lists.length > 1 ? " lists" : " list") + " in the core"; myLog(msg2); @@ -198,99 +198,99 @@ public class TutorialCardDavSync extends Activity implements OnClickListener, Li public void callStatsUpdated(LinphoneCore lc, LinphoneCall call, LinphoneCallStats stats) { // TODO Auto-generated method stub - + } @Override public void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url) { // TODO Auto-generated method stub - + } @Override public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) { // TODO Auto-generated method stub - + } @Override public void dtmfReceived(LinphoneCore lc, LinphoneCall call, int dtmf) { // TODO Auto-generated method stub - + } @Override public void notifyReceived(LinphoneCore lc, LinphoneCall call, LinphoneAddress from, byte[] event) { // TODO Auto-generated method stub - + } @Override public void transferState(LinphoneCore lc, LinphoneCall call, State new_call_state) { // TODO Auto-generated method stub - + } @Override public void infoReceived(LinphoneCore lc, LinphoneCall call, LinphoneInfoMessage info) { // TODO Auto-generated method stub - + } @Override public void subscriptionStateChanged(LinphoneCore lc, LinphoneEvent ev, SubscriptionState state) { // TODO Auto-generated method stub - + } @Override public void publishStateChanged(LinphoneCore lc, LinphoneEvent ev, PublishState state) { // TODO Auto-generated method stub - + } @Override public void show(LinphoneCore lc) { // TODO Auto-generated method stub - + } @Override public void displayStatus(LinphoneCore lc, String message) { // TODO Auto-generated method stub - + } @Override public void displayMessage(LinphoneCore lc, String message) { // TODO Auto-generated method stub - + } @Override public void displayWarning(LinphoneCore lc, String message) { // TODO Auto-generated method stub - + } @Override public void fileTransferProgressIndication(LinphoneCore lc, LinphoneChatMessage message, LinphoneContent content, int progress) { // TODO Auto-generated method stub - + } @Override public void fileTransferRecv(LinphoneCore lc, LinphoneChatMessage message, LinphoneContent content, byte[] buffer, int size) { // TODO Auto-generated method stub - + } @Override @@ -303,88 +303,93 @@ public class TutorialCardDavSync extends Activity implements OnClickListener, Li @Override public void globalState(LinphoneCore lc, GlobalState state, String message) { // TODO Auto-generated method stub - + } @Override public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, RegistrationState state, String smessage) { // TODO Auto-generated method stub - + } @Override public void configuringStatus(LinphoneCore lc, RemoteProvisioningState state, String message) { // TODO Auto-generated method stub - + } @Override public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) { // TODO Auto-generated method stub - + + } + + @Override + public void messageReceivedUnableToDecrypted(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) { + } @Override public void callState(LinphoneCore lc, LinphoneCall call, State state, String message) { // TODO Auto-generated method stub - + } @Override public void callEncryptionChanged(LinphoneCore lc, LinphoneCall call, boolean encrypted, String authenticationToken) { // TODO Auto-generated method stub - + } @Override public void notifyReceived(LinphoneCore lc, LinphoneEvent ev, String eventName, LinphoneContent content) { // TODO Auto-generated method stub - + } @Override public void isComposingReceived(LinphoneCore lc, LinphoneChatRoom cr) { // TODO Auto-generated method stub - + } @Override public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status, int delay_ms, Object data) { // TODO Auto-generated method stub - + } @Override public void uploadProgressIndication(LinphoneCore lc, int offset, int total) { // TODO Auto-generated method stub - + } @Override public void uploadStateChanged(LinphoneCore lc, LogCollectionUploadState state, String info) { // TODO Auto-generated method stub - + } @Override public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain) { // TODO Auto-generated method stub - + } @Override public void authenticationRequested(LinphoneCore lc, LinphoneAuthInfo authInfo, AuthMethod method) { // TODO Auto-generated method stub - + } } diff --git a/submodules/linphone b/submodules/linphone index 1cf4eda4a..3342ccf4a 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 1cf4eda4aac0fdd1fdac150f6e0592368bf93459 +Subproject commit 3342ccf4abb1f3bd95053ca82d9b01508704bbc2