Use portrait mode for qr code scanning

This commit is contained in:
Dominik Schürmann 2015-04-15 10:25:56 +02:00
parent e332699c9c
commit b440456acc

View File

@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.ui;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri; import android.net.Uri;
import android.nfc.NdefMessage; import android.nfc.NdefMessage;
import android.nfc.NfcAdapter; import android.nfc.NfcAdapter;
@ -83,25 +84,22 @@ public class ImportKeysProxyActivity extends FragmentActivity {
returnResult = false; returnResult = false;
processScannedContent(dataUri); processScannedContent(dataUri);
} else if (ACTION_SCAN_IMPORT.equals(action)) { } else if (ACTION_SCAN_IMPORT.equals(action) || ACTION_QR_CODE_API.equals(action)) {
returnResult = false; returnResult = false;
IntentIntegrator integrator = new IntentIntegrator(this); IntentIntegrator integrator = new IntentIntegrator(this);
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES) integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES)
.setPrompt(getString(R.string.import_qr_code_text)) .setPrompt(getString(R.string.import_qr_code_text))
.setResultDisplayDuration(0) .setResultDisplayDuration(0);
.initiateScan(); integrator.setOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
integrator.initiateScan();
} else if (ACTION_SCAN_WITH_RESULT.equals(action)) { } else if (ACTION_SCAN_WITH_RESULT.equals(action)) {
returnResult = true; returnResult = true;
IntentIntegrator integrator = new IntentIntegrator(this); IntentIntegrator integrator = new IntentIntegrator(this);
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES) integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES)
.setPrompt(getString(R.string.import_qr_code_text)) .setPrompt(getString(R.string.import_qr_code_text))
.setResultDisplayDuration(0) .setResultDisplayDuration(0);
.initiateScan(); integrator.setOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else if (ACTION_QR_CODE_API.equals(action)) { integrator.initiateScan();
// scan using xzing's Barcode Scanner from outside OpenKeychain
returnResult = false;
new IntentIntegrator(this).initiateScan();
} else if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) { } else if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
// Check to see if the Activity started due to an Android Beam // Check to see if the Activity started due to an Android Beam
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {