Improve encryption UI.

This commit is contained in:
Guillaume Beraudo 2011-10-21 16:18:27 +02:00
parent bba107f83d
commit 9f99d61a1f
9 changed files with 79 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 873 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

View file

@ -33,6 +33,8 @@
<TextView android:id="@+id/status_label" style="@style/callee_status" />
<ImageView android:id="@+id/callee_status_paused" style="@style/callee_status" android:src="@drawable/conf_status_paused" />
<ImageView android:id="@+id/callee_status_inconf" style="@style/callee_status" android:src="@drawable/conf_status_inconf"/>
<ImageView android:id="@+id/callee_status_secured" style="@style/callee_status" android:src="@drawable/conf_secured" android:visibility="gone"/>
<ImageView android:id="@+id/callee_status_not_secured" style="@style/callee_status" android:src="@drawable/conf_not_secured" android:visibility="gone"/>
</LinearLayout>

View file

@ -39,4 +39,9 @@
android:src="@drawable/conf_status_paused" />
<ImageView android:id="@+id/callee_status_inconf" style="@style/callee_status"
android:src="@drawable/conf_status_inconf" />
<ImageView android:id="@+id/callee_status_secured" style="@style/callee_status"
android:src="@drawable/conf_secured" android:visibility="gone"/>
<ImageView android:id="@+id/callee_status_not_secured" style="@style/callee_status"
android:src="@drawable/conf_not_secured" android:visibility="gone"/>
</LinearLayout>

View file

@ -63,5 +63,17 @@
<TextView android:text="@string/conf_choice_terminate" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/encrypted" android:visibility="gone"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageView android:src="@drawable/conf_secured" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:id="@+id/authentication_token" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/unencrypted" android:visibility="gone"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageView android:src="@drawable/conf_not_secured" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/not_encrypted" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</ScrollView>

View file

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="authenticationTokenFormat">Authentication token is %s</string>
<string name="not_encrypted">Communication not encrypted</string>
<string name="waiting_for_startup">Starting up...</string>
<string name="couldnt_accept_call">An error occurred while accepting call</string>

View file

@ -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<LinphoneCall>,
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;

View file

@ -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,

View file

@ -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);
}