added fixes

This commit is contained in:
Chumva 2018-05-25 11:36:58 +03:00
parent fff98d810d
commit d493e5ef15
5 changed files with 14 additions and 26 deletions

View file

@ -760,18 +760,6 @@
<intent-filter>
<data android:scheme="http" />
<data android:host="osmand.net" />
<data android:pathPrefix="/travel" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.APP_MAPS" />
<category android:name="android.intent.category.CAR_MODE" />
<category android:name="android.intent.category.CAR_DOCK" />
<category android:name="android.intent.category.DESK_DOCK" />
</intent-filter>
<intent-filter>
<data android:scheme="https" />
<data android:host="osmand.net" />
<data android:pathPrefix="/travel" />

View file

@ -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
-->
<string name="share_article">Share article</string>
<string name="get_osmand_live">Get OsmAnd Live to unlock all features: Daily map updates with unlimited downloads, all paid and free plugins, Wikipedia, Wikivoyage and much more.</string>
<string name="unirs_render_descr">Modification of the default style to increase contrast of pedestrian and bicycle roads. Uses legacy Mapnik colors.</string>
<string name="shared_string_bookmark">Bookmark</string>

View file

@ -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));

View file

@ -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;
}
}

View file

@ -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)));
}
});