Make encryption locker clickable + cleaning

This commit is contained in:
Guillaume Beraudo 2011-11-30 12:27:11 +01:00
parent 1aa6cb4e4e
commit afb8f8da93
3 changed files with 42 additions and 52 deletions

View file

@ -18,13 +18,6 @@
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_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/transfer_new"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/conf_transfer" android:clickable="false"

View file

@ -7,10 +7,9 @@
<string name="not_ready_to_make_new_call">Not ready for a new call</string>
<string name="bad_target_uri">Bad contact : %s</string>
<string name="reset_sas_fmt">Reset validated %s</string>
<string name="validate_sas_fmt">Validate %s</string>
<string name="reset_sas_fmt">Reset verified %s</string>
<string name="verify_sas_fmt">Verify %s</string>
<string name="communication_encrypted">Encrypted</string>
<string name="not_encrypted">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

@ -22,6 +22,7 @@ import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
@ -338,9 +339,6 @@ public class IncallActivity extends AbstractCalleesActivity implements
this.call = call;
this.dialog = dialog;
}
public CallActionListener(LinphoneCall call) {
this.call = call;
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.merge_to_conference:
@ -440,32 +438,14 @@ public class IncallActivity extends AbstractCalleesActivity implements
}
v.setBackgroundResource(bgDrawableId);
boolean connectionEstablished = state == State.StreamsRunning
final boolean connectionEstablished = state == State.StreamsRunning
|| state == State.Paused
|| state == State.PausedByRemote;
View confButton = v.findViewById(R.id.merge_to_conference);
final boolean showMergeToConf = connectionEstablished && aConferenceIsPossible();
setVisibility(confButton, false);
boolean statusPaused = state== State.Paused || state == State.PausedByRemote;
setVisibility(v, R.id.callee_status_paused, statusPaused);
final OnClickListener l = new CallActionListener(call);
confButton.setOnClickListener(l);
MediaEncryption mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
if (MediaEncryption.None == mediaEncryption) {
setVisibility(v, R.id.callee_status_secured, false);
setVisibility(v, R.id.callee_status_maybe_secured, false);
setVisibility(v, R.id.callee_status_not_secured, false);
} else {
boolean reallySecured = !Version.hasZrtp() || call.isAuthenticationTokenVerified();
setVisibility(v, R.id.callee_status_secured, reallySecured);
setVisibility(v, R.id.callee_status_maybe_secured, !reallySecured);
setVisibility(v, R.id.callee_status_not_secured, false);
}
v.setOnLongClickListener(new OnLongClickListener() {
final OnLongClickListener showCallActionsLongListener = new OnLongClickListener() {
public boolean onLongClick(View v) {
if (lc().soundResourcesLocked()) {
return false;
@ -475,32 +455,50 @@ public class IncallActivity extends AbstractCalleesActivity implements
OnClickListener l = new CallActionListener(call, dialog);
enableView(content, R.id.transfer_existing, l, mAllowTransfers && getSpecificCalls().size() >=2);
enableView(content, R.id.transfer_new, l, mAllowTransfers);
boolean showMergeToConf = connectionEstablished && aConferenceIsPossible();
enableView(content, R.id.merge_to_conference, l, showMergeToConf);
enableView(content, R.id.terminate_call, l, true);
MediaEncryption mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
MediaEncryption supposedEncryption = LinphoneManager.getLc().getMediaEncryption();
if (mediaEncryption==MediaEncryption.None) {
setVisibility(content, R.id.unencrypted, supposedEncryption!=MediaEncryption.None);
} else{
TextView token = (TextView) content.findViewById(R.id.authentication_token);
if (mediaEncryption==MediaEncryption.ZRTP) {
if (call.getCurrentParamsCopy().getMediaEncryption()==MediaEncryption.ZRTP) {
boolean authVerified = call.isAuthenticationTokenVerified();
String fmt = getString(authVerified ? R.string.reset_sas_fmt : R.string.validate_sas_fmt);
String fmt = getString(authVerified ? R.string.reset_sas_fmt : R.string.verify_sas_fmt);
TextView token = (TextView) content.findViewById(R.id.authentication_token);
token.setText(String.format(fmt, call.getAuthenticationToken()));
enableView(content, R.id.set_auth_token_not_verified, l, authVerified);
enableView(content, R.id.set_auth_token_verified, l, !authVerified);
enableView(content, R.id.encrypted, l, true);
} else {
setVisibility(content, R.id.encrypted, true);
token.setText(R.string.communication_encrypted);
}
setVisibility(content, R.id.encrypted, false);
}
dialog.show();
return true;
}
});
};
v.setOnLongClickListener(showCallActionsLongListener);
OnClickListener showCallActionsSimpleListener = new OnClickListener() {
@Override
public void onClick(View v) {
showCallActionsLongListener.onLongClick(v);
}
};
MediaEncryption mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
if (MediaEncryption.None == mediaEncryption) {
setVisibility(v, R.id.callee_status_secured, false);
setVisibility(v, R.id.callee_status_maybe_secured, false);
setVisibility(v, R.id.callee_status_not_secured, false);
} else if (MediaEncryption.ZRTP == mediaEncryption ) {
boolean reallySecured = call.isAuthenticationTokenVerified();
enableView(v, R.id.callee_status_secured, showCallActionsSimpleListener, reallySecured);
enableView(v, R.id.callee_status_maybe_secured, showCallActionsSimpleListener, !reallySecured);
enableView(v, R.id.callee_status_not_secured, showCallActionsSimpleListener, false);
} else {
setVisibility(v, R.id.callee_status_secured, true);
setVisibility(v, R.id.callee_status_maybe_secured, false);
setVisibility(v, R.id.callee_status_not_secured, false);
}
v.setOnClickListener(new OnClickListener() {
@Override