Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
46127894aa
5 changed files with 35 additions and 21 deletions
|
@ -19,6 +19,7 @@ import net.osmand.plus.SQLiteTileSource;
|
||||||
import net.osmand.plus.download.LocalIndexesFragment.LoadLocalIndexTask;
|
import net.osmand.plus.download.LocalIndexesFragment.LoadLocalIndexTask;
|
||||||
import net.osmand.plus.voice.MediaCommandPlayerImpl;
|
import net.osmand.plus.voice.MediaCommandPlayerImpl;
|
||||||
import net.osmand.plus.voice.TTSCommandPlayerImpl;
|
import net.osmand.plus.voice.TTSCommandPlayerImpl;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
|
@ -39,19 +40,11 @@ public class LocalIndexHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInstalledDateEdition(long t, TimeZone timeZone){
|
public String getInstalledDateEdition(long t, TimeZone timeZone){
|
||||||
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
|
return app.getString(R.string.local_index_installed) + ": " + app.getResourceManager().getDateFormat().format(new Date(t));
|
||||||
if(timeZone != null) {
|
|
||||||
dateFormat.setTimeZone(timeZone);
|
|
||||||
}
|
|
||||||
return app.getString(R.string.local_index_installed) + " : " + dateFormat.format(new Date(t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInstalledDate(long t, TimeZone timeZone){
|
public String getInstalledDate(long t, TimeZone timeZone){
|
||||||
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
|
return app.getResourceManager().getDateFormat().format(new Date(t));
|
||||||
if(timeZone != null) {
|
|
||||||
dateFormat.setTimeZone(timeZone);
|
|
||||||
}
|
|
||||||
return dateFormat.format(new Date(t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateDescription(LocalIndexInfo info){
|
public void updateDescription(LocalIndexInfo info){
|
||||||
|
@ -63,6 +56,10 @@ public class LocalIndexHelper {
|
||||||
} else {
|
} else {
|
||||||
info.setDescription(getInstalledDate(f));
|
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){
|
} else if(info.getType() == LocalIndexType.VOICE_DATA){
|
||||||
info.setDescription(getInstalledDate(f));
|
info.setDescription(getInstalledDate(f));
|
||||||
} else if(info.getType() == LocalIndexType.TTS_VOICE_DATA){
|
} else if(info.getType() == LocalIndexType.TTS_VOICE_DATA){
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package net.osmand.plus.download;
|
package net.osmand.plus.download;
|
||||||
|
|
||||||
import static net.osmand.IndexConstants.BINARY_MAP_INDEX_EXT;
|
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.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
@ -19,7 +19,6 @@ public class DownloadEntry {
|
||||||
public String assetName;
|
public String assetName;
|
||||||
public DownloadActivityType type;
|
public DownloadActivityType type;
|
||||||
|
|
||||||
public DownloadEntry attachedEntry;
|
|
||||||
public IndexItem item;
|
public IndexItem item;
|
||||||
|
|
||||||
public DownloadEntry(IndexItem item) {
|
public DownloadEntry(IndexItem item) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.download;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -24,6 +25,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||||
import net.osmand.plus.download.DownloadFileHelper.DownloadFileShowWarning;
|
import net.osmand.plus.download.DownloadFileHelper.DownloadFileShowWarning;
|
||||||
|
import net.osmand.plus.download.DownloadOsmandIndexesHelper.AssetIndexItem;
|
||||||
import net.osmand.plus.helpers.DatabaseHelper;
|
import net.osmand.plus.helpers.DatabaseHelper;
|
||||||
import net.osmand.plus.resources.ResourceManager;
|
import net.osmand.plus.resources.ResourceManager;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -375,9 +377,6 @@ public class DownloadIndexesThread {
|
||||||
} else {
|
} else {
|
||||||
res = downloadFileHelper.downloadFile(de, this, filesToReindex, this, forceWifi);
|
res = downloadFileHelper.downloadFile(de, this, filesToReindex, this, forceWifi);
|
||||||
}
|
}
|
||||||
if (res && de.attachedEntry != null) {
|
|
||||||
return downloadFile(de.attachedEntry, filesToReindex, forceWifi);
|
|
||||||
}
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,8 +592,25 @@ public class DownloadIndexesThread {
|
||||||
outdated = true;
|
outdated = true;
|
||||||
} else {
|
} else {
|
||||||
long itemSize = item.getContentSize();
|
long itemSize = item.getContentSize();
|
||||||
File file = new File(item.getType().getDownloadFolder(app, item), sfName);
|
long oldItemSize = 0;
|
||||||
long oldItemSize = file.length();
|
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){
|
if (itemSize != oldItemSize){
|
||||||
outdated = true;
|
outdated = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,19 +328,22 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMapDescription(IndexItem item){
|
private String getMapDescription(IndexItem item){
|
||||||
String typeName = getTypeName(item.getType().getResource());
|
String typeName = getTypeName(item, item.getType().getResource());
|
||||||
String date = item.getDate(format);
|
String date = item.getDate(format);
|
||||||
String size = item.getSizeDescription(getActivity());
|
String size = item.getSizeDescription(getActivity());
|
||||||
return typeName + " " + date + " " + size;
|
return typeName + " " + date + " " + size;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTypeName(int resId){
|
private String getTypeName(IndexItem item, int resId){
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (resId == R.string.download_regular_maps){
|
if (resId == R.string.download_regular_maps){
|
||||||
return activity.getString(R.string.shared_string_map);
|
return activity.getString(R.string.shared_string_map);
|
||||||
} else if (resId == R.string.voices){
|
} else if (resId == R.string.download_wikipedia_maps){
|
||||||
return activity.getString(R.string.ttsvoice);
|
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){
|
} else if (resId == R.string.download_roads_only_maps){
|
||||||
return activity.getString(R.string.roads_only);
|
return activity.getString(R.string.roads_only);
|
||||||
} else if (resId == R.string.download_srtm_maps){
|
} else if (resId == R.string.download_srtm_maps){
|
||||||
|
|
Loading…
Reference in a new issue