This commit is contained in:
Alexey Kulish 2017-05-29 19:28:57 +03:00
parent 30221cf06b
commit 2b52eacb3a
2 changed files with 68 additions and 23 deletions

View file

@ -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
<string name="private_access_routing_req">Your destination is located in the area with a private access. Do you want to allow access to the private roads for this trip?</string>
=======
<string name="shared_string_permissions">Permissions</string>
<string name="import_gpx_failed_descr">OsmAnd cannot import the file. Please check if OsmAnd has permission to read file from its location.</string>
<string name="distance_moving">Distance corrected</string>
<string name="mapillary_image">Mapillary image</string>
<string name="open_mapillary">Open Mapillary</string>
<string name="shared_string_install">Install</string>
<string name="improve_coverage_mapillary">Improve photo coverage with Mapillary</string>
<string name="improve_coverage_install_mapillary_desc">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.</string>
<string name="online_photos">Online photos</string>
<string name="shared_string_add_photos">Add photos</string>
<string name="no_photos_descr">We do not have photos for this location</string>
<string name="mapillary_action_descr">Contribute with your own street-level views of this location via Mapillary.</string>
<string name="mapillary_widget">Mapillary widget</string>
<string name="mapillary_widget_descr">Allows you to quickly contribute to Mapillary</string>
<string name="mapillary_descr">Online street-level photos for everyone. Discover places, collaborate, capture the world.</string>
<string name="mapillary">Mapillary</string>
<string name="plugin_mapillary_descr">Street-level photos for everyone. Discover places, collaborate, capture the world.</string>
<string name="private_access_routing_req">Your destination is located in an area with private access. Do you want to allow access to the private roads for this trip?</string>
>>>>>>> 950b5efbde... Fix #3819
<string name="restart_search">Restart search</string>
<string name="increase_search_radius">Increase search radius</string>
<string name="nothing_found">Nothing found :(</string>

View file

@ -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<Void, Void, GPXUtilities.GPXFile>() {
new AsyncTask<Void, Void, GPXFile>() {
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<Void, Void, GPXUtilities.GPXFile>() {
new AsyncTask<Void, Void, GPXFile>() {
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<Void, Void, GPXUtilities.GPXFile>() {
new AsyncTask<Void, Void, GPXFile>() {
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<FavouritePoint> 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<Void, Void, GPXUtilities.GPXFile>() {
new AsyncTask<Void, Void, GPXFile>() {
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<Void, Void, String> {
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;
}