统一日志管理

This commit is contained in:
Jenly
2020-04-27 21:44:01 +08:00
parent 86dac6216b
commit 078d31b2ad
19 changed files with 502 additions and 155 deletions

View File

@@ -3,14 +3,14 @@
![Image](app/src/main/ic_launcher-web.png) ![Image](app/src/main/ic_launcher-web.png)
[![Download](https://img.shields.io/badge/download-App-blue.svg)](https://raw.githubusercontent.com/jenly1314/ZXingLite/master/app/release/app-release.apk) [![Download](https://img.shields.io/badge/download-App-blue.svg)](https://raw.githubusercontent.com/jenly1314/ZXingLite/master/app/release/app-release.apk)
[![JCenter](https://img.shields.io/badge/JCenter-1.1.7-46C018.svg)](https://bintray.com/beta/#/jenly/maven/zxing-lite) [![JCenter](https://img.shields.io/badge/JCenter-1.1.8-46C018.svg)](https://bintray.com/beta/#/jenly/maven/zxing-lite)
[![JitPack](https://jitpack.io/v/jenly1314/ZXingLite.svg)](https://jitpack.io/#jenly1314/ZXingLite) [![JitPack](https://jitpack.io/v/jenly1314/ZXingLite.svg)](https://jitpack.io/#jenly1314/ZXingLite)
[![CI](https://travis-ci.org/jenly1314/ZXingLite.svg?branch=master)](https://travis-ci.org/jenly1314/ZXingLite) [![CI](https://travis-ci.org/jenly1314/ZXingLite.svg?branch=master)](https://travis-ci.org/jenly1314/ZXingLite)
[![CircleCI](https://circleci.com/gh/jenly1314/ZXingLite.svg?style=svg)](https://circleci.com/gh/jenly1314/ZXingLite) [![CircleCI](https://circleci.com/gh/jenly1314/ZXingLite.svg?style=svg)](https://circleci.com/gh/jenly1314/ZXingLite)
[![API](https://img.shields.io/badge/API-16%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=16) [![API](https://img.shields.io/badge/API-16%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=16)
[![License](https://img.shields.io/badge/license-Apche%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0) [![License](https://img.shields.io/badge/license-Apche%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)
[![Blog](https://img.shields.io/badge/blog-Jenly-9933CC.svg)](https://jenly1314.github.io/) [![Blog](https://img.shields.io/badge/blog-Jenly-9933CC.svg)](https://jenly1314.github.io/)
[![QQGroup](https://img.shields.io/badge/QQGroup-20867961-blue.svg)](http://shang.qq.com/wpa/qunwpa?idkey=8fcc6a2f88552ea44b1.1.782c94fd124f7bb3ec227e2a400dbbfaad3dc2f5ad) [![QQGroup](https://img.shields.io/badge/QQGroup-20867961-blue.svg)](http://shang.qq.com/wpa/qunwpa?idkey=8fcc6a2f88552ea44b1.1.882c94fd124f7bb3ec227e2a400dbbfaad3dc2f5ad)
ZXingLite for Android 是ZXing的精简版基于ZXing库优化扫码和生成二维码/条形码功能,扫码界面完全支持自定义,也可一行代码使用默认实现的扫码功能。总之你想要的都在这里。 ZXingLite for Android 是ZXing的精简版基于ZXing库优化扫码和生成二维码/条形码功能,扫码界面完全支持自定义,也可一行代码使用默认实现的扫码功能。总之你想要的都在这里。
>简单如斯,你不试试? Come on~ >简单如斯,你不试试? Come on~
@@ -55,21 +55,21 @@ ZXingLite for Android 是ZXing的精简版基于ZXing库优化扫码和生成
<dependency> <dependency>
<groupId>com.king.zxing</groupId> <groupId>com.king.zxing</groupId>
<artifactId>zxing-lite</artifactId> <artifactId>zxing-lite</artifactId>
<version>1.1.7</version> <version>1.1.8</version>
<type>pom</type> <type>pom</type>
</dependency> </dependency>
``` ```
### Gradle: ### Gradle:
```gradle ```gradle
//AndroidX 版本 //AndroidX 版本
implementation 'com.king.zxing:zxing-lite:1.1.7-androidx' implementation 'com.king.zxing:zxing-lite:1.1.8-androidx'
//Android 版本 //Android 版本
implementation 'com.king.zxing:zxing-lite:1.1.7' implementation 'com.king.zxing:zxing-lite:1.1.8'
``` ```
### Lvy: ### Lvy:
```lvy ```lvy
<dependency org='com.king.zxing' name='zxing-lite' rev='1.1.7'> <dependency org='com.king.zxing' name='zxing-lite' rev='1.1.8'>
<artifact name='$AID' ext='pom'></artifact> <artifact name='$AID' ext='pom'></artifact>
</dependency> </dependency>
``` ```
@@ -170,6 +170,10 @@ api 'com.google.zxing:core:3.3.3'
## 版本记录 ## 版本记录
#### v1.1.82020-4-27
* 统一日志管理
* 优化细节
#### v1.1.72020-3-29 #### v1.1.72020-3-29
* 优化一些默认参数配置 * 优化一些默认参数配置
* 修复扫码界面开启闪光灯并切到后台时手电筒按钮状态未同步问题fix#81 * 修复扫码界面开启闪光灯并切到后台时手电筒按钮状态未同步问题fix#81
@@ -249,7 +253,7 @@ api 'com.google.zxing:core:3.3.3'
Github: <a title="Github开源项目" href="https://github.com/jenly1314" target="_blank">jenly1314</a> Github: <a title="Github开源项目" href="https://github.com/jenly1314" target="_blank">jenly1314</a>
加入QQ群: <a title="点击加入QQ群" href="http://shang.qq.com/wpa/qunwpa?idkey=8fcc6a2f88552ea44b1.1.782c94fd124f7bb3ec227e2a400dbbfaad3dc2f5ad" target="_blank">20867961</a> 加入QQ群: <a title="点击加入QQ群" href="http://shang.qq.com/wpa/qunwpa?idkey=8fcc6a2f88552ea44b1.1.882c94fd124f7bb3ec227e2a400dbbfaad3dc2f5ad" target="_blank">20867961</a>
<div> <div>
<img src="https://jenly1314.github.io/image/jenly666.png"> <img src="https://jenly1314.github.io/image/jenly666.png">
<img src="https://jenly1314.github.io/image/qqgourp.png"> <img src="https://jenly1314.github.io/image/qqgourp.png">

Binary file not shown.

View File

@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":22,"versionName":"1.1.7-androidx","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":24,"versionName":"1.1.8-androidx","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

View File

@@ -26,7 +26,8 @@ import android.media.MediaPlayer;
import android.os.Build; import android.os.Build;
import android.os.Vibrator; import android.os.Vibrator;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import com.king.zxing.util.LogUtils;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
@@ -106,7 +107,7 @@ public final class BeepManager implements MediaPlayer.OnErrorListener, Closeable
mediaPlayer.prepare(); mediaPlayer.prepare();
return mediaPlayer; return mediaPlayer;
} catch (IOException ioe) { } catch (IOException ioe) {
Log.w(TAG, ioe); LogUtils.w(ioe);
mediaPlayer.release(); mediaPlayer.release();
return null; return null;
} }

View File

@@ -47,6 +47,7 @@ public class CaptureActivity extends AppCompatActivity implements OnCaptureCallb
setContentView(layoutId); setContentView(layoutId);
} }
initUI(); initUI();
mCaptureHelper.onCreate();
} }
/** /**
@@ -60,9 +61,12 @@ public class CaptureActivity extends AppCompatActivity implements OnCaptureCallb
ivTorch = findViewById(ivTorchId); ivTorch = findViewById(ivTorchId);
ivTorch.setVisibility(View.INVISIBLE); ivTorch.setVisibility(View.INVISIBLE);
} }
initCaptureHelper();
}
public void initCaptureHelper(){
mCaptureHelper = new CaptureHelper(this,surfaceView,viewfinderView,ivTorch); mCaptureHelper = new CaptureHelper(this,surfaceView,viewfinderView,ivTorch);
mCaptureHelper.setOnCaptureCallback(this); mCaptureHelper.setOnCaptureCallback(this);
mCaptureHelper.onCreate();
} }
/** /**

View File

@@ -73,6 +73,10 @@ public class CaptureFragment extends Fragment implements OnCaptureCallback {
ivTorch = mRootView.findViewById(ivTorchId); ivTorch = mRootView.findViewById(ivTorchId);
ivTorch.setVisibility(View.INVISIBLE); ivTorch.setVisibility(View.INVISIBLE);
} }
initCaptureHelper();
}
public void initCaptureHelper(){
mCaptureHelper = new CaptureHelper(this,surfaceView,viewfinderView,ivTorch); mCaptureHelper = new CaptureHelper(this,surfaceView,viewfinderView,ivTorch);
mCaptureHelper.setOnCaptureCallback(this); mCaptureHelper.setOnCaptureCallback(this);
} }

View File

@@ -33,6 +33,7 @@ import com.google.zxing.DecodeHintType;
import com.google.zxing.Result; import com.google.zxing.Result;
import com.king.zxing.camera.CameraManager; import com.king.zxing.camera.CameraManager;
import com.king.zxing.camera.FrontLightMode; import com.king.zxing.camera.FrontLightMode;
import com.king.zxing.util.LogUtils;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@@ -44,13 +45,14 @@ import java.util.Map;
import androidx.annotation.FloatRange; import androidx.annotation.FloatRange;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
/**
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
/** /**
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a> * @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/ */
public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,CaptureManager, SurfaceHolder.Callback { public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,CaptureManager, SurfaceHolder.Callback {
public static final String TAG = CaptureHelper.class.getSimpleName();
private Activity activity; private Activity activity;
private CaptureHandler captureHandler; private CaptureHandler captureHandler;
@@ -63,6 +65,7 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
private AmbientLightManager ambientLightManager; private AmbientLightManager ambientLightManager;
private SurfaceView surfaceView;
private ViewfinderView viewfinderView; private ViewfinderView viewfinderView;
private SurfaceHolder surfaceHolder; private SurfaceHolder surfaceHolder;
private View ivTorch; private View ivTorch;
@@ -186,15 +189,16 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
*/ */
public CaptureHelper(Activity activity,SurfaceView surfaceView,ViewfinderView viewfinderView,View ivTorch){ public CaptureHelper(Activity activity,SurfaceView surfaceView,ViewfinderView viewfinderView,View ivTorch){
this.activity = activity; this.activity = activity;
this.surfaceView = surfaceView;
this.viewfinderView = viewfinderView; this.viewfinderView = viewfinderView;
this.ivTorch = ivTorch; this.ivTorch = ivTorch;
surfaceHolder = surfaceView.getHolder();
hasSurface = false;
} }
@Override @Override
public void onCreate(){ public void onCreate(){
surfaceHolder = surfaceView.getHolder();
hasSurface = false;
inactivityTimer = new InactivityTimer(activity); inactivityTimer = new InactivityTimer(activity);
beepManager = new BeepManager(activity); beepManager = new BeepManager(activity);
ambientLightManager = new AmbientLightManager(activity); ambientLightManager = new AmbientLightManager(activity);
@@ -238,7 +242,6 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
public void onPause(){ public void onPause(){
if (captureHandler != null) { if (captureHandler != null) {
captureHandler.quitSynchronously(); captureHandler.quitSynchronously();
captureHandler = null;
} }
inactivityTimer.onPause(); inactivityTimer.onPause();
ambientLightManager.stop(); ambientLightManager.stop();
@@ -332,7 +335,7 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
throw new IllegalStateException("No SurfaceHolder provided"); throw new IllegalStateException("No SurfaceHolder provided");
} }
if (cameraManager.isOpen()) { if (cameraManager.isOpen()) {
Log.w(TAG, "initCamera() while already open -- late SurfaceView callback?"); LogUtils.w("initCamera() while already open -- late SurfaceView callback?");
return; return;
} }
try { try {
@@ -346,18 +349,18 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
captureHandler.setSupportLuminanceInvert(isSupportLuminanceInvert); captureHandler.setSupportLuminanceInvert(isSupportLuminanceInvert);
} }
} catch (IOException ioe) { } catch (IOException ioe) {
Log.w(TAG, ioe); LogUtils.w(ioe);
} catch (RuntimeException e) { } catch (RuntimeException e) {
// Barcode Scanner has seen crashes in the wild of this variety: // Barcode Scanner has seen crashes in the wild of this variety:
// java.?lang.?RuntimeException: Fail to connect to camera service // java.?lang.?RuntimeException: Fail to connect to camera service
Log.w(TAG, "Unexpected error initializing camera", e); LogUtils.w( "Unexpected error initializing camera", e);
} }
} }
@Override @Override
public void surfaceCreated(SurfaceHolder holder) { public void surfaceCreated(SurfaceHolder holder) {
if (holder == null) { if (holder == null) {
Log.e(TAG, "*** WARNING *** surfaceCreated() gave us a null surface!"); LogUtils.w( "*** WARNING *** surfaceCreated() gave us a null surface!");
} }
if (!hasSurface) { if (!hasSurface) {
hasSurface = true; hasSurface = true;
@@ -393,7 +396,7 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
params.setZoom(zoom); params.setZoom(zoom);
camera.setParameters(params); camera.setParameters(params);
} else { } else {
Log.i(TAG, "zoom not supported"); LogUtils.i( "zoom not supported");
} }
} }

View File

@@ -19,13 +19,11 @@ package com.king.zxing;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Point; import android.graphics.Point;
import android.graphics.PointF;
import android.hardware.Camera; import android.hardware.Camera;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.util.Log;
import android.view.Display; import android.view.Display;
import android.view.WindowManager; import android.view.WindowManager;
@@ -33,22 +31,19 @@ import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap; import com.google.zxing.BinaryBitmap;
import com.google.zxing.DecodeHintType; import com.google.zxing.DecodeHintType;
import com.google.zxing.MultiFormatReader; import com.google.zxing.MultiFormatReader;
import com.google.zxing.NotFoundException;
import com.google.zxing.PlanarYUVLuminanceSource; import com.google.zxing.PlanarYUVLuminanceSource;
import com.google.zxing.ReaderException;
import com.google.zxing.Result; import com.google.zxing.Result;
import com.google.zxing.ResultPoint; import com.google.zxing.ResultPoint;
import com.google.zxing.common.GlobalHistogramBinarizer; import com.google.zxing.common.GlobalHistogramBinarizer;
import com.google.zxing.common.HybridBinarizer; import com.google.zxing.common.HybridBinarizer;
import com.king.zxing.camera.CameraManager; import com.king.zxing.camera.CameraManager;
import com.king.zxing.util.LogUtils;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.util.Map; import java.util.Map;
final class DecodeHandler extends Handler { final class DecodeHandler extends Handler {
private static final String TAG = DecodeHandler.class.getSimpleName();
private final Context context; private final Context context;
private final CameraManager cameraManager; private final CameraManager cameraManager;
private final CaptureHandler handler; private final CaptureHandler handler;
@@ -151,7 +146,7 @@ final class DecodeHandler extends Handler {
if (rawResult != null) { if (rawResult != null) {
// Don't log the barcode contents for security. // Don't log the barcode contents for security.
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
Log.d(TAG, "Found barcode in " + (end - start) + " ms"); LogUtils.d("Found barcode in " + (end - start) + " ms");
BarcodeFormat barcodeFormat = rawResult.getBarcodeFormat(); BarcodeFormat barcodeFormat = rawResult.getBarcodeFormat();
if(handler!=null && handler.isSupportAutoZoom() && barcodeFormat == BarcodeFormat.QR_CODE){ if(handler!=null && handler.isSupportAutoZoom() && barcodeFormat == BarcodeFormat.QR_CODE){
@@ -242,7 +237,7 @@ final class DecodeHandler extends Handler {
lastZoomTime = System.currentTimeMillis(); lastZoomTime = System.currentTimeMillis();
return true; return true;
} else { } else {
Log.i(TAG, "Zoom not supported"); LogUtils.d("Zoom not supported");
} }
} }

View File

@@ -21,13 +21,13 @@ import com.google.zxing.BarcodeFormat;
import com.google.zxing.DecodeHintType; import com.google.zxing.DecodeHintType;
import com.google.zxing.ResultPointCallback; import com.google.zxing.ResultPointCallback;
import com.king.zxing.camera.CameraManager; import com.king.zxing.camera.CameraManager;
import com.king.zxing.util.LogUtils;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import java.util.Collection; import java.util.Collection;
import java.util.EnumMap; import java.util.EnumMap;
@@ -98,7 +98,7 @@ final class DecodeThread extends Thread {
hints.put(DecodeHintType.CHARACTER_SET, characterSet); hints.put(DecodeHintType.CHARACTER_SET, characterSet);
} }
hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback); hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
Log.i("DecodeThread", "Hints: " + hints); LogUtils.i("Hints: " + hints);
} }
Handler getHandler() { Handler getHandler() {

View File

@@ -24,7 +24,8 @@ import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.BatteryManager; import android.os.BatteryManager;
import android.util.Log;
import com.king.zxing.util.LogUtils;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.RejectedExecutionException;
@@ -56,7 +57,7 @@ final class InactivityTimer {
try { try {
inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} catch (RejectedExecutionException ree) { } catch (RejectedExecutionException ree) {
Log.w(TAG, "Couldn't schedule inactivity task; ignoring"); LogUtils.w( "Couldn't schedule inactivity task; ignoring");
} }
} }
@@ -66,13 +67,13 @@ final class InactivityTimer {
activity.unregisterReceiver(powerStatusReceiver); activity.unregisterReceiver(powerStatusReceiver);
registered = false; registered = false;
} else { } else {
Log.w(TAG, "PowerStatusReceiver was never registered?"); LogUtils.w( "PowerStatusReceiver was never registered?");
} }
} }
void onResume() { void onResume() {
if (registered) { if (registered) {
Log.w(TAG, "PowerStatusReceiver was already registered?"); LogUtils.w( "PowerStatusReceiver was already registered?");
} else { } else {
activity.registerReceiver(powerStatusReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); activity.registerReceiver(powerStatusReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
registered = true; registered = true;
@@ -130,7 +131,7 @@ final class InactivityTimer {
protected Object doInBackground(Object... objects) { protected Object doInBackground(Object... objects) {
try { try {
Thread.sleep(INACTIVITY_DELAY_MS); Thread.sleep(INACTIVITY_DELAY_MS);
Log.i(TAG, "Finishing activity due to inactivity"); LogUtils.i("Finishing activity due to inactivity");
Activity activity = weakReference.get(); Activity activity = weakReference.get();
if(activity!=null){ if(activity!=null){
activity.finish(); activity.finish();

View File

@@ -20,7 +20,6 @@ import android.content.SharedPreferences;
import android.hardware.Camera; import android.hardware.Camera;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
@@ -28,11 +27,10 @@ import java.util.Collection;
import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.RejectedExecutionException;
import com.king.zxing.Preferences; import com.king.zxing.Preferences;
import com.king.zxing.util.LogUtils;
final class AutoFocusManager implements Camera.AutoFocusCallback { final class AutoFocusManager implements Camera.AutoFocusCallback {
private static final String TAG = AutoFocusManager.class.getSimpleName();
private static final long AUTO_FOCUS_INTERVAL_MS = 1200L; private static final long AUTO_FOCUS_INTERVAL_MS = 1200L;
private static final Collection<String> FOCUS_MODES_CALLING_AF; private static final Collection<String> FOCUS_MODES_CALLING_AF;
static { static {
@@ -54,7 +52,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
useAutoFocus = useAutoFocus =
sharedPrefs.getBoolean(Preferences.KEY_AUTO_FOCUS, true) && sharedPrefs.getBoolean(Preferences.KEY_AUTO_FOCUS, true) &&
FOCUS_MODES_CALLING_AF.contains(currentFocusMode); FOCUS_MODES_CALLING_AF.contains(currentFocusMode);
Log.i(TAG, "Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus); LogUtils.i("Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus);
start(); start();
} }
@@ -71,7 +69,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
newTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); newTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
outstandingTask = newTask; outstandingTask = newTask;
} catch (RejectedExecutionException ree) { } catch (RejectedExecutionException ree) {
Log.w(TAG, "Could not request auto focus", ree); LogUtils.w("Could not request auto focus", ree);
} }
} }
} }
@@ -85,7 +83,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
focusing = true; focusing = true;
} catch (RuntimeException re) { } catch (RuntimeException re) {
// Have heard RuntimeException reported in Android 4.0.x+; continue? // Have heard RuntimeException reported in Android 4.0.x+; continue?
Log.w(TAG, "Unexpected exception while focusing", re); LogUtils.w("Unexpected exception while focusing", re);
// Try again later to keep cycle going // Try again later to keep cycle going
autoFocusAgainLater(); autoFocusAgainLater();
} }
@@ -111,7 +109,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
camera.cancelAutoFocus(); camera.cancelAutoFocus();
} catch (RuntimeException re) { } catch (RuntimeException re) {
// Have heard RuntimeException reported in Android 4.0.x+; continue? // Have heard RuntimeException reported in Android 4.0.x+; continue?
Log.w(TAG, "Unexpected exception while cancelling focusing", re); LogUtils.w("Unexpected exception while cancelling focusing", re);
} }
} }
} }

View File

@@ -22,7 +22,6 @@ import android.content.SharedPreferences;
import android.graphics.Point; import android.graphics.Point;
import android.hardware.Camera; import android.hardware.Camera;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Display; import android.view.Display;
import android.view.Surface; import android.view.Surface;
import android.view.WindowManager; import android.view.WindowManager;
@@ -30,6 +29,7 @@ import android.view.WindowManager;
import com.king.zxing.Preferences; import com.king.zxing.Preferences;
import com.king.zxing.camera.open.CameraFacing; import com.king.zxing.camera.open.CameraFacing;
import com.king.zxing.camera.open.OpenCamera; import com.king.zxing.camera.open.OpenCamera;
import com.king.zxing.util.LogUtils;
/** /**
* A class which deals with reading, parsing, and setting the camera parameters which are used to * A class which deals with reading, parsing, and setting the camera parameters which are used to
@@ -38,8 +38,6 @@ import com.king.zxing.camera.open.OpenCamera;
@SuppressWarnings("deprecation") // camera APIs @SuppressWarnings("deprecation") // camera APIs
final class CameraConfigurationManager { final class CameraConfigurationManager {
private static final String TAG = "CameraConfiguration";
private final Context context; private final Context context;
private int cwNeededRotation; private int cwNeededRotation;
private int cwRotationFromDisplayToCamera; private int cwRotationFromDisplayToCamera;
@@ -83,15 +81,15 @@ final class CameraConfigurationManager {
throw new IllegalArgumentException("Bad rotation: " + displayRotation); throw new IllegalArgumentException("Bad rotation: " + displayRotation);
} }
} }
Log.i(TAG, "Display at: " + cwRotationFromNaturalToDisplay); LogUtils.i("Display at: " + cwRotationFromNaturalToDisplay);
int cwRotationFromNaturalToCamera = camera.getOrientation(); int cwRotationFromNaturalToCamera = camera.getOrientation();
Log.i(TAG, "Camera at: " + cwRotationFromNaturalToCamera); LogUtils.i("Camera at: " + cwRotationFromNaturalToCamera);
// Still not 100% sure about this. But acts like we need to flip this: // Still not 100% sure about this. But acts like we need to flip this:
if (camera.getFacing() == CameraFacing.FRONT) { if (camera.getFacing() == CameraFacing.FRONT) {
cwRotationFromNaturalToCamera = (360 - cwRotationFromNaturalToCamera) % 360; cwRotationFromNaturalToCamera = (360 - cwRotationFromNaturalToCamera) % 360;
Log.i(TAG, "Front camera overriden to: " + cwRotationFromNaturalToCamera); LogUtils.i("Front camera overriden to: " + cwRotationFromNaturalToCamera);
} }
/* /*
@@ -103,30 +101,30 @@ final class CameraConfigurationManager {
overrideRotationString = prefs.getString(PreferencesActivity.KEY_FORCE_CAMERA_ORIENTATION, null); overrideRotationString = prefs.getString(PreferencesActivity.KEY_FORCE_CAMERA_ORIENTATION, null);
} }
if (overrideRotationString != null && !"-".equals(overrideRotationString)) { if (overrideRotationString != null && !"-".equals(overrideRotationString)) {
Log.i(TAG, "Overriding camera manually to " + overrideRotationString); LogUtils.i("Overriding camera manually to " + overrideRotationString);
cwRotationFromNaturalToCamera = Integer.parseInt(overrideRotationString); cwRotationFromNaturalToCamera = Integer.parseInt(overrideRotationString);
} }
*/ */
cwRotationFromDisplayToCamera = (360 + cwRotationFromNaturalToCamera - cwRotationFromNaturalToDisplay) % 360; cwRotationFromDisplayToCamera = (360 + cwRotationFromNaturalToCamera - cwRotationFromNaturalToDisplay) % 360;
Log.i(TAG, "Final display orientation: " + cwRotationFromDisplayToCamera); LogUtils.i("Final display orientation: " + cwRotationFromDisplayToCamera);
if (camera.getFacing() == CameraFacing.FRONT) { if (camera.getFacing() == CameraFacing.FRONT) {
Log.i(TAG, "Compensating rotation for front camera"); LogUtils.i("Compensating rotation for front camera");
cwNeededRotation = (360 - cwRotationFromDisplayToCamera) % 360; cwNeededRotation = (360 - cwRotationFromDisplayToCamera) % 360;
} else { } else {
cwNeededRotation = cwRotationFromDisplayToCamera; cwNeededRotation = cwRotationFromDisplayToCamera;
} }
Log.i(TAG, "Clockwise rotation from display to camera: " + cwNeededRotation); LogUtils.i("Clockwise rotation from display to camera: " + cwNeededRotation);
Point theScreenResolution = new Point(); Point theScreenResolution = new Point();
display.getSize(theScreenResolution); display.getSize(theScreenResolution);
screenResolution = theScreenResolution; screenResolution = theScreenResolution;
Log.i(TAG, "Screen resolution in current orientation: " + screenResolution); LogUtils.i("Screen resolution in current orientation: " + screenResolution);
cameraResolution = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution); cameraResolution = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution);
Log.i(TAG, "Camera resolution: " + cameraResolution); LogUtils.i("Camera resolution: " + cameraResolution);
bestPreviewSize = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution); bestPreviewSize = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution);
Log.i(TAG, "Best available preview size: " + bestPreviewSize); LogUtils.i("Best available preview size: " + bestPreviewSize);
boolean isScreenPortrait = screenResolution.x < screenResolution.y; boolean isScreenPortrait = screenResolution.x < screenResolution.y;
boolean isPreviewSizePortrait = bestPreviewSize.x < bestPreviewSize.y; boolean isPreviewSizePortrait = bestPreviewSize.x < bestPreviewSize.y;
@@ -136,7 +134,7 @@ final class CameraConfigurationManager {
} else { } else {
previewSizeOnScreen = new Point(bestPreviewSize.y, bestPreviewSize.x); previewSizeOnScreen = new Point(bestPreviewSize.y, bestPreviewSize.x);
} }
Log.i(TAG, "Preview size on screen: " + previewSizeOnScreen); LogUtils.i("Preview size on screen: " + previewSizeOnScreen);
} }
void setDesiredCameraParameters(OpenCamera camera, boolean safeMode) { void setDesiredCameraParameters(OpenCamera camera, boolean safeMode) {
@@ -145,14 +143,14 @@ final class CameraConfigurationManager {
Camera.Parameters parameters = theCamera.getParameters(); Camera.Parameters parameters = theCamera.getParameters();
if (parameters == null) { if (parameters == null) {
Log.w(TAG, "Device error: no camera parameters are available. Proceeding without configuration."); LogUtils.w("Device error: no camera parameters are available. Proceeding without configuration.");
return; return;
} }
Log.i(TAG, "Initial camera parameters: " + parameters.flatten()); LogUtils.i("Initial camera parameters: " + parameters.flatten());
if (safeMode) { if (safeMode) {
Log.w(TAG, "In camera config safe mode -- most settings will not be honored"); LogUtils.w("In camera config safe mode -- most settings will not be honored");
} }
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@@ -199,7 +197,7 @@ final class CameraConfigurationManager {
Camera.Parameters afterParameters = theCamera.getParameters(); Camera.Parameters afterParameters = theCamera.getParameters();
Camera.Size afterSize = afterParameters.getPreviewSize(); Camera.Size afterSize = afterParameters.getPreviewSize();
if (afterSize != null && (bestPreviewSize.x != afterSize.width || bestPreviewSize.y != afterSize.height)) { if (afterSize != null && (bestPreviewSize.x != afterSize.width || bestPreviewSize.y != afterSize.height)) {
Log.w(TAG, "Camera said it supported preview size " + bestPreviewSize.x + 'x' + bestPreviewSize.y + LogUtils.w("Camera said it supported preview size " + bestPreviewSize.x + 'x' + bestPreviewSize.y +
", but after setting it, preview size is " + afterSize.width + 'x' + afterSize.height); ", but after setting it, preview size is " + afterSize.width + 'x' + afterSize.height);
bestPreviewSize.x = afterSize.width; bestPreviewSize.x = afterSize.width;
bestPreviewSize.y = afterSize.height; bestPreviewSize.y = afterSize.height;

View File

@@ -20,12 +20,12 @@ import android.graphics.Point;
import android.graphics.Rect; import android.graphics.Rect;
import android.hardware.Camera; import android.hardware.Camera;
import android.os.Build; import android.os.Build;
import android.util.Log;
import com.king.zxing.util.LogUtils;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@@ -38,8 +38,6 @@ import java.util.regex.Pattern;
@SuppressWarnings("deprecation") // camera APIs @SuppressWarnings("deprecation") // camera APIs
public final class CameraConfigurationUtils { public final class CameraConfigurationUtils {
private static final String TAG = "CameraConfiguration";
private static final Pattern SEMICOLON = Pattern.compile(";"); private static final Pattern SEMICOLON = Pattern.compile(";");
private static final int MIN_PREVIEW_PIXELS = 480 * 320; // normal screen private static final int MIN_PREVIEW_PIXELS = 480 * 320; // normal screen
@@ -81,7 +79,7 @@ public final class CameraConfigurationUtils {
} }
if (focusMode != null) { if (focusMode != null) {
if (focusMode.equals(parameters.getFocusMode())) { if (focusMode.equals(parameters.getFocusMode())) {
Log.i(TAG, "Focus mode already set to " + focusMode); LogUtils.d( "Focus mode already set to " + focusMode);
} else { } else {
parameters.setFocusMode(focusMode); parameters.setFocusMode(focusMode);
} }
@@ -103,9 +101,9 @@ public final class CameraConfigurationUtils {
} }
if (flashMode != null) { if (flashMode != null) {
if (flashMode.equals(parameters.getFlashMode())) { if (flashMode.equals(parameters.getFlashMode())) {
Log.i(TAG, "Flash mode already set to " + flashMode); LogUtils.d( "Flash mode already set to " + flashMode);
} else { } else {
Log.i(TAG, "Setting flash mode to " + flashMode); LogUtils.d( "Setting flash mode to " + flashMode);
parameters.setFlashMode(flashMode); parameters.setFlashMode(flashMode);
} }
} }
@@ -123,13 +121,13 @@ public final class CameraConfigurationUtils {
// Clamp value: // Clamp value:
compensationSteps = Math.max(Math.min(compensationSteps, maxExposure), minExposure); compensationSteps = Math.max(Math.min(compensationSteps, maxExposure), minExposure);
if (parameters.getExposureCompensation() == compensationSteps) { if (parameters.getExposureCompensation() == compensationSteps) {
Log.i(TAG, "Exposure compensation already set to " + compensationSteps + " / " + actualCompensation); LogUtils.d( "Exposure compensation already set to " + compensationSteps + " / " + actualCompensation);
} else { } else {
Log.i(TAG, "Setting exposure compensation to " + compensationSteps + " / " + actualCompensation); LogUtils.d( "Setting exposure compensation to " + compensationSteps + " / " + actualCompensation);
parameters.setExposureCompensation(compensationSteps); parameters.setExposureCompensation(compensationSteps);
} }
} else { } else {
Log.i(TAG, "Camera does not support exposure compensation"); LogUtils.d( "Camera does not support exposure compensation");
} }
} }
@@ -139,7 +137,7 @@ public final class CameraConfigurationUtils {
public static void setBestPreviewFPS(Camera.Parameters parameters, int minFPS, int maxFPS) { public static void setBestPreviewFPS(Camera.Parameters parameters, int minFPS, int maxFPS) {
List<int[]> supportedPreviewFpsRanges = parameters.getSupportedPreviewFpsRange(); List<int[]> supportedPreviewFpsRanges = parameters.getSupportedPreviewFpsRange();
Log.i(TAG, "Supported FPS ranges: " + toString(supportedPreviewFpsRanges)); LogUtils.d( "Supported FPS ranges: " + toString(supportedPreviewFpsRanges));
if (supportedPreviewFpsRanges != null && !supportedPreviewFpsRanges.isEmpty()) { if (supportedPreviewFpsRanges != null && !supportedPreviewFpsRanges.isEmpty()) {
int[] suitableFPSRange = null; int[] suitableFPSRange = null;
for (int[] fpsRange : supportedPreviewFpsRanges) { for (int[] fpsRange : supportedPreviewFpsRanges) {
@@ -151,14 +149,14 @@ public final class CameraConfigurationUtils {
} }
} }
if (suitableFPSRange == null) { if (suitableFPSRange == null) {
Log.i(TAG, "No suitable FPS range?"); LogUtils.d( "No suitable FPS range?");
} else { } else {
int[] currentFpsRange = new int[2]; int[] currentFpsRange = new int[2];
parameters.getPreviewFpsRange(currentFpsRange); parameters.getPreviewFpsRange(currentFpsRange);
if (Arrays.equals(currentFpsRange, suitableFPSRange)) { if (Arrays.equals(currentFpsRange, suitableFPSRange)) {
Log.i(TAG, "FPS range already set to " + Arrays.toString(suitableFPSRange)); LogUtils.d( "FPS range already set to " + Arrays.toString(suitableFPSRange));
} else { } else {
Log.i(TAG, "Setting FPS range to " + Arrays.toString(suitableFPSRange)); LogUtils.d( "Setting FPS range to " + Arrays.toString(suitableFPSRange));
parameters.setPreviewFpsRange(suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX], parameters.setPreviewFpsRange(suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]); suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
} }
@@ -168,23 +166,23 @@ public final class CameraConfigurationUtils {
public static void setFocusArea(Camera.Parameters parameters) { public static void setFocusArea(Camera.Parameters parameters) {
if (parameters.getMaxNumFocusAreas() > 0) { if (parameters.getMaxNumFocusAreas() > 0) {
Log.i(TAG, "Old focus areas: " + toString(parameters.getFocusAreas())); LogUtils.d( "Old focus areas: " + toString(parameters.getFocusAreas()));
List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000); List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
Log.i(TAG, "Setting focus area to : " + toString(middleArea)); LogUtils.d( "Setting focus area to : " + toString(middleArea));
parameters.setFocusAreas(middleArea); parameters.setFocusAreas(middleArea);
} else { } else {
Log.i(TAG, "Device does not support focus areas"); LogUtils.d( "Device does not support focus areas");
} }
} }
public static void setMetering(Camera.Parameters parameters) { public static void setMetering(Camera.Parameters parameters) {
if (parameters.getMaxNumMeteringAreas() > 0) { if (parameters.getMaxNumMeteringAreas() > 0) {
Log.i(TAG, "Old metering areas: " + parameters.getMeteringAreas()); LogUtils.d( "Old metering areas: " + parameters.getMeteringAreas());
List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000); List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
Log.i(TAG, "Setting metering area to : " + toString(middleArea)); LogUtils.d( "Setting metering area to : " + toString(middleArea));
parameters.setMeteringAreas(middleArea); parameters.setMeteringAreas(middleArea);
} else { } else {
Log.i(TAG, "Device does not support metering areas"); LogUtils.d( "Device does not support metering areas");
} }
} }
@@ -196,19 +194,19 @@ public final class CameraConfigurationUtils {
public static void setVideoStabilization(Camera.Parameters parameters) { public static void setVideoStabilization(Camera.Parameters parameters) {
if (parameters.isVideoStabilizationSupported()) { if (parameters.isVideoStabilizationSupported()) {
if (parameters.getVideoStabilization()) { if (parameters.getVideoStabilization()) {
Log.i(TAG, "Video stabilization already enabled"); LogUtils.d( "Video stabilization already enabled");
} else { } else {
Log.i(TAG, "Enabling video stabilization..."); LogUtils.d( "Enabling video stabilization...");
parameters.setVideoStabilization(true); parameters.setVideoStabilization(true);
} }
} else { } else {
Log.i(TAG, "This device does not support video stabilization"); LogUtils.d( "This device does not support video stabilization");
} }
} }
public static void setBarcodeSceneMode(Camera.Parameters parameters) { public static void setBarcodeSceneMode(Camera.Parameters parameters) {
if (Camera.Parameters.SCENE_MODE_BARCODE.equals(parameters.getSceneMode())) { if (Camera.Parameters.SCENE_MODE_BARCODE.equals(parameters.getSceneMode())) {
Log.i(TAG, "Barcode scene mode already set"); LogUtils.d( "Barcode scene mode already set");
return; return;
} }
String sceneMode = findSettableValue("scene mode", String sceneMode = findSettableValue("scene mode",
@@ -226,22 +224,22 @@ public final class CameraConfigurationUtils {
return; return;
} }
if (parameters.getZoom() == zoom) { if (parameters.getZoom() == zoom) {
Log.i(TAG, "Zoom is already set to " + zoom); LogUtils.d( "Zoom is already set to " + zoom);
} else { } else {
Log.i(TAG, "Setting zoom to " + zoom); LogUtils.d( "Setting zoom to " + zoom);
parameters.setZoom(zoom); parameters.setZoom(zoom);
} }
} else { } else {
Log.i(TAG, "Zoom is not supported"); LogUtils.d( "Zoom is not supported");
} }
} }
private static Integer indexOfClosestZoom(Camera.Parameters parameters, double targetZoomRatio) { private static Integer indexOfClosestZoom(Camera.Parameters parameters, double targetZoomRatio) {
List<Integer> ratios = parameters.getZoomRatios(); List<Integer> ratios = parameters.getZoomRatios();
Log.i(TAG, "Zoom ratios: " + ratios); LogUtils.d( "Zoom ratios: " + ratios);
int maxZoom = parameters.getMaxZoom(); int maxZoom = parameters.getMaxZoom();
if (ratios == null || ratios.isEmpty() || ratios.size() != maxZoom + 1) { if (ratios == null || ratios.isEmpty() || ratios.size() != maxZoom + 1) {
Log.w(TAG, "Invalid zoom ratios!"); LogUtils.w( "Invalid zoom ratios!");
return null; return null;
} }
double target100 = 100.0 * targetZoomRatio; double target100 = 100.0 * targetZoomRatio;
@@ -254,13 +252,13 @@ public final class CameraConfigurationUtils {
closestIndex = i; closestIndex = i;
} }
} }
Log.i(TAG, "Chose zoom ratio of " + (ratios.get(closestIndex) / 100.0)); LogUtils.d( "Chose zoom ratio of " + (ratios.get(closestIndex) / 100.0));
return closestIndex; return closestIndex;
} }
public static void setInvertColor(Camera.Parameters parameters) { public static void setInvertColor(Camera.Parameters parameters) {
if (Camera.Parameters.EFFECT_NEGATIVE.equals(parameters.getColorEffect())) { if (Camera.Parameters.EFFECT_NEGATIVE.equals(parameters.getColorEffect())) {
Log.i(TAG, "Negative effect already set"); LogUtils.d( "Negative effect already set");
return; return;
} }
String colorMode = findSettableValue("color effect", String colorMode = findSettableValue("color effect",
@@ -275,7 +273,7 @@ public final class CameraConfigurationUtils {
List<Camera.Size> rawSupportedSizes = parameters.getSupportedPreviewSizes(); List<Camera.Size> rawSupportedSizes = parameters.getSupportedPreviewSizes();
if (rawSupportedSizes == null) { if (rawSupportedSizes == null) {
Log.w(TAG, "Device returned no supported preview sizes; using default"); LogUtils.w( "Device returned no supported preview sizes; using default");
Camera.Size defaultSize = parameters.getPreviewSize(); Camera.Size defaultSize = parameters.getPreviewSize();
if (defaultSize == null) { if (defaultSize == null) {
throw new IllegalStateException("Parameters contained no preview size!"); throw new IllegalStateException("Parameters contained no preview size!");
@@ -284,12 +282,12 @@ public final class CameraConfigurationUtils {
} }
if (Log.isLoggable(TAG, Log.INFO)) { if (LogUtils.isShowLog()) {
StringBuilder previewSizesString = new StringBuilder(); StringBuilder previewSizesString = new StringBuilder();
for (Camera.Size size : rawSupportedSizes) { for (Camera.Size size : rawSupportedSizes) {
previewSizesString.append(size.width).append('x').append(size.height).append(' '); previewSizesString.append(size.width).append('x').append(size.height).append(' ');
} }
Log.i(TAG, "Supported preview sizes: " + previewSizesString); LogUtils.d( "Supported preview sizes: " + previewSizesString);
} }
double screenAspectRatio; double screenAspectRatio;
@@ -298,7 +296,7 @@ public final class CameraConfigurationUtils {
}else{ }else{
screenAspectRatio = screenResolution.y / (double) screenResolution.x; screenAspectRatio = screenResolution.y / (double) screenResolution.x;
} }
Log.i(TAG, "screenAspectRatio: " + screenAspectRatio); LogUtils.d( "screenAspectRatio: " + screenAspectRatio);
// Find a suitable size, with max resolution // Find a suitable size, with max resolution
int maxResolution = 0; int maxResolution = 0;
@@ -314,19 +312,19 @@ public final class CameraConfigurationUtils {
boolean isCandidatePortrait = realWidth < realHeight; boolean isCandidatePortrait = realWidth < realHeight;
int maybeFlippedWidth = isCandidatePortrait ? realWidth: realHeight ; int maybeFlippedWidth = isCandidatePortrait ? realWidth: realHeight ;
int maybeFlippedHeight = isCandidatePortrait ? realHeight : realWidth; int maybeFlippedHeight = isCandidatePortrait ? realHeight : realWidth;
Log.i(TAG, String.format("maybeFlipped:%d * %d",maybeFlippedWidth,maybeFlippedHeight)); LogUtils.d( String.format("maybeFlipped:%d * %d",maybeFlippedWidth,maybeFlippedHeight));
double aspectRatio = maybeFlippedWidth / (double) maybeFlippedHeight; double aspectRatio = maybeFlippedWidth / (double) maybeFlippedHeight;
Log.i(TAG, "aspectRatio: " + aspectRatio); LogUtils.d( "aspectRatio: " + aspectRatio);
double distortion = Math.abs(aspectRatio - screenAspectRatio); double distortion = Math.abs(aspectRatio - screenAspectRatio);
Log.i(TAG, "distortion: " + distortion); LogUtils.d( "distortion: " + distortion);
if (distortion > MAX_ASPECT_DISTORTION) { if (distortion > MAX_ASPECT_DISTORTION) {
continue; continue;
} }
if (maybeFlippedWidth == screenResolution.x && maybeFlippedHeight == screenResolution.y) { if (maybeFlippedWidth == screenResolution.x && maybeFlippedHeight == screenResolution.y) {
Point exactPoint = new Point(realWidth, realHeight); Point exactPoint = new Point(realWidth, realHeight);
Log.i(TAG, "Found preview size exactly matching screen size: " + exactPoint); LogUtils.d( "Found preview size exactly matching screen size: " + exactPoint);
return exactPoint; return exactPoint;
} }
@@ -342,7 +340,7 @@ public final class CameraConfigurationUtils {
// the CPU is much more powerful. // the CPU is much more powerful.
if (maxResPreviewSize != null) { if (maxResPreviewSize != null) {
Point largestSize = new Point(maxResPreviewSize.width, maxResPreviewSize.height); Point largestSize = new Point(maxResPreviewSize.width, maxResPreviewSize.height);
Log.i(TAG, "Using largest suitable preview size: " + largestSize); LogUtils.d( "Using largest suitable preview size: " + largestSize);
return largestSize; return largestSize;
} }
@@ -352,24 +350,24 @@ public final class CameraConfigurationUtils {
throw new IllegalStateException("Parameters contained no preview size!"); throw new IllegalStateException("Parameters contained no preview size!");
} }
Point defaultSize = new Point(defaultPreview.width, defaultPreview.height); Point defaultSize = new Point(defaultPreview.width, defaultPreview.height);
Log.i(TAG, "No suitable preview sizes, using default: " + defaultSize); LogUtils.d( "No suitable preview sizes, using default: " + defaultSize);
return defaultSize; return defaultSize;
} }
private static String findSettableValue(String name, private static String findSettableValue(String name,
Collection<String> supportedValues, Collection<String> supportedValues,
String... desiredValues) { String... desiredValues) {
Log.i(TAG, "Requesting " + name + " value from among: " + Arrays.toString(desiredValues)); LogUtils.d( "Requesting " + name + " value from among: " + Arrays.toString(desiredValues));
Log.i(TAG, "Supported " + name + " values: " + supportedValues); LogUtils.d( "Supported " + name + " values: " + supportedValues);
if (supportedValues != null) { if (supportedValues != null) {
for (String desiredValue : desiredValues) { for (String desiredValue : desiredValues) {
if (supportedValues.contains(desiredValue)) { if (supportedValues.contains(desiredValue)) {
Log.i(TAG, "Can set " + name + " to: " + desiredValue); LogUtils.d( "Can set " + name + " to: " + desiredValue);
return desiredValue; return desiredValue;
} }
} }
} }
Log.i(TAG, "No supported values match"); LogUtils.d( "No supported values match");
return null; return null;
} }

View File

@@ -22,12 +22,12 @@ import android.graphics.Point;
import android.graphics.Rect; import android.graphics.Rect;
import android.hardware.Camera; import android.hardware.Camera;
import android.os.Handler; import android.os.Handler;
import android.util.Log;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
import com.google.zxing.PlanarYUVLuminanceSource; import com.google.zxing.PlanarYUVLuminanceSource;
import com.king.zxing.camera.open.OpenCamera; import com.king.zxing.camera.open.OpenCamera;
import com.king.zxing.camera.open.OpenCameraInterface; import com.king.zxing.camera.open.OpenCameraInterface;
import com.king.zxing.util.LogUtils;
import java.io.IOException; import java.io.IOException;
@@ -43,8 +43,6 @@ import androidx.annotation.FloatRange;
@SuppressWarnings("deprecation") // camera APIs @SuppressWarnings("deprecation") // camera APIs
public final class CameraManager { public final class CameraManager {
private static final String TAG = CameraManager.class.getSimpleName();
private static final int MIN_FRAME_WIDTH = 240; private static final int MIN_FRAME_WIDTH = 240;
private static final int MIN_FRAME_HEIGHT = 240; private static final int MIN_FRAME_HEIGHT = 240;
private static final int MAX_FRAME_WIDTH = 1200; // = 5/8 * 1920 private static final int MAX_FRAME_WIDTH = 1200; // = 5/8 * 1920
@@ -117,8 +115,8 @@ public final class CameraManager {
configManager.setDesiredCameraParameters(theCamera, false); configManager.setDesiredCameraParameters(theCamera, false);
} catch (RuntimeException re) { } catch (RuntimeException re) {
// Driver failed // Driver failed
Log.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters"); LogUtils.w("Camera rejected parameters. Setting only minimal safe-mode parameters");
Log.i(TAG, "Resetting to saved camera params: " + parametersFlattened); LogUtils.i( "Resetting to saved camera params: " + parametersFlattened);
// Reset: // Reset:
if (parametersFlattened != null) { if (parametersFlattened != null) {
parameters = cameraObject.getParameters(); parameters = cameraObject.getParameters();
@@ -128,7 +126,7 @@ public final class CameraManager {
configManager.setDesiredCameraParameters(theCamera, true); configManager.setDesiredCameraParameters(theCamera, true);
} catch (RuntimeException re2) { } catch (RuntimeException re2) {
// Well, darn. Give up // Well, darn. Give up
Log.w(TAG, "Camera rejected even safe-mode parameters! No configuration"); LogUtils.w("Camera rejected even safe-mode parameters! No configuration");
} }
} }
} }
@@ -360,7 +358,7 @@ public final class CameraManager {
int leftOffset = (screenResolution.x - width) / 2; int leftOffset = (screenResolution.x - width) / 2;
int topOffset = (screenResolution.y - height) / 2; int topOffset = (screenResolution.y - height) / 2;
framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height); framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);
Log.d(TAG, "Calculated manual framing rect: " + framingRect); LogUtils.d( "Calculated manual framing rect: " + framingRect);
framingRectInPreview = null; framingRectInPreview = null;
} else { } else {
requestedFramingRectWidth = width; requestedFramingRectWidth = width;

View File

@@ -21,7 +21,8 @@ import android.graphics.Point;
import android.hardware.Camera; import android.hardware.Camera;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.util.Log;
import com.king.zxing.util.LogUtils;
@SuppressWarnings("deprecation") // camera APIs @SuppressWarnings("deprecation") // camera APIs
final class PreviewCallback implements Camera.PreviewCallback { final class PreviewCallback implements Camera.PreviewCallback {
@@ -51,7 +52,7 @@ final class PreviewCallback implements Camera.PreviewCallback {
message.sendToTarget(); message.sendToTarget();
previewHandler = null; previewHandler = null;
} else { } else {
Log.d(TAG, "Got preview callback, but no handler or resolution available"); LogUtils.d("Got preview callback, but no handler or resolution available");
} }
} }

View File

@@ -18,7 +18,8 @@ package com.king.zxing.camera.open;
import android.hardware.Camera; import android.hardware.Camera;
import android.util.Log;
import com.king.zxing.util.LogUtils;
/** /**
* Abstraction over the {@link Camera} API that helps open them and return their metadata. * Abstraction over the {@link Camera} API that helps open them and return their metadata.
@@ -26,8 +27,6 @@ import android.util.Log;
@SuppressWarnings("deprecation") // camera APIs @SuppressWarnings("deprecation") // camera APIs
public final class OpenCameraInterface { public final class OpenCameraInterface {
private static final String TAG = OpenCameraInterface.class.getName();
/** /**
* For {@link #open(int)}, means no preference for which camera to open. * For {@link #open(int)}, means no preference for which camera to open.
*/ */
@@ -48,11 +47,11 @@ public final class OpenCameraInterface {
int numCameras = Camera.getNumberOfCameras(); int numCameras = Camera.getNumberOfCameras();
if (numCameras == 0) { if (numCameras == 0) {
Log.w(TAG, "No cameras!"); LogUtils.w("No cameras!");
return null; return null;
} }
if (cameraId >= numCameras) { if (cameraId >= numCameras) {
Log.w(TAG, "Requested camera does not exist: " + cameraId); LogUtils.w("Requested camera does not exist: " + cameraId);
return null; return null;
} }
@@ -67,12 +66,12 @@ public final class OpenCameraInterface {
cameraId++; cameraId++;
} }
if (cameraId == numCameras) { if (cameraId == numCameras) {
Log.i(TAG, "No camera facing " + CameraFacing.BACK + "; returning camera #0"); LogUtils.i("No camera facing " + CameraFacing.BACK + "; returning camera #0");
cameraId = 0; cameraId = 0;
} }
} }
Log.i(TAG, "Opening camera #" + cameraId); LogUtils.i("Opening camera #" + cameraId);
Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
Camera.getCameraInfo(cameraId, cameraInfo); Camera.getCameraInfo(cameraId, cameraInfo);
Camera camera = Camera.open(cameraId); Camera camera = Camera.open(cameraId);

View File

@@ -20,9 +20,13 @@ import android.graphics.BitmapFactory;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.text.TextPaint; import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.ColorInt;
import androidx.annotation.FloatRange;
import androidx.annotation.NonNull;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap; import com.google.zxing.BinaryBitmap;
@@ -30,7 +34,6 @@ import com.google.zxing.DecodeHintType;
import com.google.zxing.EncodeHintType; import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatReader; import com.google.zxing.MultiFormatReader;
import com.google.zxing.MultiFormatWriter; import com.google.zxing.MultiFormatWriter;
import com.google.zxing.NotFoundException;
import com.google.zxing.RGBLuminanceSource; import com.google.zxing.RGBLuminanceSource;
import com.google.zxing.Result; import com.google.zxing.Result;
import com.google.zxing.WriterException; import com.google.zxing.WriterException;
@@ -40,23 +43,21 @@ import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.QRCodeReader; import com.google.zxing.qrcode.QRCodeReader;
import com.google.zxing.qrcode.QRCodeWriter; import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.king.zxing.CaptureHelper;
import com.king.zxing.DecodeFormatManager; import com.king.zxing.DecodeFormatManager;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Vector; import java.util.Vector;
import androidx.annotation.ColorInt;
import androidx.annotation.FloatRange;
import androidx.annotation.NonNull;
/** /**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a> * @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/ */
public final class CodeUtils { public final class CodeUtils {
public static final int DEFAULT_REQ_WIDTH = 450;
public static final int DEFAULT_REQ_HEIGHT = 800;
private CodeUtils(){ private CodeUtils(){
throw new AssertionError(); throw new AssertionError();
} }
@@ -140,7 +141,7 @@ public final class CodeUtils {
//容错级别 //容错级别
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
//设置空白边距的宽度 //设置空白边距的宽度
hints.put(EncodeHintType.MARGIN, 1); //default is 4 hints.put(EncodeHintType.MARGIN, 1); //default is 1
return createQRCode(content,heightPix,logo,ratio,hints,codeColor); return createQRCode(content,heightPix,logo,ratio,hints,codeColor);
} }
@@ -186,7 +187,7 @@ public final class CodeUtils {
return bitmap; return bitmap;
} catch (WriterException e) { } catch (WriterException e) {
Log.w(CaptureHelper.TAG,e.getMessage()); LogUtils.w(e.getMessage());
} }
return null; return null;
@@ -234,7 +235,7 @@ public final class CodeUtils {
canvas.restore(); canvas.restore();
} catch (Exception e) { } catch (Exception e) {
bitmap = null; bitmap = null;
Log.w(CaptureHelper.TAG,e.getMessage()); LogUtils.w(e.getMessage());
} }
return bitmap; return bitmap;
@@ -273,11 +274,23 @@ public final class CodeUtils {
* @return * @return
*/ */
public static Result parseQRCodeResult(String bitmapPath, Map<DecodeHintType,?> hints){ public static Result parseQRCodeResult(String bitmapPath, Map<DecodeHintType,?> hints){
return parseQRCodeResult(bitmapPath,DEFAULT_REQ_WIDTH,DEFAULT_REQ_HEIGHT,hints);
}
/**
* 解析二维码图片
* @param bitmapPath
* @param reqWidth
* @param reqHeight
* @param hints
* @return
*/
public static Result parseQRCodeResult(String bitmapPath,int reqWidth,int reqHeight,Map<DecodeHintType,?> hints){
Result result = null; Result result = null;
try{ try{
QRCodeReader reader = new QRCodeReader(); QRCodeReader reader = new QRCodeReader();
RGBLuminanceSource source = getRGBLuminanceSource(compressBitmap(bitmapPath)); RGBLuminanceSource source = getRGBLuminanceSource(compressBitmap(bitmapPath,reqWidth,reqHeight));
if (source != null) { if (source != null) {
boolean isReDecode; boolean isReDecode;
@@ -322,7 +335,7 @@ public final class CodeUtils {
} }
}catch (Exception e){ }catch (Exception e){
Log.w(CaptureHelper.TAG,e.getMessage()); LogUtils.w(e.getMessage());
} }
return result; return result;
@@ -370,12 +383,24 @@ public final class CodeUtils {
* @return * @return
*/ */
public static Result parseCodeResult(String bitmapPath, Map<DecodeHintType,Object> hints){ public static Result parseCodeResult(String bitmapPath, Map<DecodeHintType,Object> hints){
return parseCodeResult(bitmapPath,DEFAULT_REQ_WIDTH,DEFAULT_REQ_HEIGHT,hints);
}
/**
* 解析一维码/二维码图片
* @param bitmapPath
* @param reqWidth
* @param reqHeight
* @param hints 解析编码类型
* @return
*/
public static Result parseCodeResult(String bitmapPath,int reqWidth,int reqHeight, Map<DecodeHintType,Object> hints){
Result result = null; Result result = null;
try{ try{
MultiFormatReader reader = new MultiFormatReader(); MultiFormatReader reader = new MultiFormatReader();
reader.setHints(hints); reader.setHints(hints);
RGBLuminanceSource source = getRGBLuminanceSource(compressBitmap(bitmapPath)); RGBLuminanceSource source = getRGBLuminanceSource(compressBitmap(bitmapPath,reqWidth,reqHeight));
if (source != null) { if (source != null) {
boolean isReDecode; boolean isReDecode;
@@ -420,7 +445,7 @@ public final class CodeUtils {
} }
}catch (Exception e){ }catch (Exception e){
Log.w(CaptureHelper.TAG,e.getMessage()); LogUtils.w(e.getMessage());
} }
return result; return result;
@@ -433,31 +458,33 @@ public final class CodeUtils {
* @param path * @param path
* @return * @return
*/ */
private static Bitmap compressBitmap(String path){ private static Bitmap compressBitmap(String path,int reqWidth,int reqHeight){
BitmapFactory.Options newOpts = new BitmapFactory.Options(); BitmapFactory.Options newOpts = new BitmapFactory.Options();
// 开始读入图片此时把options.inJustDecodeBounds 设回true了 // 开始读入图片此时把options.inJustDecodeBounds 设回true了
newOpts.inJustDecodeBounds = true;//获取原始图片大小 newOpts.inJustDecodeBounds = true;//获取原始图片大小
BitmapFactory.decodeFile(path, newOpts);// 此时返回bm为空 BitmapFactory.decodeFile(path, newOpts);// 此时返回bm为空
int w = newOpts.outWidth; float width = newOpts.outWidth;
int h = newOpts.outHeight; float height = newOpts.outHeight;
float width = 800f;
float height = 480f;
// 缩放比,由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可 // 缩放比,由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int be = 1;// be=1表示不缩放 int wSize = 1;// wSize=1表示不缩放
if (w > h && w > width) {// 如果宽度大的话根据宽度固定大小缩放 if (width > reqWidth) {// 如果宽度大的话根据宽度固定大小缩放
be = (int) (newOpts.outWidth / width); wSize = (int) (width / reqWidth);
} else if (w < h && h > height) {// 如果高度高的话根据宽度固定大小缩放
be = (int) (newOpts.outHeight / height);
} }
if (be <= 0) int hSize = 1;// wSize=1表示不缩放
be = 1; if (height > reqHeight) {// 如果高度高的话根据宽度固定大小缩放
newOpts.inSampleSize = be;// 设置缩放比例 hSize = (int) (height / reqHeight);
}
int size = Math.max(wSize,hSize);
if (size <= 0)
size = 1;
newOpts.inSampleSize = size;// 设置缩放比例
// 重新读入图片注意此时已经把options.inJustDecodeBounds 设回false了 // 重新读入图片注意此时已经把options.inJustDecodeBounds 设回false了
newOpts.inJustDecodeBounds = false; newOpts.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(path, newOpts); return BitmapFactory.decodeFile(path, newOpts);
} }
/** /**
* 获取RGBLuminanceSource * 获取RGBLuminanceSource
* @param bitmap * @param bitmap
@@ -610,7 +637,7 @@ public final class CodeUtils {
} }
return bitmap; return bitmap;
} catch (WriterException e) { } catch (WriterException e) {
Log.w(CaptureHelper.TAG,e.getMessage()); LogUtils.w(e.getMessage());
} }
return null; return null;
} }
@@ -623,7 +650,7 @@ public final class CodeUtils {
* @param textColor * @param textColor
* @return * @return
*/ */
private static Bitmap addCode(Bitmap src,String code,int textSize,@ColorInt int textColor,int offset) { private static Bitmap addCode(Bitmap src, String code, int textSize, @ColorInt int textColor, int offset) {
if (src == null) { if (src == null) {
return null; return null;
} }
@@ -653,7 +680,7 @@ public final class CodeUtils {
canvas.restore(); canvas.restore();
} catch (Exception e) { } catch (Exception e) {
bitmap = null; bitmap = null;
Log.w(CaptureHelper.TAG,e.getMessage()); LogUtils.w(e.getMessage());
} }
return bitmap; return bitmap;

View File

@@ -0,0 +1,316 @@
/*
Copyright © 2015, 2016 Jenly Yu <a href="mailto:jenly1314@gmail.com">Jenly</a>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.king.zxing.util;
import android.util.Log;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
public class LogUtils {
public static final String TAG = "ZXingLite";
public static final String COLON = ":";
public static final String VERTICAL = "|";
/** 是否显示Log日志 */
private static boolean isShowLog = true;
/** Log日志优先权 */
private static int priority = 1;
/**
* Priority constant for the println method;use System.out.println
*/
public static final int PRINTLN = 1;
/**
* Priority constant for the println method; use Log.v.
*/
public static final int VERBOSE = 2;
/**
* Priority constant for the println method; use Log.d.
*/
public static final int DEBUG = 3;
/**
* Priority constant for the println method; use Log.i.
*/
public static final int INFO = 4;
/**
* Priority constant for the println method; use Log.w.
*/
public static final int WARN = 5;
/**
* Priority constant for the println method; use Log.e.
*/
public static final int ERROR = 6;
/**
* Priority constant for the println method.use Log.wtf.
*/
public static final int ASSERT = 7;
public static final String TAG_FORMAT = "%s.%s(L:%d)";
private LogUtils(){
throw new AssertionError();
}
public static void setShowLog(boolean isShowLog) {
LogUtils.isShowLog = isShowLog;
}
public static boolean isShowLog() {
return isShowLog;
}
public static int getPriority() {
return priority;
}
public static void setPriority(int priority) {
LogUtils.priority = priority;
}
/**
* 根据堆栈生成TAG
* @return TAG|className.methodName(L:lineNumber)
*/
private static String generateTag(StackTraceElement caller) {
String tag = TAG_FORMAT;
String callerClazzName = caller.getClassName();
callerClazzName = callerClazzName.substring(callerClazzName.lastIndexOf(".") + 1);
tag = String.format(tag,new Object[] { callerClazzName, caller.getMethodName(),Integer.valueOf(caller.getLineNumber()) });
return new StringBuilder().append(TAG).append(VERTICAL).append(tag).toString();
}
/**
* 获取堆栈
* @param n
* n=0 VMStack
* n=1 Thread
* n=3 CurrentStack
* n=4 CallerStack
* ...
* @return
*/
public static StackTraceElement getStackTraceElement(int n) {
return Thread.currentThread().getStackTrace()[n];
}
/**
* 获取调用方的堆栈TAG
* @return
*/
private static String getCallerStackLogTag(){
return generateTag(getStackTraceElement(5));
}
/**
*
* @param t
* @return
*/
private static String getStackTraceString(Throwable t){
return Log.getStackTraceString(t);
}
// -----------------------------------Log.v
/**
* Log.v
* @param msg
*/
public static void v(String msg) {
if (isShowLog && priority <= VERBOSE)
Log.v(getCallerStackLogTag(), String.valueOf(msg));
}
public static void v(Throwable t) {
if (isShowLog && priority <= VERBOSE)
Log.v(getCallerStackLogTag(), getStackTraceString(t));
}
public static void v(String msg,Throwable t) {
if (isShowLog && priority <= VERBOSE)
Log.v(getCallerStackLogTag(), String.valueOf(msg), t);
}
// -----------------------------------Log.d
/**
* Log.d
* @param msg
*/
public static void d(String msg) {
if (isShowLog && priority <= DEBUG)
Log.d(getCallerStackLogTag(), String.valueOf(msg));
}
public static void d(Throwable t) {
if (isShowLog && priority <= DEBUG)
Log.d(getCallerStackLogTag(), getStackTraceString(t));
}
public static void d(String msg,Throwable t) {
if (isShowLog && priority <= DEBUG)
Log.d(getCallerStackLogTag(), String.valueOf(msg), t);
}
// -----------------------------------Log.i
/**
* Log.i
* @param msg
*/
public static void i(String msg) {
if (isShowLog && priority <= INFO)
Log.i(getCallerStackLogTag(), String.valueOf(msg));
}
public static void i(Throwable t) {
if (isShowLog && priority <= INFO)
Log.i(getCallerStackLogTag(), getStackTraceString(t));
}
public static void i(String msg,Throwable t) {
if (isShowLog && priority <= INFO)
Log.i(getCallerStackLogTag(), String.valueOf(msg), t);
}
// -----------------------------------Log.w
/**
* Log.w
* @param msg
*/
public static void w(String msg) {
if (isShowLog && priority <= WARN)
Log.w(getCallerStackLogTag(), String.valueOf(msg));
}
public static void w(Throwable t) {
if (isShowLog && priority <= WARN)
Log.w(getCallerStackLogTag(), getStackTraceString(t));
}
public static void w(String msg,Throwable t) {
if (isShowLog && priority <= WARN)
Log.w(getCallerStackLogTag(), String.valueOf(msg), t);
}
// -----------------------------------Log.e
/**
* Log.e
* @param msg
*/
public static void e(String msg) {
if (isShowLog && priority <= ERROR)
Log.e(getCallerStackLogTag(), String.valueOf(msg));
}
public static void e(Throwable t) {
if (isShowLog && priority <= ERROR)
Log.e(getCallerStackLogTag(), getStackTraceString(t));
}
public static void e(String msg,Throwable t) {
if (isShowLog && priority <= ERROR)
Log.e(getCallerStackLogTag(), String.valueOf(msg), t);
}
// -----------------------------------Log.wtf
/**
* Log.wtf
* @param msg
*/
public static void wtf(String msg) {
if (isShowLog && priority <= ASSERT)
Log.wtf(getCallerStackLogTag(), String.valueOf(msg));
}
public static void wtf(Throwable t) {
if (isShowLog && priority <= ASSERT)
Log.wtf(getCallerStackLogTag(), getStackTraceString(t));
}
public static void wtf(String msg,Throwable t) {
if (isShowLog && priority <= ASSERT)
Log.wtf(getCallerStackLogTag(), String.valueOf(msg), t);
}
// -----------------------------------System.out.print
/**
* System.out.print
*
* @param msg
*/
public static void print(String msg) {
if (isShowLog && priority <= PRINTLN)
System.out.print(msg);
}
public static void print(Object obj) {
if (isShowLog && priority <= PRINTLN)
System.out.print(obj);
}
// -----------------------------------System.out.printf
/**
* System.out.printf
*
* @param msg
*/
public static void printf(String msg) {
if (isShowLog && priority <= PRINTLN)
System.out.printf(msg);
}
// -----------------------------------System.out.println
/**
* System.out.println
*
* @param msg
*/
public static void println(String msg) {
if (isShowLog && priority <= PRINTLN)
System.out.println(msg);
}
public static void println(Object obj) {
if (isShowLog && priority <= PRINTLN)
System.out.println(obj);
}
}

View File

@@ -1,7 +1,7 @@
//App //App
def app_version = [:] def app_version = [:]
app_version.versionCode = 22 app_version.versionCode = 24
app_version.versionName = "1.1.7-androidx" app_version.versionName = "1.1.8-androidx"
ext.app_version = app_version ext.app_version = app_version
//build version //build version