Skip to content

Commit

Permalink
更新CameraX至v1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jenly1314 committed Apr 15, 2023
1 parent 863f1ab commit 2359695
Show file tree
Hide file tree
Showing 33 changed files with 734 additions and 319 deletions.
83 changes: 45 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,44 @@ ZXingLite for Android 是ZXing的精简极速版,基于ZXing库优化扫码和

## ViewfinderView属性说明

| 属性 | 属性类型 | 默认值 | 属性说明 |
| :------|:----------| :------ | :------ |
| maskColor | color |<font color=#000000>#60000000</font>| 扫描区外遮罩的颜色 |
| frameColor | color |<font color=#1FB3E2>#7F1FB3E2</font>| 扫描区边框的颜色 |
| cornerColor | color |<font color=#1FB3E2>#FF1FB3E2</font>| 扫描区边角的颜色 |
| laserColor | color |<font color=#1FB3E2>#FF1FB3E2</font>| 扫描区激光线的颜色 |
| labelText | string | | 扫描提示文本信息 |
| labelTextColor | color |<font color=#C0C0C0>#FFC0C0C0</font>| 提示文本字体颜色 |
| labelTextSize | dimension |14sp| 提示文本字体大小 |
| labelTextPadding | dimension |24dp| 提示文本距离扫描区的间距 |
| labelTextWidth | dimension | | 提示文本的宽度,默认为View的宽度 |
| labelTextLocation | enum |bottom| 提示文本显示位置 |
| frameWidth | dimension | | 扫码框宽度 |
| frameHeight | dimension | | 扫码框高度 |
| laserStyle | enum | line | 扫描激光的样式 |
| gridColumn | integer | 20 | 网格扫描激光列数 |
| gridHeight | integer | 40dp | 网格扫描激光高度,为0dp时,表示动态铺满 |
| cornerRectWidth | dimension | 4dp | 扫描区边角的宽 |
| cornerRectHeight | dimension | 16dp | 扫描区边角的高 |
| 属性 | 属性类型 | 默认值 | 属性说明 |
|:------------------------|:----------| :------ | :------ |
| maskColor | color |<font color=#000000>#60000000</font>| 扫描区外遮罩的颜色 |
| frameColor | color |<font color=#1FB3E2>#7F1FB3E2</font>| 扫描区边框的颜色 |
| cornerColor | color |<font color=#1FB3E2>#FF1FB3E2</font>| 扫描区边角的颜色 |
| laserColor | color |<font color=#1FB3E2>#FF1FB3E2</font>| 扫描区激光线的颜色 |
| labelText | string | | 扫描提示文本信息 |
| labelTextColor | color |<font color=#C0C0C0>#FFC0C0C0</font>| 提示文本字体颜色 |
| labelTextSize | dimension |14sp| 提示文本字体大小 |
| labelTextPadding | dimension |24dp| 提示文本距离扫描区的间距 |
| labelTextWidth | dimension | | 提示文本的宽度,默认为View的宽度 |
| labelTextLocation | enum |bottom| 提示文本显示位置 |
| frameWidth | dimension | | 扫码框宽度 |
| frameHeight | dimension | | 扫码框高度 |
| laserStyle | enum | line | 扫描激光的样式 |
| gridColumn | integer | 20 | 网格扫描激光列数 |
| gridHeight | integer | 40dp | 网格扫描激光高度,为0dp时,表示动态铺满 |
| cornerRectWidth | dimension | 4dp | 扫描区边角的宽 |
| cornerRectHeight | dimension | 16dp | 扫描区边角的高 |
| scannerLineMoveDistance | dimension | 2dp | 扫描线每次移动距离 |
| scannerLineHeight | dimension | 5dp | 扫描线高度 |
| frameLineWidth | dimension | 1dp | 边框线宽度 |
| scannerAnimationDelay | integer | 20 | 扫描动画延迟间隔时间,单位:毫秒 |
| frameRatio | float | 0.625f | 扫码框与屏幕占比 |
| framePaddingLeft | dimension | 0 | 扫码框左边的内间距 |
| framePaddingTop | dimension | 0 | 扫码框上边的内间距 |
| framePaddingRight | dimension | 0 | 扫码框右边的内间距 |
| framePaddingBottom | dimension | 0 | 扫码框下边的内间距 |
| frameGravity | enum | center | 扫码框对齐方式 |
| pointColor | color | <font color=#1FB3E2>#FF1FB3E2</font> | 结果点的颜色 |
| pointStrokeColor | color | <font color=#FFFFFF>#FFFFFFFF</font> | 结果点描边的颜色 |
| pointRadius | dimension | 15dp | 结果点的半径 |
| pointStrokeRatio | float | 1.2 | 结果点描边半径与结果点半径的比例 |
| pointDrawable | reference | | 结果点自定义图片 |
| showPointAnim | boolean | true | 是否显示结果点的动画 |
| laserDrawable | reference | | 扫描激光自定义图片 |
| viewfinderStyle | enum | classic | 取景框样式;支持:classic:经典样式(带扫码框那种)、popular:流行样式(不带扫码框) |
| scannerLineHeight | dimension | 5dp | 扫描线高度 |
| frameLineWidth | dimension | 1dp | 边框线宽度 |
| scannerAnimationDelay | integer | 20 | 扫描动画延迟间隔时间,单位:毫秒 |
| frameRatio | float | 0.625f | 扫码框与屏幕占比 |
| framePaddingLeft | dimension | 0 | 扫码框左边的内间距 |
| framePaddingTop | dimension | 0 | 扫码框上边的内间距 |
| framePaddingRight | dimension | 0 | 扫码框右边的内间距 |
| framePaddingBottom | dimension | 0 | 扫码框下边的内间距 |
| frameGravity | enum | center | 扫码框对齐方式 |
| pointColor | color | <font color=#1FB3E2>#FF1FB3E2</font> | 结果点的颜色 |
| pointStrokeColor | color | <font color=#FFFFFF>#FFFFFFFF</font> | 结果点描边的颜色 |
| pointRadius | dimension | 15dp | 结果点的半径 |
| pointStrokeRatio | float | 1.2 | 结果点描边半径与结果点半径的比例 |
| pointDrawable | reference | | 结果点自定义图片 |
| showPointAnim | boolean | true | 是否显示结果点的动画 |
| laserDrawable | reference | | 扫描激光自定义图片 |
| laserDrawableRatio | float | 0.625f | 激光扫描图片与屏幕占比 |
| viewfinderStyle | enum | classic | 取景框样式;支持:classic:经典样式(带扫码框那种)、popular:流行样式(不带扫码框) |


## 引入
Expand All @@ -83,7 +84,7 @@ allprojects {

```gradle
// AndroidX 版本
implementation 'com.github.jenly1314:zxing-lite:2.3.1'
implementation 'com.github.jenly1314:zxing-lite:2.4.0'
```

Expand Down Expand Up @@ -175,7 +176,7 @@ implementation 'com.king.zxing:zxing-lite:1.1.9'
// 获取CameraScan,扫码相关的配置设置。CameraScan里面包含部分支持链式调用的方法,即调用返回是CameraScan本身的一些配置建议在startCamera之前调用。
getCameraScan().setPlayBeep(true)//设置是否播放音效,默认为false
.setVibrate(true)//设置是否震动,默认为false
.setCameraConfig(new CameraConfig())//设置相机配置信息,CameraConfig可覆写options方法自定义配置
.setCameraConfig(new ResolutionCameraConfig(this))//设置相机配置信息,CameraConfig可覆写options方法自定义配置
.setNeedAutoZoom(false)//二维码太小时可自动缩放,默认为false
.setNeedTouchZoom(true)//支持多指触摸捏合缩放,默认为true
.setDarkLightLux(45f)//设置光线足够暗的阈值(单位:lux),需要通过{@link #bindFlashlightView(View)}绑定手电筒才有效
Expand Down Expand Up @@ -404,6 +405,12 @@ dependencies {

## 版本记录

#### v2.4.0:2023-4-15
* 优化CameraScan的缺省配置(CameraConfig相关配置)
* 优化ViewfinderView自定义属性(新增laserDrawableRatio)
* 优化ImageAnalyzer中YUV数据的处理
* 更新CameraX至v1.2.2

#### v2.3.1:2023-3-4
* 更新CameraX至v1.2.1
* 更新Gradle至v7.5
Expand Down
26 changes: 12 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
apply plugin: 'com.android.application'
//apply plugin: 'kotlin-android'
//apply plugin: 'kotlin-android-extensions'
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}

android {
compileSdkVersion build_versions.compileSdk
buildToolsVersion build_versions.buildTools
namespace 'com.king.zxing.app'
compileSdk build_versions.compileSdk

defaultConfig {
applicationId "com.king.zxing.app"
minSdkVersion build_versions.minSdk
targetSdkVersion build_versions.targetSdk
minSdk build_versions.minSdk
targetSdk build_versions.targetSdk
versionCode app_version.versionCode
versionName app_version.versionName

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -24,22 +28,16 @@ android {
abortOnError false
}


compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

// kotlinOptions {
// jvmTarget = '1.8'
// }
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation deps.test.junit
androidTestImplementation deps.test.runner
androidTestImplementation deps.test.android_ext_junit
androidTestImplementation deps.test.espresso

implementation deps.androidx.design
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 36,
"versionName": "2.3.1",
"versionCode": 37,
"versionName": "2.4.0",
"outputFile": "app-release.apk"
}
],
Expand Down
10 changes: 4 additions & 6 deletions app/src/main/java/com/king/zxing/app/CustomCaptureActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void initCameraScan() {
getCameraScan().setPlayBeep(true)//设置是否播放音效,默认为false
.setVibrate(true)//设置是否震动,默认为false
// .setCameraConfig(new CameraConfig())//设置相机配置信息,CameraConfig可覆写options方法自定义配置
.setCameraConfig(new ResolutionCameraConfig(this))//设置CameraConfig,可以根据自己的需求去自定义配置
// .setCameraConfig(new ResolutionCameraConfig(this))//设置CameraConfig,可以根据自己的需求去自定义配置
.setNeedAutoZoom(false)//二维码太小时可自动缩放,默认为false
.setNeedTouchZoom(true)//支持多指触摸捏合缩放,默认为true
.setDarkLightLux(45f)//设置光线足够暗的阈值(单位:lux),需要通过{@link #bindFlashlightView(View)}绑定手电筒才有效
Expand Down Expand Up @@ -117,12 +117,10 @@ public boolean onScanResultCallback(Result result) {
}

private void showToast(String text){
if(toast == null){
toast = Toast.makeText(this,text,Toast.LENGTH_SHORT);
}else{
toast.setText(text);
toast.setDuration(Toast.LENGTH_SHORT);
if(toast != null){
toast.cancel();
}
toast = Toast.makeText(this,text,Toast.LENGTH_SHORT);
toast.show();
}

Expand Down
14 changes: 8 additions & 6 deletions app/src/main/java/com/king/zxing/app/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@


import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
Expand Down Expand Up @@ -72,6 +74,8 @@ public class MainActivity extends AppCompatActivity implements EasyPermissions.P

private Toast toast;

private ExecutorService executor = Executors.newSingleThreadExecutor();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -97,12 +101,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}

private void showToast(String text){
if(toast == null){
toast = Toast.makeText(this,text,Toast.LENGTH_SHORT);
}else{
toast.setDuration(Toast.LENGTH_SHORT);
toast.setText(text);
if(toast != null){
toast.cancel();
}
toast = Toast.makeText(this,text,Toast.LENGTH_SHORT);
toast.show();
}

Expand Down Expand Up @@ -165,7 +167,7 @@ private void checkCameraPermissions(){
}

private void asyncThread(Runnable runnable){
new Thread(runnable).start();
executor.execute(runnable);
}

/**
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion app/src/main/res/layout/custom_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
android:id="@+id/viewfinderView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:viewfinderStyle="popular"/>
app:viewfinderStyle="popular"
app:laserStyle="image"
app:laserDrawableRatio="0.8"
app:laserDrawable="@drawable/ic_laser_line"/>
<ImageView
android:id="@+id/ivFlash"
android:layout_width="wrap_content"
Expand Down
57 changes: 7 additions & 50 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,53 +1,10 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

apply from: 'versions.gradle'

repositories {
google()
mavenCentral()
}


dependencies {
classpath "com.android.tools.build:gradle:$versions.gralde"
// classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
// classpath "com.novoda:bintray-release:$versions.bintray_release"
classpath "com.vanniktech:gradle-maven-publish-plugin:$versions.mavenPublish"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}

allprojects {
plugins.withId("com.vanniktech.maven.publish") {
mavenPublish {
sonatypeHost = "S01"
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

allprojects {
tasks.withType(Javadoc) {
options{
encoding "UTF-8"
charSet 'UTF-8'
links "http://docs.oracle.com/javase/8/docs/api"
}

options.addStringOption('Xdoclint:none', '-quiet')
failOnError false
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
// id 'org.jetbrains.dokka' version '1.7.0' apply false
id 'com.vanniktech.maven.publish' version '0.22.0' apply false
}
6 changes: 6 additions & 0 deletions change_log.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## 版本记录

#### v2.4.0:2023-4-15
* 优化CameraScan的缺省配置(CameraConfig相关配置)
* 优化ViewfinderView自定义属性(新增laserDrawableRatio)
* 优化ImageAnalyzer中YUV数据的处理
* 更新CameraX至v1.2.2

#### v2.3.1:2023-3-4
* 更新CameraX至v1.2.1
* 更新Gradle至v7.5
Expand Down
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ org.gradle.jvmargs = -Xmx1536m
android.useAndroidX=true
android.enableJetifier=true

VERSION_NAME=2.3.1
VERSION_CODE=36
VERSION_NAME=2.4.0
VERSION_CODE=37
GROUP=com.github.jenly1314

POM_DESCRIPTION=ZXingLite for Android
Expand All @@ -35,6 +35,8 @@ POM_DEVELOPER_ID=jenly
POM_DEVELOPER_NAME=Jenly Yu
POM_DEVELOPER_URL=https://github.com/jenly1314/

SONATYPE_HOST=S01

RELEASE_REPOSITORY_URL=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
SNAPSHOT_REPOSITORY_URL=https://s01.oss.sonatype.org/content/repositories/snapshots/

Expand Down
19 changes: 18 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
include ':app', ':zxing-lite'
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}

rootProject.name = "ZXingLite"
include ':app'
include ':zxing-lite'
Loading

0 comments on commit 2359695

Please sign in to comment.