Procházet zdrojové kódy

Journeys now have a count

Add some extra test data
master
Chris Smith před 14 roky
rodič
revize
1fb7f7df77

+ 18
- 0
code/Common/aggregator/FakeAutoAggregator.java Zobrazit soubor

@@ -56,6 +56,24 @@ public class FakeAutoAggregator extends AutoAggregator {
56 56
         "CLASSIFIED/IDLE/STANDING",
57 57
         "CLASSIFIED/IDLE/STANDING",
58 58
         "CLASSIFIED/IDLE/STANDING",
59
+        "CLASSIFIED/IDLE/STANDING",
60
+        "CLASSIFIED/IDLE/STANDING",
61
+        "CLASSIFIED/IDLE/STANDING",
62
+        "CLASSIFIED/WALKING",
63
+        "CLASSIFIED/WALKING",
64
+        "CLASSIFIED/IDLE/STANDING",
65
+        "CLASSIFIED/IDLE/SITTING",
66
+        "CLASSIFIED/IDLE/STANDING",
67
+        "CLASSIFIED/WALKING",
68
+        "CLASSIFIED/VEHICLE/BUS",
69
+        "CLASSIFIED/VEHICLE/BUS",
70
+        "CLASSIFIED/VEHICLE/BUS",
71
+        "CLASSIFIED/VEHICLE/BUS",
72
+        "CLASSIFIED/VEHICLE/BUS",
73
+        "CLASSIFIED/VEHICLE/BUS",
74
+        "CLASSIFIED/IDLE/STANDING",
75
+        "CLASSIFIED/IDLE/STANDING",
76
+        "CLASSIFIED/IDLE/STANDING",
59 77
     };
60 78
 
61 79
     private int i = 0;

+ 23
- 0
code/Common/geo/FakeLocationMonitor.java Zobrazit soubor

@@ -53,6 +53,29 @@ public class FakeLocationMonitor implements LocationMonitor {
53 53
         {51.498725d, -0.17950d}, // Place 3
54 54
         {51.498725d, -0.17950d},
55 55
         {51.498725d, -0.17950d},
56
+
57
+        {51.481386d, -0.084667d}, // Place 1
58
+        {51.481386d, -0.084667d},
59
+        {51.481386d, -0.084667d},
60
+
61
+        {51.491386d, -0.082667d},
62
+        {51.501386d, -0.081667d},
63
+
64
+        {51.517676d, -0.07997d}, // Place 2
65
+        {51.517676d, -0.07997d},
66
+        {51.517676d, -0.07997d},
67
+
68
+        {51.514386d, -0.08300d},
69
+        {51.511386d, -0.08500d},
70
+        {51.511386d, -0.09000d},
71
+        {51.511386d, -0.10000d},
72
+        {51.511386d, -0.12000d},
73
+        {51.511386d, -0.14000d},
74
+        {51.511386d, -0.17000d},
75
+
76
+        {51.481386d, -0.084667d}, // Place 1
77
+        {51.481386d, -0.084667d},
78
+        {51.481386d, -0.084667d},
56 79
     };
57 80
 
58 81
     public float getAccuracy() {

binární
code/ContextAnalyser/dist/ContextAnalyser.apk Zobrazit soubor


+ 12
- 7
code/ContextAnalyser/src/uk/co/md87/android/contextanalyser/DataHelper.java Zobrazit soubor

@@ -53,16 +53,18 @@ public class DataHelper {
53 53
     public static final String JOURNEYSTEPS_TABLE = "journeysteps";
54 54
 
55 55
     private static final String DATABASE_NAME = "contextapi.db";
56
-    private static final int DATABASE_VERSION = 5;
56
+    private static final int DATABASE_VERSION = 6;
57 57
 
58 58
     private static final String INSERT_LOCATION = "insert into "
59 59
       + LOCATIONS_TABLE + "(name, lat, lon) values (?, ?, ?)";
60 60
     private static final String INSERT_JOURNEY = "insert into "
61
-      + JOURNEYS_TABLE + "(start, end, steps) values (?, ?, ?)";
61
+      + JOURNEYS_TABLE + "(start, end, steps, number) values (?, ?, ?, 1)";
62 62
     private static final String INSERT_JOURNEYSTEP = "insert into "
63 63
       + JOURNEYSTEPS_TABLE + "(activity, repetitions, journey, next) values (?, ?, ?, ?)";
64 64
     private static final String UPDATE_LOCATION = "update "
65 65
       + LOCATIONS_TABLE + " set name = ? where _id = ?";
66
+    private static final String UPDATE_JOURNEY = "update "
67
+      + JOURNEYS_TABLE + " set number = number + 1 WHERE _id = ?";
66 68
     private static final String UNNAMED_QUERY = "name LIKE '%.%,%.%'";
67 69
     private static final String LOCATION_QUERY = "lat > %1$s - 0.005 and "
68 70
             + "lat < %1$s + 0.005 and lon > %2$s - 0.01 and lon < %2$s + 0.01";
@@ -71,7 +73,8 @@ public class DataHelper {
71 73
     private static final String JOURNEY_BOTH_QUERY = JOURNEY_START_QUERY + " AND end = %1$s";
72 74
 
73 75
     private final SQLiteStatement insertLocationStatement, insertJourneyStatement,
74
-            insertJourneyStepStatement, updateLocationStatement;
76
+            insertJourneyStepStatement, updateLocationStatement,
77
+            updateJourneyStatement;
75 78
 
76 79
     private SQLiteDatabase db;
77 80
 
@@ -82,6 +85,7 @@ public class DataHelper {
82 85
         this.updateLocationStatement = db.compileStatement(UPDATE_LOCATION);
83 86
         this.insertJourneyStatement = db.compileStatement(INSERT_JOURNEY);
84 87
         this.insertJourneyStepStatement = db.compileStatement(INSERT_JOURNEYSTEP);
88
+        this.updateJourneyStatement = db.compileStatement(UPDATE_JOURNEY);
85 89
     }
86 90
 
87 91
     public SQLiteDatabase getDatabase() {
@@ -137,13 +141,13 @@ public class DataHelper {
137 141
         }
138 142
 
139 143
         final Cursor cursor = db.query(JOURNEYS_TABLE,
140
-                new String[] { "_id", "start", "end", "steps" },
144
+                new String[] { "_id", "start", "end", "steps", "number" },
141 145
                 query, null, null, null, null);
142 146
 
143 147
         if (cursor.moveToFirst()) {
144 148
             do {
145 149
                 results.add(new Journey(cursor.getLong(0), cursor.getLong(1),
146
-                        cursor.getLong(2), cursor.getInt(3)));
150
+                        cursor.getLong(2), cursor.getInt(3), cursor.getInt(4)));
147 151
             } while (cursor.moveToNext());
148 152
         }
149 153
 
@@ -161,7 +165,8 @@ public class DataHelper {
161 165
                 final List<JourneyStep> theirSteps = getSteps(journey);
162 166
 
163 167
                 if (theirSteps.equals(steps)) {
164
-                    // TODO: Increment journey count/time/etc
168
+                    updateJourneyStatement.bindLong(1, journey.getId());
169
+                    updateJourneyStatement.execute();
165 170
                     return;
166 171
                 }
167 172
             }
@@ -299,7 +304,7 @@ public class DataHelper {
299 304
             if (oldVersion <= 2) {
300 305
                 db.execSQL("DROP TABLE " + LOCATIONS_TABLE);
301 306
                 onCreate(db);
302
-            } else if (oldVersion <= 5) {
307
+            } else if (oldVersion <= 6) {
303 308
                 db.execSQL("DROP TABLE " + LOCATIONS_TABLE);
304 309
                 db.execSQL("DROP TABLE " + JOURNEYS_TABLE);
305 310
                 db.execSQL("DROP TABLE " + JOURNEYSTEPS_TABLE);

+ 7
- 1
code/ContextAnalyser/src/uk/co/md87/android/contextanalyser/model/Journey.java Zobrazit soubor

@@ -34,13 +34,15 @@ public class Journey {
34 34
     private final long start;
35 35
     private final long end;
36 36
     private final int steps;
37
+    private final int number;
37 38
 
38 39
     public Journey(final long id, final long start, final long end,
39
-            final int steps) {
40
+            final int steps, final int number) {
40 41
         this.id = id;
41 42
         this.start = start;
42 43
         this.end = end;
43 44
         this.steps = steps;
45
+        this.number = number;
44 46
     }
45 47
 
46 48
     public long getEnd() {
@@ -59,4 +61,8 @@ public class Journey {
59 61
         return steps;
60 62
     }
61 63
 
64
+    public int getNumber() {
65
+        return number;
66
+    }
67
+
62 68
 }

+ 4
- 1
res/icon.svg Zobrazit soubor

@@ -15,7 +15,10 @@
15 15
    id="svg3608"
16 16
    version="1.1"
17 17
    inkscape:version="0.47 r22583"
18
-   sodipodi:docname="New document 4">
18
+   sodipodi:docname="icon.svg"
19
+   inkscape:export-filename="/home/chris/Projects/Java/ContextApi/code/ContextAnalyser/res/drawable/icon.png"
20
+   inkscape:export-xdpi="90"
21
+   inkscape:export-ydpi="90">
19 22
   <defs
20 23
      id="defs3610">
21 24
     <inkscape:perspective

Načítá se…
Zrušit
Uložit