Browse Source

Client now exposes portal URL

Closes #18
tags/SensorLogger/0.1.3
Chris Smith 14 years ago
parent
commit
bec88ac585

+ 1
- 1
code/SensorLogger/AndroidManifest.xml View File

@@ -1,6 +1,6 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
-     package="uk.co.md87.android.sensorlogger" android:versionCode="8" android:versionName="0.1.2">
3
+     package="uk.co.md87.android.sensorlogger" android:versionCode="9" android:versionName="0.1.3">
4 4
     <application android:label="Sensor Logger">
5 5
          <activity android:name=".MainActivity" android:label="Sensor Logger">
6 6
             <intent-filter>

BIN
code/SensorLogger/dist/SensorLogger.apk View File


+ 6
- 0
code/SensorLogger/res/layout/main.xml View File

@@ -33,4 +33,10 @@
33 33
         android:layout_below="@id/entry"
34 34
         android:layout_toRightOf="@id/start"
35 35
         android:text="Upload data"/>
36
+    <TextView
37
+        android:id="@+id/viewcaption"
38
+        android:layout_width="fill_parent"
39
+        android:layout_height="wrap_content"
40
+        android:layout_below="@id/upload"
41
+        android:text="View your uploaded data at:"/>
36 42
 </RelativeLayout>

+ 30
- 2
code/SensorLogger/src/uk/co/md87/android/sensorlogger/MainActivity.java View File

@@ -6,13 +6,17 @@
6 6
 package uk.co.md87.android.sensorlogger;
7 7
 
8 8
 import android.app.Activity;
9
+import android.content.Context;
9 10
 import android.content.Intent;
10 11
 import android.os.Bundle;
12
+import android.telephony.TelephonyManager;
13
+import android.text.util.Linkify;
11 14
 import android.view.View;
12 15
 import android.view.View.OnClickListener;
13 16
 import android.widget.Button;
14 17
 import android.widget.EditText;
15 18
 import android.widget.TextView;
19
+import java.math.BigInteger;
16 20
 
17 21
 /**
18 22
  *
@@ -20,7 +24,7 @@ import android.widget.TextView;
20 24
  */
21 25
 public class MainActivity extends Activity implements OnClickListener {
22 26
 
23
-    static final String VERSION = "0.1.2";
27
+    static final String VERSION = "0.1.3";
24 28
 
25 29
     static String ACTIVITY = "Unknown";
26 30
 
@@ -45,8 +49,32 @@ public class MainActivity extends Activity implements OnClickListener {
45 49
                 + "manually trigger an upload using the button below.\n\n"
46 50
                 + "Once you press the start button, there will be a 10 second "
47 51
                 + "delay for you to put the phone in your pocket etc before monitoring "
48
-                + "begins.\n\n");
52
+                + "begins.");
49 53
         ((TextView) findViewById(R.id.caption)).setText("Activity name:");
54
+
55
+        final String imei = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
56
+        final String code = "http://MD87.co.uk/android/p/" + getCode(imei);
57
+        ((TextView) findViewById(R.id.viewcaption)).setText("View your submitted data online at:\n " + code);
58
+        Linkify.addLinks(((TextView) findViewById(R.id.viewcaption)), Linkify.WEB_URLS);
59
+    }
60
+
61
+    public String getCode(final String imei) {
62
+        final String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_";
63
+        final StringBuilder builder = new StringBuilder();
64
+
65
+        long val = Long.parseLong(imei);
66
+
67
+        while (val > 0) {
68
+            final long bit = val % chars.length();
69
+            val = val / chars.length();
70
+            builder.insert(0, chars.charAt((int) bit));
71
+        }
72
+
73
+        while (builder.length() < 10) {
74
+            builder.insert(0, "a");
75
+        }
76
+
77
+        return builder.toString();
50 78
     }
51 79
 
52 80
     /** {@inheritDoc} */

+ 1
- 0
code/SensorLogger/src/uk/co/md87/android/sensorlogger/R.java View File

@@ -16,6 +16,7 @@ public final class R {
16 16
         public static final int start=0x7f040003;
17 17
         public static final int text=0x7f040000;
18 18
         public static final int upload=0x7f040004;
19
+        public static final int viewcaption=0x7f040005;
19 20
     }
20 21
     public static final class layout {
21 22
         public static final int main=0x7f020000;

Loading…
Cancel
Save