This paper shows you how to port an Apple iOS accelerometer app to HTML5 using these tools.
HTML5 is the new HTML standard. Recently, Intel Corporation announced a set of HTML5 Tools for developing mobile applications. This paper shows you how to port an Apple iOS* accelerometer app to HTML5 using these tools. Please note: Auto-generated code created by the Intel XDK may contain code licensed under one or more of the licenses detailed in Appendix A of this document. Please refer to the Intel XDK output for details on which libraries are used to enable your application.
Intel HTML5 App Porter Tool
The first thing we’ll do is take an iOS accelerometer app and convert the Objective-C*source code to HTML5. We’ll do this using the Intel® HTML5 App Porter Tool and the source code found here: [iOS_source.zip] (Note: IOS_source sample code is provided under the Intel Sample Software License detailed in Appendix B).You can download the Intel HTML5 App Porter Tool from the Tools tab here: http://software.intel.com/en-us/html5. After filling in and submitting the form with your e-mail address, you will get links for downloading this tool. The instructions on how to use this tool can be found on this site: http://software.intel.com/en-us/articles/tutorial-creating-an-html5-app-from-a-native-ios-project-with-intel-html5-app-porter-tool
When you are finished performing all the steps, you will get HTML5 source code.
Intel XDK
You can open the HTML5 code in any IDE. Intel offers you a convenient tool for developing HTML5 applications: Intel XDK – Cross platform development kit (http://html5dev-software.intel.com/). With Intel XDK, developers can write a single source code for deployment on many devices. What is particularly good is it is not necessary to install it on your computer. You can install it as an extension for Google Chrome*. If you use another browser, you have to download a JavaScript* file and run it. Sometimes it’s necessary to update Java*.
After installing Intel XDK, you will see the main window:
If you want to port existing code, press the big “Start new” button.
If you’re creating a new project, enter the Project Name and check “Create your own from scratch,” as shown in the screen shot below.
Check “Use a blank project.” Wait a bit, and you will see the message “Application Created Successfully!”
Click “Open project folder.”
Remove all files from this folder and copy the ported files. We haven’t quite ported the accelerometer app yet. We still have to write an interface for it. It is possible to remove the hooks created by the Intel HTML5 App Porter Tool. Remove these files:
todo_api_application__uiaccelerometerdelegate.js
todo_api_application_uiacceleration.js
todo_api_application_uiaccelerometer.js
todo_api_js_c_global.js
To update the project in Intel XDK, go to the editor window in the Windows emulator.
Open the index.html file and remove the lines left from the included files.
Open the todo_api_application_appdelegate.js file and implement the unmapped “window” property of the delegate.
In the ViewController_View_774585933.css file, we have to change styles of element colors from black to white to be readable on the black background: color: rgba(0,0,0,1); to color: rgba(256,256,256,1);. As a result we get:
01
div#Label_590244915
02
{
03
left: 20px;
04
color: rgba(256,256,256,1);
05
height: 21px;
06
position: absolute;
07
text-align: left;
08
width: 320px;
09
top: 0px;
10
opacity: 1;
11
}
12
div#Label_781338720
13
{
14
left: 20px;
15
color: rgba(256,256,256,1);
16
height: 21px;
17
position: absolute;
18
text-align: left;
19
width: 42px;
20
top: 29px;
21
opacity: 1;
22
}
23
div#Label_463949782
24
{
25
left: 20px;
26
color: rgba(256,256,256,1);
27
height: 21px;
28
position: absolute;
29
text-align: left;
30
width: 42px;
31
top: 51px;
32
opacity: 1;
33
}
34
div#Label_817497855
35
{
36
left: 20px;
37
color: rgba(256,256,256,1);
38
height: 21px;
39
position: absolute;
40
text-align: left;
41
width: 42px;
42
top: 74px;
43
opacity: 1;
44
}
45
div#Label_705687206
46
{
47
left: 70px;
48
color: rgba(256,256,256,1);
49
height: 21px;
50
position: absolute;
51
text-align: left;
52
width: 42px;
53
top: 29px;
54
opacity: 1;
55
}
56
div#Label_782673145
57
{
58
left: 70px;
59
color: rgba(256,256,256,1);
60
height: 21px;
61
position: absolute;
62
text-align: left;
63
width: 42px;
64
top: 51px;
65
opacity: 1;
66
}
67
div#Label_1067317462
68
{
69
left: 70px;
70
color: rgba(256,256,256,1);
71
height: 21px;
72
position: absolute;
73
text-align: left;
74
width: 42px;
75
top: 74px;
76
opacity: 1;
77
}
78
div#View_774585933
79
{
80
left: 0px;
81
height: 548px;
82
position: absolute;
83
width: 320px;
84
top: 20px;
85
opacity: 1;
86
}
After updating the emulator window, you see:
To code the accelerometer functions, we need to use the appMobi JavaScript Library. Documentation for this library can be found here. It’s installed when you download Intel XDK.
Open the index.html file and add this line into the list of scripts: