use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class OccupantListFragment method onItemClick.
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
com.xabber.android.data.extension.muc.Occupant occupant = (com.xabber.android.data.extension.muc.Occupant) listAdapter.getItem(position);
LogManager.i(this, occupant.getNickname().toString());
UserJid occupantFullJid = null;
try {
occupantFullJid = UserJid.from(JidCreate.entityFullFrom(room, occupant.getNickname()));
} catch (UserJid.UserJidCreateException e) {
LogManager.exception(this, e);
return;
}
final AbstractChat mucPrivateChat;
try {
mucPrivateChat = MessageManager.getInstance().getOrCreatePrivateMucChat(account, occupantFullJid.getJid().asFullJidIfPossible());
} catch (UserJid.UserJidCreateException e) {
LogManager.exception(this, e);
return;
}
mucPrivateChat.setIsPrivateMucChatAccepted(true);
startActivity(ChatActivity.createSpecificChatIntent(getActivity(), account, occupantFullJid));
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class RecentChatFragment method onItemClick.
@Override
public boolean onItemClick(int position) {
ChatVO chat = (ChatVO) adapter.getItem(position);
if (listener != null && chat != null) {
AbstractChat abstractChat = MessageManager.getInstance().getOrCreateChat(chat.getAccountJid(), chat.getUserJid());
if (abstractChat != null)
abstractChat.resetUnreadMessageCount();
listener.onChatSelected(chat.getAccountJid(), chat.getUserJid());
}
return true;
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class ContextMenuHelper method setContactContextMenuActions.
private static void setContactContextMenuActions(final Activity activity, final ContactListPresenter presenter, ContextMenu menu, final AccountJid account, final UserJid user) {
// menu.findItem(R.id.action_chat).setOnMenuItemClickListener(
// new MenuItem.OnMenuItemClickListener() {
//
// @Override
// public boolean onMenuItemClick(MenuItem item) {
// MessageManager.getInstance().openChat(account, user);
// activity.startActivity(ChatActivity.createSpecificChatIntent(
// activity, account, user));
// return true;
// }
// });
menu.findItem(R.id.action_edit_conference).setIntent(ConferenceAddActivity.createIntent(activity, account, user.getBareUserJid()));
menu.findItem(R.id.action_delete_conference).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
MUCDeleteDialogFragment.newInstance(account, user).show(activity.getFragmentManager(), "MUC_DELETE");
return true;
}
});
menu.findItem(R.id.action_join_conference).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
MUCManager.getInstance().joinRoom(account, user.getJid().asEntityBareJidIfPossible(), true);
return true;
}
});
menu.findItem(R.id.action_leave_conference).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
MUCManager.getInstance().leaveRoom(account, user.getJid().asEntityBareJidIfPossible());
MessageManager.getInstance().closeChat(account, user);
NotificationManager.getInstance().removeMessageNotification(account, user);
presenter.updateContactList();
return true;
}
});
// menu.findItem(R.id.action_contact_info).setIntent(
// ContactEditActivity.createIntent(activity, account, user));
menu.findItem(R.id.action_edit_contact_groups).setIntent(GroupEditActivity.createIntent(activity, account, user));
menu.findItem(R.id.action_delete_contact).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
ContactDeleteDialogFragment.newInstance(account, user).show(activity.getFragmentManager(), "CONTACT_DELETE");
return true;
}
});
menu.findItem(R.id.action_block_contact).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
BlockContactDialog.newInstance(account, user).show(activity.getFragmentManager(), BlockContactDialog.class.getName());
return true;
}
});
// menu.findItem(R.id.action_close_chat).setOnMenuItemClickListener(
// new MenuItem.OnMenuItemClickListener() {
//
// @Override
// public boolean onMenuItemClick(MenuItem item) {
// MessageManager.getInstance().closeChat(account,
// user);
// NotificationManager.getInstance()
// .removeMessageNotification(account,
// user);
// adapter.onChange();
// return true;
// }
//
// });
// menu.findItem(R.id.action_request_subscription)
// .setOnMenuItemClickListener(
// new MenuItem.OnMenuItemClickListener() {
//
// @Override
// public boolean onMenuItemClick(MenuItem item) {
// try {
// PresenceManager.getInstance()
// .requestSubscription(
// account, user);
// } catch (NetworkException e) {
// Application.getInstance()
// .onError(e);
// }
// return true;
// }
//
// });
menu.findItem(R.id.action_accept_subscription).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
try {
PresenceManager.getInstance().acceptSubscription(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
activity.startActivity(GroupEditActivity.createIntent(activity, account, user));
return true;
}
});
menu.findItem(R.id.action_discard_subscription).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
try {
PresenceManager.getInstance().discardSubscription(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
return true;
}
});
// menu.findItem(R.id.action_archive_chat).setOnMenuItemClickListener(
// new MenuItem.OnMenuItemClickListener() {
// @Override
// public boolean onMenuItemClick(MenuItem item) {
// AbstractChat chat = MessageManager.getInstance().getChat(account, user);
// if (chat != null) chat.setArchived(true, true);
// adapter.onChange();
// return true;
// }
// });
//
// menu.findItem(R.id.action_unarchive_chat).setOnMenuItemClickListener(
// new MenuItem.OnMenuItemClickListener() {
// @Override
// public boolean onMenuItemClick(MenuItem item) {
// AbstractChat chat = MessageManager.getInstance().getChat(account, user);
// if (chat != null) chat.setArchived(false, true);
// adapter.onChange();
// return true;
// }
// });
menu.findItem(R.id.action_mute_chat).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
AbstractChat chat = MessageManager.getInstance().getChat(account, user);
if (chat != null)
chat.setNotificationState(new NotificationState(NotificationState.NotificationMode.disabled, 0), true);
presenter.updateContactList();
return true;
}
});
menu.findItem(R.id.action_unmute_chat).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
AbstractChat chat = MessageManager.getInstance().getChat(account, user);
if (chat != null)
chat.setNotificationState(new NotificationState(NotificationState.NotificationMode.enabled, 0), true);
presenter.updateContactList();
return true;
}
});
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class ContextMenuHelper method setContactContextMenuItemsVisibilty.
private static void setContactContextMenuItemsVisibilty(AbstractContact abstractContact, ContextMenu menu, AccountJid account, UserJid user) {
if (!MUCManager.getInstance().hasRoom(account, user)) {
// is not conference
menu.findItem(R.id.action_edit_conference).setVisible(false);
menu.findItem(R.id.action_delete_conference).setVisible(false);
menu.findItem(R.id.action_leave_conference).setVisible(false);
menu.findItem(R.id.action_join_conference).setVisible(false);
if (RosterManager.getInstance().getRosterContact(account, user) == null) {
menu.findItem(R.id.action_delete_contact).setVisible(false);
}
// if (!MessageManager.getInstance().hasActiveChat(account, user)) {
// menu.findItem(R.id.action_close_chat).setVisible(false);
// }
Boolean supported = BlockingManager.getInstance().isSupported(account);
if ((supported == null || !supported) && !MUCManager.getInstance().isMucPrivateChat(account, user)) {
menu.findItem(R.id.action_block_contact).setVisible(false);
}
// if (abstractContact.isSubscribed()) {
// menu.findItem(R.id.action_request_subscription).setVisible(false);
// }
} else {
// is conference
// menu.findItem(R.id.action_contact_info).setVisible(false);
menu.findItem(R.id.action_edit_contact_groups).setVisible(false);
menu.findItem(R.id.action_delete_contact).setVisible(false);
menu.findItem(R.id.action_block_contact).setVisible(false);
if (MUCManager.getInstance().inUse(account, user.getJid().asEntityBareJidIfPossible())) {
menu.findItem(R.id.action_edit_conference).setVisible(false);
}
if (MUCManager.getInstance().isDisabled(account, user.getJid().asEntityBareJidIfPossible())) {
menu.findItem(R.id.action_leave_conference).setVisible(false);
} else {
menu.findItem(R.id.action_join_conference).setVisible(false);
}
}
if (!PresenceManager.getInstance().hasSubscriptionRequest(account, user)) {
menu.findItem(R.id.action_accept_subscription).setVisible(false);
menu.findItem(R.id.action_discard_subscription).setVisible(false);
}
// archive/unarchive chat
AbstractChat chat = MessageManager.getInstance().getChat(account, user);
// if (chat != null) {
// menu.findItem(R.id.action_archive_chat).setVisible(!chat.isArchived());
// menu.findItem(R.id.action_unarchive_chat).setVisible(chat.isArchived());
// }
// mute chat
menu.findItem(R.id.action_mute_chat).setVisible(chat != null && chat.notifyAboutMessage());
menu.findItem(R.id.action_unmute_chat).setVisible(chat != null && !chat.notifyAboutMessage());
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class ChatActivity method getNotifMode.
private NotificationState.NotificationMode getNotifMode() {
AbstractChat chat = MessageManager.getInstance().getOrCreateChat(account, user);
NotificationState.NotificationMode mode = NotificationState.NotificationMode.bydefault;
if (chat != null) {
boolean defaultValue = chat instanceof RegularChat ? SettingsManager.eventsOnChat() : SettingsManager.eventsOnMuc();
if (chat.getNotificationState().getMode() == NotificationState.NotificationMode.enabled && !defaultValue)
mode = NotificationState.NotificationMode.enabled;
if (chat.getNotificationState().getMode() == NotificationState.NotificationMode.disabled && defaultValue)
mode = NotificationState.NotificationMode.disabled;
}
return mode;
}
Aggregations