Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
supplier
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王宇航
supplier
Commits
649170bf
Commit
649170bf
authored
Aug 15, 2020
by
宁斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
功能权限控制完善
parent
03737d19
Show whitespace changes
Inline
Side-by-side
Showing
51 changed files
with
514 additions
and
2557 deletions
+514
-2557
base-module/build.gradle
+3
-4
base-module/src/main/java/com/gingersoft/gsa/cloud/constans/HttpsConstans.java
+7
-7
base-module/src/main/java/com/gingersoft/gsa/cloud/constans/ResultConstans.java
+14
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/function/FunctionManager.java
+18
-18
base-module/src/main/java/com/gingersoft/gsa/cloud/globalconfig/applyOptions/MyResponseErrorListener.java
+1
-1
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/MipcaCaptureActivity.java
+83
-157
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/PointsOverlayView.java
+53
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/camera/AutoFocusCallback.java
+0
-49
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/camera/CameraConfigurationManager.java
+0
-312
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/camera/CameraManager.java
+0
-393
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/camera/FlashlightManager.java
+0
-150
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/camera/PlanarYUVLuminanceSource.java
+0
-133
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/camera/PreviewCallback.java
+0
-59
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/CaptureActivityHandler.java
+0
-125
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/DecodeFormatManager.java
+0
-105
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/DecodeHandler.java
+0
-105
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/DecodeThread.java
+0
-86
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/FinishListener.java
+0
-47
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/InactivityTimer.java
+0
-71
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/Intents.java
+0
-190
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/RGBLuminanceSource.java
+0
-41
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/view/ViewfinderResultPointCallback.java
+0
-34
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/view/ViewfinderView.java
+0
-274
base-module/src/main/res/layout/base_activity_capture_new.xml
+44
-25
download-module/src/main/java/com/gingersoft/gsa/cloud/download/ComponentDownload.java
+9
-0
download-module/src/main/java/com/gingersoft/gsa/cloud/download/mvp/ui/activity/DownloadActivity.java
+7
-10
download-module/src/main/res/layout/download_data_activity_download.xml
+0
-3
login-module/src/main/java/com/gingersoft/gsa/cloud/login/mvp/presenter/BaseLoginPresenter.java
+4
-1
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/activity/NewMainActivity.java
+75
-29
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/adapter/MainOrderingAdapter.java
+1
-0
main-module/src/main/res/layout/activity_new_main.xml
+17
-2
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/network/CoolWeatherNetwork.kt
+1
-1
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/network/api/WeatherService.kt
+3
-2
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/ui/adapter/OtherOrdersAdapter.kt
+1
-0
print-module/src/main/java/com/joe/print/mvp/print/PrintBill.java
+3
-0
print-module/src/main/java/com/joe/print/mvp/print/PrinterRoot.java
+23
-0
print-module/src/main/java/com/joe/print/mvp/print/utils/BytesUtil.java
+50
-57
print-module/src/main/java/com/joe/print/mvp/print/utils/ESCUtil.java
+10
-10
print-module/src/main/java/com/joe/print/mvp/ui/activity/PrintActivity.java
+0
-2
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/contract/TableContract.java
+1
-0
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/model/bean/OrderDetailItem.java
+10
-3
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/MealStandPresenter.java
+2
-4
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/OrderContentPresenter.java
+16
-8
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/TablePresenter.java
+25
-13
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/activity/MealStandActivity.java
+2
-3
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/activity/TableActivity.java
+6
-5
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/activity/orderManager/OrderDetailActivity.java
+11
-7
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/adapter/BottomFunctionAdapter.java
+1
-1
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/adapter/OrderCenterAdapter.java
+11
-7
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/widget/UseMemberDialog.java
+2
-1
table-module/src/main/res/layout/activity_order_detail.xml
+0
-2
No files found.
base-module/build.gradle
View file @
649170bf
...
...
@@ -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'
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/constans/HttpsConstans.java
View file @
649170bf
...
...
@@ -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_CH
ANG_HK
+
"/member-web/api/"
;
_SERVER_ADDRESS
=
ROOT_SERVER_
ZHI_W
ANG_HK
+
"/member-web/api/"
;
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL
=
REPORT_TEST_ADDRESS
;
ROOT_SERVER_ADDRESS_FORMAL
=
ROOT_SERVER_
YOU_CH
ANG_HK
;
ROOT_SERVER_ADDRESS_FORMAL
=
ROOT_SERVER_
ZHI_W
ANG_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_CH
ANG_HK
+
SYSTEM_PATH
;
SYSTEM_URL
=
ROOT_SERVER_
ZHI_W
ANG_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/"
;
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/constans/ResultConstans.java
0 → 100644
View file @
649170bf
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
;
}
base-module/src/main/java/com/gingersoft/gsa/cloud/function/FunctionManager.java
View file @
649170bf
...
...
@@ -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
);
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/globalconfig/applyOptions/MyResponseErrorListener.java
View file @
649170bf
...
...
@@ -100,8 +100,8 @@ public class MyResponseErrorListener implements ResponseErrorListener {
dialogBuilder
.
create
(
R
.
style
.
MyDialogTheme2
).
show
();
}
private
void
toLoginActivity
(
Activity
context
)
{
ArmsUtils
.
killAll
();
//清空用戶信息
GsaCloudApplication
.
clearMemberInfo
();
//清空賬單數據
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/MipcaCaptureActivity.java
View file @
649170bf
...
...
@@ -11,6 +11,7 @@ import android.content.pm.PackageManager;
import
android.content.res.AssetFileDescriptor
;
import
android.database.Cursor
;
import
android.graphics.Bitmap
;
import
android.graphics.PointF
;
import
android.media.AudioManager
;
import
android.media.MediaPlayer
;
import
android.media.MediaPlayer.OnCompletionListener
;
...
...
@@ -31,8 +32,8 @@ import android.view.SurfaceView;
import
android.view.View
;
import
android.view.View.OnClickListener
;
import
android.widget.TextView
;
import
com.billy.cc.core.component.CC
;
import
com.dlazaro66.qrcodereaderview.QRCodeReaderView
;
import
com.gingersoft.gsa.cloud.base.R
;
import
com.gingersoft.gsa.cloud.base.R2
;
import
com.gingersoft.gsa.cloud.base.utils.JsonUtils
;
...
...
@@ -40,17 +41,14 @@ import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import
com.gingersoft.gsa.cloud.base.utils.log.LogUtil
;
import
com.gingersoft.gsa.cloud.base.utils.other.SPUtils
;
import
com.gingersoft.gsa.cloud.base.utils.view.BitmapUtil
;
import
com.gingersoft.gsa.cloud.zxing.camera.CameraManager
;
import
com.gingersoft.gsa.cloud.zxing.decoding.CaptureActivityHandler
;
import
com.gingersoft.gsa.cloud.zxing.decoding.InactivityTimer
;
import
com.gingersoft.gsa.cloud.zxing.decoding.RGBLuminanceSource
;
import
com.gingersoft.gsa.cloud.zxing.view.ViewfinderView
;
import
com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog
;
import
com.google.zxing.BarcodeFormat
;
import
com.google.zxing.BinaryBitmap
;
import
com.google.zxing.ChecksumException
;
import
com.google.zxing.DecodeHintType
;
import
com.google.zxing.FormatException
;
import
com.google.zxing.NotFoundException
;
import
com.google.zxing.RGBLuminanceSource
;
import
com.google.zxing.Result
;
import
com.google.zxing.common.HybridBinarizer
;
import
com.google.zxing.qrcode.QRCodeReader
;
...
...
@@ -62,44 +60,39 @@ import com.jess.arms.utils.ArmsUtils;
import
com.jess.arms.utils.DrawableProvider
;
import
com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
;
import
com.qmuiteam.qmui.widget.QMUITopBar
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.IOException
;
import
java.net.URLDecoder
;
import
java.util.Hashtable
;
import
java.util.List
;
import
java.util.Vector
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.core.app.ActivityCompat
;
import
androidx.core.content.ContextCompat
;
import
butterknife.BindView
;
import
butterknife.OnClick
;
import
static
com
.
jess
.
arms
.
utils
.
Preconditions
.
checkNotNull
;
/**
* Initial the camera
*
* @author Ryan.Tang
*/
public
class
MipcaCaptureActivity
extends
BaseActivity
<
BasePresenter
>
implements
IView
,
Callback
,
OnClickListener
{
public
class
MipcaCaptureActivity
extends
BaseActivity
<
BasePresenter
>
implements
IView
,
Callback
,
OnClickListener
,
QRCodeReaderView
.
OnQRCodeReadListener
{
@BindView
(
R2
.
id
.
topbar
)
QMUITopBar
mTopBar
;
@BindView
(
R2
.
id
.
btn_album
)
QMUITopBar
btn_album
;
TextView
btn_album
;
@BindView
(
R2
.
id
.
qrdecoderview
)
QRCodeReaderView
qrCodeReaderView
;
@BindView
(
R2
.
id
.
preview_view
)
SurfaceView
preview_view
;
@BindView
(
R2
.
id
.
viewfinder_view
)
ViewfinderView
viewfinderView
;
//
@BindView(R2.id.preview_view)
//
SurfaceView preview_view;
//
@BindView(R2.id.viewfinder_view)
//
ViewfinderView viewfinderView;
private
CaptureActivityHandler
handler
;
private
Vector
<
BarcodeFormat
>
decodeFormats
;
// private Vector<BarcodeFormat> decodeFormats;
private
String
characterSet
;
private
InactivityTimer
inactivityTimer
;
private
MediaPlayer
mediaPlayer
;
private
boolean
hasSurface
;
private
boolean
playBeep
;
...
...
@@ -135,10 +128,24 @@ public class MipcaCaptureActivity extends BaseActivity<BasePresenter> implements
@Override
public
void
initData
(
@Nullable
Bundle
savedInstanceState
)
{
qrCodeReaderView
.
setOnQRCodeReadListener
(
this
);
// Use this function to enable/disable decoding
qrCodeReaderView
.
setQRDecodingEnabled
(
true
);
// Use this function to change the autofocus interval (default is 5 secs)
qrCodeReaderView
.
setAutofocusInterval
(
2000L
);
// Use this function to enable/disable Torch
qrCodeReaderView
.
setTorchEnabled
(
true
);
// Use this function to set front camera preview
qrCodeReaderView
.
setFrontCamera
();
// Use this function to set back camera preview
qrCodeReaderView
.
setBackCamera
();
CameraManager
.
init
(
getApplication
());
hasSurface
=
false
;
inactivityTimer
=
new
InactivityTimer
(
this
);
}
@Override
...
...
@@ -177,97 +184,15 @@ public class MipcaCaptureActivity extends BaseActivity<BasePresenter> implements
@Override
protected
void
onResume
()
{
super
.
onResume
();
SurfaceView
surfaceView
=
findViewById
(
R
.
id
.
preview_view
);
SurfaceHolder
surfaceHolder
=
surfaceView
.
getHolder
();
if
(
hasSurface
)
{
initCamera
(
surfaceHolder
);
}
else
{
surfaceHolder
.
addCallback
(
this
);
surfaceHolder
.
setType
(
SurfaceHolder
.
SURFACE_TYPE_PUSH_BUFFERS
);
}
decodeFormats
=
null
;
characterSet
=
null
;
playBeep
=
true
;
AudioManager
audioService
=
(
AudioManager
)
getSystemService
(
AUDIO_SERVICE
);
if
(
audioService
.
getRingerMode
()
!=
AudioManager
.
RINGER_MODE_NORMAL
)
{
playBeep
=
false
;
}
initBeepSound
();
vibrate
=
true
;
qrCodeReaderView
.
startCamera
();
}
@Override
protected
void
onPause
()
{
super
.
onPause
();
if
(
handler
!=
null
)
{
handler
.
quitSynchronously
();
handler
=
null
;
}
CameraManager
.
get
().
closeDriver
();
qrCodeReaderView
.
stopCamera
();
}
@Override
protected
void
onDestroy
()
{
inactivityTimer
.
shutdown
();
super
.
onDestroy
();
}
/**
* 处理扫描结果
*
* @param result
*/
public
void
handleDecode
(
Result
result
,
Bitmap
bitmap
)
{
inactivityTimer
.
onActivity
();
playBeepSoundAndVibrate
();
qrCodeResult
(
result
);
}
/**
* 处理二维码识别结果
*
* @param result
*/
private
void
qrCodeResult
(
Result
result
)
{
//http://m.ricepon.com/member-web/qrcode/qrcode.html?WMP&?arg={"type":2,"QR":4e14bf5d47e14e5a9690e9472ff666f4}
String
resultStr
=
result
.
getText
();
//http://m.ricepon.com/member-web/qrcode/qrcode.html?WMP&?arg={"type":3,"data":"MDdnMnMxMjU3NTIxNA=="}
LogUtil
.
d
(
"qrCodeResult: "
+
resultStr
);
String
markStr
=
"?arg="
;
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
"qrCodeResult"
,
resultStr
);
setResult
(
CALL_BACK_QR_RESULT
,
intent
);
// ToastUtil.toastInfo(MipcaActivityCapture.this, getResources().getString(R.string.capture_fail));
finish
();
}
private
void
initCamera
(
SurfaceHolder
surfaceHolder
)
{
try
{
boolean
isOpen
=
CameraManager
.
get
().
openDriver
(
surfaceHolder
);
if
(!
isCheckSelfPermission
)
{
boolean
permission
=
ActivityCompat
.
checkSelfPermission
(
this
,
cameraPermissions
)
==
PackageManager
.
PERMISSION_GRANTED
;
if
(
Build
.
VERSION
.
SDK_INT
<
23
||
permission
)
{
if
(!
isOpen
)
{
// showMessageOKCancel();
return
;
}
}
else
{
if
(
ContextCompat
.
checkSelfPermission
(
MipcaCaptureActivity
.
this
,
cameraPermissions
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
ActivityCompat
.
requestPermissions
(
MipcaCaptureActivity
.
this
,
new
String
[]{
cameraPermissions
},
CAMERA_STORAGE_REQUEST_CODE
);
}
else
if
(!
permission
)
{
// showMessageOKCancel();
}
}
isCheckSelfPermission
=
true
;
}
}
catch
(
IOException
|
RuntimeException
ioe
)
{
return
;
}
if
(
handler
==
null
)
{
handler
=
new
CaptureActivityHandler
(
this
,
decodeFormats
,
characterSet
);
}
}
@Override
public
void
surfaceChanged
(
SurfaceHolder
holder
,
int
format
,
int
width
,
int
height
)
{
...
...
@@ -276,29 +201,24 @@ public class MipcaCaptureActivity extends BaseActivity<BasePresenter> implements
@Override
public
void
surfaceCreated
(
SurfaceHolder
holder
)
{
if
(!
hasSurface
)
{
hasSurface
=
true
;
initCamera
(
holder
);
}
}
@Override
public
void
surfaceDestroyed
(
SurfaceHolder
holder
)
{
hasSurface
=
false
;
}
public
ViewfinderView
getViewfinderView
()
{
return
viewfinderView
;
}
public
Handler
getHandler
()
{
return
handler
;
}
public
void
drawViewfinder
()
{
viewfinderView
.
drawViewfinder
();
}
// public ViewfinderView getViewfinderView() {
// return viewfinderView;
// }
//
// public Handler getHandler() {
// return handler;
// }
//
// public void drawViewfinder() {
// viewfinderView.drawViewfinder();
// }
private
void
initBeepSound
()
{
if
(
playBeep
&&
mediaPlayer
==
null
)
{
...
...
@@ -374,7 +294,7 @@ public class MipcaCaptureActivity extends BaseActivity<BasePresenter> implements
finish
();
return
;
}
qrCodeResult
(
result
);
//
qrCodeResult(result);
}
}
else
{
finish
();
...
...
@@ -409,23 +329,23 @@ public class MipcaCaptureActivity extends BaseActivity<BasePresenter> implements
// int[] data = new int[scanBitmap.getWidth() * scanBitmap.getHeight()];
// scanBitmap.getPixels(data, 0, scanBitmap.getWidth(), 0, 0, scanBitmap.getWidth(), scanBitmap.getHeight());
//新建一个RGBLuminanceSource对象,将bitmap图片传给此对象
RGBLuminanceSource
rgbLuminanceSource
=
new
RGBLuminanceSource
(
scanBitmap
);
//将图片转换成二进制图片
BinaryBitmap
binaryBitmap
=
new
BinaryBitmap
(
new
HybridBinarizer
(
rgbLuminanceSource
));
//初始化解析对象
QRCodeReader
reader
=
new
QRCodeReader
();
scanBitmap
.
recycle
();
//开始解析
//
RGBLuminanceSource rgbLuminanceSource = new RGBLuminanceSource(scanBitmap);
//
//将图片转换成二进制图片
//
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(rgbLuminanceSource));
//
//初始化解析对象
//
QRCodeReader reader = new QRCodeReader();
//
scanBitmap.recycle();
//
//开始解析
Result
result
=
null
;
try
{
result
=
reader
.
decode
(
binaryBitmap
,
hints
);
}
catch
(
NotFoundException
e
)
{
Log
.
e
(
"hxy"
,
"NotFoundException"
);
}
catch
(
ChecksumException
e
)
{
Log
.
e
(
"hxy"
,
"ChecksumException"
);
}
catch
(
FormatException
e
)
{
Log
.
e
(
"hxy"
,
"FormatException"
);
}
//
try {
//
result = reader.decode(binaryBitmap, hints);
//
} catch (NotFoundException e) {
//
Log.e("hxy", "NotFoundException");
//
} catch (ChecksumException e) {
//
Log.e("hxy", "ChecksumException");
//
} catch (FormatException e) {
//
Log.e("hxy", "FormatException");
//
}
return
result
;
}
...
...
@@ -485,16 +405,6 @@ public class MipcaCaptureActivity extends BaseActivity<BasePresenter> implements
return
null
;
}
/**
* Get the value of the data column for this Uri. This is useful for
* MediaStore Uris, and other file-based ContentProviders.
*
* @param context The context.
* @param uri The Uri to query.
* @param selection (Optional) Filter used in the query.
* @param selectionArgs (Optional) Selection arguments used in the query.
* @return The value of the _data column, which is typically a file path.
*/
public
static
String
getDataColumn
(
Context
context
,
Uri
uri
,
String
selection
,
String
[]
selectionArgs
)
{
Cursor
cursor
=
null
;
...
...
@@ -550,27 +460,42 @@ public class MipcaCaptureActivity extends BaseActivity<BasePresenter> implements
@Override
public
void
showLoading
(
String
message
)
{
if
(
message
!=
null
)
LoadingDialog
.
showDialogForLoading
(
this
,
message
,
true
);
else
LoadingDialog
.
showDialogForLoading
(
this
);
}
@Override
public
void
hideLoading
()
{
LoadingDialog
.
cancelDialogForLoading
();
}
@Override
public
void
showMessage
(
@NonNull
String
message
)
{
checkNotNull
(
message
);
ArmsUtils
.
makeText
(
this
,
message
);
}
@Override
public
void
launchActivity
(
@NonNull
Intent
intent
)
{
checkNotNull
(
intent
);
ArmsUtils
.
startActivity
(
intent
);
}
@Override
public
void
killMyself
()
{
finish
();
}
@Override
public
void
onQRCodeRead
(
String
text
,
PointF
[]
points
)
{
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
"qrCodeResult"
,
text
);
setResult
(
CALL_BACK_QR_RESULT
,
intent
);
finish
();
// showMessage("onQRCodeRead "+text);
}
}
\ No newline at end of file
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/PointsOverlayView.java
0 → 100644
View file @
649170bf
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
);
}
}
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/camera/AutoFocusCallback.java
deleted
100644 → 0
View file @
03737d19
/*
* 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"
);
}
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/camera/CameraConfigurationManager.java
deleted
100644 → 0
View file @
03737d19
/*
* 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.content.Context
;
import
android.graphics.Point
;
import
android.hardware.Camera
;
import
android.os.Build
;
import
android.util.Log
;
import
android.view.Display
;
import
android.view.WindowManager
;
import
java.lang.reflect.Method
;
import
java.util.regex.Pattern
;
final
class
CameraConfigurationManager
{
private
static
final
String
TAG
=
CameraConfigurationManager
.
class
.
getSimpleName
();
private
static
final
int
TEN_DESIRED_ZOOM
=
27
;
private
static
final
int
DESIRED_SHARPNESS
=
30
;
private
static
final
Pattern
COMMA_PATTERN
=
Pattern
.
compile
(
","
);
private
final
Context
context
;
private
Point
screenResolution
;
private
Point
cameraResolution
;
private
int
previewFormat
;
private
String
previewFormatString
;
CameraConfigurationManager
(
Context
context
)
{
this
.
context
=
context
;
}
/**
* Reads, one time, values from the camera that are needed by the app.
*/
void
initFromCameraParameters
(
Camera
camera
)
{
Camera
.
Parameters
parameters
=
camera
.
getParameters
();
previewFormat
=
parameters
.
getPreviewFormat
();
previewFormatString
=
parameters
.
get
(
"preview-format"
);
Log
.
d
(
TAG
,
"Default preview format: "
+
previewFormat
+
'/'
+
previewFormatString
);
WindowManager
manager
=
(
WindowManager
)
context
.
getSystemService
(
Context
.
WINDOW_SERVICE
);
Display
display
=
manager
.
getDefaultDisplay
();
screenResolution
=
new
Point
(
display
.
getWidth
(),
display
.
getHeight
());
Log
.
d
(
TAG
,
"Screen resolution: "
+
screenResolution
);
Point
screenResolutionForCamera
=
new
Point
();
screenResolutionForCamera
.
x
=
screenResolution
.
x
;
screenResolutionForCamera
.
y
=
screenResolution
.
y
;
if
(
screenResolution
.
x
<
screenResolution
.
y
)
{
screenResolutionForCamera
.
x
=
screenResolution
.
y
;
screenResolutionForCamera
.
y
=
screenResolution
.
x
;
}
cameraResolution
=
getCameraResolution
(
parameters
,
screenResolutionForCamera
);
Log
.
d
(
TAG
,
"Camera resolution: "
+
screenResolution
);
}
/**
* Sets the camera up to take preview images which are used for both preview and decoding.
* We detect the preview format here so that buildLuminanceSource() can build an appropriate
* LuminanceSource subclass. In the future we may want to force YUV420SP as it's the smallest,
* and the planar Y can be used for barcode scanning without a copy in some cases.
*/
void
setDesiredCameraParameters
(
Camera
camera
)
{
Camera
.
Parameters
parameters
=
camera
.
getParameters
();
Log
.
d
(
TAG
,
"Setting preview size: "
+
cameraResolution
);
parameters
.
setPreviewSize
(
cameraResolution
.
x
,
cameraResolution
.
y
);
setFlash
(
parameters
);
setZoom
(
parameters
);
//setSharpness(parameters);
//modify here
// camera.setDisplayOrientation(90);
setDisplayOrientation
(
camera
,
90
);
camera
.
setParameters
(
parameters
);
////20170905修改
// Camera.Parameters parameters = camera.getParameters();
// List<Camera.Size> supportedPreviewSizes = parameters.getSupportedPreviewSizes();
// int position = 0;
// if (supportedPreviewSizes.size() > 2) {
// position = supportedPreviewSizes.size() / 2 + 1;//supportedPreviewSizes.get();
// } else {
// position = supportedPreviewSizes.size() / 2;
// }
// int width = supportedPreviewSizes.get(position).width;
// int height = supportedPreviewSizes.get(position).height;
// Log.d(TAG, "Setting preview size: " + cameraResolution);
// camera.setDisplayOrientation(90);
// cameraResolution.x = width;
// cameraResolution.y = height;
// parameters.setPreviewSize(width, height);
// setFlash(parameters);
// setZoom(parameters);
// camera.setParameters(parameters);
}
Point
getCameraResolution
()
{
return
cameraResolution
;
}
Point
getScreenResolution
()
{
return
screenResolution
;
}
int
getPreviewFormat
()
{
return
previewFormat
;
}
String
getPreviewFormatString
()
{
return
previewFormatString
;
}
private
static
Point
getCameraResolution
(
Camera
.
Parameters
parameters
,
Point
screenResolution
)
{
String
previewSizeValueString
=
parameters
.
get
(
"preview-size-values"
);
// saw this on Xperia
if
(
previewSizeValueString
==
null
)
{
previewSizeValueString
=
parameters
.
get
(
"preview-size-value"
);
}
Point
cameraResolution
=
null
;
if
(
previewSizeValueString
!=
null
)
{
Log
.
d
(
TAG
,
"preview-size-values parameter: "
+
previewSizeValueString
);
cameraResolution
=
findBestPreviewSizeValue
(
previewSizeValueString
,
screenResolution
);
}
if
(
cameraResolution
==
null
)
{
// Ensure that the camera resolution is a multiple of 8, as the screen may not be.
cameraResolution
=
new
Point
(
(
screenResolution
.
x
>>
3
)
<<
3
,
(
screenResolution
.
y
>>
3
)
<<
3
);
}
return
cameraResolution
;
}
private
static
Point
findBestPreviewSizeValue
(
CharSequence
previewSizeValueString
,
Point
screenResolution
)
{
int
bestX
=
0
;
int
bestY
=
0
;
int
diff
=
Integer
.
MAX_VALUE
;
for
(
String
previewSize
:
COMMA_PATTERN
.
split
(
previewSizeValueString
))
{
previewSize
=
previewSize
.
trim
();
int
dimPosition
=
previewSize
.
indexOf
(
'x'
);
if
(
dimPosition
<
0
)
{
Log
.
w
(
TAG
,
"Bad preview-size: "
+
previewSize
);
continue
;
}
int
newX
;
int
newY
;
try
{
newX
=
Integer
.
parseInt
(
previewSize
.
substring
(
0
,
dimPosition
));
newY
=
Integer
.
parseInt
(
previewSize
.
substring
(
dimPosition
+
1
));
}
catch
(
NumberFormatException
nfe
)
{
Log
.
w
(
TAG
,
"Bad preview-size: "
+
previewSize
);
continue
;
}
int
newDiff
=
Math
.
abs
(
newX
-
screenResolution
.
x
)
+
Math
.
abs
(
newY
-
screenResolution
.
y
);
if
(
newDiff
==
0
)
{
bestX
=
newX
;
bestY
=
newY
;
break
;
}
else
if
(
newDiff
<
diff
)
{
bestX
=
newX
;
bestY
=
newY
;
diff
=
newDiff
;
}
}
if
(
bestX
>
0
&&
bestY
>
0
)
{
return
new
Point
(
bestX
,
bestY
);
}
return
null
;
}
private
static
int
findBestMotZoomValue
(
CharSequence
stringValues
,
int
tenDesiredZoom
)
{
int
tenBestValue
=
0
;
for
(
String
stringValue
:
COMMA_PATTERN
.
split
(
stringValues
))
{
stringValue
=
stringValue
.
trim
();
double
value
;
try
{
value
=
Double
.
parseDouble
(
stringValue
);
}
catch
(
NumberFormatException
nfe
)
{
return
tenDesiredZoom
;
}
int
tenValue
=
(
int
)
(
10.0
*
value
);
if
(
Math
.
abs
(
tenDesiredZoom
-
value
)
<
Math
.
abs
(
tenDesiredZoom
-
tenBestValue
))
{
tenBestValue
=
tenValue
;
}
}
return
tenBestValue
;
}
private
void
setFlash
(
Camera
.
Parameters
parameters
)
{
// FIXME: This is a hack to turn the flash off on the Samsung Galaxy.
// And this is a hack-hack to work around a different value on the Behold II
// Restrict Behold II check to Cupcake, per Samsung's advice
//if (Build.MODEL.contains("Behold II") &&
// CameraManager.SDK_INT == Build.VERSION_CODES.CUPCAKE) {
if
(
Build
.
MODEL
.
contains
(
"Behold II"
)
&&
CameraManager
.
SDK_INT
==
3
)
{
// 3 = Cupcake
parameters
.
set
(
"flash-value"
,
1
);
}
else
{
parameters
.
set
(
"flash-value"
,
2
);
}
// This is the standard setting to turn the flash off that all devices should honor.
parameters
.
set
(
"flash-mode"
,
"off"
);
}
private
void
setZoom
(
Camera
.
Parameters
parameters
)
{
String
zoomSupportedString
=
parameters
.
get
(
"zoom-supported"
);
if
(
zoomSupportedString
!=
null
&&
!
Boolean
.
parseBoolean
(
zoomSupportedString
))
{
return
;
}
int
tenDesiredZoom
=
TEN_DESIRED_ZOOM
;
String
maxZoomString
=
parameters
.
get
(
"max-zoom"
);
if
(
maxZoomString
!=
null
)
{
try
{
int
tenMaxZoom
=
(
int
)
(
10.0
*
Double
.
parseDouble
(
maxZoomString
));
if
(
tenDesiredZoom
>
tenMaxZoom
)
{
tenDesiredZoom
=
tenMaxZoom
;
}
}
catch
(
NumberFormatException
nfe
)
{
Log
.
w
(
TAG
,
"Bad max-zoom: "
+
maxZoomString
);
}
}
String
takingPictureZoomMaxString
=
parameters
.
get
(
"taking-picture-zoom-max"
);
if
(
takingPictureZoomMaxString
!=
null
)
{
try
{
int
tenMaxZoom
=
Integer
.
parseInt
(
takingPictureZoomMaxString
);
if
(
tenDesiredZoom
>
tenMaxZoom
)
{
tenDesiredZoom
=
tenMaxZoom
;
}
}
catch
(
NumberFormatException
nfe
)
{
Log
.
w
(
TAG
,
"Bad taking-picture-zoom-max: "
+
takingPictureZoomMaxString
);
}
}
String
motZoomValuesString
=
parameters
.
get
(
"mot-zoom-values"
);
if
(
motZoomValuesString
!=
null
)
{
tenDesiredZoom
=
findBestMotZoomValue
(
motZoomValuesString
,
tenDesiredZoom
);
}
String
motZoomStepString
=
parameters
.
get
(
"mot-zoom-step"
);
if
(
motZoomStepString
!=
null
)
{
try
{
double
motZoomStep
=
Double
.
parseDouble
(
motZoomStepString
.
trim
());
int
tenZoomStep
=
(
int
)
(
10.0
*
motZoomStep
);
if
(
tenZoomStep
>
1
)
{
tenDesiredZoom
-=
tenDesiredZoom
%
tenZoomStep
;
}
}
catch
(
NumberFormatException
nfe
)
{
// continue
}
}
// Set zoom. This helps encourage the user to pull back.
// Some devices like the Behold have a zoom parameter
if
(
maxZoomString
!=
null
||
motZoomValuesString
!=
null
)
{
parameters
.
set
(
"zoom"
,
String
.
valueOf
(
tenDesiredZoom
/
10.0
));
}
// Most devices, like the Hero, appear to expose this zoom parameter.
// It takes on values like "27" which appears to mean 2.7x zoom
if
(
takingPictureZoomMaxString
!=
null
)
{
parameters
.
set
(
"taking-picture-zoom"
,
tenDesiredZoom
);
}
}
public
static
int
getDesiredSharpness
()
{
return
DESIRED_SHARPNESS
;
}
/**
* compatible 1.6
*
* @param camera
* @param angle
*/
protected
void
setDisplayOrientation
(
Camera
camera
,
int
angle
)
{
Method
downPolymorphic
;
try
{
downPolymorphic
=
camera
.
getClass
().
getMethod
(
"setDisplayOrientation"
,
new
Class
[]{
int
.
class
});
if
(
downPolymorphic
!=
null
)
downPolymorphic
.
invoke
(
camera
,
new
Object
[]{
angle
});
}
catch
(
Exception
e1
)
{
}
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/camera/CameraManager.java
deleted
100644 → 0
View file @
03737d19
/*
* 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
.
camera
;
import
android.content.Context
;
import
android.graphics.PixelFormat
;
import
android.graphics.Point
;
import
android.graphics.Rect
;
import
android.hardware.Camera
;
import
android.hardware.Camera.Parameters
;
import
android.os.Build
;
import
android.os.Handler
;
import
android.util.DisplayMetrics
;
import
android.util.Log
;
import
android.view.SurfaceHolder
;
import
java.io.IOException
;
/**
* This object wraps the Camera service object and expects to be the only one talking to it. The
* implementation encapsulates the steps needed to take preview-sized images, which are used for
* both preview and decoding.
*/
public
final
class
CameraManager
{
private
static
final
String
TAG
=
CameraManager
.
class
.
getSimpleName
();
private
static
final
int
MIN_FRAME_WIDTH
=
240
;
private
static
final
int
MIN_FRAME_HEIGHT
=
240
;
private
static
final
int
MAX_FRAME_WIDTH
=
480
;
private
static
final
int
MAX_FRAME_HEIGHT
=
360
;
private
static
CameraManager
cameraManager
;
static
final
int
SDK_INT
;
// Later we can use Build.VERSION.SDK_INT
static
{
int
sdkInt
;
try
{
sdkInt
=
Integer
.
parseInt
(
Build
.
VERSION
.
SDK
);
}
catch
(
NumberFormatException
nfe
)
{
// Just to be safe
sdkInt
=
10000
;
}
SDK_INT
=
sdkInt
;
}
private
final
Context
context
;
private
final
CameraConfigurationManager
configManager
;
private
Camera
camera
;
private
Rect
framingRect
;
private
Rect
framingRectInPreview
;
private
boolean
initialized
;
private
boolean
previewing
;
private
final
boolean
useOneShotPreviewCallback
;
/**
* Preview frames are delivered here, which we pass on to the registered handler. Make sure to
* clear the handler so it will only receive one message.
*/
private
final
PreviewCallback
previewCallback
;
/**
* Autofocus callbacks arrive here, and are dispatched to the Handler which requested them.
*/
private
final
AutoFocusCallback
autoFocusCallback
;
/**
* Initializes this static object with the Context of the calling Activity.
*
* @param context The Activity which wants to use the camera.
*/
public
static
void
init
(
Context
context
)
{
if
(
cameraManager
==
null
)
{
cameraManager
=
new
CameraManager
(
context
);
}
}
/**
* Gets the CameraManager singleton instance.
*
* @return A reference to the CameraManager singleton.
*/
public
static
CameraManager
get
()
{
return
cameraManager
;
}
private
CameraManager
(
Context
context
)
{
this
.
context
=
context
;
this
.
configManager
=
new
CameraConfigurationManager
(
context
);
// Camera.setOneShotPreviewCallback() has a race condition in Cupcake, so we use the older
// Camera.setPreviewCallback() on 1.5 and earlier. For Donut and later, we need to use
// the more efficient one shot callback, as the older one can swamp the system and cause it
// to run out of memory. We can't use SDK_INT because it was introduced in the Donut SDK.
//useOneShotPreviewCallback = Integer.parseInt(Build.VERSION.SDK) > Build.VERSION_CODES.CUPCAKE;
useOneShotPreviewCallback
=
Integer
.
parseInt
(
Build
.
VERSION
.
SDK
)
>
3
;
// 3 = Cupcake
previewCallback
=
new
PreviewCallback
(
configManager
,
useOneShotPreviewCallback
);
autoFocusCallback
=
new
AutoFocusCallback
();
}
/**
* Opens the camera driver and initializes the hardware parameters.
*
* @param holder The surface object which the camera will draw preview frames into.
* @throws IOException Indicates the camera driver failed to open.
*/
public
boolean
openDriver
(
SurfaceHolder
holder
)
throws
IOException
{
boolean
isCanUse
=
true
;
try
{
camera
=
Camera
.
open
();
}
catch
(
Exception
e
)
{
isCanUse
=
false
;
}
if
(
camera
==
null
)
{
isCanUse
=
false
;
}
else
{
camera
.
setPreviewDisplay
(
holder
);
if
(!
initialized
)
{
initialized
=
true
;
configManager
.
initFromCameraParameters
(
camera
);
}
configManager
.
setDesiredCameraParameters
(
camera
);
FlashlightManager
.
enableFlashlight
();
}
return
isCanUse
;
}
/**
* Closes the camera driver if still in use.
*/
public
void
closeDriver
()
{
if
(
camera
!=
null
)
{
FlashlightManager
.
disableFlashlight
();
camera
.
release
();
camera
=
null
;
}
}
/**
* Asks the camera hardware to begin drawing preview frames to the screen.
*/
public
void
startPreview
()
{
if
(
camera
!=
null
&&
!
previewing
)
{
try
{
camera
.
startPreview
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
previewing
=
true
;
}
}
/**
* Tells the camera to stop drawing preview frames.
*/
public
void
stopPreview
()
{
if
(
camera
!=
null
&&
previewing
)
{
if
(!
useOneShotPreviewCallback
)
{
camera
.
setPreviewCallback
(
null
);
}
try
{
camera
.
stopPreview
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
previewCallback
.
setHandler
(
null
,
0
);
autoFocusCallback
.
setHandler
(
null
,
0
);
previewing
=
false
;
}
}
/**
* A single preview frame will be returned to the handler supplied. The data will arrive as byte[]
* in the message.obj field, with width and height encoded as message.arg1 and message.arg2,
* respectively.
*
* @param handler The handler to send the message to.
* @param message The what field of the message to be sent.
*/
public
void
requestPreviewFrame
(
Handler
handler
,
int
message
)
{
if
(
camera
!=
null
&&
previewing
)
{
previewCallback
.
setHandler
(
handler
,
message
);
if
(
useOneShotPreviewCallback
)
{
camera
.
setOneShotPreviewCallback
(
previewCallback
);
}
else
{
camera
.
setPreviewCallback
(
previewCallback
);
}
}
}
/**
* Asks the camera hardware to perform an autofocus.
*
* @param handler The Handler to notify when the autofocus completes.
* @param message The message to deliver.
*/
public
void
requestAutoFocus
(
Handler
handler
,
int
message
)
{
if
(
camera
!=
null
&&
previewing
)
{
try
{
autoFocusCallback
.
setHandler
(
handler
,
message
);
//Log.d(TAG, "Requesting auto-focus callback");
camera
.
autoFocus
(
autoFocusCallback
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
/**
* Calculates the framing rect which the UI should draw to show the user where to place the
* barcode. This target helps with alignment as well as forces the user to hold the device
* far enough away to ensure the image will be in focus.
*
* @return The rectangle to draw on screen in window coordinates.
*/
public
Rect
getFramingRect
()
{
if
(
framingRect
==
null
)
{
if
(
camera
==
null
)
{
return
null
;
}
Point
screenResolution
=
configManager
.
getScreenResolution
();
if
(
screenResolution
==
null
)
{
return
null
;
}
// int width = screenResolution.x * 3 / 4;
// if (width < MIN_FRAME_WIDTH) {
// width = MIN_FRAME_WIDTH;
// } else if (width > MAX_FRAME_WIDTH) {
// width = MAX_FRAME_WIDTH;
// }
// int height = screenResolution.y * 3 / 4;
// if (height < MIN_FRAME_HEIGHT) {
// height = MIN_FRAME_HEIGHT;
// } else if (height > MAX_FRAME_HEIGHT) {
// height = MAX_FRAME_HEIGHT;
// }
DisplayMetrics
dm
=
context
.
getResources
().
getDisplayMetrics
();
int
width
=
(
int
)
(
dm
.
widthPixels
*
0.6
);
int
height
=
(
int
)
(
width
*
1
);
int
leftOffset
=
(
screenResolution
.
x
-
width
)
/
2
;
int
topOffset
=
(
screenResolution
.
y
-
height
)
/
2
;
framingRect
=
new
Rect
(
leftOffset
,
topOffset
,
leftOffset
+
width
,
topOffset
+
height
);
Log
.
d
(
TAG
,
"Calculated framing rect: "
+
framingRect
);
}
return
framingRect
;
}
public
Rect
getReadFramingRect
()
{
Point
screenResolution
=
configManager
.
getScreenResolution
();
if
(
camera
==
null
)
{
return
null
;
}
DisplayMetrics
dm
=
context
.
getResources
().
getDisplayMetrics
();
int
width
=
(
int
)
dm
.
widthPixels
;
int
height
=
width
;
int
leftOffset
=
(
screenResolution
.
x
-
width
)
/
2
;
int
topOffset
=
(
screenResolution
.
y
-
height
)
/
2
;
return
new
Rect
(
leftOffset
,
topOffset
,
leftOffset
+
width
,
topOffset
+
height
);
}
/**
* Like {@link #getFramingRect} but coordinates are in terms of the preview frame,
* not UI / screen.
*/
public
Rect
getFramingRectInPreview
()
{
if
(
framingRectInPreview
==
null
)
{
Rect
rect
=
new
Rect
(
getReadFramingRect
());
Point
cameraResolution
=
configManager
.
getCameraResolution
();
Point
screenResolution
=
configManager
.
getScreenResolution
();
//modify here
// rect.left = rect.left * cameraResolution.x / screenResolution.x;
// rect.right = rect.right * cameraResolution.x / screenResolution.x;
// rect.top = rect.top * cameraResolution.y / screenResolution.y;
// rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y;
// 横屏换竖屏
rect
.
left
=
rect
.
left
*
cameraResolution
.
y
/
screenResolution
.
x
;
rect
.
right
=
rect
.
right
*
cameraResolution
.
y
/
screenResolution
.
x
;
rect
.
top
=
rect
.
top
*
cameraResolution
.
x
/
screenResolution
.
y
;
rect
.
bottom
=
rect
.
bottom
*
cameraResolution
.
x
/
screenResolution
.
y
;
framingRectInPreview
=
rect
;
}
return
framingRectInPreview
;
}
/**
* Converts the result points from still resolution coordinates to screen coordinates.
*
* @param points The points returned by the Reader subclass through BaseResult.getResultPoints().
* @return An array of Points scaled to the size of the framing rect and offset appropriately
* so they can be drawn in screen coordinates.
*/
/*
public Point[] convertResultPoints(ResultPoint[] points) {
Rect frame = getFramingRectInPreview();
int count = points.length;
Point[] output = new Point[count];
for (int x = 0; x < count; x++) {
output[x] = new Point();
output[x].x = frame.left + (int) (points[x].getX() + 0.5f);
output[x].y = frame.top + (int) (points[x].getY() + 0.5f);
}
return output;
}
*/
/**
* A factory method to build the appropriate LuminanceSource object based on the format
* of the preview buffers, as described by Camera.Parameters.
*
* @param data A preview frame.
* @param width The width of the image.
* @param height The height of the image.
* @return A PlanarYUVLuminanceSource instance.
*/
public
PlanarYUVLuminanceSource
buildLuminanceSource
(
byte
[]
data
,
int
width
,
int
height
)
{
Rect
rect
=
getFramingRectInPreview
();
int
previewFormat
=
configManager
.
getPreviewFormat
();
String
previewFormatString
=
configManager
.
getPreviewFormatString
();
switch
(
previewFormat
)
{
// This is the standard Android format which all devices are REQUIRED to support.
// In theory, it's the only one we should ever care about.
case
PixelFormat
.
YCbCr_420_SP
:
// This format has never been seen in the wild, but is compatible as we only care
// about the Y channel, so allow it.
case
PixelFormat
.
YCbCr_422_SP
:
return
new
PlanarYUVLuminanceSource
(
data
,
width
,
height
,
rect
.
left
,
rect
.
top
,
rect
.
width
(),
rect
.
height
());
default
:
// The Samsung Moment incorrectly uses this variant instead of the 'sp' version.
// Fortunately, it too has all the Y data up front, so we can read it.
if
(
"yuv420p"
.
equals
(
previewFormatString
))
{
return
new
PlanarYUVLuminanceSource
(
data
,
width
,
height
,
rect
.
left
,
rect
.
top
,
rect
.
width
(),
rect
.
height
());
}
}
throw
new
IllegalArgumentException
(
"Unsupported picture format: "
+
previewFormat
+
'/'
+
previewFormatString
);
}
public
int
flashHandler
()
{
int
state
=
-
1
;
try
{
if
(
camera
==
null
)
{
return
state
;
}
Parameters
parameters
=
camera
.
getParameters
();
String
flashMode
=
parameters
.
getFlashMode
();
// 判断闪光灯当前状态來修改
if
(
Parameters
.
FLASH_MODE_OFF
.
equals
(
flashMode
))
{
turnOn
(
parameters
);
state
=
1
;
}
else
if
(
Parameters
.
FLASH_MODE_TORCH
.
equals
(
flashMode
))
{
turnOff
(
parameters
);
state
=
0
;
}
}
catch
(
Exception
e
)
{
return
state
;
}
return
state
;
}
// 打开
private
void
turnOn
(
Parameters
parameters
)
{
parameters
.
setFlashMode
(
Parameters
.
FLASH_MODE_TORCH
);
camera
.
setParameters
(
parameters
);
}
// 关闭
private
void
turnOff
(
Parameters
parameters
)
{
parameters
.
setFlashMode
(
Parameters
.
FLASH_MODE_OFF
);
camera
.
setParameters
(
parameters
);
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/camera/FlashlightManager.java
deleted
100644 → 0
View file @
03737d19
/*
* 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
);
}
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/camera/PlanarYUVLuminanceSource.java
deleted
100644 → 0
View file @
03737d19
/*
* 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
;
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/camera/PreviewCallback.java
deleted
100644 → 0
View file @
03737d19
/*
* 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"
);
}
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/CaptureActivityHandler.java
deleted
100644 → 0
View file @
03737d19
/*
* 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
();
}
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/DecodeFormatManager.java
deleted
100644 → 0
View file @
03737d19
/*
* 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
;
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/DecodeHandler.java
deleted
100644 → 0
View file @
03737d19
/*
* 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
();
}
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/DecodeThread.java
deleted
100644 → 0
View file @
03737d19
/*
* 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
();
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/FinishListener.java
deleted
100644 → 0
View file @
03737d19
/*
* 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
();
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/InactivityTimer.java
deleted
100644 → 0
View file @
03737d19
/*
* 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
;
}
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/Intents.java
deleted
100644 → 0
View file @
03737d19
/*
* 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
()
{
}
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/decoding/RGBLuminanceSource.java
deleted
100644 → 0
View file @
03737d19
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
;
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/view/ViewfinderResultPointCallback.java
deleted
100644 → 0
View file @
03737d19
/*
* 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
);
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/zxing/view/ViewfinderView.java
deleted
100644 → 0
View file @
03737d19
/*
* 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.4
F
,
0.0
F
,
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
);
}
}
base-module/src/main/res/layout/base_activity_capture_new.xml
View file @
649170bf
...
...
@@ -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"
>
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"
/
>
<!-- <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"
<!-- <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=
"wrap_content"
android:layout_alignParentTop=
"true"
android:orientation=
"vertical"
>
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
download-module/src/main/java/com/gingersoft/gsa/cloud/download/ComponentDownload.java
View file @
649170bf
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
());
}
...
...
download-module/src/main/java/com/gingersoft/gsa/cloud/download/mvp/ui/activity/DownloadActivity.java
View file @
649170bf
...
...
@@ -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
...
...
download-module/src/main/res/layout/download_data_activity_download.xml
View file @
649170bf
...
...
@@ -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
login-module/src/main/java/com/gingersoft/gsa/cloud/login/mvp/presenter/BaseLoginPresenter.java
View file @
649170bf
...
...
@@ -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
));
}
}
});
}
...
...
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/activity/NewMainActivity.java
View file @
649170bf
...
...
@@ -12,6 +12,7 @@ import android.text.TextUtils;
import
android.util.SparseArray
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
...
...
@@ -29,8 +30,11 @@ import com.gingersoft.gsa.cloud.base.utils.encryption.Aes;
import
com.gingersoft.gsa.cloud.base.utils.other.SPUtils
;
import
com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
;
import
com.gingersoft.gsa.cloud.constans.AppConstans
;
import
com.gingersoft.gsa.cloud.constans.ResultConstans
;
import
com.gingersoft.gsa.cloud.database.bean.Function
;
import
com.gingersoft.gsa.cloud.function.FunctionManager
;
import
com.gingersoft.gsa.cloud.main.BuildConfig
;
import
com.gingersoft.gsa.cloud.main.ComponentMain
;
import
com.gingersoft.gsa.cloud.main.R
;
import
com.gingersoft.gsa.cloud.main.R2
;
import
com.gingersoft.gsa.cloud.main.di.component.DaggerNewMainComponent
;
...
...
@@ -49,6 +53,7 @@ import com.jess.arms.base.BaseFragmentActivity;
import
com.jess.arms.di.component.AppComponent
;
import
com.jess.arms.utils.ArmsUtils
;
import
com.jess.arms.utils.DeviceUtils
;
import
com.lihang.ShadowLayout
;
import
com.scwang.smartrefresh.layout.SmartRefreshLayout
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
...
...
@@ -59,6 +64,8 @@ import butterknife.BindView;
import
butterknife.BindViews
;
import
butterknife.OnClick
;
import
static
com
.
gingersoft
.
gsa
.
cloud
.
database
.
bean
.
Function
.
STATUS_NONACTIVATED
;
import
static
com
.
gingersoft
.
gsa
.
cloud
.
database
.
bean
.
Function
.
STATUS_TIME_LIMIT
;
import
static
com
.
jess
.
arms
.
utils
.
Preconditions
.
checkNotNull
;
...
...
@@ -89,10 +96,13 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
@BindView
(
R2
.
id
.
slideMenu
)
SlidingMenu
slideMenu
;
// @BindView(R2.id.layout_ordering_meals)
// LinearLayout orderingMeals;
// @BindView(R2.id.layout_management)
// LinearLayout layoutManagement;
@BindView
(
R2
.
id
.
layout_ordering_meals
)
ShadowLayout
sl_order
;
@BindView
(
R2
.
id
.
ll_management
)
LinearLayout
ll_management
;
@BindView
(
R2
.
id
.
ll_staff_management
)
LinearLayout
ll_staff_management
;
@BindView
(
R2
.
id
.
tv_restaurant_name
)
TextView
tvRestaurantName
;
@BindView
(
R2
.
id
.
tv_username
)
...
...
@@ -104,10 +114,10 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
@BindView
(
R2
.
id
.
qm_refresh
)
SmartRefreshLayout
refresh
;
private
MainTopFragment
mainTopFragment
;
@BindViews
({
R2
.
id
.
tv_function_name1
,
R2
.
id
.
tv_function_name2
,
R2
.
id
.
tv_function_name3
})
TextView
[]
mTvFunctionNames
;
private
MainTopFragment
mainTopFragment
;
private
RxPermissions
mRxPermissions
;
@Override
...
...
@@ -151,7 +161,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
}
});
refresh
.
setEnableLoadMore
(
false
);
initFuncationData
();
//
initFuncationData();
updateTitleInfo
();
//側滑顯示或關閉時,修改背景圓角
...
...
@@ -170,6 +180,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
@Override
protected
void
onResume
()
{
super
.
onResume
();
initFuncationData
();
if
(((
int
)
SPUtils
.
get
(
mContext
,
"isFormal"
,
0
))
!=
0
)
{
tv_version_name
.
setText
(
"v_"
+
DeviceUtils
.
getVersionName
(
this
)
+
"\u1500Beta"
);
}
else
{
...
...
@@ -249,33 +260,54 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
// }
List
<
Function
>
functions
=
new
ArrayList
<>();
// if (!BuildConfig.DEBUG) {
functions
.
add
(
new
Function
((
long
)
150
,
0
,
5
,
"點餐"
,
0
,
0
));
if
(
BuildConfig
.
DEBUG
)
{
functions
.
add
(
new
Function
((
long
)
138
,
150
,
5
,
"餐檯模式"
,
R
.
drawable
.
ic_dining_table_mode
,
0
));
}
functions
.
add
(
new
Function
((
long
)
139
,
150
,
5
,
"外送/自取"
,
R
.
drawable
.
ic_delivery_mode
,
0
));
// functions.add(new Function((long) 140, 150, 5, "外賣模式", R.drawable.ic_outsourcing_model_close, 0));
// functions.add(new Function((long) 141, 150, 5, "預點餐模式", R.drawable.ic_pre_order_mode_close, 1));
functions
.
add
(
new
Function
((
long
)
151
,
0
,
5
,
"管理"
,
0
,
0
));
if
(
BuildConfig
.
DEBUG
)
{
functions
.
add
(
new
Function
((
long
)
142
,
151
,
5
,
"賬單管理"
,
R
.
drawable
.
ic_meals_menu_management
,
0
));
functions
.
add
(
new
Function
((
long
)
143
,
151
,
5
,
"餐檯管理"
,
R
.
drawable
.
ic_dining_table_management
,
0
));
}
functions
.
add
(
new
Function
((
long
)
144
,
151
,
5
,
"打印管理"
,
R
.
drawable
.
ic_print_management
,
0
));
if
(
BuildConfig
.
DEBUG
)
{
functions
.
add
(
new
Function
((
long
)
145
,
151
,
5
,
"支付管理"
,
R
.
drawable
.
ic_pay_management_close
,
1
));
functions
.
add
(
new
Function
((
long
)
146
,
151
,
5
,
"折扣管理"
,
R
.
drawable
.
ic_discount_management_close
,
1
));
functions
.
add
(
new
Function
((
long
)
147
,
151
,
5
,
"沽清管理"
,
R
.
drawable
.
ic_sell_off_manger
,
0
));
}
//
//
if (!BuildConfig.DEBUG) {
//
functions.add(new Function((long) 150, 0, 5, "點餐", 0, 0));
//
if (BuildConfig.DEBUG) {
//
functions.add(new Function((long) 138, 150, 5, "餐檯模式", R.drawable.ic_dining_table_mode, 0));
//
}
//
functions.add(new Function((long) 139, 150, 5, "外送/自取", R.drawable.ic_delivery_mode, 0));
//
//
functions.add(new Function((long) 140, 150, 5, "外賣模式", R.drawable.ic_outsourcing_model_close, 0));
//
//
functions.add(new Function((long) 141, 150, 5, "預點餐模式", R.drawable.ic_pre_order_mode_close, 1));
//
functions.add(new Function((long) 151, 0, 5, "管理", 0, 0));
//
if (BuildConfig.DEBUG) {
//
functions.add(new Function((long) 142, 151, 5, "賬單管理", R.drawable.ic_meals_menu_management, 0));
//
functions.add(new Function((long) 143, 151, 5, "餐檯管理", R.drawable.ic_dining_table_management, 0));
//
}
//
functions.add(new Function((long) 144, 151, 5, "打印管理", R.drawable.ic_print_management, 0));
//
if (BuildConfig.DEBUG) {
//
functions.add(new Function((long) 145, 151, 5, "支付管理", R.drawable.ic_pay_management_close, 1));
//
functions.add(new Function((long) 146, 151, 5, "折扣管理", R.drawable.ic_discount_management_close, 1));
//
functions.add(new Function((long) 147, 151, 5, "沽清管理", R.drawable.ic_sell_off_manger, 0));
//
}
// functions.add(new Function((long) 152, 0, 5, "員工", 0, 0));
// functions.add(new Function((long) 147, 152, 5, "員工管理", R.drawable.ic_staff_management_close, 1));
// functions.add(new Function((long) 148, 152, 5, "權限管理", R.drawable.ic_authority_management_close, 1));
// functions.add(new Function((long) 149, 152, 5, "操作記錄", R.drawable.ic_operation_record_close, 1));
// } else {
// functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.main.class, ComponentMain.main.order, "order"));
// functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.main.class, ComponentMain.main.manager, "manager"));
// functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.main.class, ComponentMain.main.employee, "employee"));
List
<
Function
>
orderFuncations
=
FunctionManager
.
getDefault
().
getFunctionByResModule
(
this
,
ComponentMain
.
main
.
class
,
ComponentMain
.
main
.
order
,
"order"
);
if
(
orderFuncations
.
size
()
>
0
)
{
functions
.
addAll
(
orderFuncations
);
sl_order
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
sl_order
.
setVisibility
(
View
.
INVISIBLE
);
}
List
<
Function
>
managerFuncations
=
FunctionManager
.
getDefault
().
getFunctionByResModule
(
this
,
ComponentMain
.
main
.
class
,
ComponentMain
.
main
.
manager
,
"manager"
);
if
(
managerFuncations
.
size
()
>
0
)
{
functions
.
addAll
(
managerFuncations
);
ll_management
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
ll_management
.
setVisibility
(
View
.
GONE
);
}
List
<
Function
>
employeeFuncations
=
FunctionManager
.
getDefault
().
getFunctionByResModule
(
this
,
ComponentMain
.
main
.
class
,
ComponentMain
.
main
.
employee
,
"employee"
);
if
(
employeeFuncations
.
size
()
>
0
)
{
functions
.
addAll
(
employeeFuncations
);
ll_staff_management
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
ll_staff_management
.
setVisibility
(
View
.
GONE
);
}
// }
//將功能列表數據分組
...
...
@@ -295,9 +327,15 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
}
}
}
// if (orderFuncations.size() > 0) {
initAdapter
(
parents
,
funMap
,
0
,
R
.
layout
.
main_home_funcation_item
,
rvOrdering
,
4
);
// }
// if (managerFuncations.size() > 0) {
initAdapter
(
parents
,
funMap
,
1
,
R
.
layout
.
main_home_management_funcation_item
,
rvManagement
,
5
);
// }
// if (employeeFuncations.size() > 0) {
initAdapter
(
parents
,
funMap
,
2
,
R
.
layout
.
main_home_management_funcation_item
,
rvStaffManagement
,
4
);
// }
}
private
void
initAdapter
(
SparseArray
<
String
>
parents
,
SparseArray
<
List
<
Function
>>
funMap
,
int
i
,
int
p
,
RecyclerView
rvOrdering
,
int
i2
)
{
...
...
@@ -317,7 +355,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
}
private
void
functionClick
(
String
name
,
int
status
)
{
// switch (status){
// switch (status)
{
// case STATUS_NONACTIVATED:
// ToastUtils.show(mContext, "服務暫未開通,請前往開通");
// return;
...
...
@@ -509,6 +547,14 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
return
mRxPermissions
;
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
@Nullable
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
if
(
resultCode
==
ResultConstans
.
DOWNLOAD_PAGE_BACK
)
{
initFuncationData
();
}
}
private
long
mExitTime
;
@Override
...
...
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/adapter/MainOrderingAdapter.java
View file @
649170bf
...
...
@@ -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
);
}
...
...
main-module/src/main/res/layout/activity_new_main.xml
View file @
649170bf
...
...
@@ -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=
"
gon
e"
android:visibility=
"
visibl
e"
android:textColor=
"#181818"
android:textSize=
"@dimen/dp_14"
/>
...
...
@@ -222,11 +236,12 @@
android:id=
"@+id/rv_staff_management"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:visibility=
"
gon
e"
android:visibility=
"
visibl
e"
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>
<!-- 點餐模塊-->
<com.lihang.ShadowLayout
...
...
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/network/CoolWeatherNetwork.kt
View file @
649170bf
...
...
@@ -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
->
...
...
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/network/api/WeatherService.kt
View file @
649170bf
...
...
@@ -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
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/ui/adapter/OtherOrdersAdapter.kt
View file @
649170bf
...
...
@@ -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
>()
{
...
...
print-module/src/main/java/com/joe/print/mvp/print/PrintBill.java
View file @
649170bf
...
...
@@ -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
));
}
...
...
print-module/src/main/java/com/joe/print/mvp/print/PrinterRoot.java
View file @
649170bf
...
...
@@ -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
);
//會員號碼
...
...
print-module/src/main/java/com/joe/print/mvp/print/utils/BytesUtil.java
View file @
649170bf
...
...
@@ -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图转换为头四位有宽高的光栅位图
...
...
print-module/src/main/java/com/joe/print/mvp/print/utils/ESCUtil.java
View file @
649170bf
...
...
@@ -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);
//
}
/**
* 打印一维条形码
...
...
print-module/src/main/java/com/joe/print/mvp/ui/activity/PrintActivity.java
View file @
649170bf
...
...
@@ -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
;
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/contract/TableContract.java
View file @
649170bf
...
...
@@ -61,6 +61,7 @@ public interface TableContract {
void
startMealStandActivity
();
void
setBottomFunctionVisibility
(
boolean
show
);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/model/bean/OrderDetailItem.java
View file @
649170bf
...
...
@@ -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
;
/**折扣金額*/
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/MealStandPresenter.java
View file @
649170bf
...
...
@@ -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
;
}
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/OrderContentPresenter.java
View file @
649170bf
...
...
@@ -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);
}
}
...
...
@@ -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
};
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/TablePresenter.java
View file @
649170bf
...
...
@@ -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
)
{
//刷新餐檯
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/activity/MealStandActivity.java
View file @
649170bf
...
...
@@ -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,6 +569,7 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter>
void
onClickTable
()
{
//type取值:1qrCdoetype,2:手機號,3:memberId
// mUseMemberDialog = new UseMemberDialog(this);
if
(
mUseMemberDialog
==
null
)
{
mUseMemberDialog
=
new
UseMemberDialog
.
BottomLayoutBuilder
(
this
)
.
setOnLayoutClickListener
(
new
UseMemberDialog
.
BottomLayoutBuilder
.
OnLayoutClickListener
()
{
...
...
@@ -621,6 +619,7 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter>
}
})
.
build
();
}
mUseMemberDialog
.
show
();
}
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/activity/TableActivity.java
View file @
649170bf
...
...
@@ -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
;
}
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/activity/orderManager/OrderDetailActivity.java
View file @
649170bf
...
...
@@ -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
);
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/adapter/BottomFunctionAdapter.java
View file @
649170bf
...
...
@@ -69,7 +69,7 @@ public class BottomFunctionAdapter extends DefaultAdapter<Function> {
private
void
initItemData
(
Function
item
)
{
tv_name
.
setText
(
item
.
getResName
());
iv_icon
.
setImageResource
(
item
.
getIc
on
Res
());
iv_icon
.
setImageResource
(
item
.
getIcRes
());
}
}
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/adapter/OrderCenterAdapter.java
View file @
649170bf
...
...
@@ -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
);
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/widget/UseMemberDialog.java
View file @
649170bf
...
...
@@ -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
()
{
...
...
table-module/src/main/res/layout/activity_order_detail.xml
View file @
649170bf
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment