diff --git a/CHANGELOG.md b/CHANGELOG.md index 1197b8c4f..1fea2987e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Changes: - Automatically focus text field when creating or editing a group - Fix blurry icons (use SVG everywhere) +- Always open camera but add manual scan button to camera view ## v1.5.1 (2020-12-03) diff --git a/app/build.gradle b/app/build.gradle index 35f63dfe1..cb58ff8b1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -48,7 +48,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'com.google.android.material:material:1.2.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'com.journeyapps:zxing-android-embedded:3.5.0@aar' + implementation 'com.journeyapps:zxing-android-embedded:4.0.2@aar' implementation 'com.google.zxing:core:3.3.0' implementation 'org.apache.commons:commons-csv:1.5' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 771c54445..133621e93 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools"> @@ -16,6 +17,8 @@ android:name="android.hardware.camera.autofocus" android:required="false" /> + + + LUMINANCE_MIDPOINT; } - static public void startCameraBarcodeScan(Context context, Activity activity) { - IntentIntegrator integrator = new IntentIntegrator(activity); - integrator.setDesiredBarcodeFormats(BarcodeSelectorActivity.SUPPORTED_BARCODE_TYPES); - - String prompt = context.getResources().getString(R.string.scanCardBarcode); - integrator.setPrompt(prompt); - integrator.setBeepEnabled(false); - integrator.initiateScan(); - } - - static public void createSetBarcodeDialog(final Context context, final Activity activity, boolean isUpdate, final String initialCardId) { - AlertDialog.Builder builder = new AlertDialog.Builder(context); - // Get the layout inflater - LayoutInflater inflater = activity.getLayoutInflater(); - - // Inflate and set the layout for the dialog - // Pass null as the parent view because its going in the dialog layout - builder.setView(inflater.inflate(R.layout.dialog_create, null)); - - if (isUpdate) { - builder.setTitle(context.getString(R.string.editCardTitle)); - } else { - builder.setTitle(context.getString(R.string.addCardTitle)); - } - - builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - setBarcodeDialog.cancel(); - } - }); - setBarcodeDialog = builder.create(); - setBarcodeDialog.show(); - - View addFromCamera = setBarcodeDialog.getWindow().findViewById(R.id.add_from_camera); - View addManually = setBarcodeDialog.getWindow().findViewById(R.id.add_manually); - - addFromCamera.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Utils.startCameraBarcodeScan(context, activity); - - setBarcodeDialog.hide(); - } - }); - - addManually.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent i = new Intent(context, BarcodeSelectorActivity.class); - if (initialCardId != null) { - final Bundle b = new Bundle(); - b.putString("initialCardId", initialCardId); - i.putExtras(b); - } - activity.startActivityForResult(i, Utils.SELECT_BARCODE_REQUEST); - - setBarcodeDialog.hide(); - } - }); - } - static public BarcodeValues parseSetBarcodeActivityResult(int requestCode, int resultCode, Intent intent) { String contents = null; String format = null; - IntentResult result = - IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); - if (result != null) + if (resultCode == Activity.RESULT_OK) { - Log.i(TAG, "Received barcode information from capture"); - contents = result.getContents(); - format = result.getFormatName(); - } - - if(requestCode == Utils.SELECT_BARCODE_REQUEST && resultCode == Activity.RESULT_OK) - { - Log.i(TAG, "Received barcode information from typing it"); + if (requestCode == Utils.BARCODE_SCAN) { + Log.i(TAG, "Received barcode information from camera"); + } else if (requestCode == Utils.SELECT_BARCODE_REQUEST) { + Log.i(TAG, "Received barcode information from typing it"); + } else { + return new BarcodeValues(null, null); + } contents = intent.getStringExtra(BarcodeSelectorActivity.BARCODE_CONTENTS); format = intent.getStringExtra(BarcodeSelectorActivity.BARCODE_FORMAT); diff --git a/app/src/main/res/layout/custom_barcode_scanner.xml b/app/src/main/res/layout/custom_barcode_scanner.xml new file mode 100644 index 000000000..9a9de3222 --- /dev/null +++ b/app/src/main/res/layout/custom_barcode_scanner.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_create.xml b/app/src/main/res/layout/dialog_create.xml deleted file mode 100644 index bf46f8975..000000000 --- a/app/src/main/res/layout/dialog_create.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - diff --git a/app/src/main/res/layout/scan_activity.xml b/app/src/main/res/layout/scan_activity.xml new file mode 100644 index 000000000..bdbf25e99 --- /dev/null +++ b/app/src/main/res/layout/scan_activity.xml @@ -0,0 +1,26 @@ + + + + + + + +