* 内置手电筒按钮,当光线太暗时,自动显示手电筒 fix(#58)

*  生成二维码时Logo支持自定义大小 fix(#62)
This commit is contained in:
jenly1314
2019-11-15 17:29:37 +08:00
parent 004bd683a1
commit b830b89b5f
31 changed files with 411 additions and 151 deletions

View File

@@ -19,6 +19,7 @@ import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.SurfaceView;
import android.view.View;
import com.king.zxing.camera.CameraManager;
@@ -32,6 +33,7 @@ public class CaptureActivity extends Activity implements OnCaptureCallback{
private SurfaceView surfaceView;
private ViewfinderView viewfinderView;
private View ivTorch;
private CaptureHelper mCaptureHelper;
@@ -51,7 +53,12 @@ public class CaptureActivity extends Activity implements OnCaptureCallback{
public void initUI(){
surfaceView = findViewById(getSurfaceViewId());
viewfinderView = findViewById(getViewfinderViewId());
mCaptureHelper = new CaptureHelper(this,surfaceView,viewfinderView);
int ivTorchId = getIvTorchId();
if(ivTorchId != 0){
ivTorch = findViewById(ivTorchId);
ivTorch.setVisibility(View.INVISIBLE);
}
mCaptureHelper = new CaptureHelper(this,surfaceView,viewfinderView,ivTorch);
mCaptureHelper.setOnCaptureCallback(this);
mCaptureHelper.onCreate();
}
@@ -74,7 +81,7 @@ public class CaptureActivity extends Activity implements OnCaptureCallback{
}
/**
* {@link ViewfinderView} 的 id
* {@link #viewfinderView} 的 ID
* @return
*/
public int getViewfinderViewId(){
@@ -83,13 +90,21 @@ public class CaptureActivity extends Activity implements OnCaptureCallback{
/**
* 预览界面{@link #surfaceView} 的id
* 预览界面{@link #surfaceView} 的ID
* @return
*/
public int getSurfaceViewId(){
return R.id.surfaceView;
}
/**
* 获取 {@link #ivTorch} 的ID
* @return 默认返回{@code R.id.ivTorch}, 如果不需要手电筒按钮可以返回0
*/
public int getIvTorchId(){
return R.id.ivTorch;
}
/**
* Get {@link CaptureHelper}
* @return {@link #mCaptureHelper}