add header, js and fixed title textview
This commit is contained in:
parent
b867af8311
commit
be5566ad83
2 changed files with 53 additions and 2 deletions
|
@ -29,6 +29,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:textSize="@dimen/dialog_header_text_size"
|
android:textSize="@dimen/dialog_header_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium" />
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
|
@ -55,7 +55,55 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
"<meta http-equiv=\"cleartype\" content=\"on\" />\n" +
|
"<meta http-equiv=\"cleartype\" content=\"on\" />\n" +
|
||||||
"<link href=\"article_style.css\" type=\"text/css\" rel=\"stylesheet\"/>\n" +
|
"<link href=\"article_style.css\" type=\"text/css\" rel=\"stylesheet\"/>\n" +
|
||||||
"</head>";
|
"</head>";
|
||||||
private static final String FOOTER_INNER = "</body></html>";
|
private static final String FOOTER_INNER = "<script>var coll = document.getElementsByTagName(\"H2\");" +
|
||||||
|
"var i;" +
|
||||||
|
"for (i = 0; i < coll.length; i++) {" +
|
||||||
|
" coll[i].addEventListener(\"click\", function() {" +
|
||||||
|
" this.classList.toggle(\"active\");" +
|
||||||
|
" var content = this.nextElementSibling;" +
|
||||||
|
" if (content.style.display === \"block\") {" +
|
||||||
|
" content.style.display = \"none\";" +
|
||||||
|
" } else {" +
|
||||||
|
" content.style.display = \"block\";" +
|
||||||
|
" }" +
|
||||||
|
" });" +
|
||||||
|
"}" +
|
||||||
|
"document.addEventListener(\"DOMContentLoaded\", function(event) {\n" +
|
||||||
|
" document.querySelectorAll('img').forEach(function(img) {\n" +
|
||||||
|
" img.onerror = function() {\n" +
|
||||||
|
" this.style.display = 'none';\n" +
|
||||||
|
" var caption = img.parentElement.nextElementSibling;\n" +
|
||||||
|
" if (caption.className == \"thumbnailcaption\") {\n" +
|
||||||
|
" caption.style.display = 'none';\n" +
|
||||||
|
" }\n" +
|
||||||
|
" };\n" +
|
||||||
|
" })\n" +
|
||||||
|
"});" +
|
||||||
|
"function scrollAnchor(id, title) {" +
|
||||||
|
"openContent(title);" +
|
||||||
|
"window.location.hash = id;}\n" +
|
||||||
|
"function openContent(id) {\n" +
|
||||||
|
" var doc = document.getElementById(id).parentElement;\n" +
|
||||||
|
" doc.classList.toggle(\"active\");\n" +
|
||||||
|
" var content = doc.nextElementSibling;\n" +
|
||||||
|
" content.style.display = \"block\";\n" +
|
||||||
|
" collapseActive(doc);" +
|
||||||
|
"}" +
|
||||||
|
"function collapseActive(doc) {" +
|
||||||
|
" var coll = document.getElementsByTagName(\"H2\");" +
|
||||||
|
" var i;" +
|
||||||
|
" for (i = 0; i < coll.length; i++) {" +
|
||||||
|
" var item = coll[i];" +
|
||||||
|
" if (item != doc && item.classList.contains(\"active\")) {" +
|
||||||
|
" item.classList.toggle(\"active\");" +
|
||||||
|
" var content = item.nextElementSibling;" +
|
||||||
|
" if (content.style.display === \"block\") {" +
|
||||||
|
" content.style.display = \"none\";" +
|
||||||
|
" }" +
|
||||||
|
" }" +
|
||||||
|
" }" +
|
||||||
|
"}</script>"
|
||||||
|
+ "</body></html>";
|
||||||
|
|
||||||
private static final int MENU_ITEM_NO_ID = 0;
|
private static final int MENU_ITEM_NO_ID = 0;
|
||||||
private static final int MENU_ITEM_SHOW_ID = 1;
|
private static final int MENU_ITEM_SHOW_ID = 1;
|
||||||
|
@ -69,6 +117,7 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
private boolean darkMode;
|
private boolean darkMode;
|
||||||
private Amenity amenity;
|
private Amenity amenity;
|
||||||
private String lang;
|
private String lang;
|
||||||
|
private String title;
|
||||||
|
|
||||||
public void setAmenity(Amenity amenity) {
|
public void setAmenity(Amenity amenity) {
|
||||||
this.amenity = amenity;
|
this.amenity = amenity;
|
||||||
|
@ -174,6 +223,7 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
sb.append("<div class=\"main");
|
sb.append("<div class=\"main");
|
||||||
sb.append(nightModeClass);
|
sb.append(nightModeClass);
|
||||||
sb.append("\">\n");
|
sb.append("\">\n");
|
||||||
|
sb.append("<h1>").append(title).append("</h1>");
|
||||||
sb.append(article);
|
sb.append(article);
|
||||||
sb.append(FOOTER_INNER);
|
sb.append(FOOTER_INNER);
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
@ -206,7 +256,7 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
final String langSelected = lng;
|
final String langSelected = lng;
|
||||||
final String title = amenity.getName(langSelected);
|
title = amenity.getName(langSelected);
|
||||||
articleToolbarText.setText(title);
|
articleToolbarText.setText(title);
|
||||||
readFullArticleButton.setOnClickListener(new View.OnClickListener() {
|
readFullArticleButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue