use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class ContactVcardViewerFragment method fillResourceList.
private void fillResourceList(AccountJid account, Jid bareAddress, List<View> resourcesList) {
final List<Presence> allPresences = RosterManager.getInstance().getPresences(account, bareAddress);
boolean isAccount = account.getFullJid().asBareJid().equals(user.getBareJid());
Resourcepart accountResource = null;
if (isAccount) {
// TODO: probably not the best way to get own resource
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
if (accountItem != null) {
accountResource = accountItem.getConnection().getConfiguration().getResource();
}
}
PresenceManager.sortPresencesByPriority(allPresences);
for (Presence presence : allPresences) {
Jid fromJid = presence.getFrom();
ClientInfo clientInfo = CapabilitiesManager.getInstance().getCachedClientInfo(fromJid);
String client = "";
if (clientInfo == null) {
client = getString(R.string.please_wait);
CapabilitiesManager.getInstance().requestClientInfoByUser(account, fromJid);
} else if (clientInfo == ClientInfo.INVALID_CLIENT_INFO) {
client = getString(R.string.unknown);
} else {
String name = clientInfo.getName();
if (name != null) {
client = name;
}
String type = clientInfo.getType();
if (type != null) {
if (client.isEmpty()) {
client = type;
} else {
client = client + "/" + type;
}
}
}
int priorityValue = presence.getPriority();
String priorityString;
if (priorityValue == Integer.MIN_VALUE) {
priorityString = getString(R.string.account_priority) + ": " + getString(R.string.unknown);
} else {
priorityString = getString(R.string.account_priority) + ": " + priorityValue;
}
if (!client.isEmpty()) {
client = getString(R.string.contact_viewer_client) + ": " + client;
}
Resourcepart resourceOrNull = fromJid.getResourceOrNull();
String resource = getString(R.string.account_resource) + ": " + resourceOrNull;
final StatusMode statusMode = StatusMode.createStatusMode(presence);
String status = presence.getStatus();
if (TextUtils.isEmpty(status)) {
status = getString(statusMode.getStringID());
}
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View resourceView = inflater.inflate(R.layout.item_contact_info, xmppItems, false);
resourceView.findViewById(R.id.contact_info_item_secondary);
((TextView) resourceView.findViewById(R.id.contact_info_item_secondary)).setText(client);
((TextView) resourceView.findViewById(R.id.contact_info_item_main)).setText(status);
((TextView) resourceView.findViewById(R.id.contact_info_item_secondary_second_line)).setText(resource);
resourceView.findViewById(R.id.contact_info_item_secondary_second_line).setVisibility(View.VISIBLE);
((TextView) resourceView.findViewById(R.id.contact_info_item_secondary_third_line)).setText(priorityString);
resourceView.findViewById(R.id.contact_info_item_secondary_third_line).setVisibility(View.VISIBLE);
if (isAccount && resourceOrNull != null && resourceOrNull.equals(accountResource)) {
TextView thisDeviceIndicatorTextView = (TextView) resourceView.findViewById(R.id.contact_info_item_secondary_forth_line);
thisDeviceIndicatorTextView.setTextColor(ColorManager.getInstance().getAccountPainter().getAccountSendButtonColor(account));
thisDeviceIndicatorTextView.setText(R.string.contact_viewer_this_device);
thisDeviceIndicatorTextView.setVisibility(View.VISIBLE);
}
ImageView statusIcon = (ImageView) resourceView.findViewById(R.id.contact_info_right_icon);
statusIcon.setVisibility(View.VISIBLE);
statusIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_status));
statusIcon.setImageLevel(statusMode.getStatusLevel());
resourcesList.add(resourceView);
}
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class ContextMenuHelper method createContactContextMenu.
public static void createContactContextMenu(final Activity activity, ContactListPresenter presenter, AbstractContact abstractContact, ContextMenu menu) {
final AccountJid account = abstractContact.getAccount();
final UserJid user = abstractContact.getUser();
menu.setHeaderTitle(abstractContact.getName());
MenuInflater inflater = activity.getMenuInflater();
inflater.inflate(R.menu.item_contact, menu);
setContactContextMenuActions(activity, presenter, menu, account, user);
setContactContextMenuItemsVisibilty(abstractContact, menu, account, user);
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class AccountInfoEditorActivity method onCreate.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_with_toolbar_and_container);
Intent intent = getIntent();
AccountJid account = getAccount(intent);
String vCard = intent.getStringExtra(ARG_VCARD);
if (AccountManager.getInstance().getAccount(account) == null) {
Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
setResult(RESULT_CANCELED);
finish();
}
toolbar = (Toolbar) findViewById(R.id.toolbar_default);
toolbar.setNavigationIcon(R.drawable.ic_clear_white_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
toolbar.setTitle(R.string.edit_account_user_info);
BarPainter barPainter = new BarPainter(this, toolbar);
barPainter.updateWithAccountName(account);
toolbar.inflateMenu(SAVE_MENU);
toolbar.setOnMenuItemClickListener(this);
boolean isSaveButtonEnabled = false;
if (savedInstanceState == null) {
getFragmentManager().beginTransaction().add(R.id.fragment_container, AccountInfoEditorFragment.newInstance(account, vCard)).commit();
} else {
isSaveButtonEnabled = savedInstanceState.getBoolean(ARGUMENT_SAVE_BUTTON_ENABLED);
}
toolbar.getMenu().findItem(R.id.action_save).setEnabled(isSaveButtonEnabled);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class ChatActivity method getInitialChatFromIntent.
private void getInitialChatFromIntent() {
Intent intent = getIntent();
AccountJid newAccount = getAccount(intent);
UserJid newUser = getUser(intent);
if (newAccount != null) {
this.account = newAccount;
}
if (newUser != null) {
this.user = newUser;
}
LogManager.i(LOG_TAG, "getInitialChatFromIntent " + this.user);
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class ChatActivity method getAccount.
@Nullable
private static AccountJid getAccount(Intent intent) {
AccountJid value = EntityIntentBuilder.getAccount(intent);
if (value != null)
return value;
// Backward compatibility.
String stringExtra = intent.getStringExtra("com.xabber.android.data.account");
if (stringExtra == null) {
return null;
}
try {
return AccountJid.from(stringExtra);
} catch (XmppStringprepException e) {
LogManager.exception(LOG_TAG, e);
return null;
}
}
Aggregations