Commit 602bbe89 by 罗翻

增加扫描条形码功能

parent b9732d99
......@@ -52,7 +52,7 @@
android:hint="@{presenter.mHint}"
android:paddingLeft="@dimen/dp_13"
android:paddingTop="@dimen/dp_17"
android:maxEms="200"
android:maxLength="200"
android:text="@={presenter.mComment}"
android:textColor="@color/cl_home_title_text_color"
android:textColorHint="@color/cl_selector_hui"
......
......@@ -24,7 +24,6 @@ android {
minifyEnabled isDebugMinify
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "String", "BASEURL", "\"${BASE_URL}\""
// resValue("string", "PORT_NUMBER", "8081")
}
}
......@@ -65,6 +64,9 @@ dependencies {
// compile 'com.contrarywind:Android-PickerView:3.2.7'
//jsbridge
compile 'com.github.lzyzsd:jsbridge:1.0.4'
//zxing
compile 'com.google.zxing:core:3.3.0'
compile 'com.journeyapps:zxing-android-embedded:3.5.0'
compile project(':locationComponent')
compile project(':pickerview')
......
......@@ -626,5 +626,7 @@ C) 在甲方使用大鱼平å°æœåŠ¡è¿‡ç¨‹ä¸­äº§ç”Ÿçš„业务数æ®ï¼Œå®¢æˆ·æ•°æ
<string name="input_new_pwd_again">再次输入新的密码</string>
<string name="sms_code">验证码:</string>
<string name="skip">跳过</string>
<string name="turn_on_flashlight">打开闪光灯</string>
<string name="turn_off_flashlight">关闭闪光灯</string>
</resources>
......@@ -2,7 +2,7 @@
buildscript {
ext.compile_sdk_version = 27
ext.build_tools_version = "27.0.2"
ext.build_tools_version = "27.0.3"
ext.min_sdk_version = 16
ext.target_sdk_version = 23
ext.version_code = 14
......
......@@ -50,13 +50,6 @@ public class MultipleProcessPresenter extends MultipleProcessContract.Presenter
mAccountId = Integer.parseInt(UserManager.getInstance().getUser().getAccountId());
mSpus = mView.getBundle().getParcelableArrayList(OrderConstant.SPUS);
int type = mView.getBundle().getInt(OrderConstant.ORDER_TYPE);
mSpus.add(mSpus.get(0));
mSpus.add(mSpus.get(0));
mSpus.add(mSpus.get(0));
mSpus.add(mSpus.get(0));
mSpus.add(mSpus.get(0));
mSpus.add(mSpus.get(0));
mSpus.add(mSpus.get(0));
mDatas.set(mSpus);
if (mSpus.size() == 1 && type == 1) {
mOrderType = 1;
......
package com.dayu.order.ui.activity;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import com.dayu.order.R;
import com.journeyapps.barcodescanner.CaptureManager;
import com.journeyapps.barcodescanner.DecoratedBarcodeView;
/**
* Custom Scannner Activity extending from Activity to display a custom layout form scanner view.
*/
public class CustomScannerActivity extends Activity implements
DecoratedBarcodeView.TorchListener {
private CaptureManager capture;
private DecoratedBarcodeView barcodeScannerView;
private Button switchFlashlightButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_scanner);
barcodeScannerView = (DecoratedBarcodeView) findViewById(R.id.zxing_barcode_scanner);
barcodeScannerView.setTorchListener(this);
switchFlashlightButton = (Button) findViewById(R.id.switch_flashlight);
// if the device does not have flashlight in its camera,
// then remove the switch flashlight button...
if (!hasFlash()) {
switchFlashlightButton.setVisibility(View.GONE);
}
capture = new CaptureManager(this, barcodeScannerView);
capture.initializeFromIntent(getIntent(), savedInstanceState);
capture.decode();
}
@Override
protected void onResume() {
super.onResume();
capture.onResume();
}
@Override
protected void onPause() {
super.onPause();
capture.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
capture.onDestroy();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
capture.onSaveInstanceState(outState);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return barcodeScannerView.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
}
/**
* Check if the device's camera has a Flashlight.
*
* @return true if there is Flashlight, otherwise false.
*/
private boolean hasFlash() {
return getApplicationContext().getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
}
public void switchFlashlight(View view) {
if (getString(R.string.turn_on_flashlight).equals(switchFlashlightButton.getText())) {
barcodeScannerView.setTorchOn();
} else {
barcodeScannerView.setTorchOff();
}
}
@Override
public void onTorchOn() {
switchFlashlightButton.setText(getString(R.string.turn_off_flashlight));
}
@Override
public void onTorchOff() {
switchFlashlightButton.setText(getString(R.string.turn_on_flashlight));
}
}
......@@ -17,6 +17,8 @@ import com.dayu.order.presenter.multiprocessorder.MultiProcessOrderContract;
import com.dayu.order.presenter.multiprocessorder.MultiProcessOrderPresenter;
import com.dayu.utils.GlideImageLoader;
import com.dayu.utils.UtilsScreen;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import com.luck.picture.lib.PictureSelectionModel;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
......@@ -69,6 +71,9 @@ public class MultiProcessOrderActivity extends BaseActivity<MultiProcessOrderPre
mBind.ivDelete.setVisibility(View.GONE);
mSnImages.clear();
});
mBind.scan.setOnClickListener(v -> {
new IntentIntegrator(this).setOrientationLocked(false).setCaptureActivity(CustomScannerActivity.class).initiateScan();
});
}
@Override
......@@ -176,6 +181,15 @@ public class MultiProcessOrderActivity extends BaseActivity<MultiProcessOrderPre
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (result != null && requestCode == IntentIntegrator.REQUEST_CODE) {
if (result.getContents() == null) {
// toast = "Cancelled from fragment";
} else {
mBind.etSerialNum.setText(result.getContents());
}
return;
}
if (resultCode == RESULT_OK) {
switch (requestCode) {
case PictureConfig.CHOOSE_REQUEST:
......
......@@ -77,5 +77,8 @@
<activity
android:name=".ui.activity.OrderLivenessActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activity.CustomScannerActivity"
android:screenOrientation="portrait" />
</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.journeyapps.barcodescanner.DecoratedBarcodeView
android:id="@+id/zxing_barcode_scanner"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:zxing_scanner_layout="@layout/custom_barcode_scanner">
</com.journeyapps.barcodescanner.DecoratedBarcodeView>
<Button
android:id="@+id/switch_flashlight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/turn_on_flashlight"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:onClick="switchFlashlight"/>
</RelativeLayout>
\ No newline at end of file
......@@ -5,7 +5,8 @@
<import type="android.view.View" />
<import type="android.text.TextUtils"/>
<import type="android.text.TextUtils" />
<variable
name="presenter"
......@@ -144,8 +145,8 @@
android:layout_marginLeft="90dp"
android:layout_toRightOf="@id/text_two_text"
android:background="@null"
android:maxEms="50"
android:hint="@string/order_brand_name"
android:maxLength="50"
android:text="@={presenter.mBrandName}"
android:textColor="@color/default_text_color"
android:textSize="@dimen/sp_15" />
......@@ -191,18 +192,19 @@
style="@style/line"
android:layout_below="@id/rl_verion" />
<RelativeLayout
<LinearLayout
android:id="@+id/rl_serial_num"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_54"
android:layout_below="@id/line_version"
android:background="@color/cl_white">
android:background="@color/cl_white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_serial_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_13"
android:text="@string/order_serail"
android:textColor="@color/cl_home_title_text_color"
......@@ -211,8 +213,6 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/tv_serial_num"
android:text="*"
android:textColor="#F74848"
android:textSize="@dimen/sp_15"
......@@ -220,18 +220,24 @@
<EditText
android:id="@+id/et_serial_num"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="75dp"
android:layout_toRightOf="@id/tv_serial_num"
android:layout_weight="1"
android:background="@null"
android:maxEms="50"
android:hint="@string/order_serail_hint"
android:maxLength="50"
android:text="@={presenter.mSn}"
android:textColor="@color/default_text_color"
android:textSize="@dimen/sp_15" />
</RelativeLayout>
<ImageView
android:id="@+id/scan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:src="@drawable/icon_navigation" />
</LinearLayout>
<ImageView
android:id="@+id/line_serial"
......@@ -306,9 +312,9 @@
android:background="@drawable/subscribe_time_shape"
android:gravity="top"
android:hint="@string/order_hint"
android:maxLength="200"
android:paddingLeft="@dimen/dp_13"
android:paddingTop="@dimen/dp_11"
android:maxEms="200"
android:text="@={presenter.mInfo}"
android:textColor="@color/cl_home_title_text_color"
android:textColorHint="@color/cl_selector_hui"
......
......@@ -144,7 +144,7 @@
android:layout_marginLeft="90dp"
android:layout_toRightOf="@id/text_two_text"
android:background="@null"
android:maxEms="50"
android:maxLength="50"
android:text='@{!TextUtils.isEmpty(presenter.mDetail.brandName)?presenter.mDetail.brandName:@string/no_data}'
android:textColor="@color/default_text_color"
android:textSize="@dimen/sp_15" />
......@@ -226,7 +226,7 @@
android:layout_marginLeft="75dp"
android:layout_toRightOf="@id/tv_serial_num"
android:background="@null"
android:maxEms="50"
android:maxLength="50"
android:text="@{!TextUtils.isEmpty(presenter.mDetail.sn)?presenter.mDetail.sn:@string/no_data}"
android:textColor="@color/default_text_color"
android:textSize="@dimen/sp_15" />
......@@ -429,7 +429,7 @@
android:layout_toRightOf="@id/time_subscribe_remark"
android:background="@drawable/subscribe_time_shape"
android:gravity="top"
android:maxEms="200"
android:maxLength="200"
android:hint="@string/order_hint"
android:paddingLeft="@dimen/dp_13"
android:paddingTop="@dimen/dp_11"
......@@ -750,7 +750,7 @@
android:layout_marginTop="@dimen/dp_17"
android:background="@drawable/subscribe_time_shape"
android:gravity="top"
android:maxEms="100"
android:maxLength="100"
android:hint="@string/tv_order_other"
android:paddingTop="@dimen/dp_11"
android:text="@{presenter.mOrderField.otherInfo}"
......
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.journeyapps.barcodescanner.BarcodeView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/zxing_barcode_surface"
app:zxing_framing_rect_width="250dp"
app:zxing_framing_rect_height="150dp"/>
<com.journeyapps.barcodescanner.ViewfinderView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/zxing_viewfinder_view"
app:zxing_possible_result_points="@color/zxing_custom_possible_result_points"
app:zxing_result_view="@color/zxing_custom_result_view"
app:zxing_viewfinder_laser="@color/zxing_custom_viewfinder_laser"
app:zxing_viewfinder_mask="@color/zxing_custom_viewfinder_mask"/>
<TextView
android:id="@+id/zxing_status_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:background="@color/zxing_transparent"
android:text="@string/zxing_msg_default_status"
android:textColor="@color/zxing_status_text"/>
</merge>
......@@ -390,7 +390,7 @@
android:background="@drawable/subscribe_time_shape"
android:gravity="top"
android:hint="@string/tv_order_other"
android:maxEms="100"
android:maxLength="100"
android:paddingTop="@dimen/dp_11"
android:textColor="@color/cl_home_title_text_color"
android:textColorHint="@color/cl_selector_hui"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment