Adding notification for SAS

This commit is contained in:
Erwan Croze 2017-07-18 11:54:51 +02:00
parent 8320b11825
commit 7a2d276162
6 changed files with 35 additions and 2 deletions

View file

@ -197,6 +197,8 @@ Vos amis pourront vous joindre plus facilement si vous associez votre compte à
<string name="no_current_call">Aucun appel en cours</string>
<string name="couldnt_accept_call">Une erreur est survenue pendant l\'acceptation de l\'appel</string>
<string name="zrtp_dialog1">Indiquez le code SAS suivant à votre interlocuteur:\nDites: %s</string>
<string name="zrtp_notification_title">SAS</string>
<string name="zrtp_notification_message">Veulliez vérifier par oral avec votre interlocatueur qu\'il dispose de ce code.</string>
<string name="unknown_incoming_call_name">Inconnu</string>
<string name="call_stats_audio">Audio</string>
<string name="call_stats_video">Vidéo</string>

View file

@ -212,6 +212,8 @@
<string name="couldnt_accept_call">An error occurred while accepting the call</string>
<string name="zrtp_dialog1">Confirm the following SAS with peer:\nSay: %s</string>
<string name="zrtp_dialog2">\nYour caller should say: %s</string>
<string name="zrtp_notification_title">SAS</string>
<string name="zrtp_notification_message">Confirm the previous SAS code with your correspondant</string>
<string name="unknown_incoming_call_name">Unknown</string>
<string name="call_stats_audio">Audio</string>
<string name="call_stats_video">Video</string>

View file

@ -166,6 +166,10 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList
@Override
public void callState(LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) {
if (LinphoneManager.getLc().getCallsNb() == 0) {
if (status != null) {
LinphoneService.instance().removeSasNotification();
status.setisZrtpAsk(false);
}
finish();
return;
}

View file

@ -1438,7 +1438,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (getCurrentFragment() == FragmentsAvailable.SETTINGS) {
if (fragment instanceof SettingsFragment) {
((SettingsFragment) fragment).closePreferenceScreen();

View file

@ -94,6 +94,7 @@ public final class LinphoneService extends Service {
private final static int MESSAGE_NOTIF_ID=3;
private final static int CUSTOM_NOTIF_ID=4;
private final static int MISSED_NOTIF_ID=5;
private final static int SAS_NOTIF_ID=6;
public static boolean isReady() {
return instance != null && instance.mTestDelayElapsed;
@ -118,6 +119,7 @@ public final class LinphoneService extends Service {
private Notification mIncallNotif;
private Notification mMsgNotif;
private Notification mCustomNotif;
private Notification mSasNotif;
private int mMsgNotifCount;
private PendingIntent mNotifContentIntent;
private String mNotificationTitle;
@ -347,6 +349,12 @@ public final class LinphoneService extends Service {
}
if (state == State.CallEnd || state == State.CallReleased || state == State.Error) {
if (LinphoneManager.isInstanciated() && LinphoneManager.getLc() != null && LinphoneManager.getLc().getCallsNb() == 0) {
if (LinphoneActivity.isInstanciated() && LinphoneActivity.instance().getStatusFragment() != null) {
removeSasNotification();
LinphoneActivity.instance().getStatusFragment().setisZrtpAsk(false);
}
}
destroyOverlay();
}
@ -415,7 +423,7 @@ public final class LinphoneService extends Service {
}
});
try {
mStartForeground = getClass().getMethod("startForeground", mStartFgSign);
mStopForeground = getClass().getMethod("stopForeground", mStopFgSign);
@ -634,6 +642,19 @@ public final class LinphoneService extends Service {
resetIntentLaunchedOnNotificationClick();
}
public void displaySasNotification(String sas) {
mSasNotif = Compatibility.createSimpleNotification(getApplicationContext(),
getString(R.string.zrtp_notification_title),
sas + " " + getString(R.string.zrtp_notification_message),
null);
notifyWrapper(SAS_NOTIF_ID, mSasNotif);
}
public void removeSasNotification() {
mNM.cancel(SAS_NOTIF_ID);
}
private static final Class<?>[] mSetFgSign = new Class[] {boolean.class};
private static final Class<?>[] mStartFgSign = new Class[] {
int.class, Notification.class};

View file

@ -416,6 +416,8 @@ public class StatusFragment extends Fragment {
zrtpToRead = token.substring(2);
}
LinphoneService.instance().displaySasNotification(token);
TextView customText = (TextView) ZRTPdialog.findViewById(R.id.customText);
String newText = getString(R.string.zrtp_dialog1).replace("%s", zrtpToRead)
+ getString(R.string.zrtp_dialog2).replace("%s", zrtpToListen);
@ -434,6 +436,7 @@ public class StatusFragment extends Fragment {
}
isZrtpAsk = false;
ZRTPdialog.dismiss();
LinphoneService.instance().removeSasNotification();
}
});
@ -448,6 +451,7 @@ public class StatusFragment extends Fragment {
}
isZrtpAsk = false;
ZRTPdialog.dismiss();
LinphoneService.instance().removeSasNotification();
}
});
ZRTPdialog.show();