diff --git a/.gitignore b/.gitignore index a568390..25188ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,12 @@ /nbproject/private/ /build/ -/dist/ \ No newline at end of file +/dist/ +/target +/common/target +/javase/target +/android/target +/win/target +/ios/target +/javascript/target +/lib/target +/tests/**/target \ No newline at end of file diff --git a/.idea/codenameone-maven-manual.iml b/.idea/codenameone-maven-manual.iml new file mode 100644 index 0000000..f409c0e --- /dev/null +++ b/.idea/codenameone-maven-manual.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..dcc642b --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..e40f599 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..0455e17 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_codenameone_codenameone_core_7_0_122.xml b/.idea/libraries/Maven__com_codenameone_codenameone_core_7_0_122.xml new file mode 100644 index 0000000..cb7a7e6 --- /dev/null +++ b/.idea/libraries/Maven__com_codenameone_codenameone_core_7_0_122.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_codenameone_codenameone_javase_7_0_122.xml b/.idea/libraries/Maven__com_codenameone_codenameone_javase_7_0_122.xml new file mode 100644 index 0000000..8142237 --- /dev/null +++ b/.idea/libraries/Maven__com_codenameone_codenameone_javase_7_0_122.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_codenameone_qrscanner_common_1_0_SNAPSHOT.xml b/.idea/libraries/Maven__com_codenameone_qrscanner_common_1_0_SNAPSHOT.xml new file mode 100644 index 0000000..58b0ff4 --- /dev/null +++ b/.idea/libraries/Maven__com_codenameone_qrscanner_common_1_0_SNAPSHOT.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6724a16 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..f6f3722 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1614703962614 + + + + \ No newline at end of file diff --git a/README.md b/README.md index 6bfd6b0..b219d3c 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,28 @@ How to use Installation ------------ -1. Install the [cn1-codescan](https://github.com/codenameone/cn1-codescan) library into your project. -1. Build or download the [QRScanner.cn1lib](bin/QRScanner.cn1lib) file. -2. Put the file the `libs` folder of your project. -3. Right-click on your project and choose `Refresh Libs` +### Maven Projects + +Add the following dependency to your project's common/pom.xml file: + +```xml + + com.codenameone + qrscanner-lib + 2.0.2 + pom + +``` + +If you want to hack on the sources, and use a modified version, you can just clone this repository and run `mvn install` to install it into your local Maven repository. + +### Ant Projects + +Use Codename One Preferences to install the QRScanner library. + +or + +Build this project from source, then find the `.cn1lib` file in the `common/target` directory, and copy it to the "libs" directory of your Codename One application project, and select "Refresh Libs". Example Code ------------ @@ -52,3 +70,18 @@ if (CodeScanner.getInstance() != null) { Dialog.show("Not Supported","QR Code Scanning is not available on this device","OK",null); } ``` + +## Configuring Types to Scan For + +By default, the scanner will look for bar codes of type `EAN13` in barcode scanning mode, and `QR_CODE` in QR code scanning mode. +If you want to detect ALL supported code types, you can call the following before making the call to scan the code: + +```java +Display.getInstance().setProperty("scanAllCodeTypes", "true"); +``` + +## Building from Source + +1. Clone this repository +2. Set JAVA_HOME to a JDK 1.8 or JDK 11 installation +3. mvn install diff --git a/Stubber.jar b/Stubber.jar deleted file mode 100644 index 0e08279..0000000 Binary files a/Stubber.jar and /dev/null differ diff --git a/ZBarScannerLibrary.aar b/ZBarScannerLibrary.aar deleted file mode 100644 index e350d6a..0000000 Binary files a/ZBarScannerLibrary.aar and /dev/null differ diff --git a/android/pom.xml b/android/pom.xml new file mode 100644 index 0000000..3bdb9e1 --- /dev/null +++ b/android/pom.xml @@ -0,0 +1,125 @@ + + + 4.0.0 + + com.codenameone + qrscanner + 2.0.3-SNAPSHOT + + com.codenameone + qrscanner-android + 2.0.3-SNAPSHOT + + qrscanner-android + + src/main/dummy + + + src/main/java + + + src/main/resources + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + + package + + + + + + + + + + + + + + run + + + + + + + + + + ${project.groupId} + ${cn1lib.name}-common + ${project.version} + + + + + + kotlin + + + + codenameone_kotlin.properties + + + + + org.jetbrains.kotlin + kotlin-stdlib + + + org.jetbrains + annotations + 13.0 + + + com.codenameone + java-runtime + provided + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + + + + + + diff --git a/native/android/com/codename1/ext/codescan/NativeCodeScannerImpl.java b/android/src/main/java/com/codename1/ext/codescan/NativeCodeScannerImpl.java similarity index 100% rename from native/android/com/codename1/ext/codescan/NativeCodeScannerImpl.java rename to android/src/main/java/com/codename1/ext/codescan/NativeCodeScannerImpl.java diff --git a/native/android/org/littlemonkey/qrscanner/NativeScannerImpl.java b/android/src/main/java/org/littlemonkey/qrscanner/NativeScannerImpl.java similarity index 86% rename from native/android/org/littlemonkey/qrscanner/NativeScannerImpl.java rename to android/src/main/java/org/littlemonkey/qrscanner/NativeScannerImpl.java index 20ad0c8..355290b 100644 --- a/native/android/org/littlemonkey/qrscanner/NativeScannerImpl.java +++ b/android/src/main/java/org/littlemonkey/qrscanner/NativeScannerImpl.java @@ -8,6 +8,7 @@ import com.codename1.io.Log; import net.sourceforge.zbar.Symbol; import com.dm.zbar.android.scanner.*; +import com.codename1.ui.Display; public class NativeScannerImpl { @@ -26,11 +27,14 @@ private void scanCode(boolean qrCode) { } final android.app.Activity ctx = com.codename1.impl.android.AndroidNativeUtil.getActivity(); Intent intent = new Intent(ctx, ZBarScannerActivity.class); - if (qrCode) { - intent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.QRCODE}); - } else { - intent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.EAN13}); + if(Display.getInstance().getProperty("scanAllCodeTypes", "false").equals("false")) { + if (qrCode) { + intent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.QRCODE}); + } else { + intent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.EAN13}); + } } + com.codename1.impl.android.AndroidNativeUtil.startActivityForResult(intent, new IntentResultListener() { public void onActivityResult(int requestCode, int resultCode, Intent data) { diff --git a/native/android/ZBarScannerLibrary.aar b/android/src/main/resources/ZBarScannerLibrary.aar similarity index 100% rename from native/android/ZBarScannerLibrary.aar rename to android/src/main/resources/ZBarScannerLibrary.aar diff --git a/bin/QRScanner.cn1lib b/bin/QRScanner.cn1lib deleted file mode 100644 index 3a23227..0000000 Binary files a/bin/QRScanner.cn1lib and /dev/null differ diff --git a/build.xml b/build.xml deleted file mode 100644 index 14780fd..0000000 --- a/build.xml +++ /dev/null @@ -1,188 +0,0 @@ - - - - - - Builds, tests, and runs the project QRScanner. - - - - - - - - - - - Currently testing a library project isn't supported - - - - Compile is forcing compliance to the supported API's/features for maximum device compatibility. This allows smaller - code size and wider device support - - - - - - - - - - - - - - You can't run a library project - - - - You can't run a library project - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Zipping rim native code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Zipping JavaSE native code - - - - - Zipping Android native code - - - - - - - - - - - - - - - - - Zipping win native code - - - - - - - - - - - - - - - - - Zipping ios native code - - - - - - - - - - - - - - - - - Zipping me native code - - - - diff --git a/codenameone_library.properties b/common/codenameone_library.properties similarity index 100% rename from codenameone_library.properties rename to common/codenameone_library.properties diff --git a/codenameone_library_appended.properties b/common/codenameone_library_appended.properties similarity index 93% rename from codenameone_library_appended.properties rename to common/codenameone_library_appended.properties index d2a8edb..2baa544 100644 --- a/codenameone_library_appended.properties +++ b/common/codenameone_library_appended.properties @@ -7,3 +7,4 @@ codename1.arg.android.xapplication= codename1.arg.android.proguardKeep=\ -keep class net.sourceforge.zbar.** {*;} codename1.arg.android.permission.CAMERA=true +codename1.arg.ios.add_libs=;AVFoundation.framework diff --git a/codenameone_library_required.properties b/common/codenameone_library_required.properties similarity index 100% rename from codenameone_library_required.properties rename to common/codenameone_library_required.properties diff --git a/manifest.properties b/common/manifest.properties similarity index 100% rename from manifest.properties rename to common/manifest.properties diff --git a/common/pom.xml b/common/pom.xml new file mode 100644 index 0000000..ecae43a --- /dev/null +++ b/common/pom.xml @@ -0,0 +1,324 @@ + + + + + com.codenameone + qrscanner + 2.0.3-SNAPSHOT + + 4.0.0 + com.codenameone + qrscanner-common + 2.0.3-SNAPSHOT + jar + + UTF-8 + 8 + 8 + + + + + + + com.codenameone + codenameone-core + ${cn1.version} + provided + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.0.1 + + + build-javadoc + + jar + + post-integration-test + + true + + + + + 1.8 + protected + false + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + + com.codenameone + codenameone-maven-plugin + + + generate-gui-sources + process-sources + + generate-gui-sources + + + + cn1-compliance-check + process-classes + + compliance-check + + + + build-legacy-cn1lib + package + + cn1lib + + + + + + + + + + + + + kotlin + + + + ${basedir}/src/main/kotlin + + + + + org.jetbrains.kotlin + kotlin-stdlib + + + org.jetbrains + annotations + 13.0 + + + com.codenameone + java-runtime + provided + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + compile + + compile + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + + -no-reflect + -no-jdk + + + + + test-compile + + test-compile + + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + + -no-reflect + -no-jdk + + + + + + + + + + + appended-properties + + + ${basedir}/codenameone_library_appended.properties + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + + copy-library-appended-properties + process-resources + + + + + + + + + + + run + + + + + + + + + required-properties + + + ${basedir}/codenameone_library_required.properties + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + + copy-library-required-properties + process-resources + + + + + + + + + + + run + + + + + + + + + + copy-css + + + + ${basedir}/src/main/css + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + + copy-css + process-resources + + + + + + + + + + + + + + + + run + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + + attach-css + package + + attach-artifact + + + + + ${project.build.directory}/${project.build.finalName}-cn1css.zip + zip + cn1css + + + + + + + + + + + + diff --git a/common/src/main/build/stubs/com/codename1/ext/codescan/CodeScanner.java b/common/src/main/build/stubs/com/codename1/ext/codescan/CodeScanner.java new file mode 100644 index 0000000..e5f27f0 --- /dev/null +++ b/common/src/main/build/stubs/com/codename1/ext/codescan/CodeScanner.java @@ -0,0 +1,40 @@ +package com.codename1.ext.codescan; + + +/** + * A barcode/qrcode scanner API, this class is a singleton, notice that this + * API might not be implemented for all platforms in which case the getInstance() + * method will return null! + * + * @author Shai Almog + */ +public class CodeScanner { + + public static boolean isSupported() { + } + + /** + * Returns the instance of the code scanner, notice that this method is equivalent + * to Display.getInstance().getCodeScanner(). + * + * @return instance of the code scanner + */ + public static CodeScanner getInstance() { + } + + /** + * Scans based on the settings in this class and returns the results + * + * @param callback scan results + */ + public void scanQRCode(ScanResult callback) { + } + + /** + * Scans based on the settings in this class and returns the results + * + * @param callback scan results + */ + public void scanBarCode(ScanResult callback) { + } +} diff --git a/common/src/main/build/stubs/com/codename1/ext/codescan/NativeCodeScanner.java b/common/src/main/build/stubs/com/codename1/ext/codescan/NativeCodeScanner.java new file mode 100644 index 0000000..cb68a79 --- /dev/null +++ b/common/src/main/build/stubs/com/codename1/ext/codescan/NativeCodeScanner.java @@ -0,0 +1,13 @@ +package com.codename1.ext.codescan; + + +/** + * + * @author shannah + */ +public interface NativeCodeScanner { + + public void scanQRCode(); + + public void scanBarCode(); +} diff --git a/common/src/main/build/stubs/com/codename1/ext/codescan/ScanResult.java b/common/src/main/build/stubs/com/codename1/ext/codescan/ScanResult.java new file mode 100644 index 0000000..36d39ef --- /dev/null +++ b/common/src/main/build/stubs/com/codename1/ext/codescan/ScanResult.java @@ -0,0 +1,33 @@ +package com.codename1.ext.codescan; + + +/** + * Callback for the code scanner indicating the result of a scan operation, + * the methods of this call will always be invoked on the EDT! + * + * @author Shai Almog + */ +public interface ScanResult { + + /** + * Called upon a successful scan operation + * + * @param contents the contents of the data + * @param formatName the format of the scan + * @param rawBytes the bytes of data + */ + public void scanCompleted(String contents, String formatName, byte[] rawBytes); + + /** + * Invoked if the user canceled the scan + */ + public void scanCanceled(); + + /** + * Invoked if an error occurred during the scanning process + * + * @param errorCode code + * @param message descriptive message + */ + public void scanError(int errorCode, String message); +} diff --git a/common/src/main/build/stubs/org/littlemonkey/qrscanner/NativeScanner.java b/common/src/main/build/stubs/org/littlemonkey/qrscanner/NativeScanner.java new file mode 100644 index 0000000..4088e9e --- /dev/null +++ b/common/src/main/build/stubs/org/littlemonkey/qrscanner/NativeScanner.java @@ -0,0 +1,19 @@ +package org.littlemonkey.qrscanner; + + +/** + * + * @author nick + */ +public interface NativeScanner { + + /** + * Scans based on the settings in this class and returns the results + */ + public void scanQRCode(); + + /** + * Scans based on the settings in this class and returns the results + */ + public void scanBarCode(); +} diff --git a/common/src/main/build/stubs/org/littlemonkey/qrscanner/QRScanner.java b/common/src/main/build/stubs/org/littlemonkey/qrscanner/QRScanner.java new file mode 100644 index 0000000..94d8168 --- /dev/null +++ b/common/src/main/build/stubs/org/littlemonkey/qrscanner/QRScanner.java @@ -0,0 +1,49 @@ +package org.littlemonkey.qrscanner; + + +/** + * QRScanner uses built in ZBar on Android + * Falls back to CodeScanner on other platforms where supported + * + * Removes dependence on a third party scanner being installed. + * + * Needs additional build hints: + * + * android.xapplication = + * android.xpermissions = + * + * And for release builds (only) + * android.proguardKeep = -keep class net.sourceforge.zbar.** {*;} + * + * NOTE THERE NEEDS TO BE A SPACE BEFORE AND AFTER THIS VALUE + * + * @see CodeScanner + * + * @author nick + */ +public class QRScanner { + + public QRScanner() { + } + + /** + * Scan a QR Code with callback + * + * @param callback + */ + public static void scanQRCode(com.codename1.ext.codescan.ScanResult callback) { + } + + /** + * Scan a barcode with callback, + * Currently scans for EAN13 codes on Android. + * Change this in the native implementation. + * + * @param callback + */ + public static void scanBarCode(com.codename1.ext.codescan.ScanResult callback) { + } + + public static com.codename1.ext.codescan.ScanResult getCallback() { + } +} diff --git a/src/com/codename1/ext/codescan/CodeScanner.java b/common/src/main/java/com/codename1/ext/codescan/CodeScanner.java similarity index 100% rename from src/com/codename1/ext/codescan/CodeScanner.java rename to common/src/main/java/com/codename1/ext/codescan/CodeScanner.java diff --git a/src/com/codename1/ext/codescan/NativeCodeScanner.java b/common/src/main/java/com/codename1/ext/codescan/NativeCodeScanner.java similarity index 100% rename from src/com/codename1/ext/codescan/NativeCodeScanner.java rename to common/src/main/java/com/codename1/ext/codescan/NativeCodeScanner.java diff --git a/src/com/codename1/ext/codescan/ScanResult.java b/common/src/main/java/com/codename1/ext/codescan/ScanResult.java similarity index 100% rename from src/com/codename1/ext/codescan/ScanResult.java rename to common/src/main/java/com/codename1/ext/codescan/ScanResult.java diff --git a/src/org/littlemonkey/qrscanner/NativeScanner.java b/common/src/main/java/org/littlemonkey/qrscanner/NativeScanner.java similarity index 100% rename from src/org/littlemonkey/qrscanner/NativeScanner.java rename to common/src/main/java/org/littlemonkey/qrscanner/NativeScanner.java diff --git a/src/org/littlemonkey/qrscanner/QRScanner.java b/common/src/main/java/org/littlemonkey/qrscanner/QRScanner.java similarity index 100% rename from src/org/littlemonkey/qrscanner/QRScanner.java rename to common/src/main/java/org/littlemonkey/qrscanner/QRScanner.java diff --git a/src/com/codename1/ext/codescan/package.html b/common/src/main/resources/com/codename1/ext/codescan/package.html similarity index 100% rename from src/com/codename1/ext/codescan/package.html rename to common/src/main/resources/com/codename1/ext/codescan/package.html diff --git a/common/src/test/java/com/codenameone/FilechooserTest.java b/common/src/test/java/com/codenameone/FilechooserTest.java new file mode 100644 index 0000000..82615b3 --- /dev/null +++ b/common/src/test/java/com/codenameone/FilechooserTest.java @@ -0,0 +1,21 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.codenameone; + +import com.codename1.testing.AbstractTest; + +/** + * + * @author shannah + */ +public class FilechooserTest extends AbstractTest { + + @Override + public boolean runTest() throws Exception { + return true; + } + +} diff --git a/dist/QRScanner.cn1lib b/dist/QRScanner.cn1lib deleted file mode 100644 index b044d32..0000000 Binary files a/dist/QRScanner.cn1lib and /dev/null differ diff --git a/ios/pom.xml b/ios/pom.xml new file mode 100644 index 0000000..ff6a8fc --- /dev/null +++ b/ios/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + com.codenameone + qrscanner + 2.0.3-SNAPSHOT + + com.codenameone + qrscanner-ios + 2.0.3-SNAPSHOT + + qrscanner-ios + + + + src/main/objectivec + + + src/main/resources + + + + + + + ${project.groupId} + ${cn1lib.name}-common + ${project.version} + + + + + diff --git a/ios/src/main/objectivec/CN1AVFoundationCodeScanner.h b/ios/src/main/objectivec/CN1AVFoundationCodeScanner.h new file mode 100644 index 0000000..e6fe289 --- /dev/null +++ b/ios/src/main/objectivec/CN1AVFoundationCodeScanner.h @@ -0,0 +1,11 @@ +#import + +@interface CN1AVFoundationCodeScanner : UIViewController + +@property (strong, nonatomic) AVCaptureSession *session; +@property (strong, nonatomic) AVCaptureVideoPreviewLayer *previewLayer; +@property (strong, nonatomic) NSArray *metadataObjectTypes; + +- (instancetype)initWithMetadataObjectTypes:(NSArray *)metadataObjectTypes; + +@end diff --git a/ios/src/main/objectivec/CN1AVFoundationCodeScanner.m b/ios/src/main/objectivec/CN1AVFoundationCodeScanner.m new file mode 100644 index 0000000..6f0a8ae --- /dev/null +++ b/ios/src/main/objectivec/CN1AVFoundationCodeScanner.m @@ -0,0 +1,112 @@ +#import "com_codename1_ext_codescan_CodeScanner.h" +#import "CN1AVFoundationCodeScanner.h" +#import "CodenameOne_GLViewController.h" + +@implementation CN1AVFoundationCodeScanner + +- (instancetype)initWithMetadataObjectTypes:(NSArray *)metadataObjectTypes { + self = [super init]; + if (self) { + self.metadataObjectTypes = metadataObjectTypes; + } + return self; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + // Additional setup if needed +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + [self scanBarCode]; +} + +- (void)scanBarCode { + dispatch_async(dispatch_get_main_queue(), ^{ + POOL_BEGIN(); + + self.session = [[AVCaptureSession alloc] init]; + AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; + + NSError *error = nil; + AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; + if (!input) { + NSLog(@"Error: %@", error); + return; + } + [self.session addInput:input]; + + AVCaptureMetadataOutput *output = [[AVCaptureMetadataOutput alloc] init]; + [output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()]; + [self.session addOutput:output]; + + // Specify the types of metadata objects to recognize + if (self.metadataObjectTypes && self.metadataObjectTypes.count > 0) { + output.metadataObjectTypes = self.metadataObjectTypes; + } else { + output.metadataObjectTypes = output.availableMetadataObjectTypes; + } + + self.previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:self.session]; + self.previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; + self.previewLayer.frame = self.view.layer.bounds; + [self.view.layer addSublayer:self.previewLayer]; + + // Add tap gesture recognizer to cancel scanning + UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cancelScanning)]; + [self.view addGestureRecognizer:tapGesture]; + + [self.session startRunning]; + POOL_END(); + }); +} + +- (void)cancelScanning { + [self cleanupScanning]; + com_codename1_ext_codescan_CodeScanner_scanCanceledCallback__(CN1_THREAD_GET_STATE_PASS_SINGLE_ARG); +} + +-(void)cleanupScanning { + [self.session stopRunning]; + [self.previewLayer removeFromSuperlayer]; + // Remove the tap gesture recognizer + for (UIGestureRecognizer *recognizer in self.view.gestureRecognizers) { + if ([recognizer isKindOfClass:[UITapGestureRecognizer class]]) { + [self.view removeGestureRecognizer:recognizer]; + } + } + [self dismissModalViewControllerAnimated: YES]; +} + +#pragma mark - AVCaptureMetadataOutputObjectsDelegate + +- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray<__kindof AVMetadataObject *> *)metadataObjects fromConnection:(AVCaptureConnection *)connection { + for (AVMetadataObject *metadataObject in metadataObjects) { + if (self.metadataObjectTypes == nil || self.metadataObjectTypes.count == 0 || [self.metadataObjectTypes containsObject:metadataObject.type]) { + AVMetadataMachineReadableCodeObject *readableObject = (AVMetadataMachineReadableCodeObject *)metadataObject; + NSString *scannedResult = readableObject.stringValue; + NSString *codeType = readableObject.type; + // Handle the scanned result + NSLog(@"Scanned code: %@", scannedResult); + [self.session stopRunning]; // Stop the session once we get a result + [self.previewLayer removeFromSuperlayer]; + [self cleanupScanning]; // Clean up gesture recognizers and dismiss view controller + com_codename1_ext_codescan_CodeScanner_scanCompletedCallback___java_lang_String_java_lang_String_byte_1ARRAY( + CN1_THREAD_GET_STATE_PASS_ARG + fromNSString( + CN1_THREAD_GET_STATE_PASS_ARG + scannedResult + ), + fromNSString( + CN1_THREAD_GET_STATE_PASS_ARG + codeType + ), + JAVA_NULL + ); + break; + } + } +} + +@end diff --git a/native/ios/CVZBarReaderViewControllerExt.h b/ios/src/main/objectivec/CVZBarReaderViewControllerExt.h similarity index 100% rename from native/ios/CVZBarReaderViewControllerExt.h rename to ios/src/main/objectivec/CVZBarReaderViewControllerExt.h diff --git a/ios/src/main/objectivec/CVZBarReaderViewControllerExt.m b/ios/src/main/objectivec/CVZBarReaderViewControllerExt.m new file mode 100644 index 0000000..baaa7a9 --- /dev/null +++ b/ios/src/main/objectivec/CVZBarReaderViewControllerExt.m @@ -0,0 +1,28 @@ +#import "CVZBarReaderViewControllerExt.h" +#if !TARGET_IPHONE_SIMULATOR + +@implementation CVZBarReaderViewControllerExt +- (void) loadView +{ +#ifdef CN1_USE_ARC + self.view = [[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 480)]; +#else + self.view = [[[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 480)] autorelease]; +#endif +} + +// Hack to hide the info button because it would just crash when pressed. +// https://github.com/codenameone/CodenameOne/issues/3287 +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + // Accessing the toolbar + UIToolbar *toolbar = [[controls subviews] firstObject]; + + // Only keeping the first two items of the toolbar, thus deleting the info button + if ([toolbar isKindOfClass:UIToolbar.class]) { + toolbar.items = @[ toolbar.items[0], toolbar.items[1] ]; + } +} +@end +#endif diff --git a/native/ios/Decoder.h b/ios/src/main/objectivec/Decoder.h similarity index 100% rename from native/ios/Decoder.h rename to ios/src/main/objectivec/Decoder.h diff --git a/native/ios/Image.h b/ios/src/main/objectivec/Image.h similarity index 100% rename from native/ios/Image.h rename to ios/src/main/objectivec/Image.h diff --git a/native/ios/ImageScanner.h b/ios/src/main/objectivec/ImageScanner.h similarity index 100% rename from native/ios/ImageScanner.h rename to ios/src/main/objectivec/ImageScanner.h diff --git a/native/ios/Processor.h b/ios/src/main/objectivec/Processor.h similarity index 100% rename from native/ios/Processor.h rename to ios/src/main/objectivec/Processor.h diff --git a/native/ios/ScanCodeImplExt.h b/ios/src/main/objectivec/ScanCodeImplExt.h similarity index 100% rename from native/ios/ScanCodeImplExt.h rename to ios/src/main/objectivec/ScanCodeImplExt.h diff --git a/native/ios/ScanCodeImplExt.m b/ios/src/main/objectivec/ScanCodeImplExt.m similarity index 100% rename from native/ios/ScanCodeImplExt.m rename to ios/src/main/objectivec/ScanCodeImplExt.m diff --git a/native/ios/Scanner.h b/ios/src/main/objectivec/Scanner.h similarity index 100% rename from native/ios/Scanner.h rename to ios/src/main/objectivec/Scanner.h diff --git a/native/ios/Symbol.h b/ios/src/main/objectivec/Symbol.h similarity index 100% rename from native/ios/Symbol.h rename to ios/src/main/objectivec/Symbol.h diff --git a/native/ios/Video.h b/ios/src/main/objectivec/Video.h similarity index 100% rename from native/ios/Video.h rename to ios/src/main/objectivec/Video.h diff --git a/native/ios/Window.h b/ios/src/main/objectivec/Window.h similarity index 100% rename from native/ios/Window.h rename to ios/src/main/objectivec/Window.h diff --git a/native/ios/ZBarCameraSimulator.h b/ios/src/main/objectivec/ZBarCameraSimulator.h similarity index 100% rename from native/ios/ZBarCameraSimulator.h rename to ios/src/main/objectivec/ZBarCameraSimulator.h diff --git a/native/ios/ZBarCaptureReader.h b/ios/src/main/objectivec/ZBarCaptureReader.h similarity index 100% rename from native/ios/ZBarCaptureReader.h rename to ios/src/main/objectivec/ZBarCaptureReader.h diff --git a/native/ios/ZBarHelpController.h b/ios/src/main/objectivec/ZBarHelpController.h similarity index 94% rename from native/ios/ZBarHelpController.h rename to ios/src/main/objectivec/ZBarHelpController.h index 37639dd..4badddc 100644 --- a/native/ios/ZBarHelpController.h +++ b/ios/src/main/objectivec/ZBarHelpController.h @@ -22,6 +22,7 @@ //------------------------------------------------------------------------ #import +#import @class ZBarHelpController; @@ -36,12 +37,12 @@ // failure dialog w/a few useful tips @interface ZBarHelpController : UIViewController - < UIWebViewDelegate, + < WKNavigationDelegate, UIAlertViewDelegate > { NSString *reason; id delegate; - UIWebView *webView; + WKWebView *webView; UIToolbar *toolbar; UIBarButtonItem *doneBtn, *backBtn, *space; NSURL *linkURL; diff --git a/native/ios/ZBarImage.h b/ios/src/main/objectivec/ZBarImage.h similarity index 100% rename from native/ios/ZBarImage.h rename to ios/src/main/objectivec/ZBarImage.h diff --git a/native/ios/ZBarImageScanner.h b/ios/src/main/objectivec/ZBarImageScanner.h similarity index 100% rename from native/ios/ZBarImageScanner.h rename to ios/src/main/objectivec/ZBarImageScanner.h diff --git a/native/ios/ZBarReaderController.h b/ios/src/main/objectivec/ZBarReaderController.h similarity index 100% rename from native/ios/ZBarReaderController.h rename to ios/src/main/objectivec/ZBarReaderController.h diff --git a/native/ios/ZBarReaderView.h b/ios/src/main/objectivec/ZBarReaderView.h similarity index 95% rename from native/ios/ZBarReaderView.h rename to ios/src/main/objectivec/ZBarReaderView.h index bc75c9d..dfb4dfd 100644 --- a/native/ios/ZBarReaderView.h +++ b/ios/src/main/objectivec/ZBarReaderView.h @@ -36,6 +36,11 @@ didReadSymbols: (ZBarSymbolSet*) symbols fromImage: (UIImage*) image; +@optional +- (void) readerViewDidStart: (ZBarReaderView*) readerView; +- (void) readerView: (ZBarReaderView*) readerView + didStopWithError: (NSError*) error; + @end // read barcodes from the displayed video preview. the view maintains @@ -62,7 +67,7 @@ UIPinchGestureRecognizer *pinch; CGFloat imageScale; CGSize imageSize; - BOOL started, running; + BOOL started, running, locked; } // supply a pre-configured image scanner. diff --git a/native/ios/ZBarReaderViewController.h b/ios/src/main/objectivec/ZBarReaderViewController.h similarity index 99% rename from native/ios/ZBarReaderViewController.h rename to ios/src/main/objectivec/ZBarReaderViewController.h index be2bf21..20fb7e9 100644 --- a/native/ios/ZBarReaderViewController.h +++ b/ios/src/main/objectivec/ZBarReaderViewController.h @@ -56,7 +56,7 @@ BOOL showsZBarControls, tracksSymbols, enableCache; ZBarHelpController *helpController; - UIView *controls; + UIView *controls, *shutter; BOOL didHideStatusBar, rotating; ZBarCameraSimulator *cameraSim; } diff --git a/native/ios/ZBarSDK.h b/ios/src/main/objectivec/ZBarSDK.h similarity index 100% rename from native/ios/ZBarSDK.h rename to ios/src/main/objectivec/ZBarSDK.h diff --git a/native/ios/ZBarSymbol.h b/ios/src/main/objectivec/ZBarSymbol.h similarity index 100% rename from native/ios/ZBarSymbol.h rename to ios/src/main/objectivec/ZBarSymbol.h diff --git a/native/ios/com_codename1_ext_codescan_NativeCodeScannerImpl.h b/ios/src/main/objectivec/com_codename1_ext_codescan_NativeCodeScannerImpl.h similarity index 59% rename from native/ios/com_codename1_ext_codescan_NativeCodeScannerImpl.h rename to ios/src/main/objectivec/com_codename1_ext_codescan_NativeCodeScannerImpl.h index f4d7a75..f4a07f2 100644 --- a/native/ios/com_codename1_ext_codescan_NativeCodeScannerImpl.h +++ b/ios/src/main/objectivec/com_codename1_ext_codescan_NativeCodeScannerImpl.h @@ -1,4 +1,8 @@ #import +#define CN1_QRSCANNER_AVFOUNDATION 1 +#ifdef CN1_QRSCANNER_AVFOUNDATION +#import "CN1AVFoundationCodeScanner.h" +#endif @interface com_codename1_ext_codescan_NativeCodeScannerImpl : NSObject { } diff --git a/ios/src/main/objectivec/com_codename1_ext_codescan_NativeCodeScannerImpl.m b/ios/src/main/objectivec/com_codename1_ext_codescan_NativeCodeScannerImpl.m new file mode 100644 index 0000000..300421d --- /dev/null +++ b/ios/src/main/objectivec/com_codename1_ext_codescan_NativeCodeScannerImpl.m @@ -0,0 +1,96 @@ +#import "com_codename1_ext_codescan_NativeCodeScannerImpl.h" +#import "ScanCodeImplExt.h" +#import "CodenameOne_GLViewController.h" +#import "cn1_globals.h" +#import "com_codename1_ui_Display.h" +@implementation com_codename1_ext_codescan_NativeCodeScannerImpl + +-(void)scanQRCode{ +#ifdef CN1_QRSCANNER_AVFOUNDATION + dispatch_async(dispatch_get_main_queue(), ^{ + CN1AVFoundationCodeScanner *scannerViewController = [self isScanAllTypesEnabled] + ? [[CN1AVFoundationCodeScanner alloc] init] + : [[CN1AVFoundationCodeScanner alloc] initWithMetadataObjectTypes: [self getQRScanningTypes]]; + + [[CodenameOne_GLViewController instance] presentModalViewController:scannerViewController animated:NO]; + }); + + return; +#endif + [self scanBarCode]; +} + +-(NSArray*) getBarCodeScanningTypes { + return @[AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypeEAN8Code, AVMetadataObjectTypeUPCECode]; +} + +-(NSArray*) getQRScanningTypes { + return @[AVMetadataObjectTypeQRCode]; +} + +-(BOOL) isScanAllTypesEnabled { + NSString *resultString = [self getStringDisplayProperty: @"scanAllCodeTypes" default: @"false"]; + return [resultString isEqualToString:@"true"]; +} + +-(NSString*) getStringDisplayProperty: (NSString*)key default:(NSString*)defaultVal { + struct ThreadLocalData* threadStateData = getThreadLocalData(); + enteringNativeAllocations(); + JAVA_OBJECT d = com_codename1_ui_Display_getInstance__(CN1_THREAD_GET_STATE_PASS_SINGLE_ARG); + JAVA_OBJECT jkey = fromNSString(CN1_THREAD_GET_STATE_PASS_ARG key); + JAVA_OBJECT jdefaultVal = fromNSString(CN1_THREAD_GET_STATE_PASS_ARG defaultVal); + JAVA_OBJECT res = com_codename1_ui_Display_getProperty___java_lang_String_java_lang_String_R_java_lang_String( + CN1_THREAD_GET_STATE_PASS_ARG d, + jkey, + jdefaultVal + ); + finishedNativeAllocations(); + + return toNSString(CN1_THREAD_GET_STATE_PASS_ARG res); +} + +-(void)scanBarCode{ +#ifdef CN1_QRSCANNER_AVFOUNDATION + dispatch_async(dispatch_get_main_queue(), ^{ + CN1AVFoundationCodeScanner *scannerViewController = [self isScanAllTypesEnabled] + ? [[CN1AVFoundationCodeScanner alloc] init] + : [[CN1AVFoundationCodeScanner alloc] initWithMetadataObjectTypes: [self getBarCodeScanningTypes]]; + + [[CodenameOne_GLViewController instance] presentModalViewController:scannerViewController animated:NO]; + + }); + return; +#endif +#if !TARGET_IPHONE_SIMULATOR + dispatch_async(dispatch_get_main_queue(), ^{ + POOL_BEGIN(); + CVZBarReaderViewControllerExt *reader = [CVZBarReaderViewControllerExt new]; + ScanCodeImplExt* scanCall = [[ScanCodeImplExt alloc] init]; + reader.readerDelegate = scanCall; + reader.supportedOrientationsMask = ZBarOrientationMaskAll; + + //ZBAR_CONFIGURATIONS + + ZBarImageScanner *scanner = reader.scanner; + // TODO: (optional) additional reader configuration here + + // EXAMPLE: disable rarely used I2/5 to improve performance + [scanner setSymbology: ZBAR_I25 + config: ZBAR_CFG_ENABLE + to: 0]; + + // present and release the controller + [[CodenameOne_GLViewController instance] presentModalViewController:reader animated:NO]; +#ifndef CN1_USE_ARC + [reader release]; +#endif + POOL_END(); + }); +#endif +} + +-(BOOL)isSupported{ + return YES; +} + +@end diff --git a/native/ios/org_littlemonkey_qrscanner_NativeScannerImpl.h b/ios/src/main/objectivec/org_littlemonkey_qrscanner_NativeScannerImpl.h similarity index 100% rename from native/ios/org_littlemonkey_qrscanner_NativeScannerImpl.h rename to ios/src/main/objectivec/org_littlemonkey_qrscanner_NativeScannerImpl.h diff --git a/native/ios/org_littlemonkey_qrscanner_NativeScannerImpl.m b/ios/src/main/objectivec/org_littlemonkey_qrscanner_NativeScannerImpl.m similarity index 100% rename from native/ios/org_littlemonkey_qrscanner_NativeScannerImpl.m rename to ios/src/main/objectivec/org_littlemonkey_qrscanner_NativeScannerImpl.m diff --git a/native/ios/zbar.h b/ios/src/main/objectivec/zbar.h similarity index 100% rename from native/ios/zbar.h rename to ios/src/main/objectivec/zbar.h diff --git a/ios/src/main/resources/libzbar.a b/ios/src/main/resources/libzbar.a new file mode 100644 index 0000000..aafe44c Binary files /dev/null and b/ios/src/main/resources/libzbar.a differ diff --git a/native/ios/zbar-help.html b/ios/src/main/resources/zbar-help.html similarity index 100% rename from native/ios/zbar-help.html rename to ios/src/main/resources/zbar-help.html diff --git a/native/ios/zbar-helpicons.png b/ios/src/main/resources/zbar-helpicons.png similarity index 100% rename from native/ios/zbar-helpicons.png rename to ios/src/main/resources/zbar-helpicons.png diff --git a/native/ios/zbar-samples.png b/ios/src/main/resources/zbar-samples.png similarity index 100% rename from native/ios/zbar-samples.png rename to ios/src/main/resources/zbar-samples.png diff --git a/javascript/pom.xml b/javascript/pom.xml new file mode 100644 index 0000000..95bc5bc --- /dev/null +++ b/javascript/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + com.codenameone + qrscanner + 2.0.3-SNAPSHOT + + com.codenameone + qrscanner-javascript + 2.0.3-SNAPSHOT + + qrscanner-javascript + + + + src/main/javascript + + + src/main/resources + + + + + + + ${project.groupId} + ${cn1lib.name}-common + ${project.version} + + + + + diff --git a/native/javascript/com_codename1_ext_codescan_NativeCodeScanner.js b/javascript/src/main/javascript/com_codename1_ext_codescan_NativeCodeScanner.js similarity index 100% rename from native/javascript/com_codename1_ext_codescan_NativeCodeScanner.js rename to javascript/src/main/javascript/com_codename1_ext_codescan_NativeCodeScanner.js diff --git a/javase/pom.xml b/javase/pom.xml new file mode 100644 index 0000000..02bbf26 --- /dev/null +++ b/javase/pom.xml @@ -0,0 +1,38 @@ + + + 4.0.0 + + com.codenameone + qrscanner + 2.0.3-SNAPSHOT + + com.codenameone + qrscanner-javase + 2.0.3-SNAPSHOT + + qrscanner-javase + + + UTF-8 + 1.8 + 1.8 + + + + + + + com.codenameone + codenameone-javase + provided + + + ${project.groupId} + ${cn1lib.name}-common + ${project.version} + + + + + + diff --git a/native/javase/com/codename1/ext/codescan/NativeCodeScannerImpl.java b/javase/src/main/java/com/codename1/ext/codescan/NativeCodeScannerImpl.java similarity index 100% rename from native/javase/com/codename1/ext/codescan/NativeCodeScannerImpl.java rename to javase/src/main/java/com/codename1/ext/codescan/NativeCodeScannerImpl.java diff --git a/javase/src/main/java/org/littlemonkey/qrscanner/NativeScannerImpl.java b/javase/src/main/java/org/littlemonkey/qrscanner/NativeScannerImpl.java new file mode 100644 index 0000000..22ca197 --- /dev/null +++ b/javase/src/main/java/org/littlemonkey/qrscanner/NativeScannerImpl.java @@ -0,0 +1,30 @@ +package org.littlemonkey.qrscanner; + +public class NativeScannerImpl implements org.littlemonkey.qrscanner.NativeScanner{ + + private static boolean cameraUsageDescriptionChecked; + public void scanQRCode() { + } + + public void scanBarCode() { + } + + public boolean isSupported() { + checkCameraUsageDescription(); + return false; + } + + private static void checkCameraUsageDescription() { + if (!cameraUsageDescriptionChecked) { + cameraUsageDescriptionChecked = true; + + java.util.Map m = com.codename1.ui.Display.getInstance().getProjectBuildHints(); + if(m != null) { + if(!m.containsKey("ios.NSCameraUsageDescription")) { + com.codename1.ui.Display.getInstance().setProjectBuildHint("ios.NSCameraUsageDescription", "Some functionality of the application requires your camera"); + } + } + } + } + +} diff --git a/lib/CLDC11.jar b/lib/CLDC11.jar deleted file mode 100644 index 6d5eb73..0000000 Binary files a/lib/CLDC11.jar and /dev/null differ diff --git a/lib/CodenameOne.jar b/lib/CodenameOne.jar deleted file mode 100644 index 44f0d66..0000000 Binary files a/lib/CodenameOne.jar and /dev/null differ diff --git a/lib/CodenameOne_SRC.zip b/lib/CodenameOne_SRC.zip deleted file mode 100644 index c52032c..0000000 Binary files a/lib/CodenameOne_SRC.zip and /dev/null differ diff --git a/lib/impl/cls/com/codename1/ext/codescan/CodeScanner$1.class b/lib/impl/cls/com/codename1/ext/codescan/CodeScanner$1.class deleted file mode 100644 index 809cfcc..0000000 Binary files a/lib/impl/cls/com/codename1/ext/codescan/CodeScanner$1.class and /dev/null differ diff --git a/lib/impl/cls/com/codename1/ext/codescan/CodeScanner$2.class b/lib/impl/cls/com/codename1/ext/codescan/CodeScanner$2.class deleted file mode 100644 index e14f432..0000000 Binary files a/lib/impl/cls/com/codename1/ext/codescan/CodeScanner$2.class and /dev/null differ diff --git a/lib/impl/cls/com/codename1/ext/codescan/CodeScanner$3.class b/lib/impl/cls/com/codename1/ext/codescan/CodeScanner$3.class deleted file mode 100644 index d703706..0000000 Binary files a/lib/impl/cls/com/codename1/ext/codescan/CodeScanner$3.class and /dev/null differ diff --git a/lib/impl/cls/com/codename1/ext/codescan/CodeScanner.class b/lib/impl/cls/com/codename1/ext/codescan/CodeScanner.class deleted file mode 100644 index 2c7c3ef..0000000 Binary files a/lib/impl/cls/com/codename1/ext/codescan/CodeScanner.class and /dev/null differ diff --git a/lib/impl/cls/com/codename1/ext/codescan/NativeCodeScanner.class b/lib/impl/cls/com/codename1/ext/codescan/NativeCodeScanner.class deleted file mode 100644 index ddf66c3..0000000 Binary files a/lib/impl/cls/com/codename1/ext/codescan/NativeCodeScanner.class and /dev/null differ diff --git a/lib/impl/cls/com/codename1/ext/codescan/ScanResult.class b/lib/impl/cls/com/codename1/ext/codescan/ScanResult.class deleted file mode 100644 index 7e62bbf..0000000 Binary files a/lib/impl/cls/com/codename1/ext/codescan/ScanResult.class and /dev/null differ diff --git a/lib/pom.xml b/lib/pom.xml new file mode 100644 index 0000000..ec27a2c --- /dev/null +++ b/lib/pom.xml @@ -0,0 +1,115 @@ + + + 4.0.0 + + com.codenameone + qrscanner + 2.0.3-SNAPSHOT + + com.codenameone + qrscanner-lib + 2.0.3-SNAPSHOT + pom + qrscanner-lib + + + UTF-8 + 1.8 + 1.8 + + + + + + + ${project.groupId} + ${cn1lib.name}-common + ${project.version} + + + + + + javase + + + codename1.platform + javase + + + + + ${project.groupId} + ${cn1lib.name}-javase + ${project.version} + + + + + javascript + + + codename1.platform + javascript + + + + + ${project.groupId} + ${cn1lib.name}-javascript + ${project.version} + + + + + ios + + + codename1.platform + ios + + + + + ${project.groupId} + ${cn1lib.name}-ios + ${project.version} + + + + + win + + + codename1.platform + win + + + + + ${project.groupId} + ${cn1lib.name}-win + ${project.version} + + + + + android + + + codename1.platform + android + + + + + ${project.groupId} + ${cn1lib.name}-android + ${project.version} + + + + + + + diff --git a/manifest.mf b/manifest.mf deleted file mode 100644 index 1574df4..0000000 --- a/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/native/internal_tmp/com/codename1/ext/codescan/NativeCodeScannerImpl.class b/native/internal_tmp/com/codename1/ext/codescan/NativeCodeScannerImpl.class deleted file mode 100644 index 80ce82b..0000000 Binary files a/native/internal_tmp/com/codename1/ext/codescan/NativeCodeScannerImpl.class and /dev/null differ diff --git a/native/ios/CVZBarReaderViewControllerExt.m b/native/ios/CVZBarReaderViewControllerExt.m deleted file mode 100644 index f1b4746..0000000 --- a/native/ios/CVZBarReaderViewControllerExt.m +++ /dev/null @@ -1,14 +0,0 @@ -#import "CVZBarReaderViewControllerExt.h" -#if !TARGET_IPHONE_SIMULATOR - -@implementation CVZBarReaderViewControllerExt -- (void) loadView -{ -#ifdef CN1_USE_ARC - self.view = [[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 480)]; -#else - self.view = [[[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 480)] autorelease]; -#endif -} -@end -#endif diff --git a/native/ios/ZBARException.h b/native/ios/ZBARException.h deleted file mode 100644 index 236622f..0000000 --- a/native/ios/ZBARException.h +++ /dev/null @@ -1,187 +0,0 @@ -//------------------------------------------------------------------------ -// Copyright 2007-2009 (c) Jeff Brown -// -// This file is part of the ZBar Bar Code Reader. -// -// The ZBar Bar Code Reader is free software; you can redistribute it -// and/or modify it under the terms of the GNU Lesser Public License as -// published by the Free Software Foundation; either version 2.1 of -// the License, or (at your option) any later version. -// -// The ZBar Bar Code Reader is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser Public License for more details. -// -// You should have received a copy of the GNU Lesser Public License -// along with the ZBar Bar Code Reader; if not, write to the Free -// Software Foundation, Inc., 51 Franklin St, Fifth Floor, -// Boston, MA 02110-1301 USA -// -// http://sourceforge.net/projects/zbar -//------------------------------------------------------------------------ -#ifndef _ZBAR_EXCEPTION_H_ -#define _ZBAR_EXCEPTION_H_ - -/// @file -/// C++ Exception definitions - -#ifndef _ZBAR_H_ -# error "include zbar.h in your application, **not** zbar/Exception.h" -#endif - -#include -#include - -namespace zbar { - -/// base class for exceptions defined by this API. -class Exception : public std::exception { - -public: - /// create exception from C library error - Exception (const void *obj = NULL) - : std::exception(), - _obj(obj) - { } - - ~Exception () throw() { } - - /// retrieve error message - virtual const char* what () const throw() - { - if(!_obj) - return("zbar library unspecified generic error"); - return(_zbar_error_string(_obj, 0)); - } - -private: - const void *_obj; -}; - -/// internal library error. -class InternalError : public Exception { -public: - /// create exception from C library error - InternalError (const void *obj) - : Exception(obj) - { } -}; - -/// unsupported request. -class UnsupportedError : public Exception { -public: - /// create exception from C library error - UnsupportedError (const void *obj) - : Exception(obj) - { } -}; - -/// invalid request. -class InvalidError : public Exception { -public: - /// create exception from C library error - InvalidError (const void *obj) - : Exception(obj) - { } -}; - -/// failed system call. -class SystemError : public Exception { -public: - /// create exception from C library error - SystemError (const void *obj) - : Exception(obj) - { } -}; - -/// locking error. -class LockingError : public Exception { -public: - /// create exception from C library error - LockingError (const void *obj) - : Exception(obj) - { } -}; - -/// all resources busy. -class BusyError : public Exception { -public: - /// create exception from C library error - BusyError (const void *obj) - : Exception(obj) - { } -}; - -/// X11 display error. -class XDisplayError : public Exception { -public: - /// create exception from C library error - XDisplayError (const void *obj) - : Exception(obj) - { } -}; - -/// X11 protocol error. -class XProtoError : public Exception { -public: - /// create exception from C library error - XProtoError (const void *obj) - : Exception(obj) - { } -}; - -/// output window is closed. -class ClosedError : public Exception { -public: - /// create exception from C library error - ClosedError (const void *obj) - : Exception(obj) - { } -}; - -/// image format error -class FormatError : public Exception { - // FIXME needs c equivalent - - virtual const char* what () const throw() - { - // FIXME what format? - return("unsupported format"); - } -}; - -/// @internal - -/// extract error information and create exception. -static inline std::exception throw_exception (const void *obj) -{ - switch(_zbar_get_error_code(obj)) { - case ZBAR_ERR_NOMEM: - throw std::bad_alloc(); - case ZBAR_ERR_INTERNAL: - throw InternalError(obj); - case ZBAR_ERR_UNSUPPORTED: - throw UnsupportedError(obj); - case ZBAR_ERR_INVALID: - throw InvalidError(obj); - case ZBAR_ERR_SYSTEM: - throw SystemError(obj); - case ZBAR_ERR_LOCKING: - throw LockingError(obj); - case ZBAR_ERR_BUSY: - throw BusyError(obj); - case ZBAR_ERR_XDISPLAY: - throw XDisplayError(obj); - case ZBAR_ERR_XPROTO: - throw XProtoError(obj); - case ZBAR_ERR_CLOSED: - throw ClosedError(obj); - default: - throw Exception(obj); - } -} - -} - -#endif diff --git a/native/ios/com_codename1_ext_codescan_NativeCodeScannerImpl.m b/native/ios/com_codename1_ext_codescan_NativeCodeScannerImpl.m deleted file mode 100644 index 3ea41a8..0000000 --- a/native/ios/com_codename1_ext_codescan_NativeCodeScannerImpl.m +++ /dev/null @@ -1,44 +0,0 @@ -#import "com_codename1_ext_codescan_NativeCodeScannerImpl.h" -#import "ScanCodeImplExt.h" -#import "CodenameOne_GLViewController.h" - -@implementation com_codename1_ext_codescan_NativeCodeScannerImpl - --(void)scanQRCode{ - [self scanBarCode]; -} - --(void)scanBarCode{ -#if !TARGET_IPHONE_SIMULATOR - dispatch_async(dispatch_get_main_queue(), ^{ - POOL_BEGIN(); - CVZBarReaderViewControllerExt *reader = [CVZBarReaderViewControllerExt new]; - ScanCodeImplExt* scanCall = [[ScanCodeImplExt alloc] init]; - reader.readerDelegate = scanCall; - reader.supportedOrientationsMask = ZBarOrientationMaskAll; - - //ZBAR_CONFIGURATIONS - - ZBarImageScanner *scanner = reader.scanner; - // TODO: (optional) additional reader configuration here - - // EXAMPLE: disable rarely used I2/5 to improve performance - [scanner setSymbology: ZBAR_I25 - config: ZBAR_CFG_ENABLE - to: 0]; - - // present and release the controller - [[CodenameOne_GLViewController instance] presentModalViewController:reader animated:NO]; -#ifndef CN1_USE_ARC - [reader release]; -#endif - POOL_END(); - }); -#endif -} - --(BOOL)isSupported{ - return YES; -} - -@end diff --git a/native/ios/libzbar.a b/native/ios/libzbar.a deleted file mode 100644 index 7533efb..0000000 Binary files a/native/ios/libzbar.a and /dev/null differ diff --git a/native/j2me/com/codename1/ext/codescan/AdvancedMultimediaManager.java b/native/j2me/com/codename1/ext/codescan/AdvancedMultimediaManager.java deleted file mode 100644 index 25dd189..0000000 --- a/native/j2me/com/codename1/ext/codescan/AdvancedMultimediaManager.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.codename1.ext.codescan; - -import javax.microedition.amms.control.camera.ExposureControl; -import javax.microedition.amms.control.camera.FocusControl; -import javax.microedition.amms.control.camera.ZoomControl; -import javax.microedition.amms.control.camera.FlashControl; -import javax.microedition.media.Controllable; -import javax.microedition.media.MediaException; -import javax.microedition.media.Control; - -/** - *

Implementation suitable for JSR-234 phones which takes advantage of advanced camera - * capability.

- * - * @author Sean Owen - */ -final class AdvancedMultimediaManager implements MultimediaManager { - - private static final int NO_ZOOM = 100; - private static final int MAX_ZOOM = 200; - private static final long FOCUS_TIME_MS = 750L; - private static final String DESIRED_METERING = "center-weighted"; - private static final int DESIRED_FLASH = FlashControl.AUTO; - - public void setFocus(Controllable player) { - FocusControl focusControl = - (FocusControl) getControl(player, "javax.microedition.amms.control.camera.FocusControl"); - if (focusControl != null) { - try { - if (focusControl.isMacroSupported() && !focusControl.getMacro()) { - focusControl.setMacro(true); - } - if (focusControl.isAutoFocusSupported()) { - focusControl.setFocus(FocusControl.AUTO); - try { - Thread.sleep(FOCUS_TIME_MS); // let it focus... - } catch (InterruptedException ie) { - // continue - } - focusControl.setFocus(FocusControl.AUTO_LOCK); - } - } catch (MediaException me) { - // continue - } - } - } - - public void setZoom(Controllable player) { - ZoomControl zoomControl = (ZoomControl) getControl(player, "javax.microedition.amms.control.camera.ZoomControl"); - if (zoomControl != null) { - // We zoom in if possible to encourage the viewer to take a snapshot from a greater distance. - // This is a crude way of dealing with the fact that many phone cameras will not focus at a - // very close range. - int maxZoom = zoomControl.getMaxOpticalZoom(); - if (maxZoom > NO_ZOOM) { - zoomControl.setOpticalZoom(maxZoom > MAX_ZOOM ? MAX_ZOOM : maxZoom); - } else { - int maxDigitalZoom = zoomControl.getMaxDigitalZoom(); - if (maxDigitalZoom > NO_ZOOM) { - zoomControl.setDigitalZoom(maxDigitalZoom > MAX_ZOOM ? MAX_ZOOM : maxDigitalZoom); - } - } - } - } - - public void setExposure(Controllable player) { - ExposureControl exposureControl = - (ExposureControl) getControl(player, "javax.microedition.amms.control.camera.ExposureControl"); - if (exposureControl != null) { - - int[] supportedISOs = exposureControl.getSupportedISOs(); - if (supportedISOs != null && supportedISOs.length > 0) { - int maxISO = Integer.MIN_VALUE; - for (int i = 0; i < supportedISOs.length; i++) { - if (supportedISOs[i] > maxISO) { - maxISO = supportedISOs[i]; - } - } - try { - exposureControl.setISO(maxISO); - } catch (MediaException me) { - // continue - } - } - - String[] supportedMeterings = exposureControl.getSupportedLightMeterings(); - if (supportedMeterings != null) { - for (int i = 0; i < supportedMeterings.length; i++) { - if (DESIRED_METERING.equals(supportedMeterings[i])) { - exposureControl.setLightMetering(DESIRED_METERING); - break; - } - } - } - - } - } - - public void setFlash(Controllable player) { - FlashControl flashControl = - (FlashControl) getControl(player, "javax.microedition.amms.control.camera.FlashControl"); - if (flashControl != null) { - int[] supportedFlash = flashControl.getSupportedModes(); - if (supportedFlash != null && supportedFlash.length > 0) { - for (int i = 0; i < supportedFlash.length; i++) { - if (supportedFlash[i] == DESIRED_FLASH) { - try { - flashControl.setMode(DESIRED_FLASH); - } catch (IllegalArgumentException iae) { - // continue - } - break; - } - } - } - } - } - - private static Control getControl(Controllable player, String fullName) { - Control control = player.getControl(fullName); - if (control == null) { - String shortName = fullName.substring(fullName.lastIndexOf('.') + 1); - control = player.getControl(shortName); - } - return control; - } - -} \ No newline at end of file diff --git a/native/j2me/com/codename1/ext/codescan/BarCodeScanner.java b/native/j2me/com/codename1/ext/codescan/BarCodeScanner.java deleted file mode 100644 index 4a085c1..0000000 --- a/native/j2me/com/codename1/ext/codescan/BarCodeScanner.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.codename1.ext.codescan; - -import com.codename1.media.Media; - -import javax.microedition.media.Player; -import javax.microedition.media.control.VideoControl; - -import com.google.zxing.Result; -import com.codename1.ui.Button; -import com.codename1.ui.Command; -import com.codename1.ui.Component; -import com.codename1.ui.Container; -import com.codename1.ui.Display; -import com.codename1.ui.Form; -import com.codename1.ui.events.ActionEvent; -import com.codename1.ui.layouts.BorderLayout; -import com.codename1.ui.layouts.FlowLayout; - -public class BarCodeScanner { - - private Media media; - private Player player; - private SnapshotThread snapshotThread; - private Form cameraForm; - private Form backForm; - private ScanResult callback; - int type; - public static final int BARCODE = 0; - public static final int QRCODE = 1; - - - public BarCodeScanner(Media media) { - this.media = media; - backForm = Display.getInstance().getCurrent(); - } - - private void startScan() { - player = (Player) media.getVideoComponent().getClientProperty("nativePlayer"); - - MultimediaManager multimediaManager = buildMultimediaManager(); - if (player != null) { - multimediaManager.setZoom(player); - multimediaManager.setExposure(player); - multimediaManager.setFlash(player); - } - media.play(); - snapshotThread = new SnapshotThread(this); - new Thread(snapshotThread).start(); - if (Display.getInstance().isEdt()) { - cameraForm.show(); - } else { - // Now show the dialog in EDT - Display.getInstance().callSerially(new Runnable() { - - public void run() { - cameraForm.show(); - } - }); - } - } - - - static MultimediaManager buildMultimediaManager() { - if (isAMMSPresent()) { - return new AdvancedMultimediaManager(); - } else { - return new DefaultMultimediaManager(); - } - } - - class HandleDecodedTextCall implements Runnable { - Result theResult; - public void run() { - callback.scanCompleted(theResult.getText(), theResult.getBarcodeFormat().getName(), theResult.getRawBytes()); - stop(); - media.cleanup(); - backForm.showBack(); - backForm = null; - cameraForm = null; - callback = null; - } - } - - public void handleDecodedText(final Result theResult) { - HandleDecodedTextCall h = new HandleDecodedTextCall(); - h.theResult = theResult; - Display.getInstance().callSerially(h); - } - - private void stop() { - media.pause(); - } - - private void startScaning(ScanResult callback) { - this.callback = callback; - try { - // Add the listener for scan and cancel - Container cmdContainer = new Container(new FlowLayout(Component.CENTER)); - Button scanButton = new Button(new Command("Scan") { - - public void actionPerformed(ActionEvent evt) { - cameraForm.repaint(); - if (snapshotThread != null) { - snapshotThread.continueRun(); - } - } - }); - Button cancelButton = new Button(new Command("Cancel") { - - public void actionPerformed(ActionEvent evt) { - if (snapshotThread != null) { - snapshotThread.stop(); - cancelScan(); - } - } - }); - cmdContainer.addComponent(scanButton); - cmdContainer.addComponent(cancelButton); - cameraForm = new Form(); - cameraForm.setScrollable(false); - cameraForm.setLayout(new BorderLayout()); - cameraForm.addComponent(BorderLayout.CENTER, media.getVideoComponent()); - cameraForm.addComponent(BorderLayout.SOUTH, cmdContainer); - } catch (Exception e) { -// throw new AppException("Image/video capture not supported on this phone", e).setCode(97); - e.printStackTrace(); - } - startScan(); - } - - class CancelScanCall implements Runnable { - public void run() { - stop(); - media.cleanup(); - backForm.showBack(); - callback.scanCanceled(); - backForm = null; - cameraForm = null; - callback = null; - } - } - - private void cancelScan() { - Display.getInstance().callSerially(new CancelScanCall()); - } - - private static boolean isAMMSPresent() { - try { - Class.forName("javax.microedition.amms.GlobalManager"); - return true; - } catch (ClassNotFoundException _ex) { - return false; - } - - } - - Player getPlayer() { - return player; - } - - VideoControl getVideoControl() { - return (VideoControl) media.getVideoComponent().getClientProperty("VideoControl"); - } - - void showError(String err) { - callback.scanError(-1, err); - } - - void startScaningQRcode(ScanResult callback) { - type = QRCODE; - startScaning(callback); - } - - void startScaningBarCode(ScanResult callback) { - type = BARCODE; - startScaning(callback); - } - - - -} diff --git a/native/j2me/com/codename1/ext/codescan/CN1ImageLuminanceSource.java b/native/j2me/com/codename1/ext/codescan/CN1ImageLuminanceSource.java deleted file mode 100644 index a75a862..0000000 --- a/native/j2me/com/codename1/ext/codescan/CN1ImageLuminanceSource.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.codename1.ext.codescan; - -import com.google.zxing.LuminanceSource; -import com.codename1.ui.Image; - -/** - * A LuminanceSource based on Java ME's LWUIT Library Image class. It does not - * support cropping or rotation. - * - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - */ -public final class CN1ImageLuminanceSource extends LuminanceSource { - - private final Image image; - private int[] rgbData; - - public CN1ImageLuminanceSource(Image image) { - super(image.getWidth(), image.getHeight()); - this.image = image; - } - - // Instead of multiplying by 306, 601, 117, we multiply by 256, 512, 256, so that - // the multiplies can be implemented as shifts. - // - // Really, it's: - // - // return ((((pixel >> 16) & 0xFF) << 8) + - // (((pixel >> 8) & 0xFF) << 9) + - // (( pixel & 0xFF) << 8)) >> 10; - // - // That is, we're replacing the coefficients in the original with powers of two, - // which can be implemented as shifts, even though changing the coefficients slightly - // alters the conversion. The difference is not significant for our purposes. - public byte[] getRow(int y, byte[] row) { - if (y < 0 || y >= getHeight()) { - throw new IllegalArgumentException("Requested row is outside the image: " + y); - } - int width = getWidth(); - if (row == null || row.length < width) { - row = new byte[width]; - } - - /* - * if (rgbData == null || rgbData.length < width) { rgbData = new - * int[width]; } - */ - //image.getRGB(rgbData, 0, width, 0, y, width, 1); - // For LWUIT Image get the row as sub image without alpha processing, - // as we don't need alpha channel anyway - Image rowImg = image.subImage(0, y, width, 1, false); - rgbData = rowImg.getRGB(); - for (int x = 0; x < width; x++) { - row[x] = toLuminance(rgbData[x]); - } - return row; - } - - public byte[] getMatrix() { - int width = getWidth(); - int height = getHeight(); - int area = width * height; - byte[] matrix = new byte[area]; - - //int[] rgb = new int[area]; - //image.getRGB(rgb, 0, width, 0, 0, width, height); - int[] rgb = image.getRGBCached(); - for (int y = 0; y < height; y++) { - int offset = y * width; - for (int x = 0; x < width; x++) { - matrix[offset + x] = toLuminance(rgb[offset + x]); - } - } - return matrix; - } - - public boolean isRotateSupported() { - return true; - } - - public LuminanceSource rotateCounterClockwise() { - return new CCRotatedLWUITImageLuminanceSource(image); - } - - static byte toLuminance(int pixel) { - return (byte) ((((pixel & 0x00FF0000) >> 16) - + ((pixel & 0x0000FF00) >> 7) - + (pixel & 0x000000FF)) >> 2); - } - - /** - * A variant on {@link LWUITImageLuminanceSource} that acts as if the input - * is rotated 90 degrees counter-clockwise. - */ - private static final class CCRotatedLWUITImageLuminanceSource extends LuminanceSource { - - private final Image image; - private int[] rgbData; - - private CCRotatedLWUITImageLuminanceSource(Image image) { - super(image.getHeight(), image.getWidth()); - this.image = image; - } - - public byte[] getRow(int y, byte[] row) { - int height = getHeight(); - if (y < 0 || y >= height) { - throw new IllegalArgumentException("Requested row is outside the image: " + y); - } - int width = getWidth(); - if (row == null || row.length < width) { - row = new byte[width]; - } - - /* - * if (rgbData == null || rgbData.length < width) { rgbData = new - * int[width]; } - */ - //image.getRGB(rgbData, 0, height, height - 1 - y, 0, 1, width); - // For LWUIT Image get the row as sub image without alpha processing, - // as we don't need alpha channel anyway - Image rowImg = image.subImage(height - 1 - y, 0, 1, width, false); - rgbData = rowImg.getRGB(); - for (int x = 0; x < width; x++) { - row[x] = toLuminance(rgbData[x]); - } - return row; - } - - public byte[] getMatrix() { - int width = getWidth(); - int height = getHeight(); - int area = width * height; - byte[] matrix = new byte[area]; - - //int[] rgb = new int[area]; - //image.getRGB(rgb, 0, width, 0, 0, width, height); - int[] rgb = image.getRGBCached(); - // This flips x/y in the target to result in a rotated image - int offset = height * (width - 1); - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - matrix[offset - height * x + y] = toLuminance(rgb[y * width + x]); - } - } - return matrix; - } - } -} diff --git a/native/j2me/com/codename1/ext/codescan/CodeScannerImpl.java b/native/j2me/com/codename1/ext/codescan/CodeScannerImpl.java deleted file mode 100644 index 6edadaa..0000000 --- a/native/j2me/com/codename1/ext/codescan/CodeScannerImpl.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.codename1.ext.codescan; - - - -import com.codename1.media.Media; - -/** - * - * @author Chen - */ -public class CodeScannerImpl { - - private BarCodeScanner bs; - - public CodeScannerImpl(Media recorder) { - bs = new BarCodeScanner(recorder); - } - - public void scanQRCode(ScanResult callback) { - bs.startScaningQRcode(callback); - } - - public void scanBarCode(ScanResult callback) { - bs.startScaningBarCode(callback); - } - -} diff --git a/native/j2me/com/codename1/ext/codescan/DefaultMultimediaManager.java b/native/j2me/com/codename1/ext/codescan/DefaultMultimediaManager.java deleted file mode 100644 index 5438d7c..0000000 --- a/native/j2me/com/codename1/ext/codescan/DefaultMultimediaManager.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.codename1.ext.codescan; - -import javax.microedition.media.Controllable; - -/** - *

Dummy implemenation which does nothing. This is suitable for non-JSR-234 phones.

- * - * @author Sean Owen - */ -final class DefaultMultimediaManager implements MultimediaManager { - - public void setFocus(Controllable player) { - } - - public void setZoom(Controllable player) { - } - - public void setExposure(Controllable player) { - } - - public void setFlash(Controllable player) { - } - -} \ No newline at end of file diff --git a/native/j2me/com/codename1/ext/codescan/MultimediaManager.java b/native/j2me/com/codename1/ext/codescan/MultimediaManager.java deleted file mode 100644 index e1c25b6..0000000 --- a/native/j2me/com/codename1/ext/codescan/MultimediaManager.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.codename1.ext.codescan; - -import javax.microedition.media.Controllable; - -/** - *

Implemented by {@link com.google.zxing.client.j2me.DefaultMultimediaManager} and - * {@link com.google.zxing.client.j2me.AdvancedMultimediaManager} in order to dynamically - * load support for JSR-234 APIs where possible.

- * - * @author Sean Owen - * @author Paul Hackenberger - */ -interface MultimediaManager { - - void setFocus(Controllable player); - - void setZoom(Controllable player); - - void setExposure(Controllable player); - - void setFlash(Controllable player); - -} \ No newline at end of file diff --git a/native/j2me/com/codename1/ext/codescan/NativeCodeScannerImpl.java b/native/j2me/com/codename1/ext/codescan/NativeCodeScannerImpl.java deleted file mode 100644 index bca8926..0000000 --- a/native/j2me/com/codename1/ext/codescan/NativeCodeScannerImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.codename1.ext.codescan; - -public class NativeCodeScannerImpl { - public void scanQRCode() { - new ScannerHider().getCodeScanner().scanQRCode(new ScanResult() { - - public void scanCompleted(String contents, String formatName, byte[] rawBytes) { - CodeScanner.scanCompletedCallback(contents, formatName, rawBytes); - } - - public void scanCanceled() { - CodeScanner.scanCanceledCallback(); - } - - public void scanError(int errorCode, String message) { - CodeScanner.scanErrorCallback(errorCode, message); - } - - }); - } - - public void scanBarCode() { - new ScannerHider().getCodeScanner().scanBarCode(new ScanResult() { - - public void scanCompleted(String contents, String formatName, byte[] rawBytes) { - CodeScanner.scanCompletedCallback(contents, formatName, rawBytes); - } - - public void scanCanceled() { - CodeScanner.scanCanceledCallback(); - } - - public void scanError(int errorCode, String message) { - CodeScanner.scanErrorCallback(errorCode, message); - } - - }); - } - - public boolean isSupported() { - return true; - } - -} diff --git a/native/j2me/com/codename1/ext/codescan/ScannerHider.java b/native/j2me/com/codename1/ext/codescan/ScannerHider.java deleted file mode 100644 index 6040f5e..0000000 --- a/native/j2me/com/codename1/ext/codescan/ScannerHider.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2012, Codename One and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Codename One designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Codename One through http://www.codenameone.com/ if you - * need additional information or have any questions. - */ - -package com.codename1.ext.codescan; - -import com.codename1.io.CodeScannerUtil; -import com.codename1.impl.ImplementationFactory; -import com.codename1.impl.midp.GameCanvasImplementation; -import com.codename1.impl.midp.MMAPIPlayer; - -/** - * Class that effectively hides the code scanner API - * - * @author Shai Almog - */ -public class ScannerHider { - /** - * Returns the native implementation of the code scanner or null - * - * @return code scanner instance - */ - CodeScannerImpl getCodeScanner() { - try { - MMAPIPlayer player = null; - - String platform = System.getProperty("microedition.platform"); - /* - if (platform != null && platform.indexOf("Nokia") >= 0) { - try { - player = MMAPIPlayer.createPlayer("capture://image", null); - } catch (Throwable e) { - // Ignore all exceptions for image capture, continue with video capture... - } - } - if (player == null) { - try { - player = MMAPIPlayer.createPlayer("capture://video", null); - } catch (Exception e) { - // The Nokia 2630 throws this if image/video capture is not supported - throw new RuntimeException("Image/video capture not supported on this phone"); - } - } - */ - String uri = null; - if (platform != null && platform.indexOf("Nokia") >= 0) { - uri = "capture://image"; - } else { - uri = "capture://video"; - } - - //GameCanvasImplementation.MIDPVideoComponent video = new GameCanvasImplementation.MIDPVideoComponent(player, GameCanvasImplementationExt.getStaticCanvas()); - GameCanvasImplementation.MIDPVideoComponent video = (GameCanvasImplementation.MIDPVideoComponent)CodeScannerUtil.getImplementation().createMedia(uri, true, null); - video.setFocusable(false); - return new CodeScannerImpl(video); - } catch(Throwable t) { - return null; - } - } - - -} diff --git a/native/j2me/com/codename1/ext/codescan/SnapshotThread.java b/native/j2me/com/codename1/ext/codescan/SnapshotThread.java deleted file mode 100644 index f87278c..0000000 --- a/native/j2me/com/codename1/ext/codescan/SnapshotThread.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.codename1.ext.codescan; - -import com.google.zxing.*; -import com.google.zxing.common.HybridBinarizer; -import com.google.zxing.qrcode.QRCodeReader; -//import com.nvsoft.csk.util.Configuration; -import com.codename1.ui.Image; -import com.google.zxing.common.GlobalHistogramBinarizer; -import java.util.Hashtable; - -import javax.microedition.media.MediaException; -import javax.microedition.media.Player; -import javax.microedition.media.control.VideoControl; - -/** - * Thread which does the work of capturing a frame and decoding it. - * - * @author Sean Owen - */ -final class SnapshotThread implements Runnable { -// private static final Logger logger = LoggerFactory.getLogger(SnapshotThread.class); - - private final BarCodeScanner barCodeScanner; - private final Object waitLock; - private volatile boolean done; - private final MultimediaManager multimediaManager; - private String bestEncoding; - - SnapshotThread(BarCodeScanner barCodeScanner) { - this.barCodeScanner = barCodeScanner; - waitLock = new Object(); - done = false; - multimediaManager = BarCodeScanner.buildMultimediaManager(); - } - - void continueRun() { - synchronized (waitLock) { - waitLock.notifyAll(); - } - } - - private void waitForSignal() { - synchronized (waitLock) { - try { - waitLock.wait(); - } catch (InterruptedException ie) { - // continue - } - } - } - - void stop() { - done = true; - continueRun(); - } - - public void run() { - do { - waitForSignal(); - if (done) { - break; - } - BinaryBitmap bitmap = null; - try { - Player player = barCodeScanner.getPlayer(); - if (player == null) { - break; - } - multimediaManager.setFocus(player); - byte[] snapshot = takeSnapshot(); - if (snapshot == null) { - break; - } - Image capturedImage = Image.createImage(snapshot, 0, snapshot.length); - LuminanceSource source = new CN1ImageLuminanceSource(capturedImage); - bitmap = new BinaryBitmap(new HybridBinarizer(source)); - Result result = null; - if(barCodeScanner.type == BarCodeScanner.QRCODE){ - Reader reader = new QRCodeReader(); - result = reader.decode(bitmap); - }else{ - MultiFormatReader reader = new MultiFormatReader(); - result = reader.decodeBarcode(bitmap); - } - barCodeScanner.handleDecodedText(result); - - - } catch (ReaderException re) { - barCodeScanner.showError("Not found!"); - } catch (Exception e) { - barCodeScanner.showError(e.getMessage()); - } - } while (!done); - } - - private byte[] takeSnapshot() throws MediaException { - - String bestEncoding = guessBestEncoding(); - - VideoControl videoControl = barCodeScanner.getVideoControl(); - if (videoControl == null) { - throw new MediaException("Can't obtain video control"); - } - byte[] snapshot = null; - try { - snapshot = videoControl.getSnapshot("".equals(bestEncoding) ? null : bestEncoding); - } catch (MediaException me) { - } - if (snapshot == null) { - // Fall back on JPEG; seems that some cameras default to PNG even - // when PNG isn't supported! - snapshot = videoControl.getSnapshot("encoding=jpeg"); - if (snapshot == null) { - throw new MediaException("Can't obtain a snapshot"); - } - } - return snapshot; - } - - private synchronized String guessBestEncoding() throws MediaException { - if (bestEncoding == null) { - // Check this property, present on some Nokias? - String supportsVideoCapture = System.getProperty("supports.video.capture"); - if ("false".equals(supportsVideoCapture)) { - throw new MediaException("supports.video.capture is false"); - } - - bestEncoding = ""; - String videoSnapshotEncodings = System.getProperty("video.snapshot.encodings"); - if (videoSnapshotEncodings != null) { - // We know explicitly what the camera supports; see if PNG is among them since - // Image.createImage() should always support it - int pngEncodingStart = videoSnapshotEncodings.indexOf("encoding=png"); - if (pngEncodingStart >= 0) { - int space = videoSnapshotEncodings.indexOf(' ', pngEncodingStart); - bestEncoding = space >= 0 ? - videoSnapshotEncodings.substring(pngEncodingStart, space) : - videoSnapshotEncodings.substring(pngEncodingStart); - } - } - } - return bestEncoding; - } - -} diff --git a/native/j2me/com/codename1/io/CodeScannerUtil.java b/native/j2me/com/codename1/io/CodeScannerUtil.java deleted file mode 100644 index 4db7c6f..0000000 --- a/native/j2me/com/codename1/io/CodeScannerUtil.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.codename1.io; -import com.codename1.impl.midp.GameCanvasImplementation; -/** - * - * @author shannah - */ -public class CodeScannerUtil { - public static GameCanvasImplementation getImplementation() { - return (GameCanvasImplementation)Util.getImplementation(); - } -} diff --git a/native/j2me/org/littlemonkey/qrscanner/NativeScannerImpl.java b/native/j2me/org/littlemonkey/qrscanner/NativeScannerImpl.java deleted file mode 100644 index 192ebf3..0000000 --- a/native/j2me/org/littlemonkey/qrscanner/NativeScannerImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.littlemonkey.qrscanner; - -public class NativeScannerImpl { - public void scanQRCode() { - } - - public void scanBarCode() { - } - - public boolean isSupported() { - return false; - } - -} diff --git a/native/javase/org/littlemonkey/qrscanner/NativeScannerImpl.java b/native/javase/org/littlemonkey/qrscanner/NativeScannerImpl.java deleted file mode 100644 index 76adffc..0000000 --- a/native/javase/org/littlemonkey/qrscanner/NativeScannerImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.littlemonkey.qrscanner; - -public class NativeScannerImpl implements org.littlemonkey.qrscanner.NativeScanner{ - public void scanQRCode() { - } - - public void scanBarCode() { - } - - public boolean isSupported() { - return false; - } - -} diff --git a/native/rim/com/codename1/ext/codescan/BitmapLuminanceSource.java b/native/rim/com/codename1/ext/codescan/BitmapLuminanceSource.java deleted file mode 100644 index c81bfd7..0000000 --- a/native/rim/com/codename1/ext/codescan/BitmapLuminanceSource.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.codename1.ext.codescan; - -import com.google.zxing.LuminanceSource; -import net.rim.device.api.system.Bitmap; - -/** - * - * @author nirmal - */ -public class BitmapLuminanceSource extends LuminanceSource { - private final Bitmap _bitmap; - private byte[] _matrix; - - /** - * Construct luminance source for specified Bitmap - * @param bitmap - */ - public BitmapLuminanceSource(Bitmap bitmap) { - super(bitmap.getWidth(), bitmap.getHeight()); - int width = bitmap.getWidth(); - int height = bitmap.getHeight(); - _bitmap = bitmap; - - int area = width * height; - _matrix = new byte[area]; - int[] rgb = new int[area]; - - _bitmap.getARGB(rgb, 0, width, 0, 0, width, height); - - for (int y = 0; y < height; y++) { - int offset = y * width; - for (int x = 0; x < width; x++) { - int pixel = rgb[offset + x]; - int luminance = (306 * ((pixel >> 16) & 0xFF) + 601 - * ((pixel >> 8) & 0xFF) + 117 * (pixel & 0xFF)) >> 10; - _matrix[offset + x] = (byte) luminance; - } - } - - rgb = null; - - } - - /** - * Get the byte for specified row, starts from 0. - */ - public byte[] getRow(int y, byte[] row) { - if (y < 0 || y >= getHeight()) { - throw new IllegalArgumentException( - "Requested row is outside the image: " + y); - } - - int width = getWidth(); - if (row == null || row.length < width) { - row = new byte[width]; - } - - int offset = y * width; - System.arraycopy(this._matrix, offset, row, 0, width); - - return row; - } - - /** - * Get the byte matrix in 1-dimensional array of byte - */ - public byte[] getMatrix() { - return _matrix; - } - -} diff --git a/native/rim/com/codename1/ext/codescan/CodeScannerImpl.java b/native/rim/com/codename1/ext/codescan/CodeScannerImpl.java deleted file mode 100644 index 6fd678d..0000000 --- a/native/rim/com/codename1/ext/codescan/CodeScannerImpl.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.codename1.ext.codescan; - - -import com.codename1.media.Media; -import com.codename1.ui.Form; -import com.google.zxing.*; -import com.google.zxing.common.HybridBinarizer; -import com.google.zxing.qrcode.QRCodeReader; -import java.util.Hashtable; -import java.util.Timer; -import java.util.TimerTask; -import javax.microedition.media.Manager; -import javax.microedition.media.MediaException; -import javax.microedition.media.Player; -import javax.microedition.media.control.VideoControl; -import net.rim.device.api.system.Application; -import net.rim.device.api.system.Bitmap; -import net.rim.device.api.system.Display; -import net.rim.device.api.ui.Field; -import net.rim.device.api.ui.UiApplication; -import net.rim.device.api.ui.container.MainScreen; - -/** - * - * @author Chen - */ -public class CodeScannerImpl { - - private MultimediaManager multimediaManager; - private ScanResult callback; - private boolean isQRScanning; - private VideoControl videoControl; - private Player player; - private Field viewFinder; - private ViewFinderScreen viewFinderScreen; - private BarcodeScanTask task; - private Timer timer; - private Result result; - - public CodeScannerImpl(MultimediaManager multimediaManager) { - // Setup barcode decoding hints, arg passed is not used at present - this.multimediaManager = multimediaManager; - } - - public void scanQRCode(ScanResult callback) { - this.callback = callback; - isQRScanning = true; - startScan(); - } - - public void scanBarCode(ScanResult callback) { - this.callback = callback; - isQRScanning = false; - startScan(); - } - - - public void cancelScan() { - stopScan(); - if (callback != null) { - callback.scanCanceled(); - //callback.onEvent(doneEvent); - callback = null; - } - } - - public void handleDecodedText(Result theResult) { - // And then stop the scan and go back to the LWUIT form, - // if there was no error. TODO: fix this properly later. - callback.scanCompleted(theResult.getText(), theResult.getBarcodeFormat().getName(), theResult.getRawBytes()); - stopScan(); - callback = null; - } - - /** - * Get the player instance - * - * @return player instance - */ - public Player getPlayer() { - return player; - } - - /** - * Get the video control - * - * @return video control instance - */ - public VideoControl getVideoControl() { - return videoControl; - } - - public void startScan() { - try { - System.gc(); - - player = Manager.createPlayer("capture://video"); - player.realize(); - multimediaManager.setZoom(player); - multimediaManager.setExposure(player); - multimediaManager.setFlash(player); - player.start(); - videoControl = (VideoControl) player.getControl("VideoControl"); - - viewFinder = (Field) videoControl.initDisplayMode( - VideoControl.USE_GUI_PRIMITIVE, - "net.rim.device.api.ui.Field"); - - if (videoControl != null) { - viewFinderScreen = new ViewFinderScreen(); - UiApplication.getUiApplication().invokeLater(new Runnable() { - - public void run() { - UiApplication.getUiApplication().pushScreen( - viewFinderScreen); - viewFinder.setFocus(); - - } - }); - videoControl.setVisible(true); - videoControl.setDisplayFullScreen(true); - task = new BarcodeScanTask(); - // create timer every 3 seconds, get a screenshot - timer = new Timer(); - timer.schedule(task, 0, 3000); // once every 3 seconds - } else { - throw new MediaException("Video Control is not initialized"); - } - } catch (Exception e) { - callback.scanError(-1, e.getMessage()); - } - } - - public void stopScan() { - if (timer != null) { - timer.cancel(); // stop the timer - } - // Destroy the videoControl and player - - if (videoControl != null) { - // TODO: This might not be needed, but have it just in case - videoControl.setVisible(false); - videoControl = null; - } - if (player != null) { - player.close(); - player = null; - } - if (viewFinderScreen != null) { - synchronized (Application.getEventLock()) { - // viewFinderScreen.close(); - UiApplication.getUiApplication().popScreen(viewFinderScreen); - } - viewFinderScreen = null; - } - System.gc(); - } - - final class BarcodeScanTask extends TimerTask { - - public void run() { - try { - - Bitmap bmpScreenshot = new Bitmap(Display.getWidth(), - Display.getHeight()); - multimediaManager.setFocus(player); - Display.screenshot(bmpScreenshot); - // creating luminance source - LuminanceSource source = new BitmapLuminanceSource( - bmpScreenshot); - BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer( - source)); - - if(isQRScanning){ - QRCodeReader reader = new QRCodeReader(); - result = reader.decodeQR(bitmap); - }else{ - MultiFormatReader reader = new MultiFormatReader(); - result = reader.decodeBarcode(bitmap); - } - handleDecodedText(result); - timer.cancel(); // stop the timer - } catch (Throwable e) { - callback.scanError(-1, e.getMessage()); - } - } - } - - public final class ViewFinderScreen extends MainScreen { - - public ViewFinderScreen() throws Exception { - super(MainScreen.DEFAULT_CLOSE); - add(viewFinder); - } - - protected boolean navigationClick(int arg0, int arg1) { - cancelScan(); - this.close(); - return true; - } - - public boolean onClose() { - try { - stopScan(); - return super.onClose(); - } catch (Exception e) { - return false; - } - } - } - -} diff --git a/native/rim/com/codename1/ext/codescan/MultimediaManager.java b/native/rim/com/codename1/ext/codescan/MultimediaManager.java deleted file mode 100644 index ebf3e7a..0000000 --- a/native/rim/com/codename1/ext/codescan/MultimediaManager.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.codename1.ext.codescan; - -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import javax.microedition.media.Controllable; -import javax.microedition.media.MediaException; -import javax.microedition.media.Control; - -/** - *

Implementation suitable for JSR-234 phones which takes advantage of advanced camera - * capability.

- * - * @author Sean Owen - */ -public class MultimediaManager { - - public void setFocus(Controllable player) { - } - - public void setZoom(Controllable player) { - } - - public void setExposure(Controllable player) { - } - - public void setFlash(Controllable player) { - } - -} \ No newline at end of file diff --git a/native/rim/com/codename1/ext/codescan/NativeCodeScannerImpl.java b/native/rim/com/codename1/ext/codescan/NativeCodeScannerImpl.java deleted file mode 100644 index ac3dcae..0000000 --- a/native/rim/com/codename1/ext/codescan/NativeCodeScannerImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.codename1.ext.codescan; - -public class NativeCodeScannerImpl { - public void scanQRCode() { - new CodeScannerImpl(new MultimediaManager()).scanQRCode(new ScanResult() { - - public void scanCompleted(String contents, String formatName, byte[] rawBytes) { - CodeScanner.scanCompletedCallback(contents, formatName, rawBytes); - } - - public void scanCanceled() { - CodeScanner.scanCanceledCallback(); - } - - public void scanError(int errorCode, String message) { - CodeScanner.scanErrorCallback(errorCode, message); - } - - }); - } - - public void scanBarCode() { - new CodeScannerImpl(new MultimediaManager()).scanBarCode(new ScanResult() { - - public void scanCompleted(String contents, String formatName, byte[] rawBytes) { - CodeScanner.scanCompletedCallback(contents, formatName, rawBytes); - } - - public void scanCanceled() { - CodeScanner.scanCanceledCallback(); - } - - public void scanError(int errorCode, String message) { - CodeScanner.scanErrorCallback(errorCode, message); - } - - }); - } - - public boolean isSupported() { - return true; - } - -} diff --git a/native/rim/org/littlemonkey/qrscanner/NativeScannerImpl.java b/native/rim/org/littlemonkey/qrscanner/NativeScannerImpl.java deleted file mode 100644 index 192ebf3..0000000 --- a/native/rim/org/littlemonkey/qrscanner/NativeScannerImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.littlemonkey.qrscanner; - -public class NativeScannerImpl { - public void scanQRCode() { - } - - public void scanBarCode() { - } - - public boolean isSupported() { - return false; - } - -} diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml deleted file mode 100644 index 496b791..0000000 --- a/nbproject/build-impl.xml +++ /dev/null @@ -1,1400 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties deleted file mode 100644 index 798d123..0000000 --- a/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=65812561 -build.xml.script.CRC32=c17a4175 -build.xml.stylesheet.CRC32=28e38971@1.44.1.45 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=65812561 -nbproject/build-impl.xml.script.CRC32=d56d33ea -nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46 diff --git a/nbproject/nativej2me.res b/nbproject/nativej2me.res deleted file mode 100644 index 6b33caf..0000000 Binary files a/nbproject/nativej2me.res and /dev/null differ diff --git a/nbproject/project.properties b/nbproject/project.properties deleted file mode 100644 index 613d48a..0000000 --- a/nbproject/project.properties +++ /dev/null @@ -1,84 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=QRScanner -application.vendor=Codename One -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/QRScanner.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -file.reference.android.jar=/home/nick/android-sdk-linux/platforms/android-19/android.jar -file.reference.build-classes=lib/cn1-codescan.jar -file.reference.CLDC11.jar=lib/CLDC11.jar -file.reference.CodenameOne.jar=lib/CodenameOne.jar -file.reference.CodenameOne_SRC.zip=lib/CodenameOne_SRC.zip -file.reference.QRScanner-override=override -includes=** -jar.compress=false -javac.classpath=\ - ${file.reference.CLDC11.jar}:\ - ${file.reference.CodenameOne.jar}:\ - ${file.reference.CodenameOne_SRC.zip}:\ - ${file.reference.QRScanner-override}:\ - ${file.reference.build-classes} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath}:\ - ${file.reference.android.jar} -javac.source=1.5 -javac.target=1.5 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=windows-1252 -src.dir=src -test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml deleted file mode 100644 index 9ef2387..0000000 --- a/nbproject/project.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - QRScanner - - - - - - - - - diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..35da4a6 --- /dev/null +++ b/pom.xml @@ -0,0 +1,279 @@ + + + 4.0.0 + + com.codenameone + qrscanner + 2.0.3-SNAPSHOT + pom + + qrscanner + Codename One qrscanner library + https://www.codenameone.com + + + + GPL v2 With Classpath Exception + https://openjdk.java.net/legal/gplv2+ce.html + repo + A business-friendly OSS license + + + + + + + + shannah + Steve Hannah + steve.hannah@codenameone.com + -8 + + + + + + + + https://github.com/codenameone/QRScanner + scm:git:git@github.com:codenameone/QRScanner.git + + + + + 7.0.117 + LATEST + UTF-8 + + 1.8 + 11 + 3.8.0 + 1.8 + 1.8 + qrscanner + 1.3.72 + true + 1.8 + + + common + android + ios + javascript + javase + win + lib + tests + + + + + com.codenameone + java-runtime + ${cn1.version} + + + com.codenameone + codenameone-core + ${cn1.version} + + + com.codenameone + codenameone-javase + ${cn1.version} + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + + + + org.jetbrains + annotations + 13.0 + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + + org.codehaus.mojo + exec-maven-plugin + 3.0.0 + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + + compile + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + + + + test-compile + + test-compile + + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + + + + com.codenameone + codenameone-maven-plugin + ${cn1.plugin.version} + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9 + + + build-javadoc + + jar + + post-integration-test + + true + + + + + + 1.8 + protected + false + + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + + + + + + + + + sign-artifacts + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.4 + + + sign-artifacts + verify + + sign + + + ${gpg.passphrase} + + + + + + + + + + + nexus-staging + Nexus Release Repository + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + diff --git a/print-version.sh b/print-version.sh new file mode 100644 index 0000000..9897e9b --- /dev/null +++ b/print-version.sh @@ -0,0 +1,15 @@ +#!/bin/bash +#Prints the current project version +# +# Created by Steve Hannah +# Creation Date March 19, 2021 +# Usage: bash print-version.sh +# Output Example: 7.0.13-SNAPSHOT +SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" +cd $SCRIPTPATH +regex=' qrscanner (.*):$' + +LINE=$(mvn validate | grep "Reactor Summary") +[[ $LINE =~ $regex ]] + +echo "${BASH_REMATCH[1]}" \ No newline at end of file diff --git a/tests/.mvn/jvm.config b/tests/.mvn/jvm.config new file mode 100644 index 0000000..e69de29 diff --git a/tests/common/codenameone_settings.properties b/tests/common/codenameone_settings.properties new file mode 100644 index 0000000..fb108b5 --- /dev/null +++ b/tests/common/codenameone_settings.properties @@ -0,0 +1,29 @@ +codename1.android.keystore= +codename1.android.keystoreAlias= +codename1.android.keystorePassword= +codename1.arg.ios.newStorageLocation=true +codename1.arg.java.version=8 +codename1.displayName=LibraryTests +codename1.icon=icon.png +codename1.ios.appid=Q5GHSKAL2F.com.codenameone +codename1.ios.certificate= +codename1.ios.certificatePassword= +codename1.ios.debug.certificate= +codename1.ios.debug.certificatePassword= +codename1.ios.debug.provision= +codename1.ios.provision= +codename1.ios.release.certificate= +codename1.ios.release.certificatePassword= +codename1.ios.release.provision= +codename1.j2me.nativeTheme=nbproject/nativej2me.res +codename1.kotlin=false +codename1.languageLevel=5 +codename1.mainName=LibraryTests +codename1.packageName=com.codenameone +codename1.rim.certificatePassword= +codename1.rim.signtoolCsk= +codename1.rim.signtoolDb= +codename1.secondaryTitle=Hello World +codename1.vendor=CodenameOne +codename1.version=1.0 +codename1.cssTheme=true diff --git a/tests/common/nbactions.xml b/tests/common/nbactions.xml new file mode 100644 index 0000000..29e1b86 --- /dev/null +++ b/tests/common/nbactions.xml @@ -0,0 +1,20 @@ + + + + run + build-with-dependencies + + jar + + + org.codehaus.mojo:exec-maven-plugin:3.0.0:exec + + + ${Env.M2_HOME}/bin/mvn + verify -P simulator -Dcodename1.platform=javase + ../javase + + + + + diff --git a/tests/common/pom.xml b/tests/common/pom.xml new file mode 100644 index 0000000..8b2e42f --- /dev/null +++ b/tests/common/pom.xml @@ -0,0 +1,327 @@ + + + 4.0.0 + + com.codenameone + qrscanner-tests + 2.0.3-SNAPSHOT + + com.codenameone + qrscanner-tests-common + 2.0.3-SNAPSHOT + jar + + + + + + kotlin + + + cn1.kotlin + + + + 1.4.32 + true + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + + + + org.jetbrains + annotations + 13.0 + + + com.codenameone + java-runtime + provided + + + + + + org.codehaus.mojo + properties-maven-plugin + 1.0.0 + + + initialize + + read-project-properties + + + + ${basedir}/codenameone_settings.properties + + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + + compile + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + + -no-reflect + -no-jdk + + + + + test-compile + + test-compile + + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + + -no-reflect + -no-jdk + + + + + + + + + + + + + javase + + + codename1.platform + javase + + + + javase + + + + + org.codehaus.mojo + exec-maven-plugin + + java + true + + -Xmx1024M + + -classpath + + ${exec.mainClass} + ${cn1.mainClass} + + + + + + + + + + simulator + + javase + + + + + + ios-debug + + + iphone + + + ios + + + + + ios-release + + + iphone + true + + + ios + true + + + + + javascript + + javascript + javascript + + + + + android + + android + android + + + + + uwp + + windows + win + + + + + windows + + desktop_windows + javase + + + + + mac + + desktop_macosx + javase + + + + + + com.codenameone + codenameone-core + + + com.codenameone + codenameone-javase + runtime + + + + + + + + + org.codehaus.mojo + properties-maven-plugin + 1.0.0 + + + initialize + + read-project-properties + + + + ${basedir}/codenameone_settings.properties + + + + + + + + com.codenameone + codenameone-maven-plugin + + + + + cn1-process-classes + process-classes + + compliance-check + css + + + + + attach-test-artifact + test + + attach-test-artifact + + + + + + + + + + + + + + + + cn1libs + cn1libs + file:${project.basedir}/../cn1libs + + + + + + + + diff --git a/tests/common/src/main/css/theme.css b/tests/common/src/main/css/theme.css new file mode 100644 index 0000000..7ba9ade --- /dev/null +++ b/tests/common/src/main/css/theme.css @@ -0,0 +1,9 @@ +#Constants { + includeNativeBool: true; +} +Button { + color:green; + border:1px solid green; + border-radius: 2mm; + margin: 5mm; +} \ No newline at end of file diff --git a/tests/common/src/main/java/com/codenameone/LibraryTests.java b/tests/common/src/main/java/com/codenameone/LibraryTests.java new file mode 100644 index 0000000..2209803 --- /dev/null +++ b/tests/common/src/main/java/com/codenameone/LibraryTests.java @@ -0,0 +1,66 @@ +package com.codenameone; + +import static com.codename1.ui.CN.*; +import com.codename1.ui.*; +import com.codename1.ui.layouts.*; +import com.codename1.io.*; +import com.codename1.ui.plaf.*; +import com.codename1.ui.util.Resources; + +/** + * This file was generated by Codename One for the purpose + * of building native mobile applications using Java. + */ +public class LibraryTests { + + private Form current; + private Resources theme; + + public void init(Object context) { + // use two network threads instead of one + updateNetworkThreadCount(2); + + theme = UIManager.initFirstTheme("/theme"); + + // Enable Toolbar on all Forms by default + Toolbar.setGlobalToolbar(true); + + // Pro only feature + Log.bindCrashProtection(true); + + addNetworkErrorListener(err -> { + // prevent the event from propagating + err.consume(); + if(err.getError() != null) { + Log.e(err.getError()); + } + Log.sendLogAsync(); + Dialog.show("Connection Error", "There was a networking error in the connection to " + err.getConnectionRequest().getUrl(), "OK", null); + }); + } + + + public void start() { + if(current != null){ + current.show(); + return; + } + //WebSocket sock; + Form hi = new Form("Hi World", BoxLayout.y()); + hi.add(new Label("Hello World")); + + hi.show(); + } + + public void stop() { + current = getCurrentForm(); + if(current instanceof Dialog) { + ((Dialog)current).dispose(); + current = getCurrentForm(); + } + } + + public void destroy() { + } + +} diff --git a/tests/common/src/test/java/com/codenameone/MyFirstTest.java b/tests/common/src/test/java/com/codenameone/MyFirstTest.java new file mode 100644 index 0000000..9cff27e --- /dev/null +++ b/tests/common/src/test/java/com/codenameone/MyFirstTest.java @@ -0,0 +1,23 @@ + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.codenameone; + +import com.codename1.testing.AbstractTest; + +/** + * + * @author shannah + */ +public class MyFirstTest extends AbstractTest { + + @Override + public boolean runTest() throws Exception { + return true; + } + + +} diff --git a/tests/pom.xml b/tests/pom.xml new file mode 100644 index 0000000..a958540 --- /dev/null +++ b/tests/pom.xml @@ -0,0 +1,105 @@ + + + 4.0.0 + + qrscanner + com.codenameone + 2.0.3-SNAPSHOT + + + com.codenameone + qrscanner-tests + 2.0.3-SNAPSHOT + pom + + qrscanner-tests-tests + qrscanner-tests-tests + https://www.codenameone.com + + + + GPL v2 With Classpath Exception + https://openjdk.java.net/legal/gplv2+ce.html + repo + A business-friendly OSS license + + + + + common + + + + + + 7.0.8-b6 + UTF-8 + + 1.8 + 11 + 1.7.11 + 3.8.0 + 8 + 8 + qrscanner-tests + + + + + + + + + + + + com.codenameone + codenameone-core + ${cn1.version} + + + com.codenameone + codenameone-javase + ${cn1.version} + + + + + + + + + + + + com.codenameone + codenameone-maven-plugin + ${cn1.plugin.version} + + + + + + + + + + + + + + + + diff --git a/update-version.sh b/update-version.sh new file mode 100644 index 0000000..0be4e05 --- /dev/null +++ b/update-version.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# update-version.sh +# Created by Steve Hannah. March 24, 2021 +# +# Synopsis: +# --------- +# +# Updates the version of this project and commits the version changes in Git. If the version +# is a release version (i.e. not ending in '-SNAPSHOT', then it will also add a git tag). +# +# Typically you would run this before and after running the deploy-to-sonatype.sh script. Before +# to set the release version, and after to change to a new SNAPSHOT version. +# +# +# Usage: +# bash update-version.sh VERSION +# +# Arguments: +# VERSION The version number to update to. +# +# Examples: +# bash update-version.sh 8.0.1 +# Updates to version 8.0.1 +# +# bash update-version.sh 8.0.2-SNAPSHOT +# Updates to version 8.0.2-SNAPSHOT +# +# Typical Workflow is: +# bash update-version.sh 8.0.1 && bash deploy-to-sonatype.sh && bash update-version.sh 8.0.2-SNAPSHOT +set -e +if [ -z $1 ]; then + echo "Usage bash update-version.sh VERSION" + echo " Where VERSION is the version number to update to." + echo " E.g. bash update-version.sh 7.0.15-SNAPSHOT" + exit 1 +fi +version=$1 +oldVersion=$(bash print-version.sh) +if [ $version == $oldVersion ]; then + echo "Version is same as old version. Not updating version" + exit 0 +fi +echo "Version: $version" +mvn versions:set -DnewVersion=$version +mvn versions:commit + +echo "Committing version change in git" +git add -u . +# Note: the -u is to prevent adding files that aren't added to git yet. Only changed +# files. This is to help avoid accidents. +git commit -m "Updated version to $version" +if [[ "$version" == *-SNAPSHOT ]]; then + echo "This is a snapshot version so not adding a tag" +else + echo "Adding git tag for 'v${version}'" + git tag -a "v${version}" -m "Version ${version}" +fi \ No newline at end of file diff --git a/win/pom.xml b/win/pom.xml new file mode 100644 index 0000000..97f5769 --- /dev/null +++ b/win/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + com.codenameone + qrscanner + 2.0.3-SNAPSHOT + + com.codenameone + qrscanner-win + 2.0.3-SNAPSHOT + + qrscanner-win + + + + src/main/csharp + + + src/main/resources + + + + + + + ${project.groupId} + ${cn1lib.name}-common + ${project.version} + + + + + diff --git a/native/win/com/codename1/ext/codescan/NativeCodeScannerImpl.cs b/win/src/main/csharp/com/codename1/ext/codescan/NativeCodeScannerImpl.cs similarity index 96% rename from native/win/com/codename1/ext/codescan/NativeCodeScannerImpl.cs rename to win/src/main/csharp/com/codename1/ext/codescan/NativeCodeScannerImpl.cs index 9c1e199..7bfcafd 100644 --- a/native/win/com/codename1/ext/codescan/NativeCodeScannerImpl.cs +++ b/win/src/main/csharp/com/codename1/ext/codescan/NativeCodeScannerImpl.cs @@ -1,9 +1,9 @@ -namespace com.codename1.ext.codescan{ - -using System; -using System.Windows; - -public class NativeCodeScannerImpl { +namespace com.codename1.ext.codescan{ + +using System; +using System.Windows; + +public class NativeCodeScannerImpl { public void scanQRCode() { } @@ -14,5 +14,5 @@ public bool isSupported() { return false; } -} -} +} +} diff --git a/native/win/org/littlemonkey/qrscanner/NativeScannerImpl.cs b/win/src/main/csharp/org/littlemonkey/qrscanner/NativeScannerImpl.cs similarity index 96% rename from native/win/org/littlemonkey/qrscanner/NativeScannerImpl.cs rename to win/src/main/csharp/org/littlemonkey/qrscanner/NativeScannerImpl.cs index 057164a..a7cb58c 100644 --- a/native/win/org/littlemonkey/qrscanner/NativeScannerImpl.cs +++ b/win/src/main/csharp/org/littlemonkey/qrscanner/NativeScannerImpl.cs @@ -1,9 +1,9 @@ -namespace org.littlemonkey.qrscanner{ - -using System; -using System.Windows; - -public class NativeScannerImpl { +namespace org.littlemonkey.qrscanner{ + +using System; +using System.Windows; + +public class NativeScannerImpl { public void scanQRCode() { } @@ -14,5 +14,5 @@ public bool isSupported() { return false; } -} -} +} +}