Fix chat notifications on lollipop
This commit is contained in:
parent
80ff8aa3f8
commit
25144d93b7
4 changed files with 26 additions and 4 deletions
|
@ -438,6 +438,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
|
||||
LinphoneService.instance().removeMessageNotification();
|
||||
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().updateChatFragment(null);
|
||||
}
|
||||
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
if (lc != null) {
|
||||
lc.removeListener(mListener);
|
||||
|
@ -462,6 +466,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
|
||||
LinphoneActivity.instance().hideStatusBar();
|
||||
}
|
||||
LinphoneActivity.instance().updateChatFragment(this);
|
||||
}
|
||||
|
||||
String draft = getArguments().getString("messageDraft");
|
||||
|
|
|
@ -102,6 +102,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
private FragmentsAvailable currentFragment, nextFragment;
|
||||
private List<FragmentsAvailable> fragmentsHistory;
|
||||
private Fragment dialerFragment, messageListFragment, friendStatusListenerFragment;
|
||||
private ChatFragment chatFragment;
|
||||
private SavedState dialerSavedState;
|
||||
private boolean isAnimationDisabled = false, preferLinphoneContacts = false;
|
||||
private OrientationEventListener mOrientationHelper;
|
||||
|
@ -599,6 +600,15 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
changeCurrentFragment(FragmentsAvailable.ABOUT, null);
|
||||
}
|
||||
|
||||
public boolean displayChatMessageNotification(String address){
|
||||
if(chatFragment != null) {
|
||||
if(chatFragment.getSipUri().equals(address)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void displayChat(String sipUri) {
|
||||
if (getResources().getBoolean(R.bool.disable_chat)) {
|
||||
return;
|
||||
|
@ -744,6 +754,10 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
}
|
||||
|
||||
public void updateChatFragment(ChatFragment fragment) {
|
||||
chatFragment = fragment;
|
||||
}
|
||||
|
||||
public void updateChatListFragment(ChatListFragment fragment) {
|
||||
messageListFragment = fragment;
|
||||
}
|
||||
|
|
|
@ -717,10 +717,12 @@ public class LinphoneManager implements LinphoneCoreListener {
|
|||
try {
|
||||
Contact contact = ContactsManager.getInstance().findContactWithAddress(mServiceContext.getContentResolver(),from);
|
||||
if (!mServiceContext.getResources().getBoolean(R.bool.disable_chat__message_notification)) {
|
||||
if(contact != null) {
|
||||
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), contact.getName(), textMessage);
|
||||
} else {
|
||||
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), from.getUserName(), textMessage);
|
||||
if(LinphoneActivity.isInstanciated() && !LinphoneActivity.instance().displayChatMessageNotification(from.asStringUriOnly())) {
|
||||
if (contact != null) {
|
||||
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), contact.getName(), textMessage);
|
||||
} else {
|
||||
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), from.getUserName(), textMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -50,6 +50,7 @@ public class ApiTwentyOnePlus {
|
|||
.setSmallIcon(R.drawable.chat_icon_over)
|
||||
.setAutoCancel(true)
|
||||
.setContentIntent(intent)
|
||||
.setDefaults(Notification.DEFAULT_ALL)
|
||||
.setLargeIcon(contactIcon)
|
||||
.setCategory(Notification.CATEGORY_MESSAGE)
|
||||
.setVisibility(Notification.VISIBILITY_PRIVATE)
|
||||
|
|
Loading…
Reference in a new issue