Search in sources :

Example 6 with IntentIntegrator

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

the class StartConversationActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.action_create_contact:
            showCreateContactDialog(null, null);
            return true;
        case R.id.action_join_conference:
            showJoinConferenceDialog(null);
            return true;
        case R.id.action_create_conference:
            showCreateConferenceDialog();
            return true;
        case R.id.action_scan_qr_code:
            new IntentIntegrator(this).initiateScan(Arrays.asList("AZTEC", "QR_CODE"));
            return true;
        case R.id.action_hide_offline:
            mHideOfflineContacts = !item.isChecked();
            getPreferences().edit().putBoolean("hide_offline", mHideOfflineContacts).commit();
            if (mSearchEditText != null) {
                filter(mSearchEditText.getText().toString());
            }
            invalidateOptionsMenu();
    }
    return super.onOptionsItemSelected(item);
}
Also used : IntentIntegrator(com.google.zxing.integration.android.IntentIntegrator)

Example 7 with IntentIntegrator

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

the class WXPageActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.action_refresh:
            createWeexInstance();
            renderPage();
            break;
        case R.id.action_scan:
            IntentIntegrator integrator = new IntentIntegrator(this);
            integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
            integrator.setPrompt("Scan a barcode");
            //integrator.setCameraId(0);  // Use a specific camera of the device
            integrator.setBeepEnabled(true);
            integrator.setOrientationLocked(false);
            integrator.setBarcodeImageEnabled(true);
            integrator.setPrompt(getString(R.string.capture_qrcode_prompt));
            integrator.initiateScan();
            break;
        case android.R.id.home:
            finish();
        default:
            break;
    }
    return super.onOptionsItemSelected(item);
}
Also used : IntentIntegrator(com.google.zxing.integration.android.IntentIntegrator)

Example 8 with IntentIntegrator

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

the class WXPageActivity method showDevOptionsDialog.

public void showDevOptionsDialog() {
    if (mDevOptionsDialog != null || !mIsDevSupportEnabled || ActivityManager.isUserAMonkey()) {
        return;
    }
    LinkedHashMap<String, DevOptionHandler> options = new LinkedHashMap<>();
    /* register standard options */
    options.put(getString(R.string.scan_qr_code), new DevOptionHandler() {

        @Override
        public void onOptionSelected() {
            IntentIntegrator integrator = new IntentIntegrator(WXPageActivity.this);
            integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
            integrator.setPrompt("Scan a barcode");
            //integrator.setCameraId(0);  // Use a specific camera of the device
            integrator.setBeepEnabled(true);
            integrator.setOrientationLocked(false);
            integrator.setBarcodeImageEnabled(true);
            integrator.setPrompt(getString(R.string.capture_qrcode_prompt));
            integrator.initiateScan();
        }
    });
    options.put(getString(R.string.page_refresh), new DevOptionHandler() {

        @Override
        public void onOptionSelected() {
            createWeexInstance();
            renderPage();
        }
    });
    if (mCustomDevOptions.size() > 0) {
        options.putAll(mCustomDevOptions);
    }
    final DevOptionHandler[] optionHandlers = options.values().toArray(new DevOptionHandler[0]);
    mDevOptionsDialog = new AlertDialog.Builder(WXPageActivity.this).setItems(options.keySet().toArray(new String[0]), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            optionHandlers[which].onOptionSelected();
            mDevOptionsDialog = null;
        }
    }).setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            mDevOptionsDialog = null;
        }
    }).create();
    mDevOptionsDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    mDevOptionsDialog.show();
}
Also used : DevOptionHandler(com.alibaba.weex.commons.util.DevOptionHandler) DialogInterface(android.content.DialogInterface) IntentIntegrator(com.google.zxing.integration.android.IntentIntegrator) LinkedHashMap(java.util.LinkedHashMap)

Example 9 with IntentIntegrator

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

the class MainActivity method scanBarcodeFrontCamera.

public void scanBarcodeFrontCamera(View view) {
    IntentIntegrator integrator = new IntentIntegrator(this);
    integrator.setCameraId(Camera.CameraInfo.CAMERA_FACING_FRONT);
    integrator.initiateScan();
}
Also used : IntentIntegrator(com.google.zxing.integration.android.IntentIntegrator)

Example 10 with IntentIntegrator

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

the class MainActivity method scanWithTimeout.

public void scanWithTimeout(View view) {
    IntentIntegrator integrator = new IntentIntegrator(this);
    integrator.setTimeout(8000);
    integrator.initiateScan();
}
Also used : IntentIntegrator(com.google.zxing.integration.android.IntentIntegrator)

Aggregations

IntentIntegrator (com.google.zxing.integration.android.IntentIntegrator)13 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 Toolbar (android.support.v7.widget.Toolbar)1 DevOptionHandler (com.alibaba.weex.commons.util.DevOptionHandler)1 ContactTitleActionBarInflater (com.xabber.android.ui.helper.ContactTitleActionBarInflater)1 InvalidJidException (eu.siacs.conversations.xmpp.jid.InvalidJidException)1 LinkedHashMap (java.util.LinkedHashMap)1