use of de.pixart.messenger.entities.Account in project Pix-Art-Messenger by kriztan.
the class XmppConnectionService method switchToForeground.
private void switchToForeground() {
final boolean broadcastLastActivity = broadcastLastActivity();
for (Conversation conversation : getConversations()) {
if (conversation.getMode() == Conversation.MODE_MULTI) {
conversation.getMucOptions().resetChatState();
} else {
conversation.setIncomingChatState(Config.DEFAULT_CHATSTATE);
}
}
for (Account account : getAccounts()) {
if (account.getStatus() == Account.State.ONLINE) {
account.deactivateGracePeriod();
final XmppConnection connection = account.getXmppConnection();
if (connection != null) {
if (connection.getFeatures().csi()) {
connection.sendActive();
}
if (broadcastLastActivity) {
// send new presence but don't include idle because we are not
sendPresence(account, false);
}
}
}
}
Log.d(Config.LOGTAG, "app switched into foreground");
}
use of de.pixart.messenger.entities.Account in project Pix-Art-Messenger by kriztan.
the class ShareViaAccountActivity method onBackendConnected.
@Override
void onBackendConnected() {
final int numAccounts = xmppConnectionService.getAccounts().size();
if (numAccounts == 1) {
final String body = getIntent().getStringExtra(EXTRA_BODY);
final Account account = xmppConnectionService.getAccounts().get(0);
try {
final Jid contact = Jid.fromString(getIntent().getStringExtra(EXTRA_CONTACT));
final Conversation conversation = xmppConnectionService.findOrCreateConversation(account, contact, false, false);
switchToConversation(conversation, body, false);
} catch (InvalidJidException e) {
// ignore error
}
finish();
} else {
refreshUiReal();
}
}
use of de.pixart.messenger.entities.Account in project Pix-Art-Messenger by kriztan.
the class ShareWithActivity method share.
private void share() {
final Conversation conversation;
if (share.uuid != null) {
conversation = xmppConnectionService.findConversationByUuid(share.uuid);
if (conversation == null) {
return;
}
} else {
Account account;
try {
account = xmppConnectionService.findAccountByJid(Jid.fromString(share.account));
} catch (final InvalidJidException e) {
account = null;
}
if (account == null) {
return;
}
try {
conversation = xmppConnectionService.findOrCreateConversation(account, Jid.fromString(share.contact), false, true);
} catch (final InvalidJidException e) {
return;
}
}
ContactChosen = true;
share(conversation);
}
use of de.pixart.messenger.entities.Account in project Pix-Art-Messenger by kriztan.
the class StartConversationActivity method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (resultCode == RESULT_OK) {
if (xmppConnectionServiceBound) {
this.mPostponedActivityResult = null;
if (requestCode == REQUEST_CREATE_CONFERENCE) {
Account account = extractAccount(intent);
final String subject = intent.getStringExtra("subject");
List<Jid> jids = new ArrayList<>();
if (intent.getBooleanExtra("multiple", false)) {
String[] toAdd = intent.getStringArrayExtra("contacts");
for (String item : toAdd) {
try {
jids.add(Jid.fromString(item));
} catch (InvalidJidException e) {
// ignored
}
}
} else {
try {
jids.add(Jid.fromString(intent.getStringExtra("contact")));
} catch (Exception e) {
// ignored
}
}
if (account != null && jids.size() > 0) {
if (xmppConnectionService.createAdhocConference(account, subject, jids, mAdhocConferenceCallback)) {
mToast = Toast.makeText(this, R.string.creating_conference, Toast.LENGTH_LONG);
mToast.show();
}
}
}
} else {
this.mPostponedActivityResult = new Pair<>(requestCode, intent);
}
}
super.onActivityResult(requestCode, requestCode, intent);
}
use of de.pixart.messenger.entities.Account in project Pix-Art-Messenger by kriztan.
the class StartConversationActivity method onBackendConnected.
@Override
protected void onBackendConnected() {
if (mPostponedActivityResult != null) {
onActivityResult(mPostponedActivityResult.first, RESULT_OK, mPostponedActivityResult.second);
this.mPostponedActivityResult = null;
}
this.mActivatedAccounts.clear();
for (Account account : xmppConnectionService.getAccounts()) {
if (account.getStatus() != Account.State.DISABLED) {
if (Config.DOMAIN_LOCK != null) {
this.mActivatedAccounts.add(account.getJid().getLocalpart());
} else {
this.mActivatedAccounts.add(account.getJid().toBareJid().toString());
}
}
}
final Intent intent = getIntent();
final ActionBar ab = getSupportActionBar();
boolean init = intent != null && intent.getBooleanExtra("init", false);
boolean noConversations = xmppConnectionService.getConversations().size() == 0;
if ((init || noConversations) && ab != null) {
ab.setDisplayShowHomeEnabled(false);
ab.setDisplayHomeAsUpEnabled(false);
ab.setHomeButtonEnabled(false);
}
this.mKnownHosts = xmppConnectionService.getKnownHosts();
this.mKnownConferenceHosts = xmppConnectionService.getKnownConferenceHosts();
if (this.mPendingInvite != null) {
mPendingInvite.invite();
this.mPendingInvite = null;
filter(null);
} else if (!handleIntent(getIntent())) {
if (mSearchEditText != null) {
filter(mSearchEditText.getText().toString());
} else {
filter(null);
}
} else {
filter(null);
}
setIntent(null);
}
Aggregations