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" style="@style/font1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingLeft="10dp"
android:gravity="center"/> android:gravity="center"/>
</RelativeLayout> </RelativeLayout>

View file

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

View file

@ -3,8 +3,10 @@
<!-- New settings --> <!-- New settings -->
<!-- TODO Migrate it in linphonerc --> <!-- TODO Migrate it in linphonerc -->
<bool name="assistant_use_linphone_login_as_first_fragment">false</bool> <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_domain">sip.linphone.org</string>
<string name="default_stun">stun.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> <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.Log;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration; import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import org.linphone.ui.Numpad; import org.linphone.ui.Numpad;
import org.w3c.dom.Text;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
@ -130,6 +131,7 @@ public class CallActivity extends Activity implements OnClickListener {
cameraNumber = AndroidCameraConfiguration.retrieveCameras().length; cameraNumber = AndroidCameraConfiguration.retrieveCameras().length;
mListener = new LinphoneCoreListenerBase(){ mListener = new LinphoneCoreListenerBase(){
@Override @Override
public void callState(LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) { public void callState(LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) {
if (LinphoneManager.getLc().getCallsNb() == 0) { 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) { if (state == State.StreamsRunning) {
switchVideo(isVideoEnabled(call)); switchVideo(isVideoEnabled(call));
//Check media in progress //Check media in progress
@ -228,6 +223,9 @@ public class CallActivity extends Activity implements OnClickListener {
@Override @Override
public void callEncryptionChanged(LinphoneCore lc, final LinphoneCall call, boolean encrypted, String authenticationToken) { public void callEncryptionChanged(LinphoneCore lc, final LinphoneCall call, boolean encrypted, String authenticationToken) {
if (status != null) { if (status != null) {
if(call.getCurrentParamsCopy().getMediaEncryption().equals(LinphoneCore.MediaEncryption.ZRTP) && !call.isAuthenticationTokenVerified()){
status.showZRTPDialog(call);
}
status.refreshStatusItems(call, call.getCurrentParamsCopy().getVideoEnabled()); status.refreshStatusItems(call, call.getCurrentParamsCopy().getVideoEnabled());
} }
} }
@ -1450,109 +1448,54 @@ public class CallActivity extends Activity implements OnClickListener {
videoCallFragment = fragment; videoCallFragment = fragment;
} }
private void displayActiveCall(LinphoneCall call){
if(!isVideoEnabled(call)){ //CALL INFORMATION
mActiveCallHeader.setVisibility(View.VISIBLE);
mNoCurrentCall.setVisibility(View.GONE); private void displayCurrentCall(LinphoneCall call){
//if(!isVideoEnabled(call)){
// mActiveCallHeader.setVisibility(View.VISIBLE);
// mNoCurrentCall.setVisibility(View.GONE);
//}
LinphoneAddress lAddress = call.getRemoteAddress();
TextView contactName = (TextView) findViewById(R.id.contact_name);
setContactInformation(contactName, contactPicture, lAddress);
registerCallDurationTimer(null, call);
} }
if(call == null) return; private void displayPausedCalls(Resources resources, final LinphoneCall call, int index) {
String sipUri = call.getRemoteAddress().asStringUriOnly(); LinphoneAddress lAddress = call.getRemoteAddress();
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");
}
TextView contact = (TextView) findViewById(R.id.contact_name);
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());
}
/*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();
}
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");
}
// Control Row // Control Row
LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.call_inactive_row, container, false); LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.call_inactive_row, container, false);
callView.setId(index+1); 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(call == null) {
if (lContact == null) { if(isConferenceRunning){
contact.setText(lAddress.getUserName()); Log.w("conf running");
} else {
contact.setText(lContact.getName());
} }
contactName.setText(resources.getString(R.string.conference));
contactImage.setImageResource(R.drawable.conference_start);
} else {
setContactInformation(contactName, contactImage, lAddress);
displayCallStatusIconAndReturnCallPaused(callView, call); displayCallStatusIconAndReturnCallPaused(callView, call);
registerCallDurationTimer(callView, call); registerCallDurationTimer(callView, call);
callsList.addView(callView); 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();
} }
} }
});*/
}
private void setContactName(LinearLayout callView, LinphoneAddress lAddress, String sipUri, Resources resources) { private void setContactInformation(TextView contactName, ImageView contactPicture, LinphoneAddress lAddress) {
TextView contact = (TextView) callView.findViewById(R.id.contactNameOrNumber); Contact lContact = ContactsManager.getInstance().findContactWithAddress(contactName.getContext().getContentResolver(), lAddress);
Contact lContact = ContactsManager.getInstance().findContactWithAddress(callView.getContext().getContentResolver(), lAddress);
if (lContact == null) { if (lContact == null) {
contact.setText(lAddress.getUserName()); contactName.setText(LinphoneUtils.getAddressDisplayName(lAddress));
contactPicture.setImageResource(R.drawable.avatar);
} else { } 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; 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) { if (timer == null) {
throw new IllegalArgumentException("no callee_duration view found"); 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()) { for (LinphoneCall call : LinphoneManager.getLc().getCalls()) {
if(call.isInConference()) break; if(call.isInConference()) break;
if (call != LinphoneManager.getLc().getCurrentCall()) { if (call != LinphoneManager.getLc().getCurrentCall()) {
displayOtherCalls(resources, call, index); displayPausedCalls(resources, call, index);
index++; index++;
} else { } 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.LinphoneCore;
import org.linphone.core.LinphoneCoreListenerBase; import org.linphone.core.LinphoneCoreListenerBase;
import org.linphone.mediastream.Log; import org.linphone.mediastream.Log;
import org.linphone.ui.LinphoneSliders;
import org.linphone.ui.LinphoneSliders.LinphoneSliderTriggered; import org.linphone.ui.LinphoneSliders.LinphoneSliderTriggered;
import android.app.Activity; import android.app.Activity;
import android.content.ClipData;
import android.content.ClipDescription;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.view.DragEvent;
import android.view.GestureDetector;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
@ -278,7 +271,7 @@ public class CallIncomingActivity extends Activity implements LinphoneSliderTrig
} }
private void answer() { private void answer() {
LinphoneCallParams params = LinphoneManager.getLc().createDefaultCallParameters(); LinphoneCallParams params = LinphoneManager.getLc().createCallParams(mCall);
if (!LinphoneManager.getInstance().acceptCallWithParams(mCall, params)) { if (!LinphoneManager.getInstance().acceptCallWithParams(mCall, params)) {
// the above method takes care of Samsung Galaxy S // the above method takes care of Samsung Galaxy S

View file

@ -225,21 +225,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
routeAudioToSpeakerHelper(false); 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) { public synchronized static final LinphoneManager createAndStart(Context c) {
if (instance != null) if (instance != null)
throw new RuntimeException("Linphone Manager is already initialized"); throw new RuntimeException("Linphone Manager is already initialized");

View file

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