Search in sources :

Example 1 with XmppUri

use of de.pixart.messenger.utils.XmppUri in project Pix-Art-Messenger by kriztan.

the class EditAccountActivity method onStart.

@Override
protected void onStart() {
    super.onStart();
    final int theme = findTheme();
    if (this.mTheme != theme) {
        recreate();
    } else if (getIntent() != null) {
        try {
            this.jidToEdit = Jid.fromString(getIntent().getStringExtra("jid"));
        } catch (final InvalidJidException | NullPointerException ignored) {
            this.jidToEdit = null;
        }
        if (jidToEdit != null && getIntent().getData() != null) {
            final XmppUri uri = new XmppUri(getIntent().getData());
            if (xmppConnectionServiceBound) {
                processFingerprintVerification(uri, false);
            } else {
                this.pendingUri = uri;
            }
        }
        boolean init = getIntent().getBooleanExtra("init", false);
        this.mInitMode = init || this.jidToEdit == null;
        this.messageFingerprint = getIntent().getStringExtra("fingerprint");
        if (!mInitMode) {
            this.mRegisterNew.setVisibility(View.GONE);
            if (getSupportActionBar() != null) {
                getSupportActionBar().setTitle(getString(R.string.account_details));
            }
        } else {
            this.mAvatar.setVisibility(View.GONE);
            ActionBar ab = getSupportActionBar();
            if (ab != null) {
                if (init && Config.MAGIC_CREATE_DOMAIN == null) {
                    ab.setDisplayShowHomeEnabled(false);
                    ab.setDisplayHomeAsUpEnabled(false);
                }
                ab.setTitle(R.string.action_add_account);
            }
        }
    }
    SharedPreferences preferences = getPreferences();
    mUseTor = Config.FORCE_ORBOT || preferences.getBoolean("use_tor", false);
    this.mShowOptions = mUseTor || preferences.getBoolean("show_connection_options", false);
    this.mNamePort.setVisibility(mShowOptions ? View.VISIBLE : View.GONE);
}
Also used : XmppUri(de.pixart.messenger.utils.XmppUri) SharedPreferences(android.content.SharedPreferences) ActionBar(android.support.v7.app.ActionBar)

Example 2 with XmppUri

use of de.pixart.messenger.utils.XmppUri in project Pix-Art-Messenger by kriztan.

the class OmemoActivity method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, requestCode, intent);
    if (requestCode == ScanActivity.REQUEST_SCAN_QR_CODE && resultCode == RESULT_OK) {
        String result = intent.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
        XmppUri uri = new XmppUri(result == null ? "" : result);
        if (xmppConnectionServiceBound) {
            processFingerprintVerification(uri);
        } else {
            this.mPendingFingerprintVerificationUri = uri;
        }
    }
}
Also used : XmppUri(de.pixart.messenger.utils.XmppUri)

Example 3 with XmppUri

use of de.pixart.messenger.utils.XmppUri in project Pix-Art-Messenger by kriztan.

the class UriHandlerActivity method handleUri.

private void handleUri(Uri uri) {
    final Intent intent;
    final XmppUri xmppUri = new XmppUri(uri);
    // TODO only look at enabled accounts
    final List<Jid> accounts = DatabaseBackend.getInstance(this).getAccountJids();
    if (accounts.size() == 0) {
        intent = new Intent(getApplicationContext(), WelcomeActivity.class);
        WelcomeActivity.addInviteUri(intent, xmppUri);
        startActivity(intent);
        return;
    }
    if (xmppUri.isAction(XmppUri.ACTION_MESSAGE)) {
        final Jid jid = xmppUri.getJid();
        final String body = xmppUri.getBody();
        if (jid != null) {
            intent = new Intent(getApplicationContext(), ShareViaAccountActivity.class);
            intent.putExtra(ShareViaAccountActivity.EXTRA_CONTACT, jid.toString());
            intent.putExtra(ShareViaAccountActivity.EXTRA_BODY, body);
        } else {
            intent = new Intent(getApplicationContext(), ShareWithActivity.class);
            intent.setAction(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_TEXT, body);
        }
    } else if (accounts.contains(xmppUri.getJid())) {
        intent = new Intent(getApplicationContext(), EditAccountActivity.class);
        intent.setAction(Intent.ACTION_VIEW);
        intent.putExtra("jid", xmppUri.getJid().toBareJid().toString());
        intent.setData(uri);
    } else if (xmppUri.isJidValid()) {
        intent = new Intent(getApplicationContext(), StartConversationActivity.class);
        intent.setAction(Intent.ACTION_VIEW);
        intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        intent.setData(uri);
    } else {
        Toast.makeText(this, R.string.invalid_jid, Toast.LENGTH_SHORT).show();
        return;
    }
    startActivity(intent);
}
Also used : XmppUri(de.pixart.messenger.utils.XmppUri) Jid(de.pixart.messenger.xmpp.jid.Jid) Intent(android.content.Intent)

Aggregations

XmppUri (de.pixart.messenger.utils.XmppUri)3 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 ActionBar (android.support.v7.app.ActionBar)1 Jid (de.pixart.messenger.xmpp.jid.Jid)1