use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.
the class ConversationView method startChat.
private void startChat(String username) {
if (username != null) {
new ChatSessionInitTask(((ImApp) mActivity.getApplication()), mProviderId, mAccountId, Imps.Contacts.TYPE_NORMAL, true) {
@Override
protected void onPostExecute(Long chatId) {
if (chatId != -1 && true) {
Intent intent = new Intent(mActivity, ConversationDetailActivity.class);
intent.putExtra("id", chatId);
mActivity.startActivity(intent);
}
super.onPostExecute(chatId);
}
}.executeOnExecutor(ImApp.sThreadPoolExecutor, new Contact(new XmppAddress(username)));
mActivity.finish();
}
}
use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.
the class ConversationView method declineSubscription.
void declineSubscription() {
if (mConn != null) {
try {
IContactListManager manager = mConn.getContactListManager();
manager.declineSubscription(new Contact(new XmppAddress(mRemoteAddress), mRemoteNickname, Imps.Contacts.TYPE_NORMAL));
} 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 ConversationView method setSelected.
public void setSelected(boolean isSelected) {
mIsSelected = isSelected;
if (mIsSelected) {
// bindChat(mLastChatId);
startListening();
updateWarningView();
mComposeMessage.requestFocus();
userActionDetected();
updateGroupTitle();
try {
mApp.dismissChatNotification(mProviderId, XmppAddress.stripResource(mRemoteAddress));
mCurrentChatSession.markAsRead();
} catch (Exception e) {
}
try {
if (mConn == null)
if (!checkConnection())
return;
if (mConn == null)
return;
IContactListManager manager = mConn.getContactListManager();
Contact contact = manager.getContactByAddress(mRemoteAddress);
if (contact != null) {
if (contact.getPresence() != null) {
mLastSeen = contact.getPresence().getLastSeen();
if (mLastSeen != null)
mActivity.updateLastSeen(mLastSeen);
}
if (!TextUtils.isEmpty(contact.getForwardingAddress())) {
showContactMoved(contact);
}
}
if ((mLastSessionStatus == null || mLastSessionStatus == SessionStatus.PLAINTEXT)) {
boolean otrPolicyAuto = getOtrPolicy() == OtrPolicy.OPPORTUNISTIC || getOtrPolicy() == OtrPolicy.OTRL_POLICY_ALWAYS;
if (mCurrentChatSession == null)
mCurrentChatSession = getChatSession();
if (mCurrentChatSession == null)
return;
IOtrChatSession otrChatSession = mCurrentChatSession.getDefaultOtrChatSession();
if (otrChatSession != null && (!isGroupChat())) {
String remoteJID = otrChatSession.getRemoteUserId();
boolean doOtr = (remoteJID != null && (remoteJID.toLowerCase().contains("chatsecure") || remoteJID.toLowerCase().contains("zom")));
if (!doOtr)
doOtr = OtrAndroidKeyManagerImpl.getInstance(mActivity).hasRemoteFingerprint(remoteJID);
if (// if set to auto, and is chatsecure, then start encryption
otrPolicyAuto && doOtr) {
// automatically attempt to turn on OTR after 1 second
mHandler.postDelayed(new Runnable() {
public void run() {
setOTRState(true);
scheduleRequery(DEFAULT_QUERY_INTERVAL);
}
}, 100);
}
}
}
} catch (RemoteException re) {
}
} else {
stopListening();
sendTypingStatus(false);
}
}
use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.
the class ConversationView method approveSubscription.
void approveSubscription() {
if (mConn != null) {
try {
IContactListManager manager = mConn.getContactListManager();
manager.approveSubscription(new Contact(new XmppAddress(mRemoteAddress), mRemoteNickname, 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 ChatSessionAdapter method insertOrUpdateGroupContactInDb.
private long insertOrUpdateGroupContactInDb(ChatGroup group) {
// Insert a record in contacts table
ContentValues values = new ContentValues(4);
values.put(Imps.Contacts.USERNAME, group.getAddress().getAddress());
values.put(Imps.Contacts.NICKNAME, group.getName());
values.put(Imps.Contacts.CONTACTLIST, ContactListManagerAdapter.LOCAL_GROUP_LIST_ID);
values.put(Imps.Contacts.TYPE, Imps.Contacts.TYPE_GROUP);
Uri contactUri = ContentUris.withAppendedId(ContentUris.withAppendedId(Imps.Contacts.CONTENT_URI, mConnection.mProviderId), mConnection.mAccountId);
ContactListManagerAdapter listManager = (ContactListManagerAdapter) mConnection.getContactListManager();
long id = listManager.queryGroup(group);
if (id == -1) {
id = ContentUris.parseId(mContentResolver.insert(contactUri, values));
for (Contact member : group.getMembers()) {
insertGroupMemberInDb(member);
}
}
return id;
}
Aggregations