From 131a252ca5b05c7bf2876651129b9cd29ea4214d Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 25 Sep 2012 14:51:15 +0200 Subject: [PATCH] Fix notification issues + don't automatically show virtual keyboard when coming back to chat fragment from notification --- AndroidManifest.xml | 2 +- src/org/linphone/LinphoneActivity.java | 8 ++++---- src/org/linphone/LinphoneService.java | 14 +++++++++----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 3e98b775f..1c489749b 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -34,7 +34,7 @@ diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java index 389f3ecb4..730db276d 100644 --- a/src/org/linphone/LinphoneActivity.java +++ b/src/org/linphone/LinphoneActivity.java @@ -580,14 +580,14 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene public void updateDialerFragment(DialerFragment fragment) { dialerFragment = fragment; - // Hack to maintain ADJUST_PAN flag - getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); + // Hack to maintain soft input flags + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); } public void updateChatFragment(ChatFragment fragment) { messageListenerFragment = fragment; - // Hack to maintain ADJUST_PAN flag - getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); + // Hack to maintain soft input flags + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); } public void updateChatListFragment(ChatListFragment fragment) { diff --git a/src/org/linphone/LinphoneService.java b/src/org/linphone/LinphoneService.java index fcf45e66e..e65253be3 100644 --- a/src/org/linphone/LinphoneService.java +++ b/src/org/linphone/LinphoneService.java @@ -158,7 +158,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis Intent notifIntent = new Intent(this, incomingReceivedActivity); notifIntent.putExtra("Notification", true); - mNotifContentIntent = PendingIntent.getActivity(this, 0, notifIntent, PendingIntent.FLAG_CANCEL_CURRENT); + mNotifContentIntent = PendingIntent.getActivity(this, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT); Compatibility.setNotificationLatestEventInfo(mNotif, this, mNotificationTitle, "", mNotifContentIntent); @@ -271,7 +271,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis } public void addNotification(Intent onClickIntent, int iconResourceID, String title, String message) { - PendingIntent notifContentIntent = PendingIntent.getActivity(this, 0, onClickIntent, PendingIntent.FLAG_CANCEL_CURRENT); + PendingIntent notifContentIntent = PendingIntent.getActivity(this, 0, onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT); if (mCustomNotif == null) { mCustomNotif = new Notification(); @@ -295,7 +295,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis notifIntent.putExtra("GoToChat", true); notifIntent.putExtra("ChatContactSipUri", fromSipUri); - PendingIntent notifContentIntent = PendingIntent.getActivity(this, 0, notifIntent, PendingIntent.FLAG_CANCEL_CURRENT); + PendingIntent notifContentIntent = PendingIntent.getActivity(this, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT); if (fromName == null) { fromName = fromSipUri; @@ -321,6 +321,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis public void removeMessageNotification() { mNM.cancel(MESSAGE_NOTIF_ID); + resetIntentLaunchedOnNotificationClick(); } private static final Class[] mSetFgSign = new Class[] {boolean.class}; @@ -523,9 +524,12 @@ public final class LinphoneService extends Service implements LinphoneServiceLis public void setActivityToLaunchOnIncomingReceived(Class activity) { incomingReceivedActivity = activity; - + resetIntentLaunchedOnNotificationClick(); + } + + private void resetIntentLaunchedOnNotificationClick() { Intent notifIntent = new Intent(this, incomingReceivedActivity); - mNotifContentIntent = PendingIntent.getActivity(this, 0, notifIntent, 0); + mNotifContentIntent = PendingIntent.getActivity(this, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT); Compatibility.setNotificationLatestEventInfo(mNotif, this, mNotificationTitle, "", mNotifContentIntent); }