forked from mirror/monocles_chat_clean
show notification on MUC invite
This commit is contained in:
parent
fd5de32d43
commit
7a4897399f
3 changed files with 30 additions and 0 deletions
src/main
java/eu/siacs/conversations
res/values
|
@ -1130,8 +1130,10 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
|||
conversation.getMucOptions().setPassword(password);
|
||||
mXmppConnectionService.databaseBackend.updateConversation(conversation);
|
||||
final Contact contact = inviter != null ? account.getRoster().getContactFromContactList(inviter) : null;
|
||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received invite to " + jid + " (" + conversation.getName() + ") from " + contact.getJid().asBareJid());
|
||||
mXmppConnectionService.joinMuc(conversation, contact != null && contact.mutualPresenceSubscription());
|
||||
mXmppConnectionService.updateConversationUi();
|
||||
mXmppConnectionService.showInvitationNotification(conversation, contact);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -5146,6 +5146,33 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
}
|
||||
|
||||
public void showInvitationNotification(final Conversation conversation, final Contact contact) {
|
||||
final String messageId = "MUC_INVITATION_" + System.currentTimeMillis();
|
||||
final Message message = new Message(
|
||||
conversation,
|
||||
Message.STATUS_RECEIVED,
|
||||
Message.TYPE_PRIVATE,
|
||||
messageId
|
||||
);
|
||||
final String from = contact.getJid().asBareJid().toEscapedString();
|
||||
String to = conversation.getJid().toString();
|
||||
final String toDisplayName = conversation.getName().toString();
|
||||
if (toDisplayName != null && toDisplayName.length() > 0) {
|
||||
to = toDisplayName + " (" + to + ")";
|
||||
}
|
||||
message.setBody(String.format(getString(R.string.got_invitation_from),from, to));
|
||||
message.setServerMsgId(messageId);
|
||||
message.setTime(System.currentTimeMillis());
|
||||
if (conversation instanceof Conversation) {
|
||||
((Conversation) conversation).add(message);
|
||||
createMessageAsync(message);
|
||||
message.markUnread();
|
||||
updateConversationUi();
|
||||
} else {
|
||||
throw new IllegalStateException("Somehow the conversation in a message was a stub");
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnMamPreferencesFetched {
|
||||
void onPreferencesFetched(Element prefs);
|
||||
|
||||
|
|
|
@ -1097,4 +1097,5 @@
|
|||
<string name="webview_not_available">Webview is not available on your device.</string>
|
||||
<string name="pref_easy_downloader_summary">Automatically download all attachments in public channels and from strangers instead of showing a button for a manual download.</string>
|
||||
<string name="pref_easy_downloader">Automatically download all attachments</string>
|
||||
<string name="got_invitation_from">You have been invited by %s to the chat room %s.</string>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Reference in a new issue