暴露ViewfinderView中的labelText相关属性,支持代码修改labelText相关属性。
This commit is contained in:
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@@ -36,17 +36,17 @@ ZXingLite for Android 是ZXing的精简版,优化扫码和生成二维码功
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.king.zxing</groupId>
|
<groupId>com.king.zxing</groupId>
|
||||||
<artifactId>zxing-lite</artifactId>
|
<artifactId>zxing-lite</artifactId>
|
||||||
<version>1.0.2</version>
|
<version>1.0.3</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
### Gradle:
|
### Gradle:
|
||||||
```gradle
|
```gradle
|
||||||
implementation 'com.king.zxing:zxing-lite:1.0.2'
|
implementation 'com.king.zxing:zxing-lite:1.0.3'
|
||||||
```
|
```
|
||||||
### Lvy:
|
### Lvy:
|
||||||
```lvy
|
```lvy
|
||||||
<dependency org='com.king.zxing' name='zxing-lite' rev='1.0.2'>
|
<dependency org='com.king.zxing' name='zxing-lite' rev='1.0.3'>
|
||||||
<artifact name='$AID' ext='pom'></artifact>
|
<artifact name='$AID' ext='pom'></artifact>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
@@ -84,6 +84,9 @@ api 'com.google.zxing:core:3.3.3'
|
|||||||
|
|
||||||
代码示例 (二维码/条形码)
|
代码示例 (二维码/条形码)
|
||||||
```Java
|
```Java
|
||||||
|
//跳转的默认扫码界面
|
||||||
|
startActivityForResult(new Intent(context,CaptureActivity.class),requestCode);
|
||||||
|
|
||||||
//生成二维码
|
//生成二维码
|
||||||
CodeUtils.createQRCode(content,600,logo);
|
CodeUtils.createQRCode(content,600,logo);
|
||||||
//生成条形码
|
//生成条形码
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ 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.ColorRes;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.text.Layout;
|
import android.text.Layout;
|
||||||
import android.text.StaticLayout;
|
import android.text.StaticLayout;
|
||||||
@@ -81,10 +82,10 @@ public final class ViewfinderView extends View {
|
|||||||
//扫描区域提示文本
|
//扫描区域提示文本
|
||||||
private String labelText;
|
private String labelText;
|
||||||
//扫描区域提示文本颜色
|
//扫描区域提示文本颜色
|
||||||
private final int labelTextColor;
|
private int labelTextColor;
|
||||||
private final float labelTextSize;
|
private float labelTextSize;
|
||||||
public static int scannerStart = 0;
|
public int scannerStart = 0;
|
||||||
public static int scannerEnd = 0;
|
public int scannerEnd = 0;
|
||||||
private boolean isShowResultPoint;
|
private boolean isShowResultPoint;
|
||||||
|
|
||||||
private List<ResultPoint> possibleResultPoints;
|
private List<ResultPoint> possibleResultPoints;
|
||||||
@@ -142,6 +143,22 @@ public final class ViewfinderView extends View {
|
|||||||
this.cameraManager = cameraManager;
|
this.cameraManager = cameraManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLabelText(String labelText) {
|
||||||
|
this.labelText = labelText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabelTextColor(int color) {
|
||||||
|
this.labelTextColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabelTextColorResource(@ColorRes int id){
|
||||||
|
this.labelTextColor = ContextCompat.getColor(getContext(),id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabelTextSize(float textSize) {
|
||||||
|
this.labelTextSize = textSize;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("DrawAllocation")
|
@SuppressLint("DrawAllocation")
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(Canvas canvas) {
|
public void onDraw(Canvas canvas) {
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ public final class CameraManager {
|
|||||||
private int requestedCameraId = OpenCameraInterface.NO_REQUESTED_CAMERA;
|
private int requestedCameraId = OpenCameraInterface.NO_REQUESTED_CAMERA;
|
||||||
private int requestedFramingRectWidth;
|
private int requestedFramingRectWidth;
|
||||||
private int requestedFramingRectHeight;
|
private int requestedFramingRectHeight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preview frames are delivered here, which we pass on to the registered handler. Make sure to
|
* Preview frames are delivered here, which we pass on to the registered handler. Make sure to
|
||||||
* clear the handler so it will only receive one message.
|
* clear the handler so it will only receive one message.
|
||||||
@@ -229,9 +230,11 @@ public final class CameraManager {
|
|||||||
int width = findDesiredDimensionInRange(screenResolution.x, MIN_FRAME_WIDTH, MAX_FRAME_WIDTH);
|
int width = findDesiredDimensionInRange(screenResolution.x, MIN_FRAME_WIDTH, MAX_FRAME_WIDTH);
|
||||||
int height = findDesiredDimensionInRange(screenResolution.y, MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT);
|
int height = findDesiredDimensionInRange(screenResolution.y, MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT);
|
||||||
|
|
||||||
int leftOffset = (screenResolution.x - width) / 2;
|
int size = Math.min(width,height);
|
||||||
int topOffset = (screenResolution.y - height) / 2;
|
|
||||||
framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);
|
int leftOffset = (screenResolution.x - size) / 2;
|
||||||
|
int topOffset = (screenResolution.y - size) / 2;
|
||||||
|
framingRect = new Rect(leftOffset, topOffset, leftOffset + size, topOffset + size);
|
||||||
Log.d(TAG, "Calculated framing rect: " + framingRect);
|
Log.d(TAG, "Calculated framing rect: " + framingRect);
|
||||||
}
|
}
|
||||||
return framingRect;
|
return framingRect;
|
||||||
@@ -334,9 +337,12 @@ public final class CameraManager {
|
|||||||
if (rect == null) {
|
if (rect == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
int size = Math.min(width,height);
|
||||||
|
int left = (width-size)/2;
|
||||||
|
int top = (height-size)/2;
|
||||||
// Go ahead and assume it's YUV rather than die.
|
// Go ahead and assume it's YUV rather than die.
|
||||||
return new PlanarYUVLuminanceSource(data, width, height, 0, 0,
|
return new PlanarYUVLuminanceSource(data, width, height, left, top,
|
||||||
width, height, false);
|
left + size, top + size, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
//App
|
//App
|
||||||
def app_version = [:]
|
def app_version = [:]
|
||||||
app_version.versionCode = 3
|
app_version.versionCode = 4
|
||||||
app_version.versionName = "1.0.2"
|
app_version.versionName = "1.0.3"
|
||||||
ext.app_version = app_version
|
ext.app_version = app_version
|
||||||
|
|
||||||
//build version
|
//build version
|
||||||
|
|||||||
Reference in New Issue
Block a user