Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android: update library #357

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
}
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 8 additions & 11 deletions android/src/com/google/zxing/client/android/CaptureActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -651,20 +648,16 @@ 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;
} else {
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) {
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions android/src/com/google/zxing/client/android/Intents.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Expand Down
4 changes: 3 additions & 1 deletion android/src/ti/barcode/BarcodeModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down
25 changes: 20 additions & 5 deletions apidoc/BarcodeModule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading