From 3f8f1590859188c334739f76f1d64c2b6c2bfd55 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 31 十月 2024 17:01:06 +0800
Subject: [PATCH] 2024年10月31日17:01:04
---
app/src/main/res/layout/activity_scan.xml | 120 +++---
app/src/main/java/com/hdl/photovoltaic/ui/device/ScanActivity.java | 844 +++++++++++++++++++++++--------------------------
app/src/main/java/com/hdl/photovoltaic/utils/StringUtils.java | 3
app/build.gradle | 4
4 files changed, 456 insertions(+), 515 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index fca1c03..debb8cc 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -136,7 +136,7 @@
//榛樿鍊间负 5ms 灏忎簬璇ュ�肩殑鍑芥暟鍦ㄨ皟鐢ㄦ爤涓笉鏄剧ず
thresholdTime 10
// //璋冪敤鏍堝嚱鏁板叆鍙� 鍗冧竾涓嶈鐢ㄦ垜榛樿鐨勯厤缃� 濡傛灉鏈夌壒娈婇渶姹備慨鏀规垚椤圭洰涓嚜宸辩殑鍏ュ彛 鍋囧涓嶉渶瑕佸彲浠ュ幓鎺夎瀛楁
-// enterMethods = ["com.hdl.photovoltaic.MainDebugActivity.test1"]
+ enterMethods = ["com.hdl.photovoltaic.ui.StartActivity"]
// //榛戝悕鍗� 绮掑害鏈�灏忓埌绫� 鏆備笉鏀寔鍒版柟娉� 鍗冧竾涓嶈鐢ㄦ垜榛樿鐨勯厤缃� 濡傛灉鏈夌壒娈婇渶姹備慨鏀规垚椤圭洰涓嚜宸辩殑鍏ュ彛 鍋囧涓嶉渶瑕佸彲浠ュ幓鎺夎瀛楁
// methodBlacklist = ["com.facebook.drawee.backends.pipeline.Fresco"]
}
@@ -187,7 +187,7 @@
//鍥藉鍒楄〃鍜屾墜鏈哄尯鍙峰簱
implementation project(path: ':countrypicker')
//浜岀淮鐮佸簱
- implementation project(path: ':third-zxing')
+// implementation project(path: ':third-zxing')
//Link鏈湴搴擄紙鍦ㄧ嚎渚濊禆缃戠粶搴擄級
implementation 'com.hdl.android:pmsdk:1.0.9'
implementation 'com.hdl.android:debugsdk:1.0.54'
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/device/ScanActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/device/ScanActivity.java
index 96a9bb3..7d56e27 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/device/ScanActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/device/ScanActivity.java
@@ -1,462 +1,404 @@
package com.hdl.photovoltaic.ui.device;
import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.database.Cursor;
-import android.graphics.Rect;
-import android.hardware.Camera;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Handler;
-import android.provider.MediaStore;
-import android.text.TextUtils;
-import android.util.DisplayMetrics;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.View;
-import android.view.Window;
-import android.view.WindowManager;
-import android.view.animation.Animation;
-import android.view.animation.TranslateAnimation;
-import android.widget.ImageView;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import androidx.appcompat.content.res.AppCompatResources;
-
-import com.google.zxing.BinaryBitmap;
-import com.google.zxing.ChecksumException;
-import com.google.zxing.DecodeHintType;
-import com.google.zxing.FormatException;
-import com.google.zxing.NotFoundException;
-import com.google.zxing.Result;
-import com.google.zxing.common.HybridBinarizer;
-import com.google.zxing.qrcode.QRCodeReader;
-import com.hdl.photovoltaic.R;
-import com.hdl.photovoltaic.base.CustomBaseActivity;
-import com.hdl.photovoltaic.config.UserConfigManage;
-import com.hdl.photovoltaic.other.HdlCommonLogic;
-import com.hdl.photovoltaic.uni.HDLUniMP;
-import com.hdl.photovoltaic.utils.LocalManageUtil;
-import com.jaeger.library.StatusBarUtil;
-import com.zxing.IZxingActivity;
-import com.zxing.camera.CameraManager;
-import com.zxing.decode.DecodeThread;
-import com.zxing.decode.RGBLuminanceSource;
-import com.zxing.utils.BeepManager;
-import com.zxing.utils.CaptureActivityHandler;
-import com.zxing.utils.InactivityTimer;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.Hashtable;
-import java.util.Locale;
/**
* 鎵竴鎵�
*/
-public class ScanActivity extends Activity implements IZxingActivity, SurfaceHolder.Callback {
- private static final String TAG = ScanActivity.class.getSimpleName();
- private final int REQUEST_CODE = 33;
- private CameraManager cameraManager;
- private CaptureActivityHandler handler;
- private InactivityTimer inactivityTimer;
- private BeepManager beepManager;
- private SurfaceView scanPreview = null;
- private RelativeLayout scanContainer;
- private RelativeLayout scanCropView;
- private TextView tvCancel;
- private Rect mCropRect = null;
- private boolean isHasSurface = false;
-
-
- @Override
- public Handler getHandler() {
- return handler;
- }
-
- @Override
- public void drawViewfinder() {
-
- }
-
- @Override
- public CameraManager getCameraManager() {
- return cameraManager;
- }
-
- public int getRootLayoutId() {
- return R.layout.activity_scan;
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Resources resources = this.getResources();
- Configuration configuration = resources.getConfiguration();
- Locale locale = LocalManageUtil.getLocale(UserConfigManage.getInstance().getCurrentAppLanguage());
- // app locale 榛樿绠�浣撲腑鏂�
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- configuration.setLocale(locale);
- } else {
- configuration.locale = locale;
- }
- DisplayMetrics dm = resources.getDisplayMetrics();
- resources.updateConfiguration(configuration, dm);
-
- StatusBarUtil.setTranslucentForImageViewInFragment(this,
- 0, null);
- StatusBarUtil.setLightMode(this);
-
- Window window = getWindow();
- window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- //璁剧疆鏍硅鍥�
- View mContentView = LayoutInflater.from(this).inflate(getRootLayoutId(), null);
- setContentView(mContentView);
- afterViewBind(mContentView, savedInstanceState);
-
- }
-
- public void afterViewBind(View rootView, Bundle savedInstanceState) {
- tvCancel = findViewById(R.id.tv_text_cancel);
- tvCancel.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- finish();
-// enterGallery();
- }
- });
- scanPreview = findViewById(R.id.capture_preview);
- scanContainer = findViewById(R.id.capture_container);
- scanCropView = findViewById(R.id.capture_crop_view);
- ImageView scanLine = findViewById(R.id.capture_scan_line);
- inactivityTimer = new InactivityTimer(this);
- beepManager = new BeepManager(this);
-
- TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation
- .RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
- 0.9f);
- animation.setDuration(2000);
- animation.setRepeatCount(-1);
- animation.setRepeatMode(Animation.RESTART);
- scanLine.startAnimation(animation);
- ImageView imageView = findViewById(R.id.light_iv);
- //寮�鍚棯鍏夌伅鎸夐挳浜嬩欢
- imageView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- v.setSelected(!v.isSelected());
- if (v.isSelected()) {
- imageView.setImageDrawable(AppCompatResources.getDrawable(ScanActivity.this, com.zxing.R.drawable.fast_scan_light_open));
- } else {
- imageView.setImageDrawable(AppCompatResources.getDrawable(ScanActivity.this, com.zxing.R.drawable.fast_scan_light_close));
- }
- flashLightOnOrOff();
-
- }
- });
- }
-
- public void enterGallery() {
- // 杩涘叆鍥惧簱
- Intent pickIntent = new Intent(Intent.ACTION_PICK,
- MediaStore.Images.Media.EXTERNAL_CONTENT_URI);//鍚姩绯荤粺鐩稿唽
- pickIntent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
- startActivityForResult(pickIntent, REQUEST_CODE);
-
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- cameraManager = new CameraManager(getApplication());
- handler = null;
- if (isHasSurface) {
- initCamera(scanPreview.getHolder());
- } else {
- scanPreview.getHolder().addCallback(this);
- }
-
- inactivityTimer.onResume();
- }
-
- @Override
- protected void onPause() {
- if (handler != null) {
- handler.quitSynchronously();
- handler = null;
- }
- inactivityTimer.onPause();
- beepManager.close();
- cameraManager.closeDriver();
- if (!isHasSurface) {
- scanPreview.getHolder().removeCallback(this);
- }
- super.onPause();
- }
-
- @Override
- protected void onDestroy() {
- inactivityTimer.shutdown();
- super.onDestroy();
- }
-
- @Override
- public void surfaceCreated(SurfaceHolder holder) {
- if (holder == null) {
- Log.d(TAG, "*** WARNING *** surfaceCreated() gave us a null surface!");
- }
- if (!isHasSurface) {
- isHasSurface = true;
- initCamera(holder);
- }
- }
-
- @Override
- public void surfaceDestroyed(SurfaceHolder holder) {
- isHasSurface = false;
- }
-
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
-
- }
-
- /**
- * A valid barcode has been found, so give an indication of success and show
- * the results.
- *
- * @param rawResult The contents of the barcode.
- * @param bundle The extras
- */
- @Override
- public void handleDecode(Result rawResult, Bundle bundle) {
- inactivityTimer.onActivity();
- beepManager.playBeepSoundAndVibrate();
- doProcess(rawResult.getText());
- restartPreviewAfterDelay(3000);
- }
-
- private void initCamera(SurfaceHolder surfaceHolder) {
- if (surfaceHolder == null) {
- throw new IllegalStateException("No SurfaceHolder provided");
- }
- if (cameraManager.isOpen()) {
- Log.w(TAG, "initCamera() while already open -- late SurfaceView callback?");
- return;
- }
- try {
- cameraManager.openDriver(surfaceHolder);
- // Creating the handler starts the preview, which can also throw a
- // RuntimeException.
- if (handler == null) {
- handler = new CaptureActivityHandler(this, cameraManager, DecodeThread.ALL_MODE);
- }
-
- initCrop();
- } catch (IOException ioe) {
- Log.w(TAG, ioe);
- Toast.makeText(this, R.string.capture_no_camera, Toast.LENGTH_SHORT).show();
- finish();
- } catch (RuntimeException e) {
- Log.w(TAG, "Unexpected error initializing camera", e);
- Toast.makeText(this, R.string.capture_no_camera, Toast.LENGTH_SHORT).show();
- finish();
- }
- }
-
- public void restartPreviewAfterDelay(long delayMS) {
- if (handler != null) {
- handler.sendEmptyMessageDelayed(com.zxing.R.id.restart_preview, delayMS);
- }
- }
-
- @Override
- public Rect getCropRect() {
- return mCropRect;
- }
-
- /**
- * 鍒濆鍖栨埅鍙栫殑鐭╁舰鍖哄煙
- */
- private void initCrop() {
- int cameraWidth = cameraManager.getCameraResolution().y;
- int cameraHeight = cameraManager.getCameraResolution().x;
-
- /** 鑾峰彇甯冨眬涓壂鎻忔鐨勪綅缃俊鎭� */
- int[] location = new int[2];
- scanCropView.getLocationInWindow(location);
-
- int cropLeft = location[0];
- int cropTop = location[1] - getStatusBarHeight();
-
- int cropWidth = scanCropView.getWidth();
- int cropHeight = scanCropView.getHeight();
-
- /** 鑾峰彇甯冨眬瀹瑰櫒鐨勫楂� */
- int containerWidth = scanContainer.getWidth();
- int containerHeight = scanContainer.getHeight();
-
- /** 璁$畻鏈�缁堟埅鍙栫殑鐭╁舰鐨勫乏涓婅椤剁偣x鍧愭爣 */
- int x = cropLeft * cameraWidth / containerWidth;
- /** 璁$畻鏈�缁堟埅鍙栫殑鐭╁舰鐨勫乏涓婅椤剁偣y鍧愭爣 */
- int y = cropTop * cameraHeight / containerHeight;
-
- /** 璁$畻鏈�缁堟埅鍙栫殑鐭╁舰鐨勫搴� */
- int width = cropWidth * cameraWidth / containerWidth;
- /** 璁$畻鏈�缁堟埅鍙栫殑鐭╁舰鐨勯珮搴� */
- int height = cropHeight * cameraHeight / containerHeight;
-
- /** 鐢熸垚鏈�缁堢殑鎴彇鐨勭煩褰� */
- mCropRect = new Rect(x, y, width + x, height + y);
- }
-
- private int getStatusBarHeight() {
- try {
- Class<?> c = Class.forName("com.android.internal.R$dimen");
- Object obj = c.newInstance();
- Field field = c.getField("status_bar_height");
- int x = Integer.parseInt(field.get(obj).toString());
- return getResources().getDimensionPixelSize(x);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return 0;
- }
-
- private void doProcess(String result) {
- /*if (!DeviceHelper.getNetworkState()) {
- Toast.makeText(this, R.string.capture_no_network, Toast.LENGTH_SHORT).show();
- return;
- }*/
-
- if (TextUtils.isEmpty(result)) {
- Toast.makeText(this, R.string.capture_no_result, Toast.LENGTH_SHORT).show();
- } else {
- if (result.startsWith("https://") || result.startsWith("http://")) {
- Intent intent = new Intent();
- intent.putExtra("data", result);
- setResult(RESULT_OK, intent);
- finish();
- //EventBus浜嬩欢鍒嗗彂
- HdlCommonLogic.getInstance().postEventBusSticky(
- HDLUniMP.UNI_EVENT_REPLY_HOME_ADD,
- HDLUniMP.UNI_EVENT_REPLY_HOME_ADD,
- result);
- } else {
- Toast.makeText(this, R.string.not_delivery_qr_code, Toast.LENGTH_SHORT).show();
- }
-
- }
- }
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (requestCode == REQUEST_CODE && resultCode == RESULT_OK && data != null) {
- Uri originalUri = data.getData();
- if (originalUri != null) {
- String path = originalUri.getPath();
- String[] proj = {MediaStore.Images.Media.DATA};
- Cursor cursor = getContentResolver().query(originalUri, proj, null, null, null);
- if (cursor != null) {
- int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
- cursor.moveToFirst();
- path = cursor.getString(column_index);
- cursor.close();
- }
-
- if (!TextUtils.isEmpty(path)) {
- handleQRCodeFormPhoto(path);
- } else {
-// Toast.makeText(this, R.string.pic_error, Toast.LENGTH_SHORT).show();
- }
- }
- }
- }
-
- /**
- * 瑙f瀽鍥惧簱閫夋嫨鐨勪簩缁寸爜
- */
- public void handleQRCodeFormPhoto(final String filePath) {
- Thread dealThread = new Thread(new Runnable() {
- @Override
- public void run() {
- Hashtable<DecodeHintType, String> hints = new Hashtable<>();
- hints.put(DecodeHintType.CHARACTER_SET, "utf-8");
- RGBLuminanceSource source = null;
- try {
- source = new RGBLuminanceSource(filePath);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source));
- QRCodeReader reader = new QRCodeReader();
- Result result;
- try {
- result = reader.decode(binaryBitmap, hints);
- if (!TextUtils.isEmpty(result.getText())) {
- dealUIInfo(result.getText());
- } else {
- dealUIInfo(null);
- }
- } catch (NotFoundException | ChecksumException | FormatException e) {
- dealUIInfo(null);
- e.printStackTrace();
- }
- }
- });
- dealThread.start();
- }
-
- private void dealUIInfo(final Object progressInfo) {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- if (progressInfo == null) {
- Toast.makeText(ScanActivity.this, R.string.capture_no_result2, Toast.LENGTH_SHORT).show();
- } else {
- doProcess(progressInfo.toString());
- }
- }
- });
- }
-
- /**
- * 闂厜鐏紑鍚垨鑰呭叧闂�
- */
- private void flashLightOnOrOff() {
+public class ScanActivity extends Activity {
+// private static final String TAG = ScanActivity.class.getSimpleName();
+// private final int REQUEST_CODE = 33;
+// private CameraManager cameraManager;
+// private CaptureActivityHandler handler;
+// private InactivityTimer inactivityTimer;
+// private BeepManager beepManager;
+// private SurfaceView scanPreview = null;
+// private RelativeLayout scanContainer;
+// private RelativeLayout scanCropView;
+// private TextView tvCancel;
+// private Rect mCropRect = null;
+// private boolean isHasSurface = false;
//
- android.hardware.Camera camera = cameraManager.getCamera();
- if (camera == null) {
- return;
- }
- android.hardware.Camera.Parameters parameters = camera.getParameters();
-// 鍒ゆ柇闂厜鐏綋鍓嶇姸鎬�
- if (Camera.Parameters.FLASH_MODE_OFF.equals(parameters.getFlashMode())) {
- onLight(camera, parameters);
- } else if (Camera.Parameters.FLASH_MODE_TORCH.equals(parameters.getFlashMode())) {
- offLight(camera, parameters);
- }
- }
-
- private void onLight(android.hardware.Camera camera, Camera.Parameters parameters) {
- parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
- camera.setParameters(parameters);
- }
-
- private void offLight(android.hardware.Camera camera, Camera.Parameters parameters) {
- parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
- camera.setParameters(parameters);
- }
+//
+// @Override
+// public Handler getHandler() {
+// return handler;
+// }
+//
+// @Override
+// public void drawViewfinder() {
+//
+// }
+//
+// @Override
+// public CameraManager getCameraManager() {
+// return cameraManager;
+// }
+//
+// public int getRootLayoutId() {
+// return R.layout.activity_scan;
+// }
+//
+// @Override
+// protected void onCreate(Bundle savedInstanceState) {
+// super.onCreate(savedInstanceState);
+// Resources resources = this.getResources();
+// Configuration configuration = resources.getConfiguration();
+// Locale locale = LocalManageUtil.getLocale(UserConfigManage.getInstance().getCurrentAppLanguage());
+// // app locale 榛樿绠�浣撲腑鏂�
+// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+// configuration.setLocale(locale);
+// } else {
+// configuration.locale = locale;
+// }
+// DisplayMetrics dm = resources.getDisplayMetrics();
+// resources.updateConfiguration(configuration, dm);
+//
+// StatusBarUtil.setTranslucentForImageViewInFragment(this,
+// 0, null);
+// StatusBarUtil.setLightMode(this);
+//
+// Window window = getWindow();
+// window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+// //璁剧疆鏍硅鍥�
+// View mContentView = LayoutInflater.from(this).inflate(getRootLayoutId(), null);
+// setContentView(mContentView);
+// afterViewBind(mContentView, savedInstanceState);
+//
+// }
+//
+// public void afterViewBind(View rootView, Bundle savedInstanceState) {
+// tvCancel = findViewById(R.id.tv_text_cancel);
+// tvCancel.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View v) {
+// finish();
+//// enterGallery();
+// }
+// });
+// scanPreview = findViewById(R.id.capture_preview);
+// scanContainer = findViewById(R.id.capture_container);
+// scanCropView = findViewById(R.id.capture_crop_view);
+// ImageView scanLine = findViewById(R.id.capture_scan_line);
+// inactivityTimer = new InactivityTimer(this);
+// beepManager = new BeepManager(this);
+//
+// TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation
+// .RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
+// 0.9f);
+// animation.setDuration(2000);
+// animation.setRepeatCount(-1);
+// animation.setRepeatMode(Animation.RESTART);
+// scanLine.startAnimation(animation);
+// ImageView imageView = findViewById(R.id.light_iv);
+// //寮�鍚棯鍏夌伅鎸夐挳浜嬩欢
+// imageView.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View v) {
+// v.setSelected(!v.isSelected());
+// if (v.isSelected()) {
+// imageView.setImageDrawable(AppCompatResources.getDrawable(ScanActivity.this, com.zxing.R.drawable.fast_scan_light_open));
+// } else {
+// imageView.setImageDrawable(AppCompatResources.getDrawable(ScanActivity.this, com.zxing.R.drawable.fast_scan_light_close));
+// }
+// flashLightOnOrOff();
+//
+// }
+// });
+// }
+//
+// public void enterGallery() {
+// // 杩涘叆鍥惧簱
+// Intent pickIntent = new Intent(Intent.ACTION_PICK,
+// MediaStore.Images.Media.EXTERNAL_CONTENT_URI);//鍚姩绯荤粺鐩稿唽
+// pickIntent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
+// startActivityForResult(pickIntent, REQUEST_CODE);
+//
+// }
+//
+// @Override
+// protected void onResume() {
+// super.onResume();
+// cameraManager = new CameraManager(getApplication());
+// handler = null;
+// if (isHasSurface) {
+// initCamera(scanPreview.getHolder());
+// } else {
+// scanPreview.getHolder().addCallback(this);
+// }
+//
+// inactivityTimer.onResume();
+// }
+//
+// @Override
+// protected void onPause() {
+// if (handler != null) {
+// handler.quitSynchronously();
+// handler = null;
+// }
+// inactivityTimer.onPause();
+// beepManager.close();
+// cameraManager.closeDriver();
+// if (!isHasSurface) {
+// scanPreview.getHolder().removeCallback(this);
+// }
+// super.onPause();
+// }
+//
+// @Override
+// protected void onDestroy() {
+// inactivityTimer.shutdown();
+// super.onDestroy();
+// }
+//
+// @Override
+// public void surfaceCreated(SurfaceHolder holder) {
+// if (holder == null) {
+// Log.d(TAG, "*** WARNING *** surfaceCreated() gave us a null surface!");
+// }
+// if (!isHasSurface) {
+// isHasSurface = true;
+// initCamera(holder);
+// }
+// }
+//
+// @Override
+// public void surfaceDestroyed(SurfaceHolder holder) {
+// isHasSurface = false;
+// }
+//
+// @Override
+// public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+//
+// }
+//
+// /**
+// * A valid barcode has been found, so give an indication of success and show
+// * the results.
+// *
+// * @param rawResult The contents of the barcode.
+// * @param bundle The extras
+// */
+// @Override
+// public void handleDecode(Result rawResult, Bundle bundle) {
+// inactivityTimer.onActivity();
+// beepManager.playBeepSoundAndVibrate();
+// doProcess(rawResult.getText());
+// restartPreviewAfterDelay(3000);
+// }
+//
+// private void initCamera(SurfaceHolder surfaceHolder) {
+// if (surfaceHolder == null) {
+// throw new IllegalStateException("No SurfaceHolder provided");
+// }
+// if (cameraManager.isOpen()) {
+// Log.w(TAG, "initCamera() while already open -- late SurfaceView callback?");
+// return;
+// }
+// try {
+// cameraManager.openDriver(surfaceHolder);
+// // Creating the handler starts the preview, which can also throw a
+// // RuntimeException.
+// if (handler == null) {
+// handler = new CaptureActivityHandler(this, cameraManager, DecodeThread.ALL_MODE);
+// }
+//
+// initCrop();
+// } catch (IOException ioe) {
+// Log.w(TAG, ioe);
+// Toast.makeText(this, R.string.capture_no_camera, Toast.LENGTH_SHORT).show();
+// finish();
+// } catch (RuntimeException e) {
+// Log.w(TAG, "Unexpected error initializing camera", e);
+// Toast.makeText(this, R.string.capture_no_camera, Toast.LENGTH_SHORT).show();
+// finish();
+// }
+// }
+//
+// public void restartPreviewAfterDelay(long delayMS) {
+// if (handler != null) {
+// handler.sendEmptyMessageDelayed(com.zxing.R.id.restart_preview, delayMS);
+// }
+// }
+//
+// @Override
+// public Rect getCropRect() {
+// return mCropRect;
+// }
+//
+// /**
+// * 鍒濆鍖栨埅鍙栫殑鐭╁舰鍖哄煙
+// */
+// private void initCrop() {
+// int cameraWidth = cameraManager.getCameraResolution().y;
+// int cameraHeight = cameraManager.getCameraResolution().x;
+//
+// /** 鑾峰彇甯冨眬涓壂鎻忔鐨勪綅缃俊鎭� */
+// int[] location = new int[2];
+// scanCropView.getLocationInWindow(location);
+//
+// int cropLeft = location[0];
+// int cropTop = location[1] - getStatusBarHeight();
+//
+// int cropWidth = scanCropView.getWidth();
+// int cropHeight = scanCropView.getHeight();
+//
+// /** 鑾峰彇甯冨眬瀹瑰櫒鐨勫楂� */
+// int containerWidth = scanContainer.getWidth();
+// int containerHeight = scanContainer.getHeight();
+//
+// /** 璁$畻鏈�缁堟埅鍙栫殑鐭╁舰鐨勫乏涓婅椤剁偣x鍧愭爣 */
+// int x = cropLeft * cameraWidth / containerWidth;
+// /** 璁$畻鏈�缁堟埅鍙栫殑鐭╁舰鐨勫乏涓婅椤剁偣y鍧愭爣 */
+// int y = cropTop * cameraHeight / containerHeight;
+//
+// /** 璁$畻鏈�缁堟埅鍙栫殑鐭╁舰鐨勫搴� */
+// int width = cropWidth * cameraWidth / containerWidth;
+// /** 璁$畻鏈�缁堟埅鍙栫殑鐭╁舰鐨勯珮搴� */
+// int height = cropHeight * cameraHeight / containerHeight;
+//
+// /** 鐢熸垚鏈�缁堢殑鎴彇鐨勭煩褰� */
+// mCropRect = new Rect(x, y, width + x, height + y);
+// }
+//
+// private int getStatusBarHeight() {
+// try {
+// Class<?> c = Class.forName("com.android.internal.R$dimen");
+// Object obj = c.newInstance();
+// Field field = c.getField("status_bar_height");
+// int x = Integer.parseInt(field.get(obj).toString());
+// return getResources().getDimensionPixelSize(x);
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// return 0;
+// }
+//
+// private void doProcess(String result) {
+// /*if (!DeviceHelper.getNetworkState()) {
+// Toast.makeText(this, R.string.capture_no_network, Toast.LENGTH_SHORT).show();
+// return;
+// }*/
+//
+// if (TextUtils.isEmpty(result)) {
+// Toast.makeText(this, R.string.capture_no_result, Toast.LENGTH_SHORT).show();
+// } else {
+// if (result.startsWith("https://") || result.startsWith("http://")) {
+// Intent intent = new Intent();
+// intent.putExtra("data", result);
+// setResult(RESULT_OK, intent);
+// finish();
+// //EventBus浜嬩欢鍒嗗彂
+// HdlCommonLogic.getInstance().postEventBusSticky(
+// HDLUniMP.UNI_EVENT_REPLY_HOME_ADD,
+// HDLUniMP.UNI_EVENT_REPLY_HOME_ADD,
+// result);
+// } else {
+// Toast.makeText(this, R.string.not_delivery_qr_code, Toast.LENGTH_SHORT).show();
+// }
+//
+// }
+// }
+//
+// @Override
+// public void onActivityResult(int requestCode, int resultCode, Intent data) {
+// super.onActivityResult(requestCode, resultCode, data);
+// if (requestCode == REQUEST_CODE && resultCode == RESULT_OK && data != null) {
+// Uri originalUri = data.getData();
+// if (originalUri != null) {
+// String path = originalUri.getPath();
+// String[] proj = {MediaStore.Images.Media.DATA};
+// Cursor cursor = getContentResolver().query(originalUri, proj, null, null, null);
+// if (cursor != null) {
+// int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
+// cursor.moveToFirst();
+// path = cursor.getString(column_index);
+// cursor.close();
+// }
+//
+// if (!TextUtils.isEmpty(path)) {
+// handleQRCodeFormPhoto(path);
+// } else {
+//// Toast.makeText(this, R.string.pic_error, Toast.LENGTH_SHORT).show();
+// }
+// }
+// }
+// }
+//
+// /**
+// * 瑙f瀽鍥惧簱閫夋嫨鐨勪簩缁寸爜
+// */
+// public void handleQRCodeFormPhoto(final String filePath) {
+// Thread dealThread = new Thread(new Runnable() {
+// @Override
+// public void run() {
+// Hashtable<DecodeHintType, String> hints = new Hashtable<>();
+// hints.put(DecodeHintType.CHARACTER_SET, "utf-8");
+// RGBLuminanceSource source = null;
+// try {
+// source = new RGBLuminanceSource(filePath);
+// } catch (FileNotFoundException e) {
+// e.printStackTrace();
+// }
+// BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source));
+// QRCodeReader reader = new QRCodeReader();
+// Result result;
+// try {
+// result = reader.decode(binaryBitmap, hints);
+// if (!TextUtils.isEmpty(result.getText())) {
+// dealUIInfo(result.getText());
+// } else {
+// dealUIInfo(null);
+// }
+// } catch (NotFoundException | ChecksumException | FormatException e) {
+// dealUIInfo(null);
+// e.printStackTrace();
+// }
+// }
+// });
+// dealThread.start();
+// }
+//
+// private void dealUIInfo(final Object progressInfo) {
+// runOnUiThread(new Runnable() {
+// @Override
+// public void run() {
+// if (progressInfo == null) {
+// Toast.makeText(ScanActivity.this, R.string.capture_no_result2, Toast.LENGTH_SHORT).show();
+// } else {
+// doProcess(progressInfo.toString());
+// }
+// }
+// });
+// }
+//
+// /**
+// * 闂厜鐏紑鍚垨鑰呭叧闂�
+// */
+// private void flashLightOnOrOff() {
+////
+// android.hardware.Camera camera = cameraManager.getCamera();
+// if (camera == null) {
+// return;
+// }
+// android.hardware.Camera.Parameters parameters = camera.getParameters();
+//// 鍒ゆ柇闂厜鐏綋鍓嶇姸鎬�
+// if (Camera.Parameters.FLASH_MODE_OFF.equals(parameters.getFlashMode())) {
+// onLight(camera, parameters);
+// } else if (Camera.Parameters.FLASH_MODE_TORCH.equals(parameters.getFlashMode())) {
+// offLight(camera, parameters);
+// }
+// }
+//
+// private void onLight(android.hardware.Camera camera, Camera.Parameters parameters) {
+// parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
+// camera.setParameters(parameters);
+// }
+//
+// private void offLight(android.hardware.Camera camera, Camera.Parameters parameters) {
+// parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
+// camera.setParameters(parameters);
+// }
}
diff --git a/app/src/main/java/com/hdl/photovoltaic/utils/StringUtils.java b/app/src/main/java/com/hdl/photovoltaic/utils/StringUtils.java
index 0598337..13cdc4f 100644
--- a/app/src/main/java/com/hdl/photovoltaic/utils/StringUtils.java
+++ b/app/src/main/java/com/hdl/photovoltaic/utils/StringUtils.java
@@ -2,7 +2,6 @@
import android.text.TextUtils;
-import com.zxing.utils.Strings;
import java.util.Iterator;
import java.util.regex.Pattern;
@@ -35,7 +34,7 @@
* 鍘婚櫎瀛楃涓蹭腑鐨勭┖鏍�
*/
public static String trimAll(CharSequence s) {
- if (s == null || s.length() == 0) return Strings.EMPTY;
+ if (s == null || s.length() == 0) return "";
StringBuilder sb = new StringBuilder(s.length());
for (int i = 0, L = s.length(); i < L; i++) {
char c = s.charAt(i);
diff --git a/app/src/main/res/layout/activity_scan.xml b/app/src/main/res/layout/activity_scan.xml
index 7ca098d..64f5c1a 100644
--- a/app/src/main/res/layout/activity_scan.xml
+++ b/app/src/main/res/layout/activity_scan.xml
@@ -54,73 +54,73 @@
</RelativeLayout>
- <ImageView
- android:id="@+id/capture_mask_top"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_above="@+id/capture_crop_view"
- android:background="@drawable/ic_shadow"/>
+<!-- <ImageView-->
+<!-- android:id="@+id/capture_mask_top"-->
+<!-- android:layout_width="match_parent"-->
+<!-- android:layout_height="wrap_content"-->
+<!-- android:layout_alignParentTop="true"-->
+<!-- android:layout_above="@+id/capture_crop_view"-->
+<!-- android:background="@drawable/ic_shadow"/>-->
- <ImageView
- android:id="@+id/capture_mask_bottom"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_below="@+id/capture_crop_view"
- android:background="@drawable/ic_shadow"/>
+<!-- <ImageView-->
+<!-- android:id="@+id/capture_mask_bottom"-->
+<!-- android:layout_width="match_parent"-->
+<!-- android:layout_height="wrap_content"-->
+<!-- android:layout_alignParentBottom="true"-->
+<!-- android:layout_below="@+id/capture_crop_view"-->
+<!-- android:background="@drawable/ic_shadow"/>-->
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_above="@+id/capture_mask_bottom"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/capture_mask_top"
- android:layout_toLeftOf="@+id/capture_crop_view"
- android:background="@drawable/ic_shadow"/>
+<!-- <ImageView-->
+<!-- android:layout_width="wrap_content"-->
+<!-- android:layout_height="match_parent"-->
+<!-- android:layout_above="@+id/capture_mask_bottom"-->
+<!-- android:layout_alignParentLeft="true"-->
+<!-- android:layout_below="@+id/capture_mask_top"-->
+<!-- android:layout_toLeftOf="@+id/capture_crop_view"-->
+<!-- android:background="@drawable/ic_shadow"/>-->
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_above="@+id/capture_mask_bottom"
- android:layout_alignParentRight="true"
- android:layout_below="@+id/capture_mask_top"
- android:layout_toRightOf="@+id/capture_crop_view"
- android:background="@drawable/ic_shadow"/>
+<!-- <ImageView-->
+<!-- android:layout_width="wrap_content"-->
+<!-- android:layout_height="match_parent"-->
+<!-- android:layout_above="@+id/capture_mask_bottom"-->
+<!-- android:layout_alignParentRight="true"-->
+<!-- android:layout_below="@+id/capture_mask_top"-->
+<!-- android:layout_toRightOf="@+id/capture_crop_view"-->
+<!-- android:background="@drawable/ic_shadow"/>-->
- <RelativeLayout
- android:id="@+id/capture_crop_view"
- android:layout_width="267dp"
- android:layout_height="267dp"
- android:layout_centerInParent="true"
- android:background="@drawable/scan_capture">
- </RelativeLayout>
+<!-- <RelativeLayout-->
+<!-- android:id="@+id/capture_crop_view"-->
+<!-- android:layout_width="267dp"-->
+<!-- android:layout_height="267dp"-->
+<!-- android:layout_centerInParent="true"-->
+<!-- android:background="@drawable/scan_capture">-->
+<!-- </RelativeLayout>-->
- <RelativeLayout
- android:layout_width="267dp"
- android:layout_height="267dp"
- android:layout_below="@+id/capture_mask_top"
- android:layout_centerInParent="true">
+<!-- <RelativeLayout-->
+<!-- android:layout_width="267dp"-->
+<!-- android:layout_height="267dp"-->
+<!-- android:layout_below="@+id/capture_mask_top"-->
+<!-- android:layout_centerInParent="true">-->
- <ImageView
- android:id="@+id/capture_scan_line"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:src="@drawable/scan_line" />
- </RelativeLayout>
+<!-- <ImageView-->
+<!-- android:id="@+id/capture_scan_line"-->
+<!-- android:layout_width="match_parent"-->
+<!-- android:layout_height="wrap_content"-->
+<!-- android:layout_alignParentTop="true"-->
+<!-- android:layout_marginTop="5dp"-->
+<!-- android:layout_marginBottom="5dp"-->
+<!-- android:src="@drawable/scan_line" />-->
+<!-- </RelativeLayout>-->
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/capture_crop_view"
- android:layout_centerHorizontal="true"
- android:layout_marginTop="10dp"
- android:text=""
- android:textColor="#ffffffff"
- android:textSize="14sp"/>
+<!-- <TextView-->
+<!-- android:layout_width="wrap_content"-->
+<!-- android:layout_height="wrap_content"-->
+<!-- android:layout_below="@+id/capture_crop_view"-->
+<!-- android:layout_centerHorizontal="true"-->
+<!-- android:layout_marginTop="10dp"-->
+<!-- android:text=""-->
+<!-- android:textColor="#ffffffff"-->
+<!-- android:textSize="14sp"/>-->
</RelativeLayout>
<ImageView
--
Gitblit v1.8.0