Explorar el Código

[提交内容]:nfc

wangyj18 %!s(int64=9) %!d(string=hace) años
padre
commit
7f0ec72973

+ 4 - 4
display-client/AndroidManifest.xml

@ -5,8 +5,8 @@
5 5
    android:versionName="1.3" >
6 6

7 7
    <uses-sdk
8
        android:minSdkVersion="8"
9
        android:targetSdkVersion="15" />
8
        android:minSdkVersion="10"
9
        android:targetSdkVersion="15" /><!-- minSdkVersion modify to 10 by wyj for nfc  -->
10 10

11 11
    <uses-permission android:name="android.permission.CAMERA" />
12 12
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
@ -69,7 +69,7 @@
69 69
        <activity
70 70
            android:name="com.wade.mobile.common.nfc.activity.NfcActivity">
71 71
            
72
            <intent-filter>
72
            <!-- <intent-filter>
73 73
                <action android:name="android.nfc.action.TECH_DISCOVERED" />
74 74
            </intent-filter>
75 75

@ -81,7 +81,7 @@
81 81
                <action android:name="android.nfc.action.TAG_DISCOVERED" />
82 82

83 83
                <category android:name="android.intent.category.DEFAULT" />
84
            </intent-filter>
84
            </intent-filter> -->
85 85
        </activity>
86 86
        
87 87
        <!-- 注册推送服务 -->

+ 23 - 0
display-server/web/biz/js/plugin/nfc.js

@ -0,0 +1,23 @@
1
require(["domReady!","mobile","jcl","tap"],function(doc, Mobile, $) {
2
	
3
	/* 欢迎分享公共的NFC数据读取 */
4
	
5
	$("#init").tap(function(){
6
		// 默认已经支持北京公交卡信息的读取(即读取北京公交卡的数据不需要解析)
7
		// 发送的指令,byte[]数组转换成string
8
		// 可以使用wade-mobile-com.jar包中的com.wade.mobile.common.nfc.util.Util的toHexString转换成字符串
9
		var cmds1 = new $.DataMap();
10
		cmds1.put("cmd1","00A404000E315041592E5359532E444446303100");
11
		cmds1.put("cmd2","00B0840000");
12
		cmds1.put("cmd3","00B0850000");
13
		cmds1.put("cmd4","00A4000002100100");
14
		cmds1.put("cmd5","805C000204");
15
		var cmds = new $.DataMap();
16
		cmds.put("cmds1",cmds1);
17
		Mobile.initDfc(cmds);
18
	});
19
	
20
	window.getNfcMsg = function(msg){
21
		alert(msg);
22
	}
23
});

+ 0 - 14
display-server/web/template/common/Head.html

@ -10,20 +10,6 @@ require(["domReady!","mobile","jcl","tap"],function(doc, Mobile, $) {
10 10
	$(".c_navBar").find(".back").tap(function(){
11 11
		Mobile.back();
12 12
	});
13
	
14
	var cmds1 = new $.DataMap();
15
	cmds1.put("cmd1","00A404000E315041592E5359532E444446303100");
16
	cmds1.put("cmd2","00B0840000");
17
	cmds1.put("cmd3","00B0850000");
18
	cmds1.put("cmd4","00A4000002100100");
19
	cmds1.put("cmd5","805C000204");
20
	var cmds = new $.DataMap();
21
	cmds.put("cmds1",cmds1);
22
	Mobile.initDfc(cmds);
23
	
24
	window.getNfcMsg = function(msg){
25
		alert(msg);
26
	}
27 13
}); 
28 14
</script>
29 15


+ 2 - 0
display-server/web/template/webapp/plugin/NFC.html

@ -6,6 +6,7 @@
6 6
	<title>NFC</title>
7 7
	{%>template/common/Head.html%}
8 8
	<link href="biz/css/project.css" rel="stylesheet" type="text/css" />
9
	<script type="text/javascript" src="biz/js/plugin/nfc.js"></script>
9 10
</head>
10 11
<body>
11 12

@ -28,6 +29,7 @@
28 29
						<div class="title">初始化NFC</div>
29 30
						<div class="info">在公共方法中初始化nfc,如指令等</div>
30 31
					</div>
32
					<div class="fn fn-2" id="init">初始化</div>
31 33
				</div>
32 34
			</li>
33 35
		</ul>

BIN
wade-mobile-common/libs/wade-mobile.jar


BIN
wade-mobile-func/libs/wade-mobile-com.jar


+ 6 - 0
wade-mobile-func/src/com/wade/mobile/func/MobileDevice.java

@ -3,9 +3,11 @@ package com.wade.mobile.func;
3 3
import org.json.JSONArray;
4 4
import org.json.JSONObject;
5 5

6
import android.content.Intent;
6 7
import android.os.Bundle;
7 8
import android.os.Handler;
8 9

10
import com.wade.mobile.common.nfc.activity.NfcActivity;
9 11
import com.wade.mobile.common.nfc.util.NfcConstant;
10 12
import com.wade.mobile.frame.IWadeMobile;
11 13
import com.wade.mobile.frame.plugin.Plugin;
@ -13,6 +15,8 @@ import com.wade.mobile.util.EscapeUnescape;
13 15

14 16
public class MobileDevice extends Plugin {
15 17

18
	private static final int INIT_NFC = 111;
19

16 20
	public MobileDevice(IWadeMobile wademobile) {
17 21
		super(wademobile);
18 22
	}
@ -32,6 +36,8 @@ public class MobileDevice extends Plugin {
32 36
			NfcConstant.setCmds(cmds);
33 37
		}
34 38

39
		Intent intent = new Intent(context, NfcActivity.class);
40
		startActivityForResult(intent, INIT_NFC);
35 41
	}
36 42

37 43
	final Handler handler = new Handler() {

+ 14 - 30
wade-mobile-func/src/com/wade/mobile/func/MobileUI.java

@ -16,6 +16,7 @@ import android.app.ProgressDialog;
16 16
import android.content.DialogInterface;
17 17
import android.content.Intent;
18 18
import android.graphics.Color;
19
import android.util.Log;
19 20
import android.view.Gravity;
20 21
import android.view.KeyEvent;
21 22
import android.webkit.WebView;
@ -150,10 +151,8 @@ public class MobileUI extends Plugin {
150 151

151 152
		context.runOnUiThread(new Runnable() {
152 153
			public void run() {
153
				// TODO Auto-generated method stub
154 154
				try {
155
					TemplateWebView webview = initFlipperPage(pageAction,
156
							isAnimation);
155
					TemplateWebView webview = initFlipperPage(pageAction, isAnimation);
157 156
					webview.loadTemplate(templatePath, data);
158 157
				} catch (Exception e) {
159 158
					MobileLog.e(TAG, e.getMessage(), e);
@ -261,41 +260,34 @@ public class MobileUI extends Plugin {
261 260
	}
262 261

263 262
	/************************ 多WebView 开始 *****************************/
264
	private TemplateWebView initFlipperPage(String pageAction,
265
			boolean isAnimation) {
266
		// TODO Auto-generated method stub
263
	private TemplateWebView initFlipperPage(String pageAction, boolean isAnimation) {
267 264
		FlipperLayout mainFlipper = wademobile.getFlipperLayout();
268
		TemplateWebView webview = (TemplateWebView) mainFlipper
269
				.findViewWithTag(pageAction);
265
		TemplateWebView webview = (TemplateWebView) mainFlipper.getNextView();
266
		
270 267
		if (webview == null) {
271
			webview = addFlipperPage(mainFlipper, pageAction);
268
			webview = addFlipperPage(mainFlipper);
272 269
		}
270
		
273 271
		if (isAnimation) {
274 272
			mainFlipper.setAnimation(AnimationResource.pushLeft[0],
275 273
					AnimationResource.pushLeft[1]);
276 274
			mainFlipper.setBackAnimation(AnimationResource.pushRight[0],
277 275
					AnimationResource.pushRight[1]);
278 276
		}
279
		webview.setTag(pageAction);
277
		webview.setTag(pageAction); //记录当前页面名称
280 278
		mainFlipper.setPreCurrView(webview);
281 279
		return webview;
282 280
	}
283 281

284
	private TemplateWebView addFlipperPage(final FlipperLayout mainFlipper,
285
			final String pageAction) {
286
		final TemplateWebView webview = new TemplateWebView(wademobile) {
287
			final TemplateWebView outWebView = this;// 让上级对象转义到下级scope
288

282
	private TemplateWebView addFlipperPage(final FlipperLayout mainFlipper) {
283
		TemplateWebView webview = new TemplateWebView(wademobile) {
289 284
			@Override
290 285
			protected void initialize() {
291
				// TODO Auto-generated method stub
292 286
				WadeWebViewClient webViewClient = new WadeWebViewClient(
293 287
						wademobile, new TemplateWebViewEvent(wademobile) {
294 288
							@Override
295 289
							public void loadingFinished(WebView view, String url) {
296
								// TODO Auto-generated method stub
297
								wademobile.getFlipperLayout().showView(
298
										outWebView.getTag().toString());// 直接使用getTag()方法也可行
290
								wademobile.getFlipperLayout().showNextView();
299 291
							}
300 292
						});
301 293
				setWebViewClient(webViewClient);
@ -303,13 +295,10 @@ public class MobileUI extends Plugin {
303 295
		};
304 296
		webview.setLayoutParams(ConstantParams
305 297
				.getFillParams(LinearLayout.LayoutParams.class));
306
		((WadeMobileActivity) wademobile).getWebviewSetting().setWebViewStyle(
307
				webview);// 设置webview的样式
308

309
		webview.setId(mainFlipper.getChildCount());
298
		((WadeMobileActivity) wademobile).getWebviewSetting().setWebViewStyle(webview);// 设置webview的样式
310 299

311
		mainFlipper.addView(webview);// 增加view
312
		webview.postInvalidate();// 刷新页面
300
		mainFlipper.addNextView(webview);// 增加view
301
//		webview.postInvalidate();// 刷新页面
313 302
		return webview;
314 303
	}
315 304

@ -451,7 +440,6 @@ public class MobileUI extends Plugin {
451 440
	 */
452 441
	public void confirm(String message, String title, final String[] events,
453 442
			final String[] buttons) {
454
		// TODO Auto-generated method stub
455 443
		AlertDialog.Builder dialog = new AlertDialog.Builder(this.context);
456 444
		dialog.setMessage(message);
457 445
		if (title != null) {
@ -512,7 +500,6 @@ public class MobileUI extends Plugin {
512 500
	}
513 501

514 502
	public void getDate(String date, final String format) {
515
		// TODO Auto-generated method stub
516 503
		int year, month, day_of_month;
517 504
		final Calendar cal = Calendar.getInstance();
518 505
		final SimpleDateFormat df = new SimpleDateFormat(format);
@ -536,7 +523,6 @@ public class MobileUI extends Plugin {
536 523
						@Override
537 524
						public void onDateSet(DatePicker view, int year,
538 525
								int monthOfYear, int dayOfMonth) {
539
							// TODO Auto-generated method stub
540 526
							cal.set(year, monthOfYear, dayOfMonth);
541 527
							String date = df.format(cal.getTime());
542 528
							MobileUI.this.callback(date);
@ -553,7 +539,6 @@ public class MobileUI extends Plugin {
553 539
						@Override
554 540
						public void onDateSet(DatePicker view, int year,
555 541
								int monthOfYear, int dayOfMonth) {
556
							// TODO Auto-generated method stub
557 542
							cal.set(year, monthOfYear, dayOfMonth);
558 543
							String date = df.format(cal.getTime());
559 544
							MobileUI.this.callback(date);
@ -841,7 +826,6 @@ public class MobileUI extends Plugin {
841 826

842 827
	@Override
843 828
	public void onActivityResult(int requestCode, int resultCode, Intent intent) {
844
		// TODO Auto-generated method stub
845 829
		if (requestCode == REQUEST_CODE_CUSTOM_DIALOG) {
846 830
			if (intent == null)
847 831
				return;