use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.
the class ContactListManagerAdapter method updateAvatarsContent.
void updateAvatarsContent(Contact[] contacts) {
ArrayList<ContentValues> avatars = new ArrayList<ContentValues>();
ArrayList<String> usernames = new ArrayList<String>();
for (Contact contact : contacts) {
byte[] avatarData = contact.getPresence().getAvatarData();
if (avatarData == null) {
continue;
}
String username = mAdaptee.normalizeAddress(contact.getAddress().getAddress());
ContentValues values = new ContentValues(2);
values.put(Imps.Avatars.CONTACT, username);
values.put(Imps.Avatars.DATA, avatarData);
avatars.add(values);
usernames.add(username);
}
if (avatars.size() > 0) {
// ImProvider will replace the avatar content if it already exist.
mResolver.bulkInsert(mAvatarUrl, avatars.toArray(new ContentValues[avatars.size()]));
// notify avatar changed
Intent i = new Intent(ImServiceConstants.ACTION_AVATAR_CHANGED);
i.putExtra(ImServiceConstants.EXTRA_INTENT_FROM_ADDRESS, usernames);
i.putExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID, mConn.getProviderId());
i.putExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID, mConn.getAccountId());
mContext.sendBroadcast(i);
}
}
use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.
the class ContactListItem method declineSubscription.
void declineSubscription() {
ImApp app = ((ImApp) ((Activity) getContext()).getApplication());
IImConnection mConn = app.getConnection(mHolder.mProviderId, mHolder.mAccountId);
if (mConn != null) {
try {
IContactListManager manager = mConn.getContactListManager();
manager.declineSubscription(new Contact(new XmppAddress(address), nickname, Imps.Contacts.TYPE_NORMAL));
app.dismissChatNotification(mHolder.mProviderId, address);
manager.removeContact(address);
} catch (RemoteException e) {
// mHandler.showServiceErrorAlert(e.getLocalizedMessage());
LogCleaner.error(ImApp.LOG_TAG, "decline sub error", e);
}
}
}
use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.
the class ContactListItem method approveSubscription.
/*
private String queryGroupMembers(ContentResolver resolver, long groupId) {
String[] projection = { Imps.GroupMembers.NICKNAME };
Uri uri = ContentUris.withAppendedId(Imps.GroupMembers.CONTENT_URI, groupId);
Cursor c = resolver.query(uri, projection, null, null, null);
StringBuilder buf = new StringBuilder();
if (c != null) {
while (c.moveToNext()) {
buf.append(c.getString(0));
Imps.Avatars.DATA
if (!c.isLast()) {
buf.append(',');
}
}
}
c.close();
return buf.toString();
}*/
void approveSubscription() {
ImApp app = ((ImApp) ((Activity) getContext()).getApplication());
IImConnection mConn = app.getConnection(mHolder.mProviderId, mHolder.mAccountId);
if (mConn != null) {
try {
IContactListManager manager = mConn.getContactListManager();
manager.approveSubscription(new Contact(new XmppAddress(address), nickname, Imps.Contacts.TYPE_NORMAL));
} catch (RemoteException e) {
// mHandler.showServiceErrorAlert(e.getLocalizedMessage());
LogCleaner.error(ImApp.LOG_TAG, "approve sub error", e);
}
}
}
use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.
the class ContactDisplayActivity method startChat.
public void startChat() {
if (mConn == null)
return;
try {
IChatSessionManager manager = mConn.getChatSessionManager();
if (manager != null) {
IChatSession session = manager.getChatSession(mUsername);
if (session == null) {
new ChatSessionInitTask(((ImApp) getApplication()), mProviderId, mAccountId, Imps.Contacts.TYPE_NORMAL, false) {
@Override
protected void onPostExecute(Long chatId) {
super.onPostExecute(chatId);
if (mContactId == -1) {
Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
intent.putExtra("id", chatId);
startActivity(intent);
finish();
}
}
}.executeOnExecutor(ImApp.sThreadPoolExecutor, new Contact(new XmppAddress(mUsername)));
// Toast.makeText(this, getString(R.string.message_waiting_for_friend), Toast.LENGTH_LONG).show();
} else {
Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
intent.putExtra("id", session.getId());
startActivity(intent);
finish();
}
}
} catch (RemoteException re) {
}
if (mContactId != -1) {
Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
intent.putExtra("id", mContactId);
startActivity(intent);
finish();
}
}
use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.
the class ContactListManagerAdapter method updatePresenceContent.
void updatePresenceContent(Contact[] contacts) {
if (mAdaptee == null)
return;
ArrayList<String> usernames = new ArrayList<String>();
ArrayList<String> nicknames = new ArrayList<String>();
ArrayList<String> statusArray = new ArrayList<String>();
ArrayList<String> customStatusArray = new ArrayList<String>();
ArrayList<String> clientTypeArray = new ArrayList<String>();
ArrayList<String> resourceArray = new ArrayList<String>();
for (Contact c : contacts) {
String username = mAdaptee.normalizeAddress(c.getAddress().getAddress());
Presence p = c.getPresence();
int status = convertPresenceStatus(p);
String customStatus = p.getStatusText();
int clientType = translateClientType(p);
usernames.add(username);
nicknames.add(c.getName());
statusArray.add(String.valueOf(status));
customStatusArray.add(customStatus);
clientTypeArray.add(String.valueOf(clientType));
if (!TextUtils.isEmpty(p.getResource()))
resourceArray.add(p.getResource());
else
resourceArray.add("");
}
ContentValues values = new ContentValues();
values.put(Imps.Contacts.ACCOUNT, mConn.getAccountId());
values.put(Imps.Contacts.PROVIDER, mConn.getProviderId());
putStringArrayList(values, Imps.Contacts.USERNAME, usernames);
putStringArrayList(values, Imps.Contacts.NICKNAME, nicknames);
mResolver.update(Imps.Contacts.BULK_CONTENT_URI, values, null, null);
values = new ContentValues();
values.put(Imps.Contacts.ACCOUNT, mConn.getAccountId());
values.put(Imps.Contacts.PROVIDER, mConn.getProviderId());
putStringArrayList(values, Imps.Contacts.USERNAME, usernames);
putStringArrayList(values, Imps.Presence.PRESENCE_STATUS, statusArray);
putStringArrayList(values, Imps.Presence.PRESENCE_CUSTOM_STATUS, customStatusArray);
putStringArrayList(values, Imps.Presence.CONTENT_TYPE, clientTypeArray);
putStringArrayList(values, Imps.Presence.JID_RESOURCE, resourceArray);
mResolver.update(Imps.Presence.BULK_CONTENT_URI, values, null, null);
}
Aggregations