From d38965b693e35db05fcdad0a47b97196a509385c Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 22 Jun 2012 11:54:12 +0200 Subject: [PATCH] Display encryption icon during call --- src/org/linphone/InCallActivity.java | 2 +- src/org/linphone/StatusFragment.java | 24 +++++++++++++++++++++--- src/org/linphone/VideoCallFragment.java | 1 - 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/org/linphone/InCallActivity.java b/src/org/linphone/InCallActivity.java index 40f1f0e1f..36d4ab31e 100644 --- a/src/org/linphone/InCallActivity.java +++ b/src/org/linphone/InCallActivity.java @@ -381,7 +381,7 @@ public class InCallActivity extends FragmentActivity implements public void onCallEncryptionChanged(LinphoneCall call, boolean encrypted, String authenticationToken) { if (status != null) { - status.setEncryption(true); + status.refreshEncryptionIcon(); } } diff --git a/src/org/linphone/StatusFragment.java b/src/org/linphone/StatusFragment.java index ff88c3e30..9936b7e4e 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ import org.linphone.core.LinphoneCall; +import org.linphone.core.LinphoneCore.MediaEncryption; import org.linphone.core.LinphoneCore.RegistrationState; import android.app.Activity; @@ -66,7 +67,6 @@ public class StatusFragment extends Fragment { @Override public void onAttach(Activity activity) { super.onAttach(activity); - isAttached = true; if (activity instanceof LinphoneActivity) { ((LinphoneActivity) activity).updateStatusFragment(this); @@ -75,6 +75,8 @@ public class StatusFragment extends Fragment { ((InCallActivity) activity).updateStatusFragment(this); isInCall = true; } + + isAttached = true; } @Override @@ -161,6 +163,11 @@ public class StatusFragment extends Fragment { if (isInCall) { startCallQuality(); + refreshEncryptionIcon(); + + // We are obviously connected + statusLed.setImageResource(R.drawable.connected_led); + statusText.setText(getString(R.string.status_connected)); } } @@ -174,9 +181,20 @@ public class StatusFragment extends Fragment { } } - public void setEncryption(boolean b) { + public void refreshEncryptionIcon() { if (encryption != null) { - //TODO + LinphoneCall call = LinphoneManager.getLc().getCurrentCall(); + MediaEncryption mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption(); + + encryption.setVisibility(View.VISIBLE); + + if (mediaEncryption == MediaEncryption.SRTP || (mediaEncryption == MediaEncryption.ZRTP && call.isAuthenticationTokenVerified())) { + encryption.setImageResource(R.drawable.secure); + } else if (mediaEncryption == MediaEncryption.ZRTP && !call.isAuthenticationTokenVerified()) { + encryption.setImageResource(R.drawable.maybe_secure); + } else { + encryption.setImageResource(R.drawable.not_secure); + } } } } diff --git a/src/org/linphone/VideoCallFragment.java b/src/org/linphone/VideoCallFragment.java index e4d9f1231..cbbd71814 100644 --- a/src/org/linphone/VideoCallFragment.java +++ b/src/org/linphone/VideoCallFragment.java @@ -36,7 +36,6 @@ import android.view.View; import android.view.View.OnTouchListener; import android.view.ViewGroup; -//FIXME : preview gone after coming back from audio only /** * @author Sylvain Berfini */