diff --git a/Android/build.gradle b/Android/build.gradle
index 7d6d18db..143e9239 100644
--- a/Android/build.gradle
+++ b/Android/build.gradle
@@ -21,6 +21,7 @@ allprojects {
maven {
url "https://dl.bintray.com/osborn/Android"
}
+ maven { url 'https://jitpack.io' }
}
}
diff --git a/Android/doric/build.gradle b/Android/doric/build.gradle
index 48396872..bcf9a6de 100644
--- a/Android/doric/build.gradle
+++ b/Android/doric/build.gradle
@@ -54,6 +54,9 @@ dependencies {
implementation 'com.google.code.gson:gson:2.8.6'
api "com.google.android.material:material:1.0.0"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ implementation 'cn.bingoogolapple:bga-qrcode-zxing:1.3.7'
+ implementation 'com.github.tbruyelle:rxpermissions:0.10.2'
+ implementation "io.reactivex.rxjava2:rxjava:2.2.14"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
diff --git a/Android/doric/src/main/AndroidManifest.xml b/Android/doric/src/main/AndroidManifest.xml
index c334325c..de0689df 100644
--- a/Android/doric/src/main/AndroidManifest.xml
+++ b/Android/doric/src/main/AndroidManifest.xml
@@ -1,2 +1,9 @@
+ package="pub.doric">
+
+
+
+
+
+
+
diff --git a/Android/doric/src/main/java/pub/doric/dev/DevPanel.java b/Android/doric/src/main/java/pub/doric/dev/DevPanel.java
index e5aa2bba..37713773 100644
--- a/Android/doric/src/main/java/pub/doric/dev/DevPanel.java
+++ b/Android/doric/src/main/java/pub/doric/dev/DevPanel.java
@@ -1,5 +1,7 @@
package pub.doric.dev;
+import android.Manifest;
+import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -9,7 +11,10 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
+import com.tbruyelle.rxpermissions2.RxPermissions;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.functions.Consumer;
import pub.doric.R;
public class DevPanel extends BottomSheetDialogFragment {
@@ -27,4 +32,28 @@ public class DevPanel extends BottomSheetDialogFragment {
) {
return inflater.inflate(R.layout.layout_dev, container, false);
}
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ getView().findViewById(R.id.menu1_text_view).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ final RxPermissions rxPermissions = new RxPermissions(DevPanel.this);
+ Disposable disposable = rxPermissions
+ .request(Manifest.permission.CAMERA)
+ .subscribe(new Consumer() {
+ @Override
+ public void accept(Boolean grant) throws Exception {
+ if (grant){
+ Intent intent = new Intent(getContext(), ScanQRCodeActivity.class);
+ getContext().startActivity(intent);
+ }
+ }
+ });
+
+ }
+ });
+ }
}
diff --git a/Android/doric/src/main/java/pub/doric/dev/ScanQRCodeActivity.java b/Android/doric/src/main/java/pub/doric/dev/ScanQRCodeActivity.java
new file mode 100644
index 00000000..82312848
--- /dev/null
+++ b/Android/doric/src/main/java/pub/doric/dev/ScanQRCodeActivity.java
@@ -0,0 +1,72 @@
+package pub.doric.dev;
+
+import android.os.Bundle;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+
+import cn.bingoogolapple.qrcode.core.QRCodeView;
+import cn.bingoogolapple.qrcode.zxing.ZXingView;
+import pub.doric.R;
+
+public class ScanQRCodeActivity extends AppCompatActivity implements QRCodeView.Delegate {
+
+ private ZXingView mZXingView;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.layout_scan_qrcode);
+ mZXingView = findViewById(R.id.zxingview);
+ mZXingView.setDelegate(this);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ mZXingView.startCamera();
+ mZXingView.startSpotAndShowRect();
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+
+ mZXingView.stopCamera();
+ super.onStop();
+ }
+
+ @Override
+ protected void onDestroy() {
+ mZXingView.onDestroy();
+ super.onDestroy();
+ }
+
+ @Override
+ public void onScanQRCodeSuccess(String result) {
+ setTitle("扫描结果为:" + result);
+ }
+
+ @Override
+ public void onCameraAmbientBrightnessChanged(boolean isDark) {
+ String tipText = mZXingView.getScanBoxView().getTipText();
+ String ambientBrightnessTip = "\n环境过暗,请打开闪光灯";
+ if (isDark) {
+ if (!tipText.contains(ambientBrightnessTip)) {
+ mZXingView.getScanBoxView().setTipText(tipText + ambientBrightnessTip);
+ }
+ } else {
+ if (tipText.contains(ambientBrightnessTip)) {
+ tipText = tipText.substring(0, tipText.indexOf(ambientBrightnessTip));
+ mZXingView.getScanBoxView().setTipText(tipText);
+ }
+ }
+ }
+
+ @Override
+ public void onScanQRCodeOpenCameraError() {
+ System.out.println();
+ }
+}
diff --git a/Android/doric/src/main/res/layout/layout_dev.xml b/Android/doric/src/main/res/layout/layout_dev.xml
index 73192065..09f24399 100644
--- a/Android/doric/src/main/res/layout/layout_dev.xml
+++ b/Android/doric/src/main/res/layout/layout_dev.xml
@@ -1,6 +1,5 @@
@@ -10,11 +9,8 @@
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center"
- android:text="Debug via Visual Studio Code"
- android:textSize="20sp"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
+ android:text="Dev Kit"
+ android:textSize="20sp" />
+
+
+
+
+ android:textSize="20sp" />
\ No newline at end of file
diff --git a/Android/doric/src/main/res/layout/layout_scan_qrcode.xml b/Android/doric/src/main/res/layout/layout_scan_qrcode.xml
new file mode 100644
index 00000000..7511b4f9
--- /dev/null
+++ b/Android/doric/src/main/res/layout/layout_scan_qrcode.xml
@@ -0,0 +1,20 @@
+
+
+
+
+