Merge pull request #5201 from osmandapp/WikivoyageImprovements
add title image to article
This commit is contained in:
commit
52164ae4d5
2 changed files with 44 additions and 19 deletions
|
@ -1,12 +1,22 @@
|
|||
body {
|
||||
max-width: 100% !important;
|
||||
/* overflow-x: hidden; hide scroll bar */
|
||||
display: block;
|
||||
margin-top: 7%;
|
||||
margin-bottom: 0;
|
||||
margin-left: 7%;
|
||||
margin-right: 7%;
|
||||
background-color: white;
|
||||
margin-top: 0%;
|
||||
margin-bottom: 0%;
|
||||
margin-left: 0%;
|
||||
margin-right: 0%;
|
||||
}
|
||||
|
||||
.main {
|
||||
max-width: 100% !important;
|
||||
/* overflow-x: hidden; hide scroll bar */
|
||||
display: block;
|
||||
margin-top: 7%;
|
||||
margin-bottom: 0;
|
||||
margin-left: 7%;
|
||||
margin-right: 7%;
|
||||
background-color: white;
|
||||
font-family: sans-serif;
|
||||
|
||||
}
|
||||
|
||||
h2 {
|
||||
|
@ -15,14 +25,15 @@ h2 {
|
|||
font-family: serif;
|
||||
font-weight: bold;
|
||||
word-wrap: break-word;
|
||||
padding-top: 5%;
|
||||
}
|
||||
|
||||
h3 {
|
||||
color: #212121;
|
||||
font-size: 1.5em;
|
||||
font-family: sans-serif;
|
||||
padding-top: 5%;
|
||||
word-wrap: break-word;
|
||||
padding-top: 5%;
|
||||
}
|
||||
|
||||
p {
|
||||
|
@ -31,17 +42,18 @@ p {
|
|||
line-height: 1.6em;
|
||||
}
|
||||
|
||||
li {
|
||||
font-family: sans-serif;
|
||||
line-height: 1.6em;
|
||||
}
|
||||
|
||||
ul {
|
||||
font-size: 1.1em;
|
||||
line-height: 1.6em;
|
||||
padding-top: 3%;
|
||||
padding-bottom: 3%;
|
||||
}
|
||||
|
||||
li {
|
||||
font-family: sans-serif;
|
||||
padding-top: 1%;
|
||||
padding-bottom: 1%;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
|
@ -79,4 +91,4 @@ pre {
|
|||
color: #727272;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@ import net.osmand.IndexConstants;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.wikivoyage.data.WikivoyageArticle;
|
||||
import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -36,8 +37,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n" +
|
||||
"<meta http-equiv=\"cleartype\" content=\"on\" />\n" +
|
||||
"<link href=\"article_style.css\" type=\"text/css\" rel=\"stylesheet\"/>\n" +
|
||||
"</head><body>\n" +
|
||||
"<div class=\"main\">\n";
|
||||
"</head><body>";
|
||||
private static final String FOOTER_INNER = "</div></body></html>";
|
||||
|
||||
private WikivoyageSearchResult searchResult;
|
||||
|
@ -140,9 +140,22 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
if (article == null) {
|
||||
return;
|
||||
}
|
||||
String articleTitle = "<h1>" + article.getTitle() + "</h1>";
|
||||
String content = HEADER_INNER + articleTitle + article.getContent() + FOOTER_INNER;
|
||||
contentWebView.loadDataWithBaseURL(getBaseUrl(), content, "text/html", "UTF-8", null);
|
||||
|
||||
contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(article), "text/html", "UTF-8", null);
|
||||
}
|
||||
|
||||
private String createHtmlContent(WikivoyageArticle article) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(HEADER_INNER);
|
||||
String articleTitle = article.getImageTitle();
|
||||
if (!Algorithms.isEmpty(articleTitle)) {
|
||||
stringBuilder.append("<img class=\"title-image\" src=\"").append(WikivoyageArticle.getImageUrl(articleTitle)).append("\"/>");
|
||||
}
|
||||
stringBuilder.append("<div class=\"main\">\n");
|
||||
stringBuilder.append("<h1>").append(article.getTitle()).append("</h1>");
|
||||
stringBuilder.append(article.getContent()).append(FOOTER_INNER);
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
Loading…
Reference in a new issue