Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0d7192ba9 | ||
|
|
2878dc8069 | ||
|
|
4458ea747d | ||
|
|
fa8c2166c7 | ||
|
|
f7bc5d2d01 | ||
|
|
a9c04fb310 | ||
|
|
aba5fcadf2 | ||
|
|
888687e06a | ||
|
|
5c16340d78 | ||
|
|
f521b9e057 | ||
|
|
56f3fed338 | ||
|
|
72378b0a6d | ||
|
|
f1d16dceae | ||
|
|
69fef8f69f | ||
|
|
c7dbf12f57 | ||
|
|
ef9344d77d | ||
|
|
7f8ab364b5 | ||
|
|
7096f1edd9 | ||
|
|
572096da10 | ||
|
|
c1c70bec5b | ||
|
|
154fe31526 | ||
|
|
c9b74fd707 | ||
|
|
39f13c3c3f | ||
|
|
3465b76e96 | ||
|
|
7db08d87d8 | ||
|
|
9479cad482 | ||
|
|
913af19017 | ||
|
|
3e8f612e9f | ||
|
|
10554f1a9f | ||
|
|
d16a02d768 | ||
|
|
a69485d2ef | ||
|
|
ab26e53c09 | ||
|
|
5b4c15db1f |
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
version: 2
|
version: 2
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ ZXingLite for Android 是ZXing的精简版,基于ZXing库优化扫码和生成
|
|||||||
>简单如斯,你不试试? Come on~
|
>简单如斯,你不试试? Come on~
|
||||||
|
|
||||||
|
|
||||||
|
### [AndroidX version](https://github.com/jenly1314/ZXingLite/tree/androidx)
|
||||||
|
|
||||||
## 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{}中添加配置:
|
||||||
|
|||||||
@@ -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.
@@ -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":{}}]
|
||||||
@@ -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.
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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}对应的生命周期
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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'
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -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();
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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,7 +114,7 @@ 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) {
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user