Added fonts download
This commit is contained in:
parent
646a45edab
commit
f648fc7f77
16 changed files with 157 additions and 31 deletions
|
@ -33,6 +33,8 @@ public class IndexConstants {
|
||||||
public static final String TTSVOICE_INDEX_EXT_ZIP = ".ttsvoice.zip"; //$NON-NLS-1$
|
public static final String TTSVOICE_INDEX_EXT_ZIP = ".ttsvoice.zip"; //$NON-NLS-1$
|
||||||
public static final String ANYVOICE_INDEX_EXT_ZIP = "voice.zip"; //$NON-NLS-1$ //to cactch both voices, .voice.zip and .ttsvoice.zip
|
public static final String ANYVOICE_INDEX_EXT_ZIP = "voice.zip"; //$NON-NLS-1$ //to cactch both voices, .voice.zip and .ttsvoice.zip
|
||||||
|
|
||||||
|
public static final String FONT_INDEX_EXT = ".otf"; //$NON-NLS-1$
|
||||||
|
public static final String FONT_INDEX_EXT_ZIP = ".otf.zip"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
public static final String RENDERER_INDEX_EXT = ".render.xml"; //$NON-NLS-1$
|
public static final String RENDERER_INDEX_EXT = ".render.xml"; //$NON-NLS-1$
|
||||||
|
@ -53,6 +55,7 @@ public class IndexConstants {
|
||||||
public static final String ROADS_INDEX_DIR = "roads/"; //$NON-NLS-1$
|
public static final String ROADS_INDEX_DIR = "roads/"; //$NON-NLS-1$
|
||||||
public static final String WIKI_INDEX_DIR = "wiki/"; //$NON-NLS-1$
|
public static final String WIKI_INDEX_DIR = "wiki/"; //$NON-NLS-1$
|
||||||
public static final String AV_INDEX_DIR = "avnotes/"; //$NON-NLS-1$
|
public static final String AV_INDEX_DIR = "avnotes/"; //$NON-NLS-1$
|
||||||
|
public static final String FONT_INDEX_DIR = "fonts/"; //$NON-NLS-1$
|
||||||
public static final String VOICE_INDEX_DIR = "voice/"; //$NON-NLS-1$
|
public static final String VOICE_INDEX_DIR = "voice/"; //$NON-NLS-1$
|
||||||
public static final String RENDERERS_DIR = "rendering/"; //$NON-NLS-1$
|
public static final String RENDERERS_DIR = "rendering/"; //$NON-NLS-1$
|
||||||
public static final String ROUTING_XML_FILE= "routing.xml";
|
public static final String ROUTING_XML_FILE= "routing.xml";
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="fonts_header">Fonts for map</string>
|
||||||
<string name="right_side_navigation">Right-hand driving</string>
|
<string name="right_side_navigation">Right-hand driving</string>
|
||||||
<string name="driving_region_automatic">Automatic</string>
|
<string name="driving_region_automatic">Automatic</string>
|
||||||
<string name="do_not_send_anonymous_app_usage">Do not send anonymous app usage</string>
|
<string name="do_not_send_anonymous_app_usage">Do not send anonymous app usage</string>
|
||||||
|
|
|
@ -89,6 +89,8 @@ public class LocalIndexHelper {
|
||||||
info.setDescription(getInstalledDate(f));
|
info.setDescription(getInstalledDate(f));
|
||||||
} 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.FONT_DATA) {
|
||||||
|
info.setDescription(getInstalledDate(f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,6 +212,7 @@ public class LocalIndexHelper {
|
||||||
loadWikiData(app.getAppPath(IndexConstants.WIKI_INDEX_DIR), result, loadTask);
|
loadWikiData(app.getAppPath(IndexConstants.WIKI_INDEX_DIR), result, loadTask);
|
||||||
//loadVoiceData(app.getAppPath(IndexConstants.TTSVOICE_INDEX_EXT_ZIP), result, true, loadTask);
|
//loadVoiceData(app.getAppPath(IndexConstants.TTSVOICE_INDEX_EXT_ZIP), result, true, loadTask);
|
||||||
loadVoiceData(app.getAppPath(IndexConstants.VOICE_INDEX_DIR), result, false, loadTask);
|
loadVoiceData(app.getAppPath(IndexConstants.VOICE_INDEX_DIR), result, false, loadTask);
|
||||||
|
loadFontData(app.getAppPath(IndexConstants.FONT_INDEX_DIR), result, false, loadTask);
|
||||||
loadObfData(app.getAppPath(IndexConstants.BACKUP_INDEX_DIR), result, true, loadTask, loadedMaps);
|
loadObfData(app.getAppPath(IndexConstants.BACKUP_INDEX_DIR), result, true, loadTask, loadedMaps);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -255,6 +258,20 @@ public class LocalIndexHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadFontData(File fontDir, List<LocalIndexInfo> result, boolean backup, AbstractLoadLocalIndexTask loadTask) {
|
||||||
|
if (fontDir.canRead()) {
|
||||||
|
for (File fontFile : listFilesSorted(fontDir)) {
|
||||||
|
if (fontFile.isFile() && fontFile.getName().endsWith(IndexConstants.FONT_INDEX_EXT)) {
|
||||||
|
LocalIndexType lt = LocalIndexType.FONT_DATA;
|
||||||
|
LocalIndexInfo info = new LocalIndexInfo(lt, fontFile, backup, app);
|
||||||
|
updateDescription(info);
|
||||||
|
result.add(info);
|
||||||
|
loadTask.loadFile(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void loadTilesData(File tilesPath, List<LocalIndexInfo> result, boolean backup, AbstractLoadLocalIndexTask loadTask) {
|
private void loadTilesData(File tilesPath, List<LocalIndexInfo> result, boolean backup, AbstractLoadLocalIndexTask loadTask) {
|
||||||
if (tilesPath.canRead()) {
|
if (tilesPath.canRead()) {
|
||||||
for (File tileFile : listFilesSorted(tilesPath)) {
|
for (File tileFile : listFilesSorted(tilesPath)) {
|
||||||
|
@ -342,6 +359,7 @@ public class LocalIndexHelper {
|
||||||
WIKI_DATA(R.string.local_indexes_cat_wiki, R.drawable.ic_plugin_wikipedia, 50),
|
WIKI_DATA(R.string.local_indexes_cat_wiki, R.drawable.ic_plugin_wikipedia, 50),
|
||||||
TTS_VOICE_DATA(R.string.local_indexes_cat_tts, R.drawable.ic_action_volume_up, 20),
|
TTS_VOICE_DATA(R.string.local_indexes_cat_tts, R.drawable.ic_action_volume_up, 20),
|
||||||
VOICE_DATA(R.string.local_indexes_cat_voice, R.drawable.ic_action_volume_up, 30),
|
VOICE_DATA(R.string.local_indexes_cat_voice, R.drawable.ic_action_volume_up, 30),
|
||||||
|
FONT_DATA(R.string.fonts_header, R.drawable.ic_action_map_language, 35),
|
||||||
DEACTIVATED(R.string.local_indexes_cat_backup, R.drawable.ic_type_archive, 1000);
|
DEACTIVATED(R.string.local_indexes_cat_backup, R.drawable.ic_type_archive, 1000);
|
||||||
// AV_DATA(R.string.local_indexes_cat_av);;
|
// AV_DATA(R.string.local_indexes_cat_av);;
|
||||||
|
|
||||||
|
@ -392,6 +410,13 @@ public class LocalIndexHelper {
|
||||||
}
|
}
|
||||||
return fileName.substring(0, l);
|
return fileName.substring(0, l);
|
||||||
}
|
}
|
||||||
|
if (this == FONT_DATA) {
|
||||||
|
int l = fileName.indexOf('.');
|
||||||
|
if (l == -1) {
|
||||||
|
l = fileName.length();
|
||||||
|
}
|
||||||
|
return fileName.substring(0, l).replace('_', ' ').replace('-', ' ');
|
||||||
|
}
|
||||||
int ls = fileName.lastIndexOf('_');
|
int ls = fileName.lastIndexOf('_');
|
||||||
if (ls >= 0) {
|
if (ls >= 0) {
|
||||||
return fileName.substring(0, ls);
|
return fileName.substring(0, ls);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.download;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
@ -17,6 +18,7 @@ import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v4.widget.Space;
|
import android.support.v4.widget.Space;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.AppCompatButton;
|
import android.support.v7.widget.AppCompatButton;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -33,6 +35,7 @@ import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.IProgress;
|
import net.osmand.IProgress;
|
||||||
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.access.AccessibilityAssistant;
|
import net.osmand.access.AccessibilityAssistant;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
@ -281,6 +284,19 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
||||||
downloadItem = null;
|
downloadItem = null;
|
||||||
downloadTargetFileName = null;
|
downloadTargetFileName = null;
|
||||||
}
|
}
|
||||||
|
if (!Algorithms.isEmpty(downloadTargetFileName) && downloadTargetFileName.endsWith(IndexConstants.FONT_INDEX_EXT)) {
|
||||||
|
AlertDialog.Builder bld = new AlertDialog.Builder(this);
|
||||||
|
bld.setMessage(R.string.restart_is_required);
|
||||||
|
bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
android.os.Process.killProcess(android.os.Process.myPid());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bld.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
bld.show();
|
||||||
|
}
|
||||||
for (WeakReference<Fragment> ref : fragSet) {
|
for (WeakReference<Fragment> ref : fragSet) {
|
||||||
Fragment f = ref.get();
|
Fragment f = ref.get();
|
||||||
if (f instanceof DownloadEvents && f.isAdded()) {
|
if (f instanceof DownloadEvents && f.isAdded()) {
|
||||||
|
|
|
@ -33,17 +33,16 @@ public class DownloadActivityType {
|
||||||
new DownloadActivityType(R.string.download_regular_maps, "map", 10);
|
new DownloadActivityType(R.string.download_regular_maps, "map", 10);
|
||||||
public static final DownloadActivityType VOICE_FILE =
|
public static final DownloadActivityType VOICE_FILE =
|
||||||
new DownloadActivityType(R.string.voices, R.drawable.ic_action_volume_up, "voice", 20);
|
new DownloadActivityType(R.string.voices, R.drawable.ic_action_volume_up, "voice", 20);
|
||||||
|
public static final DownloadActivityType FONT_FILE =
|
||||||
|
new DownloadActivityType(R.string.fonts_header, R.drawable.ic_action_map_language, "fonts", 25);
|
||||||
public static final DownloadActivityType ROADS_FILE =
|
public static final DownloadActivityType ROADS_FILE =
|
||||||
new DownloadActivityType(R.string.download_roads_only_maps, "road_map", 30);
|
new DownloadActivityType(R.string.download_roads_only_maps, "road_map", 30);
|
||||||
public static final DownloadActivityType SRTM_COUNTRY_FILE =
|
public static final DownloadActivityType SRTM_COUNTRY_FILE =
|
||||||
new DownloadActivityType(R.string.download_srtm_maps,
|
new DownloadActivityType(R.string.download_srtm_maps, R.drawable.ic_plugin_srtm, "srtm_map", 40);
|
||||||
R.drawable.ic_plugin_srtm, "srtm_map", 40);
|
|
||||||
public static final DownloadActivityType HILLSHADE_FILE =
|
public static final DownloadActivityType HILLSHADE_FILE =
|
||||||
new DownloadActivityType(R.string.download_hillshade_maps,
|
new DownloadActivityType(R.string.download_hillshade_maps, R.drawable.ic_action_hillshade_dark, "hillshade", 50);
|
||||||
R.drawable.ic_action_hillshade_dark, "hillshade", 50);
|
|
||||||
public static final DownloadActivityType WIKIPEDIA_FILE =
|
public static final DownloadActivityType WIKIPEDIA_FILE =
|
||||||
new DownloadActivityType(R.string.download_wikipedia_maps,
|
new DownloadActivityType(R.string.download_wikipedia_maps, R.drawable.ic_plugin_wikipedia, "wikimap", 60);
|
||||||
R.drawable.ic_plugin_wikipedia, "wikimap", 60);
|
|
||||||
public static final DownloadActivityType LIVE_UPDATES_FILE =
|
public static final DownloadActivityType LIVE_UPDATES_FILE =
|
||||||
new DownloadActivityType(R.string.download_live_updates, "live_updates", 70);
|
new DownloadActivityType(R.string.download_live_updates, "live_updates", 70);
|
||||||
private final int stringResource;
|
private final int stringResource;
|
||||||
|
@ -115,6 +114,8 @@ public class DownloadActivityType {
|
||||||
return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_ROAD_MAP_INDEX_EXT_ZIP, IndexConstants.BINARY_MAP_VERSION));
|
return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_ROAD_MAP_INDEX_EXT_ZIP, IndexConstants.BINARY_MAP_VERSION));
|
||||||
} else if (VOICE_FILE == this) {
|
} else if (VOICE_FILE == this) {
|
||||||
return fileName.endsWith(addVersionToExt(IndexConstants.VOICE_INDEX_EXT_ZIP, IndexConstants.VOICE_VERSION));
|
return fileName.endsWith(addVersionToExt(IndexConstants.VOICE_INDEX_EXT_ZIP, IndexConstants.VOICE_VERSION));
|
||||||
|
} else if (FONT_FILE == this) {
|
||||||
|
return fileName.endsWith(IndexConstants.FONT_INDEX_EXT_ZIP);
|
||||||
} else if (WIKIPEDIA_FILE == this) {
|
} else if (WIKIPEDIA_FILE == this) {
|
||||||
return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT_ZIP,
|
return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT_ZIP,
|
||||||
IndexConstants.BINARY_MAP_VERSION));
|
IndexConstants.BINARY_MAP_VERSION));
|
||||||
|
@ -135,6 +136,8 @@ public class DownloadActivityType {
|
||||||
return ctx.getAppPath(IndexConstants.MAPS_PATH);
|
return ctx.getAppPath(IndexConstants.MAPS_PATH);
|
||||||
} else if (VOICE_FILE == this) {
|
} else if (VOICE_FILE == this) {
|
||||||
return ctx.getAppPath(IndexConstants.VOICE_INDEX_DIR);
|
return ctx.getAppPath(IndexConstants.VOICE_INDEX_DIR);
|
||||||
|
} else if (FONT_FILE == this) {
|
||||||
|
return ctx.getAppPath(IndexConstants.FONT_INDEX_DIR);
|
||||||
} else if (ROADS_FILE == this) {
|
} else if (ROADS_FILE == this) {
|
||||||
return ctx.getAppPath(IndexConstants.ROADS_INDEX_DIR);
|
return ctx.getAppPath(IndexConstants.ROADS_INDEX_DIR);
|
||||||
} else if (SRTM_COUNTRY_FILE == this) {
|
} else if (SRTM_COUNTRY_FILE == this) {
|
||||||
|
@ -178,6 +181,8 @@ public class DownloadActivityType {
|
||||||
return IndexConstants.BINARY_ROAD_MAP_INDEX_EXT;
|
return IndexConstants.BINARY_ROAD_MAP_INDEX_EXT;
|
||||||
} else if (VOICE_FILE == this) {
|
} else if (VOICE_FILE == this) {
|
||||||
return "";
|
return "";
|
||||||
|
} else if (FONT_FILE == this) {
|
||||||
|
return IndexConstants.FONT_INDEX_EXT;
|
||||||
} else if (SRTM_COUNTRY_FILE == this) {
|
} else if (SRTM_COUNTRY_FILE == this) {
|
||||||
return IndexConstants.BINARY_SRTM_MAP_INDEX_EXT;
|
return IndexConstants.BINARY_SRTM_MAP_INDEX_EXT;
|
||||||
} else if (WIKIPEDIA_FILE == this) {
|
} else if (WIKIPEDIA_FILE == this) {
|
||||||
|
@ -199,16 +204,21 @@ public class DownloadActivityType {
|
||||||
return "&srtmcountry=yes";
|
return "&srtmcountry=yes";
|
||||||
} else if (this == DownloadActivityType.WIKIPEDIA_FILE) {
|
} else if (this == DownloadActivityType.WIKIPEDIA_FILE) {
|
||||||
return "&wiki=yes";
|
return "&wiki=yes";
|
||||||
}else if (this== DownloadActivityType.HILLSHADE_FILE) {
|
}else if (this == DownloadActivityType.HILLSHADE_FILE) {
|
||||||
return "&hillshade=yes";
|
return "&hillshade=yes";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBaseUrl(OsmandApplication ctx, String fileName) {
|
public String getBaseUrl(OsmandApplication ctx, String fileName) {
|
||||||
|
if (this == FONT_FILE) {
|
||||||
|
return "http://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN + "/download?event=2&fonts=yes&"
|
||||||
|
+ Version.getVersionAsURLParam(ctx) + "&file=" + encode(fileName);
|
||||||
|
} else {
|
||||||
return "http://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN + "/download?event=2&"
|
return "http://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN + "/download?event=2&"
|
||||||
+ Version.getVersionAsURLParam(ctx) + "&file=" + encode(fileName);
|
+ Version.getVersionAsURLParam(ctx) + "&file=" + encode(fileName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected String encode(String fileName) {
|
protected String encode(String fileName) {
|
||||||
|
@ -268,9 +278,12 @@ public class DownloadActivityType {
|
||||||
}
|
}
|
||||||
return getBasename(indexItem);
|
return getBasename(indexItem);
|
||||||
}
|
}
|
||||||
|
if (this == FONT_FILE) {
|
||||||
|
return FileNameTranslationHelper.getFontName(ctx, getBasename(indexItem));
|
||||||
|
}
|
||||||
final String basename = getBasename(indexItem);
|
final String basename = getBasename(indexItem);
|
||||||
if (basename.endsWith(FileNameTranslationHelper.WIKI_NAME)){
|
if (basename.endsWith(FileNameTranslationHelper.WIKI_NAME)){
|
||||||
return FileNameTranslationHelper.getWikiName(ctx,basename);
|
return FileNameTranslationHelper.getWikiName(ctx, basename);
|
||||||
}
|
}
|
||||||
// if (this == HILLSHADE_FILE){
|
// if (this == HILLSHADE_FILE){
|
||||||
// return FileNameTranslationHelper.getHillShadeName(ctx, osmandRegions, bn);
|
// return FileNameTranslationHelper.getHillShadeName(ctx, osmandRegions, bn);
|
||||||
|
@ -300,6 +313,12 @@ public class DownloadActivityType {
|
||||||
l = fileName.length();
|
l = fileName.length();
|
||||||
}
|
}
|
||||||
return fileName.substring(0, l);
|
return fileName.substring(0, l);
|
||||||
|
} else if (this == FONT_FILE) {
|
||||||
|
int l = fileName.indexOf('.');
|
||||||
|
if (l == -1) {
|
||||||
|
l = fileName.length();
|
||||||
|
}
|
||||||
|
return fileName.substring(0, l) + IndexConstants.FONT_INDEX_EXT;
|
||||||
} else if (this == HILLSHADE_FILE) {
|
} else if (this == HILLSHADE_FILE) {
|
||||||
return fileName.replace('_', ' ');
|
return fileName.replace('_', ' ');
|
||||||
} else if (this == LIVE_UPDATES_FILE) {
|
} else if (this == LIVE_UPDATES_FILE) {
|
||||||
|
@ -355,6 +374,13 @@ public class DownloadActivityType {
|
||||||
}
|
}
|
||||||
return fileName.substring(0, l);
|
return fileName.substring(0, l);
|
||||||
}
|
}
|
||||||
|
if (this == FONT_FILE) {
|
||||||
|
int l = fileName.indexOf('.');
|
||||||
|
if (l == -1) {
|
||||||
|
l = fileName.length();
|
||||||
|
}
|
||||||
|
return fileName.substring(0, l);
|
||||||
|
}
|
||||||
if (this == LIVE_UPDATES_FILE) {
|
if (this == LIVE_UPDATES_FILE) {
|
||||||
if(fileName.indexOf('.') > 0){
|
if(fileName.indexOf('.') > 0){
|
||||||
return fileName.substring(0, fileName.indexOf('.'));
|
return fileName.substring(0, fileName.indexOf('.'));
|
||||||
|
|
|
@ -586,6 +586,7 @@ public class DownloadIndexesThread {
|
||||||
}
|
}
|
||||||
List<String> warnings = new ArrayList<String>();
|
List<String> warnings = new ArrayList<String>();
|
||||||
manager.indexVoiceFiles(this);
|
manager.indexVoiceFiles(this);
|
||||||
|
manager.indexFontFiles(this);
|
||||||
if (vectorMapsToReindex) {
|
if (vectorMapsToReindex) {
|
||||||
warnings = manager.indexingMaps(this);
|
warnings = manager.indexingMaps(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,12 +37,15 @@ public class DownloadResourceGroup {
|
||||||
// headers with voice items
|
// headers with voice items
|
||||||
VOICE_HEADER_TTS(R.string.index_name_tts_voice),
|
VOICE_HEADER_TTS(R.string.index_name_tts_voice),
|
||||||
VOICE_HEADER_REC(R.string.index_name_voice),
|
VOICE_HEADER_REC(R.string.index_name_voice),
|
||||||
|
// headers with font items
|
||||||
|
FONTS_HEADER(R.string.fonts_header),
|
||||||
// headers with resources
|
// headers with resources
|
||||||
OTHER_MAPS_GROUP(R.string.download_select_map_types),
|
OTHER_MAPS_GROUP(R.string.download_select_map_types),
|
||||||
VOICE_GROUP(R.string.voices),
|
OTHER_GROUP(R.string.other_menu_group),
|
||||||
SUBREGIONS(R.string.regions),
|
SUBREGIONS(R.string.regions),
|
||||||
// screen items
|
// screen items
|
||||||
VOICE_TTS(R.string.index_name_tts_voice),
|
VOICE_TTS(R.string.index_name_tts_voice),
|
||||||
|
FONTS(R.string.fonts_header),
|
||||||
VOICE_REC(R.string.index_name_voice),
|
VOICE_REC(R.string.index_name_voice),
|
||||||
OTHER_MAPS(R.string.download_select_map_types),
|
OTHER_MAPS(R.string.download_select_map_types),
|
||||||
WORLD(-1),
|
WORLD(-1),
|
||||||
|
@ -56,7 +59,7 @@ public class DownloadResourceGroup {
|
||||||
|
|
||||||
public boolean isScreen() {
|
public boolean isScreen() {
|
||||||
return this == WORLD || this == REGION || this == VOICE_TTS
|
return this == WORLD || this == REGION || this == VOICE_TTS
|
||||||
|| this == VOICE_REC || this == OTHER_MAPS;
|
|| this == VOICE_REC || this == OTHER_MAPS || this == FONTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDefaultId() {
|
public String getDefaultId() {
|
||||||
|
@ -68,18 +71,19 @@ public class DownloadResourceGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsIndexItem() {
|
public boolean containsIndexItem() {
|
||||||
return isHeader() && this != SUBREGIONS && this != VOICE_GROUP && this != OTHER_MAPS_GROUP;
|
return isHeader() && this != SUBREGIONS && this != OTHER_GROUP && this != OTHER_MAPS_GROUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHeader() {
|
public boolean isHeader() {
|
||||||
return this == VOICE_HEADER_REC || this == VOICE_HEADER_TTS || this == SUBREGIONS
|
return this == VOICE_HEADER_REC || this == VOICE_HEADER_TTS || this == SUBREGIONS
|
||||||
|| this == WORLD_MAPS || this == REGION_MAPS || this == VOICE_GROUP
|
|| this == WORLD_MAPS || this == REGION_MAPS || this == OTHER_GROUP
|
||||||
|| this == HILLSHADE_HEADER || this == SRTM_HEADER
|
|| this == HILLSHADE_HEADER || this == SRTM_HEADER
|
||||||
|| this == OTHER_MAPS_HEADER || this == OTHER_MAPS_GROUP;
|
|| this == OTHER_MAPS_HEADER || this == OTHER_MAPS_GROUP
|
||||||
|
|| this == FONTS_HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getVoiceTTSId() {
|
public static String getVoiceTTSId() {
|
||||||
return "#" + VOICE_GROUP.name().toLowerCase() + "#" + VOICE_TTS.name().toLowerCase();
|
return "#" + OTHER_GROUP.name().toLowerCase() + "#" + VOICE_TTS.name().toLowerCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,8 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (item.getType() == DownloadActivityType.FONT_FILE) {
|
||||||
|
oldItemSize = new File(app.getAppPath(IndexConstants.FONT_INDEX_DIR), item.getTargetFileName()).length();
|
||||||
} else {
|
} else {
|
||||||
oldItemSize = app.getAppPath(item.getTargetFileName()).length();
|
oldItemSize = app.getAppPath(item.getTargetFileName()).length();
|
||||||
}
|
}
|
||||||
|
@ -244,11 +246,13 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
otherMapsScreen.addGroup(otherMaps);
|
otherMapsScreen.addGroup(otherMaps);
|
||||||
otherMapsGroup.addGroup(otherMapsScreen);
|
otherMapsGroup.addGroup(otherMapsScreen);
|
||||||
|
|
||||||
DownloadResourceGroup voiceGroup = new DownloadResourceGroup(this, DownloadResourceGroupType.VOICE_GROUP);
|
DownloadResourceGroup otherGroup = new DownloadResourceGroup(this, DownloadResourceGroupType.OTHER_GROUP);
|
||||||
DownloadResourceGroup voiceScreenTTS = new DownloadResourceGroup(voiceGroup, DownloadResourceGroupType.VOICE_TTS);
|
DownloadResourceGroup voiceScreenTTS = new DownloadResourceGroup(otherGroup, DownloadResourceGroupType.VOICE_TTS);
|
||||||
DownloadResourceGroup voiceScreenRec = new DownloadResourceGroup(voiceGroup, DownloadResourceGroupType.VOICE_REC);
|
DownloadResourceGroup voiceScreenRec = new DownloadResourceGroup(otherGroup, DownloadResourceGroupType.VOICE_REC);
|
||||||
DownloadResourceGroup voiceTTS = new DownloadResourceGroup(voiceGroup, DownloadResourceGroupType.VOICE_HEADER_TTS);
|
DownloadResourceGroup fontScreen = new DownloadResourceGroup(otherGroup, DownloadResourceGroupType.FONTS);
|
||||||
DownloadResourceGroup voiceRec = new DownloadResourceGroup(voiceGroup, DownloadResourceGroupType.VOICE_HEADER_REC);
|
DownloadResourceGroup voiceTTS = new DownloadResourceGroup(otherGroup, DownloadResourceGroupType.VOICE_HEADER_TTS);
|
||||||
|
DownloadResourceGroup voiceRec = new DownloadResourceGroup(otherGroup, DownloadResourceGroupType.VOICE_HEADER_REC);
|
||||||
|
DownloadResourceGroup fonts = new DownloadResourceGroup(otherGroup, DownloadResourceGroupType.FONTS_HEADER);
|
||||||
|
|
||||||
DownloadResourceGroup worldMaps = new DownloadResourceGroup(this, DownloadResourceGroupType.WORLD_MAPS);
|
DownloadResourceGroup worldMaps = new DownloadResourceGroup(this, DownloadResourceGroupType.WORLD_MAPS);
|
||||||
Map<WorldRegion, List<IndexItem> > groupByRegion = new LinkedHashMap<WorldRegion, List<IndexItem>>();
|
Map<WorldRegion, List<IndexItem> > groupByRegion = new LinkedHashMap<WorldRegion, List<IndexItem>>();
|
||||||
|
@ -262,6 +266,10 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (ii.getType() == DownloadActivityType.FONT_FILE) {
|
||||||
|
fonts.addItem(ii);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
String basename = ii.getBasename().toLowerCase();
|
String basename = ii.getBasename().toLowerCase();
|
||||||
WorldRegion wg = regs.getRegionDataByDownloadName(basename);
|
WorldRegion wg = regs.getRegionDataByDownloadName(basename);
|
||||||
if (wg != null) {
|
if (wg != null) {
|
||||||
|
@ -322,9 +330,15 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
|
|
||||||
voiceScreenTTS.addGroup(voiceTTS);
|
voiceScreenTTS.addGroup(voiceTTS);
|
||||||
voiceScreenRec.addGroup(voiceRec);
|
voiceScreenRec.addGroup(voiceRec);
|
||||||
voiceGroup.addGroup(voiceScreenTTS);
|
if (fonts.getIndividualResources() != null) {
|
||||||
voiceGroup.addGroup(voiceScreenRec);
|
fontScreen.addGroup(fonts);
|
||||||
addGroup(voiceGroup);
|
}
|
||||||
|
otherGroup.addGroup(voiceScreenTTS);
|
||||||
|
otherGroup.addGroup(voiceScreenRec);
|
||||||
|
if (fonts.getIndividualResources() != null) {
|
||||||
|
otherGroup.addGroup(fontScreen);
|
||||||
|
}
|
||||||
|
addGroup(otherGroup);
|
||||||
|
|
||||||
createHillshadeSRTMGroups();
|
createHillshadeSRTMGroups();
|
||||||
trimEmptyGroups();
|
trimEmptyGroups();
|
||||||
|
|
|
@ -30,6 +30,8 @@ public class DownloadGroupViewHolder {
|
||||||
if (group.getType() == DownloadResourceGroup.DownloadResourceGroupType.VOICE_REC
|
if (group.getType() == DownloadResourceGroup.DownloadResourceGroupType.VOICE_REC
|
||||||
|| group.getType() == DownloadResourceGroup.DownloadResourceGroupType.VOICE_TTS) {
|
|| group.getType() == DownloadResourceGroup.DownloadResourceGroupType.VOICE_TTS) {
|
||||||
iconLeft = ctx.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_volume_up);
|
iconLeft = ctx.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_volume_up);
|
||||||
|
} else if (group.getType() == DownloadResourceGroup.DownloadResourceGroupType.FONTS) {
|
||||||
|
iconLeft = ctx.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_map_language);
|
||||||
} else {
|
} else {
|
||||||
IconsCache cache = ctx.getMyApplication().getIconsCache();
|
IconsCache cache = ctx.getMyApplication().getIconsCache();
|
||||||
if (isParentWorld(group) || isParentWorld(group.getParentGroup())) {
|
if (isParentWorld(group) || isParentWorld(group.getParentGroup())) {
|
||||||
|
|
|
@ -308,6 +308,8 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
||||||
if (group.getType() == DownloadResourceGroupType.VOICE_REC
|
if (group.getType() == DownloadResourceGroupType.VOICE_REC
|
||||||
|| group.getType() == DownloadResourceGroupType.VOICE_TTS) {
|
|| group.getType() == DownloadResourceGroupType.VOICE_TTS) {
|
||||||
iconLeft = ctx.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_volume_up);
|
iconLeft = ctx.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_volume_up);
|
||||||
|
} else if (group.getType() == DownloadResourceGroupType.FONTS) {
|
||||||
|
iconLeft = ctx.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_map_language);
|
||||||
} else {
|
} else {
|
||||||
IconsCache cache = ctx.getMyApplication().getIconsCache();
|
IconsCache cache = ctx.getMyApplication().getIconsCache();
|
||||||
if (isParentWorld(group) || isParentWorld(group.getParentGroup())) {
|
if (isParentWorld(group) || isParentWorld(group.getParentGroup())) {
|
||||||
|
|
|
@ -400,6 +400,8 @@ public class ItemViewHolder {
|
||||||
tp = LocalIndexType.SRTM_DATA;
|
tp = LocalIndexType.SRTM_DATA;
|
||||||
} else if (indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE) {
|
} else if (indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE) {
|
||||||
tp = LocalIndexType.MAP_DATA;
|
tp = LocalIndexType.MAP_DATA;
|
||||||
|
} else if (indexItem.getType() == DownloadActivityType.FONT_FILE) {
|
||||||
|
tp = LocalIndexType.FONT_DATA;
|
||||||
} else if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {
|
} else if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {
|
||||||
tp = indexItem.getBasename().contains("tts") ? LocalIndexType.TTS_VOICE_DATA
|
tp = indexItem.getBasename().contains("tts") ? LocalIndexType.TTS_VOICE_DATA
|
||||||
: LocalIndexType.VOICE_DATA;
|
: LocalIndexType.VOICE_DATA;
|
||||||
|
|
|
@ -197,7 +197,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
.setListener(listener)
|
.setListener(listener)
|
||||||
.setPosition(2).createItem());
|
.setPosition(2).createItem());
|
||||||
}
|
}
|
||||||
if (info.getType() != LocalIndexType.TTS_VOICE_DATA && info.getType() != LocalIndexType.VOICE_DATA) {
|
if (info.getType() != LocalIndexType.TTS_VOICE_DATA && info.getType() != LocalIndexType.VOICE_DATA
|
||||||
|
&& info.getType() != LocalIndexType.FONT_DATA) {
|
||||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||||
.setTitleId(R.string.shared_string_rename, getContext())
|
.setTitleId(R.string.shared_string_rename, getContext())
|
||||||
.setListener(listener)
|
.setListener(listener)
|
||||||
|
@ -447,6 +448,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR);
|
parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR);
|
||||||
} else if (i.getOriginalType() == LocalIndexType.VOICE_DATA) {
|
} else if (i.getOriginalType() == LocalIndexType.VOICE_DATA) {
|
||||||
parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR);
|
parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR);
|
||||||
|
} else if (i.getOriginalType() == LocalIndexType.FONT_DATA) {
|
||||||
|
parent = getMyApplication().getAppPath(IndexConstants.FONT_INDEX_DIR);
|
||||||
}
|
}
|
||||||
return new File(parent, i.getFileName());
|
return new File(parent, i.getFileName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -478,7 +478,8 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
||||||
// process other maps & voice prompts
|
// process other maps & voice prompts
|
||||||
if (group.getType() == DownloadResourceGroupType.OTHER_MAPS_HEADER
|
if (group.getType() == DownloadResourceGroupType.OTHER_MAPS_HEADER
|
||||||
|| group.getType() == DownloadResourceGroupType.VOICE_HEADER_REC
|
|| group.getType() == DownloadResourceGroupType.VOICE_HEADER_REC
|
||||||
|| group.getType() == DownloadResourceGroupType.VOICE_HEADER_TTS) {
|
|| group.getType() == DownloadResourceGroupType.VOICE_HEADER_TTS
|
||||||
|
|| group.getType() == DownloadResourceGroupType.FONTS_HEADER) {
|
||||||
if (group.getIndividualResources() != null) {
|
if (group.getIndividualResources() != null) {
|
||||||
for (IndexItem item : group.getIndividualResources()) {
|
for (IndexItem item : group.getIndividualResources()) {
|
||||||
name = item.getVisibleName(ctx, osmandRegions, false).toLowerCase();
|
name = item.getVisibleName(ctx, osmandRegions, false).toLowerCase();
|
||||||
|
|
|
@ -23,9 +23,11 @@ public class FileNameTranslationHelper {
|
||||||
public static String getFileName(Context ctx, OsmandRegions regions, String fileName) {
|
public static String getFileName(Context ctx, OsmandRegions regions, String fileName) {
|
||||||
String basename = getBasename(fileName);
|
String basename = getBasename(fileName);
|
||||||
if (basename.endsWith(WIKI_NAME)) { //wiki files
|
if (basename.endsWith(WIKI_NAME)) { //wiki files
|
||||||
return getWikiName(ctx,basename);
|
return getWikiName(ctx, basename);
|
||||||
} else if (fileName.endsWith("tts")) { //tts files
|
} else if (fileName.endsWith("tts")) { //tts files
|
||||||
return getVoiceName(ctx, fileName);
|
return getVoiceName(ctx, fileName);
|
||||||
|
} else if (fileName.endsWith(IndexConstants.FONT_INDEX_EXT)) { //otf files
|
||||||
|
return getFontName(ctx, basename);
|
||||||
} else if (fileName.startsWith(HILL_SHADE)){
|
} else if (fileName.startsWith(HILL_SHADE)){
|
||||||
return getHillShadeName(ctx, regions, basename);
|
return getHillShadeName(ctx, regions, basename);
|
||||||
} else if (fileName.length() == 2) { //voice recorded files
|
} else if (fileName.length() == 2) { //voice recorded files
|
||||||
|
@ -75,9 +77,9 @@ public class FileNameTranslationHelper {
|
||||||
return wikiName + " " + ctx.getString(R.string.amenity_type_osmwiki);
|
return wikiName + " " + ctx.getString(R.string.amenity_type_osmwiki);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getVoiceName(Context ctx, String basename) {
|
public static String getVoiceName(Context ctx, String fileName) {
|
||||||
try {
|
try {
|
||||||
String nm = basename.replace('-', '_').replace(' ', '_');
|
String nm = fileName.replace('-', '_').replace(' ', '_');
|
||||||
if (nm.endsWith("_tts") || nm.endsWith("-tts")) {
|
if (nm.endsWith("_tts") || nm.endsWith("-tts")) {
|
||||||
nm = nm.substring(0, nm.length() - 4);
|
nm = nm.substring(0, nm.length() - 4);
|
||||||
}
|
}
|
||||||
|
@ -89,7 +91,11 @@ public class FileNameTranslationHelper {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println(e.getMessage());
|
System.err.println(e.getMessage());
|
||||||
}
|
}
|
||||||
return basename;
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getFontName(Context ctx, String basename) {
|
||||||
|
return basename.replace('-', ' ').replace('_', ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getBasename(String fileName) {
|
private static String getBasename(String fileName) {
|
||||||
|
|
|
@ -513,6 +513,8 @@ public class MapDataMenuController extends MenuController {
|
||||||
} else if (localIndexInfo.getOriginalType() == LocalIndexType.TTS_VOICE_DATA
|
} else if (localIndexInfo.getOriginalType() == LocalIndexType.TTS_VOICE_DATA
|
||||||
|| localIndexInfo.getOriginalType() == LocalIndexType.VOICE_DATA) {
|
|| localIndexInfo.getOriginalType() == LocalIndexType.VOICE_DATA) {
|
||||||
return DownloadActivityType.VOICE_FILE;
|
return DownloadActivityType.VOICE_FILE;
|
||||||
|
} else if (localIndexInfo.getOriginalType() == LocalIndexType.FONT_DATA) {
|
||||||
|
return DownloadActivityType.FONT_FILE;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -506,6 +506,7 @@ public class ResourceManager {
|
||||||
// indexingImageTiles(progress);
|
// indexingImageTiles(progress);
|
||||||
warnings.addAll(indexingMaps(progress));
|
warnings.addAll(indexingMaps(progress));
|
||||||
warnings.addAll(indexVoiceFiles(progress));
|
warnings.addAll(indexVoiceFiles(progress));
|
||||||
|
warnings.addAll(indexFontFiles(progress));
|
||||||
warnings.addAll(OsmandPlugin.onIndexingFiles(progress));
|
warnings.addAll(OsmandPlugin.onIndexingFiles(progress));
|
||||||
warnings.addAll(indexAdditionalMaps(progress));
|
warnings.addAll(indexAdditionalMaps(progress));
|
||||||
return warnings;
|
return warnings;
|
||||||
|
@ -539,6 +540,23 @@ public class ResourceManager {
|
||||||
return warnings;
|
return warnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> indexFontFiles(IProgress progress){
|
||||||
|
File file = context.getAppPath(IndexConstants.FONT_INDEX_DIR);
|
||||||
|
file.mkdirs();
|
||||||
|
List<String> warnings = new ArrayList<String>();
|
||||||
|
if (file.exists() && file.canRead()) {
|
||||||
|
File[] lf = file.listFiles();
|
||||||
|
if (lf != null) {
|
||||||
|
for (File f : lf) {
|
||||||
|
if (!f.isDirectory()) {
|
||||||
|
indexFileNames.put(f.getName(), dateFormat.format(f.lastModified()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return warnings;
|
||||||
|
}
|
||||||
|
|
||||||
private List<String> checkAssets(IProgress progress) {
|
private List<String> checkAssets(IProgress progress) {
|
||||||
String fv = Version.getFullVersion(context);
|
String fv = Version.getFullVersion(context);
|
||||||
if (!fv.equalsIgnoreCase(context.getSettings().PREVIOUS_INSTALLED_VERSION.get())) {
|
if (!fv.equalsIgnoreCase(context.getSettings().PREVIOUS_INSTALLED_VERSION.get())) {
|
||||||
|
|
Loading…
Reference in a new issue