Search in sources :

Example 1 with IntentResult

use of com.google.zxing.integration.android.IntentResult in project zxing-android-embedded by journeyapps.

the class MainActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    if (result != null) {
        if (result.getContents() == null) {
            Log.d("MainActivity", "Cancelled scan");
            Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
        } else {
            Log.d("MainActivity", "Scanned");
            Toast.makeText(this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show();
        }
    } else {
        // This is important, otherwise the result will not be passed to the fragment
        super.onActivityResult(requestCode, resultCode, data);
    }
}
Also used : IntentResult(com.google.zxing.integration.android.IntentResult)

Example 2 with IntentResult

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

the class VerifyOTRActivity 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();
            XmppUri uri = new XmppUri(data);
            if (xmppConnectionServiceBound) {
                verifyWithUri(uri);
                finish();
            } else {
                this.mPendingUri = uri;
            }
        } else {
            finish();
        }
    }
    super.onActivityResult(requestCode, requestCode, intent);
}
Also used : IntentResult(com.google.zxing.integration.android.IntentResult) XmppUri(eu.siacs.conversations.utils.XmppUri)

Example 3 with IntentResult

use of com.google.zxing.integration.android.IntentResult in project cw-omnibus by commonsguy.

the class ZXingDemo method onActivityResult.

public void onActivityResult(int request, int result, Intent i) {
    IntentResult scan = IntentIntegrator.parseActivityResult(request, result, i);
    if (scan != null) {
        format.setText(scan.getFormatName());
        contents.setText(scan.getContents());
    }
}
Also used : IntentResult(com.google.zxing.integration.android.IntentResult)

Example 4 with IntentResult

use of com.google.zxing.integration.android.IntentResult in project android-uploader by nightscout.

the class SettingsActivity method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    NightscoutPreferences prefs = new AndroidPreferences(this);
    if (scanResult != null && scanResult.getContents() != null) {
        NSBarcodeConfig barcode = new NSBarcodeConfig(scanResult.getContents());
        if (barcode.hasMongoConfig()) {
            prefs.setMongoUploadEnabled(true);
            if (barcode.getMongoUri().isPresent()) {
                prefs.setMongoClientUri(barcode.getMongoUri().get());
                prefs.setMongoCollection(barcode.getMongoCollection().orNull());
                prefs.setMongoDeviceStatusCollection(barcode.getMongoDeviceStatusCollection().orNull());
            }
        } else {
            prefs.setMongoUploadEnabled(false);
        }
        if (barcode.hasApiConfig()) {
            prefs.setRestApiEnabled(true);
            prefs.setRestApiBaseUris(barcode.getApiUris());
        } else {
            prefs.setRestApiEnabled(false);
        }
        refreshFragments();
    }
}
Also used : AndroidPreferences(com.nightscout.android.preferences.AndroidPreferences) IntentResult(com.google.zxing.integration.android.IntentResult) NightscoutPreferences(com.nightscout.core.preferences.NightscoutPreferences) NSBarcodeConfig(com.nightscout.core.barcode.NSBarcodeConfig)

Example 5 with IntentResult

use of com.google.zxing.integration.android.IntentResult in project xabber-android by redsolution.

the class FingerprintViewer method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    if (scanResult != null) {
        String code = scanResult.getContents();
        boolean equals = code != null && code.equals(remoteFingerprint);
        verifiedView.setChecked(equals);
        int dialogMessageId;
        if (equals) {
            dialogMessageId = R.string.action_otr_smp_verified;
        } else {
            dialogMessageId = R.string.action_otr_smp_unverified;
        }
        new AlertDialog.Builder(this).setMessage(dialogMessageId).setNeutralButton(android.R.string.ok, null).show();
    }
}
Also used : AlertDialog(android.app.AlertDialog) 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