28 Commits

Author SHA1 Message Date
Jenly
9b0635a4d4 Update README 2020-12-29 15:26:43 +08:00
Jenly
2771733a9b Update README 2020-12-24 18:16:16 +08:00
Jenly
4d607cf849 fix #86 2020-04-28 22:29:44 +08:00
Jenly
282c3dc39e 优化细节 2020-04-28 22:27:59 +08:00
Jenly
4b8b4e8723 优化细节 2020-04-28 21:08:50 +08:00
Jenly
078d31b2ad 统一日志管理 2020-04-27 21:44:01 +08:00
Jenly
86dac6216b fix#81 2020-03-29 17:21:43 +08:00
jenly1314
d3d98a3e90 Update README 2019-12-30 09:18:31 +08:00
jenly1314
30bc3e3708 发布v1.1.6-androidx 2019-12-27 18:50:44 +08:00
jenly1314
42a5cc926a 支持识别反色码(#66,#69,#72) 2019-12-27 18:11:44 +08:00
jenly1314
0a136a686b 生成条形码/二维码支持自定义颜色 (#73) 2019-12-27 18:10:42 +08:00
jenly1314
6952061597 Update README 2019-12-17 09:10:31 +08:00
jenly1314
1f1f379a6d - 2019-12-16 13:56:19 +08:00
jenly1314
2f4379cd7a 优化Camera初始化相关策略,减少出现卡顿的可能性(#64,#65) 2019-12-16 11:52:28 +08:00
jenly1314
c36ea8eb58 优化细节 2019-12-05 10:46:24 +08:00
jenly1314
b1eecb27e6 增加混淆规则 2019-11-28 16:01:24 +08:00
jenly1314
6054dcccf6 Update README 2019-11-28 16:00:24 +08:00
jenly1314
c74ad11a19 增加混淆规则 2019-11-28 16:00:10 +08:00
jenly1314
22ec947508 增加混淆规则 2019-11-25 10:57:35 +08:00
jenly1314
f528805859 Update README 2019-11-25 10:57:08 +08:00
jenly1314
26d60ae141 Update README 2019-11-18 11:09:21 +08:00
jenly1314
b830b89b5f * 内置手电筒按钮,当光线太暗时,自动显示手电筒 fix(#58)
*  生成二维码时Logo支持自定义大小 fix(#62)
2019-11-15 17:29:37 +08:00
jenly1314
004bd683a1 1、支持真实识别区域比例和识别区域偏移量可配置
2、对外暴露更多可配置参数
2019-09-24 11:49:13 +08:00
jenly1314
db340b3f4d CI 2019-09-24 11:48:56 +08:00
jenly1314
7dab96d448 CI 2019-08-23 09:41:34 +08:00
jenly1314
eb409a37fb CI 2019-08-23 09:38:17 +08:00
jenly1314
61a40d70e7 支持AndroidX对应版本 2019-06-27 18:09:12 +08:00
jenly1314
d85da52e84 支持AndroidX对应版本 2019-06-27 14:03:57 +08:00
44 changed files with 191 additions and 167 deletions

View File

@@ -1,3 +1,4 @@
version: 2
jobs:
build:

View File

@@ -16,8 +16,6 @@ ZXingLite for Android 是ZXing的精简版基于ZXing库优化扫码和生成
>简单如斯,你不试试? Come on~
### [AndroidX version](https://github.com/jenly1314/ZXingLite/tree/androidx)
## Gif 展示
![Image](GIF.gif)
@@ -167,6 +165,7 @@ api 'com.google.zxing:core:3.3.3'
> 4、参照CaptureHelper写一个自定义的扫码帮助类其它步骤同方式3。扩展高级用法谨慎使用
### 其他
需使用JDK8+编译在你项目中的build.gradle的android{}中添加配置:

View File

@@ -9,7 +9,7 @@ android {
targetSdkVersion build_versions.targetSdk
versionCode app_version.versionCode
versionName app_version.versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {

Binary file not shown.

View File

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

View File

@@ -1,13 +1,14 @@
package com.king.zxing.app;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import static org.junit.Assert.assertEquals;
/**
* Instrumented test, which will execute on an Android device.

View File

@@ -1,17 +1,18 @@
package com.king.zxing.app;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
import com.king.zxing.CaptureFragment;
import com.king.zxing.app.util.StatusBarUtils;
import androidx.annotation.IdRes;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
/**
* Fragment扫码
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>

View File

@@ -18,8 +18,6 @@ package com.king.zxing.app;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@@ -27,6 +25,9 @@ import android.widget.TextView;
import com.google.zxing.BarcodeFormat;
import com.king.zxing.util.CodeUtils;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/

View File

@@ -1,11 +1,7 @@
package com.king.zxing.app;
import android.app.Activity;
import android.hardware.Camera;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MotionEvent;
import android.view.SurfaceView;
import android.view.View;
@@ -17,6 +13,10 @@ import com.king.zxing.OnCaptureCallback;
import com.king.zxing.ViewfinderView;
import com.king.zxing.app.util.StatusBarUtils;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
/**
* 自定义扫码当直接使用CaptureActivity
* 自定义扫码,切记自定义扫码需在{@link Activity}或者{@link Fragment}相对应的生命周期里面调用{@link #mCaptureHelper}对应的生命周期

View File

@@ -16,7 +16,6 @@
package com.king.zxing.app;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
@@ -25,6 +24,8 @@ import com.king.zxing.CaptureActivity;
import com.king.zxing.app.util.StatusBarUtils;
import com.king.zxing.camera.FrontLightMode;
import androidx.appcompat.widget.Toolbar;
/**
* 自定义继承CaptureActivity
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>

View File

@@ -16,14 +16,14 @@
package com.king.zxing.app;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
import com.king.zxing.CaptureActivity;
import com.king.zxing.DecodeFormatManager;
import com.king.zxing.app.util.StatusBarUtils;
import androidx.appcompat.widget.Toolbar;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/

View File

@@ -19,9 +19,6 @@ import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
@@ -36,6 +33,9 @@ import com.king.zxing.util.CodeUtils;
import java.util.List;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.app.ActivityOptionsCompat;
import pub.devrel.easypermissions.AfterPermissionGranted;
import pub.devrel.easypermissions.EasyPermissions;

View File

@@ -19,8 +19,6 @@ import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.FloatRange;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
@@ -29,6 +27,9 @@ import android.widget.LinearLayout;
import com.king.zxing.app.R;
import androidx.annotation.FloatRange;
import androidx.appcompat.widget.Toolbar;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/

View File

@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:background="@color/colorPrimary"
android:layout_height="wrap_content"
@@ -27,7 +25,7 @@
android:textColor="@color/white"
android:layout_gravity="center_horizontal"
android:text="@string/app_name"/>
</android.support.v7.widget.Toolbar>
</androidx.appcompat.widget.Toolbar>
<Button
android:id="@+id/btn0"
android:layout_width="match_parent"
@@ -133,4 +131,4 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn6"
style="@style/OnClick"/>
</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -15,4 +15,4 @@
app:layout_constraintTop_toBottomOf="@+id/toolbar"
app:layout_constraintBottom_toBottomOf="parent"/>
</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
@@ -33,4 +33,4 @@
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="160dp" />
<include layout="@layout/toolbar_capture"/>
</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
@@ -32,4 +32,4 @@
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="160dp" />
<include layout="@layout/toolbar_capture"/>
</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/zxl_capture"/>
<include layout="@layout/toolbar_capture"/>
</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
@@ -9,4 +9,4 @@
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp">
<include layout="@layout/top_title_back_bar"/>
</android.support.v7.widget.Toolbar>
</androidx.appcompat.widget.Toolbar>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
@@ -8,4 +8,4 @@
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp">
<include layout="@layout/top_title_back_bar"/>
</android.support.v7.widget.Toolbar>
</androidx.appcompat.widget.Toolbar>

View File

@@ -4,6 +4,7 @@ buildscript {
apply from: 'versions.gradle'
addRepos(repositories)
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.novoda:bintray-release:0.9'

View File

@@ -11,3 +11,5 @@ org.gradle.jvmargs = -Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true

View File

@@ -10,7 +10,7 @@ android {
versionCode app_version.versionCode
versionName app_version.versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {

View File

@@ -1,12 +1,13 @@
package com.king.zxing;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import static org.junit.Assert.*;
/**

View File

@@ -37,6 +37,8 @@ import java.io.IOException;
*/
public final class BeepManager implements MediaPlayer.OnErrorListener, Closeable {
private static final String TAG = BeepManager.class.getSimpleName();
private static final float BEEP_VOLUME = 0.10f;
private static final long VIBRATE_DURATION = 200L;
@@ -105,7 +107,7 @@ public final class BeepManager implements MediaPlayer.OnErrorListener, Closeable
mediaPlayer.prepare();
return mediaPlayer;
} catch (IOException ioe) {
LogUtils.w( ioe);
LogUtils.w(ioe);
mediaPlayer.release();
return null;
}

View File

@@ -16,16 +16,19 @@
package com.king.zxing;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.SurfaceView;
import android.view.View;
import com.king.zxing.camera.CameraManager;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
/**
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
public class CaptureActivity extends AppCompatActivity implements OnCaptureCallback{
public static final String KEY_RESULT = Intents.Scan.RESULT;

View File

@@ -16,9 +16,6 @@
package com.king.zxing;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.SurfaceView;
import android.view.View;
@@ -26,6 +23,10 @@ import android.view.ViewGroup;
import com.king.zxing.camera.CameraManager;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
/**
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/

View File

@@ -22,8 +22,6 @@ import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.RectF;
import android.hardware.Camera;
import android.support.annotation.FloatRange;
import android.support.v4.app.Fragment;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@@ -43,6 +41,12 @@ import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import androidx.annotation.FloatRange;
import androidx.fragment.app.Fragment;
/**
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
/**
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
@@ -345,7 +349,7 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
captureHandler.setSupportLuminanceInvert(isSupportLuminanceInvert);
}
} catch (IOException ioe) {
LogUtils.w( ioe);
LogUtils.w(ioe);
} catch (RuntimeException e) {
// Barcode Scanner has seen crashes in the wild of this variety:
// java.?lang.?RuntimeException: Fail to connect to camera service
@@ -532,6 +536,7 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
activity.setResult(Activity.RESULT_OK,intent);
activity.finish();
},100);
return;
}

View File

@@ -146,7 +146,7 @@ final class DecodeHandler extends Handler {
if (rawResult != null) {
// Don't log the barcode contents for security.
long end = System.currentTimeMillis();
LogUtils.d( "Found barcode in " + (end - start) + " ms");
LogUtils.d("Found barcode in " + (end - start) + " ms");
BarcodeFormat barcodeFormat = rawResult.getBarcodeFormat();
if(handler!=null && handler.isSupportAutoZoom() && barcodeFormat == BarcodeFormat.QR_CODE){
@@ -237,7 +237,7 @@ final class DecodeHandler extends Handler {
lastZoomTime = System.currentTimeMillis();
return true;
} else {
LogUtils.i( "Zoom not supported");
LogUtils.d("Zoom not supported");
}
}

View File

@@ -98,7 +98,7 @@ final class DecodeThread extends Thread {
hints.put(DecodeHintType.CHARACTER_SET, characterSet);
}
hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
LogUtils.i( "Hints: " + hints);
LogUtils.i("Hints: " + hints);
}
Handler getHandler() {

View File

@@ -35,6 +35,8 @@ import java.util.concurrent.RejectedExecutionException;
*/
final class InactivityTimer {
private static final String TAG = InactivityTimer.class.getSimpleName();
private static final long INACTIVITY_DELAY_MS = 5 * 60 * 1000L;
private final Activity activity;
@@ -129,7 +131,7 @@ final class InactivityTimer {
protected Object doInBackground(Object... objects) {
try {
Thread.sleep(INACTIVITY_DELAY_MS);
LogUtils.i( "Finishing activity due to inactivity");
LogUtils.i("Finishing activity due to inactivity");
Activity activity = weakReference.get();
if(activity!=null){
activity.finish();

View File

@@ -1,5 +1,4 @@
package com.king.zxing;
/*
* Copyright (C) 2008 ZXing authors
*
@@ -16,7 +15,6 @@ package com.king.zxing;
* limitations under the License.
*/
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
@@ -25,10 +23,6 @@ import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
@@ -43,6 +37,11 @@ import com.google.zxing.ResultPoint;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
/**
* This view is overlaid on top of the camera preview. It adds the viewfinder rectangle and partial
* transparency outside it, as well as the laser scanner animation and result points.

View File

@@ -29,7 +29,6 @@ import java.util.concurrent.RejectedExecutionException;
import com.king.zxing.Preferences;
import com.king.zxing.util.LogUtils;
@SuppressWarnings("deprecation") // camera APIs
final class AutoFocusManager implements Camera.AutoFocusCallback {
private static final long AUTO_FOCUS_INTERVAL_MS = 1200L;
@@ -53,7 +52,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
useAutoFocus =
sharedPrefs.getBoolean(Preferences.KEY_AUTO_FOCUS, true) &&
FOCUS_MODES_CALLING_AF.contains(currentFocusMode);
LogUtils.i( "Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus);
LogUtils.i("Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus);
start();
}
@@ -70,7 +69,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
newTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
outstandingTask = newTask;
} catch (RejectedExecutionException ree) {
LogUtils.w( "Could not request auto focus", ree);
LogUtils.w("Could not request auto focus", ree);
}
}
}
@@ -84,7 +83,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
focusing = true;
} catch (RuntimeException re) {
// Have heard RuntimeException reported in Android 4.0.x+; continue?
LogUtils.w( "Unexpected exception while focusing", re);
LogUtils.w("Unexpected exception while focusing", re);
// Try again later to keep cycle going
autoFocusAgainLater();
}
@@ -110,7 +109,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
camera.cancelAutoFocus();
} catch (RuntimeException re) {
// Have heard RuntimeException reported in Android 4.0.x+; continue?
LogUtils.w( "Unexpected exception while cancelling focusing", re);
LogUtils.w("Unexpected exception while cancelling focusing", re);
}
}
}

View File

@@ -81,15 +81,15 @@ final class CameraConfigurationManager {
throw new IllegalArgumentException("Bad rotation: " + displayRotation);
}
}
LogUtils.i( "Display at: " + cwRotationFromNaturalToDisplay);
LogUtils.i("Display at: " + cwRotationFromNaturalToDisplay);
int cwRotationFromNaturalToCamera = camera.getOrientation();
LogUtils.i( "Camera at: " + cwRotationFromNaturalToCamera);
LogUtils.i("Camera at: " + cwRotationFromNaturalToCamera);
// Still not 100% sure about this. But acts like we need to flip this:
if (camera.getFacing() == CameraFacing.FRONT) {
cwRotationFromNaturalToCamera = (360 - cwRotationFromNaturalToCamera) % 360;
LogUtils.i( "Front camera overriden to: " + cwRotationFromNaturalToCamera);
LogUtils.i("Front camera overriden to: " + cwRotationFromNaturalToCamera);
}
/*
@@ -101,30 +101,30 @@ final class CameraConfigurationManager {
overrideRotationString = prefs.getString(PreferencesActivity.KEY_FORCE_CAMERA_ORIENTATION, null);
}
if (overrideRotationString != null && !"-".equals(overrideRotationString)) {
LogUtils.i( "Overriding camera manually to " + overrideRotationString);
LogUtils.i("Overriding camera manually to " + overrideRotationString);
cwRotationFromNaturalToCamera = Integer.parseInt(overrideRotationString);
}
*/
cwRotationFromDisplayToCamera = (360 + cwRotationFromNaturalToCamera - cwRotationFromNaturalToDisplay) % 360;
LogUtils.i( "Final display orientation: " + cwRotationFromDisplayToCamera);
LogUtils.i("Final display orientation: " + cwRotationFromDisplayToCamera);
if (camera.getFacing() == CameraFacing.FRONT) {
LogUtils.i( "Compensating rotation for front camera");
LogUtils.i("Compensating rotation for front camera");
cwNeededRotation = (360 - cwRotationFromDisplayToCamera) % 360;
} else {
cwNeededRotation = cwRotationFromDisplayToCamera;
}
LogUtils.i( "Clockwise rotation from display to camera: " + cwNeededRotation);
LogUtils.i("Clockwise rotation from display to camera: " + cwNeededRotation);
Point theScreenResolution = new Point();
display.getSize(theScreenResolution);
screenResolution = theScreenResolution;
LogUtils.i( "Screen resolution in current orientation: " + screenResolution);
LogUtils.i("Screen resolution in current orientation: " + screenResolution);
cameraResolution = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution);
LogUtils.i( "Camera resolution: " + cameraResolution);
LogUtils.i("Camera resolution: " + cameraResolution);
bestPreviewSize = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution);
LogUtils.i( "Best available preview size: " + bestPreviewSize);
LogUtils.i("Best available preview size: " + bestPreviewSize);
boolean isScreenPortrait = screenResolution.x < screenResolution.y;
boolean isPreviewSizePortrait = bestPreviewSize.x < bestPreviewSize.y;
@@ -134,7 +134,7 @@ final class CameraConfigurationManager {
} else {
previewSizeOnScreen = new Point(bestPreviewSize.y, bestPreviewSize.x);
}
LogUtils.i( "Preview size on screen: " + previewSizeOnScreen);
LogUtils.i("Preview size on screen: " + previewSizeOnScreen);
}
void setDesiredCameraParameters(OpenCamera camera, boolean safeMode) {
@@ -143,14 +143,14 @@ final class CameraConfigurationManager {
Camera.Parameters parameters = theCamera.getParameters();
if (parameters == null) {
LogUtils.w( "Device error: no camera parameters are available. Proceeding without configuration.");
LogUtils.w("Device error: no camera parameters are available. Proceeding without configuration.");
return;
}
LogUtils.i( "Initial camera parameters: " + parameters.flatten());
LogUtils.i("Initial camera parameters: " + parameters.flatten());
if (safeMode) {
LogUtils.w( "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);
@@ -197,7 +197,7 @@ final class CameraConfigurationManager {
Camera.Parameters afterParameters = theCamera.getParameters();
Camera.Size afterSize = afterParameters.getPreviewSize();
if (afterSize != null && (bestPreviewSize.x != afterSize.width || bestPreviewSize.y != afterSize.height)) {
LogUtils.w( "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);
bestPreviewSize.x = afterSize.width;
bestPreviewSize.y = afterSize.height;

View File

@@ -22,7 +22,6 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.hardware.Camera;
import android.os.Handler;
import android.support.annotation.FloatRange;
import android.view.SurfaceHolder;
import com.google.zxing.PlanarYUVLuminanceSource;
@@ -32,6 +31,8 @@ import com.king.zxing.util.LogUtils;
import java.io.IOException;
import androidx.annotation.FloatRange;
/**
* This object wraps the Camera service object and expects to be the only one talking to it. The
* implementation encapsulates the steps needed to take preview-sized images, which are used for
@@ -114,7 +115,7 @@ public final class CameraManager {
configManager.setDesiredCameraParameters(theCamera, false);
} catch (RuntimeException re) {
// Driver failed
LogUtils.w( "Camera rejected parameters. Setting only minimal safe-mode parameters");
LogUtils.w("Camera rejected parameters. Setting only minimal safe-mode parameters");
LogUtils.i( "Resetting to saved camera params: " + parametersFlattened);
// Reset:
if (parametersFlattened != null) {
@@ -125,7 +126,7 @@ public final class CameraManager {
configManager.setDesiredCameraParameters(theCamera, true);
} catch (RuntimeException re2) {
// Well, darn. Give up
LogUtils.w( "Camera rejected even safe-mode parameters! No configuration");
LogUtils.w("Camera rejected even safe-mode parameters! No configuration");
}
}
}
@@ -184,7 +185,6 @@ public final class CameraManager {
previewCallback.setHandler(null, 0);
previewing = false;
}
}
/**

View File

@@ -27,6 +27,8 @@ import com.king.zxing.util.LogUtils;
@SuppressWarnings("deprecation") // camera APIs
final class PreviewCallback implements Camera.PreviewCallback {
private static final String TAG = PreviewCallback.class.getSimpleName();
private final CameraConfigurationManager configManager;
private Handler previewHandler;
private int previewMessage;
@@ -50,7 +52,7 @@ final class PreviewCallback implements Camera.PreviewCallback {
message.sendToTarget();
previewHandler = null;
} else {
LogUtils.d( "Got preview callback, but no handler or resolution available");
LogUtils.d("Got preview callback, but no handler or resolution available");
}
}

View File

@@ -47,11 +47,11 @@ public final class OpenCameraInterface {
int numCameras = Camera.getNumberOfCameras();
if (numCameras == 0) {
LogUtils.w( "No cameras!");
LogUtils.w("No cameras!");
return null;
}
if (cameraId >= numCameras) {
LogUtils.w( "Requested camera does not exist: " + cameraId);
LogUtils.w("Requested camera does not exist: " + cameraId);
return null;
}

View File

@@ -20,12 +20,14 @@ import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.text.TextPaint;
import android.text.TextUtils;
import androidx.annotation.ColorInt;
import androidx.annotation.FloatRange;
import androidx.annotation.NonNull;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.DecodeHintType;
@@ -648,7 +650,7 @@ public final class CodeUtils {
* @param textColor
* @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) {
return null;
}

View File

@@ -1,7 +1,7 @@
//App
def app_version = [:]
app_version.versionCode = 25 //androidx 26
app_version.versionName = "1.1.9"
app_version.versionCode = 26
app_version.versionName = "1.1.9-androidx"
ext.app_version = app_version
//build version
@@ -16,35 +16,37 @@ ext.deps = [:]
// App dependencies
def versions = [:]
//support
versions.supportLibrary = "28.0.0"
//AndroidX
versions.material = "1.2.0-alpha01"
versions.appcompat = "1.1.0"
versions.constraintLayout = "1.1.3"
//test
versions.junit = "4.12"
versions.runner = "1.0.2"
versions.rules = "1.0.2"
versions.espresso = "3.0.2"
versions.junit = "1.1.0"
versions.test = "1.2.0"
versions.runner = "1.2.0"
versions.espresso = "3.2.0"
//zxing
versions.zxing = "3.3.3"
versions.easypermissions = "2.0.1"
versions.easypermissions = "3.0.0"
ext.versions = versions
//support
def support = [:]
support.design = "com.android.support:design:$versions.supportLibrary"
support.appcompat = "com.android.support:appcompat-v7:$versions.supportLibrary"
support.constraintlayout = "com.android.support.constraint:constraint-layout:$versions.constraintLayout"
support.design = "com.google.android.material:material:$versions.material"
support.appcompat = "androidx.appcompat:appcompat:$versions.appcompat"
support.constraintlayout = "androidx.constraintlayout:constraintlayout:$versions.constraintLayout"
deps.support = support
//test
def test = [:]
test.junit = "junit:junit:$versions.junit"
test.runner = "com.android.support.test:runner:$versions.runner"
test.espresso = "com.android.support.test.espresso:espresso-core:$versions.espresso"
test.junit = "androidx.test.ext:junit:$versions.junit"
test.test = "androidx.test:core:$versions.test"
test.runner = "androidx.test:runner:$versions.runner"
test.espresso = "androidx.test.espresso:espresso-core:$versions.espresso"
deps.test = test
//zxing