Fixed an issue with js files removal

This commit is contained in:
PaulStets 2018-08-07 15:08:09 +03:00
parent 7d808a38a9
commit a1fbee1aa1
5 changed files with 8 additions and 6 deletions

View file

@ -339,7 +339,7 @@ public class DownloadActivityType {
// fileName.endsWith(IndexConstants.TTSVOICE_INDEX_EXT_ZIP)) {
if (this == VOICE_FILE) {
if (fileName.contains(".js")) {
return fileName;
return fileName.replace('_', '-').replace('.', '-');
}
int l = fileName.lastIndexOf('_');
if (l == -1) {
@ -413,7 +413,7 @@ public class DownloadActivityType {
if (l == -1) {
l = fileName.length();
}
return fileName.endsWith(IndexConstants.TTSVOICE_INDEX_EXT_JS) ? fileName : fileName.substring(0, l);
return fileName.endsWith(IndexConstants.TTSVOICE_INDEX_EXT_JS) ? fileName.replace('_', '-').replace('.', '-') : fileName.substring(0, l);
}
if (this == FONT_FILE) {
int l = fileName.indexOf('.');

View file

@ -141,7 +141,8 @@ public class IndexItem implements Comparable<IndexItem> {
basename = (FileNameTranslationHelper.HILL_SHADE + getBasename()).replace("_", " ");
} else if (type == DownloadActivityType.VOICE_FILE && getFileName().endsWith(IndexConstants.TTSVOICE_INDEX_EXT_JS)){
return new File(type.getDownloadFolder(ctx, this),
getBasename().replaceAll("[_\\.]+", "-") + File.separator + getBasename());
getBasename().replaceAll("[_\\.]+", "-") + File.separator + getBasename().replaceFirst("-", "_")
.replace('-', '.'));
} else {
basename = getBasename();
}

View file

@ -403,7 +403,7 @@ public class ItemViewHolder {
} else if (indexItem.getType() == DownloadActivityType.FONT_FILE) {
tp = LocalIndexType.FONT_DATA;
} else if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {
tp = indexItem.getFileName().endsWith(IndexConstants.TTSVOICE_INDEX_EXT_JS) ? LocalIndexType.TTS_VOICE_DATA_JS :
tp = indexItem.getFileName().contains("-tts-js") ? LocalIndexType.TTS_VOICE_DATA_JS :
indexItem.getBasename().contains("tts") ? LocalIndexType.TTS_VOICE_DATA
: LocalIndexType.VOICE_DATA;
}

View file

@ -396,7 +396,7 @@ public class ResourceManager {
String lang = f.getName().replace("-tts-js", "");
File jsConf = new File(f, lang + "_" + IndexConstants.TTSVOICE_INDEX_EXT_JS);
if (jsConf.exists()) {
indexFileNames.put(jsConf.getName(), dateFormat.format(jsConf.lastModified()));
indexFileNames.put(f.getName(), dateFormat.format(jsConf.lastModified()));
}
}
}

View file

@ -97,7 +97,8 @@ public class RoutingHelper {
public RoutingHelper(OsmandApplication context){
this.app = context;
settings = context.getSettings();
voiceRouter = settings.USE_JS_VOICE_GUIDANCE.get() ?new JSVoiceRouter(this, settings)
boolean useJS = settings.VOICE_PROVIDER.get().contains("-js");
voiceRouter = useJS ? new JSVoiceRouter(this, settings)
: new VoiceRouter(this, settings);
provider = new RouteProvider();
setAppMode(settings.APPLICATION_MODE.get());