Update call activity with ZRTP popup

This commit is contained in:
Margaux Clerc 2015-11-02 17:23:26 +01:00
parent 104668cd4d
commit 5ba6c571af
7 changed files with 86 additions and 156 deletions

View file

@ -25,7 +25,6 @@
style="@style/font1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:gravity="center"/>
</RelativeLayout>

View file

@ -12,7 +12,6 @@
<color name="colorJ">#ffa645</color>
<color name="colorK">#3eb5c0</color>
<color name="colorL">#96c11f</color>
<color name="colorAB">#ffeee5</color>
<color name="transparent">#00000000</color>
</resources>

View file

@ -3,8 +3,10 @@
<!-- New settings -->
<!-- TODO Migrate it in linphonerc -->
<bool name="assistant_use_linphone_login_as_first_fragment">false</bool>
<bool name="hide_in_call_stats">false</bool>
<string name="default_domain">sip.linphone.org</string>
<string name="default_stun">stun.linphone.org</string>
<bool name="use_linphone_friend">true</bool>
<string name="wizard_url">https://www.linphone.org/wizard.php</string>

View file

@ -32,6 +32,7 @@ import org.linphone.core.LinphonePlayer;
import org.linphone.mediastream.Log;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import org.linphone.ui.Numpad;
import org.w3c.dom.Text;
import android.app.Activity;
import android.app.Dialog;
@ -130,6 +131,7 @@ public class CallActivity extends Activity implements OnClickListener {
cameraNumber = AndroidCameraConfiguration.retrieveCameras().length;
mListener = new LinphoneCoreListenerBase(){
@Override
public void callState(LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) {
if (LinphoneManager.getLc().getCallsNb() == 0) {
@ -163,13 +165,6 @@ public class CallActivity extends Activity implements OnClickListener {
}
}
if (state == State.Connected) {
if(call.getCurrentParamsCopy().getMediaEncryption().equals(LinphoneCore.MediaEncryption.ZRTP) && !call.isAuthenticationTokenVerified()){
//TODO AFFICHER DIALOG ZRTP
status.showZRTPDialog(call);
}
}
if (state == State.StreamsRunning) {
switchVideo(isVideoEnabled(call));
//Check media in progress
@ -228,6 +223,9 @@ public class CallActivity extends Activity implements OnClickListener {
@Override
public void callEncryptionChanged(LinphoneCore lc, final LinphoneCall call, boolean encrypted, String authenticationToken) {
if (status != null) {
if(call.getCurrentParamsCopy().getMediaEncryption().equals(LinphoneCore.MediaEncryption.ZRTP) && !call.isAuthenticationTokenVerified()){
status.showZRTPDialog(call);
}
status.refreshStatusItems(call, call.getCurrentParamsCopy().getVideoEnabled());
}
}
@ -1450,109 +1448,54 @@ public class CallActivity extends Activity implements OnClickListener {
videoCallFragment = fragment;
}
private void displayActiveCall(LinphoneCall call){
if(!isVideoEnabled(call)){
mActiveCallHeader.setVisibility(View.VISIBLE);
mNoCurrentCall.setVisibility(View.GONE);
}
if(call == null) return;
String sipUri = call.getRemoteAddress().asStringUriOnly();
LinphoneAddress lAddress;
try {
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
} catch (LinphoneCoreException e) {
Log.e("Incall activity cannot parse remote address",e);
lAddress= LinphoneCoreFactory.instance().createLinphoneAddress("unknown","unknown","unknown");
}
//CALL INFORMATION
TextView contact = (TextView) findViewById(R.id.contact_name);
private void displayCurrentCall(LinphoneCall call){
//if(!isVideoEnabled(call)){
// mActiveCallHeader.setVisibility(View.VISIBLE);
// mNoCurrentCall.setVisibility(View.GONE);
//}
Contact lContact = ContactsManager.getInstance().findContactWithAddress(getContentResolver(), lAddress);
if (lContact == null) {
contact.setText(lAddress.getUserName());
} else {
contact.setText(lContact.getName());
LinphoneUtils.setImagePictureFromUri(contactPicture.getContext(), contactPicture, lContact.getPhotoUri(), lContact.getThumbnailUri());
}
LinphoneAddress lAddress = call.getRemoteAddress();
TextView contactName = (TextView) findViewById(R.id.contact_name);
/*if(contact != null) {
} else {
displayOrHideContactPicture(imageView, null, null, false);
}
callsList.addView(imageView);*/
int callDuration = call.getDuration();
if (callDuration == 0 && call.getState() != State.StreamsRunning) {
return;
}
Chronometer timer = (Chronometer) findViewById(R.id.call_timer);
if (timer == null) {
throw new IllegalArgumentException("no callee_duration view found");
}
timer.setBase(SystemClock.elapsedRealtime() - 1000 * callDuration);
timer.start();
setContactInformation(contactName, contactPicture, lAddress);
registerCallDurationTimer(null, call);
}
private void displayOtherCalls(Resources resources, final LinphoneCall call, int index) {
String sipUri = call.getRemoteAddress().asStringUriOnly();
LinphoneAddress lAddress;
try {
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
} catch (LinphoneCoreException e) {
Log.e("Incall activity cannot parse remote address",e);
lAddress= LinphoneCoreFactory.instance().createLinphoneAddress("uknown","unknown","unkonown");
}
private void displayPausedCalls(Resources resources, final LinphoneCall call, int index) {
LinphoneAddress lAddress = call.getRemoteAddress();
// Control Row
LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.call_inactive_row, container, false);
callView.setId(index+1);
TextView contact = (TextView) callView.findViewById(R.id.contact_name);
TextView contactName = (TextView) callView.findViewById(R.id.contact_name);
ImageView contactImage = (ImageView) callView.findViewById(R.id.contact_picture);
Contact lContact = ContactsManager.getInstance().findContactWithAddress(getContentResolver(), lAddress);
if (lContact == null) {
contact.setText(lAddress.getUserName());
} else {
contact.setText(lContact.getName());
}
displayCallStatusIconAndReturnCallPaused(callView, call);
registerCallDurationTimer(callView, call);
callsList.addView(callView);
// Image Row
// callView.setTag(imageView);
/* callView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (v.getTag() != null) {
View imageView = (View) v.getTag();
if (imageView.getVisibility() == View.VISIBLE)
imageView.setVisibility(View.GONE);
else
imageView.setVisibility(View.VISIBLE);
callsList.invalidate();
}
if(call == null) {
if(isConferenceRunning){
Log.w("conf running");
}
});*/
contactName.setText(resources.getString(R.string.conference));
contactImage.setImageResource(R.drawable.conference_start);
} else {
setContactInformation(contactName, contactImage, lAddress);
displayCallStatusIconAndReturnCallPaused(callView, call);
registerCallDurationTimer(callView, call);
callsList.addView(callView);
}
}
private void setContactName(LinearLayout callView, LinphoneAddress lAddress, String sipUri, Resources resources) {
TextView contact = (TextView) callView.findViewById(R.id.contactNameOrNumber);
Contact lContact = ContactsManager.getInstance().findContactWithAddress(callView.getContext().getContentResolver(), lAddress);
private void setContactInformation(TextView contactName, ImageView contactPicture, LinphoneAddress lAddress) {
Contact lContact = ContactsManager.getInstance().findContactWithAddress(contactName.getContext().getContentResolver(), lAddress);
if (lContact == null) {
contact.setText(lAddress.getUserName());
contactName.setText(LinphoneUtils.getAddressDisplayName(lAddress));
contactPicture.setImageResource(R.drawable.avatar);
} else {
contact.setText(lContact.getName());
contactName.setText(lContact.getName());
LinphoneUtils.setImagePictureFromUri(contactPicture.getContext(), contactPicture, lContact.getPhotoUri(), lContact.getThumbnailUri());
}
}
@ -1598,7 +1541,13 @@ public class CallActivity extends Activity implements OnClickListener {
return;
}
Chronometer timer = (Chronometer) v.findViewById(R.id.call_timer);
Chronometer timer;
if(v == null){
timer = (Chronometer) findViewById(R.id.call_timer);
} else {
timer = (Chronometer) v.findViewById(R.id.call_timer);
}
if (timer == null) {
throw new IllegalArgumentException("no callee_duration view found");
}
@ -1630,10 +1579,10 @@ public class CallActivity extends Activity implements OnClickListener {
for (LinphoneCall call : LinphoneManager.getLc().getCalls()) {
if(call.isInConference()) break;
if (call != LinphoneManager.getLc().getCurrentCall()) {
displayOtherCalls(resources, call, index);
displayPausedCalls(resources, call, index);
index++;
} else {
displayActiveCall(call);
displayCurrentCall(call);
}
}

View file

@ -27,20 +27,13 @@ import org.linphone.core.LinphoneCallParams;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCoreListenerBase;
import org.linphone.mediastream.Log;
import org.linphone.ui.LinphoneSliders;
import org.linphone.ui.LinphoneSliders.LinphoneSliderTriggered;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipDescription;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.os.Build;
import android.os.Bundle;
import android.os.PowerManager;
import android.view.DragEvent;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
@ -278,7 +271,7 @@ public class CallIncomingActivity extends Activity implements LinphoneSliderTrig
}
private void answer() {
LinphoneCallParams params = LinphoneManager.getLc().createDefaultCallParameters();
LinphoneCallParams params = LinphoneManager.getLc().createCallParams(mCall);
if (!LinphoneManager.getInstance().acceptCallWithParams(mCall, params)) {
// the above method takes care of Samsung Galaxy S

View file

@ -225,21 +225,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
routeAudioToSpeakerHelper(false);
}
public synchronized final void destroyLinphoneCore(Context c) {
BluetoothManager.getInstance().destroy();
try {
mTimer.cancel();
mLc.destroy();
}
catch (RuntimeException e) {
e.printStackTrace();
}
finally {
mServiceContext.unregisterReceiver(instance.mKeepAliveReceiver);
mLc = null;
}
}
public synchronized static final LinphoneManager createAndStart(Context c) {
if (instance != null)
throw new RuntimeException("Linphone Manager is already initialized");

View file

@ -67,6 +67,7 @@ public class StatusFragment extends Fragment {
private Timer mTimer;
private TimerTask mTask;
private LinphoneCoreListenerBase mListener;
private Dialog ZRTPdialog = null;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -384,46 +385,48 @@ public class StatusFragment extends Fragment {
return;
}
final Dialog dialog = new Dialog(getActivity());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
Drawable d = new ColorDrawable(getResources().getColor(R.color.colorC));
d.setAlpha(200);
dialog.setContentView(R.layout.dialog);
dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
dialog.getWindow().setBackgroundDrawable(d);
if(ZRTPdialog == null || !ZRTPdialog.isShowing()) {
ZRTPdialog = new Dialog(getActivity());
ZRTPdialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
Drawable d = new ColorDrawable(getResources().getColor(R.color.colorC));
d.setAlpha(200);
ZRTPdialog.setContentView(R.layout.dialog);
ZRTPdialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
ZRTPdialog.getWindow().setBackgroundDrawable(d);
TextView customText = (TextView) dialog.findViewById(R.id.customText);
String newText = getString(R.string.zrtp_dialog).replace("%s",call.getAuthenticationToken());
customText.setText(newText);
Button delete = (Button) dialog.findViewById(R.id.delete);
delete.setText(R.string.accept);
Button cancel = (Button) dialog.findViewById(R.id.cancel);
cancel.setText(R.string.deny);
TextView customText = (TextView) ZRTPdialog.findViewById(R.id.customText);
String newText = getString(R.string.zrtp_dialog).replace("%s", call.getAuthenticationToken());
customText.setText(newText);
Button delete = (Button) ZRTPdialog.findViewById(R.id.delete);
delete.setText(R.string.accept);
Button cancel = (Button) ZRTPdialog.findViewById(R.id.cancel);
cancel.setText(R.string.deny);
delete.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
call.setAuthenticationTokenVerified(true);
if (encryption != null) {
encryption.setImageResource(R.drawable.security_ok);
}
dialog.dismiss();
}
});
cancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (call != null) {
call.setAuthenticationTokenVerified(false);
delete.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
call.setAuthenticationTokenVerified(true);
if (encryption != null) {
encryption.setImageResource(R.drawable.security_pending);
encryption.setImageResource(R.drawable.security_ok);
}
ZRTPdialog.dismiss();
}
dialog.dismiss();
}
});
dialog.show();
});
cancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (call != null) {
call.setAuthenticationTokenVerified(false);
if (encryption != null) {
encryption.setImageResource(R.drawable.security_ko);
}
}
ZRTPdialog.dismiss();
}
});
ZRTPdialog.show();
}
}
public void initCallStatsRefresher(final LinphoneCall call, final View view) {