From 2b52eacb3aa4e8f684420abd2d918a64aa5b6477 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Mon, 29 May 2017 19:28:57 +0300 Subject: [PATCH] Fix #3819 --- OsmAnd/res/values/strings.xml | 21 ++++++ .../osmand/plus/helpers/GpxImportHelper.java | 70 +++++++++++++------ 2 files changed, 68 insertions(+), 23 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 33431ea381..f3ae5b8b41 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,7 +9,28 @@ 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 --> +<<<<<<< HEAD Your destination is located in the area with a private access. Do you want to allow access to the private roads for this trip? +======= + Permissions + OsmAnd cannot import the file. Please check if OsmAnd has permission to read file from its location. + Distance corrected + Mapillary image + Open Mapillary + Install + Improve photo coverage with Mapillary + You can take your own photos or series of photos and attach them to this map location.\n\nTo do this you need to install the Mapillary app from the Google Play Store. + Online photos + Add photos + We do not have photos for this location + Contribute with your own street-level views of this location via Mapillary. + Mapillary widget + Allows you to quickly contribute to Mapillary + Online street-level photos for everyone. Discover places, collaborate, capture the world. + Mapillary + Street-level photos for everyone. Discover places, collaborate, capture the world. + Your destination is located in an area with private access. Do you want to allow access to the private roads for this trip? +>>>>>>> 950b5efbde... Fix #3819 Restart search Increase search radius Nothing found :( diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java index b5fc8bb86f..517d8c4694 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java @@ -9,6 +9,7 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.ParcelFileDescriptor; import android.provider.OpenableColumns; +import android.provider.Settings; import android.support.v7.app.AlertDialog; import android.widget.Toast; @@ -110,7 +111,7 @@ public class GpxImportHelper { } private void handleGpxImport(final Uri gpxFile, final String fileName, final boolean save, final boolean useImportDir) { - new AsyncTask() { + new AsyncTask() { ProgressDialog progress = null; @Override @@ -119,7 +120,7 @@ public class GpxImportHelper { } @Override - protected GPXUtilities.GPXFile doInBackground(Void... nothing) { + protected GPXFile doInBackground(Void... nothing) { InputStream is = null; try { final ParcelFileDescriptor pFD = app.getContentResolver().openFileDescriptor(gpxFile, "r"); @@ -140,7 +141,7 @@ public class GpxImportHelper { } @Override - protected void onPostExecute(GPXUtilities.GPXFile result) { + protected void onPostExecute(GPXFile result) { progress.dismiss(); handleResult(result, fileName, save, useImportDir); } @@ -148,7 +149,7 @@ public class GpxImportHelper { } private void handleFavouritesImport(final Uri gpxFile, final String fileName, final boolean save, final boolean useImportDir) { - new AsyncTask() { + new AsyncTask() { ProgressDialog progress = null; @Override @@ -157,7 +158,7 @@ public class GpxImportHelper { } @Override - protected GPXUtilities.GPXFile doInBackground(Void... nothing) { + protected GPXFile doInBackground(Void... nothing) { InputStream is = null; try { final ParcelFileDescriptor pFD = app.getContentResolver().openFileDescriptor(gpxFile, "r"); @@ -178,7 +179,7 @@ public class GpxImportHelper { } @Override - protected void onPostExecute(final GPXUtilities.GPXFile result) { + protected void onPostExecute(final GPXFile result) { progress.dismiss(); importFavourites(result, fileName, save, useImportDir); } @@ -186,7 +187,7 @@ public class GpxImportHelper { } private void importFavoritesImpl(final GPXFile gpxFile) { - new AsyncTask() { + new AsyncTask() { ProgressDialog progress = null; @Override @@ -195,7 +196,7 @@ public class GpxImportHelper { } @Override - protected GPXUtilities.GPXFile doInBackground(Void... nothing) { + protected GPXFile doInBackground(Void... nothing) { final List favourites = asFavourites(gpxFile.points); final FavouritesDbHelper favoritesHelper = app.getFavorites(); for (final FavouritePoint favourite : favourites) { @@ -208,7 +209,7 @@ public class GpxImportHelper { } @Override - protected void onPostExecute(GPXUtilities.GPXFile result) { + protected void onPostExecute(GPXFile result) { progress.dismiss(); Toast.makeText(activity, R.string.fav_imported_sucessfully, Toast.LENGTH_LONG).show(); final Intent newIntent = new Intent(activity, app.getAppCustomization().getFavoritesActivity()); @@ -218,7 +219,7 @@ public class GpxImportHelper { } private void handleKmlImport(final Uri kmlFile, final String name, final boolean save, final boolean useImportDir) { - new AsyncTask() { + new AsyncTask() { ProgressDialog progress = null; @Override @@ -227,7 +228,7 @@ public class GpxImportHelper { } @Override - protected GPXUtilities.GPXFile doInBackground(Void... nothing) { + protected GPXFile doInBackground(Void... nothing) { InputStream is = null; try { final ParcelFileDescriptor pFD = app.getContentResolver().openFileDescriptor(kmlFile, "r"); @@ -254,14 +255,15 @@ public class GpxImportHelper { } @Override - protected void onPostExecute(GPXUtilities.GPXFile result) { + protected void onPostExecute(GPXFile result) { progress.dismiss(); handleResult(result, name, save, useImportDir); } }.execute(); } - private void handleResult(final GPXUtilities.GPXFile result, final String name, final boolean save, final boolean useImportDir) { + private void handleResult(final GPXFile result, final String name, final boolean save, + final boolean useImportDir) { if (result != null) { if (result.warning != null) { Toast.makeText(activity, result.warning, Toast.LENGTH_LONG).show(); @@ -279,14 +281,35 @@ public class GpxImportHelper { } } } else { - Toast.makeText(activity, R.string.error_reading_gpx, Toast.LENGTH_LONG).show(); - if (gpxImportCompleteListener != null) { - gpxImportCompleteListener.onComplete(false); - } + new AlertDialog.Builder(activity) + .setTitle(R.string.shared_string_import2osmand) + .setMessage(R.string.import_gpx_failed_descr) + .setNeutralButton(R.string.shared_string_permissions, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + Uri uri = Uri.fromParts("package", app.getPackageName(), null); + intent.setData(uri); + app.startActivity(intent); + if (gpxImportCompleteListener != null) { + gpxImportCompleteListener.onComplete(false); + } + } + }) + .setNegativeButton(R.string.shared_string_cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (gpxImportCompleteListener != null) { + gpxImportCompleteListener.onComplete(false); + } + } + }) + .show(); } } - private String saveImport(final GPXUtilities.GPXFile gpxFile, final String fileName, final boolean useImportDir) { + private String saveImport(final GPXFile gpxFile, final String fileName, final boolean useImportDir) { final String warning; if (gpxFile.isEmpty() || fileName == null) { @@ -329,11 +352,11 @@ public class GpxImportHelper { } private class SaveAsyncTask extends AsyncTask { - private final GPXUtilities.GPXFile result; + private final GPXFile result; private final String name; private final boolean useImportDir; - private SaveAsyncTask(GPXUtilities.GPXFile result, final String name, boolean useImportDir) { + private SaveAsyncTask(GPXFile result, final String name, boolean useImportDir) { this.result = result; this.name = name; this.useImportDir = useImportDir; @@ -362,7 +385,7 @@ public class GpxImportHelper { } } - private void showGpxOnMap(final GPXUtilities.GPXFile result) { + private void showGpxOnMap(final GPXFile result) { if (mapView != null && getMapActivity() != null) { app.getSelectedGpxHelper().setGpxFileToDisplay(result); final GPXUtilities.WptPt moveTo = result.findPointToShow(); @@ -376,8 +399,9 @@ public class GpxImportHelper { } } - private void importFavourites(final GPXUtilities.GPXFile gpxFile, final String fileName, final boolean save, final boolean useImportDir) { - if(gpxFile == null || gpxFile.points == null || gpxFile.points.size() == 0) { + private void importFavourites(final GPXFile gpxFile, final String fileName, final boolean save, + final boolean useImportDir) { + if (gpxFile == null || gpxFile.points == null || gpxFile.points.size() == 0) { handleResult(gpxFile, fileName, save, useImportDir); return; }