mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-25 16:50:44 +02:00
Make icon long press to toggle raw/calculated data
This commit is contained in:
parent
b85dbcf3d6
commit
3bff745b38
@ -53,6 +53,7 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
private static final Logger LOG = LoggerFactory.getLogger(ActivitySummaryDetail.class);
|
private static final Logger LOG = LoggerFactory.getLogger(ActivitySummaryDetail.class);
|
||||||
private GBDevice mGBDevice;
|
private GBDevice mGBDevice;
|
||||||
private JSONObject groupData = setGroups();
|
private JSONObject groupData = setGroups();
|
||||||
|
private boolean show_raw_data = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -77,7 +78,6 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
String activitykindname = ActivityKind.asString(intent.getIntExtra("ActivityKind",0), getApplicationContext());
|
String activitykindname = ActivityKind.asString(intent.getIntExtra("ActivityKind",0), getApplicationContext());
|
||||||
Date starttime = (Date) intent.getSerializableExtra("StartTime");
|
Date starttime = (Date) intent.getSerializableExtra("StartTime");
|
||||||
Date endtime = (Date) intent.getSerializableExtra("EndTime");
|
Date endtime = (Date) intent.getSerializableExtra("EndTime");
|
||||||
@ -110,6 +110,19 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
|
|
||||||
JSONObject listOfSummaries = makeSummaryList(summaryData);
|
JSONObject listOfSummaries = makeSummaryList(summaryData);
|
||||||
makeSummaryContent(listOfSummaries);
|
makeSummaryContent(listOfSummaries);
|
||||||
|
|
||||||
|
final JSONObject finalSummaryData = summaryData;
|
||||||
|
activity_icon.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
show_raw_data=!show_raw_data;
|
||||||
|
TableLayout fieldLayout = findViewById(R.id.summaryDetails);
|
||||||
|
fieldLayout.removeAllViews();
|
||||||
|
JSONObject listOfSummaries = makeSummaryList(finalSummaryData);
|
||||||
|
makeSummaryContent(listOfSummaries);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeSummaryContent (JSONObject data){
|
private void makeSummaryContent (JSONObject data){
|
||||||
@ -138,23 +151,24 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
String unit = innerData.getString("unit");
|
String unit = innerData.getString("unit");
|
||||||
String name = innerData.getString("name");
|
String name = innerData.getString("name");
|
||||||
|
|
||||||
//special casing here:
|
if (!show_raw_data) {
|
||||||
switch(unit){
|
//special casing here:
|
||||||
case "meters_second":
|
switch (unit) {
|
||||||
value = value *3.6;
|
case "meters_second":
|
||||||
unit = "km_h";
|
value = value * 3.6;
|
||||||
break;
|
unit = "km_h";
|
||||||
case "seconds_m":
|
break;
|
||||||
value = 3.6/value;
|
case "seconds_m":
|
||||||
unit = "minutes_km";
|
value = 3.6 / value;
|
||||||
break;
|
unit = "minutes_km";
|
||||||
case "seconds_km":
|
break;
|
||||||
value = value /60;
|
case "seconds_km":
|
||||||
unit = "minutes_km";
|
value = value / 60;
|
||||||
break;
|
unit = "minutes_km";
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TableRow field_row = new TableRow(ActivitySummaryDetail.this);
|
TableRow field_row = new TableRow(ActivitySummaryDetail.this);
|
||||||
if (i % 2 == 0) field_row.setBackgroundColor(Color.rgb(237,237,237));
|
if (i % 2 == 0) field_row.setBackgroundColor(Color.rgb(237,237,237));
|
||||||
|
|
||||||
@ -163,7 +177,7 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
name_field.setGravity(Gravity.START);
|
name_field.setGravity(Gravity.START);
|
||||||
value_field.setGravity(Gravity.END);
|
value_field.setGravity(Gravity.END);
|
||||||
|
|
||||||
if (unit.equals("seconds")) { //rather then plain seconds, show formatted duration
|
if (unit.equals("seconds") && !show_raw_data) { //rather then plain seconds, show formatted duration
|
||||||
value_field.setText(DateTimeUtils.formatDurationHoursMinutes((long) value, TimeUnit.SECONDS));
|
value_field.setText(DateTimeUtils.formatDurationHoursMinutes((long) value, TimeUnit.SECONDS));
|
||||||
}else {
|
}else {
|
||||||
value_field.setText(String.format("%s %s", df.format(value), getStringResourceByName(unit)));
|
value_field.setText(String.format("%s %s", df.format(value), getStringResourceByName(unit)));
|
||||||
|
Loading…
Reference in New Issue
Block a user