Search in sources :

Example 6 with IntentResult

use of com.google.zxing.integration.android.IntentResult in project Conversations by siacs.

the class OmemoActivity method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
    if (scanResult != null && scanResult.getFormatName() != null) {
        String data = scanResult.getContents();
        XmppUri uri = new XmppUri(data);
        if (xmppConnectionServiceBound) {
            processFingerprintVerification(uri);
        } else {
            this.mPendingFingerprintVerificationUri = uri;
        }
    }
}
Also used : IntentResult(com.google.zxing.integration.android.IntentResult) XmppUri(eu.siacs.conversations.utils.XmppUri)

Example 7 with IntentResult

use of com.google.zxing.integration.android.IntentResult in project Conversations by siacs.

the class StartConversationActivity method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if ((requestCode & 0xFFFF) == IntentIntegrator.REQUEST_CODE) {
        IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
        if (scanResult != null && scanResult.getFormatName() != null) {
            String data = scanResult.getContents();
            Invite invite = new Invite(data);
            if (xmppConnectionServiceBound) {
                invite.invite();
            } else if (invite.getJid() != null) {
                this.mPendingInvite = invite;
            } else {
                this.mPendingInvite = null;
            }
        }
    } else 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);
}
Also used : Account(eu.siacs.conversations.entities.Account) IntentResult(com.google.zxing.integration.android.IntentResult) InvalidJidException(eu.siacs.conversations.xmpp.jid.InvalidJidException) List(java.util.List) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) ActivityNotFoundException(android.content.ActivityNotFoundException) InvalidJidException(eu.siacs.conversations.xmpp.jid.InvalidJidException) Pair(android.util.Pair)

Example 8 with IntentResult

use of com.google.zxing.integration.android.IntentResult in project weex-example by KalicyZhou.

the class WXPageActivity method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    if (result != null) {
        if (result.getContents() == null) {
            Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
        } else {
            handleDecodeInternally(result.getContents());
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}
Also used : IntentResult(com.google.zxing.integration.android.IntentResult)

Aggregations

IntentResult (com.google.zxing.integration.android.IntentResult)8 XmppUri (eu.siacs.conversations.utils.XmppUri)2 AlertDialog (android.app.AlertDialog)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 SpannableString (android.text.SpannableString)1 Pair (android.util.Pair)1 AndroidPreferences (com.nightscout.android.preferences.AndroidPreferences)1 NSBarcodeConfig (com.nightscout.core.barcode.NSBarcodeConfig)1 NightscoutPreferences (com.nightscout.core.preferences.NightscoutPreferences)1 Account (eu.siacs.conversations.entities.Account)1 InvalidJidException (eu.siacs.conversations.xmpp.jid.InvalidJidException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1