use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class AccountRosterListener method onRosterLoaded.
@Override
public void onRosterLoaded(Roster roster) {
LogManager.i(getLogTag(), "onRosterLoaded");
final AccountItem accountItem = AccountManager.getInstance().getAccount(AccountRosterListener.this.account);
if (accountItem != null) {
for (OnRosterReceivedListener listener : Application.getInstance().getManagers(OnRosterReceivedListener.class)) {
listener.onRosterReceived(accountItem);
}
}
AccountManager.getInstance().onAccountChanged(AccountRosterListener.this.account);
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class ContextMenuHelper method setUpAccountMenu.
public static void setUpAccountMenu(final FragmentActivity activity, final UpdatableAdapter adapter, final String account, Menu menu) {
final AccountItem accountItem = AccountManager.getInstance().getAccount(account);
ConnectionState state = accountItem.getState();
if (state == ConnectionState.waiting) {
menu.findItem(R.id.action_reconnect_account).setVisible(true).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (accountItem.updateConnection(true))
AccountManager.getInstance().onAccountChanged(account);
return true;
}
});
}
menu.findItem(R.id.action_edit_account_status).setIntent(StatusEditor.createIntent(activity, account));
menu.findItem(R.id.action_edit_account).setIntent(AccountViewer.createAccountPreferencesIntent(activity, account));
if (state.isConnected()) {
menu.findItem(R.id.action_contact_info).setVisible(true).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
activity.startActivity(AccountViewer.createAccountInfoIntent(activity, account));
return true;
}
});
menu.findItem(R.id.action_add_contact).setVisible(true).setIntent(ContactAdd.createIntent(activity, account));
}
if (SettingsManager.contactsShowAccounts()) {
menu.findItem(R.id.action_set_up_offline_contacts).setVisible(true).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
ContextMenuHelper.createOfflineContactsDialog(activity, adapter, account, GroupManager.IS_ACCOUNT).show();
return true;
}
});
}
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class CarbonManager method onPacket.
@Override
public void onPacket(ConnectionItem connection, String bareAddress, Stanza packet) {
if (!(connection instanceof AccountItem)) {
return;
}
if (!SettingsManager.connectionUseCarbons()) {
return;
}
final String user = packet.getFrom();
if (user == null)
return;
if (!(packet instanceof Message))
return;
final Message message = (Message) packet;
if (!getCarbonsEnabled()) {
return;
}
ExtensionElement carbonExtension = null;
Direction dir = null;
for (ExtensionElement packetExtension : message.getExtensions()) {
if (packetExtension instanceof Received) {
carbonExtension = packetExtension;
dir = Direction.received;
} else if (packetExtension instanceof Sent) {
carbonExtension = packetExtension;
dir = Direction.sent;
}
}
if (carbonExtension == null) {
return;
}
Forwarded forwarded;
if (dir == Direction.sent) {
Sent carbon = (Sent) carbonExtension;
forwarded = carbon.getForwarded();
} else {
Received carbon = (Received) carbonExtension;
forwarded = carbon.getForwarded();
}
if (forwarded == null) {
return;
}
Message forwardedMsg = (Message) forwarded.getForwardedPacket();
MessageManager.getInstance().displayForwardedMessage(connection, forwardedMsg, dir);
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class StatusEditor method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing()) {
return;
}
actionWithItem = null;
setContentView(R.layout.status_editor);
Toolbar toolbar = (Toolbar) findViewById(R.id.top_toolbar);
toolbar.setNavigationIcon(R.drawable.ic_clear_white_24dp);
setTitle(null);
setSupportActionBar(toolbar);
Intent intent = getIntent();
account = StatusEditor.getAccount(intent);
BarPainter barPainter = new BarPainter(this, toolbar);
if (account != null) {
barPainter.updateWithAccountName(account);
} else {
barPainter.setDefaultColor();
}
ListView listView = getListView();
listView.setOnItemClickListener(this);
registerForContextMenu(listView);
adapter = new StatusEditorAdapter(this);
View footerView = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.status_history_footer, null, false);
footerView.findViewById(R.id.clear_status_history_button).setOnClickListener(this);
listView.addFooterView(footerView);
setListAdapter(adapter);
statusTextView = (EditText) findViewById(R.id.status_text);
statusModeView = (Spinner) findViewById(R.id.status_icon);
statusModeView.setAdapter(new StatusModeAdapter(this));
savedStatusesTextView = findViewById(R.id.saved_statuses_textview);
StatusMode statusMode;
String statusText;
if (savedInstanceState == null) {
if (account == null) {
statusMode = SettingsManager.statusMode();
statusText = SettingsManager.statusText();
} else {
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
if (accountItem == null) {
Application.getInstance().onError(R.string.NO_SUCH_ACCOUNT);
finish();
return;
}
statusMode = accountItem.getFactualStatusMode();
statusText = accountItem.getStatusText();
}
} else {
statusMode = StatusMode.valueOf(savedInstanceState.getString(SAVED_MODE));
statusText = savedInstanceState.getString(SAVED_TEXT);
}
showStatus(statusMode, statusText);
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class GroupedContactAdapter method getGroupView.
private View getGroupView(int position, View convertView, ViewGroup parent) {
final View view;
final GroupViewHolder viewHolder;
if (convertView == null) {
view = layoutInflater.inflate(R.layout.base_group_item, parent, false);
viewHolder = new GroupViewHolder(view);
view.setTag(viewHolder);
} else {
view = convertView;
viewHolder = (GroupViewHolder) view.getTag();
}
final GroupConfiguration configuration = (GroupConfiguration) getItem(position);
final int level = AccountManager.getInstance().getColorLevel(configuration.getAccount());
final String name = GroupManager.getInstance().getGroupName(configuration.getAccount(), configuration.getUser());
viewHolder.indicator.setImageLevel(configuration.isExpanded() ? 1 : 0);
viewHolder.groupOfflineIndicator.setImageLevel(configuration.getShowOfflineMode().ordinal());
int color;
viewHolder.groupOfflineIndicator.setVisibility(View.GONE);
viewHolder.offlineShadow.setVisibility(View.GONE);
if (configuration.getUser().equals(GroupManager.ACTIVE_CHATS)) {
color = activeChatsColor;
viewHolder.name.setText(name);
} else {
viewHolder.name.setText(String.format("%s (%d/%d)", name, configuration.getOnline(), configuration.getTotal()));
color = accountSubgroupColors[level];
viewHolder.groupOfflineIndicator.setVisibility(View.VISIBLE);
AccountItem accountItem = AccountManager.getInstance().getAccount(configuration.getAccount());
if (accountItem != null) {
StatusMode statusMode = accountItem.getDisplayStatusMode();
if (statusMode == StatusMode.unavailable || statusMode == StatusMode.connection) {
viewHolder.offlineShadow.setVisibility(View.VISIBLE);
}
}
}
view.setBackgroundDrawable(new ColorDrawable(color));
return view;
}
Aggregations