|
|
@@ -2,22 +2,18 @@ package com.naz.sdkdemo;
|
|
|
|
|
|
import android.Manifest;
|
|
|
import android.annotation.SuppressLint;
|
|
|
-import android.app.AlertDialog;
|
|
|
import android.bluetooth.BluetoothAdapter;
|
|
|
import android.bluetooth.BluetoothGatt;
|
|
|
import android.bluetooth.BluetoothGattCharacteristic;
|
|
|
import android.bluetooth.BluetoothGattService;
|
|
|
import android.content.ContentValues;
|
|
|
import android.content.Context;
|
|
|
-import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.content.pm.PackageManager;
|
|
|
import android.location.LocationManager;
|
|
|
import android.os.Build;
|
|
|
import android.os.Environment;
|
|
|
-import android.os.Handler;
|
|
|
import android.provider.MediaStore;
|
|
|
-import android.provider.Settings;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
import android.view.KeyEvent;
|
|
|
@@ -38,13 +34,12 @@ import com.clj.fastble.utils.HexUtil;
|
|
|
import com.google.common.util.concurrent.ListenableFuture;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
-import com.naz.sdkdemo.activity.CaremaActivity;
|
|
|
-import com.naz.sdkdemo.activity.ble.BleActivity;
|
|
|
import com.naz.sdkdemo.activity.ble.comm.ObserverManager;
|
|
|
import com.naz.sdkdemo.base.BaseActivity;
|
|
|
import com.naz.sdkdemo.bean.PrintModule;
|
|
|
import com.naz.sdkdemo.bean.PrintModule2;
|
|
|
import com.naz.sdkdemo.bean.PrintModule3;
|
|
|
+import com.naz.sdkdemo.http.ApiHelper;
|
|
|
import com.naz.sdkdemo.utils.MyTools;
|
|
|
import com.tencent.smtt.export.external.interfaces.WebResourceError;
|
|
|
import com.tencent.smtt.export.external.interfaces.WebResourceRequest;
|
|
|
@@ -61,7 +56,6 @@ import java.lang.reflect.Method;
|
|
|
import java.lang.reflect.Type;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
@@ -252,8 +246,8 @@ public class MainActivity extends BaseActivity {
|
|
|
findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener(){
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
-// Log.e("-------->","------->path="+getImagePath("123.jpg"));
|
|
|
- toTakePhoto();
|
|
|
+ Log.e("-------->","------->path="+getImagePath("123.jpg"));
|
|
|
+ savePicture(new File(getImagePath("123.jpg")), "ceshi", "202119");
|
|
|
// startActivity(new Intent(MainActivity.this, CaremaActivity.class));
|
|
|
}
|
|
|
});
|
|
|
@@ -280,9 +274,9 @@ public class MainActivity extends BaseActivity {
|
|
|
private class AndroidInterface {
|
|
|
|
|
|
@JavascriptInterface
|
|
|
- public void takePhoto() {
|
|
|
+ public void takePhoto(String path, String name) {
|
|
|
Log.e(TAG, "takePhoto");
|
|
|
- toTakePhoto();
|
|
|
+ toTakePhoto(path, name);
|
|
|
}
|
|
|
|
|
|
@JavascriptInterface
|
|
|
@@ -378,7 +372,7 @@ public class MainActivity extends BaseActivity {
|
|
|
}, ContextCompat.getMainExecutor(this));
|
|
|
}
|
|
|
|
|
|
- private void toTakePhoto() {
|
|
|
+ private void toTakePhoto(String path, String name) {
|
|
|
Log.e("-------->","------>toTakePhoto");
|
|
|
long timeStamp = System.currentTimeMillis();
|
|
|
savePath = timeStamp+".jpg";
|
|
|
@@ -409,6 +403,7 @@ public class MainActivity extends BaseActivity {
|
|
|
Log.e("-------->","------>savePath="+outputFileResults.getSavedUri().getPath());
|
|
|
Log.e("-------->","------>保存成功");
|
|
|
Toast.makeText(MainActivity.this, "保存成功", Toast.LENGTH_SHORT).show();
|
|
|
+ savePicture(file, path, name);
|
|
|
mWebView.loadUrl("javascript:uploadPhotoPath('" + outputFileOptions.getFile().getAbsolutePath() + "')");
|
|
|
}
|
|
|
|
|
|
@@ -420,6 +415,10 @@ public class MainActivity extends BaseActivity {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private void savePicture(File file, String path, String name) {
|
|
|
+ ApiHelper.uploadPicture(this, file, path, name);
|
|
|
+ }
|
|
|
+
|
|
|
private void checkNet() {
|
|
|
if (!MyTools.isNetworkAvailable(getApplicationContext())) {
|
|
|
ll_nonet.setVisibility(View.VISIBLE);
|