Added .wpt.chart and .3d.chart support

This commit is contained in:
max-klaus 2020-09-12 14:20:31 +03:00
parent 7d55b00fec
commit bb65803201
3 changed files with 99 additions and 17 deletions

View file

@ -45,6 +45,9 @@ public class IndexConstants {
public static final String GPX_FILE_EXT = ".gpx"; //$NON-NLS-1$ public static final String GPX_FILE_EXT = ".gpx"; //$NON-NLS-1$
public static final String WPT_CHART_FILE_EXT = ".wpt.chart";
public static final String SQLITE_CHART_FILE_EXT = ".3d.chart";
public final static String POI_TABLE = "poi"; //$NON-NLS-1$ public final static String POI_TABLE = "poi"; //$NON-NLS-1$
public static final String INDEX_DOWNLOAD_DOMAIN = "download.osmand.net"; public static final String INDEX_DOWNLOAD_DOMAIN = "download.osmand.net";

View file

@ -371,6 +371,72 @@
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.xml" /> <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.xml" />
</intent-filter> </intent-filter>
<intent-filter
android:label="@string/app_name"
android:priority="50">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file"/>
<data android:scheme="content"/>
<data android:host="*"/>
<data android:pathPattern=".*\\.wpt.chart" />
<data android:pathPattern=".*\\..*\\.wpt.chart" />
<data android:pathPattern=".*\\..*\\..*\\.wpt.chart" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.wpt.chart" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.wpt.chart" />
</intent-filter>
<intent-filter
android:label="@string/app_name"
android:priority="50">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file"/>
<data android:scheme="content"/>
<data android:host="*"/>
<data android:mimeType="*/*"/>
<data android:pathPattern=".*\\.wpt.chart" />
<data android:pathPattern=".*\\..*\\.wpt.chart" />
<data android:pathPattern=".*\\..*\\..*\\.wpt.chart" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.wpt.chart" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.wpt.chart" />
</intent-filter>
<intent-filter
android:label="@string/app_name"
android:priority="50">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file"/>
<data android:scheme="content"/>
<data android:host="*"/>
<data android:pathPattern=".*\\.3d.chart" />
<data android:pathPattern=".*\\..*\\.3d.chart" />
<data android:pathPattern=".*\\..*\\..*\\.3d.chart" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.3d.chart" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.3d.chart" />
</intent-filter>
<intent-filter
android:label="@string/app_name"
android:priority="50">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file"/>
<data android:scheme="content"/>
<data android:host="*"/>
<data android:mimeType="*/*"/>
<data android:pathPattern=".*\\.3d.chart" />
<data android:pathPattern=".*\\..*\\.3d.chart" />
<data android:pathPattern=".*\\..*\\..*\\.3d.chart" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.3d.chart" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.3d.chart" />
</intent-filter>
<!--trying to handle emails--> <!--trying to handle emails-->
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />

View file

@ -74,10 +74,13 @@ import java.util.Locale;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import static android.app.Activity.RESULT_OK; import static android.app.Activity.RESULT_OK;
import static net.osmand.IndexConstants.WPT_CHART_FILE_EXT;
import static net.osmand.IndexConstants.GPX_FILE_EXT; import static net.osmand.IndexConstants.GPX_FILE_EXT;
import static net.osmand.IndexConstants.OSMAND_SETTINGS_FILE_EXT; import static net.osmand.IndexConstants.OSMAND_SETTINGS_FILE_EXT;
import static net.osmand.IndexConstants.RENDERER_INDEX_EXT; import static net.osmand.IndexConstants.RENDERER_INDEX_EXT;
import static net.osmand.IndexConstants.ROUTING_FILE_EXT; import static net.osmand.IndexConstants.ROUTING_FILE_EXT;
import static net.osmand.IndexConstants.SQLITE_CHART_FILE_EXT;
import static net.osmand.IndexConstants.SQLITE_EXT;
import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE; import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE;
import static net.osmand.plus.AppInitializer.loadRoutingFiles; import static net.osmand.plus.AppInitializer.loadRoutingFiles;
import static net.osmand.plus.myplaces.FavoritesActivity.FAV_TAB; import static net.osmand.plus.myplaces.FavoritesActivity.FAV_TAB;
@ -181,7 +184,7 @@ public class ImportHelper {
} else if (isContentIntent) { } else if (isContentIntent) {
fileName = getNameFromContentUri(app, uri); fileName = getNameFromContentUri(app, uri);
} }
handleGpxOrFavouritesImport(uri, fileName, saveFile, false, true); handleGpxOrFavouritesImport(uri, fileName, saveFile, false, true, false);
} }
public void handleFileImport(Uri intentUri, String fileName, Bundle extras, boolean useImportDir) { public void handleFileImport(Uri intentUri, String fileName, Bundle extras, boolean useImportDir) {
@ -191,7 +194,7 @@ public class ImportHelper {
final boolean saveFile = !isFileIntent || !isOsmandSubdir; final boolean saveFile = !isFileIntent || !isOsmandSubdir;
if (fileName == null) { if (fileName == null) {
handleGpxOrFavouritesImport(intentUri, fileName, saveFile, useImportDir, false); handleGpxOrFavouritesImport(intentUri, fileName, saveFile, useImportDir, false, false);
} else if (fileName.endsWith(KML_SUFFIX)) { } else if (fileName.endsWith(KML_SUFFIX)) {
handleKmlImport(intentUri, fileName, saveFile, useImportDir); handleKmlImport(intentUri, fileName, saveFile, useImportDir);
} else if (fileName.endsWith(KMZ_SUFFIX)) { } else if (fileName.endsWith(KMZ_SUFFIX)) {
@ -204,8 +207,12 @@ public class ImportHelper {
handleOsmAndSettingsImport(intentUri, fileName, extras, null); handleOsmAndSettingsImport(intentUri, fileName, extras, null);
} else if (fileName.endsWith(ROUTING_FILE_EXT)) { } else if (fileName.endsWith(ROUTING_FILE_EXT)) {
handleXmlFileImport(intentUri, fileName, null); handleXmlFileImport(intentUri, fileName, null);
} else if (fileName.endsWith(WPT_CHART_FILE_EXT)) {
handleGpxOrFavouritesImport(intentUri, fileName.replace(WPT_CHART_FILE_EXT, GPX_FILE_EXT), saveFile, useImportDir, false, true);
} else if (fileName.endsWith(SQLITE_CHART_FILE_EXT)) {
handleSqliteTileImport(intentUri, fileName.replace(SQLITE_CHART_FILE_EXT, SQLITE_EXT));
} else { } else {
handleGpxOrFavouritesImport(intentUri, fileName, saveFile, useImportDir, false); handleGpxOrFavouritesImport(intentUri, fileName, saveFile, useImportDir, false, false);
} }
} }
@ -277,7 +284,9 @@ public class ImportHelper {
} }
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
private void handleGpxOrFavouritesImport(final Uri fileUri, final String fileName, final boolean save, final boolean useImportDir, final boolean forceImportFavourites) { private void handleGpxOrFavouritesImport(final Uri fileUri, final String fileName, final boolean save,
final boolean useImportDir, final boolean forceImportFavourites,
final boolean forceImportGpx) {
new AsyncTask<Void, Void, GPXFile>() { new AsyncTask<Void, Void, GPXFile>() {
ProgressDialog progress = null; ProgressDialog progress = null;
@ -343,8 +352,7 @@ public class ImportHelper {
if (AndroidUtils.isActivityNotDestroyed(activity)) { if (AndroidUtils.isActivityNotDestroyed(activity)) {
progress.dismiss(); progress.dismiss();
} }
importGpxOrFavourites(result, fileName, save, useImportDir, forceImportFavourites, forceImportGpx);
importGpxOrFavourites(result, fileName, save, useImportDir, forceImportFavourites);
} }
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
@ -1144,7 +1152,8 @@ public class ImportHelper {
} }
private void importGpxOrFavourites(final GPXFile gpxFile, final String fileName, final boolean save, private void importGpxOrFavourites(final GPXFile gpxFile, final String fileName, final boolean save,
final boolean useImportDir, final boolean forceImportFavourites) { final boolean useImportDir, final boolean forceImportFavourites,
final boolean forceImportGpx) {
if (gpxFile == null || gpxFile.isPointsEmpty()) { if (gpxFile == null || gpxFile.isPointsEmpty()) {
if (forceImportFavourites) { if (forceImportFavourites) {
final DialogInterface.OnClickListener importAsTrackListener = new DialogInterface.OnClickListener() { final DialogInterface.OnClickListener importAsTrackListener = new DialogInterface.OnClickListener() {
@ -1177,16 +1186,20 @@ public class ImportHelper {
if (forceImportFavourites) { if (forceImportFavourites) {
importFavoritesImpl(gpxFile, fileName, true); importFavoritesImpl(gpxFile, fileName, true);
} else if (fileName != null) { } else if (fileName != null) {
ImportGpxBottomSheetDialogFragment fragment = new ImportGpxBottomSheetDialogFragment(); if (forceImportGpx) {
fragment.setUsedOnMap(true); handleResult(gpxFile, fileName, save, useImportDir, false);
fragment.setImportHelper(this); } else {
fragment.setGpxFile(gpxFile); ImportGpxBottomSheetDialogFragment fragment = new ImportGpxBottomSheetDialogFragment();
fragment.setFileName(fileName); fragment.setUsedOnMap(true);
fragment.setSave(save); fragment.setImportHelper(this);
fragment.setUseImportDir(useImportDir); fragment.setGpxFile(gpxFile);
activity.getSupportFragmentManager().beginTransaction() fragment.setFileName(fileName);
.add(fragment, ImportGpxBottomSheetDialogFragment.TAG) fragment.setSave(save);
.commitAllowingStateLoss(); fragment.setUseImportDir(useImportDir);
activity.getSupportFragmentManager().beginTransaction()
.add(fragment, ImportGpxBottomSheetDialogFragment.TAG)
.commitAllowingStateLoss();
}
} }
} }