Преглед на файлове

Skeleton context analyser project

Move classifier into common class
Refactor common classes so they're, well, common
master
Chris Smith преди 14 години
родител
ревизия
e6692123b5
променени са 24 файла, в които са добавени 970 реда и са изтрити 81 реда
  1. 1
    0
      .gitignore
  2. 2
    41
      code/ActivityRecorder/src/uk/co/md87/android/activityrecorder/ClassifierService.java
  3. 1
    0
      code/ActivityRecorder/src/uk/co/md87/android/common
  4. 65
    0
      code/Common/Classifier.java
  5. 1
    0
      code/Common/Common
  6. 0
    0
      code/Common/ExceptionHandler.java
  7. 17
    0
      code/ContextAnalyser/AndroidManifest.xml
  8. 25
    0
      code/ContextAnalyser/build.xml
  9. Двоични данни
      code/ContextAnalyser/dist/ContextAnalyser.apk
  10. Двоични данни
      code/ContextAnalyser/lib/FlurryAgent.jar
  11. 3
    0
      code/ContextAnalyser/manifest.mf
  12. 707
    0
      code/ContextAnalyser/nbproject/build-impl.xml
  13. 8
    0
      code/ContextAnalyser/nbproject/genfiles.properties
  14. 59
    0
      code/ContextAnalyser/nbproject/project.properties
  15. 16
    0
      code/ContextAnalyser/nbproject/project.xml
  16. Двоични данни
      code/ContextAnalyser/res/drawable/icon.png
  17. 10
    0
      code/ContextAnalyser/res/layout/main.xml
  18. 4
    0
      code/ContextAnalyser/res/values/strings.xml
  19. 1
    0
      code/ContextAnalyser/src/uk/co/md87/android/common/Common
  20. 0
    0
      code/ContextAnalyser/src/uk/co/md87/android/common/ExceptionHandler.java
  21. 24
    0
      code/ContextAnalyser/src/uk/co/md87/android/contextanalyser/IntroActivity.java
  22. 22
    0
      code/ContextAnalyser/src/uk/co/md87/android/contextanalyser/R.java
  23. 1
    0
      code/SensorLogger/src/uk/co/md87/android/common
  24. 3
    40
      code/SensorLogger/src/uk/co/md87/android/sensorlogger/ClassifierService.java

+ 1
- 0
.gitignore Целия файл

@@ -1,6 +1,7 @@
1 1
 /papers/*.bak
2 2
 /code/*/build
3 3
 /code/*/nbproject/private
4
+/code/*/*.apk
4 5
 /reports/*~
5 6
 /website/settings.php
6 7
 /*.keystore

+ 2
- 41
code/ActivityRecorder/src/uk/co/md87/android/activityrecorder/ClassifierService.java Целия файл

@@ -11,11 +11,10 @@ import android.content.Intent;
11 11
 import android.content.ServiceConnection;
12 12
 import android.os.IBinder;
13 13
 import android.os.RemoteException;
14
-import android.util.Log;
15 14
 import android.widget.Toast;
16 15
 
17
-import java.util.Map;
18 16
 import uk.co.md87.android.activityrecorder.rpc.ActivityRecorderBinder;
17
+import uk.co.md87.android.common.Classifier;
19 18
 
20 19
 /**
21 20
  *
@@ -71,45 +70,7 @@ public class ClassifierService extends Service implements Runnable {
71 70
     }
72 71
 
73 72
     public void run() {
74
-        float oddTotal = 0, evenTotal = 0;
75
-        float oddMin = Float.MAX_VALUE, oddMax = Float.MIN_VALUE;
76
-        float evenMin = Float.MAX_VALUE, evenMax = Float.MIN_VALUE;
77
-
78
-        for (int i = 0; i < 128; i++) {
79
-            evenTotal += data[i * 2];
80
-            oddTotal += data[i * 2 + 1];
81
-
82
-            evenMin = Math.min(evenMin, data[i * 2]);
83
-            oddMin = Math.min(oddMin, data[i * 2 + 1]);
84
-
85
-            evenMax = Math.max(evenMax, data[i * 2]);
86
-            oddMax = Math.max(oddMax, data[i * 2 + 1]);
87
-        }
88
-
89
-        final float[] points = {
90
-            Math.abs(evenTotal / 128),
91
-            Math.abs(oddTotal / 128),
92
-            evenMax - evenMin,
93
-            oddMax - oddMin
94
-        };
95
-
96
-        float bestDistance = Float.MAX_VALUE;
97
-        String bestActivity = "UNCLASSIFIED/UNKNOWN";
98
-        
99
-        for (Map.Entry<Float[], String> entry : RecorderService.model.entrySet()) {
100
-            float distance = 0;
101
-
102
-            for (int i = 0; i < points.length; i++) {
103
-                distance += Math.pow(points[i] - entry.getKey()[i], 2);
104
-            }
105
-
106
-            if (distance < bestDistance) {
107
-                bestDistance = distance;
108
-                bestActivity = entry.getValue();
109
-            }
110
-        }
111
-
112
-        classification = bestActivity;
73
+        classification = new Classifier(RecorderService.model.entrySet()).classify(data);
113 74
 
114 75
         //Log.i(getClass().getName(), "Classification: " + classification);
115 76
 

+ 1
- 0
code/ActivityRecorder/src/uk/co/md87/android/common Целия файл

@@ -0,0 +1 @@
1
+../../../../../../Common/

+ 65
- 0
code/Common/Classifier.java Целия файл

@@ -0,0 +1,65 @@
1
+/*
2
+ * To change this template, choose Tools | Templates
3
+ * and open the template in the editor.
4
+ */
5
+
6
+package uk.co.md87.android.common;
7
+
8
+import java.util.Map;
9
+import java.util.Map.Entry;
10
+import java.util.Set;
11
+
12
+/**
13
+ *
14
+ * @author chris
15
+ */
16
+public class Classifier {
17
+
18
+    private final Set<Map.Entry<Float[], String>> model;
19
+
20
+    public Classifier(final Set<Entry<Float[], String>> model) {
21
+        this.model = model;
22
+    }
23
+
24
+    public String classify(final float[] data) {
25
+        float oddTotal = 0, evenTotal = 0;
26
+        float oddMin = Float.MAX_VALUE, oddMax = Float.MIN_VALUE;
27
+        float evenMin = Float.MAX_VALUE, evenMax = Float.MIN_VALUE;
28
+
29
+        for (int i = 0; i < 128; i++) {
30
+            evenTotal += data[i * 2];
31
+            oddTotal += data[i * 2 + 1];
32
+
33
+            evenMin = Math.min(evenMin, data[i * 2]);
34
+            oddMin = Math.min(oddMin, data[i * 2 + 1]);
35
+
36
+            evenMax = Math.max(evenMax, data[i * 2]);
37
+            oddMax = Math.max(oddMax, data[i * 2 + 1]);
38
+        }
39
+
40
+        final float[] points = {
41
+            Math.abs(evenTotal / 128),
42
+            Math.abs(oddTotal / 128),
43
+            evenMax - evenMin,
44
+            oddMax - oddMin
45
+        };
46
+
47
+        float bestDistance = Float.MAX_VALUE;
48
+        String bestActivity = "UNCLASSIFIED/UNKNOWN";
49
+
50
+        for (Map.Entry<Float[], String> entry : model) {
51
+            float distance = 0;
52
+
53
+            for (int i = 0; i < points.length; i++) {
54
+                distance += Math.pow(points[i] - entry.getKey()[i], 2);
55
+            }
56
+
57
+            if (distance < bestDistance) {
58
+                bestDistance = distance;
59
+                bestActivity = entry.getValue();
60
+            }
61
+        }
62
+
63
+        return bestActivity;
64
+    }
65
+}

+ 1
- 0
code/Common/Common Целия файл

@@ -0,0 +1 @@
1
+../../../../../../Common/

code/ActivityRecorder/src/uk/co/md87/android/common/ExceptionHandler.java → code/Common/ExceptionHandler.java Целия файл


+ 17
- 0
code/ContextAnalyser/AndroidManifest.xml Целия файл

@@ -0,0 +1,17 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+     package="uk.co.md87.android.contextanalyser" android:versionCode="1" android:versionName="0.0.1">
4
+    <application android:label="Context Analyser" android:icon="@drawable/icon">
5
+         <activity android:name=".IntroActivity" android:label="IntroActivity">
6
+            <intent-filter>
7
+                <action android:name="android.intent.action.MAIN"/>
8
+                <category android:name="android.intent.category.LAUNCHER"/>
9
+            </intent-filter>
10
+        </activity>
11
+    </application>
12
+
13
+    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
14
+    <uses-permission android:name="android.permission.INTERNET"/>
15
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
16
+    <uses-sdk android:minSdkVersion="3" />
17
+</manifest>

+ 25
- 0
code/ContextAnalyser/build.xml Целия файл

@@ -0,0 +1,25 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!-- You may freely edit this file. See commented blocks below for -->
3
+<!-- some examples of how to customize the build. -->
4
+<!-- (If you delete it and reopen the project it will be recreated.) -->
5
+<project name="ContextAnalyser" default="default" basedir=".">
6
+    <description>Builds, tests, and runs the project ContextAnalyser.</description>
7
+    <import file="nbproject/build-impl.xml"/>
8
+
9
+    <target depends="init,-package-res-and-assets,-package-res-no-assets,-package-dex" name="-build-without-signing">
10
+        <exec executable="${apkbuilder}" failonerror="true">
11
+            <arg value="${basedir}/${dist.apk}"/>
12
+            <arg value="-u"/>
13
+            <arg value="-z"/>
14
+            <arg value="${basedir}/${dist.apk}_"/>
15
+        </exec>
16
+        <delete file="${dist.apk}_"/>
17
+    </target>
18
+
19
+    <target depends="init,compile,-pre-jar,-dex,-package-res-and-assets,-package-res-no-assets,-package-dex,-build-without-signing,-post-jar" description="Build unsigned JAR." name="unsigned-jar"/>
20
+
21
+    <target name="-pre-jar">
22
+       <unzip src="lib/FlurryAgent.jar" dest="${build.classes.dir}" overwrite="true"/>
23
+    </target>
24
+
25
+</project>

Двоични данни
code/ContextAnalyser/dist/ContextAnalyser.apk Целия файл


Двоични данни
code/ContextAnalyser/lib/FlurryAgent.jar Целия файл


+ 3
- 0
code/ContextAnalyser/manifest.mf Целия файл

@@ -0,0 +1,3 @@
1
+Manifest-Version: 1.0
2
+X-COMMENT: Main-Class will be added automatically by build
3
+

+ 707
- 0
code/ContextAnalyser/nbproject/build-impl.xml Целия файл

@@ -0,0 +1,707 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!--
3
+*** GENERATED FROM project.xml - DO NOT EDIT  ***
4
+***         EDIT ../build.xml INSTEAD         ***
5
+
6
+For the purpose of easier reading the script
7
+is divided into following sections:
8
+
9
+  - initialization
10
+  - compilation
11
+  - jar
12
+  - execution
13
+  - debugging
14
+  - javadoc
15
+  - junit compilation
16
+  - junit execution
17
+  - junit debugging
18
+  - cleanup
19
+
20
+        -->
21
+<project xmlns:androidproject1="http://www.netbeans.org/ns/android-project/1" basedir=".." default="default" name="ContextAnalyser-impl">
22
+    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
23
+    <!-- 
24
+                ======================
25
+                INITIALIZATION SECTION 
26
+                ======================
27
+            -->
28
+    <target name="-pre-init">
29
+        <!-- Empty placeholder for easier customization. -->
30
+        <!-- You can override this target in the ../build.xml file. -->
31
+    </target>
32
+    <target depends="-pre-init" name="-init-private">
33
+        <property file="nbproject/private/config.properties"/>
34
+        <property file="nbproject/private/configs/${config}.properties"/>
35
+        <property file="nbproject/private/private.properties"/>
36
+    </target>
37
+    <target depends="-pre-init,-init-private" name="-init-user">
38
+        <property file="${user.properties.file}"/>
39
+        <!-- The two properties below are usually overridden -->
40
+        <!-- by the active platform. Just a fallback. -->
41
+        <property name="default.javac.source" value="1.4"/>
42
+        <property name="default.javac.target" value="1.4"/>
43
+    </target>
44
+    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
45
+        <property file="nbproject/configs/${config}.properties"/>
46
+        <property file="nbproject/project.properties"/>
47
+    </target>
48
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
49
+        <androidproject1:property name="platform.home" value="platforms.${platform.active}.home"/>
50
+        <androidproject1:property name="platform.bootcp" value="platforms.${platform.active}.bootclasspath"/>
51
+        <androidproject1:property name="platform.bootcp0" value="platforms.${platform.active}.bootclasspath0"/>
52
+        <androidproject1:property name="platform.bootcp1" value="platforms.${platform.active}.bootclasspath1"/>
53
+        <androidproject1:property name="aapt" value="platforms.${platform.active}.aapt"/>
54
+        <androidproject1:property name="adb" value="platforms.${platform.active}.adb"/>
55
+        <androidproject1:property name="dx" value="platforms.${platform.active}.dx"/>
56
+        <androidproject1:property name="emulator" value="platforms.${platform.active}.emulator"/>
57
+        <androidproject1:property name="apkbuilder" value="platforms.${platform.active}.apkbuilder"/>
58
+        <condition property="bootclasspath1.available">
59
+            <and>
60
+                <isset property="platforms.${platform.active}.bootclasspath1"/>
61
+                <not>
62
+                    <equals arg1="${platform.bootcp1}" arg2="" trim="true"/>
63
+                </not>
64
+            </and>
65
+        </condition>
66
+        <condition property="no.bootclasspath1.available">
67
+            <not>
68
+                <isset property="bootclasspath1.available"/>
69
+            </not>
70
+        </condition>
71
+        <condition property="assets.available">
72
+            <and>
73
+                <isset property="${assets.dir}"/>
74
+                <not>
75
+                    <equals arg1="${assets.dir}" arg2="" trim="true"/>
76
+                </not>
77
+                <available file="${assets.dir}" property="assets.available"/>
78
+            </and>
79
+        </condition>
80
+        <available file="${manifest.file}" property="manifest.available"/>
81
+        <condition property="have.tests">
82
+            <or>
83
+                <available file="${test.src.dir}"/>
84
+            </or>
85
+        </condition>
86
+        <condition property="have.sources">
87
+            <or>
88
+                <available file="${src.dir}"/>
89
+            </or>
90
+        </condition>
91
+        <condition property="netbeans.home+have.tests">
92
+            <and>
93
+                <isset property="netbeans.home"/>
94
+                <isset property="have.tests"/>
95
+            </and>
96
+        </condition>
97
+        <condition property="no.javadoc.preview">
98
+            <and>
99
+                <isset property="javadoc.preview"/>
100
+                <isfalse value="${javadoc.preview}"/>
101
+            </and>
102
+        </condition>
103
+        <property name="run.jvmargs" value=""/>
104
+        <property name="javac.compilerargs" value=""/>
105
+        <property name="work.dir" value="${basedir}"/>
106
+        <condition property="no.deps">
107
+            <and>
108
+                <istrue value="${no.dependencies}"/>
109
+            </and>
110
+        </condition>
111
+        <property name="javac.debug" value="true"/>
112
+        <property name="javadoc.preview" value="true"/>
113
+        <property name="application.args" value=""/>
114
+        <property name="source.encoding" value="${file.encoding}"/>
115
+        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
116
+            <and>
117
+                <isset property="javadoc.encoding"/>
118
+                <not>
119
+                    <equals arg1="${javadoc.encoding}" arg2=""/>
120
+                </not>
121
+            </and>
122
+        </condition>
123
+        <property name="javadoc.encoding.used" value="${source.encoding}"/>
124
+        <property name="includes" value="**"/>
125
+        <property name="excludes" value=""/>
126
+        <property name="do.depend" value="false"/>
127
+        <condition property="do.depend.true">
128
+            <istrue value="${do.depend}"/>
129
+        </condition>
130
+        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
131
+            <and>
132
+                <isset property="jaxws.endorsed.dir"/>
133
+                <available file="nbproject/jaxws-build.xml"/>
134
+            </and>
135
+        </condition>
136
+        <property name="screen.skin" value="HVGA"/>
137
+        <property name="emulator.options" value=""/>
138
+        <property name="android.target.device" value=""/>
139
+        <condition property="do.start.app.false">
140
+            <and>
141
+                <isset property="do.start.app"/>
142
+                <isfalse value="${do.start.app}"/>
143
+            </and>
144
+        </condition>
145
+    </target>
146
+    <target name="-post-init">
147
+        <!-- Empty placeholder for easier customization. -->
148
+        <!-- You can override this target in the ../build.xml file. -->
149
+    </target>
150
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
151
+        <fail unless="src.dir">Must set src.dir</fail>
152
+        <fail unless="test.src.dir">Must set test.src.dir</fail>
153
+        <fail unless="build.dir">Must set build.dir</fail>
154
+        <fail unless="dist.dir">Must set dist.dir</fail>
155
+        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
156
+        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
157
+        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
158
+        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
159
+        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
160
+        <fail unless="dist.apk">Must set dist.apk</fail>
161
+    </target>
162
+    <target name="-init-macrodef-property">
163
+        <macrodef name="property" uri="http://www.netbeans.org/ns/android-project/1">
164
+            <attribute name="name"/>
165
+            <attribute name="value"/>
166
+            <sequential>
167
+                <property name="@{name}" value="${@{value}}"/>
168
+            </sequential>
169
+        </macrodef>
170
+    </target>
171
+    <target name="-init-macrodef-javac">
172
+        <macrodef name="javac" uri="http://www.netbeans.org/ns/android-project/1">
173
+            <attribute default="${src.dir}" name="srcdir"/>
174
+            <attribute default="${build.classes.dir}" name="destdir"/>
175
+            <attribute default="${javac.classpath}" name="classpath"/>
176
+            <attribute default="${includes}" name="includes"/>
177
+            <attribute default="${excludes}" name="excludes"/>
178
+            <attribute default="${javac.debug}" name="debug"/>
179
+            <attribute default="" name="sourcepath"/>
180
+            <element name="customize" optional="true"/>
181
+            <sequential>
182
+                <javac bootclasspath="${platform.bootcp}" debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
183
+                    <classpath>
184
+                        <path path="@{classpath}"/>
185
+                    </classpath>
186
+                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
187
+                    <customize/>
188
+                </javac>
189
+            </sequential>
190
+        </macrodef>
191
+        <macrodef name="depend" uri="http://www.netbeans.org/ns/android-project/1">
192
+            <attribute default="${src.dir}" name="srcdir"/>
193
+            <attribute default="${build.classes.dir}" name="destdir"/>
194
+            <attribute default="${javac.classpath}" name="classpath"/>
195
+            <sequential>
196
+                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
197
+                    <classpath>
198
+                        <path path="@{classpath}"/>
199
+                    </classpath>
200
+                </depend>
201
+            </sequential>
202
+        </macrodef>
203
+        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/android-project/1">
204
+            <attribute default="${build.classes.dir}" name="destdir"/>
205
+            <sequential>
206
+                <fail unless="javac.includes">Must set javac.includes</fail>
207
+                <pathconvert pathsep="," property="javac.includes.binary">
208
+                    <path>
209
+                        <filelist dir="@{destdir}" files="${javac.includes}"/>
210
+                    </path>
211
+                    <globmapper from="*.java" to="*.class"/>
212
+                </pathconvert>
213
+                <delete>
214
+                    <files includes="${javac.includes.binary}"/>
215
+                </delete>
216
+            </sequential>
217
+        </macrodef>
218
+    </target>
219
+    <target name="-init-macrodef-junit">
220
+        <macrodef name="junit" uri="http://www.netbeans.org/ns/android-project/1">
221
+            <attribute default="${includes}" name="includes"/>
222
+            <attribute default="${excludes}" name="excludes"/>
223
+            <attribute default="**" name="testincludes"/>
224
+            <sequential>
225
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
226
+                    <batchtest todir="${build.test.results.dir}">
227
+                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
228
+                            <filename name="@{testincludes}"/>
229
+                        </fileset>
230
+                    </batchtest>
231
+                    <classpath>
232
+                        <path path="${run.test.classpath}"/>
233
+                    </classpath>
234
+                    <syspropertyset>
235
+                        <propertyref prefix="test-sys-prop."/>
236
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
237
+                    </syspropertyset>
238
+                    <formatter type="brief" usefile="false"/>
239
+                    <formatter type="xml"/>
240
+                    <jvmarg line="${run.jvmargs}"/>
241
+                </junit>
242
+            </sequential>
243
+        </macrodef>
244
+    </target>
245
+    <target name="-init-macrodef-nbjpda">
246
+        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/android-project/1">
247
+            <attribute default="${main.activity}" name="name"/>
248
+            <attribute default="${debug.classpath}" name="classpath"/>
249
+            <attribute default="" name="stopclassname"/>
250
+            <sequential>
251
+                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="dt_socket">
252
+                    <classpath>
253
+                        <path path="@{classpath}"/>
254
+                    </classpath>
255
+                    <bootclasspath>
256
+                        <path path="${platform.bootcp}"/>
257
+                    </bootclasspath>
258
+                </nbjpdastart>
259
+            </sequential>
260
+        </macrodef>
261
+        <macrodef name="nbjpdaconnect" uri="http://www.netbeans.org/ns/android-project/1">
262
+            <attribute default="${main.activity}" name="name"/>
263
+            <attribute default="${debug.classpath}" name="classpath"/>
264
+            <sequential>
265
+                <nbjpdaconnect address="${local.debug.port}" name="@{name}" transport="dt_socket">
266
+                    <classpath>
267
+                        <path path="@{classpath}"/>
268
+                    </classpath>
269
+                    <bootclasspath>
270
+                        <path path="${platform.bootcp}"/>
271
+                    </bootclasspath>
272
+                </nbjpdaconnect>
273
+            </sequential>
274
+        </macrodef>
275
+        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/android-project/1">
276
+            <attribute default="${build.classes.dir}" name="dir"/>
277
+            <sequential>
278
+                <nbjpdareload>
279
+                    <fileset dir="@{dir}" includes="${fix.includes}*.class"/>
280
+                </nbjpdareload>
281
+            </sequential>
282
+        </macrodef>
283
+    </target>
284
+    <target name="-init-debug-args">
285
+        <property name="version-output" value="java version &quot;${ant.java.version}"/>
286
+        <condition property="have-jdk-older-than-1.4">
287
+            <or>
288
+                <contains string="${version-output}" substring="java version &quot;1.0"/>
289
+                <contains string="${version-output}" substring="java version &quot;1.1"/>
290
+                <contains string="${version-output}" substring="java version &quot;1.2"/>
291
+                <contains string="${version-output}" substring="java version &quot;1.3"/>
292
+            </or>
293
+        </condition>
294
+        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
295
+            <istrue value="${have-jdk-older-than-1.4}"/>
296
+        </condition>
297
+    </target>
298
+    <target depends="-init-debug-args" name="-init-macrodef-debug">
299
+        <macrodef name="debug" uri="http://www.netbeans.org/ns/android-project/1">
300
+            <attribute default="${main.activity}" name="classname"/>
301
+            <attribute default="${debug.classpath}" name="classpath"/>
302
+            <element name="customize" optional="true"/>
303
+            <sequential>
304
+                <java classname="@{classname}" dir="${work.dir}" fork="true">
305
+                    <jvmarg line="${debug-args-line}"/>
306
+                    <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
307
+                    <jvmarg line="${run.jvmargs}"/>
308
+                    <classpath>
309
+                        <path path="@{classpath}"/>
310
+                    </classpath>
311
+                    <syspropertyset>
312
+                        <propertyref prefix="run-sys-prop."/>
313
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
314
+                    </syspropertyset>
315
+                    <customize/>
316
+                </java>
317
+            </sequential>
318
+        </macrodef>
319
+    </target>
320
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug" name="init"/>
321
+    <!--
322
+                ===================
323
+                COMPILATION SECTION
324
+                ===================
325
+            -->
326
+    <target depends="init" name="deps-jar" unless="no.deps"/>
327
+    <target depends="init,deps-jar" name="-pre-pre-compile">
328
+        <mkdir dir="${build.classes.dir}"/>
329
+    </target>
330
+    <target name="-pre-compile">
331
+        <!-- Empty placeholder for easier customization. -->
332
+        <!-- You can override this target in the ../build.xml file. -->
333
+    </target>
334
+    <target if="do.depend.true" name="-compile-depend">
335
+        <androidproject1:depend/>
336
+    </target>
337
+    <target depends="init,-pre-pre-compile,-pre-compile" name="-res-compile" unless="bootclasspath1.available">
338
+        <exec executable="${aapt}" failonerror="true">
339
+            <arg value="package"/>
340
+            <arg value="-m"/>
341
+            <arg value="-J"/>
342
+            <arg value="${src.dir}"/>
343
+            <arg value="-M"/>
344
+            <arg value="AndroidManifest.xml"/>
345
+            <arg value="-S"/>
346
+            <arg value="${resource.dir}"/>
347
+            <arg value="-I"/>
348
+            <arg value="${platform.bootcp}"/>
349
+        </exec>
350
+    </target>
351
+    <target depends="init,-pre-pre-compile,-pre-compile" if="bootclasspath1.available" name="-res-compile1">
352
+        <exec executable="${aapt}" failonerror="true">
353
+            <arg value="package"/>
354
+            <arg value="-m"/>
355
+            <arg value="-J"/>
356
+            <arg value="${src.dir}"/>
357
+            <arg value="-M"/>
358
+            <arg value="AndroidManifest.xml"/>
359
+            <arg value="-S"/>
360
+            <arg value="${resource.dir}"/>
361
+            <arg value="-I"/>
362
+            <arg value="${platform.bootcp0}"/>
363
+            <arg value="-I"/>
364
+            <arg value="${platform.bootcp1}"/>
365
+        </exec>
366
+    </target>
367
+    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile" name="-idl-compile"/>
368
+    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
369
+        <androidproject1:javac/>
370
+        <copy todir="${build.classes.dir}">
371
+            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
372
+        </copy>
373
+    </target>
374
+    <target name="-post-compile">
375
+        <!-- Empty placeholder for easier customization. -->
376
+        <!-- You can override this target in the ../build.xml file. -->
377
+    </target>
378
+    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-res-compile,-res-compile1,-idl-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
379
+    <target name="-pre-compile-single">
380
+        <!-- Empty placeholder for easier customization. -->
381
+        <!-- You can override this target in the ../build.xml file. -->
382
+    </target>
383
+    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
384
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
385
+        <androidproject1:force-recompile/>
386
+        <androidproject1:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
387
+    </target>
388
+    <target name="-post-compile-single">
389
+        <!-- Empty placeholder for easier customization. -->
390
+        <!-- You can override this target in the ../build.xml file. -->
391
+    </target>
392
+    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
393
+    <!--
394
+                ====================
395
+                JAR BUILDING SECTION
396
+                ====================
397
+            -->
398
+    <target depends="init" name="-pre-pre-jar">
399
+        <dirname file="${dist.apk}" property="dist.apk.dir"/>
400
+        <mkdir dir="${dist.apk.dir}"/>
401
+    </target>
402
+    <target name="-pre-jar">
403
+        <!-- Empty placeholder for easier customization. -->
404
+        <!-- You can override this target in the ../build.xml file. -->
405
+    </target>
406
+    <target name="-post-jar">
407
+        <!-- Empty placeholder for easier customization. -->
408
+        <!-- You can override this target in the ../build.xml file. -->
409
+    </target>
410
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-dex">
411
+        <exec executable="${dx}" failonerror="true">
412
+            <arg value="--dex"/>
413
+            <arg value="--output=${basedir}/${intermediate.dex}"/>
414
+            <arg value="--positions=lines"/>
415
+            <arg path="${build.classes.dir}"/>
416
+        </exec>
417
+    </target>
418
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="assets.available" name="-package-res-and-assets" unless="bootclasspath1.available">
419
+        <exec executable="${aapt}" failonerror="true">
420
+            <arg value="package"/>
421
+            <arg value="-f"/>
422
+            <arg value="-M"/>
423
+            <arg value="AndroidManifest.xml"/>
424
+            <arg value="-S"/>
425
+            <arg value="${resource.dir}"/>
426
+            <arg value="-A"/>
427
+            <arg value="${asset.dir}"/>
428
+            <arg value="-I"/>
429
+            <arg value="${platform.bootcp}"/>
430
+            <arg value="-F"/>
431
+            <arg value="${dist.apk}_"/>
432
+        </exec>
433
+    </target>
434
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="assets.available" name="-package-res-and-assets1" unless="no.bootclasspath1.available">
435
+        <exec executable="${aapt}" failonerror="true">
436
+            <arg value="package"/>
437
+            <arg value="-f"/>
438
+            <arg value="-M"/>
439
+            <arg value="AndroidManifest.xml"/>
440
+            <arg value="-S"/>
441
+            <arg value="${resource.dir}"/>
442
+            <arg value="-A"/>
443
+            <arg value="${asset.dir}"/>
444
+            <arg value="-I"/>
445
+            <arg value="${platform.bootcp0}"/>
446
+            <arg value="-I"/>
447
+            <arg value="${platform.bootcp1}"/>
448
+            <arg value="-F"/>
449
+            <arg value="${dist.apk}_"/>
450
+        </exec>
451
+    </target>
452
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="no.bootclasspath1.available" name="-package-res-no-assets" unless="assets.available">
453
+        <exec executable="${aapt}" failonerror="true">
454
+            <arg value="package"/>
455
+            <arg value="-f"/>
456
+            <arg value="-M"/>
457
+            <arg value="AndroidManifest.xml"/>
458
+            <arg value="-S"/>
459
+            <arg value="${resource.dir}"/>
460
+            <arg value="-I"/>
461
+            <arg value="${platform.bootcp}"/>
462
+            <arg value="-F"/>
463
+            <arg value="${dist.apk}_"/>
464
+        </exec>
465
+    </target>
466
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="bootclasspath1.available" name="-package-res-no-assets1" unless="assets.available">
467
+        <exec executable="${aapt}" failonerror="true">
468
+            <arg value="package"/>
469
+            <arg value="-f"/>
470
+            <arg value="-M"/>
471
+            <arg value="AndroidManifest.xml"/>
472
+            <arg value="-S"/>
473
+            <arg value="${resource.dir}"/>
474
+            <arg value="-I"/>
475
+            <arg value="${platform.bootcp0}"/>
476
+            <arg value="-I"/>
477
+            <arg value="${platform.bootcp1}"/>
478
+            <arg value="-F"/>
479
+            <arg value="${dist.apk}_"/>
480
+        </exec>
481
+    </target>
482
+    <target depends="init,compile,-pre-pre-jar,-pre-jar,-dex,-package-res-and-assets,-package-res-no-assets,-package-res-and-assets1,-package-res-no-assets1" name="-package-dex">
483
+        <dirname file="${intermediate.dex}" property="package-dex.dex.folder"/>
484
+        <basename file="${intermediate.dex}" property="package-dex.dex.file"/>
485
+        <zip destfile="${dist.apk}_" update="true">
486
+            <fileset dir="${package-dex.dex.folder}" includes="${package-dex.dex.file}"/>
487
+        </zip>
488
+    </target>
489
+    <target depends="init,-package-res-and-assets,-package-res-no-assets,-package-dex" name="-sign">
490
+        <exec executable="${apkbuilder}" failonerror="true">
491
+            <arg value="${basedir}/${dist.apk}"/>
492
+            <arg value="-z"/>
493
+            <arg value="${basedir}/${dist.apk}_"/>
494
+        </exec>
495
+        <delete file="${dist.apk}_"/>
496
+    </target>
497
+    <target depends="init,compile,-pre-jar,-dex,-package-res-and-assets,-package-res-no-assets,-package-dex,-sign,-post-jar" description="Build JAR." name="jar"/>
498
+    <!--
499
+                =================
500
+                EXECUTION SECTION
501
+                =================
502
+            -->
503
+    <target depends="init,compile,jar,-start-emulator,-wait-for-emulator,-install-app,-run-app" description="Run a main activity." name="run"/>
504
+    <target depends="init,compile,jar,-start-emulator,-wait-for-emulator,-install-app" name="-run-app" unless="do.start.app.false">
505
+        <taskdef classname="org.netbeans.modules.android.ant.AndroidManifestParse" classpath="${libs.AndroidAntTasks.classpath}" name="android-manifest-parse"/>
506
+        <android-manifest-parse mainActivityProperty="main.activity" manifestFile="AndroidManifest.xml"/>
507
+        <echo message="About to start ${main.component}/${main.activity}"/>
508
+        <exec executable="${adb}">
509
+            <arg line="${android.target.device}"/>
510
+            <arg value="shell"/>
511
+            <arg value="am start -n ${main.component}/${main.activity}"/>
512
+        </exec>
513
+    </target>
514
+    <target depends="init,compile,jar" name="-emulator-running">
515
+        <exec executable="${adb}" outputproperty="emulator-running.out" resultproperty="is.emulator.running.tmp">
516
+            <arg line="${android.target.device}"/>
517
+            <arg value="shell"/>
518
+            <arg value="date"/>
519
+        </exec>
520
+        <condition property="is.emulator.running">
521
+            <not>
522
+                <isfailure code="${is.emulator.running.tmp}"/>
523
+            </not>
524
+        </condition>
525
+    </target>
526
+    <target depends="init,compile,jar,-emulator-running" name="-start-emulator" unless="is.emulator.running">
527
+        <exec executable="${adb}">
528
+            <arg value="kill-server"/>
529
+        </exec>
530
+        <fail unless="android.target.avd">Must set android.target.avd</fail>
531
+        <exec executable="${emulator}" spawn="true">
532
+            <arg value="-skin"/>
533
+            <arg value="${screen.skin}"/>
534
+            <arg value="-avd"/>
535
+            <arg value="${android.target.avd}"/>
536
+            <arg line="${emulator.options}"/>
537
+        </exec>
538
+    </target>
539
+    <target depends="init,compile,jar,-start-emulator" name="-wait-for-emulator">
540
+        <taskdef classname="org.netbeans.modules.android.ant.AdbPackageManagerWait" classpath="${libs.AndroidAntTasks.classpath}" name="adb-pm-wait"/>
541
+        <adb-pm-wait adb="${adb}" deviceArgs="${android.target.device}"/>
542
+    </target>
543
+    <target depends="init,compile,jar,-start-emulator,-wait-for-emulator" name="-install-app">
544
+        <exec executable="${adb}">
545
+            <arg line="${android.target.device}"/>
546
+            <arg value="install"/>
547
+            <arg value="-r"/>
548
+            <arg value="${dist.apk}"/>
549
+        </exec>
550
+    </target>
551
+    <target name="-do-not-recompile">
552
+        <property name="javac.includes.binary" value=""/>
553
+    </target>
554
+    <!--
555
+                =================
556
+                DEBUGGING SECTION
557
+                =================
558
+            -->
559
+    <target depends="init,-debug-start-debuggee" if="netbeans.home" name="-debug-start-debugger">
560
+        <androidproject1:nbjpdaconnect/>
561
+    </target>
562
+    <target depends="init,compile,-start-emulator,-wait-for-emulator,-install-app" name="-debug-start-debuggee">
563
+        <taskdef classname="org.netbeans.modules.android.ant.AndroidManifestParse" classpath="${libs.AndroidAntTasks.classpath}" name="android-manifest-parse"/>
564
+        <android-manifest-parse mainActivityProperty="main.activity" manifestFile="AndroidManifest.xml"/>
565
+        <echo message="About to start ${main.component}/${main.activity}"/>
566
+        <exec executable="${adb}">
567
+            <arg line="${android.target.device}"/>
568
+            <arg value="shell"/>
569
+            <arg value="am start -D -n ${main.component}/${main.activity}"/>
570
+        </exec>
571
+        <getdebuggerport addressProperty="local.debug.port" app="${main.component}"/>
572
+    </target>
573
+    <target depends="init,compile,-debug-start-debuggee,-debug-start-debugger" description="Debug project in IDE." if="netbeans.home" name="debug"/>
574
+    <!--
575
+                ===============
576
+                JAVADOC SECTION
577
+                ===============
578
+            -->
579
+    <target depends="init" name="-javadoc-build">
580
+        <mkdir dir="${dist.javadoc.dir}"/>
581
+        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
582
+            <classpath>
583
+                <path path="${javac.classpath}"/>
584
+            </classpath>
585
+            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
586
+                <filename name="**/*.java"/>
587
+            </fileset>
588
+        </javadoc>
589
+    </target>
590
+    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
591
+        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
592
+    </target>
593
+    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
594
+    <!--
595
+                =========================
596
+                JUNIT COMPILATION SECTION
597
+                =========================
598
+            -->
599
+    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
600
+        <mkdir dir="${build.test.classes.dir}"/>
601
+    </target>
602
+    <target name="-pre-compile-test">
603
+        <!-- Empty placeholder for easier customization. -->
604
+        <!-- You can override this target in the ../build.xml file. -->
605
+    </target>
606
+    <target if="do.depend.true" name="-compile-test-depend">
607
+        <androidproject1:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
608
+    </target>
609
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
610
+        <androidproject1:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
611
+        <copy todir="${build.test.classes.dir}">
612
+            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
613
+        </copy>
614
+    </target>
615
+    <target name="-post-compile-test">
616
+        <!-- Empty placeholder for easier customization. -->
617
+        <!-- You can override this target in the ../build.xml file. -->
618
+    </target>
619
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
620
+    <target name="-pre-compile-test-single">
621
+        <!-- Empty placeholder for easier customization. -->
622
+        <!-- You can override this target in the ../build.xml file. -->
623
+    </target>
624
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
625
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
626
+        <androidproject1:force-recompile destdir="${build.test.classes.dir}"/>
627
+        <androidproject1:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
628
+        <copy todir="${build.test.classes.dir}">
629
+            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
630
+        </copy>
631
+    </target>
632
+    <target name="-post-compile-test-single">
633
+        <!-- Empty placeholder for easier customization. -->
634
+        <!-- You can override this target in the ../build.xml file. -->
635
+    </target>
636
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
637
+    <!--
638
+                =======================
639
+                JUNIT EXECUTION SECTION
640
+                =======================
641
+            -->
642
+    <target depends="init" if="have.tests" name="-pre-test-run">
643
+        <mkdir dir="${build.test.results.dir}"/>
644
+    </target>
645
+    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
646
+        <androidproject1:junit testincludes="**/*Test.java"/>
647
+    </target>
648
+    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
649
+        <fail if="tests.failed">Some tests failed; see details above.</fail>
650
+    </target>
651
+    <target depends="init" if="have.tests" name="test-report"/>
652
+    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
653
+    <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
654
+    <target depends="init" if="have.tests" name="-pre-test-run-single">
655
+        <mkdir dir="${build.test.results.dir}"/>
656
+    </target>
657
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
658
+        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
659
+        <androidproject1:junit excludes="" includes="${test.includes}"/>
660
+    </target>
661
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
662
+        <fail if="tests.failed">Some tests failed; see details above.</fail>
663
+    </target>
664
+    <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
665
+    <!--
666
+                =======================
667
+                JUNIT DEBUGGING SECTION
668
+                =======================
669
+            -->
670
+    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
671
+        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
672
+        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
673
+        <delete file="${test.report.file}"/>
674
+        <mkdir dir="${build.test.results.dir}"/>
675
+        <androidproject1:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
676
+            <customize>
677
+                <syspropertyset>
678
+                    <propertyref prefix="test-sys-prop."/>
679
+                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
680
+                </syspropertyset>
681
+                <arg value="${test.class}"/>
682
+                <arg value="showoutput=true"/>
683
+                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
684
+                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
685
+            </customize>
686
+        </androidproject1:debug>
687
+    </target>
688
+    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
689
+        <androidproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
690
+    </target>
691
+    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
692
+    <!--
693
+                ===============
694
+                CLEANUP SECTION
695
+                ===============
696
+            -->
697
+    <target depends="init" name="deps-clean" unless="no.deps"/>
698
+    <target depends="init" name="-do-clean">
699
+        <delete dir="${build.dir}"/>
700
+        <delete dir="${dist.dir}"/>
701
+    </target>
702
+    <target name="-post-clean">
703
+        <!-- Empty placeholder for easier customization. -->
704
+        <!-- You can override this target in the ../build.xml file. -->
705
+    </target>
706
+    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
707
+</project>

+ 8
- 0
code/ContextAnalyser/nbproject/genfiles.properties Целия файл

@@ -0,0 +1,8 @@
1
+build.xml.data.CRC32=d76a746a
2
+build.xml.script.CRC32=84cee8d0
3
+build.xml.stylesheet.CRC32=0cfbaa1e@0.10
4
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6
+nbproject/build-impl.xml.data.CRC32=d76a746a
7
+nbproject/build-impl.xml.script.CRC32=586b8f0b
8
+nbproject/build-impl.xml.stylesheet.CRC32=fed06522@0.10

+ 59
- 0
code/ContextAnalyser/nbproject/project.properties Целия файл

@@ -0,0 +1,59 @@
1
+assets.dir=
2
+build.classes.dir=${build.dir}/classes
3
+build.classes.excludes=**/*.java
4
+# This directory is removed when the project is cleaned:
5
+build.dir=build
6
+build.generated.dir=${build.dir}/generated
7
+# Only compile against the classpath explicitly listed here:
8
+build.sysclasspath=ignore
9
+build.test.classes.dir=${build.dir}/test/classes
10
+build.test.results.dir=${build.dir}/test/results
11
+debug.classpath=\
12
+    ${run.classpath}
13
+debug.test.classpath=\
14
+    ${run.test.classpath}
15
+dist.apk=${dist.dir}/ContextAnalyser.apk
16
+# This directory is removed when the project is cleaned:
17
+dist.dir=dist
18
+dist.javadoc.dir=${dist.dir}/javadoc
19
+excludes=
20
+gen.source.dir=${src.dir}
21
+includes=**
22
+intermediate.dex=${build.dir}/classes.dex
23
+javac.classpath=
24
+# Space-separated list of extra javac options
25
+javac.compilerargs=
26
+javac.deprecation=false
27
+javac.source=1.5
28
+javac.target=1.5
29
+javac.test.classpath=\
30
+    ${javac.classpath}:\
31
+    ${build.classes.dir}:\
32
+    ${libs.junit.classpath}:\
33
+    ${libs.junit_4.classpath}
34
+javadoc.additionalparam=
35
+javadoc.author=false
36
+javadoc.encoding=${source.encoding}
37
+javadoc.noindex=false
38
+javadoc.nonavbar=false
39
+javadoc.notree=false
40
+javadoc.private=false
41
+javadoc.splitindex=true
42
+javadoc.use=true
43
+javadoc.version=false
44
+javadoc.windowtitle=
45
+main.component=uk.co.md87.android.contextanalyser
46
+manifest.file=manifest.mf
47
+meta.inf.dir=${src.dir}/META-INF
48
+platform.active=Android
49
+resource.dir=res
50
+run.classpath=\
51
+    ${javac.classpath}:\
52
+    ${build.classes.dir}
53
+run.jvmargs=
54
+run.test.classpath=\
55
+    ${javac.test.classpath}:\
56
+    ${build.test.classes.dir}
57
+source.encoding=UTF-8
58
+src.dir=src
59
+test.src.dir=test

+ 16
- 0
code/ContextAnalyser/nbproject/project.xml Целия файл

@@ -0,0 +1,16 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://www.netbeans.org/ns/project/1">
3
+    <type>org.netbeans.modules.android.project</type>
4
+    <configuration>
5
+        <data xmlns="http://www.netbeans.org/ns/android-project/1">
6
+            <name>ContextAnalyser</name>
7
+            <minimum-ant-version>1.7.0</minimum-ant-version>
8
+            <source-roots>
9
+                <root id="src.dir"/>
10
+            </source-roots>
11
+            <test-roots>
12
+                <root id="test.src.dir"/>
13
+            </test-roots>
14
+        </data>
15
+    </configuration>
16
+</project>

Двоични данни
code/ContextAnalyser/res/drawable/icon.png Целия файл


+ 10
- 0
code/ContextAnalyser/res/layout/main.xml Целия файл

@@ -0,0 +1,10 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:orientation="vertical"
4
+    android:layout_width="fill_parent"
5
+    android:layout_height="fill_parent">" 
6
+    <TextView
7
+        android:layout_width="fill_parent"
8
+        android:layout_height="wrap_content"
9
+        android:text="Hello Android from NetBeans"/>
10
+</LinearLayout>

+ 4
- 0
code/ContextAnalyser/res/values/strings.xml Целия файл

@@ -0,0 +1,4 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<resources>
3
+    <string name="app_name">ContextAnalyser</string>
4
+</resources>

+ 1
- 0
code/ContextAnalyser/src/uk/co/md87/android/common/Common Целия файл

@@ -0,0 +1 @@
1
+../../../../../../Common/

code/SensorLogger/src/uk/co/md87/android/common/ExceptionHandler.java → code/ContextAnalyser/src/uk/co/md87/android/common/ExceptionHandler.java Целия файл


+ 24
- 0
code/ContextAnalyser/src/uk/co/md87/android/contextanalyser/IntroActivity.java Целия файл

@@ -0,0 +1,24 @@
1
+/*
2
+ * To change this template, choose Tools | Templates
3
+ * and open the template in the editor.
4
+ */
5
+
6
+package uk.co.md87.android.contextanalyser;
7
+
8
+import android.app.Activity;
9
+import android.os.Bundle;
10
+
11
+/**
12
+ *
13
+ * @author chris
14
+ */
15
+public class IntroActivity extends Activity {
16
+
17
+    /** Called when the activity is first created. */
18
+    @Override
19
+    public void onCreate(Bundle icicle) {
20
+        super.onCreate(icicle);
21
+        // ToDo add your GUI initialization code here        
22
+    }
23
+
24
+}

+ 22
- 0
code/ContextAnalyser/src/uk/co/md87/android/contextanalyser/R.java Целия файл

@@ -0,0 +1,22 @@
1
+/* AUTO-GENERATED FILE.  DO NOT MODIFY.
2
+ *
3
+ * This class was automatically generated by the
4
+ * aapt tool from the resource data it found.  It
5
+ * should not be modified by hand.
6
+ */
7
+
8
+package uk.co.md87.android.contextanalyser;
9
+
10
+public final class R {
11
+    public static final class attr {
12
+    }
13
+    public static final class drawable {
14
+        public static final int icon=0x7f020000;
15
+    }
16
+    public static final class layout {
17
+        public static final int main=0x7f030000;
18
+    }
19
+    public static final class string {
20
+        public static final int app_name=0x7f040000;
21
+    }
22
+}

+ 1
- 0
code/SensorLogger/src/uk/co/md87/android/common Целия файл

@@ -0,0 +1 @@
1
+../../../../../../Common/

+ 3
- 40
code/SensorLogger/src/uk/co/md87/android/sensorlogger/ClassifierService.java Целия файл

@@ -10,7 +10,7 @@ import android.os.IBinder;
10 10
 import android.os.RemoteException;
11 11
 import android.util.Log;
12 12
 
13
-import java.util.Map;
13
+import uk.co.md87.android.common.Classifier;
14 14
 
15 15
 /**
16 16
  *
@@ -40,46 +40,9 @@ public class ClassifierService extends BoundService implements Runnable {
40 40
     }
41 41
 
42 42
     public void run() {
43
-        float oddTotal = 0, evenTotal = 0;
44
-        float oddMin = Float.MAX_VALUE, oddMax = Float.MIN_VALUE;
45
-        float evenMin = Float.MAX_VALUE, evenMax = Float.MIN_VALUE;
46
-
47
-        for (int i = 0; i < 128; i++) {
48
-            evenTotal += data[i * 2];
49
-            oddTotal += data[i * 2 + 1];
50
-
51
-            evenMin = Math.min(evenMin, data[i * 2]);
52
-            oddMin = Math.min(oddMin, data[i * 2 + 1]);
53
-
54
-            evenMax = Math.max(evenMax, data[i * 2]);
55
-            oddMax = Math.max(oddMax, data[i * 2 + 1]);
56
-        }
57
-
58
-        final float[] points = {
59
-            Math.abs(evenTotal / 128),
60
-            Math.abs(oddTotal / 128),
61
-            evenMax - evenMin,
62
-            oddMax - oddMin
63
-        };
64
-
65
-        float bestDistance = Float.MAX_VALUE;
66
-        String bestActivity = "UNCLASSIFIED/UNKNOWN";
67
-        
68
-        for (Map.Entry<Float[], String> entry : RecorderService.model.entrySet()) {
69
-            float distance = 0;
70
-
71
-            for (int i = 0; i < points.length; i++) {
72
-                distance += Math.pow(points[i] - entry.getKey()[i], 2);
73
-            }
74
-
75
-            if (distance < bestDistance) {
76
-                bestDistance = distance;
77
-                bestActivity = entry.getValue();
78
-            }
79
-        }
80
-
81 43
         try {
82
-            service.submitClassification(bestActivity);
44
+            service.submitClassification(
45
+                    new Classifier(RecorderService.model.entrySet()).classify(data));
83 46
         } catch (RemoteException ex) {
84 47
             Log.e(getClass().getName(), "Error submitting classification", ex);
85 48
         }

Loading…
Отказ
Запис