|
@@ -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} */
|