Browse Source

添加扫码依赖包

master
Penny 3 years ago
parent
commit
ab9cce52e1
  1. 1
      .gitignore
  2. 3
      app/build.gradle
  3. BIN
      app/libs/mlkit-scanner-release.aar
  4. 9
      scanCode/build.gradle
  5. 27
      scanCode/src/main/java/cn/bnyer/scancode/scanCode.java

1
.gitignore

@ -5,6 +5,7 @@
/.idea/libraries /.idea/libraries
/.idea/modules.xml /.idea/modules.xml
/.idea/workspace.xml /.idea/workspace.xml
.idea
.DS_Store .DS_Store
/build /build
/captures /captures

3
app/build.gradle

@ -81,4 +81,7 @@ dependencies {
implementation project(':uniplugin_module') implementation project(':uniplugin_module')
implementation project(':uniplugin_richalert') implementation project(':uniplugin_richalert')
implementation project(':scanCode') implementation project(':scanCode')
} }

BIN
app/libs/mlkit-scanner-release.aar

Binary file not shown.

9
scanCode/build.gradle

@ -64,13 +64,20 @@ repositories {
dependencies { dependencies {
compileOnly fileTree(dir: 'libs', include: ['*.jar']) compileOnly fileTree(dir: 'libs', include: ['*.jar'])
compileOnly fileTree(dir: '../app/libs', include: ['uniapp-v8-release.aar']) compileOnly fileTree(dir: '../app/libs', include: ['uniapp-v8-release.aar','mlkit-scanner-release.aar'])
compileOnly 'androidx.recyclerview:recyclerview:1.0.0' compileOnly 'androidx.recyclerview:recyclerview:1.0.0'
compileOnly 'androidx.legacy:legacy-support-v4:1.0.0' compileOnly 'androidx.legacy:legacy-support-v4:1.0.0'
compileOnly 'androidx.appcompat:appcompat:1.0.0' compileOnly 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.alibaba:fastjson:1.2.83' implementation 'com.alibaba:fastjson:1.2.83'
implementation 'com.facebook.fresco:fresco:1.13.0' implementation 'com.facebook.fresco:fresco:1.13.0'
//
implementation 'com.github.ITxiaoguang:MLKitScanner:1.0.0'
implementation 'com.google.mlkit:barcode-scanning:17.0.2'
// implementation "androidx.camera:camera-core:1.0.2"
// implementation "androidx.camera:camera-camera2:1.0.2"
// implementation "androidx.camera:camera-lifecycle:1.0.2"
// implementation "androidx.camera:camera-view:1.0.0-alpha25"
/*implementation 'com.android.support:appcompat-v7:28.0.0' /*implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'

27
scanCode/src/main/java/cn/bnyer/scancode/scanCode.java

@ -1,5 +1,12 @@
package cn.bnyer.scancode; package cn.bnyer.scancode;
import android.content.Intent;
import com.google.mlkit.vision.barcode.BarcodeScannerOptions;
import com.google.mlkit.vision.barcode.common.Barcode;
import com.xiaoguang.widget.mlkitscanner.ScanManager;
import com.xiaoguang.widget.mlkitscanner.callback.act.ScanCallback;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -9,7 +16,7 @@ import io.dcloud.feature.uniapp.common.UniModule;
public class scanCode extends UniModule { public class scanCode extends UniModule {
@UniJSMethod @UniJSMethod(uiThread = false)
public void add(JSONObject json, UniJSCallback callback) throws JSONException { public void add(JSONObject json, UniJSCallback callback) throws JSONException {
final int a = json.getInt("a"); final int a = json.getInt("a");
final int b = json.getInt("b"); final int b = json.getInt("b");
@ -20,4 +27,22 @@ public class scanCode extends UniModule {
} }
}); });
} }
@UniJSMethod(uiThread = false)
public void scanCode(){
BarcodeScannerOptions options = new BarcodeScannerOptions.Builder()
.setBarcodeFormats(
Barcode.FORMAT_QR_CODE,
Barcode.FORMAT_AZTEC)
.build();
// ScanManager manager = new ScanManager();
// manager.startScan(this, new ScanCallback() {
// @Override
// public void onActivityResult(int i, Intent intent) {
//
// }
// });
}
} }

Loading…
Cancel
Save