Skip to content

Commit

Permalink
1.新增颜色修改gif
Browse files Browse the repository at this point in the history
2.更新过时方法
  • Loading branch information
yuzhiqiang1993 committed May 30, 2018
1 parent dc66b27 commit 348bb98
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 31 deletions.
21 changes: 10 additions & 11 deletions app/src/main/java/com/yzq/zxing/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,20 @@ public void onClick(View v) {
@Override
public void onAction(List<String> permissions) {
Intent intent = new Intent(MainActivity.this, CaptureActivity.class);

/*ZxingConfig是配置类 可以设置是否显示底部布局,闪光灯,相册,是否播放提示音 震动 扫描框颜色等动能
/*ZxingConfig是配置类
*可以设置是否显示底部布局,闪光灯,相册,
* 是否播放提示音 震动
* 设置扫描框颜色等
* 也可以不传这个参数
*
* */

ZxingConfig config = new ZxingConfig();
config.setPlayBeep(true);
config.setShake(true);
config.setDecodeBarCode(false);
config.setReactColor(R.color.colorAccent);
//config.setFrameLineColor(R.color.colorAccent);
config.setFullScreenScan(true);
config.setPlayBeep(true);//是否播放扫描声音 默认为true
config.setShake(true);//是否震动 默认为true
config.setDecodeBarCode(false);//是否扫描条形码 默认为true
config.setReactColor(R.color.white);//设置扫描框四个角的颜色 默认为淡蓝色
config.setFrameLineColor(R.color.white);//设置扫描框边框颜色 默认无色
config.setFullScreenScan(false);//是否全屏扫描 默认为true 设为false则只会在扫描框中扫描
intent.putExtra(Constant.INTENT_ZXING_CONFIG, config);

startActivityForResult(intent, REQUEST_CODE_SCAN);
}
})
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="white">#ffffff</color>
</resources>
Binary file added img/edit_frameline_color.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/edit_react_color.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public final class ViewfinderView extends View {
private int resultPointColor; // 特征点的颜色
private int statusColor; // 提示文字颜色
private int reactColor;//四个角的颜色
private int scanLineColor;//扫描线的颜色
private int frameLineColor = -1;//扫描框边线颜色



private List<ResultPoint> possibleResultPoints;
Expand Down Expand Up @@ -71,16 +70,7 @@ public ViewfinderView(Context context, AttributeSet attrs) {
public void setZxingConfig(ZxingConfig config) {

this.config = config;

// maskColor = ContextCompat.getColor(getContext(), config.getMaskViewColor());
reactColor = ContextCompat.getColor(getContext(), config.getReactColor());
// scanLineColor = ContextCompat.getColor(getContext(), config.getScanLineColor());

if (config.getFrameLineColor() != -1) {
frameLineColor = ContextCompat.getColor(getContext(), config.getFrameLineColor());
}


}


Expand All @@ -90,16 +80,10 @@ public ViewfinderView(Context context, @Nullable AttributeSet attrs, int defStyl

paint = new Paint(Paint.ANTI_ALIAS_FLAG);
Resources resources = getResources();

maskColor = ContextCompat.getColor(getContext(), R.color.viewfinder_mask);
//resources.getColor(R.color.viewfinder_mask);
resultColor = ContextCompat.getColor(getContext(), R.color.result_view);
// resources.getColor(R.color.result_view);
resultPointColor = ContextCompat.getColor(getContext(), R.color.possible_result_points);
//resources.getColor(R.color.possible_result_points);
statusColor = ContextCompat.getColor(getContext(), R.color.status_text);
//resources.getColor(R.color.status_text);


possibleResultPoints = new ArrayList<ResultPoint>(10);
lastPossibleResultPoints = null;
Expand Down Expand Up @@ -217,13 +201,12 @@ private void drawFrameBounds(Canvas canvas, Rect frame) {
/*扫描框的边框线*/


if (frameLineColor != -1) {
paint.setColor(frameLineColor);
if (config.getFrameLineColor() != -1) {
paint.setColor(ContextCompat.getColor(getContext(),config.getFrameLineColor()));
paint.setStrokeWidth(2);
paint.setStyle(Paint.Style.STROKE);
canvas.drawRect(frame, paint);


}


Expand Down

0 comments on commit 348bb98

Please sign in to comment.