暴露ViewfinderView中的labelText相关属性,支持代码修改labelText相关属性。
This commit is contained in:
@@ -28,6 +28,7 @@ import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.Layout;
|
||||
import android.text.StaticLayout;
|
||||
@@ -81,10 +82,10 @@ public final class ViewfinderView extends View {
|
||||
//扫描区域提示文本
|
||||
private String labelText;
|
||||
//扫描区域提示文本颜色
|
||||
private final int labelTextColor;
|
||||
private final float labelTextSize;
|
||||
public static int scannerStart = 0;
|
||||
public static int scannerEnd = 0;
|
||||
private int labelTextColor;
|
||||
private float labelTextSize;
|
||||
public int scannerStart = 0;
|
||||
public int scannerEnd = 0;
|
||||
private boolean isShowResultPoint;
|
||||
|
||||
private List<ResultPoint> possibleResultPoints;
|
||||
@@ -142,6 +143,22 @@ public final class ViewfinderView extends View {
|
||||
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")
|
||||
@Override
|
||||
public void onDraw(Canvas canvas) {
|
||||
@@ -329,7 +346,7 @@ public final class ViewfinderView extends View {
|
||||
isShowResultPoint = showResultPoint;
|
||||
}
|
||||
|
||||
// /**
|
||||
// /**
|
||||
// * Draw a bitmap with the result points highlighted instead of the live scanning display.
|
||||
// *
|
||||
// * @param barcode An image of the decoded barcode.
|
||||
|
||||
@@ -58,6 +58,7 @@ public final class CameraManager {
|
||||
private int requestedCameraId = OpenCameraInterface.NO_REQUESTED_CAMERA;
|
||||
private int requestedFramingRectWidth;
|
||||
private int requestedFramingRectHeight;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -229,9 +230,11 @@ public final class CameraManager {
|
||||
int width = findDesiredDimensionInRange(screenResolution.x, MIN_FRAME_WIDTH, MAX_FRAME_WIDTH);
|
||||
int height = findDesiredDimensionInRange(screenResolution.y, MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT);
|
||||
|
||||
int leftOffset = (screenResolution.x - width) / 2;
|
||||
int topOffset = (screenResolution.y - height) / 2;
|
||||
framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);
|
||||
int size = Math.min(width,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);
|
||||
}
|
||||
return framingRect;
|
||||
@@ -334,9 +337,12 @@ public final class CameraManager {
|
||||
if (rect == 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.
|
||||
return new PlanarYUVLuminanceSource(data, width, height, 0, 0,
|
||||
width, height, false);
|
||||
return new PlanarYUVLuminanceSource(data, width, height, left, top,
|
||||
left + size, top + size, false);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user