From a3e130745203bf23bd819ef6fe2219d0b6c01f16 Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 27 Apr 2018 16:30:21 +0300 Subject: [PATCH] add nigntmode and xml changes --- ...ment_wikivoyage_show_images_first_time.xml | 28 +++++++++---------- .../WikivoyageArticleDialogFragment.java | 22 +++++++++++---- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/OsmAnd/res/layout/fragment_wikivoyage_show_images_first_time.xml b/OsmAnd/res/layout/fragment_wikivoyage_show_images_first_time.xml index 5d45215f3d..1e194a3a08 100644 --- a/OsmAnd/res/layout/fragment_wikivoyage_show_images_first_time.xml +++ b/OsmAnd/res/layout/fragment_wikivoyage_show_images_first_time.xml @@ -17,21 +17,19 @@ android:layout_height="wrap_content" android:orientation="horizontal"> - + diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index fb2b9eea91..725f006124 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -30,6 +30,7 @@ import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings.WikivoyageShowImages; import net.osmand.plus.R; import net.osmand.plus.activities.TrackActivity; +import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment; import net.osmand.plus.wikivoyage.WikivoyageShowPicturesDialogFragment; import net.osmand.plus.wikivoyage.WikivoyageWebViewClient; @@ -40,6 +41,8 @@ import net.osmand.util.Algorithms; import java.io.File; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragment { @@ -321,22 +324,26 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen if (langs == null) { return; } - final PopupMenu popup = new PopupMenu(view.getContext(), view, Gravity.END); - for (final String lang : langs) { + Map names = new HashMap<>(); + for (String n : langs) { + names.put(n, FileNameTranslationHelper.getVoiceName(getContext(), n)); + } + for (final Map.Entry e : names.entrySet()) { + final String lang = e.getValue(); + final String langKey = e.getKey(); MenuItem item = popup.getMenu().add(lang); item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { - if (!selectedLang.equals(lang)) { - selectedLang = lang; + if (!selectedLang.equals(langKey)) { + selectedLang = langKey; populateArticle(); } return true; } }); } - popup.show(); } @@ -408,7 +415,10 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen String url = TravelArticle.getImageUrl(imageTitle, false); sb.append("
"); } - sb.append("
\n"); + + String nightModeClass = nightMode?"nightmode":""; + + sb.append("
\n"); sb.append("

").append(article.getTitle()).append("

"); sb.append(article.getContent()); sb.append(FOOTER_INNER);