From 85b6669625c9b94972fb03ec0de2da689c24d299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 14 Jan 2015 19:14:30 +0100 Subject: [PATCH] Integrate QR Code library instead of requiring the app to be installed, also due to security reasons --- OpenKeychain/build.gradle | 7 +++++-- .../keychain/ui/QrCodeScanActivity.java | 8 ++++++-- OpenKeychain/src/main/res/values/strings.xml | 1 + build.gradle | 5 +++++ settings.gradle | 2 -- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/OpenKeychain/build.gradle b/OpenKeychain/build.gradle index 6c78c3aea..21482340a 100644 --- a/OpenKeychain/build.gradle +++ b/OpenKeychain/build.gradle @@ -10,8 +10,6 @@ dependencies { compile project(':extern:openkeychain-api-lib') compile project(':extern:html-textview') compile project(':extern:StickyListHeaders:library') - compile project(':extern:zxing-qr-code') - compile project(':extern:zxing-android-integration') compile project(':extern:spongycastle:core') compile project(':extern:spongycastle:pg') compile project(':extern:spongycastle:pkix') @@ -22,6 +20,11 @@ dependencies { compile project(':extern:TokenAutoComplete:library') compile project(':extern:safeslinger-exchange') compile project(':extern:android-lockpattern:code') + + // TODO: include as submodule?: + compile 'com.journeyapps:zxing-android-embedded:2.0.1@aar' + compile 'com.journeyapps:zxing-android-integration:2.0.1@aar' + compile 'com.google.zxing:core:3.0.1' } android { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeScanActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeScanActivity.java index 5966870df..28488879b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeScanActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeScanActivity.java @@ -78,7 +78,11 @@ public class QrCodeScanActivity extends FragmentActivity { // scan using xzing's Barcode Scanner and return result parcel in OpenKeychain returnResult = true; - new IntentIntegrator(this).initiateScan(); + IntentIntegrator integrator = new IntentIntegrator(this); + integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES) + .setPrompt(getString(R.string.import_qr_code_text)) + .setResultDisplayDuration(0) + .initiateScan(); } else if (ACTION_QR_CODE_API.equals(action)) { // scan using xzing's Barcode Scanner from outside OpenKeychain @@ -168,7 +172,7 @@ public class QrCodeScanActivity extends FragmentActivity { return; } - if ( ! result.success()) { + if (!result.success()) { // only return if no success... Intent data = new Intent(); data.putExtras(returnData); diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 5163f16e6..7f38d40a1 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -395,6 +395,7 @@ "QR Code malformed! Please try again!" "Fingerprint is too short (< 16 characters)" "Scan QR Code" + "Place your camera over the QR Code!" "View Log" diff --git a/build.gradle b/build.gradle index 8c3b355d4..f8e6afc27 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,11 @@ buildscript { allprojects { repositories { jcenter() + + maven { + // for https://github.com/journeyapps/zxing-android-embedded + url "http://dl.bintray.com/journeyapps/maven" + } } } diff --git a/settings.gradle b/settings.gradle index 2439d70e4..d12c56b58 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,8 +3,6 @@ include ':extern:openpgp-api-lib' include ':extern:openkeychain-api-lib' include ':extern:html-textview' include ':extern:StickyListHeaders:library' -include ':extern:zxing-qr-code' -include ':extern:zxing-android-integration' include ':extern:spongycastle:core' include ':extern:spongycastle:pg' include ':extern:spongycastle:pkix'