From 2e6731a6546ccef78bfe15a0c2e37f70ad9d6c63 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 3 Apr 2018 14:13:58 +0300 Subject: [PATCH 1/6] add title image to article --- .../plus/wikivoyage/WikivoyageArticleDialogFragment.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index 2f257cec3e..36b8e66774 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -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; @@ -140,8 +141,13 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen if (article == null) { return; } + String articleTitle = "

" + article.getTitle() + "

"; - String content = HEADER_INNER + articleTitle + article.getContent() + FOOTER_INNER; + String articleTitleImage = ""; + if (!Algorithms.isEmpty(article.getImageTitle())) { + articleTitleImage = ""; + } + String content = HEADER_INNER + articleTitleImage + articleTitle + article.getContent() + FOOTER_INNER; contentWebView.loadDataWithBaseURL(getBaseUrl(), content, "text/html", "UTF-8", null); } From 762c7062e2014fa63ff6e2c5eb72561c75e7f976 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 3 Apr 2018 15:20:36 +0300 Subject: [PATCH 2/6] add method createHtmlContent and chabge css --- OsmAnd/assets/article_style.css | 40 ++++++++++++------- .../WikivoyageArticleDialogFragment.java | 20 ++++++---- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/OsmAnd/assets/article_style.css b/OsmAnd/assets/article_style.css index 7a9dd26943..534c1ba94e 100644 --- a/OsmAnd/assets/article_style.css +++ b/OsmAnd/assets/article_style.css @@ -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; -} +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index 36b8e66774..58bda6370b 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -37,8 +37,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen "\n" + "\n" + "\n" + - "\n" + - "
\n"; + ""; private static final String FOOTER_INNER = "
"; private WikivoyageSearchResult searchResult; @@ -142,13 +141,20 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen return; } - String articleTitle = "

" + article.getTitle() + "

"; - String articleTitleImage = ""; + contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(article), "text/html", "UTF-8", null); + } + + private String createHtmlContent(WikivoyageArticle article) { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(HEADER_INNER); if (!Algorithms.isEmpty(article.getImageTitle())) { - articleTitleImage = ""; + stringBuilder.append(""); } - String content = HEADER_INNER + articleTitleImage + articleTitle + article.getContent() + FOOTER_INNER; - contentWebView.loadDataWithBaseURL(getBaseUrl(), content, "text/html", "UTF-8", null); + stringBuilder.append("
\n"); + stringBuilder.append("

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

"); + stringBuilder.append(article.getContent()).append(FOOTER_INNER); + + return stringBuilder.toString(); } @NonNull From 126b7003ad6f4f20808a04e6795a61402b543255 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 3 Apr 2018 15:21:50 +0300 Subject: [PATCH 3/6] add articleTitle to createHtmlContent method --- .../plus/wikivoyage/WikivoyageArticleDialogFragment.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index 58bda6370b..58c1056c7b 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -147,8 +147,9 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen private String createHtmlContent(WikivoyageArticle article) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(HEADER_INNER); - if (!Algorithms.isEmpty(article.getImageTitle())) { - stringBuilder.append(""); + String articleTitle = article.getImageTitle(); + if (!Algorithms.isEmpty(articleTitle)) { + stringBuilder.append(""); } stringBuilder.append("
\n"); stringBuilder.append("

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

"); From b651b913c0b3160489e7e4b2d64d67a78962b6a9 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 3 Apr 2018 15:25:20 +0300 Subject: [PATCH 4/6] Add "Picasso" library; show header images in wikivoyage search list --- OsmAnd/build.gradle | 2 + .../wikivoyage_search_placeholder.xml | 24 +++++++++ .../layout/wikivoyage_search_list_item.xml | 4 +- .../tools/CropCircleTransformation.java | 49 +++++++++++++++++++ .../search/SearchRecyclerViewAdapter.java | 28 ++++++++--- 5 files changed, 97 insertions(+), 10 deletions(-) create mode 100644 OsmAnd/res/drawable/wikivoyage_search_placeholder.xml create mode 100644 OsmAnd/src/net/osmand/plus/widgets/tools/CropCircleTransformation.java diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index 2f003cfe52..e7a96711c7 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -414,6 +414,8 @@ dependencies { compile 'com.moparisthebest:junidecode:0.1.1' compile 'org.immutables:gson:2.5.0' compile 'com.vividsolutions:jts-core:1.14.0' + + compile 'com.squareup.picasso:picasso:2.71828' // size restrictions // compile 'com.ibm.icu:icu4j:50.1' // compile 'net.sf.trove4j:trove4j:3.0.3' diff --git a/OsmAnd/res/drawable/wikivoyage_search_placeholder.xml b/OsmAnd/res/drawable/wikivoyage_search_placeholder.xml new file mode 100644 index 0000000000..b93920d87e --- /dev/null +++ b/OsmAnd/res/drawable/wikivoyage_search_placeholder.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + diff --git a/OsmAnd/res/layout/wikivoyage_search_list_item.xml b/OsmAnd/res/layout/wikivoyage_search_list_item.xml index 45f73908ef..6054c31bc4 100644 --- a/OsmAnd/res/layout/wikivoyage_search_list_item.xml +++ b/OsmAnd/res/layout/wikivoyage_search_list_item.xml @@ -22,8 +22,8 @@ items = new ArrayList<>(); @@ -35,7 +41,11 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter Date: Tue, 3 Apr 2018 15:33:40 +0300 Subject: [PATCH 5/6] Format WikivoyageArticleDialogFragment#createHtmlContent --- .../WikivoyageArticleDialogFragment.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index 58c1056c7b..c82f75f5c0 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -9,6 +9,7 @@ import android.support.annotation.Nullable; import android.support.v4.app.FragmentManager; import android.support.v7.widget.PopupMenu; import android.support.v7.widget.Toolbar; +import android.text.TextUtils; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MenuItem; @@ -22,7 +23,6 @@ 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; @@ -144,18 +144,21 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen 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(""); - } - stringBuilder.append("
\n"); - stringBuilder.append("

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

"); - stringBuilder.append(article.getContent()).append(FOOTER_INNER); + @NonNull + private String createHtmlContent(@NonNull WikivoyageArticle article) { + StringBuilder sb = new StringBuilder(HEADER_INNER); - return stringBuilder.toString(); + String articleTitle = article.getImageTitle(); + if (!TextUtils.isEmpty(articleTitle)) { + String url = WikivoyageArticle.getImageUrl(articleTitle); + sb.append(""); + } + sb.append("
\n"); + sb.append("

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

"); + sb.append(article.getContent()); + sb.append(FOOTER_INNER); + + return sb.toString(); } @NonNull From 8b2eed3f9836c3e5c61d71fdaae588718029490e Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 3 Apr 2018 16:23:30 +0300 Subject: [PATCH 6/6] Update wikivoyage db scheme --- .../net/osmand/plus/wikivoyage/data/WikivoyageArticle.java | 5 +++++ .../net/osmand/plus/wikivoyage/data/WikivoyageDbHelper.java | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java index fc288174ad..ab7595f7e1 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java @@ -24,6 +24,7 @@ public class WikivoyageArticle { long cityId; long originalId; String lang; + String aggregatedPartOf; public String getId() { return id; @@ -69,6 +70,10 @@ public class WikivoyageArticle { return lang; } + public String getAggregatedPartOf() { + return aggregatedPartOf; + } + @NonNull public static String getThumbImageUrl(@NonNull String imageTitle) { String[] hash = getHash(imageTitle); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageDbHelper.java index 3781de1421..04f70d8dec 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageDbHelper.java @@ -39,6 +39,7 @@ public class WikivoyageDbHelper { private static final String ARTICLES_COL_CITY_ID = "city_id"; private static final String ARTICLES_COL_ORIGINAL_ID = "original_id"; private static final String ARTICLES_COL_LANG = "lang"; + private static final String ARTICLES_COL_AGGREGATED_PART_OF = "aggregated_part_of"; private static final String ARTICLES_TABLE_SELECT = "SELECT " + ARTICLES_COL_ID + ", " + @@ -51,7 +52,8 @@ public class WikivoyageDbHelper { ARTICLES_COL_GPX_GZ + ", " + ARTICLES_COL_CITY_ID + ", " + ARTICLES_COL_ORIGINAL_ID + ", " + - ARTICLES_COL_LANG + + ARTICLES_COL_LANG + ", " + + ARTICLES_COL_AGGREGATED_PART_OF + " FROM " + ARTICLES_TABLE_NAME; private static final String SEARCH_TABLE_NAME = "wikivoyage_search"; @@ -210,6 +212,7 @@ public class WikivoyageDbHelper { res.cityId = cursor.getLong(8); res.originalId = cursor.getLong(9); res.lang = cursor.getString(10); + res.aggregatedPartOf = cursor.getString(11); return res; }