From 28f874f337ea496f6f1c1214a2994369a8feef5e Mon Sep 17 00:00:00 2001 From: maning <154292322@qq.com> Date: Wed, 18 Sep 2019 09:59:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/caches/build_file_checksums.ser | Bin 0 -> 590 bytes .idea/caches/gradle_models.ser | Bin 0 -> 93728 bytes .idea/encodings.xml | 6 + .idea/inspectionProfiles/Project_Default.xml | 36 ++ README.md | 13 +- app/build.gradle | 4 + app/src/main/AndroidManifest.xml | 1 + .../zxingcodedemo/CustomScanActivity.java | 322 ++++++++++++++++++ .../maning/zxingcodedemo/MainActivity.java | 119 +------ .../main/res/layout/activity_custom_scan.xml | 294 ++++++++++++++++ app/src/main/res/layout/activity_main.xml | 6 +- .../zxing/client/android/ViewfinderView.java | 4 +- .../client/android/camera/CameraManager.java | 2 +- .../client/android/model/MNScanConfig.java | 122 ++----- libraryzxing/src/main/res/values/strings.xml | 6 - screenshots/mn_zxing_screenshot_000.png | Bin 0 -> 20120 bytes screenshots/mn_zxing_screenshot_001.jpeg | Bin 0 -> 31853 bytes screenshots/mn_zxing_screenshot_001.png | Bin 22863 -> 0 bytes 18 files changed, 710 insertions(+), 225 deletions(-) create mode 100644 .idea/caches/build_file_checksums.ser create mode 100644 .idea/caches/gradle_models.ser create mode 100644 .idea/encodings.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 app/src/main/java/com/maning/zxingcodedemo/CustomScanActivity.java create mode 100644 app/src/main/res/layout/activity_custom_scan.xml delete mode 100644 libraryzxing/src/main/res/values/strings.xml create mode 100644 screenshots/mn_zxing_screenshot_000.png create mode 100644 screenshots/mn_zxing_screenshot_001.jpeg delete mode 100644 screenshots/mn_zxing_screenshot_001.png diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser new file mode 100644 index 0000000000000000000000000000000000000000..c44ed4ba8470937cc30aaf05051665716b4160fe GIT binary patch literal 590 zcmZ4UmVvdnh`~NNKUXg?FQq6yGexf?KR>5fFEb@IQ7^qHF(oHeub?PDD>b=9F91S2 zm1gFoxMk*~I%lLNXBU^|7Q2L-Ts|(GuF1r}k!YkIeIoBX$BB@8^+75*!EH~ZtuAL?K3 zrI@#|{N7o@Adr)voR|ZOCzvPTZjo8+5GIkk;&_|T_47?Db%1UW#Pl*;wYepq7x(mo nfo_Yd?(}=rDgcd6EGWR?;7bozeHN-KV*I3VZvw~jx|Rw67iQ84 literal 0 HcmV?d00001 diff --git a/.idea/caches/gradle_models.ser b/.idea/caches/gradle_models.ser new file mode 100644 index 0000000000000000000000000000000000000000..e15aeee0e218391116b93eecee9bb94e09e007b1 GIT binary patch literal 93728 zcmd6Q3z!^Lm48k5h zGJ}fi8(duk0d*A>kp=$ZuDa{z16^>%MOa;VXx0Y{2(G&OR|IxJP+9k!`>49N9$np4 zm5KOSnXbBzbI(2Zch0@{+;i{vjWVxgDC4C@Ev42qqfyaPW}{JUr7D`Prlt&4tLmwy z(b%h(%v5W(UP{%cQYE#trvm@3gMW2x8~wVuq3P9@LjOx7l*EK`bZvHRyHeG*sfJl8 zRhnwuY?;c^iM{Hynr@qwYI>s5GS^Hf$JAzN_O+TJEtw5tTsh3#W9Y3tjjA@&eEm6Cg0g7;LU=BP|0hi)sWy?2 z^P(_~HdEqRKj9g$;#|UY&X66mP5mMXU?T=s5hZFYO3VQzrV(G6bmk_qLA+UyRswGZWn zmdZG>7&>YZ>HA6}g_QNL`po(zi+}zn5S0m~zsYHvX`0Hq^!Y6yAYD`Iz{~VlV}BjR zqLn_kVxHG7?jEHBB)xgdt_vZ-I^a_pL?K;78E0ckcpK28c(|E1cHq~NPM*&_rsT&ow3WBR`Xc#rhYDGyXeHSYW^{QUe$t!#2v=xllNRVkY9kD-iAvE> zjoEFahfL*F4P%PqfZD92nzZLq=jqiZa=gV8V*4x%5m}PLY>ann)t1gP3gxfE{Hj+1|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iles/Project_Default.xml new file mode 100644 index 0000000..6560a98 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,36 @@ + + + + \ No newline at end of file diff --git a/README.md b/README.md index 09b79cd..2d62198 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,11 @@ 3:相册中选取图片识别 4:闪光灯开关 5: 相机可以调整焦距放大缩小 - 6: 完全自定义遮罩层,高度自定义 + 6: 完全自定义遮罩层 ## 截图: -![image](https://github.com/maning0303/ZXingCodeDemo/blob/master/screenshots/mn_zxing_screenshot_001.png) +![image](https://github.com/maning0303/ZXingCodeDemo/blob/master/screenshots/mn_zxing_screenshot_000.png) +![image](https://github.com/maning0303/ZXingCodeDemo/blob/master/screenshots/mn_zxing_screenshot_001.jpeg) ![image](https://github.com/maning0303/ZXingCodeDemo/blob/master/screenshots/mn_zxing_screenshot_002.png) #### 完全自定义遮罩层 @@ -100,9 +101,9 @@ .setGridScanLineColumn(30) //网格高度 .setGridScanLineHeight(150) - //高度偏移值(单位px) - .setScanFrameHeightOffect(150) - //是否全屏扫描 + //高度偏移值(单位px)+向上偏移,-向下偏移 + .setScanFrameHeightOffsets(150) + //是否全屏范围扫描 .setFullScreenScan(true) //自定义遮罩 .setCustomShadeViewLayoutID(R.layout.layout_custom_view, new MNCustomViewBindCallback() { @@ -167,7 +168,7 @@ ## 版本记录: v2.1.2(未发布): 1.支持设置扫描框高度偏移值 - 2.支持设置全屏扫描(默认只扫描扫描框内的二维码) + 2.支持设置全屏范围扫描(默认只扫描扫描框内的二维码) v2.1.1: 1.支持网格扫描线设置列数和高度 diff --git a/app/build.gradle b/app/build.gradle index 1e49a5a..7ecdca4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,6 +21,10 @@ dependencies { implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:support-v4:28.0.0' + //颜色选择器 + implementation 'com.github.duanhong169:colorpicker:1.1.6' + // implementation 'com.github.maning0303:MNZXingCode:V2.1.1' implementation project(':libraryzxing') + implementation 'com.android.support.constraint:constraint-layout:1.1.3' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ba21004..fb567df 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,6 +8,7 @@ android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> + diff --git a/app/src/main/java/com/maning/zxingcodedemo/CustomScanActivity.java b/app/src/main/java/com/maning/zxingcodedemo/CustomScanActivity.java new file mode 100644 index 0000000..a884dfb --- /dev/null +++ b/app/src/main/java/com/maning/zxingcodedemo/CustomScanActivity.java @@ -0,0 +1,322 @@ +package com.maning.zxingcodedemo; + +import android.content.Intent; +import android.graphics.Color; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.text.TextUtils; +import android.view.View; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RadioButton; +import android.widget.TextView; +import android.widget.Toast; + +import com.google.zxing.client.android.MNScanManager; +import com.google.zxing.client.android.model.MNScanConfig; +import com.google.zxing.client.android.other.MNCustomViewBindCallback; +import com.google.zxing.client.android.other.MNScanCallback; + +import top.defaults.colorpicker.ColorPickerPopup; + +public class CustomScanActivity extends AppCompatActivity implements View.OnClickListener { + + /** + * 是否显示相册功能 + */ + private CheckBox mCbPhoto; + /** + * 是否显示闪光灯 + */ + private CheckBox mCbLight; + /** + * 是否显示缩放控制器 + */ + private CheckBox mCbZoom; + /** + * 是否需要全屏扫描识别(默认值扫描扫描框内二维码) + */ + private CheckBox mCbFullscreenScan; + /** + * 是否开启扫描完成震动提醒 + */ + private CheckBox mCbVibrate; + /** + * 是否开启扫描完成声音提醒 + */ + private CheckBox mCbBeep; + /** + * 是否完全自定义遮罩层 + */ + private CheckBox mCbCustomView; + /** + * 输入自定义提示文案 + */ + private EditText mEtHintText; + /** + * 文字大小(sp) + */ + private EditText mEtHintTextSize; + /** + * 网格扫描高度 + */ + private EditText mEtGridlineHeight; + /** + * 网格扫描列数 + */ + private EditText mEtGridlineNum; + /** + * 扫描识别框高度偏移值(px)+向上偏移,-向下偏移 + */ + private EditText mEtScanOffsets; + private TextView mBtnColorPickerText; + private TextView mBtnColorPickerLine; + private TextView mBtnColorPickerBg; + /** + * 线性 + */ + private RadioButton mRbScanlineLine; + /** + * 网格 + */ + private RadioButton mRbScanlineGrid; + /** + * 右边 + */ + private RadioButton mRbZoomRight; + /** + * 下边 + */ + private RadioButton mRbZoomBottom; + + + private String colorText = "#FFFFFF00"; + private String colorLine = "#FFFFFF00"; + private String colorBackground = "#33FF0000"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_custom_scan); + initView(); + } + + private void initView() { + mCbPhoto = (CheckBox) findViewById(R.id.cb_photo); + mCbLight = (CheckBox) findViewById(R.id.cb_light); + mCbZoom = (CheckBox) findViewById(R.id.cb_zoom); + mCbFullscreenScan = (CheckBox) findViewById(R.id.cb_fullscreen_scan); + mCbVibrate = (CheckBox) findViewById(R.id.cb_vibrate); + mCbBeep = (CheckBox) findViewById(R.id.cb_beep); + mCbCustomView = (CheckBox) findViewById(R.id.cb_custom_view); + mEtHintText = (EditText) findViewById(R.id.et_hint_text); + mEtHintTextSize = (EditText) findViewById(R.id.et_hint_text_size); + mEtGridlineHeight = (EditText) findViewById(R.id.et_gridline_height); + mEtGridlineNum = (EditText) findViewById(R.id.et_gridline_num); + mEtScanOffsets = (EditText) findViewById(R.id.et_scan_offsets); + mBtnColorPickerText = (TextView) findViewById(R.id.btn_color_picker_text); + mBtnColorPickerText.setOnClickListener(this); + mBtnColorPickerLine = (TextView) findViewById(R.id.btn_color_picker_line); + mBtnColorPickerLine.setOnClickListener(this); + mBtnColorPickerBg = (TextView) findViewById(R.id.btn_color_picker_bg); + mBtnColorPickerBg.setOnClickListener(this); + mRbScanlineLine = (RadioButton) findViewById(R.id.rb_scanline_line); + mRbScanlineGrid = (RadioButton) findViewById(R.id.rb_scanline_grid); + mRbZoomRight = (RadioButton) findViewById(R.id.rb_zoom_right); + mRbZoomBottom = (RadioButton) findViewById(R.id.rb_zoom_bottom); + } + + @Override + public void onClick(View v) { + switch (v.getId()) { + default: + break; + case R.id.btn_color_picker_text: + new ColorPickerPopup.Builder(this) + .initialColor(Color.parseColor(colorText)) + .enableBrightness(true) + .enableAlpha(false) + .okTitle("选择颜色") + .cancelTitle("取消") + .showIndicator(true) + .showValue(true) + .build() + .show(mBtnColorPickerText, new ColorPickerPopup.ColorPickerObserver() { + @Override + public void onColorPicked(int color) { + colorText = "#" + Integer.toHexString(color); + mBtnColorPickerText.setBackgroundColor(color); + } + }); + break; + case R.id.btn_color_picker_line: + new ColorPickerPopup.Builder(this) + .initialColor(Color.parseColor(colorLine)) + .enableBrightness(true) + .enableAlpha(false) + .okTitle("选择颜色") + .cancelTitle("取消") + .showIndicator(true) + .showValue(true) + .build() + .show(mBtnColorPickerLine, new ColorPickerPopup.ColorPickerObserver() { + @Override + public void onColorPicked(int color) { + colorLine = "#" + Integer.toHexString(color); + mBtnColorPickerLine.setBackgroundColor(color); + } + }); + break; + case R.id.btn_color_picker_bg: + new ColorPickerPopup.Builder(this) + .initialColor(Color.parseColor(colorBackground)) + .enableBrightness(true) + .enableAlpha(true) + .okTitle("选择颜色") + .cancelTitle("取消") + .showIndicator(true) + .showValue(true) + .build() + .show(mBtnColorPickerBg, new ColorPickerPopup.ColorPickerObserver() { + @Override + public void onColorPicked(int color) { + colorBackground = "#" + Integer.toHexString(color); + mBtnColorPickerBg.setBackgroundColor(color); + } + }); + break; + } + } + + public void scanCode(View view) { + //需要判断有没有权限 + MNScanConfig scanConfig = new MNScanConfig.Builder() + //设置完成震动 + .isShowVibrate(mCbVibrate.isChecked()) + //扫描完成声音 + .isShowBeep(mCbBeep.isChecked()) + //显示相册功能 + .isShowPhotoAlbum(mCbPhoto.isChecked()) + //显示闪光灯 + .isShowLightController(mCbLight.isChecked()) + //打开扫描页面的动画 + .setActivityOpenAnime(R.anim.activity_anmie_in) + //退出扫描页面动画 + .setActivityExitAnime(R.anim.activity_anmie_out) + //自定义文案 + .setScanHintText(mEtHintText.getText().toString()) + .setScanHintTextColor(colorText) + .setScanHintTextSize(TextUtils.isEmpty(mEtHintTextSize.getText().toString()) ? 14 : Integer.parseInt(mEtHintTextSize.getText().toString())) + //扫描线的颜色 + .setScanColor(colorLine) + //是否显示缩放控制器 + .isShowZoomController(mCbZoom.isChecked()) + //显示缩放控制器位置 + .setZoomControllerLocation(mRbZoomBottom.isChecked() ? MNScanConfig.ZoomControllerLocation.Bottom : MNScanConfig.ZoomControllerLocation.Right) + //扫描线样式 + .setLaserStyle(mRbScanlineGrid.isChecked() ? MNScanConfig.LaserStyle.Grid : MNScanConfig.LaserStyle.Line) + //背景颜色 + .setBgColor(colorBackground) + //网格扫描线的列数 + .setGridScanLineColumn(TextUtils.isEmpty(mEtGridlineNum.getText().toString()) ? 30 : Integer.parseInt(mEtGridlineNum.getText().toString())) + //网格高度 + .setGridScanLineHeight(TextUtils.isEmpty(mEtGridlineHeight.getText().toString()) ? 0 : Integer.parseInt(mEtGridlineHeight.getText().toString())) + //高度偏移值(单位px)+向上偏移,-向下偏移 + .setScanFrameHeightOffsets(TextUtils.isEmpty(mEtScanOffsets.getText().toString()) ? 0 : Integer.parseInt(mEtScanOffsets.getText().toString())) + //是否全屏扫描,默认只扫描扫描框内的二维码 + .setFullScreenScan(mCbFullscreenScan.isChecked()) + //自定义遮罩 + .setCustomShadeViewLayoutID(mCbCustomView.isChecked() ? R.layout.layout_custom_view : 0, new MNCustomViewBindCallback() { + @Override + public void onBindView(View customView) { + if (customView == null) { + return; + } + ImageView iv_back = customView.findViewById(R.id.iv_back); + ImageView iv_photo = customView.findViewById(R.id.iv_photo); + LinearLayout btn_scan_light = customView.findViewById(R.id.btn_scan_light); + final ImageView iv_scan_light = customView.findViewById(R.id.iv_scan_light); + final TextView tv_scan_light = customView.findViewById(R.id.tv_scan_light); + LinearLayout btn_my_card = customView.findViewById(R.id.btn_my_card); + LinearLayout btn_scan_record = customView.findViewById(R.id.btn_scan_record); + iv_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //关闭扫描页面 + MNScanManager.closeScanPage(); + } + }); + btn_scan_light.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //手电筒 + if (MNScanManager.isLightOn()) { + MNScanManager.closeScanLight(); + iv_scan_light.setImageResource(R.drawable.icon_custom_light_close); + tv_scan_light.setText("开启手电筒"); + } else { + MNScanManager.openScanLight(); + iv_scan_light.setImageResource(R.drawable.icon_custom_light_open); + tv_scan_light.setText("关闭手电筒"); + } + } + }); + iv_photo.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //打开相册扫描 + MNScanManager.openAlbumPage(); + } + }); + btn_my_card.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //我的名片 + showToast("我的名片"); + } + }); + btn_scan_record.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //扫码记录 + showToast("扫码记录"); + } + }); + } + }) + .builder(); + MNScanManager.startScan(this, scanConfig, new MNScanCallback() { + @Override + public void onActivityResult(int resultCode, Intent data) { + handlerResult(resultCode, data); + } + }); + } + + private void showToast(String msg) { + Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); + } + + + private void handlerResult(int resultCode, Intent data) { + if (data == null) { + return; + } + switch (resultCode) { + case MNScanManager.RESULT_SUCCESS: + String resultSuccess = data.getStringExtra(MNScanManager.INTENT_KEY_RESULT_SUCCESS); + showToast(resultSuccess); + break; + case MNScanManager.RESULT_FAIL: + String resultError = data.getStringExtra(MNScanManager.INTENT_KEY_RESULT_ERROR); + showToast(resultError); + break; + case MNScanManager.RESULT_CANCLE: + showToast("取消扫码"); + break; + } + } + +} diff --git a/app/src/main/java/com/maning/zxingcodedemo/MainActivity.java b/app/src/main/java/com/maning/zxingcodedemo/MainActivity.java index 537f238..edcc289 100644 --- a/app/src/main/java/com/maning/zxingcodedemo/MainActivity.java +++ b/app/src/main/java/com/maning/zxingcodedemo/MainActivity.java @@ -13,14 +13,10 @@ import android.widget.CheckBox; import android.widget.EditText; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; -import com.google.zxing.client.android.CaptureActivity; import com.google.zxing.client.android.MNScanManager; -import com.google.zxing.client.android.model.MNScanConfig; -import com.google.zxing.client.android.other.MNCustomViewBindCallback; import com.google.zxing.client.android.other.MNScanCallback; import com.google.zxing.client.android.utils.ZXingUtils; @@ -37,13 +33,16 @@ public class MainActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + initView(); + requestCameraPerm(); + } + + private void initView() { textView = (TextView) findViewById(R.id.tv_show); imageView = (ImageView) findViewById(R.id.imageView); editText = (EditText) findViewById(R.id.editText); checkbox = (CheckBox) findViewById(R.id.checkbox); - - requestCameraPerm(); } public void requestCameraPerm() { @@ -65,112 +64,10 @@ public void onActivityResult(int resultCode, Intent data) { }); } - public void scanCode(View view) { - //需要判断有没有权限 - MNScanConfig scanConfig = new MNScanConfig.Builder() - //设置完成震动 - .isShowVibrate(false) - //扫描完成声音 - .isShowBeep(true) - //显示相册功能 - .isShowPhotoAlbum(true) - //显示闪光灯 - .isShowLightController(true) - //打开扫描页面的动画 - .setActivityOpenAnime(R.anim.activity_anmie_in) - //退出扫描页面动画 - .setActivityExitAnime(R.anim.activity_anmie_out) - //自定义文案 - .setScanHintText("请将二维码放入框中") - .setScanHintTextColor("#FFFF00") - .setScanHintTextSize(16) - //扫描线的颜色 - .setScanColor("#FFFF00") - //是否显示缩放控制器 - .isShowZoomController(true) - //显示缩放控制器位置 - .setZoomControllerLocation(MNScanConfig.ZoomControllerLocation.Bottom) - //扫描线样式 - .setLaserStyle(MNScanConfig.LaserStyle.Grid) - //背景颜色 - .setBgColor("#33FF0000") - //网格扫描线的列数 - .setGridScanLineColumn(30) - //网格高度 - .setGridScanLineHeight(150) - //高度偏移值(单位px) - .setScanFrameHeightOffect(150) - //是否全屏扫描,默认只扫描扫描框内的二维码 - .setFullScreenScan(true) - //自定义遮罩 - .setCustomShadeViewLayoutID(R.layout.layout_custom_view, new MNCustomViewBindCallback() { - @Override - public void onBindView(View customView) { - if(customView == null){ - return; - } - ImageView iv_back = customView.findViewById(R.id.iv_back); - ImageView iv_photo = customView.findViewById(R.id.iv_photo); - LinearLayout btn_scan_light = customView.findViewById(R.id.btn_scan_light); - final ImageView iv_scan_light = customView.findViewById(R.id.iv_scan_light); - final TextView tv_scan_light = customView.findViewById(R.id.tv_scan_light); - LinearLayout btn_my_card = customView.findViewById(R.id.btn_my_card); - LinearLayout btn_scan_record = customView.findViewById(R.id.btn_scan_record); - iv_back.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - //关闭扫描页面 - MNScanManager.closeScanPage(); - } - }); - btn_scan_light.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - //手电筒 - if (MNScanManager.isLightOn()) { - MNScanManager.closeScanLight(); - iv_scan_light.setImageResource(R.drawable.icon_custom_light_close); - tv_scan_light.setText("开启手电筒"); - } else { - MNScanManager.openScanLight(); - iv_scan_light.setImageResource(R.drawable.icon_custom_light_open); - tv_scan_light.setText("关闭手电筒"); - } - } - }); - iv_photo.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - //打开相册扫描 - MNScanManager.openAlbumPage(); - } - }); - btn_my_card.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - //我的名片 - showToast("我的名片"); - } - }); - btn_scan_record.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - //扫码记录 - showToast("扫码记录"); - } - }); - } - }) - .builder(); - MNScanManager.startScan(this, scanConfig, new MNScanCallback() { - @Override - public void onActivityResult(int resultCode, Intent data) { - handlerResult(resultCode, data); - } - }); + public void customScan(View view) { + startActivity(new Intent(this, CustomScanActivity.class)); } - public void createQRImage(View view) { String str = editText.getText().toString(); @@ -205,6 +102,8 @@ private void handlerResult(int resultCode, Intent data) { return; } switch (resultCode) { + default: + break; case MNScanManager.RESULT_SUCCESS: String resultSuccess = data.getStringExtra(MNScanManager.INTENT_KEY_RESULT_SUCCESS); showToast(resultSuccess); diff --git a/app/src/main/res/layout/activity_custom_scan.xml b/app/src/main/res/layout/activity_custom_scan.xml new file mode 100644 index 0000000..31a53f6 --- /dev/null +++ b/app/src/main/res/layout/activity_custom_scan.xml @@ -0,0 +1,294 @@ + + + + + +