Fixed goToHistory when clicking on missed call notification

This commit is contained in:
Sylvain Berfini 2018-11-21 11:14:09 +01:00
parent b16923ac1c
commit 37fed6852d
6 changed files with 16 additions and 38 deletions

View file

@ -165,15 +165,10 @@ public final class LinphoneService extends Service {
} }
if (state == State.End || state == State.Released || state == State.Error) { if (state == State.End || state == State.Released || state == State.Error) {
if (LinphoneManager.isInstanciated() && LinphoneManager.getLc() != null && LinphoneManager.getLc().getCallsNb() == 0) {
if (LinphoneActivity.isInstanciated() && LinphoneActivity.instance().getStatusFragment() != null) {
LinphoneActivity.instance().getStatusFragment().setisZrtpAsk(false);
}
}
destroyOverlay(); destroyOverlay();
} }
if (state == State.End && call.getCallLog().getStatus() == Call.Status.Missed) { if (state == State.Released && call.getCallLog().getStatus() == Call.Status.Missed) {
mNotificationManager.displayMissedCallNotification(call); mNotificationManager.displayMissedCallNotification(call);
} }
} }

View file

@ -186,9 +186,6 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList
@Override @Override
public void onCallStateChanged(Core lc, final Call call, Call.State state, String message) { public void onCallStateChanged(Core lc, final Call call, Call.State state, String message) {
if (LinphoneManager.getLc().getCallsNb() == 0) { if (LinphoneManager.getLc().getCallsNb() == 0) {
if (status != null) {
status.setisZrtpAsk(false);
}
finish(); finish();
return; return;
} }
@ -273,9 +270,6 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList
TimeRemind = savedInstanceState.getLong("TimeRemind"); TimeRemind = savedInstanceState.getLong("TimeRemind");
createTimerForDialog(TimeRemind); createTimerForDialog(TimeRemind);
} }
if (status != null && savedInstanceState.getBoolean("AskingZrtp")) {
status.setisZrtpAsk(savedInstanceState.getBoolean("AskingZrtp"));
}
refreshInCallActions(); refreshInCallActions();
return; return;
} else { } else {
@ -334,7 +328,6 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList
outState.putBoolean("VideoCallPaused", isVideoCallPaused); outState.putBoolean("VideoCallPaused", isVideoCallPaused);
outState.putBoolean("AskingVideo", isVideoAsk); outState.putBoolean("AskingVideo", isVideoAsk);
outState.putLong("TimeRemind", TimeRemind); outState.putLong("TimeRemind", TimeRemind);
if (status != null) outState.putBoolean("AskingZrtp", status.getisZrtpAsk());
if (dialog != null) dialog.dismiss(); if (dialog != null) dialog.dismiss();
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
@ -1179,8 +1172,11 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList
refreshIncallUi(); refreshIncallUi();
handleViewIntent(); handleViewIntent();
if (status != null && status.getisZrtpAsk() && lc != null) { if (status != null && lc != null) {
status.showZRTPDialog(lc.getCurrentCall()); Call currentCall = lc.getCurrentCall();
if (!currentCall.getAuthenticationTokenVerified()) {
status.showZRTPDialog(currentCall);
}
} }
if (!isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) { if (!isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) {

View file

@ -128,10 +128,6 @@ public class ApiTwentyOnePlus {
return notif; return notif;
} }
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener keyboardListener) {
viewTreeObserver.removeOnGlobalLayoutListener(keyboardListener);
}
public static Notification createMissedCallNotification(Context context, String title, String text, PendingIntent intent) { public static Notification createMissedCallNotification(Context context, String title, String text, PendingIntent intent) {
Notification notif = new Notification.Builder(context) Notification notif = new Notification.Builder(context)
.setContentTitle(title) .setContentTitle(title)
@ -141,7 +137,7 @@ public class ApiTwentyOnePlus {
.setContentIntent(intent) .setContentIntent(intent)
.setDefaults(Notification.DEFAULT_SOUND .setDefaults(Notification.DEFAULT_SOUND
| Notification.DEFAULT_VIBRATE) | Notification.DEFAULT_VIBRATE)
.setCategory(Notification.CATEGORY_MESSAGE) .setCategory(Notification.CATEGORY_EVENT)
.setVisibility(Notification.VISIBILITY_PRIVATE) .setVisibility(Notification.VISIBILITY_PRIVATE)
.setLights(ContextCompat.getColor(context, R.color.notification_color_led), .setLights(ContextCompat.getColor(context, R.color.notification_color_led),
context.getResources().getInteger(R.integer.notification_ms_on), context.getResources().getInteger(R.integer.notification_ms_on),

View file

@ -206,7 +206,7 @@ public class ApiTwentySixPlus {
.setContentIntent(intent) .setContentIntent(intent)
.setDefaults(Notification.DEFAULT_SOUND .setDefaults(Notification.DEFAULT_SOUND
| Notification.DEFAULT_VIBRATE) | Notification.DEFAULT_VIBRATE)
.setCategory(Notification.CATEGORY_MESSAGE) .setCategory(Notification.CATEGORY_EVENT)
.setVisibility(Notification.VISIBILITY_PRIVATE) .setVisibility(Notification.VISIBILITY_PRIVATE)
.setPriority(Notification.PRIORITY_HIGH) .setPriority(Notification.PRIORITY_HIGH)
.setWhen(System.currentTimeMillis()) .setWhen(System.currentTimeMillis())

View file

@ -60,7 +60,7 @@ public class StatusFragment extends Fragment {
private TextView statusText, voicemailCount; private TextView statusText, voicemailCount;
private ImageView statusLed, callQuality, encryption, menu, voicemail; private ImageView statusLed, callQuality, encryption, menu, voicemail;
private Runnable mCallQualityUpdater; private Runnable mCallQualityUpdater;
private boolean isInCall, isAttached = false, isZrtpAsk; private boolean isInCall, isAttached = false;
private CoreListenerStub mListener; private CoreListenerStub mListener;
private Dialog ZRTPdialog = null; private Dialog ZRTPdialog = null;
private int mDisplayedQuality = -1; private int mDisplayedQuality = -1;
@ -418,7 +418,6 @@ public class StatusFragment extends Fragment {
ZRTPdialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); ZRTPdialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
ZRTPdialog.getWindow().setBackgroundDrawable(d); ZRTPdialog.getWindow().setBackgroundDrawable(d);
String zrtpToRead, zrtpToListen; String zrtpToRead, zrtpToListen;
isZrtpAsk = true;
if (call.getDir().equals(Call.Dir.Incoming)) { if (call.getDir().equals(Call.Dir.Incoming)) {
zrtpToRead = token.substring(0, 2); zrtpToRead = token.substring(0, 2);
@ -461,7 +460,6 @@ public class StatusFragment extends Fragment {
encryption.setImageResource(R.drawable.security_ko); encryption.setImageResource(R.drawable.security_ko);
} }
} }
isZrtpAsk = false;
ZRTPdialog.dismiss(); ZRTPdialog.dismiss();
} }
}); });
@ -473,19 +471,10 @@ public class StatusFragment extends Fragment {
if (encryption != null) { if (encryption != null) {
encryption.setImageResource(R.drawable.security_ok); encryption.setImageResource(R.drawable.security_ok);
} }
isZrtpAsk = false;
ZRTPdialog.dismiss(); ZRTPdialog.dismiss();
} }
}); });
ZRTPdialog.show(); ZRTPdialog.show();
} }
} }
public boolean getisZrtpAsk() {
return isZrtpAsk;
}
public void setisZrtpAsk(boolean bool) {
isZrtpAsk = bool;
}
} }

View file

@ -27,7 +27,6 @@ import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.net.Uri; import android.net.Uri;
import android.provider.MediaStore;
import org.linphone.LinphoneManager; import org.linphone.LinphoneManager;
import org.linphone.LinphonePreferences; import org.linphone.LinphonePreferences;
@ -82,6 +81,7 @@ public class NotificationsManager {
bm = BitmapFactory.decodeResource(mContext.getResources(), R.mipmap.ic_launcher); bm = BitmapFactory.decodeResource(mContext.getResources(), R.mipmap.ic_launcher);
} catch (Exception e) { } catch (Exception e) {
} }
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT);
mServiceNotification = Compatibility.createNotification(mContext, mContext.getString(R.string.service_name), "", mServiceNotification = Compatibility.createNotification(mContext, mContext.getString(R.string.service_name), "",
R.drawable.linphone_notification_icon, R.mipmap.ic_launcher, bm, pendingIntent, true, R.drawable.linphone_notification_icon, R.mipmap.ic_launcher, bm, pendingIntent, true,
@ -143,6 +143,7 @@ public class NotificationsManager {
mLastNotificationId += 1; mLastNotificationId += 1;
mChatNotifMap.put(conferenceAddress, notif); mChatNotifMap.put(conferenceAddress, notif);
} }
notifMessage.setSenderBitmap(bm); notifMessage.setSenderBitmap(bm);
notif.addMessage(notifMessage); notif.addMessage(notifMessage);
notif.setIsGroup(true); notif.setIsGroup(true);
@ -173,6 +174,7 @@ public class NotificationsManager {
mLastNotificationId += 1; mLastNotificationId += 1;
mChatNotifMap.put(fromSipUri, notif); mChatNotifMap.put(fromSipUri, notif);
} }
notifMessage.setSenderBitmap(bm); notifMessage.setSenderBitmap(bm);
notif.addMessage(notifMessage); notif.addMessage(notifMessage);
notif.setIsGroup(false); notif.setIsGroup(false);
@ -184,7 +186,7 @@ public class NotificationsManager {
} }
public void displayMissedCallNotification(Call call) { public void displayMissedCallNotification(Call call) {
Intent missedCallNotifIntent = new Intent(mContext, LinphoneService.instance().getIncomingReceivedActivity()); Intent missedCallNotifIntent = new Intent(mContext, LinphoneActivity.class);
missedCallNotifIntent.putExtra("GoToHistory", true); missedCallNotifIntent.putExtra("GoToHistory", true);
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, missedCallNotifIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, missedCallNotifIntent, PendingIntent.FLAG_UPDATE_CURRENT);
@ -204,14 +206,15 @@ public class NotificationsManager {
} }
} }
} }
Notification notif = Compatibility.createMissedCallNotification(mContext, mContext.getString(R.string.missed_calls_notif_title), body, pendingIntent); Notification notif = Compatibility.createMissedCallNotification(mContext, mContext.getString(R.string.missed_calls_notif_title), body, pendingIntent);
sendNotification(MISSED_CALLS_NOTIF_ID, notif); sendNotification(MISSED_CALLS_NOTIF_ID, notif);
} }
public void displayCallNotification(Call call) { public void displayCallNotification(Call call) {
if (call == null) return;
Intent callNotifIntent = new Intent(mContext, LinphoneService.instance().getIncomingReceivedActivity()); Intent callNotifIntent = new Intent(mContext, LinphoneService.instance().getIncomingReceivedActivity());
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, callNotifIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, callNotifIntent, PendingIntent.FLAG_UPDATE_CURRENT);
if (call == null) return;
Address address = call.getRemoteAddress(); Address address = call.getRemoteAddress();
String addressAsString = address.asStringUriOnly(); String addressAsString = address.asStringUriOnly();
@ -264,7 +267,6 @@ public class NotificationsManager {
Notification notification = Compatibility.createInCallNotification(mContext, notif.getNotificationId(), Notification notification = Compatibility.createInCallNotification(mContext, notif.getNotificationId(),
showAnswerAction, mContext.getString(R.string.service_name), showAnswerAction, mContext.getString(R.string.service_name),
mContext.getString(notificationTextId), iconId, bm, name, pendingIntent); mContext.getString(notificationTextId), iconId, bm, name, pendingIntent);
sendNotification(notif.getNotificationId(), notification); sendNotification(notif.getNotificationId(), notification);
} }
@ -281,8 +283,8 @@ public class NotificationsManager {
Intent notifIntent = new Intent(mContext, LinphoneActivity.class); Intent notifIntent = new Intent(mContext, LinphoneActivity.class);
notifIntent.putExtra("GoToInapp", true); notifIntent.putExtra("GoToInapp", true);
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notif = Compatibility.createSimpleNotification(mContext, mContext.getString(R.string.inapp_notification_title), message, pendingIntent);
Notification notif = Compatibility.createSimpleNotification(mContext, mContext.getString(R.string.inapp_notification_title), message, pendingIntent);
sendNotification(IN_APP_NOTIF_ID, notif); sendNotification(IN_APP_NOTIF_ID, notif);
} }
} }