Merge branch 'r3.7' of github.com:osmandapp/Osmand into r3.7
This commit is contained in:
commit
ae10663f55
11 changed files with 427 additions and 460 deletions
|
@ -203,8 +203,7 @@ public class MapPoiTypes {
|
||||||
|
|
||||||
public Map<String, PoiType> getAllTranslatedNames(boolean skipNonEditable) {
|
public Map<String, PoiType> getAllTranslatedNames(boolean skipNonEditable) {
|
||||||
Map<String, PoiType> translation = new HashMap<String, PoiType>();
|
Map<String, PoiType> translation = new HashMap<String, PoiType>();
|
||||||
for (int i = 0; i < categories.size(); i++) {
|
for (PoiCategory pc : categories) {
|
||||||
PoiCategory pc = categories.get(i);
|
|
||||||
if (skipNonEditable && pc.isNotEditableOsm()) {
|
if (skipNonEditable && pc.isNotEditableOsm()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -298,12 +297,18 @@ public class MapPoiTypes {
|
||||||
if (!lastCategory.getKeyName().equals("Other")) {
|
if (!lastCategory.getKeyName().equals("Other")) {
|
||||||
lastCategory.setTopVisible(true);
|
lastCategory.setTopVisible(true);
|
||||||
}
|
}
|
||||||
categories.add(lastCategory);
|
addCategory(lastCategory);
|
||||||
return lastCategory;
|
return lastCategory;
|
||||||
}
|
}
|
||||||
return otherCategory;
|
return otherCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addCategory(PoiCategory category) {
|
||||||
|
List<PoiCategory> copy = new ArrayList<>(categories);
|
||||||
|
copy.add(category);
|
||||||
|
categories = copy;
|
||||||
|
}
|
||||||
|
|
||||||
public PoiTranslator getPoiTranslator() {
|
public PoiTranslator getPoiTranslator() {
|
||||||
return poiTranslator;
|
return poiTranslator;
|
||||||
}
|
}
|
||||||
|
@ -348,7 +353,7 @@ public class MapPoiTypes {
|
||||||
final Map<String, PoiType> allTypes = new LinkedHashMap<String, PoiType>();
|
final Map<String, PoiType> allTypes = new LinkedHashMap<String, PoiType>();
|
||||||
final Map<String, List<PoiType>> categoryPoiAdditionalMap = new LinkedHashMap<String, List<PoiType>>();
|
final Map<String, List<PoiType>> categoryPoiAdditionalMap = new LinkedHashMap<String, List<PoiType>>();
|
||||||
final Map<AbstractPoiType, Set<String>> abstractTypeAdditionalCategories = new LinkedHashMap<AbstractPoiType, Set<String>>();
|
final Map<AbstractPoiType, Set<String>> abstractTypeAdditionalCategories = new LinkedHashMap<AbstractPoiType, Set<String>>();
|
||||||
this.categories.clear();
|
List<PoiCategory> categoriesList = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
XmlPullParser parser = PlatformUtil.newXMLPullParser();
|
XmlPullParser parser = PlatformUtil.newXMLPullParser();
|
||||||
int tok;
|
int tok;
|
||||||
|
@ -364,7 +369,7 @@ public class MapPoiTypes {
|
||||||
if (tok == XmlPullParser.START_TAG) {
|
if (tok == XmlPullParser.START_TAG) {
|
||||||
String name = parser.getName();
|
String name = parser.getName();
|
||||||
if (name.equals("poi_category")) {
|
if (name.equals("poi_category")) {
|
||||||
lastCategory = new PoiCategory(this, parser.getAttributeValue("", "name"), categories.size());
|
lastCategory = new PoiCategory(this, parser.getAttributeValue("", "name"), categoriesList.size());
|
||||||
lastCategory.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
|
lastCategory.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
|
||||||
lastCategory.setNotEditableOsm("true".equals(parser.getAttributeValue("", "no_edit")));
|
lastCategory.setNotEditableOsm("true".equals(parser.getAttributeValue("", "no_edit")));
|
||||||
lastCategory.setDefaultTag(parser.getAttributeValue("", "default_tag"));
|
lastCategory.setDefaultTag(parser.getAttributeValue("", "default_tag"));
|
||||||
|
@ -375,7 +380,7 @@ public class MapPoiTypes {
|
||||||
lastCategory.addExcludedPoiAdditionalCategories(parser.getAttributeValue("", "excluded_poi_additional_category").split(","));
|
lastCategory.addExcludedPoiAdditionalCategories(parser.getAttributeValue("", "excluded_poi_additional_category").split(","));
|
||||||
lastCategoryPoiAdditionalsCategories.removeAll(lastCategory.getExcludedPoiAdditionalCategories());
|
lastCategoryPoiAdditionalsCategories.removeAll(lastCategory.getExcludedPoiAdditionalCategories());
|
||||||
}
|
}
|
||||||
categories.add(lastCategory);
|
categoriesList.add(lastCategory);
|
||||||
} else if (name.equals("poi_filter")) {
|
} else if (name.equals("poi_filter")) {
|
||||||
PoiFilter tp = new PoiFilter(this, lastCategory, parser.getAttributeValue("", "name"));
|
PoiFilter tp = new PoiFilter(this, lastCategory, parser.getAttributeValue("", "name"));
|
||||||
tp.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
|
tp.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
|
||||||
|
@ -477,6 +482,7 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
categories = categoriesList;
|
||||||
is.close();
|
is.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Unexpected error", e); //$NON-NLS-1$
|
log.error("Unexpected error", e); //$NON-NLS-1$
|
||||||
|
|
|
@ -90,9 +90,11 @@ public class Algorithms {
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getFileNameWithoutExtension(File f) {
|
public static String getFileNameWithoutExtension(File f) {
|
||||||
String name = f.getName();
|
return getFileNameWithoutExtension(f.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getFileNameWithoutExtension(String name) {
|
||||||
int i = name.indexOf('.');
|
int i = name.indexOf('.');
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
name = name.substring(0, i);
|
name = name.substring(0, i);
|
||||||
|
@ -250,6 +252,32 @@ public class Algorithms {
|
||||||
return test == 0x504b0304;
|
return test == 0x504b0304;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks, whether the child directory is a subdirectory of the parent
|
||||||
|
* directory.
|
||||||
|
*
|
||||||
|
* @param parent the parent directory.
|
||||||
|
* @param child the suspected child directory.
|
||||||
|
* @return true if the child is a subdirectory of the parent directory.
|
||||||
|
*/
|
||||||
|
public static boolean isSubDirectory(File parent, File child) {
|
||||||
|
try {
|
||||||
|
parent = parent.getCanonicalFile();
|
||||||
|
child = child.getCanonicalFile();
|
||||||
|
|
||||||
|
File dir = child;
|
||||||
|
while (dir != null) {
|
||||||
|
if (parent.equals(dir)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
dir = dir.getParentFile();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static int readInt(InputStream in) throws IOException {
|
private static int readInt(InputStream in) throws IOException {
|
||||||
int ch1 = in.read();
|
int ch1 = in.read();
|
||||||
int ch2 = in.read();
|
int ch2 = in.read();
|
||||||
|
|
|
@ -1,19 +1,14 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<inset>
|
<inset>
|
||||||
<shape android:shape="oval" >
|
<shape android:shape="oval">
|
||||||
<solid android:color="@color/feature_purchased_bg" />
|
<solid android:color="@color/feature_purchased_bg" />
|
||||||
</shape>
|
</shape>
|
||||||
</inset>
|
</inset>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item android:drawable="@drawable/ic_action_marker_passed" />
|
||||||
<bitmap
|
|
||||||
android:gravity="center"
|
|
||||||
android:src="@drawable/ic_action_marker_passed" />
|
|
||||||
</item>
|
|
||||||
|
|
||||||
|
|
||||||
</layer-list>
|
</layer-list>
|
|
@ -1,23 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item>
|
|
||||||
<shape android:shape="oval">
|
|
||||||
<solid android:color="@color/color_transparent"/>
|
|
||||||
<size
|
|
||||||
android:width="28dp"
|
|
||||||
android:height="28dp"/>
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/placeholder_icon"
|
android:id="@+id/placeholder_icon"
|
||||||
android:bottom="2dp"
|
android:bottom="2dp"
|
||||||
|
android:drawable="@drawable/ic_action_history"
|
||||||
android:left="2dp"
|
android:left="2dp"
|
||||||
android:right="2dp"
|
android:right="2dp"
|
||||||
android:top="2dp">
|
android:top="2dp" />
|
||||||
|
|
||||||
<bitmap
|
|
||||||
android:gravity="center"
|
|
||||||
android:src="@drawable/ic_action_history"
|
|
||||||
android:tint="@color/icon_color_default_light"/>
|
|
||||||
</item>
|
|
||||||
</layer-list>
|
</layer-list>
|
|
@ -2,22 +2,20 @@
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item>
|
<item>
|
||||||
<shape android:shape="oval">
|
<shape android:shape="oval">
|
||||||
<solid android:color="@color/color_transparent"/>
|
<solid android:color="@color/color_transparent" />
|
||||||
<size
|
<size
|
||||||
android:width="28dp"
|
android:width="28dp"
|
||||||
android:height="28dp"/>
|
android:height="28dp" />
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/placeholder_icon"
|
android:id="@+id/placeholder_icon"
|
||||||
android:bottom="2dp"
|
android:bottom="2dp"
|
||||||
|
android:drawable="@drawable/ic_action_placeholder_city"
|
||||||
android:left="2dp"
|
android:left="2dp"
|
||||||
android:right="2dp"
|
android:right="2dp"
|
||||||
android:top="2dp">
|
android:tint="@color/icon_color_default_light"
|
||||||
|
android:top="2dp" />
|
||||||
|
|
||||||
<bitmap
|
|
||||||
android:gravity="center"
|
|
||||||
android:src="@drawable/ic_action_placeholder_city"
|
|
||||||
android:tint="@color/icon_color_default_light"/>
|
|
||||||
</item>
|
|
||||||
</layer-list>
|
</layer-list>
|
|
@ -10,7 +10,9 @@
|
||||||
- For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
- For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
--> <string name="index_item_world_basemap_detailed">World overview map (detailed)</string>
|
-->
|
||||||
|
<string name="unsupported_type_error">Unsupported type</string>
|
||||||
|
<string name="index_item_world_basemap_detailed">World overview map (detailed)</string>
|
||||||
<string name="profiles_for_action_not_found">Could not find any such profiles.</string>
|
<string name="profiles_for_action_not_found">Could not find any such profiles.</string>
|
||||||
<string name="change_application_profile">Change app profile</string>
|
<string name="change_application_profile">Change app profile</string>
|
||||||
<string name="shared_string_add_profile">Add profile</string>
|
<string name="shared_string_add_profile">Add profile</string>
|
||||||
|
|
|
@ -101,7 +101,7 @@ import net.osmand.plus.firstusage.FirstUsageWizardFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.helpers.DiscountHelper;
|
import net.osmand.plus.helpers.DiscountHelper;
|
||||||
import net.osmand.plus.helpers.ImportHelper;
|
import net.osmand.plus.helpers.ImportHelper;
|
||||||
import net.osmand.plus.helpers.ImportHelper.ImportGpxBottomSheetDialogFragment;
|
import net.osmand.plus.dialogs.ImportGpxBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.IntentHelper;
|
import net.osmand.plus.helpers.IntentHelper;
|
||||||
import net.osmand.plus.helpers.LockHelper;
|
import net.osmand.plus.helpers.LockHelper;
|
||||||
import net.osmand.plus.helpers.LockHelper.LockUIAdapter;
|
import net.osmand.plus.helpers.LockHelper.LockUIAdapter;
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
package net.osmand.plus.dialogs;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.style.ForegroundColorSpan;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||||
|
import net.osmand.plus.helpers.ImportHelper;
|
||||||
|
|
||||||
|
public class ImportGpxBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
public static final String TAG = "ImportGpxBottomSheetDialogFragment";
|
||||||
|
|
||||||
|
private ImportHelper importHelper;
|
||||||
|
|
||||||
|
private GPXFile gpxFile;
|
||||||
|
private String fileName;
|
||||||
|
private boolean save;
|
||||||
|
private boolean useImportDir;
|
||||||
|
|
||||||
|
public void setImportHelper(ImportHelper importHelper) {
|
||||||
|
this.importHelper = importHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGpxFile(GPXFile gpxFile) {
|
||||||
|
this.gpxFile = gpxFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileName(String fileName) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSave(boolean save) {
|
||||||
|
this.save = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUseImportDir(boolean useImportDir) {
|
||||||
|
this.useImportDir = useImportDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
|
items.add(new TitleItem(getString(R.string.import_file)));
|
||||||
|
|
||||||
|
int nameColor = getResolvedColor(nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
|
||||||
|
int descrColor = getResolvedColor(nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light);
|
||||||
|
String descr = getString(R.string.import_gpx_file_description);
|
||||||
|
if (!descr.contains("%s")) {
|
||||||
|
descr = "%s " + descr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CharSequence txt = AndroidUtils.getStyledString(descr, fileName, new ForegroundColorSpan(descrColor),
|
||||||
|
new ForegroundColorSpan(nameColor));
|
||||||
|
items.add(new ShortDescriptionItem(txt));
|
||||||
|
|
||||||
|
BaseBottomSheetItem asFavoritesItem = new SimpleBottomSheetItem.Builder()
|
||||||
|
.setIcon(getContentIcon(R.drawable.ic_action_favorite))
|
||||||
|
.setTitle(getString(R.string.import_as_favorites))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||||
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
importHelper.importFavoritesFromGpx(gpxFile, fileName);
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create();
|
||||||
|
items.add(asFavoritesItem);
|
||||||
|
|
||||||
|
items.add(new DividerHalfItem(getContext()));
|
||||||
|
|
||||||
|
BaseBottomSheetItem asGpxItem = new SimpleBottomSheetItem.Builder()
|
||||||
|
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
|
||||||
|
.setTitle(getString(R.string.import_as_gpx))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||||
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
importHelper.handleGpxImport(gpxFile, fileName, save, useImportDir);
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create();
|
||||||
|
items.add(asGpxItem);
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,8 +12,6 @@ import android.os.Bundle;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.provider.OpenableColumns;
|
import android.provider.OpenableColumns;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.style.ForegroundColorSpan;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -33,14 +31,17 @@ import net.osmand.PlatformUtil;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.FavouritePoint.BackgroundType;
|
import net.osmand.data.FavouritePoint.BackgroundType;
|
||||||
import net.osmand.plus.AppInitializer;
|
import net.osmand.plus.AppInitializer;
|
||||||
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
|
||||||
import net.osmand.plus.AppInitializer.InitEvents;
|
|
||||||
import net.osmand.plus.CustomOsmandPlugin;
|
import net.osmand.plus.CustomOsmandPlugin;
|
||||||
import net.osmand.plus.FavouritesDbHelper;
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
import net.osmand.plus.GPXDatabase;
|
import net.osmand.plus.GPXDatabase;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.ActivityResultListener;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.activities.TrackActivity;
|
||||||
|
import net.osmand.plus.dialogs.ImportGpxBottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||||
import net.osmand.plus.settings.backend.SettingsHelper;
|
import net.osmand.plus.settings.backend.SettingsHelper;
|
||||||
import net.osmand.plus.settings.backend.SettingsHelper.CheckDuplicatesListener;
|
import net.osmand.plus.settings.backend.SettingsHelper.CheckDuplicatesListener;
|
||||||
import net.osmand.plus.settings.backend.SettingsHelper.PluginSettingsItem;
|
import net.osmand.plus.settings.backend.SettingsHelper.PluginSettingsItem;
|
||||||
|
@ -48,22 +49,14 @@ import net.osmand.plus.settings.backend.SettingsHelper.ProfileSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.SettingsHelper.SettingsCollectListener;
|
import net.osmand.plus.settings.backend.SettingsHelper.SettingsCollectListener;
|
||||||
import net.osmand.plus.settings.backend.SettingsHelper.SettingsImportListener;
|
import net.osmand.plus.settings.backend.SettingsHelper.SettingsImportListener;
|
||||||
import net.osmand.plus.settings.backend.SettingsHelper.SettingsItem;
|
import net.osmand.plus.settings.backend.SettingsHelper.SettingsItem;
|
||||||
import net.osmand.plus.activities.ActivityResultListener;
|
|
||||||
import net.osmand.plus.activities.MapActivity;
|
|
||||||
import net.osmand.plus.activities.TrackActivity;
|
|
||||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
|
||||||
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
|
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem;
|
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
|
||||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
|
||||||
import net.osmand.plus.settings.fragments.ImportSettingsFragment;
|
import net.osmand.plus.settings.fragments.ImportSettingsFragment;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.router.RoutingConfiguration;
|
import net.osmand.router.RoutingConfiguration;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -109,7 +102,8 @@ public class ImportHelper {
|
||||||
|
|
||||||
public enum ImportType {
|
public enum ImportType {
|
||||||
SETTINGS(OSMAND_SETTINGS_FILE_EXT),
|
SETTINGS(OSMAND_SETTINGS_FILE_EXT),
|
||||||
ROUTING(ROUTING_FILE_EXT);
|
ROUTING(ROUTING_FILE_EXT),
|
||||||
|
RENDERING(RENDERER_INDEX_EXT);
|
||||||
|
|
||||||
ImportType(String extension) {
|
ImportType(String extension) {
|
||||||
this.extension = extension;
|
this.extension = extension;
|
||||||
|
@ -141,21 +135,29 @@ public class ImportHelper {
|
||||||
handleFileImport(contentUri, name, extras, useImportDir);
|
handleFileImport(contentUri, name, extras, useImportDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void importFavoritesFromGpx(final GPXFile gpxFile, final String fileName) {
|
||||||
|
importFavoritesImpl(gpxFile, fileName, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleGpxImport(GPXFile result, String name, boolean save, boolean useImportDir) {
|
||||||
|
handleResult(result, name, save, useImportDir, false);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean handleGpxImport(final Uri contentUri, final boolean useImportDir) {
|
public boolean handleGpxImport(final Uri contentUri, final boolean useImportDir) {
|
||||||
String name = getNameFromContentUri(app, contentUri);
|
String name = getNameFromContentUri(app, contentUri);
|
||||||
boolean isOsmandSubdir = isSubDirectory(app.getAppPath(IndexConstants.GPX_INDEX_DIR), new File(contentUri.getPath()));
|
boolean isOsmandSubdir = Algorithms.isSubDirectory(app.getAppPath(IndexConstants.GPX_INDEX_DIR), new File(contentUri.getPath()));
|
||||||
if (!isOsmandSubdir && name != null) {
|
if (!isOsmandSubdir && name != null) {
|
||||||
String nameLC = name.toLowerCase();
|
String nameLC = name.toLowerCase();
|
||||||
if (nameLC.endsWith(GPX_FILE_EXT)) {
|
if (nameLC.endsWith(GPX_FILE_EXT)) {
|
||||||
name = name.substring(0, name.length() - 4) + GPX_FILE_EXT;
|
name = name.substring(0, name.length() - GPX_FILE_EXT.length()) + GPX_FILE_EXT;
|
||||||
handleGpxImport(contentUri, name, true, useImportDir);
|
handleGpxImport(contentUri, name, true, useImportDir);
|
||||||
return true;
|
return true;
|
||||||
} else if (nameLC.endsWith(KML_SUFFIX)) {
|
} else if (nameLC.endsWith(KML_SUFFIX)) {
|
||||||
name = name.substring(0, name.length() - 4) + KML_SUFFIX;
|
name = name.substring(0, name.length() - KML_SUFFIX.length()) + KML_SUFFIX;
|
||||||
handleKmlImport(contentUri, name, true, useImportDir);
|
handleKmlImport(contentUri, name, true, useImportDir);
|
||||||
return true;
|
return true;
|
||||||
} else if (nameLC.endsWith(KMZ_SUFFIX)) {
|
} else if (nameLC.endsWith(KMZ_SUFFIX)) {
|
||||||
name = name.substring(0, name.length() - 4) + KMZ_SUFFIX;
|
name = name.substring(0, name.length() - KMZ_SUFFIX.length()) + KMZ_SUFFIX;
|
||||||
handleKmzImport(contentUri, name, true, useImportDir);
|
handleKmzImport(contentUri, name, true, useImportDir);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +169,7 @@ public class ImportHelper {
|
||||||
String scheme = uri.getScheme();
|
String scheme = uri.getScheme();
|
||||||
boolean isFileIntent = "file".equals(scheme);
|
boolean isFileIntent = "file".equals(scheme);
|
||||||
boolean isContentIntent = "content".equals(scheme);
|
boolean isContentIntent = "content".equals(scheme);
|
||||||
boolean isOsmandSubdir = isSubDirectory(app.getAppPath(IndexConstants.GPX_INDEX_DIR), new File(uri.getPath()));
|
boolean isOsmandSubdir = Algorithms.isSubDirectory(app.getAppPath(IndexConstants.GPX_INDEX_DIR), new File(uri.getPath()));
|
||||||
final boolean saveFile = !isFileIntent || !isOsmandSubdir;
|
final boolean saveFile = !isFileIntent || !isOsmandSubdir;
|
||||||
String fileName = "";
|
String fileName = "";
|
||||||
if (isFileIntent) {
|
if (isFileIntent) {
|
||||||
|
@ -180,7 +182,7 @@ public class ImportHelper {
|
||||||
|
|
||||||
public void handleFileImport(Uri intentUri, String fileName, Bundle extras, boolean useImportDir) {
|
public void handleFileImport(Uri intentUri, String fileName, Bundle extras, boolean useImportDir) {
|
||||||
final boolean isFileIntent = "file".equals(intentUri.getScheme());
|
final boolean isFileIntent = "file".equals(intentUri.getScheme());
|
||||||
final boolean isOsmandSubdir = isSubDirectory(app.getAppPath(IndexConstants.GPX_INDEX_DIR), new File(intentUri.getPath()));
|
final boolean isOsmandSubdir = Algorithms.isSubDirectory(app.getAppPath(IndexConstants.GPX_INDEX_DIR), new File(intentUri.getPath()));
|
||||||
|
|
||||||
final boolean saveFile = !isFileIntent || !isOsmandSubdir;
|
final boolean saveFile = !isFileIntent || !isOsmandSubdir;
|
||||||
|
|
||||||
|
@ -194,10 +196,8 @@ public class ImportHelper {
|
||||||
handleSqliteTileImport(intentUri, fileName);
|
handleSqliteTileImport(intentUri, fileName);
|
||||||
} else if (fileName != null && fileName.endsWith(OSMAND_SETTINGS_FILE_EXT)) {
|
} else if (fileName != null && fileName.endsWith(OSMAND_SETTINGS_FILE_EXT)) {
|
||||||
handleOsmAndSettingsImport(intentUri, fileName, extras, null);
|
handleOsmAndSettingsImport(intentUri, fileName, extras, null);
|
||||||
} else if (fileName != null && fileName.endsWith(RENDERER_INDEX_EXT)) {
|
|
||||||
handleRenderingFileImport(intentUri, fileName);
|
|
||||||
} else if (fileName != null && fileName.endsWith(ROUTING_FILE_EXT)) {
|
} else if (fileName != null && fileName.endsWith(ROUTING_FILE_EXT)) {
|
||||||
handleRoutingFileImport(intentUri, fileName, null);
|
handleXmlFileImport(intentUri, fileName, null);
|
||||||
} else {
|
} else {
|
||||||
handleFavouritesImport(intentUri, fileName, saveFile, useImportDir, false);
|
handleFavouritesImport(intentUri, fileName, saveFile, useImportDir, false);
|
||||||
}
|
}
|
||||||
|
@ -338,8 +338,7 @@ public class ImportHelper {
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private void importFavoritesImpl(final GPXFile gpxFile, final String fileName, final boolean forceImportFavourites) {
|
private void importFavoritesImpl(final GPXFile gpxFile, final String fileName, final boolean forceImportFavourites) {
|
||||||
if(!app.isApplicationInitializing()) {
|
final AsyncTask<Void, Void, GPXFile> favoritesImportTask = new AsyncTask<Void, Void, GPXFile>() {
|
||||||
new AsyncTask<Void, Void, GPXFile>() {
|
|
||||||
ProgressDialog progress = null;
|
ProgressDialog progress = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -369,27 +368,15 @@ public class ImportHelper {
|
||||||
if (progress != null && AndroidUtils.isActivityNotDestroyed(activity)) {
|
if (progress != null && AndroidUtils.isActivityNotDestroyed(activity)) {
|
||||||
progress.dismiss();
|
progress.dismiss();
|
||||||
}
|
}
|
||||||
Toast.makeText(activity, R.string.fav_imported_sucessfully, Toast.LENGTH_LONG)
|
Toast.makeText(activity, R.string.fav_imported_sucessfully, Toast.LENGTH_LONG).show();
|
||||||
.show();
|
|
||||||
final Intent newIntent = new Intent(activity,
|
final Intent newIntent = new Intent(activity,
|
||||||
app.getAppCustomization().getFavoritesActivity());
|
app.getAppCustomization().getFavoritesActivity());
|
||||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
newIntent.putExtra(TAB_ID, FAV_TAB);
|
newIntent.putExtra(TAB_ID, FAV_TAB);
|
||||||
activity.startActivity(newIntent);
|
activity.startActivity(newIntent);
|
||||||
}
|
}
|
||||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
};
|
||||||
} else {
|
executeImportTask(favoritesImportTask);
|
||||||
app.getAppInitializer().addListener(new AppInitializeListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProgress(AppInitializer init, InitEvents event) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFinish(AppInitializer init) {
|
|
||||||
importFavoritesImpl(gpxFile, fileName, forceImportFavourites);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
|
@ -660,7 +647,7 @@ public class ImportHelper {
|
||||||
if (importType.equals(ImportType.SETTINGS)) {
|
if (importType.equals(ImportType.SETTINGS)) {
|
||||||
handleOsmAndSettingsImport(data, fileName, resultData.getExtras(), callback);
|
handleOsmAndSettingsImport(data, fileName, resultData.getExtras(), callback);
|
||||||
} else if (importType.equals(ImportType.ROUTING)){
|
} else if (importType.equals(ImportType.ROUTING)){
|
||||||
handleRoutingFileImport(data, fileName, callback);
|
handleXmlFileImport(data, fileName, callback);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app.showToastMessage(app.getString(R.string.not_support_file_type_with_ext,
|
app.showToastMessage(app.getString(R.string.not_support_file_type_with_ext,
|
||||||
|
@ -674,81 +661,6 @@ public class ImportHelper {
|
||||||
mapActivity.startActivityForResult(intent, IMPORT_FILE_REQUEST);
|
mapActivity.startActivityForResult(intent, IMPORT_FILE_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
|
||||||
private void handleRoutingFileImport(final Uri uri, final String fileName, final CallbackWithObject<RoutingConfiguration.Builder> callback) {
|
|
||||||
final AsyncTask<Void, Void, String> routingImportTask = new AsyncTask<Void, Void, String>() {
|
|
||||||
|
|
||||||
String mFileName;
|
|
||||||
ProgressDialog progress;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPreExecute() {
|
|
||||||
if (AndroidUtils.isActivityNotDestroyed(activity)) {
|
|
||||||
progress = ProgressDialog.show(activity, app.getString(R.string.loading_smth, ""), app.getString(R.string.loading_data));
|
|
||||||
}
|
|
||||||
mFileName = fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String doInBackground(Void... voids) {
|
|
||||||
File routingDir = app.getAppPath(IndexConstants.ROUTING_PROFILES_DIR);
|
|
||||||
if (!routingDir.exists()) {
|
|
||||||
routingDir.mkdirs();
|
|
||||||
}
|
|
||||||
File dest = new File(routingDir, mFileName);
|
|
||||||
while (dest.exists()) {
|
|
||||||
mFileName = AndroidUtils.createNewFileName(mFileName);
|
|
||||||
dest = new File(routingDir, mFileName);
|
|
||||||
}
|
|
||||||
return copyFile(app, dest, uri, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostExecute(String error) {
|
|
||||||
File routingDir = app.getAppPath(IndexConstants.ROUTING_PROFILES_DIR);
|
|
||||||
final File file = new File(routingDir, mFileName);
|
|
||||||
if (error == null && file.exists()) {
|
|
||||||
loadRoutingFiles(app, new AppInitializer.LoadRoutingFilesCallback() {
|
|
||||||
@Override
|
|
||||||
public void onRoutingFilesLoaded() {
|
|
||||||
if (progress != null && AndroidUtils.isActivityNotDestroyed(activity)) {
|
|
||||||
progress.dismiss();
|
|
||||||
}
|
|
||||||
RoutingConfiguration.Builder builder = app.getCustomRoutingConfig(mFileName);
|
|
||||||
if (builder != null) {
|
|
||||||
app.showShortToastMessage(app.getString(R.string.file_imported_successfully, mFileName));
|
|
||||||
if (callback != null) {
|
|
||||||
callback.processResult(builder);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
app.showToastMessage(app.getString(R.string.file_does_not_contain_routing_rules, mFileName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (progress != null && AndroidUtils.isActivityNotDestroyed(activity)) {
|
|
||||||
progress.dismiss();
|
|
||||||
}
|
|
||||||
app.showShortToastMessage(app.getString(R.string.file_import_error, mFileName, error));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (app.isApplicationInitializing()) {
|
|
||||||
app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() {
|
|
||||||
@Override
|
|
||||||
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFinish(AppInitializer init) {
|
|
||||||
routingImportTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
routingImportTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleOsmAndSettingsImport(Uri intentUri, String fileName, Bundle extras, CallbackWithObject<List<SettingsItem>> callback) {
|
private void handleOsmAndSettingsImport(Uri intentUri, String fileName, Bundle extras, CallbackWithObject<List<SettingsItem>> callback) {
|
||||||
if (extras != null && extras.containsKey(SettingsHelper.SETTINGS_VERSION_KEY) && extras.containsKey(SettingsHelper.SETTINGS_LATEST_CHANGES_KEY)) {
|
if (extras != null && extras.containsKey(SettingsHelper.SETTINGS_VERSION_KEY) && extras.containsKey(SettingsHelper.SETTINGS_LATEST_CHANGES_KEY)) {
|
||||||
int version = extras.getInt(SettingsHelper.SETTINGS_VERSION_KEY, -1);
|
int version = extras.getInt(SettingsHelper.SETTINGS_VERSION_KEY, -1);
|
||||||
|
@ -824,20 +736,7 @@ public class ImportHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (app.isApplicationInitializing()) {
|
executeImportTask(settingsImportTask);
|
||||||
app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() {
|
|
||||||
@Override
|
|
||||||
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFinish(AppInitializer init) {
|
|
||||||
settingsImportTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
settingsImportTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePluginImport(final PluginSettingsItem pluginItem, final File file) {
|
private void handlePluginImport(final PluginSettingsItem pluginItem, final File file) {
|
||||||
|
@ -896,63 +795,141 @@ public class ImportHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private void handleRenderingFileImport(final Uri intentUri, final String fileName) {
|
private void handleXmlFileImport(final Uri intentUri, final String fileName,
|
||||||
|
final CallbackWithObject routingCallback) {
|
||||||
final AsyncTask<Void, Void, String> renderingImportTask = new AsyncTask<Void, Void, String>() {
|
final AsyncTask<Void, Void, String> renderingImportTask = new AsyncTask<Void, Void, String>() {
|
||||||
|
|
||||||
String mFileName;
|
private String destFileName;
|
||||||
ProgressDialog progress;
|
private ImportType importType;
|
||||||
|
private ProgressDialog progress;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
if (AndroidUtils.isActivityNotDestroyed(activity)) {
|
if (AndroidUtils.isActivityNotDestroyed(activity)) {
|
||||||
progress = ProgressDialog.show(activity, app.getString(R.string.loading_smth, ""), app.getString(R.string.loading_data));
|
progress = ProgressDialog.show(activity, app.getString(R.string.loading_smth, ""), app.getString(R.string.loading_data));
|
||||||
}
|
}
|
||||||
mFileName = fileName;
|
destFileName = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String doInBackground(Void... voids) {
|
protected String doInBackground(Void... voids) {
|
||||||
File renderingDir = app.getAppPath(IndexConstants.RENDERERS_DIR);
|
checkImportType();
|
||||||
if (!renderingDir.exists()) {
|
if (importType != null) {
|
||||||
renderingDir.mkdirs();
|
File dest = getDestinationFile();
|
||||||
}
|
if (dest != null) {
|
||||||
File dest = new File(renderingDir, mFileName);
|
|
||||||
while (dest.exists()) {
|
|
||||||
mFileName = AndroidUtils.createNewFileName(mFileName);
|
|
||||||
dest = new File(renderingDir, mFileName);
|
|
||||||
}
|
|
||||||
return copyFile(app, dest, intentUri, true);
|
return copyFile(app, dest, intentUri, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return app.getString(R.string.file_import_error, destFileName, app.getString(R.string.unsupported_type_error));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(String error) {
|
protected void onPostExecute(String error) {
|
||||||
File renderingDir = app.getAppPath(IndexConstants.RENDERERS_DIR);
|
File destDir = getDestinationDir();
|
||||||
File file = new File(renderingDir, mFileName);
|
File file = new File(destDir, destFileName);
|
||||||
if (error == null && file.exists()) {
|
if (error == null && file.exists()) {
|
||||||
|
if (importType == ImportType.RENDERING) {
|
||||||
app.getRendererRegistry().updateExternalRenderers();
|
app.getRendererRegistry().updateExternalRenderers();
|
||||||
app.showShortToastMessage(app.getString(R.string.file_imported_successfully, mFileName));
|
app.showShortToastMessage(app.getString(R.string.file_imported_successfully, destFileName));
|
||||||
} else {
|
hideProgress();
|
||||||
app.showShortToastMessage(app.getString(R.string.file_import_error, mFileName, error));
|
} else if (importType == ImportType.ROUTING) {
|
||||||
|
loadRoutingFiles(app, new AppInitializer.LoadRoutingFilesCallback() {
|
||||||
|
@Override
|
||||||
|
public void onRoutingFilesLoaded() {
|
||||||
|
hideProgress();
|
||||||
|
RoutingConfiguration.Builder builder = app.getCustomRoutingConfig(destFileName);
|
||||||
|
if (builder != null) {
|
||||||
|
if (routingCallback != null) {
|
||||||
|
routingCallback.processResult(builder);
|
||||||
}
|
}
|
||||||
|
app.showShortToastMessage(app.getString(R.string.file_imported_successfully, destFileName));
|
||||||
|
} else {
|
||||||
|
app.showToastMessage(app.getString(R.string.file_does_not_contain_routing_rules, destFileName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hideProgress();
|
||||||
|
app.showShortToastMessage(app.getString(R.string.file_import_error, destFileName, error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hideProgress() {
|
||||||
if (progress != null && AndroidUtils.isActivityNotDestroyed(activity)) {
|
if (progress != null && AndroidUtils.isActivityNotDestroyed(activity)) {
|
||||||
progress.dismiss();
|
progress.dismiss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
if (app.isApplicationInitializing()) {
|
private File getDestinationDir() {
|
||||||
app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() {
|
if (importType == ImportType.ROUTING) {
|
||||||
@Override
|
return app.getAppPath(IndexConstants.ROUTING_PROFILES_DIR);
|
||||||
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
|
} else if (importType == ImportType.RENDERING) {
|
||||||
|
return app.getAppPath(IndexConstants.RENDERERS_DIR);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private File getDestinationFile() {
|
||||||
public void onFinish(AppInitializer init) {
|
File destDir = getDestinationDir();
|
||||||
renderingImportTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
if (destDir != null) {
|
||||||
|
if (!destDir.exists()) {
|
||||||
|
destDir.mkdirs();
|
||||||
}
|
}
|
||||||
});
|
if (importType == ImportType.RENDERING && !destFileName.endsWith(RENDERER_INDEX_EXT)) {
|
||||||
} else {
|
String fileName = Algorithms.getFileNameWithoutExtension(destFileName);
|
||||||
renderingImportTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
destFileName = fileName + RENDERER_INDEX_EXT;
|
||||||
}
|
}
|
||||||
|
File destFile = new File(destDir, destFileName);
|
||||||
|
while (destFile.exists()) {
|
||||||
|
destFileName = AndroidUtils.createNewFileName(destFileName);
|
||||||
|
destFile = new File(destDir, destFileName);
|
||||||
|
}
|
||||||
|
return destFile;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkImportType() {
|
||||||
|
InputStream is = null;
|
||||||
|
try {
|
||||||
|
final ParcelFileDescriptor pFD = app.getContentResolver().openFileDescriptor(intentUri, "r");
|
||||||
|
if (pFD != null) {
|
||||||
|
is = new FileInputStream(pFD.getFileDescriptor());
|
||||||
|
XmlPullParser parser = PlatformUtil.newXMLPullParser();
|
||||||
|
parser.setInput(is, "UTF-8");
|
||||||
|
int tok;
|
||||||
|
while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
|
||||||
|
if (tok == XmlPullParser.START_TAG) {
|
||||||
|
String name = parser.getName();
|
||||||
|
if ("osmand_routing_config".equals(name)) {
|
||||||
|
importType = ImportType.ROUTING;
|
||||||
|
} else if ("renderingStyle".equals(name)) {
|
||||||
|
importType = ImportType.RENDERING;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
pFD.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException | XmlPullParserException e) {
|
||||||
|
log.error(e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e);
|
||||||
|
} finally {
|
||||||
|
if (is != null) try {
|
||||||
|
is.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
executeImportTask(renderingImportTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleResult(final GPXFile result, final String name, final boolean save,
|
private void handleResult(final GPXFile result, final String name, final boolean save,
|
||||||
|
@ -1198,107 +1175,21 @@ public class ImportHelper {
|
||||||
return favourites;
|
return favourites;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@SuppressWarnings("unchecked")
|
||||||
* Checks, whether the child directory is a subdirectory of the parent
|
private <P> void executeImportTask(final AsyncTask<P, ?, ?> importTask, final P... requests) {
|
||||||
* directory.
|
if (app.isApplicationInitializing()) {
|
||||||
*
|
app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() {
|
||||||
* @param parent the parent directory.
|
@Override
|
||||||
* @param child the suspected child directory.
|
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
|
||||||
* @return true if the child is a subdirectory of the parent directory.
|
|
||||||
*/
|
|
||||||
public boolean isSubDirectory(File parent, File child) {
|
|
||||||
try {
|
|
||||||
parent = parent.getCanonicalFile();
|
|
||||||
child = child.getCanonicalFile();
|
|
||||||
|
|
||||||
File dir = child;
|
|
||||||
while (dir != null) {
|
|
||||||
if (parent.equals(dir)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
dir = dir.getParentFile();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ImportGpxBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
|
||||||
|
|
||||||
public static final String TAG = "ImportGpxBottomSheetDialogFragment";
|
|
||||||
|
|
||||||
private ImportHelper importHelper;
|
|
||||||
|
|
||||||
private GPXFile gpxFile;
|
|
||||||
private String fileName;
|
|
||||||
private boolean save;
|
|
||||||
private boolean useImportDir;
|
|
||||||
|
|
||||||
public void setImportHelper(ImportHelper importHelper) {
|
|
||||||
this.importHelper = importHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGpxFile(GPXFile gpxFile) {
|
|
||||||
this.gpxFile = gpxFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFileName(String fileName) {
|
|
||||||
this.fileName = fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSave(boolean save) {
|
|
||||||
this.save = save;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUseImportDir(boolean useImportDir) {
|
|
||||||
this.useImportDir = useImportDir;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createMenuItems(Bundle savedInstanceState) {
|
public void onFinish(AppInitializer init) {
|
||||||
items.add(new TitleItem(getString(R.string.import_file)));
|
importTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, requests);
|
||||||
|
|
||||||
int nameColor = getResolvedColor(nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
|
|
||||||
int descrColor = getResolvedColor(nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light);
|
|
||||||
String descr = getString(R.string.import_gpx_file_description);
|
|
||||||
if(!descr.contains("%s")) {
|
|
||||||
descr = "%s " +descr;
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
CharSequence txt = AndroidUtils.getStyledString(descr, fileName, new ForegroundColorSpan(descrColor),
|
} else {
|
||||||
new ForegroundColorSpan(nameColor));
|
importTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, requests);
|
||||||
items.add(new ShortDescriptionItem(txt));
|
|
||||||
|
|
||||||
BaseBottomSheetItem asFavoritesItem = new SimpleBottomSheetItem.Builder()
|
|
||||||
.setIcon(getContentIcon(R.drawable.ic_action_favorite))
|
|
||||||
.setTitle(getString(R.string.import_as_favorites))
|
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
importHelper.importFavoritesImpl(gpxFile, fileName, false);
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create();
|
|
||||||
items.add(asFavoritesItem);
|
|
||||||
|
|
||||||
items.add(new DividerHalfItem(getContext()));
|
|
||||||
|
|
||||||
BaseBottomSheetItem asGpxItem = new SimpleBottomSheetItem.Builder()
|
|
||||||
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
|
|
||||||
.setTitle(getString(R.string.import_as_gpx))
|
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
importHelper.handleResult(gpxFile, fileName, save, useImportDir, false);
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create();
|
|
||||||
items.add(asGpxItem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -915,9 +915,6 @@ public class RoutingHelper {
|
||||||
|
|
||||||
|
|
||||||
public static String formatStreetName(String name, String ref, String destination, String towards) {
|
public static String formatStreetName(String name, String ref, String destination, String towards) {
|
||||||
//Hardy, 2016-08-05:
|
|
||||||
//Now returns: (ref) + ((" ")+name) + ((" ")+"toward "+dest) or ""
|
|
||||||
|
|
||||||
String formattedStreetName = "";
|
String formattedStreetName = "";
|
||||||
if (ref != null && ref.length() > 0) {
|
if (ref != null && ref.length() > 0) {
|
||||||
formattedStreetName = ref;
|
formattedStreetName = ref;
|
||||||
|
@ -938,56 +935,78 @@ public class RoutingHelper {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected boolean isDistanceLess(float currentSpeed, double dist, double etalon, float defSpeed){
|
|
||||||
// if(dist < etalon || ((dist / currentSpeed) < (etalon / defSpeed))){
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public synchronized String getCurrentName(TurnType[] next, NextDirectionInfo n){
|
public static class CurrentStreetName {
|
||||||
|
public String text;
|
||||||
|
public TurnType turnType;
|
||||||
|
public boolean showMarker; // turn type has priority over showMarker
|
||||||
|
public RouteDataObject shieldObject;
|
||||||
|
public String exitRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized CurrentStreetName getCurrentName(NextDirectionInfo n){
|
||||||
|
CurrentStreetName streetName = new CurrentStreetName();
|
||||||
Location l = lastFixedLocation;
|
Location l = lastFixedLocation;
|
||||||
float speed = 0;
|
float speed = 0;
|
||||||
if(l != null && l.hasSpeed()) {
|
if (l != null && l.hasSpeed()) {
|
||||||
speed = l.getSpeed();
|
speed = l.getSpeed();
|
||||||
}
|
}
|
||||||
if(next != null && n.directionInfo != null) {
|
boolean isSet = false;
|
||||||
next[0] = n.directionInfo.getTurnType();
|
// 1. turn is imminent
|
||||||
}
|
if (n.distanceTo > 0 && n.directionInfo != null && !n.directionInfo.getTurnType().isSkipToSpeak() &&
|
||||||
if(n.distanceTo > 0 && n.directionInfo != null && !n.directionInfo.getTurnType().isSkipToSpeak() &&
|
|
||||||
voiceRouter.isDistanceLess(speed, n.distanceTo, voiceRouter.PREPARE_DISTANCE * 0.75f)) {
|
voiceRouter.isDistanceLess(speed, n.distanceTo, voiceRouter.PREPARE_DISTANCE * 0.75f)) {
|
||||||
String nm = n.directionInfo.getStreetName();
|
String nm = n.directionInfo.getStreetName();
|
||||||
String rf = n.directionInfo.getRef();
|
String rf = n.directionInfo.getRef();
|
||||||
String dn = n.directionInfo.getDestinationName();
|
String dn = n.directionInfo.getDestinationName();
|
||||||
|
isSet = !(Algorithms.isEmpty(nm) && Algorithms.isEmpty(rf) && Algorithms.isEmpty(dn));
|
||||||
return formatStreetName(nm, null, dn, "»");
|
streetName.text = formatStreetName(nm, null, dn, "»");
|
||||||
|
streetName.turnType = n.directionInfo.getTurnType();
|
||||||
|
streetName.shieldObject = n.directionInfo.getRouteDataObject();
|
||||||
|
if (streetName.turnType == null) {
|
||||||
|
streetName.turnType = TurnType.valueOf(TurnType.C, false);
|
||||||
}
|
}
|
||||||
|
if (n.directionInfo.getExitInfo() != null) {
|
||||||
|
streetName.exitRef = n.directionInfo.getExitInfo().getRef();
|
||||||
|
if (!Algorithms.isEmpty(n.directionInfo.getExitInfo().getExitStreetName())) {
|
||||||
|
streetName.text = n.directionInfo.getExitInfo().getExitStreetName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 2. display current road street name
|
||||||
|
if (!isSet) {
|
||||||
RouteSegmentResult rs = getCurrentSegmentResult();
|
RouteSegmentResult rs = getCurrentSegmentResult();
|
||||||
if(rs != null) {
|
if (rs != null) {
|
||||||
String name = getRouteSegmentStreetName(rs);
|
streetName.text = getRouteSegmentStreetName(rs, false);
|
||||||
if (!Algorithms.isEmpty(name)) {
|
if (Algorithms.isEmpty(streetName.text)) {
|
||||||
return name;
|
isSet = !Algorithms.isEmpty(getRouteSegmentStreetName(rs, true));
|
||||||
|
} else {
|
||||||
|
isSet = true;
|
||||||
|
}
|
||||||
|
streetName.showMarker = true;
|
||||||
|
streetName.shieldObject = rs.getObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rs = getNextStreetSegmentResult();
|
// 3. display next road street name if this one empty
|
||||||
if(rs != null) {
|
if (!isSet) {
|
||||||
String name = getRouteSegmentStreetName(rs);
|
RouteSegmentResult rs = getNextStreetSegmentResult();
|
||||||
if (!Algorithms.isEmpty(name)) {
|
if (rs != null) {
|
||||||
if(next != null) {
|
streetName.text = getRouteSegmentStreetName(rs, false);
|
||||||
next[0] = TurnType.valueOf(TurnType.C, false);
|
streetName.turnType = TurnType.valueOf(TurnType.C, false);
|
||||||
}
|
streetName.shieldObject = rs.getObject();
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
if (streetName.turnType == null) {
|
||||||
|
streetName.showMarker = true;
|
||||||
|
}
|
||||||
|
return streetName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getRouteSegmentStreetName(RouteSegmentResult rs) {
|
private String getRouteSegmentStreetName(RouteSegmentResult rs, boolean includeRef) {
|
||||||
String nm = rs.getObject().getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get());
|
String nm = rs.getObject().getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get());
|
||||||
// String rf = rs.getObject().getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rs.isForwardDirection());
|
String rf = rs.getObject().getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rs.isForwardDirection());
|
||||||
String dn = rs.getObject().getDestinationName(settings.MAP_PREFERRED_LOCALE.get(),
|
String dn = rs.getObject().getDestinationName(settings.MAP_PREFERRED_LOCALE.get(),
|
||||||
settings.MAP_TRANSLITERATE_NAMES.get(), rs.isForwardDirection());
|
settings.MAP_TRANSLITERATE_NAMES.get(), rs.isForwardDirection());
|
||||||
return formatStreetName(nm, null, dn, "»");
|
return formatStreetName(nm, includeRef ? rf : null, dn, "»");
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouteSegmentResult getCurrentSegmentResult() {
|
public RouteSegmentResult getCurrentSegmentResult() {
|
||||||
|
|
|
@ -931,11 +931,11 @@ public class MapInfoWidgetsFactory {
|
||||||
private View waypointInfoBar;
|
private View waypointInfoBar;
|
||||||
private LocationPointWrapper lastPoint;
|
private LocationPointWrapper lastPoint;
|
||||||
private TurnDrawable turnDrawable;
|
private TurnDrawable turnDrawable;
|
||||||
private boolean showMarker;
|
|
||||||
private int shadowRad;
|
private int shadowRad;
|
||||||
RouteCalculationResult.NextDirectionInfo calc1;
|
RouteCalculationResult.NextDirectionInfo calc1;
|
||||||
|
|
||||||
private static final Log LOG = PlatformUtil.getLog(TopTextView.class);
|
private static final Log LOG = PlatformUtil.getLog(TopTextView.class);
|
||||||
|
private boolean showMarker;
|
||||||
|
|
||||||
public TopTextView(OsmandApplication app, MapActivity map) {
|
public TopTextView(OsmandApplication app, MapActivity map) {
|
||||||
turnDrawable = new NextTurnInfoWidget.TurnDrawable(map, true);
|
turnDrawable = new NextTurnInfoWidget.TurnDrawable(map, true);
|
||||||
|
@ -981,138 +981,80 @@ public class MapInfoWidgetsFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean updateInfo(DrawSettings d) {
|
|
||||||
String text = null;
|
|
||||||
TurnType[] type = new TurnType[1];
|
|
||||||
boolean showNextTurn = false;
|
|
||||||
boolean showMarker = this.showMarker;
|
|
||||||
boolean showExitInfo = false;
|
|
||||||
boolean showShield = false;
|
|
||||||
boolean imminentTurn = false;
|
|
||||||
ExitInfo exitInfo = null;
|
|
||||||
RouteDataObject object = null;
|
|
||||||
|
|
||||||
|
public boolean updateInfo(DrawSettings d) {
|
||||||
|
RoutingHelper.CurrentStreetName streetName = null;
|
||||||
|
boolean showClosestWaypointFirstInAddress = true;
|
||||||
if (routingHelper != null && routingHelper.isRouteCalculated() && !routingHelper.isDeviatedFromRoute()) {
|
if (routingHelper != null && routingHelper.isRouteCalculated() && !routingHelper.isDeviatedFromRoute()) {
|
||||||
if (routingHelper.isFollowingMode()) {
|
if (routingHelper.isFollowingMode()) {
|
||||||
if (settings.SHOW_STREET_NAME.get()) {
|
if (settings.SHOW_STREET_NAME.get()) {
|
||||||
RouteCalculationResult.NextDirectionInfo nextDirInfo = routingHelper.getNextRouteDirectionInfo(calc1, true);
|
RouteCalculationResult.NextDirectionInfo nextDirInfo = routingHelper.getNextRouteDirectionInfo(calc1, true);
|
||||||
text = routingHelper.getCurrentName(type, nextDirInfo);
|
streetName = routingHelper.getCurrentName(nextDirInfo);
|
||||||
if (text == null) {
|
|
||||||
text = "";
|
|
||||||
} else {
|
|
||||||
if (type[0] == null) {
|
|
||||||
showMarker = true;
|
|
||||||
} else {
|
|
||||||
turnDrawable.setColor(R.color.nav_arrow);
|
turnDrawable.setColor(R.color.nav_arrow);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
RouteDirectionInfo directionInfo = nextDirInfo.directionInfo;
|
|
||||||
|
|
||||||
if (nextDirInfo.imminent >= 0) {
|
|
||||||
imminentTurn = true;
|
|
||||||
} else {
|
|
||||||
imminentTurn = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (directionInfo != null && directionInfo.getExitInfo() != null) {
|
|
||||||
exitInfo = directionInfo.getExitInfo();
|
|
||||||
showExitInfo = true;
|
|
||||||
} else {
|
|
||||||
showExitInfo = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showExitInfo) {
|
|
||||||
if(!Algorithms.isEmpty(exitInfo.getExitStreetName())) {
|
|
||||||
text = exitInfo.getExitStreetName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (directionInfo != null && directionInfo.getRouteDataObject() != null) {
|
|
||||||
object = directionInfo.getRouteDataObject();
|
|
||||||
showShield = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
int di = MapRouteInfoMenu.getDirectionInfo();
|
int di = MapRouteInfoMenu.getDirectionInfo();
|
||||||
if (di >= 0 && map.getMapRouteInfoMenu().isVisible() &&
|
if (di >= 0 && map.getMapRouteInfoMenu().isVisible() && di < routingHelper.getRouteDirections().size()) {
|
||||||
di < routingHelper.getRouteDirections().size()) {
|
showClosestWaypointFirstInAddress = false;
|
||||||
showNextTurn = true;
|
|
||||||
RouteDirectionInfo next = routingHelper.getRouteDirections().get(di);
|
RouteDirectionInfo next = routingHelper.getRouteDirections().get(di);
|
||||||
type[0] = next.getTurnType();
|
streetName = routingHelper.getCurrentName(routingHelper.getNextRouteDirectionInfo(calc1, true));
|
||||||
turnDrawable.setColor(R.color.nav_arrow_distant);
|
turnDrawable.setColor(R.color.nav_arrow_distant);
|
||||||
text = RoutingHelper.formatStreetName(next.getStreetName(), null, next.getDestinationName(), "»");
|
|
||||||
if (text == null) {
|
|
||||||
text = "";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
text = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (map.getMapViewTrackingUtilities().isMapLinkedToLocation() &&
|
} else if (map.getMapViewTrackingUtilities().isMapLinkedToLocation() &&
|
||||||
settings.SHOW_STREET_NAME.get()) {
|
settings.SHOW_STREET_NAME.get()) {
|
||||||
|
streetName = new RoutingHelper.CurrentStreetName();
|
||||||
RouteDataObject rt = locationProvider.getLastKnownRouteSegment();
|
RouteDataObject rt = locationProvider.getLastKnownRouteSegment();
|
||||||
if (rt != null) {
|
if (rt != null) {
|
||||||
Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
||||||
text = RoutingHelper.formatStreetName(
|
streetName.text = RoutingHelper.formatStreetName(
|
||||||
rt.getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()),
|
rt.getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()),
|
||||||
rt.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
rt.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
||||||
rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
||||||
"»");
|
"»");
|
||||||
}
|
if (!Algorithms.isEmpty(streetName.text) && lastKnownLocation != null) {
|
||||||
if (text == null) {
|
double dist = CurrentPositionHelper.getOrthogonalDistance(rt, lastKnownLocation);
|
||||||
text = "";
|
|
||||||
} else {
|
|
||||||
Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
|
||||||
if (!Algorithms.isEmpty(text) && lastKnownLocation != null) {
|
|
||||||
double dist =
|
|
||||||
CurrentPositionHelper.getOrthogonalDistance(rt, lastKnownLocation);
|
|
||||||
if (dist < 50) {
|
if (dist < 50) {
|
||||||
showMarker = true;
|
streetName.showMarker = true;
|
||||||
} else {
|
} else {
|
||||||
text = map.getResources().getString(R.string.shared_string_near) + " " + text;
|
streetName.text = map.getResources().getString(R.string.shared_string_near) + " " + streetName.text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (map.isTopToolbarActive() || !map.getContextMenu().shouldShowTopControls() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) {
|
if (map.isTopToolbarActive() || !map.getContextMenu().shouldShowTopControls() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) {
|
||||||
updateVisibility(false);
|
updateVisibility(false);
|
||||||
} else if (!showNextTurn && updateWaypoint()) {
|
} else if (!showClosestWaypointFirstInAddress && updateWaypoint()) {
|
||||||
updateVisibility(true);
|
updateVisibility(true);
|
||||||
AndroidUiHelper.updateVisibility(addressText, false);
|
AndroidUiHelper.updateVisibility(addressText, false);
|
||||||
AndroidUiHelper.updateVisibility(addressTextShadow, false);
|
AndroidUiHelper.updateVisibility(addressTextShadow, false);
|
||||||
} else if (text == null) {
|
} else if (streetName == null) {
|
||||||
updateVisibility(false);
|
updateVisibility(false);
|
||||||
} else {
|
} else {
|
||||||
updateVisibility(true);
|
updateVisibility(true);
|
||||||
AndroidUiHelper.updateVisibility(waypointInfoBar, false);
|
AndroidUiHelper.updateVisibility(waypointInfoBar, false);
|
||||||
AndroidUiHelper.updateVisibility(addressText, true);
|
AndroidUiHelper.updateVisibility(addressText, true);
|
||||||
AndroidUiHelper.updateVisibility(addressTextShadow, shadowRad > 0);
|
AndroidUiHelper.updateVisibility(addressTextShadow, shadowRad > 0);
|
||||||
boolean update = turnDrawable.setTurnType(type[0]) || showMarker != this.showMarker;
|
|
||||||
this.showMarker = showMarker;
|
if (streetName.shieldObject != null && setRoadShield(shieldIcon, streetName.shieldObject)) {
|
||||||
if (showShield && setRoadShield(shieldIcon, object)) {
|
|
||||||
AndroidUiHelper.updateVisibility(shieldIcon, true);
|
AndroidUiHelper.updateVisibility(shieldIcon, true);
|
||||||
} else {
|
} else {
|
||||||
AndroidUiHelper.updateVisibility(shieldIcon, false);
|
AndroidUiHelper.updateVisibility(shieldIcon, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showExitInfo) {
|
if (!Algorithms.isEmpty(streetName.exitRef) ) {
|
||||||
String exitRef = exitInfo.getRef();
|
exitRefText.setText(streetName.exitRef);
|
||||||
if (!Algorithms.isEmpty(exitRef) && imminentTurn) {
|
|
||||||
exitRefText.setText(exitRef);
|
|
||||||
AndroidUiHelper.updateVisibility(exitRefText, true);
|
AndroidUiHelper.updateVisibility(exitRefText, true);
|
||||||
} else {
|
} else {
|
||||||
AndroidUiHelper.updateVisibility(exitRefText, false);
|
AndroidUiHelper.updateVisibility(exitRefText, false);
|
||||||
}
|
}
|
||||||
} else {
|
if (turnDrawable.setTurnType(streetName.turnType) || streetName.showMarker != this.showMarker) {
|
||||||
AndroidUiHelper.updateVisibility(exitRefText, false);
|
this.showMarker = streetName.showMarker;
|
||||||
}
|
if (streetName.turnType != null) {
|
||||||
if (update) {
|
|
||||||
if (type[0] != null) {
|
|
||||||
turnIcon.invalidateDrawable(turnDrawable);
|
turnIcon.invalidateDrawable(turnDrawable);
|
||||||
turnIcon.setImageDrawable(turnDrawable);
|
turnIcon.setImageDrawable(turnDrawable);
|
||||||
AndroidUiHelper.updateVisibility(turnIcon, true);
|
AndroidUiHelper.updateVisibility(turnIcon, true);
|
||||||
} else if (showMarker) {
|
} else if (streetName.showMarker) {
|
||||||
Drawable marker = map.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, R.color.color_myloc_distance);
|
Drawable marker = map.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, R.color.color_myloc_distance);
|
||||||
turnIcon.setImageDrawable(marker);
|
turnIcon.setImageDrawable(marker);
|
||||||
AndroidUiHelper.updateVisibility(turnIcon, true);
|
AndroidUiHelper.updateVisibility(turnIcon, true);
|
||||||
|
@ -1120,9 +1062,12 @@ public class MapInfoWidgetsFactory {
|
||||||
AndroidUiHelper.updateVisibility(turnIcon, false);
|
AndroidUiHelper.updateVisibility(turnIcon, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!text.equals(addressText.getText().toString())) {
|
if(streetName.text == null || streetName.text.isEmpty()) {
|
||||||
addressTextShadow.setText(text);
|
addressTextShadow.setText("");
|
||||||
addressText.setText(text);
|
addressText.setText("");
|
||||||
|
} else if (!streetName.text.equals(addressText.getText().toString())) {
|
||||||
|
addressTextShadow.setText(streetName.text);
|
||||||
|
addressText.setText(streetName.text );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue