|
@@ -5,8 +5,11 @@
|
5
|
5
|
|
6
|
6
|
package uk.co.md87.android.activityrecorder.rpc;
|
7
|
7
|
|
|
8
|
+import android.content.Context;
|
8
|
9
|
import android.os.Parcel;
|
9
|
10
|
import android.os.Parcelable;
|
|
11
|
+import android.text.format.DateFormat;
|
|
12
|
+import java.util.Date;
|
10
|
13
|
|
11
|
14
|
/**
|
12
|
15
|
*
|
|
@@ -14,6 +17,8 @@ import android.os.Parcelable;
|
14
|
17
|
*/
|
15
|
18
|
public class Classification implements Parcelable {
|
16
|
19
|
|
|
20
|
+ private CharSequence niceClassification;
|
|
21
|
+ private String startTime;
|
17
|
22
|
private final String classification;
|
18
|
23
|
private final long start;
|
19
|
24
|
private long end;
|
|
@@ -46,7 +51,19 @@ public class Classification implements Parcelable {
|
46
|
51
|
|
47
|
52
|
@Override
|
48
|
53
|
public String toString() {
|
49
|
|
- return classification + "\n" + start + " -- " + (end - start);
|
|
54
|
+ final String duration;
|
|
55
|
+ final int length = (int) ((end - start) / 1000);
|
|
56
|
+
|
|
57
|
+ if (length < 60) {
|
|
58
|
+ duration = length + " secs";
|
|
59
|
+ } else if (length < 60 * 60) {
|
|
60
|
+ duration = (length / 60) + " mins";
|
|
61
|
+ } else {
|
|
62
|
+ duration = (length / (60 * 60)) + " hrs";
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+ return niceClassification + "\n" + startTime + " for " + duration;
|
50
|
67
|
}
|
51
|
68
|
|
52
|
69
|
public void writeToParcel(Parcel arg0, int arg1) {
|
|
@@ -55,6 +72,23 @@ public class Classification implements Parcelable {
|
55
|
72
|
arg0.writeLong(end);
|
56
|
73
|
}
|
57
|
74
|
|
|
75
|
+ public Classification withContext(final Context context) {
|
|
76
|
+ String name = "activity_" + getClassification().substring(11)
|
|
77
|
+ .replace("/", "_").toLowerCase();
|
|
78
|
+
|
|
79
|
+ niceClassification = context.getResources().getText(
|
|
80
|
+ context.getResources().getIdentifier(name, "string",
|
|
81
|
+ "uk.co.md87.android.activityrecorder"));
|
|
82
|
+
|
|
83
|
+ Date date = new Date(start);
|
|
84
|
+ java.text.DateFormat dateFormat = DateFormat.getDateFormat(context);
|
|
85
|
+ java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context);
|
|
86
|
+
|
|
87
|
+ startTime = dateFormat.format(date) + " " + timeFormat.format(date);
|
|
88
|
+
|
|
89
|
+ return this;
|
|
90
|
+ }
|
|
91
|
+
|
58
|
92
|
public static final Parcelable.Creator<Classification> CREATOR
|
59
|
93
|
= new Parcelable.Creator<Classification>() {
|
60
|
94
|
|