use of org.awesomeapp.messenger.plugin.xmpp.XmppAddress in project Zom-Android by zom.
the class ChatSessionManagerAdapter method createMultiUserChatSession.
public IChatSession createMultiUserChatSession(String roomAddress, String subject, String nickname, boolean isNewChat) {
ChatGroupManager groupMan = mConnection.getAdaptee().getChatGroupManager();
try {
if (roomAddress.endsWith("@")) {
String confServer = groupMan.getDefaultGroupChatService();
if (confServer != null)
roomAddress += confServer;
}
// TODO hard coding XMPP for now
Address address = new XmppAddress(roomAddress);
groupMan.createChatGroupAsync(roomAddress, subject, nickname);
ChatGroup chatGroup = groupMan.getChatGroup(address);
if (chatGroup != null && mConnection.getState() == ImConnection.LOGGED_IN) {
ChatSession session = getChatSessionManager().createChatSession(chatGroup, isNewChat);
ChatSessionAdapter adapter = getChatSessionAdapter(session, isNewChat);
groupMan.loadMembers(chatGroup);
return adapter;
} else {
return null;
}
} catch (Exception e) {
Log.e(ImApp.LOG_TAG, "unable to join group chat" + e.getMessage());
return null;
}
}
use of org.awesomeapp.messenger.plugin.xmpp.XmppAddress in project Zom-Android by zom.
the class AddContactActivity method setupActions.
private void setupActions() {
View btnInviteSms = findViewById(R.id.btnInviteSMS);
btnInviteSms.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ImApp app = ((ImApp) getApplication());
String nickname = app.getDefaultNickname();
if (nickname == null)
nickname = new XmppAddress(app.getDefaultUsername()).getUser();
String inviteString = OnboardingManager.generateInviteMessage(AddContactActivity.this, nickname, app.getDefaultUsername(), app.getDefaultOtrKey());
OnboardingManager.inviteSMSContact(AddContactActivity.this, null, inviteString);
}
});
View btnInviteShare = findViewById(R.id.btnInviteShare);
btnInviteShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ImApp app = ((ImApp) getApplication());
String nickname = app.getDefaultNickname();
if (nickname == null)
nickname = new XmppAddress(app.getDefaultUsername()).getUser();
String inviteString = OnboardingManager.generateInviteMessage(AddContactActivity.this, nickname, app.getDefaultUsername(), app.getDefaultOtrKey());
OnboardingManager.inviteShare(AddContactActivity.this, inviteString);
}
});
View btnInviteQR = findViewById(R.id.btnInviteScan);
btnInviteQR.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (hasCameraPermission()) {
ImApp app = ((ImApp) getApplication());
try {
String xmppLink = OnboardingManager.generateXmppLink(app.getDefaultUsername(), app.getDefaultOtrKey());
OnboardingManager.inviteScan(AddContactActivity.this, xmppLink);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
}
use of org.awesomeapp.messenger.plugin.xmpp.XmppAddress 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.plugin.xmpp.XmppAddress 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.plugin.xmpp.XmppAddress 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();
}
}
Aggregations