From 9f99d61a1f992777fba43280ac10d1185e391eb1 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 21 Oct 2011 16:18:27 +0200 Subject: [PATCH] Improve encryption UI. --- res/drawable/conf_not_secured.png | Bin 0 -> 873 bytes res/drawable/conf_secured.png | Bin 0 -> 838 bytes res/layout/conf_callee.xml | 2 + res/layout/conf_callee_older_devices.xml | 5 +++ res/layout/conf_choices_dialog.xml | 12 ++++++ res/values/strings.xml | 3 ++ src/org/linphone/ConferenceActivity.java | 41 ++++++++++++++++++- src/org/linphone/LinphoneManager.java | 7 +++- src/org/linphone/LinphoneSimpleListener.java | 15 +++++-- 9 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 res/drawable/conf_not_secured.png create mode 100644 res/drawable/conf_secured.png diff --git a/res/drawable/conf_not_secured.png b/res/drawable/conf_not_secured.png new file mode 100644 index 0000000000000000000000000000000000000000..1381f4d1720511154aadf3eb4f9a2ec1ebd6ce7f GIT binary patch literal 873 zcmV-v1D5=WP)P000*V1^@s6{^R5m00001b5ch_0Itp) z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2ipo2 z4HYr>>5M%900QYrL_t(Y$F-HaZWBQihQBjwuOYTTLZBpIKmi*;76DHXiu8yE3Hb#= z1)}1bXcYqq9$1~41u z?DYoO+aJ3}Vu0dQn%K@EYh>X!K65u##3JN!-^yJ0Fp?ODa?>5%xtOH0pP{; z5$S*|T-z6^jwDiKFFfYp*=rq!mgdG~X>MG40ZLP8QL#Fu8^ckEj)%^uos3?6-bYQH zQ5`N6T7W=L#!?jBJx!A(cV7hHxJ8On`zcPPTYr0bXSf$A00;;wTn+(~Xqq*?><*ab_)qv$^Oe`v^-y^#}{Mv<@s9OI32#dwHt575E8w{Wl1E@rj zl}9&2!q{zmfY--hBY0Q*x5cVu=FNr(-Zg7-e0l|Crw}^{_5h!rJ;eCh*7-r>tIPEG z#RBy`chl4|^Nse3NA&vk{srPg#~40+$pC!&@Kn}5FEDiS{H8A?(7NscJf%3{zU$r; zK?Fa4f06ZSnR>O%&zadR7o(P)$NICz(Yvdi5)K0dMCyMq^B;E0>*#{U=Rb^7@YEZ7UMYqBvUBpb~}FoO{yg5opxI)00000NkvXXu0mjfEy{zA literal 0 HcmV?d00001 diff --git a/res/drawable/conf_secured.png b/res/drawable/conf_secured.png new file mode 100644 index 0000000000000000000000000000000000000000..61042339fedddbbc1ae3a315c62a64ef357f1b65 GIT binary patch literal 838 zcmV-M1G)T(P)P000*V1^@s6{^R5m00001b5ch_0Itp) z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2ipo2 z4HPx$pLt~f00PEIL_t(Y$F-GDPZL2H#(y*0Zjm;c7!Ci51Z@>qqkaN7a5r8|Og{l9 z6HiK{WCatWM{XQQJT=jSH{*!|=qHf0)L2CMqoPC%pi=1Wc-Y;x+m3EJt7D^KXaYXY^mesC z1R%pvq#na&+cWPUauE?J3{p(YSFQL-%Ou%!97|ZvL<=MIRzxI9BJ&UcYsffq((RHz zKoVeaw9A(r5s8r;c}35S(K>+TxnZ$9HyoHt8QLdzzr#;rhpW!WQw-c&2vE~hV}nxF z5kzT{ta;Xf%$Z$20>jLb9q%SP9xpFj(?&-#B4ctLq@M^CabT4zI|U9wy1Pn1kG zW*(_wuKQnwg2nVXq=y%gEv^H80&Ci^T@nQ-Yud2gHRalsGv9QGCRTkAwzQF+*GaQ* zs8|5Yb+PsbD7kh#BBd$cZDjqUZzvosKumQH+6h~O4NG^=bK&s^jEU7_7sXuq8UvFJ zB<&6MP89#C>K0PB(U%4r7SnR#u?6b+O`owd`r|l!qL4~y)zO!&nj0~pQP|w}?f(4h z^l>j%DfB`jd(Dq1Kt@`Tktk~~#~K~70su>1UvYbjR!q#RiU?MmoLrt*L+UYv9tFLX zZ*O0)^W{Bo#><;lRpx8|kf*){GfpuvU#iWxPp_YzjSz0{M{nyxZ|}$cy~W=5McS|4 zYT6+IU%9uWFu7wc#lyUppmT2tXke*h*pK*I5du1RxTbj9rWK7tuWaVJKg1 Q^Z)<=07*qoM6N<$f{rD0jsO4v literal 0 HcmV?d00001 diff --git a/res/layout/conf_callee.xml b/res/layout/conf_callee.xml index aaa3e1285..0bd5317a1 100644 --- a/res/layout/conf_callee.xml +++ b/res/layout/conf_callee.xml @@ -33,6 +33,8 @@ + + diff --git a/res/layout/conf_callee_older_devices.xml b/res/layout/conf_callee_older_devices.xml index 5e2493081..6b5461026 100644 --- a/res/layout/conf_callee_older_devices.xml +++ b/res/layout/conf_callee_older_devices.xml @@ -39,4 +39,9 @@ android:src="@drawable/conf_status_paused" /> + + + diff --git a/res/layout/conf_choices_dialog.xml b/res/layout/conf_choices_dialog.xml index b79550925..64892c0b8 100644 --- a/res/layout/conf_choices_dialog.xml +++ b/res/layout/conf_choices_dialog.xml @@ -63,5 +63,17 @@ + + + + + + + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 41fad6fc3..3cf5e0c86 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,6 +1,9 @@ + Authentication token is %s + Communication not encrypted + Starting up... An error occurred while accepting call diff --git a/src/org/linphone/ConferenceActivity.java b/src/org/linphone/ConferenceActivity.java index 8b39420ae..7d8150251 100644 --- a/src/org/linphone/ConferenceActivity.java +++ b/src/org/linphone/ConferenceActivity.java @@ -28,6 +28,7 @@ import java.util.List; import org.linphone.LinphoneManagerWaitHelper.LinphoneManagerReadyListener; import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener; +import org.linphone.LinphoneSimpleListener.LinphoneOnCallEncryptionChangedListener; import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener; import org.linphone.LinphoneSimpleListener.LinphoneOnVideoCallReadyListener; import org.linphone.core.LinphoneAddress; @@ -69,6 +70,7 @@ public class ConferenceActivity extends ListActivity implements LinphoneOnAudioChangedListener, LinphoneOnVideoCallReadyListener, LinphoneOnCallStateChangedListener, + LinphoneOnCallEncryptionChangedListener, Comparator, OnClickListener { @@ -572,7 +574,8 @@ public class ConferenceActivity extends ListActivity implements LinphoneAddress address = call.getRemoteAddress(); String mainText = address.getDisplayName(); String complText = address.getUserName(); - if ((getResources().getBoolean(R.bool.show_full_remote_address_on_incoming_call))) { + if (Version.sdkAboveOrEqual(Version.API05_ECLAIR_20) + && getResources().getBoolean(R.bool.show_full_remote_address_on_incoming_call)) { complText += "@" + address.getDomain(); } TextView mainTextView = (TextView) v.findViewById(R.id.name); @@ -653,6 +656,16 @@ public class ConferenceActivity extends ListActivity implements unhookCallButton.setOnClickListener(l); removeFromConfButton.setOnClickListener(l); addVideoButton.setOnClickListener(l); + + if (Version.hasZrtp()) { + if (call.areStreamsEncrypted()) { + setVisibility(v, R.id.callee_status_secured, true); + setVisibility(v, R.id.callee_status_not_secured, false); + } else { + setVisibility(v, R.id.callee_status_secured, false); + setVisibility(v, R.id.callee_status_not_secured, true); + } + } v.setOnClickListener(new OnClickListener() { public void onClick(View v) { @@ -666,6 +679,20 @@ public class ConferenceActivity extends ListActivity implements enableView(content, R.id.pause, l,!isInConference && showPause); enableView(content, R.id.resume, l, !isInConference && showResume); enableView(content, R.id.terminate_call, l, true); + + if (Version.hasZrtp()) { + if (call.areStreamsEncrypted()) { + setVisibility(content, R.id.encrypted, true); + setVisibility(content, R.id.unencrypted, false); + TextView token = (TextView) content.findViewById(R.id.authentication_token); + String fmt = getString(R.string.authenticationTokenFormat); + token.setText(String.format(fmt, call.getAuthenticationToken())); + } else { + setVisibility(content, R.id.encrypted, false); + setVisibility(content, R.id.unencrypted, true); + } + } + dialog.show(); } }); @@ -680,6 +707,7 @@ public class ConferenceActivity extends ListActivity implements pictureView.setVisibility(GONE); } + return v; } } @@ -882,6 +910,17 @@ public class ConferenceActivity extends ListActivity implements LinphoneActivity.instance().startVideoActivity(); } + @Override + public void onCallEncryptionChanged(LinphoneCall call, boolean encrypted, + String authenticationToken) { + mHandler.post(new Runnable() { + public void run() { + CalleeListAdapter adapter = (CalleeListAdapter) getListAdapter(); + recreateActivity(adapter); + } + }); + } + /* * public int compare(LinphoneCall c1, LinphoneCall c2) { if (c1 == c2) * return 0; diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index 53c64e4ea..528f4fa85 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -1135,7 +1135,12 @@ public final class LinphoneManager implements LinphoneCoreListener { public void onCallEncryptionChanged(LinphoneCall call, boolean encrypted, String authenticationToken) { - if (serviceListener != null) serviceListener.onCallEncryptionChanged(call, encrypted, authenticationToken); + if (serviceListener != null) { + serviceListener.onCallEncryptionChanged(call, encrypted, authenticationToken); + } + for (LinphoneOnCallEncryptionChangedListener l : getSimpleListeners(LinphoneOnCallEncryptionChangedListener.class)) { + l.onCallEncryptionChanged(call, encrypted, authenticationToken); + } } public void onCallStateChanged(LinphoneCall call, State state, diff --git a/src/org/linphone/LinphoneSimpleListener.java b/src/org/linphone/LinphoneSimpleListener.java index 20439db92..66d5bf5bc 100644 --- a/src/org/linphone/LinphoneSimpleListener.java +++ b/src/org/linphone/LinphoneSimpleListener.java @@ -27,19 +27,26 @@ import android.media.MediaPlayer; public interface LinphoneSimpleListener { - public static interface LinphoneServiceListener - extends LinphoneOnGlobalStateChangedListener, LinphoneOnCallStateChangedListener { + public static interface LinphoneServiceListener extends + LinphoneOnGlobalStateChangedListener, + LinphoneOnCallStateChangedListener, + LinphoneOnCallEncryptionChangedListener + { void tryingNewOutgoingCallButCannotGetCallParameters(); void tryingNewOutgoingCallButWrongDestinationAddress(); void tryingNewOutgoingCallButAlreadyInCall(); void onRegistrationStateChanged(RegistrationState state, String message); void onRingerPlayerCreated(MediaPlayer mRingerPlayer); void onDisplayStatus(String message); - void onCallEncryptionChanged(LinphoneCall call, boolean encrypted, String authenticationToken); void onAlreadyInVideoCall(); } - + + + public static interface LinphoneOnCallEncryptionChangedListener extends LinphoneSimpleListener { + void onCallEncryptionChanged(LinphoneCall call, boolean encrypted, String authenticationToken); + } + public static interface LinphoneOnGlobalStateChangedListener extends LinphoneSimpleListener { void onGlobalStateChanged(GlobalState state, String message); }