From 70ca8ebd2e776bd7728a54f5e4553ece8a2ff7c5 Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 25 May 2018 11:36:58 +0300 Subject: [PATCH] added fixes --- OsmAnd/AndroidManifest.xml | 12 ------------ OsmAnd/res/values/strings.xml | 1 - .../net/osmand/plus/helpers/DiscountHelper.java | 2 +- .../osmand/plus/wikipedia/WikiArticleHelper.java | 9 ++++++++- .../article/WikivoyageArticleDialogFragment.java | 16 +++++----------- 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index b98cc409b3..79b475c02c 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -760,18 +760,6 @@ - - - - - - - - - - - - diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 581999f7a7..bb535aef2e 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -10,7 +10,6 @@ - For wording and consistency, please note http://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience Thx - Hardy --> - Share article Get OsmAnd Live to unlock all features: Daily map updates with unlimited downloads, all paid and free plugins, Wikipedia, Wikivoyage and much more. Modification of the default style to increase contrast of pedestrian and bicycle roads. Uses legacy Mapnik colors. Bookmark diff --git a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java index a5ace9a130..5a2d1fcc1a 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java @@ -235,7 +235,7 @@ public class DiscountHelper { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, WikiArticleHelper.buildTravelUrl(url, lang)); intent.setType("text/plain"); - mapActivity.startActivity(Intent.createChooser(intent, mapActivity.getString(R.string.share_article))); + mapActivity.startActivity(Intent.createChooser(intent, mapActivity.getString(R.string.shared_string_share))); } else { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java index 902d19ee26..4836bcf4f5 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java @@ -31,6 +31,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.lang.ref.WeakReference; import java.net.URLDecoder; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; @@ -327,6 +328,12 @@ public class WikiArticleHelper { public static String buildTravelUrl(String url, String lang) { String title = url.substring(url.indexOf(':') + 1); - return "https://osmand.net/travel?query=" + title + "&lang=" + lang; + title = title.replace(" ", "_"); + try { + title = URLEncoder.encode(title, "UTF-8"); + } catch (UnsupportedEncodingException e) { + System.err.println(e.getMessage()); + } + return "https://osmand.net/travel?title=" + title + "&lang=" + lang; } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 3f6b611952..9738b7ff1a 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -34,6 +34,7 @@ import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.wikipedia.WikiArticleBaseDialogFragment; +import net.osmand.plus.wikipedia.WikiArticleHelper; import net.osmand.plus.wikivoyage.WikivoyageShowPicturesDialogFragment; import net.osmand.plus.wikivoyage.WikivoyageWebViewClient; import net.osmand.plus.wikivoyage.data.TravelArticle; @@ -135,17 +136,10 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme trackButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - FragmentActivity activity = getActivity(); - FragmentManager fm = getFragmentManager(); - if (article == null || activity == null || fm == null) { - return; - } - TravelDbHelper dbHelper = getMyApplication().getTravelDbHelper(); - File path = dbHelper.createGpxFile(article); - Intent newIntent = new Intent(activity, getMyApplication().getAppCustomization().getTrackActivity()); - newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, path.getAbsolutePath()); - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(newIntent); + Intent intent = new Intent(Intent.ACTION_SEND); + intent.putExtra(Intent.EXTRA_TEXT, WikiArticleHelper.buildTravelUrl(article.getTitle().replace(" ", "%20"), article.getLang())); + intent.setType("text/plain"); + startActivity(Intent.createChooser(intent, getString(R.string.shared_string_share))); } });