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();
|
LinphoneService.instance().removeMessageNotification();
|
||||||
|
|
||||||
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
|
LinphoneActivity.instance().updateChatFragment(null);
|
||||||
|
}
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.removeListener(mListener);
|
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)) {
|
if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
|
||||||
LinphoneActivity.instance().hideStatusBar();
|
LinphoneActivity.instance().hideStatusBar();
|
||||||
}
|
}
|
||||||
|
LinphoneActivity.instance().updateChatFragment(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
String draft = getArguments().getString("messageDraft");
|
String draft = getArguments().getString("messageDraft");
|
||||||
|
|
|
@ -102,6 +102,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
private FragmentsAvailable currentFragment, nextFragment;
|
private FragmentsAvailable currentFragment, nextFragment;
|
||||||
private List<FragmentsAvailable> fragmentsHistory;
|
private List<FragmentsAvailable> fragmentsHistory;
|
||||||
private Fragment dialerFragment, messageListFragment, friendStatusListenerFragment;
|
private Fragment dialerFragment, messageListFragment, friendStatusListenerFragment;
|
||||||
|
private ChatFragment chatFragment;
|
||||||
private SavedState dialerSavedState;
|
private SavedState dialerSavedState;
|
||||||
private boolean isAnimationDisabled = false, preferLinphoneContacts = false;
|
private boolean isAnimationDisabled = false, preferLinphoneContacts = false;
|
||||||
private OrientationEventListener mOrientationHelper;
|
private OrientationEventListener mOrientationHelper;
|
||||||
|
@ -599,6 +600,15 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
changeCurrentFragment(FragmentsAvailable.ABOUT, null);
|
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) {
|
public void displayChat(String sipUri) {
|
||||||
if (getResources().getBoolean(R.bool.disable_chat)) {
|
if (getResources().getBoolean(R.bool.disable_chat)) {
|
||||||
return;
|
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);
|
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) {
|
public void updateChatListFragment(ChatListFragment fragment) {
|
||||||
messageListFragment = fragment;
|
messageListFragment = fragment;
|
||||||
}
|
}
|
||||||
|
|
|
@ -717,10 +717,12 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
try {
|
try {
|
||||||
Contact contact = ContactsManager.getInstance().findContactWithAddress(mServiceContext.getContentResolver(),from);
|
Contact contact = ContactsManager.getInstance().findContactWithAddress(mServiceContext.getContentResolver(),from);
|
||||||
if (!mServiceContext.getResources().getBoolean(R.bool.disable_chat__message_notification)) {
|
if (!mServiceContext.getResources().getBoolean(R.bool.disable_chat__message_notification)) {
|
||||||
if(contact != null) {
|
if(LinphoneActivity.isInstanciated() && !LinphoneActivity.instance().displayChatMessageNotification(from.asStringUriOnly())) {
|
||||||
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), contact.getName(), textMessage);
|
if (contact != null) {
|
||||||
} else {
|
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), contact.getName(), textMessage);
|
||||||
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), from.getUserName(), textMessage);
|
} else {
|
||||||
|
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), from.getUserName(), textMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class ApiTwentyOnePlus {
|
||||||
.setSmallIcon(R.drawable.chat_icon_over)
|
.setSmallIcon(R.drawable.chat_icon_over)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setContentIntent(intent)
|
.setContentIntent(intent)
|
||||||
|
.setDefaults(Notification.DEFAULT_ALL)
|
||||||
.setLargeIcon(contactIcon)
|
.setLargeIcon(contactIcon)
|
||||||
.setCategory(Notification.CATEGORY_MESSAGE)
|
.setCategory(Notification.CATEGORY_MESSAGE)
|
||||||
.setVisibility(Notification.VISIBILITY_PRIVATE)
|
.setVisibility(Notification.VISIBILITY_PRIVATE)
|
||||||
|
|
Loading…
Reference in a new issue