add nigntmode and xml changes

This commit is contained in:
Chumva 2018-04-27 16:30:21 +03:00
parent 97f6fff8c2
commit a3e1307452
2 changed files with 29 additions and 21 deletions

View file

@ -17,21 +17,19 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
android:layout_weight="1"
android:paddingTop="22dp"
android:paddingLeft="@dimen/list_content_padding"
android:paddingStart="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:paddingEnd="@dimen/list_content_padding"
android:text="@string/wikivoyage_download_pics"
android:textColor="?android:attr/textColorPrimary"
android:textStyle="bold"
android:textSize="@dimen/dialog_header_text_size"/>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/list_content_padding"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:layout_marginStart="@dimen/list_content_padding"
android:layout_marginTop="@dimen/bottom_sheet_icon_margin"
android:textSize="@dimen/empty_state_text_size"
android:textColor="?attr/wikivoyage_primary_text_color"
android:text="@string/wikivoyage_download_pics" />
</LinearLayout>

View file

@ -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<String, String> names = new HashMap<>();
for (String n : langs) {
names.put(n, FileNameTranslationHelper.getVoiceName(getContext(), n));
}
for (final Map.Entry<String, String> 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("<div class=\"title-image\" style=\"background-image: url(").append(url).append(")\"></div>");
}
sb.append("<div class=\"main\">\n");
String nightModeClass = nightMode?"nightmode":"";
sb.append("<div class=\"main "+nightModeClass+"\">\n");
sb.append("<h1>").append(article.getTitle()).append("</h1>");
sb.append(article.getContent());
sb.append(FOOTER_INNER);