Proper update time

This commit is contained in:
Victor Shcherb 2015-06-19 00:47:13 +02:00
parent 9794de3c58
commit caa20dcb3b
5 changed files with 35 additions and 21 deletions

View file

@ -19,6 +19,7 @@ import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.download.LocalIndexesFragment.LoadLocalIndexTask;
import net.osmand.plus.voice.MediaCommandPlayerImpl;
import net.osmand.plus.voice.TTSCommandPlayerImpl;
import net.osmand.util.Algorithms;
import android.content.Context;
import android.os.Build;
@ -39,19 +40,11 @@ public class LocalIndexHelper {
}
public String getInstalledDateEdition(long t, TimeZone timeZone){
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
if(timeZone != null) {
dateFormat.setTimeZone(timeZone);
}
return app.getString(R.string.local_index_installed) + " : " + dateFormat.format(new Date(t));
return app.getString(R.string.local_index_installed) + ": " + app.getResourceManager().getDateFormat().format(new Date(t));
}
public String getInstalledDate(long t, TimeZone timeZone){
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
if(timeZone != null) {
dateFormat.setTimeZone(timeZone);
}
return dateFormat.format(new Date(t));
return app.getResourceManager().getDateFormat().format(new Date(t));
}
public void updateDescription(LocalIndexInfo info){
@ -63,6 +56,10 @@ public class LocalIndexHelper {
} else {
info.setDescription(getInstalledDate(f));
}
} else if(info.getType() == LocalIndexType.WIKI_DATA){
info.setDescription(getInstalledDate(f));
} else if(info.getType() == LocalIndexType.SRTM_DATA){
info.setDescription(app.getString(R.string.download_srtm_maps));
} else if(info.getType() == LocalIndexType.VOICE_DATA){
info.setDescription(getInstalledDate(f));
} else if(info.getType() == LocalIndexType.TTS_VOICE_DATA){

View file

@ -1,7 +1,6 @@
package net.osmand.plus.download;
import static net.osmand.IndexConstants.BINARY_MAP_INDEX_EXT;
import static net.osmand.IndexConstants.BINARY_SRTM_MAP_INDEX_EXT;
import java.io.File;
import java.io.IOException;

View file

@ -19,7 +19,6 @@ public class DownloadEntry {
public String assetName;
public DownloadActivityType type;
public DownloadEntry attachedEntry;
public IndexItem item;
public DownloadEntry(IndexItem item) {

View file

@ -3,6 +3,7 @@ package net.osmand.plus.download;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -24,6 +25,7 @@ import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.download.DownloadFileHelper.DownloadFileShowWarning;
import net.osmand.plus.download.DownloadOsmandIndexesHelper.AssetIndexItem;
import net.osmand.plus.helpers.DatabaseHelper;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.util.Algorithms;
@ -375,9 +377,6 @@ public class DownloadIndexesThread {
} else {
res = downloadFileHelper.downloadFile(de, this, filesToReindex, this, forceWifi);
}
if (res && de.attachedEntry != null) {
return downloadFile(de.attachedEntry, filesToReindex, forceWifi);
}
return res;
}
@ -593,8 +592,25 @@ public class DownloadIndexesThread {
outdated = true;
} else {
long itemSize = item.getContentSize();
File file = new File(item.getType().getDownloadFolder(app, item), sfName);
long oldItemSize = file.length();
long oldItemSize = 0;
if(item.getType() == DownloadActivityType.VOICE_FILE) {
if(item instanceof AssetIndexItem) {
File file = new File(((AssetIndexItem) item).getDestFile());
oldItemSize = file.length();
} else {
oldItemSize = new File(item.getType().getDownloadFolder(app, item), sfName +"/_config.p").length();
try {
InputStream is = ctx.getAssets(). open("voice/" + sfName + "/config.p");
if(is != null) {
oldItemSize = is.available();
is.close();
}
} catch (IOException e) {
}
}
}
if (itemSize != oldItemSize){
outdated = true;
}

View file

@ -328,19 +328,22 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
}
private String getMapDescription(IndexItem item){
String typeName = getTypeName(item.getType().getResource());
String typeName = getTypeName(item, item.getType().getResource());
String date = item.getDate(format);
String size = item.getSizeDescription(getActivity());
return typeName + " " + date + " " + size;
}
private String getTypeName(int resId){
private String getTypeName(IndexItem item, int resId){
Activity activity = getActivity();
if (resId == R.string.download_regular_maps){
return activity.getString(R.string.shared_string_map);
} else if (resId == R.string.voices){
return activity.getString(R.string.ttsvoice);
} else if (resId == R.string.download_wikipedia_maps){
return activity.getString(R.string.download_wikipedia_item);
} else if (resId == R.string.voices) {
return item.getTargetFileName().contains("tts") ? activity.getString(R.string.ttsvoice) : activity
.getString(R.string.voice);
} else if (resId == R.string.download_roads_only_maps){
return activity.getString(R.string.roads_only);
} else if (resId == R.string.download_srtm_maps){