diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 652a6089..59f08ccb 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -17,24 +17,24 @@ jobs: env: CCACHE_DIR: ${{ github.workspace }}/.ccache USE_CCACHE: 1 - SDK_VERSION: 11.0.0.GA + SDK_VERSION: 12.3.0.GA MODULE_ID: ti.barcode steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - name: Use Node.js 14.x - uses: actions/setup-node@v1 + - name: Use Node.js + uses: actions/setup-node@v4 with: - node-version: '14.x' + node-version: '18.x' - uses: actions/setup-java@v3 with: distribution: 'adopt' - java-version: '11' + java-version: '17' - name: Cache Node.js modules id: node-cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: node_modules key: ${{ runner.OS }}-node-modules-${{ hashFiles('package-lock.json') }} @@ -47,7 +47,7 @@ jobs: if: steps.node-cache.outputs.cache-hit != 'true' - name: Cache Gradle packages - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.gradle/caches diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 028a97b1..a6cc0cf1 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -12,12 +12,12 @@ jobs: runs-on: ubuntu-latest name: Docs steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - name: Use Node.js 14.x - uses: actions/setup-node@v1 + - name: Use Node.js + uses: actions/setup-node@v4 with: - node-version: '14.x' + node-version: '18.x' - run: npm ci name: Install dependencies diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index ccd8c1e2..bbed24c2 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -15,19 +15,19 @@ jobs: runs-on: macos-latest name: iOS env: - SDK_VERSION: 11.0.0.GA + SDK_VERSION: 12.3.0.GA MODULE_ID: ti.barcode steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - name: Use Node.js 14.x - uses: actions/setup-node@v1 + - name: Use Node.js + uses: actions/setup-node@v4 with: - node-version: '14.x' + node-version: '18.x' - name: Cache Node.js modules id: node-cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: node_modules key: ${{ runner.OS }}-node-modules-${{ hashFiles('package-lock.json') }} diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml index ac52a365..ee98ff59 100644 --- a/.github/workflows/js.yml +++ b/.github/workflows/js.yml @@ -17,16 +17,16 @@ jobs: runs-on: ubuntu-latest name: JavaScript steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - name: Use Node.js 14.x - uses: actions/setup-node@v1 + - name: Use Node.js + uses: actions/setup-node@v4 with: - node-version: '14.x' + node-version: '18.x' - name: Cache Node.js modules id: node-cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: node_modules key: ${{ runner.OS }}-node-modules-${{ hashFiles('package-lock.json') }} diff --git a/android/build.gradle b/android/build.gradle index a8f8de2e..c8dde5cd 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,6 +1,6 @@ dependencies { - implementation 'com.google.zxing:core:3.3.3' + implementation 'com.google.zxing:core:3.5.3' implementation 'com.google.zxing:android-core:3.3.0' implementation 'com.google.zxing:android-integration:3.3.0' } diff --git a/android/manifest b/android/manifest index e8c251f1..bf87a4cf 100644 --- a/android/manifest +++ b/android/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 6.0.1 +version: 6.1.0 apiversion: 4 architectures: arm64-v8a armeabi-v7a x86 x86_64 description: Lets you process 1D/2D barcodes. diff --git a/android/src/com/google/zxing/client/android/BeepManager.java b/android/src/com/google/zxing/client/android/BeepManager.java index 76e8651e..c6515edb 100644 --- a/android/src/com/google/zxing/client/android/BeepManager.java +++ b/android/src/com/google/zxing/client/android/BeepManager.java @@ -75,7 +75,7 @@ synchronized void playBeepSoundAndVibrate() { } private static boolean shouldBeep(SharedPreferences prefs, Context activity) { - boolean shouldPlayBeep = prefs.getBoolean(PreferencesActivity.KEY_PLAY_BEEP, true); + boolean shouldPlayBeep = prefs.getBoolean(PreferencesActivity.KEY_PLAY_BEEP, false); if (shouldPlayBeep) { // See if sound settings overrides this AudioManager audioService = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE); diff --git a/android/src/com/google/zxing/client/android/CaptureActivity.java b/android/src/com/google/zxing/client/android/CaptureActivity.java index 56ffa472..fd9577a7 100755 --- a/android/src/com/google/zxing/client/android/CaptureActivity.java +++ b/android/src/com/google/zxing/client/android/CaptureActivity.java @@ -16,6 +16,7 @@ package com.google.zxing.client.android; + import com.google.zxing.BarcodeFormat; import com.google.zxing.DecodeHintType; import com.google.zxing.Result; @@ -26,8 +27,6 @@ import com.google.zxing.client.android.result.ResultButtonListener; import com.google.zxing.client.android.result.ResultHandler; import com.google.zxing.client.android.result.ResultHandlerFactory; -import com.google.zxing.client.android.result.supplement.SupplementalInfoRetriever; -import com.google.zxing.client.android.share.ShareActivity; import android.app.Activity; import android.app.AlertDialog; @@ -236,9 +235,7 @@ private void resume(){ inactivityTimer.onResume(); - copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true) - && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true)); - + copyToClipboard = intent.getBooleanExtra(Intents.Scan.KEY_COPY_TO_CLIPBOARD, false); source = IntentSource.NONE; sourceUrl = null; scanFromWebPageManager = null; @@ -651,12 +648,9 @@ private void handleDecodeInternally(Result rawResult, ResultHandler resultHandle } // Briefly show the contents of the barcode, then handle the result outside Barcode Scanner. - private void handleDecodeExternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) { - - if (barcode != null) { - viewfinderView.drawResultBitmap(barcode); - } + private void handleDecodeExternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) { + // get display time long resultDurationMS; if (getIntent() == null) { resultDurationMS = DEFAULT_INTENT_RESULT_DURATION_MS; @@ -664,7 +658,6 @@ private void handleDecodeExternally(Result rawResult, ResultHandler resultHandle resultDurationMS = getIntent().getLongExtra(Intents.Scan.RESULT_DISPLAY_DURATION_MS, DEFAULT_INTENT_RESULT_DURATION_MS); } - if (resultDurationMS > 0) { String rawResultString = String.valueOf(rawResult); if (rawResultString.length() > 32) { @@ -675,6 +668,10 @@ private void handleDecodeExternally(Result rawResult, ResultHandler resultHandle } } + if (barcode != null && resultDurationMS > 0) { + viewfinderView.drawResultBitmap(barcode); + } + maybeSetClipboard(resultHandler); if (source == IntentSource.NATIVE_APP_INTENT) { diff --git a/android/src/com/google/zxing/client/android/Intents.java b/android/src/com/google/zxing/client/android/Intents.java index 8c77ad46..89108ef3 100755 --- a/android/src/com/google/zxing/client/android/Intents.java +++ b/android/src/com/google/zxing/client/android/Intents.java @@ -185,6 +185,7 @@ public static final class Scan { * Setting this to false will not save scanned codes in the history. Specified as a {@code boolean}. */ public static final String SAVE_HISTORY = "SAVE_HISTORY"; + public static final String KEY_COPY_TO_CLIPBOARD = "KEY_COPY_TO_CLIPBOARD"; private Scan() { } diff --git a/android/src/ti/barcode/BarcodeModule.java b/android/src/ti/barcode/BarcodeModule.java index 976b508e..73903d6d 100644 --- a/android/src/ti/barcode/BarcodeModule.java +++ b/android/src/ti/barcode/BarcodeModule.java @@ -131,6 +131,7 @@ public BarcodeModule() defaultValues.put("allowInstructions", true); defaultValues.put("useFrontCamera", false); defaultValues.put("useLED", false); + defaultValues.put("copyToClipboard", false); } private static BarcodeModule _instance; @@ -351,6 +352,7 @@ public void capture(@Kroll.argument(optional = true) HashMap args) frameHeight = argsDict.optInt("frameHeight", 0); intent.putExtra(Intents.Scan.SHOW_INFO_TEXT, argsDict.optBoolean("showInfoText", false)); intent.putExtra(Intents.Scan.PREVENT_ROTATION, argsDict.optBoolean("preventRotation", true)); + intent.putExtra(Intents.Scan.RESULT_DISPLAY_DURATION_MS, (long) argsDict.optInt("resultDuration", 1500)); } else { Intents.Scan.overlayProxy = null; intent.putExtra(Intents.Scan.SHOW_RECTANGLE, true); @@ -360,8 +362,8 @@ public void capture(@Kroll.argument(optional = true) HashMap args) intent.putExtra(Intents.Scan.ALLOW_MENU, properties.optBoolean("allowMenu", true)); intent.putExtra(Intents.Scan.ALLOW_INSTRUCTIONS, properties.optBoolean("allowInstructions", true)); + intent.putExtra(Intents.Scan.KEY_COPY_TO_CLIPBOARD, properties.optBoolean("copyToClipboard", false)); intent.putExtra(Intents.Scan.PROMPT_MESSAGE, properties.optString("displayedMessage", null)); - // [MOD-217] -- Must set the package in order for it to automatically select the application as the source of the scanning activity. intent.setPackage(TiApplication.getInstance().getPackageName()); // CaptureActivity.PACKAGE_NAME = TiApplication.getInstance().getPackageName(); diff --git a/apidoc/BarcodeModule.yml b/apidoc/BarcodeModule.yml index ff1432ae..c4760038 100644 --- a/apidoc/BarcodeModule.yml +++ b/apidoc/BarcodeModule.yml @@ -335,6 +335,13 @@ properties: since: "3.1.0" platforms: [android] + - name: copyToClipboard + summary: Whether or not copy the result to the clipboard + type: Boolean + default: false + since: "6.1.0" + platforms: [android] + - name: displayedMessage summary: Controls the message that is displayed to the end user when they are capturing a barcode. type: String @@ -404,11 +411,11 @@ events: summary: The format of the barcode. Reported with a value of one of the Modules.Barcode.FORMAT_* constant if matching a known format. Otehrwise, may report a string value. type: [String,Number] platforms: [android, iphone, ipad] - + - name: result summary: The raw contents of the barcode type: String - + - name: code summary: | The activity result code from the scanning activity. Use the result constants defined in the [Ti.Android](Titanium.Android) namespace @@ -429,14 +436,14 @@ events: - name: bytes summary: The raw byte array contents of the barcode, when available type: Titanium.Buffer - + - name: error summary: Sent when an error occurs. properties: - name: message summary: The error message type: String - + - name: code summary: | The activity result code from the scanning activity. Use the result constants defined in the [Ti.Android](Titanium.Android) namespace @@ -452,7 +459,7 @@ events: - name: message summary: The error message type: String - + - name: code summary: | The activity result code from the scanning activity. Use the result constants defined in the [Ti.Android](Titanium.Android) namespace @@ -524,6 +531,14 @@ properties: default: true platforms: [android, iphone, ipad] + - name: resultDuration + summary: | + Time in milliseconds that the result will be visible after a scan. + type: Number + optional: true + default: 1500 + platforms: [android] + - name: frameWidth summary: | Width of the rectangle that is shown in the scanner diff --git a/example/app.js b/example/app.js index a7475356..a13fb1b5 100644 --- a/example/app.js +++ b/example/app.js @@ -8,7 +8,8 @@ Barcode.allowRotation = true; Barcode.displayedMessage = ' '; Barcode.allowMenu = false; Barcode.allowInstructions = false; -Barcode.useLED = true; +// Barcode.copyToClipboard = true; +// Barcode.useLED = true; var isAndroid = Ti.Platform.osname === 'android'; var isiOS = !isAndroid; @@ -50,7 +51,7 @@ var switchButton = Ti.UI.createButton({ borderRadius: 10, borderWidth: 1, opacity: 0.5, - width: 220, + width: 250, height: 30, bottom: 10 }); @@ -76,9 +77,9 @@ var cancelButton = Ti.UI.createButton({ borderRadius: 10, borderWidth: 1, opacity: 0.5, - width: 220, + width: 250, height: 30, - top: 20 + top: 10 }); cancelButton.addEventListener('click', function () { Barcode.cancel(); @@ -89,10 +90,16 @@ overlay.add(cancelButton); * Create a button that will trigger the barcode scanner. */ var scanCode = Ti.UI.createButton({ - title: 'Scan the Code', - width: 150, - height: 60, - top: 20 + title: 'Scan the Code (continuous)', + width: 300, + height: 50, + top: 10 +}); +var scanCodeOnce = Ti.UI.createButton({ + title: 'Scan the Code (one time)', + width: 300, + height: 50, + top: 10 }); var cameraPermission = (callback) => { @@ -125,7 +132,7 @@ var cameraPermission = (callback) => { }; scanCode.addEventListener('click', function () { - cameraPermission(function (re) { + cameraPermission(function (_re) { reset(); // Note: while the simulator will NOT show a camera stream in the simulator, you may still call "Barcode.capture" // to test your barcode scanning overlay. @@ -136,22 +143,43 @@ scanCode.addEventListener('click', function () { showRectangle: false, keepOpen: true /* , - acceptedFormats: [ - Barcode.FORMAT_QR_CODE - ]*/ + acceptedFormats: [ + Barcode.FORMAT_QR_CODE + ]*/ }); }); }); scrollView.add(scanCode); +scanCodeOnce.addEventListener('click', function () { + cameraPermission(function (_re) { + reset(); + // Note: while the simulator will NOT show a camera stream in the simulator, you may still call "Barcode.capture" + // to test your barcode scanning overlay. + Barcode.capture({ + animate: true, + overlay: overlay, + showCancel: false, + showRectangle: false, + keepOpen: false, + resultDuration: 0 + /* , + acceptedFormats: [ + Barcode.FORMAT_QR_CODE + ]*/ + }); + }); +}); +scrollView.add(scanCodeOnce); + /** * Create a button that will show the gallery picker. */ var scanImage = Ti.UI.createButton({ title: 'Scan Image from Gallery', - width: 150, - height: 60, - top: 20 + width: 300, + height: 50, + top: 10 }); scanImage.addEventListener('click', function () { diff --git a/ios/titanium.xcconfig b/ios/titanium.xcconfig index 258993f2..2a613683 100755 --- a/ios/titanium.xcconfig +++ b/ios/titanium.xcconfig @@ -4,10 +4,10 @@ // OF YOUR TITANIUM SDK YOU'RE BUILDING FOR // // -TITANIUM_SDK_VERSION = 9.3.2.GA +TITANIUM_SDK_VERSION = 12.3.0.GA -// +// // THESE SHOULD BE OK GENERALLY AS-IS // TITANIUM_SDK = /Users/$(USER)/Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION)