1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 12:56:49 +01:00

display swim style as string

This commit is contained in:
Andreas Shimokawa 2020-08-20 22:27:33 +02:00
parent 98b71e78bc
commit f05ddd2d24
2 changed files with 63 additions and 31 deletions

View File

@ -238,10 +238,16 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
fieldLayout.addView(label_row);
for (int i = 0; i < innerList.length(); i++) {
TextView name_field = new TextView(ActivitySummaryDetail.this);
TextView value_field = new TextView(ActivitySummaryDetail.this);
name_field.setGravity(Gravity.START);
value_field.setGravity(Gravity.END);
JSONObject innerData = innerList.getJSONObject(i);
double value = innerData.getDouble("value");
String unit = innerData.getString("unit");
String name = innerData.getString("name");
if (!unit.equals("string")) {
double value = innerData.getDouble("value");
if (!show_raw_data) {
//special casing here:
@ -261,19 +267,18 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
}
}
TableRow field_row = new TableRow(ActivitySummaryDetail.this);
if (i % 2 == 0) field_row.setBackgroundColor(alternateColor);
TextView name_field = new TextView(ActivitySummaryDetail.this);
TextView value_field = new TextView(ActivitySummaryDetail.this);
name_field.setGravity(Gravity.START);
value_field.setGravity(Gravity.END);
if (unit.equals("seconds") && !show_raw_data) { //rather then plain seconds, show formatted duration
value_field.setText(DateTimeUtils.formatDurationHoursMinutes((long) value, TimeUnit.SECONDS));
} else {
value_field.setText(String.format("%s %s", df.format(value), getStringResourceByName(unit)));
}
} else {
value_field.setText(innerData.getString("value"));
}
TableRow field_row = new TableRow(ActivitySummaryDetail.this);
if (i % 2 == 0) field_row.setBackgroundColor(alternateColor);
name_field.setText(getStringResourceByName(name));
TableRow.LayoutParams params = new TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT, 1f);

View File

@ -291,7 +291,22 @@ public class HuamiActivitySummaryParser implements ActivitySummaryParser {
addSummaryData("averageLapPace", averageLapPace, "second");
addSummaryData("strokes", strokes, "strokes");
addSummaryData("swolfIndex", swolfIndex, "swolf_index");
addSummaryData("swimStyle", swimStyle, "swim_style");
String swimStyleName = "unknown"; // TODO: translate here or keep as string identifier here?
switch (swimStyle) {
case 1:
swimStyleName = "breaststroke";
break;
case 2:
swimStyleName = "freestyle";
break;
case 3:
swimStyleName = "backstroke";
break;
case 4:
swimStyleName = "medley";
break;
}
addSummaryData("swimStyle", swimStyleName);
addSummaryData("laps", laps, "laps");
}
@ -311,4 +326,16 @@ public class HuamiActivitySummaryParser implements ActivitySummaryParser {
}
}
}
private void addSummaryData(String key, String value) {
if (key != null && !key.equals("") && value != null && !value.equals("")) {
try {
JSONObject innerData = new JSONObject();
innerData.put("value", value);
innerData.put("unit", "string");
summaryData.put(key, innerData);
} catch (JSONException ignore) {
}
}
}
}