3c2353cd
杜方
1、畅游通核销app源码提交;
|
1
|
package com.ectrip.cyt.ui;
|
df682192
杜方
畅游通核销app: 1.优化扫CY...
|
2
|
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
3
4
|
import java.io.IOException;
import java.util.ArrayList;
|
11a1872a
杜方
畅游通标准:新增动态二维码检票
|
5
|
import java.util.Date;
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import java.util.Vector;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.os.Handler;
import android.os.Vibrator;
import android.view.SurfaceHolder;
import android.view.SurfaceHolder.Callback;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
|
5aabe1c0
黄灿宏
畅游通核销app: 1.增加扫码配置
|
24
|
import android.widget.Toast;
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
25
|
|
11a1872a
杜方
畅游通标准:新增动态二维码检票
|
26
27
28
|
import com.ectrip.common.dynamic.code.core.DynamicVerifyCodeTool;
import com.ectrip.common.dynamic.code.exception.DynamicVerifyCodeException;
import com.ectrip.common.dynamic.code.model.DynamicVerifyCodeDecodeResult;
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
29
|
import com.ectrip.cyt.bean.ConfigBean;
|
5aabe1c0
黄灿宏
畅游通核销app: 1.增加扫码配置
|
30
|
import com.ectrip.cyt.config.DevicTool;
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import com.ectrip.cyt.constant.constant;
import com.ectrip.cyt.db.DbManager;
import com.ectrip.cyt.shield_home.LockLayer.MToast;
import com.ectrip.cyt.utils.AESEncryptor;
import com.ectrip.cyt.utils.Base64;
import com.ectrip.cyt.utils.DesUtil;
import com.ectrip.cyt.utils.LogUtil;
import com.ectrip.cyt.utils.SharedPreferences2Obj;
import com.ectrip.cyt.zxing.camera.CameraManager;
import com.ectrip.cyt.zxing.decoding.CaptureActivityHandler;
import com.ectrip.cyt.zxing.decoding.InactivityTimer;
import com.ectrip.cyt.zxing.view.ViewfinderView;
import com.ectrip.trips.check.R;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
/**
* 手机版扫描二维码
*/
public class PhomeScanerOrderActivity extends BaseActivity implements Callback {
|
df682192
杜方
畅游通核销app: 1.优化扫CY...
|
51
|
public final String TAG = "PhomeScanerOrderActivity";
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
52
53
54
55
56
57
58
59
60
61
62
|
private CaptureActivityHandler handler;
private ViewfinderView viewfinderView;
private boolean hasSurface;
private Vector<BarcodeFormat> decodeFormats;
private String characterSet;
private InactivityTimer inactivityTimer;
private MediaPlayer mediaPlayer;
private boolean playBeep;
private final float BEEP_VOLUME = 0.10f;
private boolean vibrate;
private String titleName;
|
df682192
杜方
畅游通核销app: 1.优化扫CY...
|
63
|
private int typeScan;
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 使屏幕不显示标题栏(必须要在setContentView方法执行前执行)
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// 隐藏状态栏,使内容全屏显示(必须要在setContentView方法执行前执行)
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_capture2);
// ViewUtil.addTopView(getApplicationContext(), this,
// R.string.scan_card);
CameraManager.init(getApplication());
viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
titleName = getIntent().getStringExtra("titleName");
if (titleName != null) {
((TextView) findViewById(R.id.title)).setText(titleName);
} else {
((TextView) findViewById(R.id.title))
.setText(R.string.scan_qr_code);
}
((TextView) findViewById(R.id.title)).setVisibility(View.VISIBLE);
findViewById(R.id.topBack).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
hasSurface = false;
inactivityTimer = new InactivityTimer(this);
}
@SuppressWarnings("deprecation")
@Override
protected void onResume() {
super.onResume();
SharedPreferences2Obj.getInstance(PhomeScanerOrderActivity.this)
.setName("SelectAction").setObject("isStatistic", "0"); // 非统计
SurfaceView 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;
}
/**
* 处理扫描结果
*
* @param result
*/
public void handleDecode(Result result) {
inactivityTimer.onActivity();
playBeepSoundAndVibrate();
|
9e9f1eb7
杜方
1、畅游通核销app:新增主界面关...
|
137
|
String resultString = result.getText().trim();
|
df682192
杜方
畅游通核销app: 1.优化扫CY...
|
138
|
LogUtil.i(TAG, "扫码数据 = " + resultString);
|
5aabe1c0
黄灿宏
畅游通核销app: 1.增加扫码配置
|
139
140
141
142
|
if (resultString.startsWith("PZ")) {
configIdent(resultString);
return;
}
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
143
144
145
146
147
|
if (resultString.equals("")) {
MToast(PhomeScanerOrderActivity.this,
getString(R.string.scan_fail), MToast.LENGTH_SHORT);
} else {
try {
|
7d3f774c
杜方
畅游通核销app: 1.修复CYT...
|
148
|
if (resultString.startsWith("CYT_")) {
|
df682192
杜方
畅游通核销app: 1.优化扫CY...
|
149
150
151
152
153
154
155
156
|
typeScan = 0;
if (resultString.contains(",")) {
resultString = resultString.substring(resultString.indexOf("_") + 1, resultString.indexOf(","));
LogUtil.i(TAG, "resultString = " + resultString);
} else {
resultString = resultString.substring(resultString.indexOf("_") + 1, resultString.length());
LogUtil.i(TAG, "resultString1 = " + resultString);
}
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
157
158
159
|
ArrayList<ConfigBean> beans = DbManager.GetConfigs();
// 畅游通生成的订单ID:
String ec_name = beans.get(0).getEc_signkey();
|
df682192
杜方
畅游通核销app: 1.优化扫CY...
|
160
|
LogUtil.i(TAG, "ec_name = " + ec_name);
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
161
|
ec_name = AESEncryptor.decrypt(constant.decrypt, ec_name);
|
df682192
杜方
畅游通核销app: 1.优化扫CY...
|
162
|
LogUtil.i(TAG, "ec_name1 = " + ec_name);
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
163
164
|
resultString = DesUtil.decrypt(resultString, ec_name);
|
7d3f774c
杜方
畅游通核销app: 1.修复CYT...
|
165
|
} else if (resultString.startsWith("TDOS_")) {
|
df682192
杜方
畅游通核销app: 1.优化扫CY...
|
166
|
typeScan = 0;
|
9b537f44
杜方
畅游通核销app: 1.优化扫TD...
|
167
168
169
170
171
172
173
|
if (resultString.contains(",")) {
resultString = resultString.substring(resultString.indexOf("_") + 1, resultString.indexOf(","));
LogUtil.i(TAG, "resultString = " + resultString);
} else {
resultString = resultString.substring(resultString.indexOf("_") + 1, resultString.length());
LogUtil.i(TAG, "resultString1 = " + resultString);
}
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
174
|
resultString = new String(Base64.decode(resultString), "utf-8");
|
7d3f774c
杜方
畅游通核销app: 1.修复CYT...
|
175
|
} else if ((resultString.startsWith("TY_") || (resultString.startsWith("PMS_")))) {
|
df682192
杜方
畅游通核销app: 1.优化扫CY...
|
176
|
typeScan = 1;
|
2707d233
杜方
1、畅游通核销app;修改扫二维码...
|
177
|
resultString = resultString;
|
da545be8
杜方
畅游通核销app:1.新增检前缀为...
|
178
179
180
|
} else if (resultString.startsWith("OCP_")) {
typeScan = 0;
resultString = resultString;
|
11a1872a
杜方
畅游通标准:新增动态二维码检票
|
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
} else if (resultString.startsWith("DYV_")) {
try {
DynamicVerifyCodeDecodeResult decodeResult = DynamicVerifyCodeTool.decodeDynamicCode(resultString);
boolean expired = decodeResult.getExpired();
String staticCode = decodeResult.getStaticCode();
Date expireTime = decodeResult.getExpireTime();
LogUtil.d(TAG, "expired = " + expired);
LogUtil.d(TAG, "staticCode = " + staticCode);
LogUtil.d(TAG, "expireTime = " + expireTime);
if (!expired) {
typeScan = 1;
resultString = staticCode;
} else {
typeScan = 2;
resultString = "动态二维码已过有效期";
}
} catch (DynamicVerifyCodeException e) {
typeScan = 2;
LogUtil.d(TAG, "动态核销码异常:" + e.getMessage());
resultString = e.getMessage();
e.printStackTrace();
}
|
7d3f774c
杜方
畅游通核销app: 1.修复CYT...
|
204
|
} else {
|
df682192
杜方
畅游通核销app: 1.优化扫CY...
|
205
|
typeScan = 1;
|
2707d233
杜方
1、畅游通核销app;修改扫二维码...
|
206
|
resultString = resultString;
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
207
208
209
210
|
}
} catch (Exception e) {
e.printStackTrace();
}
|
e4eb73bf
杜方
畅游通标准:修复打印数据为空时报错
|
211
|
Intent intent = null;
|
da545be8
杜方
畅游通核销app:1.新增检前缀为...
|
212
|
if (resultString.startsWith("OCP_")) {
|
e4eb73bf
杜方
畅游通标准:修复打印数据为空时报错
|
213
214
|
// intent = new Intent(PhomeScanerOrderActivity.this,
// PhoneCodeListActivity.class);
|
da545be8
杜方
畅游通核销app:1.新增检前缀为...
|
215
216
217
218
|
} else {
intent = new Intent(PhomeScanerOrderActivity.this,
QRCodeOrderListActivity.class);
}
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
219
220
|
intent.putExtra("mode", 1);
intent.putExtra("input_orid", resultString);
|
5aabe1c0
黄灿宏
畅游通核销app: 1.增加扫码配置
|
221
|
LogUtil.i(TAG, getString(R.string.scan_result) + resultString);
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
222
|
intent.putExtra("titleName", getString(R.string.show_result));
|
df682192
杜方
畅游通核销app: 1.优化扫CY...
|
223
|
intent.putExtra("typeScan", typeScan);
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
224
225
|
startActivity(intent);
}
|
7d3f774c
杜方
畅游通核销app: 1.修复CYT...
|
226
227
|
Boolean scanBack = SharedPreferences2Obj.getInstance(this).setName("config").getObject("scanBack", Boolean.class);
if (scanBack != null && scanBack) {
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
228
|
|
7d3f774c
杜方
畅游通核销app: 1.修复CYT...
|
229
|
} else {
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
230
|
|
7d3f774c
杜方
畅游通核销app: 1.修复CYT...
|
231
232
|
PhomeScanerOrderActivity.this.finish();
}
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
233
234
235
|
}
|
5aabe1c0
黄灿宏
畅游通核销app: 1.增加扫码配置
|
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
private void configIdent(String resultString) {
String[] split = resultString.split(";");
String serviceIp = split[0].split("=")[1];
String encode = split[1].split("=")[1];
String identity = split[2].split("=")[1];
if (!identity.equals("")) {
try {
identity = AESEncryptor.decrypt(constant.decrypt, identity);
LogUtil.d(TAG, getString(R.string.enterprise_communication_identifier)
+ identity);
identity = AESEncryptor.encrypt(constant.decrypt, identity);
} catch (Exception ex) {
try {
identity = AESEncryptor.encrypt(constant.decrypt,
identity);
LogUtil.d(TAG, getString(R.string.not_successfully_decrypt)
+ identity);
} catch (Exception e) {
e.printStackTrace();
return;
}
}
ArrayList<ConfigBean> beans = DbManager.GetConfigs();
ConfigBean bean = new ConfigBean();
String mac = DevicTool.getInstance().getDevId().trim();
bean.setEc_id(0 + "");
bean.setEc_ip(serviceIp.trim());
bean.setEc_identity(encode.trim());
bean.setEc_mac(mac.toUpperCase());
bean.setEc_passwd("123456");
bean.setEc_signkey(identity);
if (1 == beans.get(0).getEc_isPrint()) {
bean.setEc_isPrint(beans.get(0).getEc_isPrint());
|
da545be8
杜方
畅游通核销app:1.新增检前缀为...
|
269
|
} else {
|
5aabe1c0
黄灿宏
畅游通核销app: 1.增加扫码配置
|
270
271
272
273
|
bean.setEc_isPrint(0);
}
DbManager.ClearConfig();
DbManager.InsertConfig(bean);
|
c1300a1b
黄灿宏
畅游通核销app: 1.部分漏提交
|
274
275
276
|
Intent intent = new Intent(PhomeScanerOrderActivity.this,
SettingsActivity.class);
startActivity(intent);
|
5aabe1c0
黄灿宏
畅游通核销app: 1.增加扫码配置
|
277
278
279
|
}
}
|
3c2353cd
杜方
1、畅游通核销app源码提交;
|
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
private void initCamera(SurfaceHolder surfaceHolder) {
try {
CameraManager.get().openDriver(surfaceHolder, PhomeScanerOrderActivity.this);
} catch (IOException ioe) {
return;
} catch (RuntimeException e) {
return;
}
if (handler == null) {
handler = new CaptureActivityHandler(this, decodeFormats,
characterSet);
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
}
@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();
}
private void initBeepSound() {
if (playBeep && mediaPlayer == null) {
// The volume on STREAM_SYSTEM is not adjustable, and users found it
// too loud,
// so we now play on the music stream.
setVolumeControlStream(AudioManager.STREAM_MUSIC);
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setOnCompletionListener(beepListener);
AssetFileDescriptor file = getResources().openRawResourceFd(
R.raw.beep);
try {
mediaPlayer.setDataSource(file.getFileDescriptor(),
file.getStartOffset(), file.getLength());
file.close();
mediaPlayer.setVolume(BEEP_VOLUME, BEEP_VOLUME);
mediaPlayer.prepare();
} catch (IOException e) {
mediaPlayer = null;
}
}
}
private final long VIBRATE_DURATION = 200L;
private void playBeepSoundAndVibrate() {
if (playBeep && mediaPlayer != null) {
mediaPlayer.start();
}
if (vibrate) {
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATE_DURATION);
}
}
/**
* When the beep has finished playing, rewind to queue up another one.
*/
private final OnCompletionListener beepListener = new OnCompletionListener() {
public void onCompletion(MediaPlayer mediaPlayer) {
mediaPlayer.seekTo(0);
}
};
@Override
protected void onPause() {
super.onPause();
if (handler != null) {
handler.quitSynchronously();
handler = null;
}
CameraManager.get().closeDriver();
}
@Override
public void onBackPressed() {
if (handler != null) {
handler.quitSynchronously();
handler = null;
}
CameraManager.get().closeDriver();
super.onBackPressed();
}
@Override
protected void onDestroy() {
inactivityTimer.shutdown();
super.onDestroy();
}
}
|