Commit 649170bf by 宁斌

功能权限控制完善

parent 03737d19
......@@ -62,7 +62,6 @@ dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/javabase64-1.2.jar')
implementation files('libs/sun.misc.BASE64Decoder.jar')
// implementation files('libs/ZXing-core-3.2.1.jar')
api files('libs/nexgon5lib.jar')
if (project.ext.runAsApp) {
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
......@@ -83,7 +82,7 @@ dependencies {
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
api rootProject.ext.dependencies["BaseRecyclerViewAdapter"]
implementation rootProject.ext.dependencies["fastjson"]
api rootProject.ext.dependencies["zxing"]
// api rootProject.ext.dependencies["zxing"]
implementation rootProject.ext.dependencies["progressmanager"]
implementation rootProject.ext.dependencies["autosize"]
// test
......@@ -106,8 +105,8 @@ dependencies {
api 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0'
//多功能輸入框
api 'com.rengwuxian.materialedittext:library:2.1.4'
// // 斜角标签
// api 'com.github.poqiao:BeveLabelView:1.0.3'
//扫码
implementation 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.3'
api 'androidx.core:core-ktx:+'
implementation 'org.projectlombok:lombok:1.18.8'
annotationProcessor 'org.projectlombok:lombok:1.18.8'
......
......@@ -41,7 +41,7 @@ public class HttpsConstans {
private static String PATH = "/ricepon-cloud-gsa/api/";//路徑
public static String ROOT_SERVER_YOU_CHANG_HK = "http://192.168.1.142:9012/api/"; //友常本地
public static String ROOT_SERVER_SHI_WEI_HK = "http://192.168.1.169:9012/api/"; //世維本地
public static String ROOT_SERVER_ZHI_WANG_HK = "http://192.168.1.169:9012/api/"; //世維本地
public static String ROOT_SERVER_SHI_SHU_HK = "http://192.168.1.154:9012/api/"; //石书本地
//------------------------------------------外賣接單---------------------------------------------------------------------------
......@@ -126,22 +126,22 @@ public class HttpsConstans {
SYSTEM_URL = ROOT_HK_TEST_URL + SYSTEM_PATH;
break;
case 2:
_SERVER_ADDRESS = ROOT_SERVER_YOU_CHANG_HK + "/member-web/api/";
_SERVER_ADDRESS = ROOT_SERVER_ZHI_WANG_HK + "/member-web/api/";
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS;
ROOT_SERVER_ADDRESS_FORMAL = ROOT_SERVER_YOU_CHANG_HK;
ROOT_SERVER_ADDRESS_FORMAL = ROOT_SERVER_ZHI_WANG_HK;
ROOT_URL = ROOT_SZ_URL;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS + REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
SYSTEM_URL = ROOT_SERVER_YOU_CHANG_HK + SYSTEM_PATH;
SYSTEM_URL = ROOT_SERVER_ZHI_WANG_HK + SYSTEM_PATH;
break;
case 3:
_SERVER_ADDRESS = ROOT_SERVER_SHI_WEI_HK + "/member-web/api/";
_SERVER_ADDRESS = ROOT_SERVER_YOU_CHANG_HK + "/member-web/api/";
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS;
ROOT_SERVER_ADDRESS_FORMAL = ROOT_SERVER_SHI_WEI_HK;
ROOT_SERVER_ADDRESS_FORMAL = ROOT_SERVER_YOU_CHANG_HK;
ROOT_URL = ROOT_SZ_URL;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS + REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
SYSTEM_URL = ROOT_SERVER_SHI_WEI_HK + SYSTEM_PATH;
SYSTEM_URL = ROOT_SERVER_YOU_CHANG_HK + SYSTEM_PATH;
break;
case 4:
_SERVER_ADDRESS = ROOT_SERVER_SHI_SHU_HK + "/member-web/api/";
......
package com.gingersoft.gsa.cloud.constans;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-08-14
* 修订历史:2020-08-14
* 描述:
*/
public interface ResultConstans {
int DOWNLOAD_PAGE_BACK = 100;
}
......@@ -46,25 +46,25 @@ public class FunctionManager {
for (int j = 0; j < fModules.length; j++) {
FModule module = fModules[j];
if (function.getResUrl().equals(module.getKeyRes())) {
switch (function.getStatus()) {
case Function.STATUS_NONAL:
// switch (function.getStatus()) {
// case Function.STATUS_NONAL:
function.setIcRes(module.getOpenIconRes());
break;
case Function.STATUS_TIME_LIMIT:
long currentTime = System.currentTimeMillis();
long effectiveTime = function.getEffectiveTime();
if (effectiveTime > currentTime) {
//在有效期内
function.setStatus(Function.STATUS_NONAL);
function.setIcRes(module.getOpenIconRes());
} else {
function.setIcRes(module.getDisableIconRes());
}
break;
default:
function.setIcRes(module.getDisableIconRes());
break;
}
// break;
// case Function.STATUS_TIME_LIMIT:
// long currentTime = System.currentTimeMillis();
// long effectiveTime = function.getEffectiveTime();
// if (effectiveTime > currentTime) {
// //在有效期内
// function.setStatus(Function.STATUS_NONAL);
// function.setIcRes(module.getOpenIconRes());
// } else {
// function.setIcRes(module.getDisableIconRes());
// }
// break;
// default:
// function.setIcRes(module.getDisableIconRes());
// break;
// }
}
}
functions.add(function);
......
......@@ -100,8 +100,8 @@ public class MyResponseErrorListener implements ResponseErrorListener {
dialogBuilder.create(R.style.MyDialogTheme2).show();
}
private void toLoginActivity(Activity context) {
ArmsUtils.killAll();
//清空用戶信息
GsaCloudApplication.clearMemberInfo();
//清空賬單數據
......
package com.gingersoft.gsa.cloud.zxing;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.View;
public class PointsOverlayView extends View {
PointF[] points;
private Paint paint;
public PointsOverlayView(Context context) {
super(context);
init();
}
public PointsOverlayView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public PointsOverlayView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
paint = new Paint();
paint.setColor(Color.YELLOW);
paint.setStyle(Paint.Style.FILL);
}
/**
* @param points
*/
public void setPoints(PointF[] points) {
this.points = points;
invalidate();
}
@Override public void draw(Canvas canvas) {
super.draw(canvas);
if (points != null) {
for (PointF pointF : points) {
canvas.drawCircle(pointF.x, pointF.y, 10, paint);
}
}
}
}
/*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.camera;
import android.hardware.Camera;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
final class AutoFocusCallback implements Camera.AutoFocusCallback {
private static final String TAG = AutoFocusCallback.class.getSimpleName();
private static final long AUTOFOCUS_INTERVAL_MS = 2000L;
private Handler autoFocusHandler;
private int autoFocusMessage;
void setHandler(Handler autoFocusHandler, int autoFocusMessage) {
this.autoFocusHandler = autoFocusHandler;
this.autoFocusMessage = autoFocusMessage;
}
public void onAutoFocus(boolean success, Camera camera) {
if (autoFocusHandler != null) {
Message message = autoFocusHandler.obtainMessage(autoFocusMessage, success);
autoFocusHandler.sendMessageDelayed(message, AUTOFOCUS_INTERVAL_MS);
autoFocusHandler = null;
} else {
Log.d(TAG, "Got auto-focus callback, but no handler for it");
}
}
}
/*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.camera;
import android.os.IBinder;
import android.util.Log;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* This class is used to activate the weak light on some camera phones (not flash)
* in order to illuminate surfaces for scanning. There is no official way to do this,
* but, classes which allow access to this function still exist on some devices.
* This therefore proceeds through a great deal of reflection.
*
* See <a href="http://almondmendoza.com/2009/01/05/changing-the-screen-brightness-programatically/">
* http://almondmendoza.com/2009/01/05/changing-the-screen-brightness-programatically/</a> and
* <a href="http://code.google.com/p/droidled/source/browse/trunk/src/com/droidled/demo/DroidLED.java">
* http://code.google.com/p/droidled/source/browse/trunk/src/com/droidled/demo/DroidLED.java</a>.
* Thanks to Ryan Alford for pointing out the availability of this class.
*/
final class FlashlightManager {
private static final String TAG = FlashlightManager.class.getSimpleName();
private static final Object iHardwareService;
private static final Method setFlashEnabledMethod;
static {
iHardwareService = getHardwareService();
setFlashEnabledMethod = getSetFlashEnabledMethod(iHardwareService);
if (iHardwareService == null) {
Log.v(TAG, "This device does supports control of a flashlight");
} else {
Log.v(TAG, "This device does not support control of a flashlight");
}
}
private FlashlightManager() {
}
/**
* �����������ƿ���
*/
//FIXME
static void enableFlashlight() {
setFlashlight(false);
}
static void disableFlashlight() {
setFlashlight(false);
}
private static Object getHardwareService() {
Class<?> serviceManagerClass = maybeForName("android.os.ServiceManager");
if (serviceManagerClass == null) {
return null;
}
Method getServiceMethod = maybeGetMethod(serviceManagerClass, "getService", String.class);
if (getServiceMethod == null) {
return null;
}
Object hardwareService = invoke(getServiceMethod, null, "hardware");
if (hardwareService == null) {
return null;
}
Class<?> iHardwareServiceStubClass = maybeForName("android.os.IHardwareService$Stub");
if (iHardwareServiceStubClass == null) {
return null;
}
Method asInterfaceMethod = maybeGetMethod(iHardwareServiceStubClass, "asInterface", IBinder.class);
if (asInterfaceMethod == null) {
return null;
}
return invoke(asInterfaceMethod, null, hardwareService);
}
private static Method getSetFlashEnabledMethod(Object iHardwareService) {
if (iHardwareService == null) {
return null;
}
Class<?> proxyClass = iHardwareService.getClass();
return maybeGetMethod(proxyClass, "setFlashlightEnabled", boolean.class);
}
private static Class<?> maybeForName(String name) {
try {
return Class.forName(name);
} catch (ClassNotFoundException cnfe) {
// OK
return null;
} catch (RuntimeException re) {
Log.w(TAG, "Unexpected error while finding class " + name, re);
return null;
}
}
private static Method maybeGetMethod(Class<?> clazz, String name, Class<?>... argClasses) {
try {
return clazz.getMethod(name, argClasses);
} catch (NoSuchMethodException nsme) {
// OK
return null;
} catch (RuntimeException re) {
Log.w(TAG, "Unexpected error while finding method " + name, re);
return null;
}
}
private static Object invoke(Method method, Object instance, Object... args) {
try {
return method.invoke(instance, args);
} catch (IllegalAccessException e) {
Log.w(TAG, "Unexpected error while invoking " + method, e);
return null;
} catch (InvocationTargetException e) {
Log.w(TAG, "Unexpected error while invoking " + method, e.getCause());
return null;
} catch (RuntimeException re) {
Log.w(TAG, "Unexpected error while invoking " + method, re);
return null;
}
}
private static void setFlashlight(boolean active) {
if (iHardwareService != null) {
invoke(setFlashEnabledMethod, iHardwareService, active);
}
}
}
/*
* Copyright 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.camera;
import android.graphics.Bitmap;
import com.google.zxing.LuminanceSource;
/**
* This object extends LuminanceSource around an array of YUV data returned from the camera driver,
* with the option to crop to a rectangle within the full data. This can be used to exclude
* superfluous pixels around the perimeter and speed up decoding.
*
* It works for any pixel format where the Y channel is planar and appears first, including
* YCbCr_420_SP and YCbCr_422_SP.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class PlanarYUVLuminanceSource extends LuminanceSource {
private final byte[] yuvData;
private final int dataWidth;
private final int dataHeight;
private final int left;
private final int top;
public PlanarYUVLuminanceSource(byte[] yuvData, int dataWidth, int dataHeight, int left, int top,
int width, int height) {
super(width, height);
if (left + width > dataWidth || top + height > dataHeight) {
throw new IllegalArgumentException("Crop rectangle does not fit within image data.");
}
this.yuvData = yuvData;
this.dataWidth = dataWidth;
this.dataHeight = dataHeight;
this.left = left;
this.top = top;
}
@Override
public byte[] getRow(int y, byte[] row) {
if (y < 0 || y >= getHeight()) {
throw new IllegalArgumentException("Requested row is outside the image: " + y);
}
int width = getWidth();
if (row == null || row.length < width) {
row = new byte[width];
}
int offset = (y + top) * dataWidth + left;
System.arraycopy(yuvData, offset, row, 0, width);
return row;
}
@Override
public byte[] getMatrix() {
int width = getWidth();
int height = getHeight();
// If the caller asks for the entire underlying image, save the copy and give them the
// original data. The docs specifically warn that result.length must be ignored.
if (width == dataWidth && height == dataHeight) {
return yuvData;
}
int area = width * height;
byte[] matrix = new byte[area];
int inputOffset = top * dataWidth + left;
// If the width matches the full width of the underlying data, perform a single copy.
if (width == dataWidth) {
System.arraycopy(yuvData, inputOffset, matrix, 0, area);
return matrix;
}
// Otherwise copy one cropped row at a time.
byte[] yuv = yuvData;
for (int y = 0; y < height; y++) {
int outputOffset = y * width;
System.arraycopy(yuv, inputOffset, matrix, outputOffset, width);
inputOffset += dataWidth;
}
return matrix;
}
@Override
public boolean isCropSupported() {
return true;
}
public int getDataWidth() {
return dataWidth;
}
public int getDataHeight() {
return dataHeight;
}
public Bitmap renderCroppedGreyscaleBitmap() {
int width = getWidth();
int height = getHeight();
int[] pixels = new int[width * height];
byte[] yuv = yuvData;
int inputOffset = top * dataWidth + left;
for (int y = 0; y < height; y++) {
int outputOffset = y * width;
for (int x = 0; x < width; x++) {
int grey = yuv[inputOffset + x] & 0xff;
pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101);
}
inputOffset += dataWidth;
}
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
}
}
/*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.camera;
import android.graphics.Point;
import android.hardware.Camera;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
final class PreviewCallback implements Camera.PreviewCallback {
private static final String TAG = PreviewCallback.class.getSimpleName();
private final CameraConfigurationManager configManager;
private final boolean useOneShotPreviewCallback;
private Handler previewHandler;
private int previewMessage;
PreviewCallback(CameraConfigurationManager configManager, boolean useOneShotPreviewCallback) {
this.configManager = configManager;
this.useOneShotPreviewCallback = useOneShotPreviewCallback;
}
void setHandler(Handler previewHandler, int previewMessage) {
this.previewHandler = previewHandler;
this.previewMessage = previewMessage;
}
public void onPreviewFrame(byte[] data, Camera camera) {
Point cameraResolution = configManager.getCameraResolution();
if (!useOneShotPreviewCallback) {
camera.setPreviewCallback(null);
}
if (previewHandler != null) {
Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x,
cameraResolution.y, data);
message.sendToTarget();
previewHandler = null;
} else {
Log.d(TAG, "Got preview callback, but no handler for it");
}
}
}
/*
* Copyright (C) 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.decoding;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.zxing.MipcaCaptureActivity;
import com.gingersoft.gsa.cloud.zxing.camera.CameraManager;
import com.gingersoft.gsa.cloud.zxing.view.ViewfinderResultPointCallback;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import java.util.Vector;
/**
* This class handles all the messaging which comprises the state machine for capture.
*/
public final class CaptureActivityHandler extends Handler {
private static final String TAG = CaptureActivityHandler.class.getSimpleName();
private final MipcaCaptureActivity activity;
private final DecodeThread decodeThread;
private State state;
private enum State {
PREVIEW,
SUCCESS,
DONE
}
public CaptureActivityHandler(MipcaCaptureActivity activity, Vector<BarcodeFormat> decodeFormats,
String characterSet) {
this.activity = activity;
decodeThread = new DecodeThread(activity, decodeFormats, characterSet, new ViewfinderResultPointCallback(activity.getViewfinderView()));
decodeThread.start();
state = State.SUCCESS;
// Start ourselves capturing previews and decoding.
CameraManager.get().startPreview();
restartPreviewAndDecode();
}
@Override
public void handleMessage(Message message) {
if (message.what == R.id.auto_focus) {//Log.d(TAG, "Got auto-focus message");
// When one auto focus pass finishes, start another. This is the closest thing to
// continuous AF. It does seem to hunt a bit, but I'm not sure what else to do.
if (state == State.PREVIEW) {
CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
}
} else if (message.what == R.id.restart_preview) {
Log.d(TAG, "Got restart preview message");
restartPreviewAndDecode();
} else if (message.what == R.id.decode_succeeded) {
Log.d(TAG, "Got decode succeeded message");
state = State.SUCCESS;
Bundle bundle = message.getData();
/***********************************************************************/
Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//���ñ����߳�
activity.handleDecode((Result) message.obj, barcode);//���ؽ��? /***********************************************************************/
} else if (message.what == R.id.decode_failed) {// We're decoding as fast as possible, so when one decode fails, start another.
state = State.PREVIEW;
CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
} else if (message.what == R.id.return_scan_result) {
Log.d(TAG, "Got return scan result message");
activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
activity.finish();
} else if (message.what == R.id.launch_product_query) {
Log.d(TAG, "Got product query message");
String url = (String) message.obj;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
activity.startActivity(intent);
}
}
public void quitSynchronously() {
state = State.DONE;
CameraManager.get().stopPreview();
Message quit = Message.obtain(decodeThread.getHandler(), R.id.quit);
quit.sendToTarget();
try {
decodeThread.join();
} catch (InterruptedException e) {
// continue
}
// Be absolutely sure we don't send any queued up messages
removeMessages(R.id.decode_succeeded);
removeMessages(R.id.decode_failed);
}
private void restartPreviewAndDecode() {
if (state == State.SUCCESS) {
state = State.PREVIEW;
CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
activity.drawViewfinder();
}
}
}
/*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.decoding;
import android.content.Intent;
import android.net.Uri;
import com.google.zxing.BarcodeFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
import java.util.regex.Pattern;
final class DecodeFormatManager {
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
static final Vector<BarcodeFormat> PRODUCT_FORMATS;
static final Vector<BarcodeFormat> ONE_D_FORMATS;
static final Vector<BarcodeFormat> QR_CODE_FORMATS;
static final Vector<BarcodeFormat> DATA_MATRIX_FORMATS;
static {
PRODUCT_FORMATS = new Vector<BarcodeFormat>(5);
PRODUCT_FORMATS.add(BarcodeFormat.UPC_A);
PRODUCT_FORMATS.add(BarcodeFormat.UPC_E);
PRODUCT_FORMATS.add(BarcodeFormat.EAN_13);
PRODUCT_FORMATS.add(BarcodeFormat.EAN_8);
PRODUCT_FORMATS.add(BarcodeFormat.RSS_14);
ONE_D_FORMATS = new Vector<BarcodeFormat>(PRODUCT_FORMATS.size() + 4);
ONE_D_FORMATS.addAll(PRODUCT_FORMATS);
ONE_D_FORMATS.add(BarcodeFormat.CODE_39);
ONE_D_FORMATS.add(BarcodeFormat.CODE_93);
ONE_D_FORMATS.add(BarcodeFormat.CODE_128);
ONE_D_FORMATS.add(BarcodeFormat.ITF);
QR_CODE_FORMATS = new Vector<BarcodeFormat>(1);
QR_CODE_FORMATS.add(BarcodeFormat.QR_CODE);
DATA_MATRIX_FORMATS = new Vector<BarcodeFormat>(1);
DATA_MATRIX_FORMATS.add(BarcodeFormat.DATA_MATRIX);
}
private DecodeFormatManager() {}
static Vector<BarcodeFormat> parseDecodeFormats(Intent intent) {
List<String> scanFormats = null;
String scanFormatsString = intent.getStringExtra(Intents.Scan.SCAN_FORMATS);
if (scanFormatsString != null) {
scanFormats = Arrays.asList(COMMA_PATTERN.split(scanFormatsString));
}
return parseDecodeFormats(scanFormats, intent.getStringExtra(Intents.Scan.MODE));
}
static Vector<BarcodeFormat> parseDecodeFormats(Uri inputUri) {
List<String> formats = inputUri.getQueryParameters(Intents.Scan.SCAN_FORMATS);
if (formats != null && formats.size() == 1 && formats.get(0) != null){
formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0)));
}
return parseDecodeFormats(formats, inputUri.getQueryParameter(Intents.Scan.MODE));
}
private static Vector<BarcodeFormat> parseDecodeFormats(Iterable<String> scanFormats,
String decodeMode) {
if (scanFormats != null) {
Vector<BarcodeFormat> formats = new Vector<BarcodeFormat>();
try {
for (String format : scanFormats) {
formats.add(BarcodeFormat.valueOf(format));
}
return formats;
} catch (IllegalArgumentException iae) {
// ignore it then
}
}
if (decodeMode != null) {
if (Intents.Scan.PRODUCT_MODE.equals(decodeMode)) {
return PRODUCT_FORMATS;
}
if (Intents.Scan.QR_CODE_MODE.equals(decodeMode)) {
return QR_CODE_FORMATS;
}
if (Intents.Scan.DATA_MATRIX_MODE.equals(decodeMode)) {
return DATA_MATRIX_FORMATS;
}
if (Intents.Scan.ONE_D_MODE.equals(decodeMode)) {
return ONE_D_FORMATS;
}
}
return null;
}
}
/*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.decoding;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.zxing.MipcaCaptureActivity;
import com.gingersoft.gsa.cloud.zxing.camera.CameraManager;
import com.gingersoft.gsa.cloud.zxing.camera.PlanarYUVLuminanceSource;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.DecodeHintType;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.common.HybridBinarizer;
import java.util.Hashtable;
final class DecodeHandler extends Handler {
private static final String TAG = DecodeHandler.class.getSimpleName();
private final MipcaCaptureActivity activity;
private final MultiFormatReader multiFormatReader;
DecodeHandler(MipcaCaptureActivity activity, Hashtable<DecodeHintType, Object> hints) {
multiFormatReader = new MultiFormatReader();
multiFormatReader.setHints(hints);
this.activity = activity;
}
@Override
public void handleMessage(Message message) {
if (message.what == R.id.decode) {//Log.d(TAG, "Got decode message");
decode((byte[]) message.obj, message.arg1, message.arg2);
} else if (message.what == R.id.quit) {
Looper.myLooper().quit();
}
}
/**
* Decode the data within the viewfinder rectangle, and time how long it took. For efficiency,
* reuse the same reader objects from one decode to the next.
*
* @param data The YUV preview frame.
* @param width The width of the preview frame.
* @param height The height of the preview frame.
*/
private void decode(byte[] data, int width, int height) {
long start = System.currentTimeMillis();
Result rawResult = null;
//modify here
byte[] rotatedData = new byte[data.length];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++)
rotatedData[x * height + height - y - 1] = data[x + y * width];
}
int tmp = width; // Here we are swapping, that's the difference to #11
width = height;
height = tmp;
PlanarYUVLuminanceSource source = CameraManager.get().buildLuminanceSource(rotatedData, width, height);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
try {
rawResult = multiFormatReader.decodeWithState(bitmap);
} catch (ReaderException re) {
// continue
} finally {
multiFormatReader.reset();
}
if (rawResult != null) {
long end = System.currentTimeMillis();
Log.d(TAG, "Found barcode (" + (end - start) + " ms):\n" + rawResult.toString());
Message message = Message.obtain(activity.getHandler(), R.id.decode_succeeded, rawResult);
Bundle bundle = new Bundle();
bundle.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap());
message.setData(bundle);
//Log.d(TAG, "Sending decode succeeded message...");
message.sendToTarget();
} else {
Message message = Message.obtain(activity.getHandler(), R.id.decode_failed);
message.sendToTarget();
}
}
}
/*
* Copyright (C) 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.decoding;
import android.os.Handler;
import android.os.Looper;
import com.gingersoft.gsa.cloud.zxing.MipcaCaptureActivity;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.DecodeHintType;
import com.google.zxing.ResultPointCallback;
import java.util.Hashtable;
import java.util.Vector;
import java.util.concurrent.CountDownLatch;
/**
* This thread does all the heavy lifting of decoding the images.
* 解码线程
*/
final class DecodeThread extends Thread {
public static final String BARCODE_BITMAP = "barcode_bitmap";
private final MipcaCaptureActivity activity;
private final Hashtable<DecodeHintType, Object> hints;
private Handler handler;
private final CountDownLatch handlerInitLatch;
DecodeThread(MipcaCaptureActivity activity,
Vector<BarcodeFormat> decodeFormats,
String characterSet,
ResultPointCallback resultPointCallback) {
this.activity = activity;
handlerInitLatch = new CountDownLatch(1);
hints = new Hashtable<DecodeHintType, Object>(3);
if (decodeFormats == null || decodeFormats.isEmpty()) {
decodeFormats = new Vector<BarcodeFormat>();
decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
}
hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
if (characterSet != null) {
hints.put(DecodeHintType.CHARACTER_SET, characterSet);
}
hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
}
Handler getHandler() {
try {
handlerInitLatch.await();
} catch (InterruptedException ie) {
// continue?
}
return handler;
}
@Override
public void run() {
Looper.prepare();
handler = new DecodeHandler(activity, hints);
handlerInitLatch.countDown();
Looper.loop();
}
}
/*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.decoding;
import android.app.Activity;
import android.content.DialogInterface;
/**
* Simple listener used to exit the app in a few cases.
*
*/
public final class FinishListener
implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener, Runnable {
private final Activity activityToFinish;
public FinishListener(Activity activityToFinish) {
this.activityToFinish = activityToFinish;
}
public void onCancel(DialogInterface dialogInterface) {
run();
}
public void onClick(DialogInterface dialogInterface, int i) {
run();
}
public void run() {
activityToFinish.finish();
}
}
/*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.decoding;
import android.app.Activity;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
/**
* Finishes an activity after a period of inactivity.
*/
public final class InactivityTimer {
private static final int INACTIVITY_DELAY_SECONDS = 5 * 60;
private final ScheduledExecutorService inactivityTimer =
Executors.newSingleThreadScheduledExecutor(new DaemonThreadFactory());
private final Activity activity;
private ScheduledFuture<?> inactivityFuture = null;
public InactivityTimer(Activity activity) {
this.activity = activity;
onActivity();
}
public void onActivity() {
cancel();
inactivityFuture = inactivityTimer.schedule(new FinishListener(activity),
INACTIVITY_DELAY_SECONDS,
TimeUnit.SECONDS);
}
private void cancel() {
if (inactivityFuture != null) {
inactivityFuture.cancel(true);
inactivityFuture = null;
}
}
public void shutdown() {
cancel();
inactivityTimer.shutdown();
}
private static final class DaemonThreadFactory implements ThreadFactory {
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable);
thread.setDaemon(true);
return thread;
}
}
}
/*
* Copyright (C) 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.decoding;
/**
* This class provides the constants to use when sending an Intent to Barcode Scanner.
* These strings are effectively API and cannot be changed.
*/
public final class Intents {
private Intents() {
}
public static final class Scan {
/**
* Send this intent to open the Barcodes app in scanning mode, find a barcode, and return
* the results.
*/
public static final String ACTION = "com.google.zxing.client.android.SCAN";
/**
* By default, sending Scan.ACTION will decode all barcodes that we understand. However it
* may be useful to limit scanning to certain formats. Use Intent.putExtra(MODE, value) with
* one of the values below ({@link #PRODUCT_MODE}, {@link #ONE_D_MODE}, {@link #QR_CODE_MODE}).
* Optional.
*
* Setting this is effectively shorthnad for setting explicit formats with {@link #SCAN_FORMATS}.
* It is overridden by that setting.
*/
public static final String MODE = "SCAN_MODE";
/**
* Comma-separated list of formats to scan for. The values must match the names of
* {@link com.google.zxing.BarcodeFormat}s, such as {@link com.google.zxing.BarcodeFormat#EAN_13}.
* Example: "EAN_13,EAN_8,QR_CODE"
*
* This overrides {@link #MODE}.
*/
public static final String SCAN_FORMATS = "SCAN_FORMATS";
/**
* @see com.google.zxing.DecodeHintType#CHARACTER_SET
*/
public static final String CHARACTER_SET = "CHARACTER_SET";
/**
* Decode only UPC and EAN barcodes. This is the right choice for shopping apps which get
* prices, reviews, etc. for products.
*/
public static final String PRODUCT_MODE = "PRODUCT_MODE";
/**
* Decode only 1D barcodes (currently UPC, EAN, Code 39, and Code 128).
*/
public static final String ONE_D_MODE = "ONE_D_MODE";
/**
* Decode only QR codes.
*/
public static final String QR_CODE_MODE = "QR_CODE_MODE";
/**
* Decode only Data Matrix codes.
*/
public static final String DATA_MATRIX_MODE = "DATA_MATRIX_MODE";
/**
* If a barcode is found, Barcodes returns RESULT_OK to onActivityResult() of the app which
* requested the scan via startSubActivity(). The barcodes contents can be retrieved with
* intent.getStringExtra(RESULT). If the user presses Back, the result code will be
* RESULT_CANCELED.
*/
public static final String RESULT = "SCAN_RESULT";
/**
* Call intent.getStringExtra(RESULT_FORMAT) to determine which barcode format was found.
* See Contents.Format for possible values.
*/
public static final String RESULT_FORMAT = "SCAN_RESULT_FORMAT";
/**
* Setting this to false will not save scanned codes in the history.
*/
public static final String SAVE_HISTORY = "SAVE_HISTORY";
private Scan() {
}
}
public static final class Encode {
/**
* Send this intent to encode a piece of data as a QR code and display it full screen, so
* that another person can scan the barcode from your screen.
*/
public static final String ACTION = "com.google.zxing.client.android.ENCODE";
/**
* The data to encode. Use Intent.putExtra(DATA, data) where data is either a String or a
* Bundle, depending on the type and format specified. Non-QR Code formats should
* just use a String here. For QR Code, see Contents for details.
*/
public static final String DATA = "ENCODE_DATA";
/**
* The type of data being supplied if the format is QR Code. Use
* Intent.putExtra(TYPE, type) with one of Contents.Type.
*/
public static final String TYPE = "ENCODE_TYPE";
/**
* The barcode format to be displayed. If this isn't specified or is blank,
* it defaults to QR Code. Use Intent.putExtra(FORMAT, format), where
* format is one of Contents.Format.
*/
public static final String FORMAT = "ENCODE_FORMAT";
private Encode() {
}
}
public static final class SearchBookContents {
/**
* Use Google Book Search to search the contents of the book provided.
*/
public static final String ACTION = "com.google.zxing.client.android.SEARCH_BOOK_CONTENTS";
/**
* The book to search, identified by ISBN number.
*/
public static final String ISBN = "ISBN";
/**
* An optional field which is the text to search for.
*/
public static final String QUERY = "QUERY";
private SearchBookContents() {
}
}
public static final class WifiConnect {
/**
* Internal intent used to trigger connection to a wi-fi network.
*/
public static final String ACTION = "com.google.zxing.client.android.WIFI_CONNECT";
/**
* The network to connect to, all the configuration provided here.
*/
public static final String SSID = "SSID";
/**
* The network to connect to, all the configuration provided here.
*/
public static final String TYPE = "TYPE";
/**
* The network to connect to, all the configuration provided here.
*/
public static final String PASSWORD = "PASSWORD";
private WifiConnect() {
}
}
public static final class Share {
/**
* Give the user a choice of items to encode as a barcode, then render it as a QR Code and
* display onscreen for a friend to scan with their phone.
*/
public static final String ACTION = "com.google.zxing.client.android.SHARE";
private Share() {
}
}
}
package com.gingersoft.gsa.cloud.zxing.decoding;
import android.graphics.Bitmap;
import com.google.zxing.LuminanceSource;
/**
* Created by Administrator on 2017/5/5 0005.
*/
public class RGBLuminanceSource extends LuminanceSource {
private byte bitmapPixels[];
public RGBLuminanceSource(Bitmap bitmap) {
super(bitmap.getWidth(), bitmap.getHeight());
// 首先,要取得该图片的像素数组内容
int[] data = new int[bitmap.getWidth() * bitmap.getHeight()];
this.bitmapPixels = new byte[bitmap.getWidth() * bitmap.getHeight()];
bitmap.getPixels(data, 0, getWidth(), 0, 0, getWidth(), getHeight());
// 将int数组转换为byte数组
for (int i = 0; i < data.length; i++) {
this.bitmapPixels[i] = (byte) data[i];
}
}
@Override
public byte[] getMatrix() {
// 返回我们生成好的像素数据
return bitmapPixels;
}
@Override
public byte[] getRow(int y, byte[] row) {
// 这里要得到指定行的像素数据
System.arraycopy(bitmapPixels, y * getWidth(), row, 0, getWidth());
return row;
}
}
/*
* Copyright (C) 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.view;
import com.google.zxing.ResultPoint;
import com.google.zxing.ResultPointCallback;
public final class ViewfinderResultPointCallback implements ResultPointCallback {
private final ViewfinderView viewfinderView;
public ViewfinderResultPointCallback(ViewfinderView viewfinderView) {
this.viewfinderView = viewfinderView;
}
public void foundPossibleResultPoint(ResultPoint point) {
viewfinderView.addPossibleResultPoint(point);
}
}
/*
* Copyright (C) 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.view;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.View;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.zxing.camera.CameraManager;
import com.google.zxing.ResultPoint;
import com.jess.arms.utils.ArmsUtils;
import java.util.Collection;
import java.util.HashSet;
/**
* This view is overlaid on top of the camera preview. It adds the viewfinder
* rectangle and partial transparency outside it, as well as the laser scanner
* animation and result points.
*/
public final class ViewfinderView extends View {
private static final String TAG = "log";
/**
* 刷新界面的时间
*/
private static final long ANIMATION_DELAY = 10L;
private static final int OPAQUE = 0xFF;
/**
* 四个绿色边角对应的长度
*/
private int ScreenRate;
/**
* 四个绿色边角对应的宽度
*/
private static final int CORNER_WIDTH = 10;
/**
* 扫描框中的中间线的宽度
*/
private static final int MIDDLE_LINE_WIDTH = 6;
/**
* 扫描框中的中间线的与扫描框左右的间隙
*/
private static final int MIDDLE_LINE_PADDING = 5;
/**
* 中间那条线每次刷新移动的距离
*/
private static final int SPEEN_DISTANCE = 5;
/**
* 手机的屏幕密度
*/
private static float density;
/**
* 字体大小
*/
private final int TEXT_SIZE = (int) getResources().getDimension(R.dimen.sp_14);
/**
* 字体距离扫描框下面的距离
*/
private static final int TEXT_PADDING_TOP = 50;
/**
* 画笔对象的引用
*/
private Paint paint;
/**
* 中间滑动线的最顶端位置
*/
private int slideTop;
/**
* 中间滑动线的最底端位置
*/
private int slideBottom;
private StaticLayout layoutBottom;//绘制扫描框下字体
private TextPaint textPaint;
/**
* 将扫描的二维码拍下来,这里没有这个功能,暂时不考虑
*/
private Bitmap resultBitmap;
private final int maskColor;
private final int resultColor;
private final int resultPointColor;
private Collection<ResultPoint> possibleResultPoints;
private Collection<ResultPoint> lastPossibleResultPoints;
boolean isFirst;
public ViewfinderView(Context context, AttributeSet attrs) {
super(context, attrs);
density = context.getResources().getDisplayMetrics().density;
//将像素转换成dp
ScreenRate = (int) (20 * density);
paint = new Paint();
Resources resources = getResources();
maskColor = resources.getColor(R.color.viewfinder_mask);
resultColor = resources.getColor(R.color.result_view);
resultPointColor = resources.getColor(R.color.possible_result_points);
possibleResultPoints = new HashSet<ResultPoint>(5);
}
@Override
public void onDraw(Canvas canvas) {
//中间的扫描框,你要修改扫描框的大小,去CameraManager里面修改
CameraManager.init(this.getContext());
Rect frame = CameraManager.get().getFramingRect();
if (frame == null) {
return;
}
//初始化中间线滑动的最上边和最下边
if (!isFirst) {
isFirst = true;
slideTop = frame.top;
slideBottom = frame.bottom;
}
//获取屏幕的宽和高
int width = canvas.getWidth();
int height = canvas.getHeight();
paint.setColor(resultBitmap != null ? resultColor : maskColor);
//画出扫描框外面的阴影部分,共四个部分,扫描框的上面到屏幕上面,扫描框的下面到屏幕下面
//扫描框的左边面到屏幕左边,扫描框的右边到屏幕右边
canvas.drawRect(0, 0, width, frame.top, paint);
canvas.drawRect(0, frame.top, frame.left, frame.bottom + 1, paint);
canvas.drawRect(frame.right + 1, frame.top, width, frame.bottom + 1,
paint);
canvas.drawRect(0, frame.bottom + 1, width, height, paint);
if (resultBitmap != null) {
// Draw the opaque result bitmap over the scanning rectangle
paint.setAlpha(OPAQUE);
canvas.drawBitmap(resultBitmap, frame.left, frame.top, paint);
} else {
//画扫描框边上的角,总共8个部分
// int themeColor = (Integer) SPUtils.get(SApplication.getInstance(), DefaultConfig.THEME_COLOR, getResources().getColor(R.color.theme_color));
int themeColor = getResources().getColor(R.color.theme_color);
// paint.setColor(Color.GREEN);
paint.setColor(themeColor);
canvas.drawRect(frame.left, frame.top, frame.left + ScreenRate,
frame.top + CORNER_WIDTH, paint);
canvas.drawRect(frame.left, frame.top, frame.left + CORNER_WIDTH, frame.top
+ ScreenRate, paint);
canvas.drawRect(frame.right - ScreenRate, frame.top, frame.right,
frame.top + CORNER_WIDTH, paint);
canvas.drawRect(frame.right - CORNER_WIDTH, frame.top, frame.right, frame.top
+ ScreenRate, paint);
canvas.drawRect(frame.left, frame.bottom - CORNER_WIDTH, frame.left
+ ScreenRate, frame.bottom, paint);
canvas.drawRect(frame.left, frame.bottom - ScreenRate,
frame.left + CORNER_WIDTH, frame.bottom, paint);
canvas.drawRect(frame.right - ScreenRate, frame.bottom - CORNER_WIDTH,
frame.right, frame.bottom, paint);
canvas.drawRect(frame.right - CORNER_WIDTH, frame.bottom - ScreenRate,
frame.right, frame.bottom, paint);
//绘制中间的线,每次刷新界面,中间的线往下移动SPEEN_DISTANCE
slideTop += SPEEN_DISTANCE;
if (slideTop >= frame.bottom) {
slideTop = frame.top;
}
canvas.drawRect(frame.left + MIDDLE_LINE_PADDING, slideTop - MIDDLE_LINE_WIDTH / 2, frame.right - MIDDLE_LINE_PADDING, slideTop + MIDDLE_LINE_WIDTH / 2, paint);
if (textPaint == null) {
textPaint = new TextPaint();
}
//画扫描框下面的字
textPaint.setColor(Color.WHITE);
textPaint.setTextSize(TEXT_SIZE);
// textPaint.setAlpha(0x40);
textPaint.setTypeface(Typeface.create("System", Typeface.BOLD));
if (layoutBottom == null) {
layoutBottom = new StaticLayout("請掃描二維碼", textPaint, (frame.right - frame.left), Layout.Alignment.ALIGN_CENTER, 1.4F, 0.0F, true);
}
canvas.save();//锁画布(为了保存之前的画布状态)
//开始绘制的位置,相对偏移
canvas.translate(frame.left, (float) (frame.bottom) + ArmsUtils.dip2px(getContext(), 50));
layoutBottom.draw(canvas);
canvas.restore();
//识别闪烁点
// Collection<ResultPoint> currentPossible = possibleResultPoints;
// Collection<ResultPoint> currentLast = lastPossibleResultPoints;
// if (currentPossible.isEmpty()) {
// lastPossibleResultPoints = null;
// } else {
// possibleResultPoints = new HashSet<ResultPoint>(5);
// lastPossibleResultPoints = currentPossible;
// paint.setAlpha(OPAQUE);
// paint.setColor(resultPointColor);
// for (ResultPoint point : currentPossible) {
// canvas.drawCircle(frame.left + point.getX(), frame.top
// + point.getY(), 6.0f, paint);
// }
// }
// if (currentLast != null) {
// paint.setAlpha(OPAQUE / 2);
// paint.setColor(resultPointColor);
// for (ResultPoint point : currentLast) {
// canvas.drawCircle(frame.left + point.getX(), frame.top
// + point.getY(), 3.0f, paint);
// }
// }
//只刷新扫描框的内容,其他地方不刷新
postInvalidateDelayed(ANIMATION_DELAY, frame.left, frame.top,
frame.right, frame.bottom);
}
}
public void drawViewfinder() {
resultBitmap = null;
invalidate();
}
/**
* Draw a bitmap with the result points highlighted instead of the live
* scanning display.
*
* @param barcode An image of the decoded barcode.
*/
public void drawResultBitmap(Bitmap barcode) {
resultBitmap = barcode;
invalidate();
}
public void addPossibleResultPoint(ResultPoint point) {
possibleResultPoints.add(point);
}
}
......@@ -4,49 +4,67 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/topbar"
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
app:qmui_topbar_title_color="@color/theme_white_color" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/head_height">
<SurfaceView
android:id="@+id/preview_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"/>
android:layout_height="match_parent" >
<!-- <SurfaceView-->
<!-- android:id="@+id/preview_view"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_gravity="center"/>-->
<com.gingersoft.gsa.cloud.zxing.view.ViewfinderView
android:id="@+id/viewfinder_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<!-- <com.gingersoft.gsa.cloud.zxing.view.ViewfinderView-->
<!-- android:id="@+id/viewfinder_view"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content" />-->
<LinearLayout
android:id="@+id/title_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical">
<!-- <LinearLayout-->
<!-- android:id="@+id/title_layout"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_alignParentTop="true"-->
<!-- android:orientation="vertical">-->
<!-- <com.zxing.view.ViewfinderView-->
<!-- android:id="@+id/viewfinder_view"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content" />-->
<!-- <include layout="@layout/title_bar_" />-->
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/topbar"
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
app:qmui_topbar_title_color="@color/theme_white_color" />
<TextView
android:id="@+id/btn_album"
android:layout_margin="@dimen/dp_10"
android:text="相冊"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:text="相冊"
android:paddingLeft="@dimen/normal_space12"
android:paddingRight="@dimen/normal_space12"
android:paddingTop="@dimen/normal_space5"
android:paddingBottom="@dimen/normal_space5"
android:textColor="@color/white"
android:layout_below="@+id/topbar"
android:layout_marginTop="@dimen/head_height"
android:background="@drawable/shape_delivery_item_btn_normal"
android:textSize="@dimen/font_normal2"
android:layout_gravity="right"/>
</LinearLayout>
<com.dlazaro66.qrcodereaderview.QRCodeReaderView
android:id="@+id/qrdecoderview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/head_height"/>
<com.gingersoft.gsa.cloud.zxing.PointsOverlayView
android:id="@+id/points_overlay_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- </LinearLayout>-->
</RelativeLayout>
</FrameLayout>
\ No newline at end of file
package com.gingersoft.gsa.cloud.download;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.constans.ResultConstans;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
import com.gingersoft.gsa.cloud.download.mvp.ui.activity.DownloadActivity;
......@@ -116,6 +120,11 @@ public class ComponentDownload implements IComponent {
private void openActivity(CC cc) {
CCUtil.navigateTo(cc, DownloadActivity.class);
// int fromPage = cc.getParamItem("fromPage");
// Intent intent = CCUtil.createNavigateIntent(cc, DownloadActivity.class);
// intent.putExtra("fromPage", fromPage);
// Activity currentActivity = GsaCloudApplication.getAppContext().getCurrentActivity();
// currentActivity.startActivityForResult(intent, 1);
CC.sendCCResult(cc.getCallId(), CCResult.success());
}
......
......@@ -16,6 +16,7 @@ import android.widget.TextView;
import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCUtil;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.constans.ResultConstans;
import com.gingersoft.gsa.cloud.download.R;
import com.gingersoft.gsa.cloud.download.R2;
import com.gingersoft.gsa.cloud.download.di.component.DaggerDownloadComponent;
......@@ -76,6 +77,7 @@ public class DownloadActivity extends BaseActivity<DownloadPresenter> implements
*/
private int fromPage = 1;
@Override
public void setupActivityComponent(@NonNull AppComponent appComponent) {
DaggerDownloadComponent //如找不到该类,请编译一下项目
......@@ -138,8 +140,10 @@ public class DownloadActivity extends BaseActivity<DownloadPresenter> implements
.setActionName("showMainActivity")
.build()
.call();
}else {
setResult(ResultConstans.DOWNLOAD_PAGE_BACK);
}
killMyself();
finish();
}
@Override
......@@ -151,14 +155,7 @@ public class DownloadActivity extends BaseActivity<DownloadPresenter> implements
public void initTopBar() {
tv_title.setText("數據下載");
btn_back.setOnClickListener(v -> {
if (fromPage == 1) {
CC.obtainBuilder("Component.Main")
.setActionName("showMainActivity")
.build()
.call();
}
killMyself();
onBackPressed();
});
btn_refresh.setOnClickListener(v -> mPresenter.downAllList());
}
......@@ -207,7 +204,7 @@ public class DownloadActivity extends BaseActivity<DownloadPresenter> implements
@Override
public void killMyself() {
mPresenter.stopDownDisposable();
finish();
onBackPressed();
}
@Override
......
......@@ -94,8 +94,6 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/frame_top"
app:layout_constraintVertical_weight="1" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>
\ No newline at end of file
......@@ -138,7 +138,10 @@ public class BaseLoginPresenter<M extends BaseLoginContract.Model, V extends Bas
@Override
public void onError(Throwable t) {
super.onError(t);
if (IAcitivity instanceof LoginActivity) {
} else {
mRootView.launchActivity(new Intent(IAcitivity, LoginActivity.class));
}
}
});
}
......
......@@ -14,6 +14,7 @@ import androidx.annotation.Nullable;
* 首頁點餐
*/
public class MainOrderingAdapter extends BaseQuickAdapter<Function, BaseViewHolder> {
public MainOrderingAdapter(int layoutResId, @Nullable List<Function> data) {
super(layoutResId, data);
}
......
......@@ -186,6 +186,12 @@
android:orientation="vertical"
android:paddingTop="@dimen/dp_16">
<LinearLayout
android:id="@+id/ll_management"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_function_name2"
android:layout_width="wrap_content"
......@@ -207,6 +213,14 @@
android:layout_height="@dimen/dp_1"
android:background="#F0F0F0"
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_staff_management"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_function_name3"
......@@ -214,7 +228,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_20"
android:visibility="gone"
android:visibility="visible"
android:textColor="#181818"
android:textSize="@dimen/dp_14" />
......@@ -222,10 +236,11 @@
android:id="@+id/rv_staff_management"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:visibility="visible"
android:layout_marginLeft="@dimen/main_recyclerview_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/main_recyclerview_marginRight" />
</LinearLayout>
</LinearLayout>
</com.lihang.ShadowLayout>
<!-- 點餐模塊-->
......
......@@ -82,7 +82,7 @@ class CoolWeatherNetwork {
suspend fun noticePersonnel(requestBody: RequestBody) = appService.noticePersonnel(requestBody).await()
suspend fun getTransportationConfig(restaurantId: String) = systemService.getTransportationConfig(restaurantId).await()
// suspend fun getTransportationConfig(restaurantId: String) = systemService.getTransportationConfig(restaurantId).await()
private suspend fun <T> Call<T>.await(): T {
return suspendCoroutine { continuation ->
......
......@@ -69,6 +69,6 @@ interface WeatherService {
@POST("printerRecording/add")
fun addPrj(@Body requestBody: RequestBody): Call<String>
@GET("restaurantTransportationConfig/list")
fun getTransportationConfig(@Query("restaurantId") restaurantId: String):Call<TransportationBean>
// @GET("restaurantTransportationConfig/list")
// fun getTransportationConfig(@Query("restaurantId") restaurantId: String):Call<TransportationBean>
}
\ No newline at end of file
......@@ -16,6 +16,7 @@ import androidx.recyclerview.widget.RecyclerView.Adapter
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import com.gingersoft.gsa.other_order_mode.databinding.LayoutDeliveryOrderItemBinding
import com.gingersoft.gsa.other_order_mode.databinding.LayoutOtherOrderItemBinding
import com.scwang.smartrefresh.layout.util.SmartUtil.dp2px
class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.ViewHolder>() {
......
......@@ -100,6 +100,9 @@ public class PrintBill extends PrinterRoot {
layout.addView(getLine(mContext));
layout.addView(getDiningBillPayMethod(mContext, MyOrderManage.getInstance().getBillMoney()));
layout.addView(getLine(mContext));
// layout.addView(getTableMealMemberIntegerView(mContext,));
return zoomBitmap(deviceBean, viewToBitmap(mContext, layout));
}
......
......@@ -563,6 +563,29 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
return view;
}
protected View getTableMealMemberIntegerView(Context mContext, OrderDetails.DataBean data) {
View view = View.inflate(mContext, R.layout.print_model_takeaway_member_integer_info, null);
TextView tvMemberNum = view.findViewById(R.id.tv_print_model_member_number);//會員號碼
TextView tvMemberName = view.findViewById(R.id.tv_print_model_member_name);//會員名稱
TextView tvMemberPhone = view.findViewById(R.id.tv_print_model_member_phone);//會員電話
TextView tvNowPoint = view.findViewById(R.id.tv_print_model_nowPoints);//現在的積分
TextView tvAddPoints = view.findViewById(R.id.tv_print_model_addPoints);//本次添加積分
TextView tvOldPoints = view.findViewById(R.id.tv_print_model_oldPoints);//之前的積分
if (data.getAddPoints() != 0 || data.getOldPoints() != 0 || data.getAddPoints() != 0) {
tvAddPoints.setText("本次積分:" + data.getAddPoints());
tvNowPoint.setText("結餘積分:" + data.getNowPoints());
tvOldPoints.setText("上次積分:" + data.getOldPoints());
//名稱中間替換為*號
if (data.getMEMBER_NAME() != null && data.getMEMBER_NAME().length() > 0) {
tvMemberName.setText("會員名稱:" + getReplaceAfter(data.getMEMBER_NAME()));
}
if (data.getPHONE() != null && data.getPHONE().length() > 0) {
tvMemberPhone.setText("會員電話:" + getReplaceAfter(data.getPHONE()));
}
}
return view;
}
protected View getTakeawayMemberIntegerView(Context mContext, OrderDetails.DataBean data) {
View view = View.inflate(mContext, R.layout.print_model_takeaway_member_integer_info, null);
TextView tvMemberNum = view.findViewById(R.id.tv_print_model_member_number);//會員號碼
......
......@@ -2,13 +2,6 @@ package com.joe.print.mvp.print.utils;
import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import java.util.Hashtable;
public class BytesUtil {
......@@ -151,56 +144,56 @@ public class BytesUtil {
* @param size
* @return
*/
public static byte[] getZXingQRCode(String data, int size) {
try {
Hashtable<EncodeHintType, String> hints = new Hashtable<>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
//图像数据转换,使用了矩阵转换
BitMatrix bitMatrix = new QRCodeWriter().encode(data, BarcodeFormat.QR_CODE, size, size, hints);
//System.out.println("bitmatrix height:" + bitMatrix.getHeight() + " width:" + bitMatrix.getWidth());
return getBytesFromBitMatrix(bitMatrix);
} catch (WriterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public static byte[] getBytesFromBitMatrix(BitMatrix bits) {
if (bits == null) return null;
int h = bits.getHeight();
int w = (bits.getWidth() + 7) / 8;
byte[] rv = new byte[h * w + 4];
rv[0] = (byte) w;//xL
rv[1] = (byte) (w >> 8);//xH
rv[2] = (byte) h;
rv[3] = (byte) (h >> 8);
int k = 4;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
for (int n = 0; n < 8; n++) {
byte b = getBitMatrixColor(bits, j * 8 + n, i);
rv[k] += rv[k] + b;
}
k++;
}
}
return rv;
}
private static byte getBitMatrixColor(BitMatrix bits, int x, int y) {
int width = bits.getWidth();
int height = bits.getHeight();
if (x >= width || y >= height || x < 0 || y < 0) return 0;
if (bits.get(x, y)) {
return 1;
} else {
return 0;
}
}
// public static byte[] getZXingQRCode(String data, int size) {
// try {
// Hashtable<EncodeHintType, String> hints = new Hashtable<>();
// hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
// //图像数据转换,使用了矩阵转换
// BitMatrix bitMatrix = new QRCodeWriter().encode(data, BarcodeFormat.QR_CODE, size, size, hints);
// //System.out.println("bitmatrix height:" + bitMatrix.getHeight() + " width:" + bitMatrix.getWidth());
// return getBytesFromBitMatrix(bitMatrix);
// } catch (WriterException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return null;
// }
// public static byte[] getBytesFromBitMatrix(BitMatrix bits) {
// if (bits == null) return null;
//
// int h = bits.getHeight();
// int w = (bits.getWidth() + 7) / 8;
// byte[] rv = new byte[h * w + 4];
//
// rv[0] = (byte) w;//xL
// rv[1] = (byte) (w >> 8);//xH
// rv[2] = (byte) h;
// rv[3] = (byte) (h >> 8);
//
// int k = 4;
// for (int i = 0; i < h; i++) {
// for (int j = 0; j < w; j++) {
// for (int n = 0; n < 8; n++) {
// byte b = getBitMatrixColor(bits, j * 8 + n, i);
// rv[k] += rv[k] + b;
// }
// k++;
// }
// }
// return rv;
// }
// private static byte getBitMatrixColor(BitMatrix bits, int x, int y) {
// int width = bits.getWidth();
// int height = bits.getHeight();
// if (x >= width || y >= height || x < 0 || y < 0) return 0;
// if (bits.get(x, y)) {
// return 1;
// } else {
// return 0;
// }
// }
/**
* 将bitmap图转换为头四位有宽高的光栅位图
......
......@@ -98,16 +98,16 @@ public class ESCUtil {
/**
* 光栅打印二维码
*/
public static byte[] getPrintQRCode2(String data, int size){
byte[] bytes1 = new byte[4];
bytes1[0] = GS;
bytes1[1] = 0x76;
bytes1[2] = 0x30;
bytes1[3] = 0x00;
byte[] bytes2 = BytesUtil.getZXingQRCode(data, size);
return BytesUtil.byteMerger(bytes1, bytes2);
}
// public static byte[] getPrintQRCode2(String data, int size){
// byte[] bytes1 = new byte[4];
// bytes1[0] = GS;
// bytes1[1] = 0x76;
// bytes1[2] = 0x30;
// bytes1[3] = 0x00;
//
// byte[] bytes2 = BytesUtil.getZXingQRCode(data, size);
// return BytesUtil.byteMerger(bytes1, bytes2);
// }
/**
* 打印一维条形码
......
......@@ -49,10 +49,8 @@ import com.joe.print.mvp.print.utils.MyPrintUtils;
import com.joe.print.mvp.ui.adapter.DialogPrinterListAdapter;
import com.joe.print.mvp.ui.adapter.PrintProgressAdapter;
import com.yanzhenjie.recyclerview.widget.DefaultItemDecoration;
import java.util.List;
import java.util.Map;
import static com.gingersoft.gsa.cloud.constans.PrintConstans.PRINT_TYPE;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......
......@@ -61,6 +61,7 @@ public interface TableContract {
void startMealStandActivity();
void setBottomFunctionVisibility(boolean show);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
......
......@@ -52,9 +52,11 @@ public class OrderDetailItem implements Serializable {
private int person;
/**
* 订单类型
* 0#堂食
* 1#外賣
* 2#自取
* 1:堂食
* 2:外賣
* 3:掃碼點餐
* 5:預點餐
* 7:自取
*/
private int orderType;
/**總金額*/
......@@ -66,10 +68,15 @@ public class OrderDetailItem implements Serializable {
private Double rounding;
/**服務費*/
private Double serviceAmount;
/**訂單碼*/
private String billNo;
/**取餐碼*/
private String takeFoodCode;
// private String payName;
// private String orderPayType;
// private double tipsPrice;
// private byte linePayType;
/**折扣ID*/
private Long discountId;
/**折扣金額*/
......
......@@ -59,11 +59,9 @@ import com.jess.arms.utils.RxLifecycleUtils;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.uuzuche.lib_zxing.activity.CaptureActivity;
import org.simple.eventbus.EventBus;
import org.simple.eventbus.Subscriber;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -1803,12 +1801,12 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
// //添加到主食品細項最後面
// return i;
// }
boolean samePackage = item.getParentProductId() == orderDetail.getProductId() || item.getProductId() == orderDetail.getProductId();
boolean samePackage = (item.getParentProductId() == orderDetail.getProductId() || item.getProductId() == orderDetail.getProductId());
if (newOrderList.size() == nextIndex && samePackage) {
//最後一個
return nextIndex;
}
if (newOrderList.get(nextIndex).getItemType() != 3 && samePackage) {
if (newOrderList.get(nextIndex).getItemType() != 3) {
//添加到主食品細項最後面
return i;
}
......
......@@ -25,7 +25,9 @@ import com.gingersoft.gsa.cloud.constans.GoldConstants;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.database.bean.Discount;
import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.function.FunctionManager;
import com.gingersoft.gsa.cloud.print.PrinterUtils;
import com.gingersoft.gsa.cloud.table.ComponentTable;
import com.gingersoft.gsa.cloud.table.mvp.contract.OrderContentContract;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.BaseRespose;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableDetail;
......@@ -237,22 +239,28 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
}
public void initTopFunctionData() {
if (mFunctionList.size() > 0) {
mFunctionList.clear();
}
if (MyOrderManage.getInstance().isModifyOrder()) {
//修改訂單隱藏送單,印單功能
mFunctionList.add(new Function("結賬", Color.parseColor("#FFFFFF"), Color.parseColor("#DC0000"), 24));
} else {
List<Function> functions = FunctionManager.getDefault().getFunctionByResModule(IActivity, ComponentTable.table.class, ComponentTable.table.order, "order");
for (int i = 0; i < functions.size(); i++) {
if (functions.get(i).getParentId() == 0) {
functions.remove(i);
}
}
// if (functions.size() > 0) {
// mFunctionList.addAll(functions);
// } else {
mFunctionList.add(new Function("送單", Color.parseColor("#FFFFFF"), Color.parseColor("#008131"), 24));
mFunctionList.add(new Function("印單", Color.parseColor("#FFFFFF"), Color.parseColor("#FF8E04"), 24));
mFunctionList.add(new Function("結賬", Color.parseColor("#FFFFFF"), Color.parseColor("#DC0000"), 24));
mFunctionList.add(new Function("轉移", Color.parseColor("#FFFFFF"), Color.parseColor("#FF4B9DFA"), 24));
mFunctionList.add(new Function("折扣", Color.parseColor("#FFFFFF"), Color.parseColor("#008577"), 24));
// List<Function> functions = FunctionManager.getDefault().getFunctionByResModule(IActivity, ComponentTable.table.class, ComponentTable.table.order, "order");
// for (int i = 0; i < functions.size(); i++) {
// if (functions.get(i).getParentId() == 0) {
// functions.remove(i);
// }
// }
// mFunctionList.addAll(functions);
}
}
......@@ -365,7 +373,7 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
//// //打印成功
////
//// }
mRootView.sendSuccess();
mRootView.sendSuccess();
// });
}
......@@ -516,7 +524,7 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
}
public void getTable(TableBean.DataBean dataBean) {
mModel.getTable(dataBean.getId(),dataBean.getTableNumber())
mModel.getTable(dataBean.getId(), dataBean.getTableNumber())
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
......@@ -529,7 +537,7 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
public void onNext(@NonNull TableDetail result) {
if (result.isSuccess()) {
TableBean.DataBean tableBean = result.getData();
if(tableBean != null) {
if (tableBean != null) {
if (tableBean.getUseStatus() == 0) {
String msg = "轉移到" + tableBean.getTableName() + "號檯?";
Class[] parameterTypes = {TableBean.DataBean.class};
......
......@@ -151,11 +151,11 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
}
public void initBottomFunction() {
initBottomFunctionItem();
if (mBottomFunctionAdapter == null) {
mBottomFunctionAdapter = new BottomFunctionAdapter(IActivity, mBottomFunctionList);
mRootView.setBottomFunctionAdapter(mBottomFunctionAdapter);
}
initBottomFunctionItem();
initBottomFunctionListener();
}
......@@ -207,18 +207,30 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
public void initBottomFunctionItem() {
// List<Function> functions = FunctionManager.getDefault().getFunctionByResModule(IActivity, ComponentTable.table.class, ComponentTable.table.bottom, "bottom");
// for (int i = 0; i < functions.size(); i++) {
// if (functions.get(i).getParentId() == 0) {
// functions.remove(i);
// }
// }
// mBottomFunctionList.addAll(functions);
mBottomFunctionList.add(new Function((long) 1, "重置檯號", ArmsUtils.getColor(IActivity, R.color.theme_black), ArmsUtils.getDimens(IActivity, R.dimen.sp_14), R.mipmap.table_init));
mBottomFunctionList.add(new Function((long) 2, "轉檯", ArmsUtils.getColor(IActivity, R.color.theme_black), ArmsUtils.getDimens(IActivity, R.dimen.sp_14), R.mipmap.table_move));
mBottomFunctionList.add(new Function((long) 3, "分檯", ArmsUtils.getColor(IActivity, R.color.theme_black), ArmsUtils.getDimens(IActivity, R.dimen.sp_14), R.mipmap.table_splite));
boolean addFuctions = false;
List<Function> functions = FunctionManager.getDefault().getFunctionByResModule(IActivity, ComponentTable.table.class, ComponentTable.table.bottom, "bottom");
for (int i = 0; i < functions.size(); i++) {
if (functions.get(i).getParentId() == 0) {
//有配置餐檯操作模块
functions.remove(i);
addFuctions = true;
}
}
if (mBottomFunctionList.size() > 0) {
mBottomFunctionList.clear();
}
if (addFuctions) {
mBottomFunctionList.addAll(functions);
mRootView.setBottomFunctionVisibility(true);
mBottomFunctionAdapter.notifyDataSetChanged();
} else {
mRootView.setBottomFunctionVisibility(false);
}
// mBottomFunctionList.add(new Function((long) 1, "重置檯號", ArmsUtils.getColor(IActivity, R.color.theme_black), ArmsUtils.getDimens(IActivity, R.dimen.sp_14), R.mipmap.table_init));
// mBottomFunctionList.add(new Function((long) 2, "轉檯", ArmsUtils.getColor(IActivity, R.color.theme_black), ArmsUtils.getDimens(IActivity, R.dimen.sp_14), R.mipmap.table_move));
// mBottomFunctionList.add(new Function((long) 3, "分檯", ArmsUtils.getColor(IActivity, R.color.theme_black), ArmsUtils.getDimens(IActivity, R.dimen.sp_14), R.mipmap.table_splite));
// mBottomFunctionList.add(new Function((long) 4, "skyorder", ArmsUtils.getColor(IActivity, R.color.theme_black), ArmsUtils.getDimens(IActivity, R.dimen.sp_14), R.mipmap.table_skyorder));
mBottomFunctionList.add(new Function((long) 5, "上菜紙", ArmsUtils.getColor(IActivity, R.color.theme_black), ArmsUtils.getDimens(IActivity, R.dimen.sp_14), R.mipmap.table_paper));
// mBottomFunctionList.add(new Function((long) 5, "上菜紙", ArmsUtils.getColor(IActivity, R.color.theme_black), ArmsUtils.getDimens(IActivity, R.dimen.sp_14), R.mipmap.table_paper));
}
......@@ -735,7 +747,7 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
/**
* 刷新分檯数据
*/
private void refreshSplitTablesDialog(){
private void refreshSplitTablesDialog() {
SplitTableDialog splitTableDialog = IActivity.getSplitTableDialog();
if (splitTableDialog != null) {
//刷新餐檯
......
......@@ -89,10 +89,7 @@ import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.util.QMUIDrawableHelper;
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.uuzuche.lib_zxing.activity.CaptureActivity;
import org.simple.eventbus.EventBus;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
......@@ -572,55 +569,57 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter>
void onClickTable() {
//type取值:1qrCdoetype,2:手機號,3:memberId
// mUseMemberDialog = new UseMemberDialog(this);
mUseMemberDialog = new UseMemberDialog.BottomLayoutBuilder(this)
.setOnLayoutClickListener(new UseMemberDialog.BottomLayoutBuilder.OnLayoutClickListener() {
if(mUseMemberDialog == null) {
mUseMemberDialog = new UseMemberDialog.BottomLayoutBuilder(this)
.setOnLayoutClickListener(new UseMemberDialog.BottomLayoutBuilder.OnLayoutClickListener() {
@Override
public void onInputPhone(UseMemberDialog dialog, String phone) {
mPresenter.queryMember(2, phone, GsaCloudApplication.getGsPosShopId(mContext));
}
@Override
public void onScanAction(UseMemberDialog dialog) {
mPresenter.toScanActivity();
}
@Override
public void onInputPhone(UseMemberDialog dialog, String phone) {
mPresenter.queryMember(2, phone, GsaCloudApplication.getGsPosShopId(mContext));
}
@Override
public void setAdapter(RecyclerView recycler_member_info, UseMemberDialog.BottomLayoutBuilder layoutBuilder) {
mUseMemberLayoutBuilder = layoutBuilder;
if (mMemberInfoList == null) {
mMemberInfoList = new ArrayList<>();
@Override
public void onScanAction(UseMemberDialog dialog) {
mPresenter.toScanActivity();
}
if (mMemberInfoAdapter == null) {
mMemberInfoAdapter = new MemberInfoAdapter(mMemberInfoList);
@Override
public void setAdapter(RecyclerView recycler_member_info, UseMemberDialog.BottomLayoutBuilder layoutBuilder) {
mUseMemberLayoutBuilder = layoutBuilder;
if (mMemberInfoList == null) {
mMemberInfoList = new ArrayList<>();
}
if (mMemberInfoAdapter == null) {
mMemberInfoAdapter = new MemberInfoAdapter(mMemberInfoList);
}
recycler_member_info.setAdapter(mMemberInfoAdapter);
}
recycler_member_info.setAdapter(mMemberInfoAdapter);
}
@Override
public void onUseMember(UseMemberDialog dialog) {
MyOrderManage.getInstance().setMemberInfo(mMemberInfo);
btn_table.setBackgroundResource(R.color.pink_300);
}
@Override
public void onUseMember(UseMemberDialog dialog) {
MyOrderManage.getInstance().setMemberInfo(mMemberInfo);
btn_table.setBackgroundResource(R.color.pink_300);
}
@Override
public void clearMemberInfo() {
btn_table.setBackgroundColor(Color.parseColor("#336699"));
MyOrderManage.getInstance().setMemberInfo(null);
if (mMemberInfoList.size() > 0) {
mMemberInfoList.clear();
@Override
public void clearMemberInfo() {
btn_table.setBackgroundColor(Color.parseColor("#336699"));
MyOrderManage.getInstance().setMemberInfo(null);
if (mMemberInfoList.size() > 0) {
mMemberInfoList.clear();
}
mMemberInfoAdapter.notifyDataSetChanged();
if (mUseMemberLayoutBuilder != null) {
mUseMemberLayoutBuilder.showBottomLayoutVisibility(false);
}
}
mMemberInfoAdapter.notifyDataSetChanged();
if (mUseMemberLayoutBuilder != null) {
mUseMemberLayoutBuilder.showBottomLayoutVisibility(false);
}).setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
}
}
}).setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
}
})
.build();
})
.build();
}
mUseMemberDialog.show();
}
......
......@@ -160,7 +160,6 @@ public class TableActivity extends BaseFragmentActivity<TablePresenter> implemen
tv_show_popup.setWidth(ArmsUtils.getScreenWidth(this) / 3);
initTabAndPager();
mPresenter.initBottomFunction();
getTables(true, null);
}
......@@ -173,6 +172,7 @@ public class TableActivity extends BaseFragmentActivity<TablePresenter> implemen
@Override
protected void onResume() {
super.onResume();
mPresenter.initBottomFunction();
//開始刷新餐檯數據
onStartRefreshTableData();
}
......@@ -489,6 +489,11 @@ public class TableActivity extends BaseFragmentActivity<TablePresenter> implemen
rv_bottom_function.setItemAnimator(new DefaultItemAnimator());
}
@Override
public void setBottomFunctionVisibility(boolean show) {
rv_bottom_function.setVisibility(show == true ? View.VISIBLE : View.GONE);
}
private void initTabAndPager() {
QMUIFragmentPagerAdapter pagerAdapter = new QMUIFragmentPagerAdapter(getSupportFragmentManager()) {
@Override
......@@ -675,10 +680,6 @@ public class TableActivity extends BaseFragmentActivity<TablePresenter> implemen
mPresenter.getTables(show, refreshLayout);
}
private void setBottomFunctionVisibility(boolean show) {
rv_bottom_function.setVisibility(show == true ? View.VISIBLE : View.GONE);
}
public int getCurrentSelectTableStatus() {
return mCurrentSelectTableStatus;
}
......
......@@ -164,13 +164,9 @@ public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> impl
private void initOrderDetail(OrderDetailItem orderDetailItem) {
if (orderDetailItem != null) {
String payBill = LanguageUtils.get_language_system(this, "opentable.paybill", "結賬") + ":";
String tableName = LanguageUtils.get_language_system(this, "table.number", "檯號") + ":";
String pax = LanguageUtils.get_language_system(this, "Meal.Mannumber", "人數") + ":";
String orderNumber = LanguageUtils.get_language_system(this, "order.number", "訂單號") + ":";
String openTable = LanguageUtils.get_language_system(this, "open.table", "開台") + ":";
tv_table_name.setText(tableName + orderDetailItem.getTableName());
tv_people_num.setText(pax + orderDetailItem.getPerson());
tv_order_num.setText(orderNumber + orderDetailItem.getId());
tv_open_time.setText(openTable + TimeUtil.getStringByFormat(new Date(orderDetailItem.getCreateTime()), TimeUtil.dateFormatYMDHM));
if (!TextUtils.isEmpty(orderDetailItem.getEndTime())) {
tv_pay_time.setText(payBill + TimeUtil.getStringByFormat(new Date(orderDetailItem.getEndTime()), TimeUtil.dateFormatYMDHM));
......@@ -339,10 +335,18 @@ public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> impl
}
private void setTitleByOrderType(OrderDetailItem item) {
if (item.getOrderType() == 1) {
String mealCode = LanguageUtils.get_language_system(mContext, "meal.code", "訂單碼") + ": ";
if (item.getOrderType() == 2) {
tv_table_name.setText("外賣");
} else if (item.getOrderType() == 2) {
tv_order_num.setText(mealCode + item.getBillNo());
} else if (item.getOrderType() == 7) {
tv_table_name.setText("自取");
tv_order_num.setText(mealCode + item.getBillNo());
} else {
String tableName = LanguageUtils.get_language_system(this, "table.number", "檯號") + ": ";
String orderNumber = LanguageUtils.get_language_system(this, "order.number", "訂單號") + ": ";
tv_table_name.setText(tableName + item.getTableName());
tv_order_num.setText(orderNumber + item.getId());
}
}
......@@ -366,7 +370,7 @@ public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> impl
}
private void setBtnVisibilityByOrderType(OrderDetailItem item) {
if (item.getOrderType() == 1 || item.getOrderType() == 2) {
if (item.getOrderType() == 2 || item.getOrderType() == 7) {
//外賣自取 不可以修改訂單 取消訂單
btn_modify_order.setVisibility(View.GONE);
btn_cancel_order.setVisibility(View.GONE);
......
......@@ -69,7 +69,7 @@ public class BottomFunctionAdapter extends DefaultAdapter<Function> {
private void initItemData(Function item) {
tv_name.setText(item.getResName());
iv_icon.setImageResource(item.getIconRes());
iv_icon.setImageResource(item.getIcRes());
}
}
......
......@@ -90,15 +90,11 @@ public class OrderCenterAdapter extends DefaultAdapter<OrderDetailItem> {
@Override
public void setData(OrderDetailItem item, int position) {
String tableName = LanguageUtils.get_language_system(mContext, "table.number", "檯號") + ":";
String pax = LanguageUtils.get_language_system(mContext, "Meal.Mannumber", "人數") + ":";
String orderNumber = LanguageUtils.get_language_system(mContext, "order.number", "訂單號") + ":";
String openTable = LanguageUtils.get_language_system(mContext, "open.table", "開台") + ":";
String payTable = LanguageUtils.get_language_system(mContext, "open.table", "結賬") + ":";
String amount = LanguageUtils.get_language_system(mContext, "amount", "金額") + ":$";
tv_table_name.setText(tableName + item.getTableName());
tv_order_num.setText(orderNumber + item.getId());
tv_people_num.setText(pax + item.getPerson());
tv_open_time.setText(openTable + TimeUtil.getStringByFormat(new Date(item.getCreateTime()), TimeUtil.dateFormatYMDHM));
if (!TextUtils.isEmpty(item.getEndTime())) {
......@@ -121,10 +117,18 @@ public class OrderCenterAdapter extends DefaultAdapter<OrderDetailItem> {
}
private void setTitleByOrderType(OrderDetailItem item) {
if (item.getOrderType() == 1) {
String mealCode = LanguageUtils.get_language_system(mContext, "meal.code", "訂單碼") + ": ";
if (item.getOrderType() == 2) {
tv_table_name.setText("外賣");
} else if (item.getOrderType() == 2) {
tv_order_num.setText(mealCode + item.getBillNo());
} else if (item.getOrderType() == 7) {
tv_table_name.setText("自取");
tv_order_num.setText(mealCode + item.getBillNo());
} else {
String tableName = LanguageUtils.get_language_system(mContext, "table.number", "檯號") + ": ";
String orderNumber = LanguageUtils.get_language_system(mContext, "order.number", "訂單號") + ": ";
tv_table_name.setText(tableName + item.getTableName());
tv_order_num.setText(orderNumber + item.getId());
}
}
......@@ -171,7 +175,7 @@ public class OrderCenterAdapter extends DefaultAdapter<OrderDetailItem> {
}
private void setBtnVisibilityByOrderType(OrderDetailItem item) {
if (item.getOrderType() == 1 || item.getOrderType() == 2) {
if (item.getOrderType() == 2 || item.getOrderType() == 7) {
//外賣自取 不可以修改訂單 取消訂單
btn_modify_order.setVisibility(View.GONE);
btn_cancel_order.setVisibility(View.GONE);
......
......@@ -271,7 +271,7 @@ public class UseMemberDialog extends Dialog {
btn_scan = view.findViewById(R.id.btn_scan);
ll_bottom = view.findViewById(R.id.ll_bottom);
btn_use_member = view.findViewById(R.id.btn_use_member);
btn_clear_member = view.findViewById(R.id.btn_use_member);
btn_clear_member = view.findViewById(R.id.btn_clear_member);
initTopbar();
initRecyclerLayout();
......@@ -360,6 +360,7 @@ public class UseMemberDialog extends Dialog {
public void showBottomLayoutVisibility(boolean show){
ll_bottom.setVisibility(show?View.VISIBLE:View.GONE);
btn_scan.setVisibility(!show?View.VISIBLE:View.GONE);
}
private String getTvPhone() {
......
......@@ -72,7 +72,6 @@
android:visibility="gone"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_14" />
</LinearLayout>
<TextView
......@@ -248,7 +247,6 @@
android:text=""
android:textColor="@color/black"
android:textSize="@dimen/sp_16" />
</RelativeLayout>
<View
......
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 to comment