Skip to content

Commit

Permalink
release 1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hupei committed Aug 14, 2017
1 parent 98de7c9 commit 525b19c
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 54 deletions.
44 changes: 15 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,30 @@

### 四、引用

## 1、在线
- 本库依赖使用Gradle构建时添加一下即可,已依赖`zxing:core:3.3.0`
## 1、在线 已集成`zxing:core:3.3.0`
- 本库依赖使用Gradle构建时添加一下即可

```javascript
compile 'com.mylhyl:zxingscanner:1.5.0'
compile 'com.mylhyl:zxingscanner:1.5.1'
```

## 2、离线jar,需要手动添加 Zxing 核心库
核心库二种方式:

1、[最新Zxing核心库点击查看](http://jcenter.bintray.com/com/google/zxing/core/),使用Gradle构建时如下:
- [jar包](https://github.com/mylhyl/Android-Zxing/tree/master/preview/lib)
- 也可自己打包jar文件打开终端,切换置项目根据目录,执行命令:gradlew makeJar
- [最新Zxing核心库点击查看](http://jcenter.bintray.com/com/google/zxing/core/)取出aar
- 也可使用Gradle构建时如下:

```javascript
compile 'com.google.zxing:core:3.3.0'
```

2、本地依赖jar文件
win终端执行:gradlew makeJar

[gradle makeJar](http://blog.csdn.net/hupei/article/details/51886221) 或者参考下图,在android studio中执行

![这里写图片描述](http://img.blog.csdn.net/20160711135615587)

- [直接下载jar](preview)

###五、使用
### 五、使用
直接在`layout xml`使用`ScannerView`即可

```xml
Expand Down Expand Up @@ -124,8 +122,14 @@ Bitmap bitmap = new QREncode.Builder(this)
.build().encodeAsBitmap();

```
解析图中二维码

###六、样式设置
```java
public static void decodeQR(String picturePath, OnScannerCompletionListener listener);
public static void decodeQR(Bitmap srcBitmap, final OnScannerCompletionListener listener)
```

### 六、样式设置
<table class="table table-bordered table-striped table-condensed">
<tr>
<td>方法名</td>
Expand Down Expand Up @@ -220,21 +224,3 @@ Bitmap bitmap = new QREncode.Builder(this)
QQ交流群:630413339 [点击链接加入群Android-Zxing](https://jq.qq.com/?_wv=1027&k=4BR729O)

<img src="preview/qrcode.png"/>

### 八、版本更新

> 1.4.0 增加扫描类型`setScanMode`
> 1.3.1 优化代码
> 1.3.0 生成二维码增加logo
> 1.2.2 修复扫描提示文字颜色无效、支持自动换行
> 1.2.1 修复依赖提示`Failed to resolve:Android-Zxing:zxing:3.2.2`的错误
> 1.2.0 生成二维码增加`setAddressBookUri(Uri contactUri)`设置联系人`Uri`方法,更方便的使用
> 1.1.3 重新装饰`ParsedResult`各实现类并`Serializable`
> 1.1.2 修复锁屏`onPause`生命周期没有摧毁,导致`onResume`时抛出`RuntimeException`异常
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added preview/lib/zxingscanner-1.5.1.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class MainActivity extends BasicActivity {
private static final int PICK_CONTACT = 1;
private TextView tvResult;
private ImageView imageView;
private ToggleButton toggleButton, toggleButton2;
private int laserMode;
private ToggleButton toggleButton;
private int laserMode, scanMode;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -41,8 +41,8 @@ protected void onCreate(Bundle savedInstanceState) {
tvResult = (TextView) findViewById(R.id.textView);
imageView = (ImageView) findViewById(R.id.imageView);

toggleButton = (ToggleButton) findViewById(R.id.toggleButton1);
toggleButton2 = (ToggleButton) findViewById(R.id.toggleButton2);
toggleButton = (ToggleButton) findViewById(R.id.toggleButton);

final CheckBox checkBox = (CheckBox) findViewById(R.id.checkBox);
RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radioGroup);
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
Expand All @@ -62,6 +62,24 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {
}
});

RadioGroup radioGroup1 = (RadioGroup) findViewById(R.id.radioGroup1);
radioGroup1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.radioButton4:
scanMode = ScannerActivity.EXTRA_SCAN_MODE_0;
break;
case R.id.radioButton5:
scanMode = ScannerActivity.EXTRA_SCAN_MODE_1;
break;
case R.id.radioButton6:
scanMode = ScannerActivity.EXTRA_SCAN_MODE_2;
break;
}
}
});

findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -74,8 +92,7 @@ public void onClick(View v) {
} else {
//权限已经被授予,在这里直接写要执行的相应方法即可
ScannerActivity.gotoActivity(MainActivity.this,
checkBox.isChecked(), laserMode, toggleButton.isChecked()
, !toggleButton2.isChecked());
checkBox.isChecked(), laserMode, scanMode, !toggleButton.isChecked());
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.google.zxing.Result;
import com.mylhyl.zxing.scanner.ScannerView;
import com.mylhyl.zxing.scanner.camera.open.CameraFacing;
import com.mylhyl.zxing.scanner.common.Scanner;
import com.mylhyl.zxing.scanner.decode.QRDecode;
import com.mylhyl.zxing.scanner.sample.picture.PickPictureTotalActivity;
Expand All @@ -36,12 +35,16 @@ public class ScannerActivity extends DeCodeActivity {
public static final int EXTRA_LASER_LINE_MODE_1 = 1;
public static final int EXTRA_LASER_LINE_MODE_2 = 2;

public static final int EXTRA_SCAN_MODE_0 = 0;
public static final int EXTRA_SCAN_MODE_1 = 1;
public static final int EXTRA_SCAN_MODE_2 = 2;

public static final int APPLY_READ_EXTERNAL_STORAGE = 0x111;

private ScannerView mScannerView;
private Result mLastResult;
private int laserMode;
private boolean scanMode = true;
private int scanMode;


@Override
Expand Down Expand Up @@ -79,15 +82,20 @@ public void onClick(View v) {
Bundle extras = getIntent().getExtras();
if (extras != null) {
laserMode = extras.getInt(EXTRA_LASER_LINE_MODE);
scanMode = extras.getBoolean(EXTRA_SCAN_MODE);
scanMode = extras.getInt(EXTRA_SCAN_MODE);
showThumbnail = extras.getBoolean(EXTRA_SHOW_THUMBNAIL);
}
mScannerView.setMediaResId(R.raw.beep);//设置扫描成功的声音
mScannerView.setDrawText("将二维码放入框内", true);
mScannerView.setDrawTextColor(Color.RED);

if (!scanMode)//一维码
if (scanMode == 1) {
//二维码
mScannerView.setScanMode(Scanner.ScanMode.QR_CODE_MODE);
} else if (scanMode == 2) {
//一维码
mScannerView.setScanMode(Scanner.ScanMode.PRODUCT_MODE);
}

//显示扫描成功后的缩略图
mScannerView.isShowResThumbnail(showThumbnail);
Expand Down Expand Up @@ -174,7 +182,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}

public static void gotoActivity(Activity activity, boolean isBackResult
, int laserMode, boolean scanMode,boolean showThumbnail) {
, int laserMode, int scanMode, boolean showThumbnail) {
activity.startActivityForResult(new Intent(Scanner.Scan.ACTION)
.putExtra(BasicScannerActivity.EXTRA_RETURN_SCANNER_RESULT, isBackResult)
.putExtra(ScannerActivity.EXTRA_LASER_LINE_MODE, laserMode)
Expand Down
33 changes: 25 additions & 8 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="wrap_content"

android:layout_height="wrap_content"
android:layout_above="@+id/button"
android:layout_alignParentLeft="true"
Expand Down Expand Up @@ -105,29 +104,47 @@
android:layout_alignParentStart="true"
android:text="解码类型"/>

<ToggleButton
android:id="@+id/toggleButton1"
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/textView10"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@id/textView10"
android:checked="true"
android:textOff="一维"
android:textOn="二维"/>
android:orientation="horizontal">

<RadioButton
android:id="@+id/radioButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="全部"/>

<RadioButton
android:id="@+id/radioButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="仅二维"/>

<RadioButton
android:id="@+id/radioButton6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="仅一维"/>
</RadioGroup>

<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/toggleButton1"
android:layout_above="@+id/radioGroup1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="是否显示扫描结果缩略图"/>


<ToggleButton
android:id="@+id/toggleButton2"
android:id="@+id/toggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/textView11"
Expand Down
6 changes: 3 additions & 3 deletions zxingscanner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 15
targetSdkVersion 23
versionCode 20170810
versionName '1.5.0'
versionName '1.5.1'
}
buildTypes {
release {
Expand Down Expand Up @@ -41,7 +41,7 @@ def gitUrl = 'https://github.com/mylhyl/Android-Zxing.git'

def libName = "zxingscanner"
group = "com.mylhyl"
version = "1.5.0"
version = "1.5.1"

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
Expand Down Expand Up @@ -132,7 +132,7 @@ task makeJar(type: Copy) {
def jarName = libName + '-' + version + '.jar'
delete 'build/libs/' + jarName
from('build/intermediates/bundles/default/')
into('../preview')
into('../preview/lib')
include('classes.jar')
rename('classes.jar', jarName)
exclude('BuildConfig.class', 'R.class')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ private void init(Context context, AttributeSet attrs, int defStyle) {
mViewfinderView = new ViewfinderView(context, attrs);
addView(mViewfinderView, new LayoutParams(LayoutParams.MATCH_PARENT
, LayoutParams.MATCH_PARENT));

//默认解码二维
setScanMode(Scanner.ScanMode.QR_CODE_MODE);
}

public void onResume() {
Expand Down

0 comments on commit 525b19c

Please sign in to comment.