33 Commits

Author SHA1 Message Date
Jenly
c0d7192ba9 Update README 2020-12-29 15:02:23 +08:00
Jenly
2878dc8069 Update README 2020-12-24 18:09:56 +08:00
Jenly
4458ea747d Update README 2020-04-28 22:32:28 +08:00
Jenly
fa8c2166c7 fix #86 2020-04-28 22:02:24 +08:00
Jenly
f7bc5d2d01 优化细节 2020-04-28 22:01:23 +08:00
Jenly
a9c04fb310 统一日志管理 2020-04-27 21:14:05 +08:00
Jenly
aba5fcadf2 Update APK 2020-03-29 17:25:14 +08:00
Jenly
888687e06a fix#81 2020-03-29 17:01:42 +08:00
jenly1314
5c16340d78 Update README 2019-12-30 09:20:59 +08:00
jenly1314
f521b9e057 发布v1.1.6 2019-12-27 17:57:22 +08:00
jenly1314
56f3fed338 支持识别反色码(#66,#72) 2019-12-27 16:41:14 +08:00
jenly1314
72378b0a6d 生成条形码/二维码支持自定义颜色 (#73) 2019-12-27 14:49:14 +08:00
jenly1314
f1d16dceae Update README 2019-12-17 09:12:39 +08:00
jenly1314
69fef8f69f 优化Camera初始化相关策略,减少出现卡顿的可能性(#64,#65) 2019-12-16 11:35:57 +08:00
jenly1314
c7dbf12f57 优化细节 2019-12-05 09:54:12 +08:00
jenly1314
ef9344d77d Update README 2019-11-28 15:50:47 +08:00
jenly1314
7f8ab364b5 增加混淆规则 2019-11-25 10:53:53 +08:00
jenly1314
7096f1edd9 Update README 2019-11-19 15:21:14 +08:00
jenly1314
572096da10 Update README 2019-11-18 11:48:36 +08:00
jenly1314
c1c70bec5b Update README 2019-11-18 11:10:55 +08:00
jenly1314
154fe31526 Update README 2019-11-18 09:46:58 +08:00
jenly1314
c9b74fd707 * 内置手电筒按钮,当光线太暗时,自动显示手电筒 fix(#58)
*  生成二维码时Logo支持自定义大小 fix(#62)
2019-11-15 18:22:48 +08:00
jenly1314
39f13c3c3f 1、支持真实识别区域比例和识别区域偏移量可配置
2、对外暴露更多可配置参数
2019-09-24 11:04:36 +08:00
jenly1314
3465b76e96 CI 2019-08-23 09:33:17 +08:00
jenly1314
7db08d87d8 CI 2019-07-01 15:52:14 +08:00
jenly1314
9479cad482 CI 2019-07-01 15:44:32 +08:00
jenly1314
913af19017 CI 2019-07-01 15:43:17 +08:00
jenly1314
3e8f612e9f 支持AndroidX对应版本 2019-06-27 17:09:10 +08:00
jenly1314
10554f1a9f 支持AndroidX对应版本 2019-06-27 14:44:37 +08:00
jenly1314
d16a02d768 支持AndroidX对应版本 2019-06-27 14:39:34 +08:00
jenly1314
a69485d2ef 支持AndroidX对应版本 2019-06-27 14:33:40 +08:00
jenly1314
ab26e53c09 支持AndroidX对应版本 2019-06-27 14:09:26 +08:00
jenly1314
5b4c15db1f 支持AndroidX对应版本 2019-06-27 14:08:41 +08:00
44 changed files with 167 additions and 191 deletions

View File

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

View File

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

View File

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

Binary file not shown.

View File

@@ -1 +1 @@
[{"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":{}}] [{"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":{}}]

View File

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

View File

@@ -16,7 +16,7 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".MainActivity" <activity android:name=".MainActivity"
android:screenOrientation="portrait"> android:screenOrientation="portrait">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>

View File

@@ -1,18 +1,17 @@
package com.king.zxing.app; package com.king.zxing.app;
import android.os.Bundle; 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.view.View;
import android.widget.TextView; import android.widget.TextView;
import com.king.zxing.CaptureFragment; import com.king.zxing.CaptureFragment;
import com.king.zxing.app.util.StatusBarUtils; 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扫码 * Fragment扫码
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a> * @author <a href="mailto:jenly1314@gmail.com">Jenly</a>

View File

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

View File

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

View File

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

View File

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

View File

@@ -19,6 +19,9 @@ import android.Manifest;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.provider.MediaStore; 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.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
@@ -33,9 +36,6 @@ import com.king.zxing.util.CodeUtils;
import java.util.List; 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.AfterPermissionGranted;
import pub.devrel.easypermissions.EasyPermissions; import pub.devrel.easypermissions.EasyPermissions;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -16,19 +16,16 @@
package com.king.zxing; package com.king.zxing;
import android.os.Bundle; 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.MotionEvent;
import android.view.SurfaceView; import android.view.SurfaceView;
import android.view.View; import android.view.View;
import com.king.zxing.camera.CameraManager; 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 class CaptureActivity extends AppCompatActivity implements OnCaptureCallback{
public static final String KEY_RESULT = Intents.Scan.RESULT; public static final String KEY_RESULT = Intents.Scan.RESULT;

View File

@@ -16,6 +16,9 @@
package com.king.zxing; package com.king.zxing;
import android.os.Bundle; 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.LayoutInflater;
import android.view.SurfaceView; import android.view.SurfaceView;
import android.view.View; import android.view.View;
@@ -23,10 +26,6 @@ import android.view.ViewGroup;
import com.king.zxing.camera.CameraManager; 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> * @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/ */

View File

@@ -22,6 +22,8 @@ import android.graphics.Bitmap;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.RectF; import android.graphics.RectF;
import android.hardware.Camera; import android.hardware.Camera;
import android.support.annotation.FloatRange;
import android.support.v4.app.Fragment;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
import android.view.SurfaceView; import android.view.SurfaceView;
@@ -41,12 +43,6 @@ import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Map; 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> * @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/ */
@@ -349,7 +345,7 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
captureHandler.setSupportLuminanceInvert(isSupportLuminanceInvert); captureHandler.setSupportLuminanceInvert(isSupportLuminanceInvert);
} }
} catch (IOException ioe) { } catch (IOException ioe) {
LogUtils.w(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
@@ -536,7 +532,6 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
activity.setResult(Activity.RESULT_OK,intent); activity.setResult(Activity.RESULT_OK,intent);
activity.finish(); activity.finish();
},100); },100);
return; return;
} }

View File

@@ -146,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();
LogUtils.d("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){
@@ -237,7 +237,7 @@ final class DecodeHandler extends Handler {
lastZoomTime = System.currentTimeMillis(); lastZoomTime = System.currentTimeMillis();
return true; return true;
} else { } else {
LogUtils.d("Zoom not supported"); LogUtils.i( "Zoom not supported");
} }
} }

View File

@@ -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);
LogUtils.i("Hints: " + hints); LogUtils.i( "Hints: " + hints);
} }
Handler getHandler() { Handler getHandler() {

View File

@@ -35,8 +35,6 @@ import java.util.concurrent.RejectedExecutionException;
*/ */
final class InactivityTimer { final class InactivityTimer {
private static final String TAG = InactivityTimer.class.getSimpleName();
private static final long INACTIVITY_DELAY_MS = 5 * 60 * 1000L; private static final long INACTIVITY_DELAY_MS = 5 * 60 * 1000L;
private final Activity activity; private final Activity activity;
@@ -57,7 +55,7 @@ final class InactivityTimer {
try { try {
inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} catch (RejectedExecutionException ree) { } catch (RejectedExecutionException ree) {
LogUtils.w( "Couldn't schedule inactivity task; ignoring"); LogUtils.w( "Couldn't schedule inactivity task; ignoring");
} }
} }
@@ -67,13 +65,13 @@ final class InactivityTimer {
activity.unregisterReceiver(powerStatusReceiver); activity.unregisterReceiver(powerStatusReceiver);
registered = false; registered = false;
} else { } else {
LogUtils.w( "PowerStatusReceiver was never registered?"); LogUtils.w( "PowerStatusReceiver was never registered?");
} }
} }
void onResume() { void onResume() {
if (registered) { if (registered) {
LogUtils.w( "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;
@@ -131,7 +129,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);
LogUtils.i("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

@@ -1,4 +1,5 @@
package com.king.zxing; package com.king.zxing;
/* /*
* Copyright (C) 2008 ZXing authors * Copyright (C) 2008 ZXing authors
* *
@@ -15,6 +16,7 @@ package com.king.zxing;
* limitations under the License. * limitations under the License.
*/ */
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Canvas; import android.graphics.Canvas;
@@ -23,6 +25,10 @@ import android.graphics.Paint;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.RectF; import android.graphics.RectF;
import android.graphics.Shader; 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.Layout;
import android.text.StaticLayout; import android.text.StaticLayout;
import android.text.TextPaint; import android.text.TextPaint;
@@ -37,11 +43,6 @@ import com.google.zxing.ResultPoint;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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 * 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. * transparency outside it, as well as the laser scanner animation and result points.

View File

@@ -29,6 +29,7 @@ import java.util.concurrent.RejectedExecutionException;
import com.king.zxing.Preferences; import com.king.zxing.Preferences;
import com.king.zxing.util.LogUtils; import com.king.zxing.util.LogUtils;
@SuppressWarnings("deprecation") // camera APIs
final class AutoFocusManager implements Camera.AutoFocusCallback { final class AutoFocusManager implements Camera.AutoFocusCallback {
private static final long AUTO_FOCUS_INTERVAL_MS = 1200L; private static final long AUTO_FOCUS_INTERVAL_MS = 1200L;
@@ -52,7 +53,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);
LogUtils.i("Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus); LogUtils.i( "Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus);
start(); start();
} }
@@ -69,7 +70,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) {
LogUtils.w("Could not request auto focus", ree); LogUtils.w( "Could not request auto focus", ree);
} }
} }
} }
@@ -83,7 +84,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?
LogUtils.w("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();
} }
@@ -109,7 +110,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?
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); throw new IllegalArgumentException("Bad rotation: " + displayRotation);
} }
} }
LogUtils.i("Display at: " + cwRotationFromNaturalToDisplay); LogUtils.i( "Display at: " + cwRotationFromNaturalToDisplay);
int cwRotationFromNaturalToCamera = camera.getOrientation(); 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: // 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;
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); overrideRotationString = prefs.getString(PreferencesActivity.KEY_FORCE_CAMERA_ORIENTATION, null);
} }
if (overrideRotationString != null && !"-".equals(overrideRotationString)) { if (overrideRotationString != null && !"-".equals(overrideRotationString)) {
LogUtils.i("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;
LogUtils.i("Final display orientation: " + cwRotationFromDisplayToCamera); LogUtils.i( "Final display orientation: " + cwRotationFromDisplayToCamera);
if (camera.getFacing() == CameraFacing.FRONT) { if (camera.getFacing() == CameraFacing.FRONT) {
LogUtils.i("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;
} }
LogUtils.i("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;
LogUtils.i("Screen resolution in current orientation: " + screenResolution); LogUtils.i( "Screen resolution in current orientation: " + screenResolution);
cameraResolution = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution); cameraResolution = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution);
LogUtils.i("Camera resolution: " + cameraResolution); LogUtils.i( "Camera resolution: " + cameraResolution);
bestPreviewSize = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution); 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 isScreenPortrait = screenResolution.x < screenResolution.y;
boolean isPreviewSizePortrait = bestPreviewSize.x < bestPreviewSize.y; boolean isPreviewSizePortrait = bestPreviewSize.x < bestPreviewSize.y;
@@ -134,7 +134,7 @@ final class CameraConfigurationManager {
} else { } else {
previewSizeOnScreen = new Point(bestPreviewSize.y, bestPreviewSize.x); 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) { void setDesiredCameraParameters(OpenCamera camera, boolean safeMode) {
@@ -143,14 +143,14 @@ final class CameraConfigurationManager {
Camera.Parameters parameters = theCamera.getParameters(); Camera.Parameters parameters = theCamera.getParameters();
if (parameters == null) { 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; return;
} }
LogUtils.i("Initial camera parameters: " + parameters.flatten()); LogUtils.i( "Initial camera parameters: " + parameters.flatten());
if (safeMode) { 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); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@@ -197,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)) {
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); ", 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

@@ -79,7 +79,7 @@ public final class CameraConfigurationUtils {
} }
if (focusMode != null) { if (focusMode != null) {
if (focusMode.equals(parameters.getFocusMode())) { if (focusMode.equals(parameters.getFocusMode())) {
LogUtils.d( "Focus mode already set to " + focusMode); LogUtils.d( "Focus mode already set to " + focusMode);
} else { } else {
parameters.setFocusMode(focusMode); parameters.setFocusMode(focusMode);
} }
@@ -101,9 +101,9 @@ public final class CameraConfigurationUtils {
} }
if (flashMode != null) { if (flashMode != null) {
if (flashMode.equals(parameters.getFlashMode())) { if (flashMode.equals(parameters.getFlashMode())) {
LogUtils.d( "Flash mode already set to " + flashMode); LogUtils.d( "Flash mode already set to " + flashMode);
} else { } else {
LogUtils.d( "Setting flash mode to " + flashMode); LogUtils.d( "Setting flash mode to " + flashMode);
parameters.setFlashMode(flashMode); parameters.setFlashMode(flashMode);
} }
} }
@@ -121,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) {
LogUtils.d( "Exposure compensation already set to " + compensationSteps + " / " + actualCompensation); LogUtils.d( "Exposure compensation already set to " + compensationSteps + " / " + actualCompensation);
} else { } else {
LogUtils.d( "Setting exposure compensation to " + compensationSteps + " / " + actualCompensation); LogUtils.d( "Setting exposure compensation to " + compensationSteps + " / " + actualCompensation);
parameters.setExposureCompensation(compensationSteps); parameters.setExposureCompensation(compensationSteps);
} }
} else { } else {
LogUtils.d( "Camera does not support exposure compensation"); LogUtils.d( "Camera does not support exposure compensation");
} }
} }
@@ -137,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();
LogUtils.d( "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) {
@@ -149,14 +149,14 @@ public final class CameraConfigurationUtils {
} }
} }
if (suitableFPSRange == null) { if (suitableFPSRange == null) {
LogUtils.d( "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)) {
LogUtils.d( "FPS range already set to " + Arrays.toString(suitableFPSRange)); LogUtils.d( "FPS range already set to " + Arrays.toString(suitableFPSRange));
} else { } else {
LogUtils.d( "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]);
} }
@@ -166,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) {
LogUtils.d( "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);
LogUtils.d( "Setting focus area to : " + toString(middleArea)); LogUtils.d( "Setting focus area to : " + toString(middleArea));
parameters.setFocusAreas(middleArea); parameters.setFocusAreas(middleArea);
} else { } else {
LogUtils.d( "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) {
LogUtils.d( "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);
LogUtils.d( "Setting metering area to : " + toString(middleArea)); LogUtils.d( "Setting metering area to : " + toString(middleArea));
parameters.setMeteringAreas(middleArea); parameters.setMeteringAreas(middleArea);
} else { } else {
LogUtils.d( "Device does not support metering areas"); LogUtils.d( "Device does not support metering areas");
} }
} }
@@ -194,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()) {
LogUtils.d( "Video stabilization already enabled"); LogUtils.d( "Video stabilization already enabled");
} else { } else {
LogUtils.d( "Enabling video stabilization..."); LogUtils.d( "Enabling video stabilization...");
parameters.setVideoStabilization(true); parameters.setVideoStabilization(true);
} }
} else { } else {
LogUtils.d( "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())) {
LogUtils.d( "Barcode scene mode already set"); LogUtils.d( "Barcode scene mode already set");
return; return;
} }
String sceneMode = findSettableValue("scene mode", String sceneMode = findSettableValue("scene mode",
@@ -224,22 +224,22 @@ public final class CameraConfigurationUtils {
return; return;
} }
if (parameters.getZoom() == zoom) { if (parameters.getZoom() == zoom) {
LogUtils.d( "Zoom is already set to " + zoom); LogUtils.d( "Zoom is already set to " + zoom);
} else { } else {
LogUtils.d( "Setting zoom to " + zoom); LogUtils.d( "Setting zoom to " + zoom);
parameters.setZoom(zoom); parameters.setZoom(zoom);
} }
} else { } else {
LogUtils.d( "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();
LogUtils.d( "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) {
LogUtils.w( "Invalid zoom ratios!"); LogUtils.w( "Invalid zoom ratios!");
return null; return null;
} }
double target100 = 100.0 * targetZoomRatio; double target100 = 100.0 * targetZoomRatio;
@@ -252,13 +252,13 @@ public final class CameraConfigurationUtils {
closestIndex = i; closestIndex = i;
} }
} }
LogUtils.d( "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())) {
LogUtils.d( "Negative effect already set"); LogUtils.d( "Negative effect already set");
return; return;
} }
String colorMode = findSettableValue("color effect", String colorMode = findSettableValue("color effect",
@@ -273,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) {
LogUtils.w( "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!");
@@ -287,7 +287,7 @@ public final class CameraConfigurationUtils {
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(' ');
} }
LogUtils.d( "Supported preview sizes: " + previewSizesString); LogUtils.d( "Supported preview sizes: " + previewSizesString);
} }
double screenAspectRatio; double screenAspectRatio;
@@ -296,7 +296,7 @@ public final class CameraConfigurationUtils {
}else{ }else{
screenAspectRatio = screenResolution.y / (double) screenResolution.x; screenAspectRatio = screenResolution.y / (double) screenResolution.x;
} }
LogUtils.d( "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;
@@ -312,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;
LogUtils.d( 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;
LogUtils.d( "aspectRatio: " + aspectRatio); LogUtils.d( "aspectRatio: " + aspectRatio);
double distortion = Math.abs(aspectRatio - screenAspectRatio); double distortion = Math.abs(aspectRatio - screenAspectRatio);
LogUtils.d( "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);
LogUtils.d( "Found preview size exactly matching screen size: " + exactPoint); LogUtils.d( "Found preview size exactly matching screen size: " + exactPoint);
return exactPoint; return exactPoint;
} }
@@ -340,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);
LogUtils.d( "Using largest suitable preview size: " + largestSize); LogUtils.d( "Using largest suitable preview size: " + largestSize);
return largestSize; return largestSize;
} }
@@ -350,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);
LogUtils.d( "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) {
LogUtils.d( "Requesting " + name + " value from among: " + Arrays.toString(desiredValues)); LogUtils.d( "Requesting " + name + " value from among: " + Arrays.toString(desiredValues));
LogUtils.d( "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)) {
LogUtils.d( "Can set " + name + " to: " + desiredValue); LogUtils.d( "Can set " + name + " to: " + desiredValue);
return desiredValue; return desiredValue;
} }
} }
} }
LogUtils.d( "No supported values match"); LogUtils.d( "No supported values match");
return null; return null;
} }

View File

@@ -22,6 +22,7 @@ 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.support.annotation.FloatRange;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
import com.google.zxing.PlanarYUVLuminanceSource; import com.google.zxing.PlanarYUVLuminanceSource;
@@ -31,8 +32,6 @@ import com.king.zxing.util.LogUtils;
import java.io.IOException; 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 * 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 * implementation encapsulates the steps needed to take preview-sized images, which are used for
@@ -115,8 +114,8 @@ public final class CameraManager {
configManager.setDesiredCameraParameters(theCamera, false); configManager.setDesiredCameraParameters(theCamera, false);
} catch (RuntimeException re) { } catch (RuntimeException re) {
// Driver failed // 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); LogUtils.i( "Resetting to saved camera params: " + parametersFlattened);
// Reset: // Reset:
if (parametersFlattened != null) { if (parametersFlattened != null) {
parameters = cameraObject.getParameters(); parameters = cameraObject.getParameters();
@@ -126,7 +125,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
LogUtils.w("Camera rejected even safe-mode parameters! No configuration"); LogUtils.w( "Camera rejected even safe-mode parameters! No configuration");
} }
} }
} }
@@ -185,6 +184,7 @@ public final class CameraManager {
previewCallback.setHandler(null, 0); previewCallback.setHandler(null, 0);
previewing = false; previewing = false;
} }
} }
/** /**
@@ -358,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);
LogUtils.d( "Calculated manual framing rect: " + framingRect); LogUtils.d( "Calculated manual framing rect: " + framingRect);
framingRectInPreview = null; framingRectInPreview = null;
} else { } else {
requestedFramingRectWidth = width; requestedFramingRectWidth = width;

View File

@@ -27,8 +27,6 @@ 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 {
private static final String TAG = PreviewCallback.class.getSimpleName();
private final CameraConfigurationManager configManager; private final CameraConfigurationManager configManager;
private Handler previewHandler; private Handler previewHandler;
private int previewMessage; private int previewMessage;
@@ -52,7 +50,7 @@ final class PreviewCallback implements Camera.PreviewCallback {
message.sendToTarget(); message.sendToTarget();
previewHandler = null; previewHandler = null;
} else { } 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(); int numCameras = Camera.getNumberOfCameras();
if (numCameras == 0) { if (numCameras == 0) {
LogUtils.w("No cameras!"); LogUtils.w( "No cameras!");
return null; return null;
} }
if (cameraId >= numCameras) { if (cameraId >= numCameras) {
LogUtils.w("Requested camera does not exist: " + cameraId); LogUtils.w( "Requested camera does not exist: " + cameraId);
return null; return null;
} }

View File

@@ -20,14 +20,12 @@ 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.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.text.TextPaint; import android.text.TextPaint;
import android.text.TextUtils; 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.BarcodeFormat;
import com.google.zxing.BinaryBitmap; import com.google.zxing.BinaryBitmap;
import com.google.zxing.DecodeHintType; import com.google.zxing.DecodeHintType;
@@ -650,7 +648,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;
} }

View File

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