make sure recording widget always displays recorded distance if unsaved recording exists

This commit is contained in:
sonora 2014-08-23 17:29:06 +02:00
parent 9df4d139a4
commit 20438fbb11

View file

@ -170,8 +170,10 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
Drawable d = monitoringInactive; Drawable d = monitoringInactive;
long last = lastUpdateTime; long last = lastUpdateTime;
final boolean globalRecord = settings.SAVE_GLOBAL_TRACK_TO_GPX.get(); final boolean globalRecord = settings.SAVE_GLOBAL_TRACK_TO_GPX.get();
if (globalRecord || settings.SAVE_TRACK_TO_GPX.get()) { //if (globalRecord || settings.SAVE_TRACK_TO_GPX.get()) {
float dist = app.getSavingTrackHelper().getDistance(); float dist = app.getSavingTrackHelper().getDistance();
//make sure widget always shows recorded track distance if unsaved track exists
if (dist > 0) {
last = app.getSavingTrackHelper().getLastTimeUpdated(); last = app.getSavingTrackHelper().getLastTimeUpdated();
String ds = OsmAndFormatter.getFormattedDistance(dist, map.getMyApplication()); String ds = OsmAndFormatter.getFormattedDistance(dist, map.getMyApplication());
int ls = ds.lastIndexOf(' '); int ls = ds.lastIndexOf(' ');
@ -181,14 +183,17 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
txt = ds.substring(0, ls); txt = ds.substring(0, ls);
subtxt = ds.substring(ls + 1); subtxt = ds.substring(ls + 1);
} }
}
if(globalRecord) { if(globalRecord) {
//indicates global recording (+background recording) //indicates global recording (+background recording)
d = monitoringBig; d = monitoringBig;
} else if (settings.SAVE_TRACK_TO_GPX.get()) { } else if (settings.SAVE_TRACK_TO_GPX.get()) {
//indicates (profile-based, configured in settings) screen-on recording //indicates (profile-based, configured in settings) screen-on recording
d = monitoringSmall; d = monitoringSmall;
} else {
d = monitoringInactive;
} }
} //}
setText(txt, subtxt); setText(txt, subtxt);
setImageDrawable(d); setImageDrawable(d);
if (last != lastUpdateTime && globalRecord) { if (last != lastUpdateTime && globalRecord) {