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
|
||||
jobs:
|
||||
build:
|
||||
|
||||
@@ -16,6 +16,8 @@ ZXingLite for Android 是ZXing的精简版,基于ZXing库优化扫码和生成
|
||||
>简单如斯,你不试试? Come on~
|
||||
|
||||
|
||||
### [AndroidX version](https://github.com/jenly1314/ZXingLite/tree/androidx)
|
||||
|
||||
## Gif 展示
|
||||

|
||||
|
||||
@@ -165,7 +167,6 @@ api 'com.google.zxing:core:3.3.3'
|
||||
|
||||
> 4、参照CaptureHelper写一个自定义的扫码帮助类,其它步骤同方式3。(扩展高级用法,谨慎使用)
|
||||
|
||||
|
||||
### 其他
|
||||
|
||||
需使用JDK8+编译,在你项目中的build.gradle的android{}中添加配置:
|
||||
|
||||
@@ -9,7 +9,7 @@ android {
|
||||
targetSdkVersion build_versions.targetSdk
|
||||
versionCode app_version.versionCode
|
||||
versionName app_version.versionName
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
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;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity"
|
||||
android:screenOrientation="portrait">
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.king.zxing.app;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.king.zxing.CaptureFragment;
|
||||
import com.king.zxing.app.util.StatusBarUtils;
|
||||
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
/**
|
||||
* Fragment扫码
|
||||
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.king.zxing.app;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@@ -25,9 +27,6 @@ import android.widget.TextView;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.king.zxing.util.CodeUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
/**
|
||||
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
|
||||
*/
|
||||
@@ -93,4 +92,4 @@ public class CodeActivity extends AppCompatActivity {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.king.zxing.app;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.hardware.Camera;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
@@ -13,10 +17,6 @@ import com.king.zxing.OnCaptureCallback;
|
||||
import com.king.zxing.ViewfinderView;
|
||||
import com.king.zxing.app.util.StatusBarUtils;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
/**
|
||||
* 自定义扫码:当直接使用CaptureActivity
|
||||
* 自定义扫码,切记自定义扫码需在{@link Activity}或者{@link Fragment}相对应的生命周期里面调用{@link #mCaptureHelper}对应的生命周期
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.king.zxing.app;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@@ -24,8 +25,6 @@ import com.king.zxing.CaptureActivity;
|
||||
import com.king.zxing.app.util.StatusBarUtils;
|
||||
import com.king.zxing.camera.FrontLightMode;
|
||||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
/**
|
||||
* 自定义继承CaptureActivity
|
||||
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
package com.king.zxing.app;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.king.zxing.CaptureActivity;
|
||||
import com.king.zxing.DecodeFormatManager;
|
||||
import com.king.zxing.app.util.StatusBarUtils;
|
||||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
/**
|
||||
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
|
||||
*/
|
||||
|
||||
@@ -19,6 +19,9 @@ import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.ActivityOptionsCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -33,9 +36,6 @@ import com.king.zxing.util.CodeUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.app.ActivityOptionsCompat;
|
||||
import pub.devrel.easypermissions.AfterPermissionGranted;
|
||||
import pub.devrel.easypermissions.EasyPermissions;
|
||||
|
||||
@@ -243,4 +243,4 @@ public class MainActivity extends AppCompatActivity implements EasyPermissions.P
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.FloatRange;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
@@ -27,9 +29,6 @@ import android.widget.LinearLayout;
|
||||
|
||||
import com.king.zxing.app.R;
|
||||
|
||||
import androidx.annotation.FloatRange;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
/**
|
||||
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
|
||||
*/
|
||||
|
||||
@@ -68,4 +68,4 @@ public final class UriUtils {
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
<?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:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@color/colorPrimary"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -25,7 +27,7 @@
|
||||
android:textColor="@color/white"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/app_name"/>
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
</android.support.v7.widget.Toolbar>
|
||||
<Button
|
||||
android:id="@+id/btn0"
|
||||
android:layout_width="match_parent"
|
||||
@@ -131,4 +133,4 @@
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btn6"
|
||||
style="@style/OnClick"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<android.support.constraint.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -15,4 +15,4 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/toolbar"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?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:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
@@ -33,4 +33,4 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_marginTop="160dp" />
|
||||
<include layout="@layout/toolbar_capture"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?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:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
@@ -32,4 +32,4 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_marginTop="160dp" />
|
||||
<include layout="@layout/toolbar_capture"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -1,8 +1,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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<include layout="@layout/zxl_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"?>
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
@@ -9,4 +9,4 @@
|
||||
app:contentInsetLeft="0dp"
|
||||
app:contentInsetStart="0dp">
|
||||
<include layout="@layout/top_title_back_bar"/>
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
</android.support.v7.widget.Toolbar>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
@@ -8,4 +8,4 @@
|
||||
app:contentInsetLeft="0dp"
|
||||
app:contentInsetStart="0dp">
|
||||
<include layout="@layout/top_title_back_bar"/>
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
</android.support.v7.widget.Toolbar>
|
||||
@@ -4,7 +4,6 @@ buildscript {
|
||||
apply from: 'versions.gradle'
|
||||
|
||||
addRepos(repositories)
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
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
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
@@ -10,7 +10,7 @@ android {
|
||||
versionCode app_version.versionCode
|
||||
versionName app_version.versionName
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
}
|
||||
buildTypes {
|
||||
|
||||
2
lib/proguard-rules.pro
vendored
2
lib/proguard-rules.pro
vendored
@@ -31,4 +31,4 @@
|
||||
|
||||
#ZXing
|
||||
-dontwarn com.google.zxing.**
|
||||
-keep class com.google.zxing.**{ *;}
|
||||
-keep class com.google.zxing.**{ *;}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.king.zxing;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,8 +37,6 @@ import java.io.IOException;
|
||||
*/
|
||||
public final class BeepManager implements MediaPlayer.OnErrorListener, Closeable {
|
||||
|
||||
private static final String TAG = BeepManager.class.getSimpleName();
|
||||
|
||||
private static final float BEEP_VOLUME = 0.10f;
|
||||
private static final long VIBRATE_DURATION = 200L;
|
||||
|
||||
@@ -107,7 +105,7 @@ public final class BeepManager implements MediaPlayer.OnErrorListener, Closeable
|
||||
mediaPlayer.prepare();
|
||||
return mediaPlayer;
|
||||
} catch (IOException ioe) {
|
||||
LogUtils.w(ioe);
|
||||
LogUtils.w( ioe);
|
||||
mediaPlayer.release();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -16,19 +16,16 @@
|
||||
package com.king.zxing;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
|
||||
import com.king.zxing.camera.CameraManager;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
|
||||
*/
|
||||
public class CaptureActivity extends AppCompatActivity implements OnCaptureCallback{
|
||||
|
||||
public static final String KEY_RESULT = Intents.Scan.RESULT;
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
package com.king.zxing;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
@@ -23,10 +26,6 @@ import android.view.ViewGroup;
|
||||
|
||||
import com.king.zxing.camera.CameraManager;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
|
||||
*/
|
||||
@@ -189,4 +188,4 @@ public class CaptureFragment extends Fragment implements OnCaptureCallback {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -211,4 +211,4 @@ public class CaptureHandler extends Handler implements ResultPointCallback {
|
||||
public void setSupportLuminanceInvert(boolean supportLuminanceInvert) {
|
||||
isSupportLuminanceInvert = supportLuminanceInvert;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.hardware.Camera;
|
||||
import android.support.annotation.FloatRange;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
@@ -41,12 +43,6 @@ import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.annotation.FloatRange;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
|
||||
*/
|
||||
/**
|
||||
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
|
||||
*/
|
||||
@@ -349,7 +345,7 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
|
||||
captureHandler.setSupportLuminanceInvert(isSupportLuminanceInvert);
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
LogUtils.w(ioe);
|
||||
LogUtils.w( ioe);
|
||||
} catch (RuntimeException e) {
|
||||
// Barcode Scanner has seen crashes in the wild of this variety:
|
||||
// java.?lang.?RuntimeException: Fail to connect to camera service
|
||||
@@ -536,7 +532,6 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
|
||||
activity.setResult(Activity.RESULT_OK,intent);
|
||||
activity.finish();
|
||||
},100);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ final class DecodeHandler extends Handler {
|
||||
if (rawResult != null) {
|
||||
// Don't log the barcode contents for security.
|
||||
long end = System.currentTimeMillis();
|
||||
LogUtils.d("Found barcode in " + (end - start) + " ms");
|
||||
LogUtils.d( "Found barcode in " + (end - start) + " ms");
|
||||
|
||||
BarcodeFormat barcodeFormat = rawResult.getBarcodeFormat();
|
||||
if(handler!=null && handler.isSupportAutoZoom() && barcodeFormat == BarcodeFormat.QR_CODE){
|
||||
@@ -237,7 +237,7 @@ final class DecodeHandler extends Handler {
|
||||
lastZoomTime = System.currentTimeMillis();
|
||||
return true;
|
||||
} else {
|
||||
LogUtils.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.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
|
||||
LogUtils.i("Hints: " + hints);
|
||||
LogUtils.i( "Hints: " + hints);
|
||||
}
|
||||
|
||||
Handler getHandler() {
|
||||
|
||||
@@ -35,8 +35,6 @@ import java.util.concurrent.RejectedExecutionException;
|
||||
*/
|
||||
final class InactivityTimer {
|
||||
|
||||
private static final String TAG = InactivityTimer.class.getSimpleName();
|
||||
|
||||
private static final long INACTIVITY_DELAY_MS = 5 * 60 * 1000L;
|
||||
|
||||
private final Activity activity;
|
||||
@@ -57,7 +55,7 @@ final class InactivityTimer {
|
||||
try {
|
||||
inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} 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);
|
||||
registered = false;
|
||||
} else {
|
||||
LogUtils.w( "PowerStatusReceiver was never registered?");
|
||||
LogUtils.w( "PowerStatusReceiver was never registered?");
|
||||
}
|
||||
}
|
||||
|
||||
void onResume() {
|
||||
void onResume() {
|
||||
if (registered) {
|
||||
LogUtils.w( "PowerStatusReceiver was already registered?");
|
||||
LogUtils.w( "PowerStatusReceiver was already registered?");
|
||||
} else {
|
||||
activity.registerReceiver(powerStatusReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
registered = true;
|
||||
@@ -131,7 +129,7 @@ final class InactivityTimer {
|
||||
protected Object doInBackground(Object... objects) {
|
||||
try {
|
||||
Thread.sleep(INACTIVITY_DELAY_MS);
|
||||
LogUtils.i("Finishing activity due to inactivity");
|
||||
LogUtils.i( "Finishing activity due to inactivity");
|
||||
Activity activity = weakReference.get();
|
||||
if(activity!=null){
|
||||
activity.finish();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package com.king.zxing;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2008 ZXing authors
|
||||
*
|
||||
@@ -15,6 +16,7 @@ package com.king.zxing;
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
@@ -23,6 +25,10 @@ import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.Layout;
|
||||
import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
@@ -37,11 +43,6 @@ import com.google.zxing.ResultPoint;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.ColorRes;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
/**
|
||||
* This view is overlaid on top of the camera preview. It adds the viewfinder rectangle and partial
|
||||
* transparency outside it, as well as the laser scanner animation and result points.
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.concurrent.RejectedExecutionException;
|
||||
import com.king.zxing.Preferences;
|
||||
import com.king.zxing.util.LogUtils;
|
||||
|
||||
@SuppressWarnings("deprecation") // camera APIs
|
||||
final class AutoFocusManager implements Camera.AutoFocusCallback {
|
||||
|
||||
private static final long AUTO_FOCUS_INTERVAL_MS = 1200L;
|
||||
@@ -52,7 +53,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
|
||||
useAutoFocus =
|
||||
sharedPrefs.getBoolean(Preferences.KEY_AUTO_FOCUS, true) &&
|
||||
FOCUS_MODES_CALLING_AF.contains(currentFocusMode);
|
||||
LogUtils.i("Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus);
|
||||
LogUtils.i( "Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus);
|
||||
start();
|
||||
}
|
||||
|
||||
@@ -69,7 +70,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
|
||||
newTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
outstandingTask = newTask;
|
||||
} catch (RejectedExecutionException ree) {
|
||||
LogUtils.w("Could not request auto focus", ree);
|
||||
LogUtils.w( "Could not request auto focus", ree);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,7 +84,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
|
||||
focusing = true;
|
||||
} catch (RuntimeException re) {
|
||||
// Have heard RuntimeException reported in Android 4.0.x+; continue?
|
||||
LogUtils.w("Unexpected exception while focusing", re);
|
||||
LogUtils.w( "Unexpected exception while focusing", re);
|
||||
// Try again later to keep cycle going
|
||||
autoFocusAgainLater();
|
||||
}
|
||||
@@ -109,7 +110,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
|
||||
camera.cancelAutoFocus();
|
||||
} catch (RuntimeException re) {
|
||||
// Have heard RuntimeException reported in Android 4.0.x+; continue?
|
||||
LogUtils.w("Unexpected exception while cancelling focusing", re);
|
||||
LogUtils.w( "Unexpected exception while cancelling focusing", re);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,15 +81,15 @@ final class CameraConfigurationManager {
|
||||
throw new IllegalArgumentException("Bad rotation: " + displayRotation);
|
||||
}
|
||||
}
|
||||
LogUtils.i("Display at: " + cwRotationFromNaturalToDisplay);
|
||||
LogUtils.i( "Display at: " + cwRotationFromNaturalToDisplay);
|
||||
|
||||
int cwRotationFromNaturalToCamera = camera.getOrientation();
|
||||
LogUtils.i("Camera at: " + cwRotationFromNaturalToCamera);
|
||||
LogUtils.i( "Camera at: " + cwRotationFromNaturalToCamera);
|
||||
|
||||
// Still not 100% sure about this. But acts like we need to flip this:
|
||||
if (camera.getFacing() == CameraFacing.FRONT) {
|
||||
cwRotationFromNaturalToCamera = (360 - cwRotationFromNaturalToCamera) % 360;
|
||||
LogUtils.i("Front camera overriden to: " + cwRotationFromNaturalToCamera);
|
||||
LogUtils.i( "Front camera overriden to: " + cwRotationFromNaturalToCamera);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -101,30 +101,30 @@ final class CameraConfigurationManager {
|
||||
overrideRotationString = prefs.getString(PreferencesActivity.KEY_FORCE_CAMERA_ORIENTATION, null);
|
||||
}
|
||||
if (overrideRotationString != null && !"-".equals(overrideRotationString)) {
|
||||
LogUtils.i("Overriding camera manually to " + overrideRotationString);
|
||||
LogUtils.i( "Overriding camera manually to " + overrideRotationString);
|
||||
cwRotationFromNaturalToCamera = Integer.parseInt(overrideRotationString);
|
||||
}
|
||||
*/
|
||||
|
||||
cwRotationFromDisplayToCamera = (360 + cwRotationFromNaturalToCamera - cwRotationFromNaturalToDisplay) % 360;
|
||||
LogUtils.i("Final display orientation: " + cwRotationFromDisplayToCamera);
|
||||
LogUtils.i( "Final display orientation: " + cwRotationFromDisplayToCamera);
|
||||
if (camera.getFacing() == CameraFacing.FRONT) {
|
||||
LogUtils.i("Compensating rotation for front camera");
|
||||
LogUtils.i( "Compensating rotation for front camera");
|
||||
cwNeededRotation = (360 - cwRotationFromDisplayToCamera) % 360;
|
||||
} else {
|
||||
cwNeededRotation = cwRotationFromDisplayToCamera;
|
||||
}
|
||||
LogUtils.i("Clockwise rotation from display to camera: " + cwNeededRotation);
|
||||
LogUtils.i( "Clockwise rotation from display to camera: " + cwNeededRotation);
|
||||
|
||||
Point theScreenResolution = new Point();
|
||||
display.getSize(theScreenResolution);
|
||||
screenResolution = theScreenResolution;
|
||||
LogUtils.i("Screen resolution in current orientation: " + screenResolution);
|
||||
LogUtils.i( "Screen resolution in current orientation: " + screenResolution);
|
||||
|
||||
cameraResolution = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution);
|
||||
LogUtils.i("Camera resolution: " + cameraResolution);
|
||||
LogUtils.i( "Camera resolution: " + cameraResolution);
|
||||
bestPreviewSize = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution);
|
||||
LogUtils.i("Best available preview size: " + bestPreviewSize);
|
||||
LogUtils.i( "Best available preview size: " + bestPreviewSize);
|
||||
|
||||
boolean isScreenPortrait = screenResolution.x < screenResolution.y;
|
||||
boolean isPreviewSizePortrait = bestPreviewSize.x < bestPreviewSize.y;
|
||||
@@ -134,7 +134,7 @@ final class CameraConfigurationManager {
|
||||
} else {
|
||||
previewSizeOnScreen = new Point(bestPreviewSize.y, bestPreviewSize.x);
|
||||
}
|
||||
LogUtils.i("Preview size on screen: " + previewSizeOnScreen);
|
||||
LogUtils.i( "Preview size on screen: " + previewSizeOnScreen);
|
||||
}
|
||||
|
||||
void setDesiredCameraParameters(OpenCamera camera, boolean safeMode) {
|
||||
@@ -143,14 +143,14 @@ final class CameraConfigurationManager {
|
||||
Camera.Parameters parameters = theCamera.getParameters();
|
||||
|
||||
if (parameters == null) {
|
||||
LogUtils.w("Device error: no camera parameters are available. Proceeding without configuration.");
|
||||
LogUtils.w( "Device error: no camera parameters are available. Proceeding without configuration.");
|
||||
return;
|
||||
}
|
||||
|
||||
LogUtils.i("Initial camera parameters: " + parameters.flatten());
|
||||
LogUtils.i( "Initial camera parameters: " + parameters.flatten());
|
||||
|
||||
if (safeMode) {
|
||||
LogUtils.w("In camera config safe mode -- most settings will not be honored");
|
||||
LogUtils.w( "In camera config safe mode -- most settings will not be honored");
|
||||
}
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
@@ -197,7 +197,7 @@ final class CameraConfigurationManager {
|
||||
Camera.Parameters afterParameters = theCamera.getParameters();
|
||||
Camera.Size afterSize = afterParameters.getPreviewSize();
|
||||
if (afterSize != null && (bestPreviewSize.x != afterSize.width || bestPreviewSize.y != afterSize.height)) {
|
||||
LogUtils.w("Camera said it supported preview size " + bestPreviewSize.x + 'x' + bestPreviewSize.y +
|
||||
LogUtils.w( "Camera said it supported preview size " + bestPreviewSize.x + 'x' + bestPreviewSize.y +
|
||||
", but after setting it, preview size is " + afterSize.width + 'x' + afterSize.height);
|
||||
bestPreviewSize.x = afterSize.width;
|
||||
bestPreviewSize.y = afterSize.height;
|
||||
|
||||
@@ -79,7 +79,7 @@ public final class CameraConfigurationUtils {
|
||||
}
|
||||
if (focusMode != null) {
|
||||
if (focusMode.equals(parameters.getFocusMode())) {
|
||||
LogUtils.d( "Focus mode already set to " + focusMode);
|
||||
LogUtils.d( "Focus mode already set to " + focusMode);
|
||||
} else {
|
||||
parameters.setFocusMode(focusMode);
|
||||
}
|
||||
@@ -101,9 +101,9 @@ public final class CameraConfigurationUtils {
|
||||
}
|
||||
if (flashMode != null) {
|
||||
if (flashMode.equals(parameters.getFlashMode())) {
|
||||
LogUtils.d( "Flash mode already set to " + flashMode);
|
||||
LogUtils.d( "Flash mode already set to " + flashMode);
|
||||
} else {
|
||||
LogUtils.d( "Setting flash mode to " + flashMode);
|
||||
LogUtils.d( "Setting flash mode to " + flashMode);
|
||||
parameters.setFlashMode(flashMode);
|
||||
}
|
||||
}
|
||||
@@ -121,13 +121,13 @@ public final class CameraConfigurationUtils {
|
||||
// Clamp value:
|
||||
compensationSteps = Math.max(Math.min(compensationSteps, maxExposure), minExposure);
|
||||
if (parameters.getExposureCompensation() == compensationSteps) {
|
||||
LogUtils.d( "Exposure compensation already set to " + compensationSteps + " / " + actualCompensation);
|
||||
LogUtils.d( "Exposure compensation already set to " + compensationSteps + " / " + actualCompensation);
|
||||
} else {
|
||||
LogUtils.d( "Setting exposure compensation to " + compensationSteps + " / " + actualCompensation);
|
||||
LogUtils.d( "Setting exposure compensation to " + compensationSteps + " / " + actualCompensation);
|
||||
parameters.setExposureCompensation(compensationSteps);
|
||||
}
|
||||
} 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) {
|
||||
List<int[]> supportedPreviewFpsRanges = parameters.getSupportedPreviewFpsRange();
|
||||
LogUtils.d( "Supported FPS ranges: " + toString(supportedPreviewFpsRanges));
|
||||
LogUtils.d( "Supported FPS ranges: " + toString(supportedPreviewFpsRanges));
|
||||
if (supportedPreviewFpsRanges != null && !supportedPreviewFpsRanges.isEmpty()) {
|
||||
int[] suitableFPSRange = null;
|
||||
for (int[] fpsRange : supportedPreviewFpsRanges) {
|
||||
@@ -149,14 +149,14 @@ public final class CameraConfigurationUtils {
|
||||
}
|
||||
}
|
||||
if (suitableFPSRange == null) {
|
||||
LogUtils.d( "No suitable FPS range?");
|
||||
LogUtils.d( "No suitable FPS range?");
|
||||
} else {
|
||||
int[] currentFpsRange = new int[2];
|
||||
parameters.getPreviewFpsRange(currentFpsRange);
|
||||
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 {
|
||||
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],
|
||||
suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
|
||||
}
|
||||
@@ -166,23 +166,23 @@ public final class CameraConfigurationUtils {
|
||||
|
||||
public static void setFocusArea(Camera.Parameters parameters) {
|
||||
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);
|
||||
LogUtils.d( "Setting focus area to : " + toString(middleArea));
|
||||
LogUtils.d( "Setting focus area to : " + toString(middleArea));
|
||||
parameters.setFocusAreas(middleArea);
|
||||
} else {
|
||||
LogUtils.d( "Device does not support focus areas");
|
||||
LogUtils.d( "Device does not support focus areas");
|
||||
}
|
||||
}
|
||||
|
||||
public static void setMetering(Camera.Parameters parameters) {
|
||||
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);
|
||||
LogUtils.d( "Setting metering area to : " + toString(middleArea));
|
||||
LogUtils.d( "Setting metering area to : " + toString(middleArea));
|
||||
parameters.setMeteringAreas(middleArea);
|
||||
} 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) {
|
||||
if (parameters.isVideoStabilizationSupported()) {
|
||||
if (parameters.getVideoStabilization()) {
|
||||
LogUtils.d( "Video stabilization already enabled");
|
||||
LogUtils.d( "Video stabilization already enabled");
|
||||
} else {
|
||||
LogUtils.d( "Enabling video stabilization...");
|
||||
LogUtils.d( "Enabling video stabilization...");
|
||||
parameters.setVideoStabilization(true);
|
||||
}
|
||||
} 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) {
|
||||
if (Camera.Parameters.SCENE_MODE_BARCODE.equals(parameters.getSceneMode())) {
|
||||
LogUtils.d( "Barcode scene mode already set");
|
||||
LogUtils.d( "Barcode scene mode already set");
|
||||
return;
|
||||
}
|
||||
String sceneMode = findSettableValue("scene mode",
|
||||
@@ -224,22 +224,22 @@ public final class CameraConfigurationUtils {
|
||||
return;
|
||||
}
|
||||
if (parameters.getZoom() == zoom) {
|
||||
LogUtils.d( "Zoom is already set to " + zoom);
|
||||
LogUtils.d( "Zoom is already set to " + zoom);
|
||||
} else {
|
||||
LogUtils.d( "Setting zoom to " + zoom);
|
||||
LogUtils.d( "Setting zoom to " + zoom);
|
||||
parameters.setZoom(zoom);
|
||||
}
|
||||
} else {
|
||||
LogUtils.d( "Zoom is not supported");
|
||||
LogUtils.d( "Zoom is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
private static Integer indexOfClosestZoom(Camera.Parameters parameters, double targetZoomRatio) {
|
||||
List<Integer> ratios = parameters.getZoomRatios();
|
||||
LogUtils.d( "Zoom ratios: " + ratios);
|
||||
LogUtils.d( "Zoom ratios: " + ratios);
|
||||
int maxZoom = parameters.getMaxZoom();
|
||||
if (ratios == null || ratios.isEmpty() || ratios.size() != maxZoom + 1) {
|
||||
LogUtils.w( "Invalid zoom ratios!");
|
||||
LogUtils.w( "Invalid zoom ratios!");
|
||||
return null;
|
||||
}
|
||||
double target100 = 100.0 * targetZoomRatio;
|
||||
@@ -252,13 +252,13 @@ public final class CameraConfigurationUtils {
|
||||
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;
|
||||
}
|
||||
|
||||
public static void setInvertColor(Camera.Parameters parameters) {
|
||||
if (Camera.Parameters.EFFECT_NEGATIVE.equals(parameters.getColorEffect())) {
|
||||
LogUtils.d( "Negative effect already set");
|
||||
LogUtils.d( "Negative effect already set");
|
||||
return;
|
||||
}
|
||||
String colorMode = findSettableValue("color effect",
|
||||
@@ -273,7 +273,7 @@ public final class CameraConfigurationUtils {
|
||||
|
||||
List<Camera.Size> rawSupportedSizes = parameters.getSupportedPreviewSizes();
|
||||
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();
|
||||
if (defaultSize == null) {
|
||||
throw new IllegalStateException("Parameters contained no preview size!");
|
||||
@@ -287,7 +287,7 @@ public final class CameraConfigurationUtils {
|
||||
for (Camera.Size size : rawSupportedSizes) {
|
||||
previewSizesString.append(size.width).append('x').append(size.height).append(' ');
|
||||
}
|
||||
LogUtils.d( "Supported preview sizes: " + previewSizesString);
|
||||
LogUtils.d( "Supported preview sizes: " + previewSizesString);
|
||||
}
|
||||
|
||||
double screenAspectRatio;
|
||||
@@ -296,7 +296,7 @@ public final class CameraConfigurationUtils {
|
||||
}else{
|
||||
screenAspectRatio = screenResolution.y / (double) screenResolution.x;
|
||||
}
|
||||
LogUtils.d( "screenAspectRatio: " + screenAspectRatio);
|
||||
LogUtils.d( "screenAspectRatio: " + screenAspectRatio);
|
||||
// Find a suitable size, with max resolution
|
||||
int maxResolution = 0;
|
||||
|
||||
@@ -312,19 +312,19 @@ public final class CameraConfigurationUtils {
|
||||
boolean isCandidatePortrait = realWidth < realHeight;
|
||||
int maybeFlippedWidth = isCandidatePortrait ? realWidth: realHeight ;
|
||||
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;
|
||||
LogUtils.d( "aspectRatio: " + aspectRatio);
|
||||
LogUtils.d( "aspectRatio: " + aspectRatio);
|
||||
double distortion = Math.abs(aspectRatio - screenAspectRatio);
|
||||
LogUtils.d( "distortion: " + distortion);
|
||||
LogUtils.d( "distortion: " + distortion);
|
||||
if (distortion > MAX_ASPECT_DISTORTION) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (maybeFlippedWidth == screenResolution.x && maybeFlippedHeight == screenResolution.y) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ public final class CameraConfigurationUtils {
|
||||
// the CPU is much more powerful.
|
||||
if (maxResPreviewSize != null) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -350,24 +350,24 @@ public final class CameraConfigurationUtils {
|
||||
throw new IllegalStateException("Parameters contained no preview size!");
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
private static String findSettableValue(String name,
|
||||
Collection<String> supportedValues,
|
||||
String... desiredValues) {
|
||||
LogUtils.d( "Requesting " + name + " value from among: " + Arrays.toString(desiredValues));
|
||||
LogUtils.d( "Supported " + name + " values: " + supportedValues);
|
||||
LogUtils.d( "Requesting " + name + " value from among: " + Arrays.toString(desiredValues));
|
||||
LogUtils.d( "Supported " + name + " values: " + supportedValues);
|
||||
if (supportedValues != null) {
|
||||
for (String desiredValue : desiredValues) {
|
||||
if (supportedValues.contains(desiredValue)) {
|
||||
LogUtils.d( "Can set " + name + " to: " + desiredValue);
|
||||
LogUtils.d( "Can set " + name + " to: " + desiredValue);
|
||||
return desiredValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
LogUtils.d( "No supported values match");
|
||||
LogUtils.d( "No supported values match");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.Camera;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.FloatRange;
|
||||
import android.view.SurfaceHolder;
|
||||
|
||||
import com.google.zxing.PlanarYUVLuminanceSource;
|
||||
@@ -31,8 +32,6 @@ import com.king.zxing.util.LogUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import androidx.annotation.FloatRange;
|
||||
|
||||
/**
|
||||
* This object wraps the Camera service object and expects to be the only one talking to it. The
|
||||
* implementation encapsulates the steps needed to take preview-sized images, which are used for
|
||||
@@ -115,8 +114,8 @@ public final class CameraManager {
|
||||
configManager.setDesiredCameraParameters(theCamera, false);
|
||||
} catch (RuntimeException re) {
|
||||
// Driver failed
|
||||
LogUtils.w("Camera rejected parameters. Setting only minimal safe-mode parameters");
|
||||
LogUtils.i( "Resetting to saved camera params: " + parametersFlattened);
|
||||
LogUtils.w( "Camera rejected parameters. Setting only minimal safe-mode parameters");
|
||||
LogUtils.i( "Resetting to saved camera params: " + parametersFlattened);
|
||||
// Reset:
|
||||
if (parametersFlattened != null) {
|
||||
parameters = cameraObject.getParameters();
|
||||
@@ -126,7 +125,7 @@ public final class CameraManager {
|
||||
configManager.setDesiredCameraParameters(theCamera, true);
|
||||
} catch (RuntimeException re2) {
|
||||
// Well, darn. Give up
|
||||
LogUtils.w("Camera rejected even safe-mode parameters! No configuration");
|
||||
LogUtils.w( "Camera rejected even safe-mode parameters! No configuration");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,6 +184,7 @@ public final class CameraManager {
|
||||
previewCallback.setHandler(null, 0);
|
||||
previewing = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -358,7 +358,7 @@ public final class CameraManager {
|
||||
int leftOffset = (screenResolution.x - width) / 2;
|
||||
int topOffset = (screenResolution.y - height) / 2;
|
||||
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;
|
||||
} else {
|
||||
requestedFramingRectWidth = width;
|
||||
|
||||
@@ -27,8 +27,6 @@ import com.king.zxing.util.LogUtils;
|
||||
@SuppressWarnings("deprecation") // camera APIs
|
||||
final class PreviewCallback implements Camera.PreviewCallback {
|
||||
|
||||
private static final String TAG = PreviewCallback.class.getSimpleName();
|
||||
|
||||
private final CameraConfigurationManager configManager;
|
||||
private Handler previewHandler;
|
||||
private int previewMessage;
|
||||
@@ -52,7 +50,7 @@ final class PreviewCallback implements Camera.PreviewCallback {
|
||||
message.sendToTarget();
|
||||
previewHandler = null;
|
||||
} else {
|
||||
LogUtils.d("Got preview callback, but no handler or resolution available");
|
||||
LogUtils.d( "Got preview callback, but no handler or resolution available");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,11 +47,11 @@ public final class OpenCameraInterface {
|
||||
|
||||
int numCameras = Camera.getNumberOfCameras();
|
||||
if (numCameras == 0) {
|
||||
LogUtils.w("No cameras!");
|
||||
LogUtils.w( "No cameras!");
|
||||
return null;
|
||||
}
|
||||
if (cameraId >= numCameras) {
|
||||
LogUtils.w("Requested camera does not exist: " + cameraId);
|
||||
LogUtils.w( "Requested camera does not exist: " + cameraId);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,14 +20,12 @@ import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.FloatRange;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.FloatRange;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.BinaryBitmap;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
@@ -650,7 +648,7 @@ public final class CodeUtils {
|
||||
* @param textColor
|
||||
* @return
|
||||
*/
|
||||
private static Bitmap addCode(Bitmap src, String code, int textSize, @ColorInt int textColor, int offset) {
|
||||
private static Bitmap addCode(Bitmap src,String code,int textSize,@ColorInt int textColor,int offset) {
|
||||
if (src == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//App
|
||||
def app_version = [:]
|
||||
app_version.versionCode = 26
|
||||
app_version.versionName = "1.1.9-androidx"
|
||||
app_version.versionCode = 25 //androidx 26
|
||||
app_version.versionName = "1.1.9"
|
||||
ext.app_version = app_version
|
||||
|
||||
//build version
|
||||
@@ -16,37 +16,35 @@ ext.deps = [:]
|
||||
|
||||
// App dependencies
|
||||
def versions = [:]
|
||||
//AndroidX
|
||||
versions.material = "1.2.0-alpha01"
|
||||
versions.appcompat = "1.1.0"
|
||||
//support
|
||||
versions.supportLibrary = "28.0.0"
|
||||
versions.constraintLayout = "1.1.3"
|
||||
|
||||
//test
|
||||
versions.junit = "1.1.0"
|
||||
versions.test = "1.2.0"
|
||||
versions.runner = "1.2.0"
|
||||
versions.espresso = "3.2.0"
|
||||
versions.junit = "4.12"
|
||||
versions.runner = "1.0.2"
|
||||
versions.rules = "1.0.2"
|
||||
versions.espresso = "3.0.2"
|
||||
|
||||
//zxing
|
||||
versions.zxing = "3.3.3"
|
||||
|
||||
versions.easypermissions = "3.0.0"
|
||||
versions.easypermissions = "2.0.1"
|
||||
|
||||
|
||||
ext.versions = versions
|
||||
|
||||
//support
|
||||
def support = [:]
|
||||
support.design = "com.google.android.material:material:$versions.material"
|
||||
support.appcompat = "androidx.appcompat:appcompat:$versions.appcompat"
|
||||
support.constraintlayout = "androidx.constraintlayout:constraintlayout:$versions.constraintLayout"
|
||||
support.design = "com.android.support:design:$versions.supportLibrary"
|
||||
support.appcompat = "com.android.support:appcompat-v7:$versions.supportLibrary"
|
||||
support.constraintlayout = "com.android.support.constraint:constraint-layout:$versions.constraintLayout"
|
||||
deps.support = support
|
||||
|
||||
//test
|
||||
def test = [:]
|
||||
test.junit = "androidx.test.ext:junit:$versions.junit"
|
||||
test.test = "androidx.test:core:$versions.test"
|
||||
test.runner = "androidx.test:runner:$versions.runner"
|
||||
test.espresso = "androidx.test.espresso:espresso-core:$versions.espresso"
|
||||
test.junit = "junit:junit:$versions.junit"
|
||||
test.runner = "com.android.support.test:runner:$versions.runner"
|
||||
test.espresso = "com.android.support.test.espresso:espresso-core:$versions.espresso"
|
||||
deps.test = test
|
||||
|
||||
//zxing
|
||||
|
||||
Reference in New Issue
Block a user