Do not emit a notification for currently displayed chat room when receiving a message
This commit is contained in:
parent
52aef086bc
commit
de0fee9306
3 changed files with 19 additions and 19 deletions
|
@ -199,6 +199,7 @@ public class LinphoneManager implements CoreListener, ChatMessageListener, Senso
|
||||||
private Sensor mProximity;
|
private Sensor mProximity;
|
||||||
private boolean mProximitySensingEnabled;
|
private boolean mProximitySensingEnabled;
|
||||||
private boolean handsetON = false;
|
private boolean handsetON = false;
|
||||||
|
private Address mCurrentChatRoomAddress;
|
||||||
|
|
||||||
public String wizardLoginViewDomain = null;
|
public String wizardLoginViewDomain = null;
|
||||||
|
|
||||||
|
@ -1222,6 +1223,11 @@ public class LinphoneManager implements CoreListener, ChatMessageListener, Senso
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mCurrentChatRoomAddress != null && cr.getPeerAddress().asStringUriOnly().equals(mCurrentChatRoomAddress.asStringUriOnly())) {
|
||||||
|
Log.i("Message received for currently displayed chat room, do not make a notification");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Address from = message.getFromAddress();
|
Address from = message.getFromAddress();
|
||||||
String to = message.getToAddress().asString();
|
String to = message.getToAddress().asString();
|
||||||
|
|
||||||
|
@ -1231,9 +1237,9 @@ public class LinphoneManager implements CoreListener, ChatMessageListener, Senso
|
||||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(from);
|
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(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 (contact != null) {
|
||||||
LinphoneService.instance().removedNotification(to, from.asStringUriOnly(), contact.getFullName(), textMessage);
|
LinphoneService.instance().displayMessageNotification(to, from.asStringUriOnly(), contact.getFullName(), textMessage);
|
||||||
} else {
|
} else {
|
||||||
LinphoneService.instance().removedNotification(to, from.asStringUriOnly(), from.getUsername(), textMessage);
|
LinphoneService.instance().displayMessageNotification(to, from.asStringUriOnly(), from.getUsername(), textMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1241,6 +1247,10 @@ public class LinphoneManager implements CoreListener, ChatMessageListener, Senso
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCurrentChatRoomAddress(Address address) {
|
||||||
|
mCurrentChatRoomAddress = address;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEcCalibrationResult(Core lc, EcCalibratorStatus status, int delay_ms) {
|
public void onEcCalibrationResult(Core lc, EcCalibratorStatus status, int delay_ms) {
|
||||||
((AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE)).setMode(AudioManager.MODE_NORMAL);
|
((AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE)).setMode(AudioManager.MODE_NORMAL);
|
||||||
|
@ -1248,19 +1258,6 @@ public class LinphoneManager implements CoreListener, ChatMessageListener, Senso
|
||||||
Log.i("Set audio mode on 'Normal'");
|
Log.i("Set audio mode on 'Normal'");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAreDisplayAlertMessage(boolean b) {
|
|
||||||
mAreDisplayAlertMessage = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLastLcStatusMessage() {
|
|
||||||
return lastLcStatusMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removed(final Core lc, final String message) {
|
|
||||||
Log.i(message);
|
|
||||||
lastLcStatusMessage=message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onGlobalStateChanged(final Core lc, final GlobalState state, final String message) {
|
public void onGlobalStateChanged(final Core lc, final GlobalState state, final String message) {
|
||||||
Log.i("New global state [",state,"]");
|
Log.i("New global state [",state,"]");
|
||||||
if (state == Core.GlobalState.On){
|
if (state == Core.GlobalState.On){
|
||||||
|
|
|
@ -595,7 +595,7 @@ public final class LinphoneService extends Service {
|
||||||
resetIntentLaunchedOnNotificationClick();
|
resetIntentLaunchedOnNotificationClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removedNotification(String to, String fromSipUri, String fromName, String message) {
|
public void displayMessageNotification(String to, String fromSipUri, String fromName, String message) {
|
||||||
Intent notifIntent = new Intent(this, LinphoneActivity.class);
|
Intent notifIntent = new Intent(this, LinphoneActivity.class);
|
||||||
notifIntent.putExtra("GoToChat", true);
|
notifIntent.putExtra("GoToChat", true);
|
||||||
notifIntent.putExtra("ChatContactSipUri", fromSipUri);
|
notifIntent.putExtra("ChatContactSipUri", fromSipUri);
|
||||||
|
|
|
@ -261,12 +261,15 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
initChatRoom();
|
initChatRoom();
|
||||||
displayChatRoomHeader();
|
displayChatRoomHeader();
|
||||||
displayChatRoomHistory();
|
displayChatRoomHistory();
|
||||||
|
|
||||||
|
LinphoneManager.getInstance().setCurrentChatRoomAddress(mRemoteSipAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
ContactsManager.removeContactsListener(this);
|
ContactsManager.removeContactsListener(this);
|
||||||
removeVirtualKeyboardVisiblityListener();
|
removeVirtualKeyboardVisiblityListener();
|
||||||
|
LinphoneManager.getInstance().setCurrentChatRoomAddress(null);
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,7 +414,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mChatRoom = core.getChatRoomFromUri(mRemoteSipAddress.asStringUriOnly());
|
mChatRoom = core.getChatRoomFromUri(mRemoteSipAddress.asString());
|
||||||
mChatRoom.setListener(this);
|
mChatRoom.setListener(this);
|
||||||
mChatRoom.markAsRead();
|
mChatRoom.markAsRead();
|
||||||
LinphoneActivity.instance().updateMissedChatCount();
|
LinphoneActivity.instance().updateMissedChatCount();
|
||||||
|
@ -595,10 +598,10 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
if (!getResources().getBoolean(R.bool.disable_chat_message_notification)) {
|
if (!getResources().getBoolean(R.bool.disable_chat_message_notification)) {
|
||||||
String to = msg.getToAddress().asString();
|
String to = msg.getToAddress().asString();
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
LinphoneService.instance().removedNotification(to, from.asStringUriOnly(),
|
LinphoneService.instance().displayMessageNotification(to, from.asStringUriOnly(),
|
||||||
contact.getFullName(), getString(R.string.message_cant_be_decrypted_notif));
|
contact.getFullName(), getString(R.string.message_cant_be_decrypted_notif));
|
||||||
} else {
|
} else {
|
||||||
LinphoneService.instance().removedNotification(to, from.asStringUriOnly(),
|
LinphoneService.instance().displayMessageNotification(to, from.asStringUriOnly(),
|
||||||
from.getUsername(), getString(R.string.message_cant_be_decrypted_notif));
|
from.getUsername(), getString(R.string.message_cant_be_decrypted_notif));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue