Update date for map in dialog

This commit is contained in:
GaidamakUA 2015-12-24 11:06:33 +02:00
parent ef0088696f
commit e4d30dacef
3 changed files with 9 additions and 6 deletions

View file

@ -27,5 +27,5 @@
<string name="hint_value">Value</string>
<string name="live_updates_on">Live updates on</string>
<string name="live_updates_off">Live updates off</string>
<string name="last_check_date">"Last check date: %s"</string>
<string name="map_update_date">"Map update date: %s"</string>
</resources>

View file

@ -40,7 +40,6 @@ import static net.osmand.plus.liveupdates.LiveUpdatesHelper.formatDateTime;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getNameToDisplay;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceDownloadViaWiFi;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceForLocalIndex;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceTimeOfDayToUpdate;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceUpdateFrequency;
@ -79,10 +78,9 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
final IncrementalChangesManager changesManager = getMyApplication().getResourceManager().getChangesManager();
final long timestamp = changesManager.getTimestamp(fileNameWithoutExtension);
String lastUpdateDate = formatDateTime(getActivity(), timestamp);
OsmandSettings.CommonPreference<Long> lastCheckPreference = preferenceLastCheck(localIndexInfo, getSettings());
String lastCheckDate = formatDateTime(getActivity(), lastCheckPreference.get());
String lastCheck = lastCheckPreference.get() != -1 ? lastCheckDate : lastUpdateDate;
lastCheckTextView.setText(getString(R.string.last_check_date, lastCheck));
final long mapTimestamp = changesManager.getMapTimestamp(fileNameWithoutExtension);
String lastCheckDate = formatDateTime(getActivity(), mapTimestamp);
lastCheckTextView.setText(getString(R.string.map_update_date, lastCheckDate));
lastUpdateTextView.setText(getString(R.string.update_date_pattern, lastUpdateDate));
final OsmandSettings.CommonPreference<Boolean> liveUpdatePreference =
preferenceForLocalIndex(localIndexInfo, getSettings());

View file

@ -370,6 +370,11 @@ public class IncrementalChangesManager {
return getTimestamp(ruf);
}
public long getMapTimestamp(String fileName) {
RegionUpdateFiles ruf = regions.get(fileName.toLowerCase());
return ruf.mainFileInit;
}
private long getTimestamp(RegionUpdateFiles ruf) {
long timestamp = ruf.mainFileInit;
for (RegionUpdate ru : ruf.monthUpdates.values()) {