Search in sources :

Example 1 with CameraSettings

use of com.journeyapps.barcodescanner.camera.CameraSettings in project zxing-android-embedded by journeyapps.

the class DecoratedBarcodeView method initializeFromIntent.

/**
     * Convenience method to initialize camera id, decode formats and prompt message from an intent.
     *
     * @param intent the intent, as generated by IntentIntegrator
     */
public void initializeFromIntent(Intent intent) {
    // Scan the formats the intent requested, and return the result to the calling activity.
    Set<BarcodeFormat> decodeFormats = DecodeFormatManager.parseDecodeFormats(intent);
    Map<DecodeHintType, Object> decodeHints = DecodeHintManager.parseDecodeHints(intent);
    CameraSettings settings = new CameraSettings();
    if (intent.hasExtra(Intents.Scan.CAMERA_ID)) {
        int cameraId = intent.getIntExtra(Intents.Scan.CAMERA_ID, -1);
        if (cameraId >= 0) {
            settings.setRequestedCameraId(cameraId);
        }
    }
    String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE);
    if (customPromptMessage != null) {
        setStatusText(customPromptMessage);
    }
    // Check to see if the scan should be inverted.
    boolean inverted = intent.getBooleanExtra(Intents.Scan.INVERTED_SCAN, false);
    String characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET);
    MultiFormatReader reader = new MultiFormatReader();
    reader.setHints(decodeHints);
    barcodeView.setCameraSettings(settings);
    barcodeView.setDecoderFactory(new DefaultDecoderFactory(decodeFormats, decodeHints, characterSet, inverted));
}
Also used : MultiFormatReader(com.google.zxing.MultiFormatReader) DecodeHintType(com.google.zxing.DecodeHintType) BarcodeFormat(com.google.zxing.BarcodeFormat) CameraSettings(com.journeyapps.barcodescanner.camera.CameraSettings) ResultPoint(com.google.zxing.ResultPoint)

Aggregations

BarcodeFormat (com.google.zxing.BarcodeFormat)1 DecodeHintType (com.google.zxing.DecodeHintType)1 MultiFormatReader (com.google.zxing.MultiFormatReader)1 ResultPoint (com.google.zxing.ResultPoint)1 CameraSettings (com.journeyapps.barcodescanner.camera.CameraSettings)1