diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 7120882de..c2e63136b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -421,7 +421,7 @@
android:windowSoftInputMode="stateHidden" />
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ActivitySummariesActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ActivitySummariesActivity.java
index 728645083..12a783318 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ActivitySummariesActivity.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ActivitySummariesActivity.java
@@ -134,7 +134,7 @@ public class ActivitySummariesActivity extends AbstractListActivity keys = summaryData.keys();
- LOG.debug("petr summary JSON:" + summaryData + keys);
+ JSONObject listOfSummaries = makeSummaryList(summaryData);
+ TextView details = (TextView) findViewById(R.id.details);
+ details.setText(makeSummaryContent(listOfSummaries));
+ }
+
+ private String makeSummaryContent (JSONObject data){
+ //convert dictionary to pretty print string, use localized names
+ StringBuilder content = new StringBuilder();
+ Iterator keys = data.keys();
+ DecimalFormat df = new DecimalFormat("#.##");
+
+ while (keys.hasNext()) {
+ String key = keys.next();
+ try {
+ LOG.error("SportsActivity:" + key + ": " + data.get(key) + "\n");
+ JSONArray innerList = (JSONArray) data.get(key);
+ content.append(String.format("\n%s\n", getStringResourceByName(key).toUpperCase()));
+
+ for (int i = 0; i < innerList.length(); i++) {
+ JSONObject innerData = innerList.getJSONObject(i);
+ double value = innerData.getDouble("value");
+ String unit = innerData.getString("unit");
+ String name = innerData.getString("name");
+
+ //special casing here:
+ switch(unit){
+ case "meters_second":
+ value = value *3.6;
+ unit = "km_h";
+ break;
+ case "seconds_m":
+ value = 3.6/value;
+ unit = "minutes_km";
+ break;
+ case "seconds_km":
+ value = value /60;
+ unit = "minutes_km";
+ break;
+ }
+
+ content.append(String.format("%s: %s %s\n", getStringResourceByName(name), df.format(value), getStringResourceByName(unit)));
+ }
+ } catch (JSONException e) {
+ LOG.error("SportsActivity", e);
+ }
+ }
+
+ return content.toString();
+ }
+
+
+ private JSONObject makeSummaryList(JSONObject summaryData){
+ //make dictionary with data for each group
+ JSONObject list = new JSONObject();
+ Iterator keys = summaryData.keys();
+ LOG.error("SportsActivity JSON:" + summaryData + keys);
while (keys.hasNext()) {
String key = keys.next();
- LOG.debug("petr key:" + key);
try {
- LOG.debug("petr" + key + ": " + summaryData.get(key) + "\n");
- DecimalFormat df = new DecimalFormat("#.##");
+ LOG.error("SportsActivity:" + key + ": " + summaryData.get(key) + "\n");
JSONObject innerData = (JSONObject) summaryData.get(key);
Object value = innerData.get("value");
String unit = innerData.getString("unit");
- summaryDatastr.append(String.format("%s: %s %s\n", key, df.format(value), unit));
+ String group = innerData.getString("group");
+
+ if (!list.has(group)) {
+ list.put(group,new JSONArray());
+ }
+
+ JSONArray tmpl = (JSONArray) list.get(group);
+ JSONObject innernew = new JSONObject();
+ innernew.put("name", key);
+ innernew.put("value", value);
+ innernew.put("unit", unit);
+ tmpl.put(innernew);
+ list.put(group, tmpl);
} catch (JSONException e) {
- e.printStackTrace();
+ LOG.error("SportsActivity", e);
}
}
- TextView details = (TextView) findViewById(R.id.details);
- details.setText(summaryDatastr.toString());
+ return list;
}
+ private String getStringResourceByName(String aString) {
+ String packageName = getPackageName();
+ int resId = getResources().getIdentifier(aString, "string", packageName);
+ if (resId==0){
+ LOG.warn("SportsActivity " + "Missing string in strings:" + aString);
+ return aString;
+ }else{
+ return getString(resId);
+ }
+ }
private int getSteps(int tsStart, int tsEnd) {
try (DBHandler handler = GBApplication.acquireDB()) {
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/ActivitySummariesAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/ActivitySummariesAdapter.java
index b7d9d2e0a..2a5852ea1 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/ActivitySummariesAdapter.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/ActivitySummariesAdapter.java
@@ -72,12 +72,9 @@ public class ActivitySummariesAdapter extends AbstractItemAdapter 0) {
try {
JSONObject innerData= new JSONObject();
innerData.put("value", value);
innerData.put("unit", unit);
- summaryData.put(key, innerData);
- } catch (JSONException ignore) {
- }
- }
- }
- private void addSummaryData(String key, short value, String unit) {
- if (value> 0) {
- try {
- JSONObject innerData= new JSONObject();
- innerData.put("value", value);
- innerData.put("unit", unit);
+ innerData.put("group", group);
summaryData.put(key, innerData);
} catch (JSONException ignore) {
}
}
}
- private void addSummaryData(String key, int value, String unit) {
- if (value> 0) {
- try {
- JSONObject innerData= new JSONObject();
- innerData.put("value", value);
- innerData.put("unit", unit);
- summaryData.put(key, innerData);
- } catch (JSONException ignore) {
- }
- }
- }
@Override
protected String getLastSyncTimeKey() {
diff --git a/app/src/main/res/layout/activity_summary_details.xml b/app/src/main/res/layout/activity_summary_details.xml
index 5e37a79d4..ea6b25e53 100644
--- a/app/src/main/res/layout/activity_summary_details.xml
+++ b/app/src/main/res/layout/activity_summary_details.xml
@@ -43,7 +43,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
- android:text="Start:" />
+ android:text="@string/activity_detail_start_label" />
+ android:text="@string/activity_detail_end_label" />
+ android:text="@string/activity_detail_duration_label" />
+ android:text="@string/activity_detail_show_gps_label" />
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 40dc15503..fe72ce3de 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -699,7 +699,8 @@
Walking
Swimming
Unknown activity
- Activities
+ Sport Activities
+ Sport Activity Detail
Biking
Treadmill
Exercise
@@ -903,6 +904,69 @@
Ignore bonded devices
Enabling this option will ignore devices that have been bonded/paired already when scanning
Location must be turned on to scan for devices
+
+ Distance
+ Uphill
+ Downhill
+ Maximum
+ Minimum
+ Steps
+ Active
+ Calories
+ Maximum
+ Slowest Pace
+ Fastest Pace
+ Total stride
+ Heartrate
+ Pace
+ Average Stride
+ Average Stroke Distance
+ Average Strokes
+ Average Lap Pace
+ Strokes
+ swolfIndex
+ swimStyle
+ Laps
+ Ascenting
+ Descenting
+ Flat
+
+
+ m
+ cm
+ steps
+ m/s
+ km/h
+ str/s
+ str
+ sec
+ swolf index
+ swim style
+ laps
+ Kcal
+ sec/km
+ min/km
+ bpm
+
+
+
+ Strokes
+ Swimming
+ Distance
+ Elevation
+ Speed
+ Activity
+ Steps
+
+
+
+ Start:
+ End:
+ Duration:
+ Show GPS Track
+
+
+
- %d hour