use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class ChatActivity method selectChat.
private void selectChat(AccountJid accountJid, UserJid userJid) {
AbstractChat chat = MessageManager.getInstance().getOrCreateChat(accountJid, userJid);
selectChatPage(chat, true);
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class ChatActivity method createSendIntent.
/**
* Create intent to send message.
* <p/>
* Contact list will not be shown on when chat will be closed.
* @param text if <code>null</code> then user will be able to send a number
* of messages. Else only one message can be send.
*/
public static Intent createSendIntent(Context context, AccountJid account, UserJid user, String text) {
Intent intent = ChatActivity.createSpecificChatIntent(context, account, user);
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, text);
AbstractChat chat = MessageManager.getInstance().getChat(account, user);
intent.putExtra(KEY_SHOW_ARCHIVED, chat != null && chat.isArchived());
return intent;
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class ChatActivity method setUpOptionsMenu.
private void setUpOptionsMenu(Menu menu) {
AbstractChat abstractChat = MessageManager.getInstance().getChat(account, user);
if (abstractChat != null) {
menu.clear();
MenuInflater inflater = getMenuInflater();
if (selectedPagePosition == PAGE_POSITION_RECENT_CHATS) {
inflater.inflate(R.menu.menu_chat_recent_list, menu);
setUpRecentChatsMenu(menu, abstractChat);
return;
}
if (selectedPagePosition == PAGE_POSITION_CHAT_INFO) {
inflater.inflate(R.menu.toolbar_contact, menu);
setUpContactInfoMenu(menu, abstractChat);
if (abstractChat instanceof RoomChat)
setUpMUCInfoMenu(menu, abstractChat);
return;
}
if (abstractChat instanceof RoomChat) {
inflater.inflate(R.menu.menu_chat_muc, menu);
setUpMUCMenu(menu, abstractChat);
return;
}
if (abstractChat instanceof RegularChat) {
inflater.inflate(R.menu.menu_chat_regular, menu);
setUpRegularChatMenu(menu, abstractChat);
return;
}
}
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class ChatActivity method handleOtrIntent.
private void handleOtrIntent(Intent intent) {
String account = intent.getStringExtra(KEY_ACCOUNT);
String user = intent.getStringExtra(KEY_USER);
String question = intent.getStringExtra(KEY_QUESTION);
if (account != null && user != null) {
try {
AccountJid accountJid = AccountJid.from(account);
UserJid userJid = UserJid.from(user);
AbstractChat chat = MessageManager.getInstance().getOrCreateChat(accountJid, userJid);
if (chat != null && chat instanceof RegularChat) {
if (intent.getBooleanExtra(EXTRA_OTR_PROGRESS, false)) {
((RegularChat) chat).setIntent(QuestionActivity.createCancelIntent(Application.getInstance(), accountJid, userJid));
} else {
((RegularChat) chat).setIntent(QuestionActivity.createIntent(Application.getInstance(), accountJid, userJid, question != null, true, question));
}
}
} catch (UserJid.UserJidCreateException | XmppStringprepException e) {
e.printStackTrace();
}
}
getIntent().removeExtra(EXTRA_OTR_REQUEST);
getIntent().removeExtra(EXTRA_OTR_PROGRESS);
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class BookmarksManager method onAuthorized.
public void onAuthorized(AccountJid account) {
cleanCache(account);
List<BookmarkedConference> conferences = getConferencesFromBookmarks(account);
if (!conferences.isEmpty()) {
for (BookmarkedConference conference : conferences) {
if (!MUCManager.getInstance().hasRoom(account, conference.getJid())) {
createMUC(account, conference);
LogManager.d(this, " Conference " + conference.getJid() + "was added to roster from bookmarks");
}
}
}
// Check bookmarks on first run new Xabber. Adding all conferences to bookmarks.
if (!isBookmarkCheckedByXabber(account)) {
// add conferences from phone to bookmarks
Collection<AbstractChat> chats = MessageManager.getInstance().getChats(account);
if (!chats.isEmpty()) {
for (AbstractChat chat : chats) {
if (chat instanceof RoomChat) {
RoomChat roomChat = (RoomChat) chat;
if (!hasConference(conferences, roomChat.getTo())) {
addConferenceToBookmarks(account, roomChat.getTo().toString(), roomChat.getTo(), roomChat.getNickname());
}
}
}
}
// add url about check to bookmarks
addUrlToBookmarks(account, XABBER_URL, XABBER_NAME, false);
}
Collection<AbstractChat> chats = MessageManager.getInstance().getChats(account);
if (!chats.isEmpty()) {
for (AbstractChat chat : chats) {
if (chat instanceof RoomChat) {
if (!hasConference(conferences, ((RoomChat) chat).getTo())) {
removeMUC(account, chat.getUser());
LogManager.d(this, " Conference " + chat.getTo().toString() + " was deleted from phone");
}
}
}
}
}
Aggregations