更新CameraX至v1.2.2

This commit is contained in:
Jenly
2023-04-15 16:45:34 +08:00
parent 863f1ab1b4
commit 2359695964
33 changed files with 734 additions and 319 deletions

View File

@@ -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
@@ -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

Binary file not shown.

View File

@@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 36,
"versionName": "2.3.1",
"versionCode": 37,
"versionName": "2.4.0",
"outputFile": "app-release.apk"
}
],

View File

@@ -77,7 +77,7 @@ public class CustomCaptureActivity extends CaptureActivity {
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)}绑定手电筒才有效
@@ -117,12 +117,10 @@ public class CustomCaptureActivity extends CaptureActivity {
}
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();
}

View File

@@ -32,6 +32,8 @@ import com.king.zxing.util.LogUtils;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
@@ -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);
@@ -97,12 +101,10 @@ public class MainActivity extends AppCompatActivity implements EasyPermissions.P
}
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();
}
@@ -165,7 +167,7 @@ public class MainActivity extends AppCompatActivity implements EasyPermissions.P
}
private void asyncThread(Runnable runnable){
new Thread(runnable).start();
executor.execute(runnable);
}
/**

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@@ -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"