From 4ea5ab16db2b8fb1f007c018522241fcb480ded3 Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 12 Apr 2018 17:29:42 +0300 Subject: [PATCH 01/11] add options for icons cache and history --- OsmAnd/res/values/strings.xml | 5 +- .../src/net/osmand/plus/OsmandSettings.java | 2 + .../WikivoyageArticleDialogFragment.java | 4 +- ...sImagesCasheBottomSheetDialogFragment.java | 74 +++++++++++++++++++ .../WikivoyageExploreDialogFragment.java | 10 +++ .../search/SearchRecyclerViewAdapter.java | 3 +- 6 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCasheBottomSheetDialogFragment.java diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 6d00d5cf6c..6ef916f89b 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,6 +12,9 @@ Travel maps Wikivoyage Article removed + Images cache + Delete search history + Show images Search: Country, City, Province Read Saved articles @@ -311,7 +314,7 @@ Sea depth contour lines and nautical point maps. Thank you for purchasing nautical depth contours Nautical depth contours - + Worldwide Wikivoyage articles Southern hemisphere nautical depth points Northern hemisphere nautical depth points diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 4f8f2de103..68af0772d2 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -717,6 +717,8 @@ public class OsmandSettings { public final CommonPreference SHOW_LINES_TO_FIRST_MARKERS = new BooleanPreference("show_lines_to_first_markers", false).makeProfile(); public final CommonPreference SHOW_ARROWS_TO_FIRST_MARKERS = new BooleanPreference("show_arrows_to_first_markers", false).makeProfile(); + public final CommonPreference SHOW_WEBVIEW_IMAGES = new BooleanPreference("show_webview_images", false); + public final CommonPreference SELECT_MARKER_ON_SINGLE_TAP = new BooleanPreference("select_marker_on_single_tap", false).makeProfile(); public final CommonPreference COORDS_INPUT_USE_RIGHT_SIDE = new BooleanPreference("coords_input_use_right_side", true).makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 6edf4e53fa..de23079453 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -119,7 +119,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen contentWebView = (WebView) mainView.findViewById(R.id.content_web_view); contentWebView.getSettings().setJavaScriptEnabled(true); - + contentWebView.getSettings().setLoadsImagesAutomatically(getSettings().SHOW_WEBVIEW_IMAGES.get()); return mainView; } @@ -230,7 +230,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen StringBuilder sb = new StringBuilder(HEADER_INNER); String articleTitle = article.getImageTitle(); - if (!TextUtils.isEmpty(articleTitle)) { + if (!TextUtils.isEmpty(articleTitle)&&!getSettings().SHOW_WEBVIEW_IMAGES.get()) { String url = WikivoyageArticle.getImageUrl(articleTitle, false); sb.append("
"); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCasheBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCasheBottomSheetDialogFragment.java new file mode 100644 index 0000000000..a03d18bba3 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCasheBottomSheetDialogFragment.java @@ -0,0 +1,74 @@ +package net.osmand.plus.wikivoyage.explore; + +import android.os.Bundle; +import android.view.View; + +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton; +import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; +import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; +import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper; + +public class OptionsImagesCasheBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { + + public final static String TAG = "OptionsImagesCasheBottomSheetDialogFragment"; + + @Override + public void createMenuItems(Bundle savedInstanceState) { + + items.add(new TitleItem(getString(R.string.shared_string_options))); + + boolean showWebviewImages = getMyApplication().getSettings().SHOW_WEBVIEW_IMAGES.get(); + + BaseBottomSheetItem showWebviewImagesItem = new BottomSheetItemWithCompoundButton.Builder() + .setChecked(showWebviewImages) + .setIcon(getContentIcon(R.drawable.ic_type_img)) + .setTitle(getString(R.string.wikivoyage_show_images)) + .setLayoutId(R.layout.bottom_sheet_item_with_switch) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + OsmandSettings settings = getMyApplication().getSettings(); + settings.SHOW_WEBVIEW_IMAGES.set(!settings.SHOW_WEBVIEW_IMAGES.get()); + dismiss(); + } + }) + .create(); + items.add(showWebviewImagesItem); + + BaseBottomSheetItem clearCacheItem = new BottomSheetItemWithDescription.Builder() + .setDescription(getString(R.string.shared_string_clear)) + .setTitle(getString(R.string.wikivoyage_images_cache)) + .setLayoutId(R.layout.bottom_sheet_item_with_right_descr) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + dismiss(); + } + }) + .create(); + items.add(clearCacheItem); + + items.add(new DividerHalfItem(getContext())); + + BaseBottomSheetItem clearHistoryItem = new SimpleBottomSheetItem.Builder() + .setIcon(getContentIcon(R.drawable.ic_action_history)) + .setTitle(getString(R.string.shared_string_delete_search_history)) + .setLayoutId(R.layout.bottom_sheet_item_simple) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + WikivoyageLocalDataHelper.getInstance(getMyApplication()).clearHistory(); + dismiss(); + } + }) + .create(); + items.add(clearHistoryItem); + } +} diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java index 7cb8ca66f1..5a4188c8a9 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java @@ -20,6 +20,7 @@ import android.widget.TextView; import net.osmand.AndroidUtils; import net.osmand.plus.LockableViewPager; import net.osmand.plus.R; +import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment; import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment; import net.osmand.plus.wikivoyage.search.WikivoyageSearchDialogFragment; @@ -53,6 +54,15 @@ public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragmen } }); + mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + OptionsImagesCasheBottomSheetDialogFragment fragment = new OptionsImagesCasheBottomSheetDialogFragment(); + fragment.setUsedOnMap(false); + fragment.show(getChildFragmentManager(), OptionsImagesCasheBottomSheetDialogFragment.TAG); + } + }); + final LockableViewPager viewPager = (LockableViewPager) mainView.findViewById(R.id.view_pager); viewPager.setOffscreenPageLimit(2); viewPager.setSwipeLocked(true); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java index a3f2b5679f..16a7d9fa98 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java @@ -74,7 +74,8 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter Date: Thu, 12 Apr 2018 17:35:33 +0300 Subject: [PATCH 02/11] add check for downloading images in saved articles --- .../wikivoyage/article/WikivoyageArticleDialogFragment.java | 1 + .../osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index de23079453..2e5c361d7c 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -120,6 +120,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen contentWebView = (WebView) mainView.findViewById(R.id.content_web_view); contentWebView.getSettings().setJavaScriptEnabled(true); contentWebView.getSettings().setLoadsImagesAutomatically(getSettings().SHOW_WEBVIEW_IMAGES.get()); + return mainView; } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java index b4391c4169..3725d7a0c3 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -78,7 +78,8 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter Date: Thu, 12 Apr 2018 19:03:26 +0300 Subject: [PATCH 03/11] add clearCache for webView --- .../explore/OptionsImagesCasheBottomSheetDialogFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCasheBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCasheBottomSheetDialogFragment.java index a03d18bba3..c3661331fe 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCasheBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCasheBottomSheetDialogFragment.java @@ -2,6 +2,7 @@ package net.osmand.plus.wikivoyage.explore; import android.os.Bundle; import android.view.View; +import android.webkit.WebView; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; @@ -48,7 +49,7 @@ public class OptionsImagesCasheBottomSheetDialogFragment extends MenuBottomSheet .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - + new WebView(getContext()).clearCache(true); dismiss(); } }) From fc6aa1a404f9c721b94d6113e0aab12658534e78 Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 13 Apr 2018 11:29:17 +0300 Subject: [PATCH 04/11] change names and saved articles images --- OsmAnd/res/values/strings.xml | 6 ++-- .../src/net/osmand/plus/OsmandSettings.java | 2 +- .../WikivoyageArticleDialogFragment.java | 8 ++--- ...acheHistoryBottomSheetDialogFragment.java} | 14 ++++---- .../explore/SavedArticlesRvAdapter.java | 32 ++++++++++--------- .../WikivoyageExploreDialogFragment.java | 5 ++- .../search/SearchRecyclerViewAdapter.java | 2 +- 7 files changed, 35 insertions(+), 34 deletions(-) rename OsmAnd/src/net/osmand/plus/wikivoyage/explore/{OptionsImagesCasheBottomSheetDialogFragment.java => OptionsImagesCacheHistoryBottomSheetDialogFragment.java} (82%) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 6ef916f89b..d3f75c56e2 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,12 +9,12 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Images cache: + Delete search history + Show images Travel maps Wikivoyage Article removed - Images cache - Delete search history - Show images Search: Country, City, Province Read Saved articles diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 68af0772d2..67ee106e8d 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -717,7 +717,7 @@ public class OsmandSettings { public final CommonPreference SHOW_LINES_TO_FIRST_MARKERS = new BooleanPreference("show_lines_to_first_markers", false).makeProfile(); public final CommonPreference SHOW_ARROWS_TO_FIRST_MARKERS = new BooleanPreference("show_arrows_to_first_markers", false).makeProfile(); - public final CommonPreference SHOW_WEBVIEW_IMAGES = new BooleanPreference("show_webview_images", false); + public final CommonPreference SHOW_IMAGES = new BooleanPreference("show_images", false); public final CommonPreference SELECT_MARKER_ON_SINGLE_TAP = new BooleanPreference("select_marker_on_single_tap", false).makeProfile(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 2e5c361d7c..d43f33e78a 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -119,7 +119,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen contentWebView = (WebView) mainView.findViewById(R.id.content_web_view); contentWebView.getSettings().setJavaScriptEnabled(true); - contentWebView.getSettings().setLoadsImagesAutomatically(getSettings().SHOW_WEBVIEW_IMAGES.get()); + contentWebView.getSettings().setLoadsImagesAutomatically(getSettings().SHOW_IMAGES.get()); return mainView; } @@ -230,9 +230,9 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen private String createHtmlContent(@NonNull WikivoyageArticle article) { StringBuilder sb = new StringBuilder(HEADER_INNER); - String articleTitle = article.getImageTitle(); - if (!TextUtils.isEmpty(articleTitle)&&!getSettings().SHOW_WEBVIEW_IMAGES.get()) { - String url = WikivoyageArticle.getImageUrl(articleTitle, false); + String articleImageTitle = article.getImageTitle(); + if (!TextUtils.isEmpty(articleImageTitle)&&!getSettings().SHOW_IMAGES.get()) { + String url = WikivoyageArticle.getImageUrl(articleImageTitle, false); sb.append("
"); } sb.append("
\n"); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCasheBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCacheHistoryBottomSheetDialogFragment.java similarity index 82% rename from OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCasheBottomSheetDialogFragment.java rename to OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCacheHistoryBottomSheetDialogFragment.java index c3661331fe..6bdfa170b8 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCasheBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCacheHistoryBottomSheetDialogFragment.java @@ -15,7 +15,7 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper; -public class OptionsImagesCasheBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { +public class OptionsImagesCacheHistoryBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { public final static String TAG = "OptionsImagesCasheBottomSheetDialogFragment"; @@ -24,18 +24,18 @@ public class OptionsImagesCasheBottomSheetDialogFragment extends MenuBottomSheet items.add(new TitleItem(getString(R.string.shared_string_options))); - boolean showWebviewImages = getMyApplication().getSettings().SHOW_WEBVIEW_IMAGES.get(); + boolean showImages = getMyApplication().getSettings().SHOW_IMAGES.get(); BaseBottomSheetItem showWebviewImagesItem = new BottomSheetItemWithCompoundButton.Builder() - .setChecked(showWebviewImages) + .setChecked(showImages) .setIcon(getContentIcon(R.drawable.ic_type_img)) - .setTitle(getString(R.string.wikivoyage_show_images)) + .setTitle(getString(R.string.show_images)) .setLayoutId(R.layout.bottom_sheet_item_with_switch) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { OsmandSettings settings = getMyApplication().getSettings(); - settings.SHOW_WEBVIEW_IMAGES.set(!settings.SHOW_WEBVIEW_IMAGES.get()); + settings.SHOW_IMAGES.set(!settings.SHOW_IMAGES.get()); dismiss(); } }) @@ -44,7 +44,7 @@ public class OptionsImagesCasheBottomSheetDialogFragment extends MenuBottomSheet BaseBottomSheetItem clearCacheItem = new BottomSheetItemWithDescription.Builder() .setDescription(getString(R.string.shared_string_clear)) - .setTitle(getString(R.string.wikivoyage_images_cache)) + .setTitle(getString(R.string.images_cache)) .setLayoutId(R.layout.bottom_sheet_item_with_right_descr) .setOnClickListener(new View.OnClickListener() { @Override @@ -60,7 +60,7 @@ public class OptionsImagesCasheBottomSheetDialogFragment extends MenuBottomSheet BaseBottomSheetItem clearHistoryItem = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_history)) - .setTitle(getString(R.string.shared_string_delete_search_history)) + .setTitle(getString(R.string.delete_search_history)) .setLayoutId(R.layout.bottom_sheet_item_simple) .setOnClickListener(new View.OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java index 3725d7a0c3..0a69ae34d4 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -76,22 +76,24 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter Date: Fri, 13 Apr 2018 15:06:27 +0300 Subject: [PATCH 05/11] change settings name and fix articleImageTitle showing condition --- OsmAnd/res/values/strings.xml | 6 +++--- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 2 +- .../wikivoyage/article/WikivoyageArticleDialogFragment.java | 4 ++-- .../OptionsImagesCacheHistoryBottomSheetDialogFragment.java | 6 +++--- .../plus/wikivoyage/explore/SavedArticlesRvAdapter.java | 2 +- .../plus/wikivoyage/search/SearchRecyclerViewAdapter.java | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index d3f75c56e2..261e7551e3 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,9 +9,9 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> - Images cache: - Delete search history - Show images + Images cache + Delete search history + Show images Travel maps Wikivoyage Article removed diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 67ee106e8d..b686d58f9d 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -717,7 +717,7 @@ public class OsmandSettings { public final CommonPreference SHOW_LINES_TO_FIRST_MARKERS = new BooleanPreference("show_lines_to_first_markers", false).makeProfile(); public final CommonPreference SHOW_ARROWS_TO_FIRST_MARKERS = new BooleanPreference("show_arrows_to_first_markers", false).makeProfile(); - public final CommonPreference SHOW_IMAGES = new BooleanPreference("show_images", false); + public final CommonPreference WIKIVOYAGE_SHOW_IMAGES = new BooleanPreference("wikivoyage_show_images", false); public final CommonPreference SELECT_MARKER_ON_SINGLE_TAP = new BooleanPreference("select_marker_on_single_tap", false).makeProfile(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index d43f33e78a..7a308fb93e 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -119,7 +119,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen contentWebView = (WebView) mainView.findViewById(R.id.content_web_view); contentWebView.getSettings().setJavaScriptEnabled(true); - contentWebView.getSettings().setLoadsImagesAutomatically(getSettings().SHOW_IMAGES.get()); + contentWebView.getSettings().setLoadsImagesAutomatically(getSettings().WIKIVOYAGE_SHOW_IMAGES.get()); return mainView; } @@ -231,7 +231,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen StringBuilder sb = new StringBuilder(HEADER_INNER); String articleImageTitle = article.getImageTitle(); - if (!TextUtils.isEmpty(articleImageTitle)&&!getSettings().SHOW_IMAGES.get()) { + if (!TextUtils.isEmpty(articleImageTitle)&&getSettings().WIKIVOYAGE_SHOW_IMAGES.get()) { String url = WikivoyageArticle.getImageUrl(articleImageTitle, false); sb.append("
"); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCacheHistoryBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCacheHistoryBottomSheetDialogFragment.java index 6bdfa170b8..2e803c1e8b 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCacheHistoryBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCacheHistoryBottomSheetDialogFragment.java @@ -24,7 +24,7 @@ public class OptionsImagesCacheHistoryBottomSheetDialogFragment extends MenuBott items.add(new TitleItem(getString(R.string.shared_string_options))); - boolean showImages = getMyApplication().getSettings().SHOW_IMAGES.get(); + boolean showImages = getMyApplication().getSettings().WIKIVOYAGE_SHOW_IMAGES.get(); BaseBottomSheetItem showWebviewImagesItem = new BottomSheetItemWithCompoundButton.Builder() .setChecked(showImages) @@ -35,7 +35,7 @@ public class OptionsImagesCacheHistoryBottomSheetDialogFragment extends MenuBott @Override public void onClick(View v) { OsmandSettings settings = getMyApplication().getSettings(); - settings.SHOW_IMAGES.set(!settings.SHOW_IMAGES.get()); + settings.WIKIVOYAGE_SHOW_IMAGES.set(!settings.WIKIVOYAGE_SHOW_IMAGES.get()); dismiss(); } }) @@ -44,7 +44,7 @@ public class OptionsImagesCacheHistoryBottomSheetDialogFragment extends MenuBott BaseBottomSheetItem clearCacheItem = new BottomSheetItemWithDescription.Builder() .setDescription(getString(R.string.shared_string_clear)) - .setTitle(getString(R.string.images_cache)) + .setTitle(getString(R.string.images_cache)+":") .setLayoutId(R.layout.bottom_sheet_item_with_right_descr) .setOnClickListener(new View.OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java index 0a69ae34d4..461530c97d 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -76,7 +76,7 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter Date: Fri, 13 Apr 2018 16:31:11 +0300 Subject: [PATCH 06/11] Refactor some code --- .../WikivoyageArticleDialogFragment.java | 6 ++--- .../WikivoyageExploreDialogFragment.java | 18 +++++++-------- ...yageOptionsBottomSheetDialogFragment.java} | 22 +++++++++---------- .../search/SearchRecyclerViewAdapter.java | 4 ++-- 4 files changed, 25 insertions(+), 25 deletions(-) rename OsmAnd/src/net/osmand/plus/wikivoyage/explore/{OptionsImagesCacheHistoryBottomSheetDialogFragment.java => WikivoyageOptionsBottomSheetDialogFragment.java} (74%) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 7a308fb93e..fd5b3c0a00 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -230,9 +230,9 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen private String createHtmlContent(@NonNull WikivoyageArticle article) { StringBuilder sb = new StringBuilder(HEADER_INNER); - String articleImageTitle = article.getImageTitle(); - if (!TextUtils.isEmpty(articleImageTitle)&&getSettings().WIKIVOYAGE_SHOW_IMAGES.get()) { - String url = WikivoyageArticle.getImageUrl(articleImageTitle, false); + String imageTitle = article.getImageTitle(); + if (!TextUtils.isEmpty(imageTitle) && getSettings().WIKIVOYAGE_SHOW_IMAGES.get()) { + String url = WikivoyageArticle.getImageUrl(imageTitle, false); sb.append("
"); } sb.append("
\n"); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java index e6dfb46033..04d7be9e4b 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java @@ -41,6 +41,15 @@ public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragmen setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar)); + mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + WikivoyageOptionsBottomSheetDialogFragment fragment = new WikivoyageOptionsBottomSheetDialogFragment(); + fragment.setUsedOnMap(false); + fragment.show(getChildFragmentManager(), WikivoyageOptionsBottomSheetDialogFragment.TAG); + } + }); + int searchColorId = nightMode ? R.color.icon_color : R.color.ctx_menu_title_color_dark; ((TextView) mainView.findViewById(R.id.search_hint)).setTextColor(getResolvedColor(searchColorId)); ((ImageView) mainView.findViewById(R.id.search_icon)) @@ -53,15 +62,6 @@ public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragmen } }); - mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - OptionsImagesCacheHistoryBottomSheetDialogFragment fragment = new OptionsImagesCacheHistoryBottomSheetDialogFragment(); - fragment.setUsedOnMap(false); - fragment.show(getChildFragmentManager(), OptionsImagesCacheHistoryBottomSheetDialogFragment.TAG); - } - }); - final LockableViewPager viewPager = (LockableViewPager) mainView.findViewById(R.id.view_pager); viewPager.setOffscreenPageLimit(2); viewPager.setSwipeLocked(true); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCacheHistoryBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java similarity index 74% rename from OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCacheHistoryBottomSheetDialogFragment.java rename to OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java index 2e803c1e8b..e2d8c382da 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/OptionsImagesCacheHistoryBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java @@ -4,6 +4,7 @@ import android.os.Bundle; import android.view.View; import android.webkit.WebView; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.base.MenuBottomSheetDialogFragment; @@ -15,36 +16,35 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper; -public class OptionsImagesCacheHistoryBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { +public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { - public final static String TAG = "OptionsImagesCasheBottomSheetDialogFragment"; + public final static String TAG = "WikivoyageOptionsBottomSheetDialogFragment"; @Override public void createMenuItems(Bundle savedInstanceState) { + final OsmandApplication app = getMyApplication(); + final OsmandSettings.CommonPreference showImagesPref = app.getSettings().WIKIVOYAGE_SHOW_IMAGES; items.add(new TitleItem(getString(R.string.shared_string_options))); - boolean showImages = getMyApplication().getSettings().WIKIVOYAGE_SHOW_IMAGES.get(); - - BaseBottomSheetItem showWebviewImagesItem = new BottomSheetItemWithCompoundButton.Builder() - .setChecked(showImages) + BaseBottomSheetItem showImagesItem = new BottomSheetItemWithCompoundButton.Builder() + .setChecked(showImagesPref.get()) .setIcon(getContentIcon(R.drawable.ic_type_img)) .setTitle(getString(R.string.show_images)) .setLayoutId(R.layout.bottom_sheet_item_with_switch) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - OsmandSettings settings = getMyApplication().getSettings(); - settings.WIKIVOYAGE_SHOW_IMAGES.set(!settings.WIKIVOYAGE_SHOW_IMAGES.get()); + showImagesPref.set(!showImagesPref.get()); dismiss(); } }) .create(); - items.add(showWebviewImagesItem); + items.add(showImagesItem); BaseBottomSheetItem clearCacheItem = new BottomSheetItemWithDescription.Builder() .setDescription(getString(R.string.shared_string_clear)) - .setTitle(getString(R.string.images_cache)+":") + .setTitle(getString(R.string.images_cache) + ":") .setLayoutId(R.layout.bottom_sheet_item_with_right_descr) .setOnClickListener(new View.OnClickListener() { @Override @@ -65,7 +65,7 @@ public class OptionsImagesCacheHistoryBottomSheetDialogFragment extends MenuBott .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - WikivoyageLocalDataHelper.getInstance(getMyApplication()).clearHistory(); + WikivoyageLocalDataHelper.getInstance(app).clearHistory(); dismiss(); } }) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java index 0dbcfef1f4..f182249b16 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java @@ -74,8 +74,8 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter Date: Fri, 13 Apr 2018 18:11:03 +0300 Subject: [PATCH 07/11] Disable the ability to clear the images cache in wikivoyage for now. --- .../WikivoyageOptionsBottomSheetDialogFragment.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java index e2d8c382da..8267318a80 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java @@ -2,7 +2,7 @@ package net.osmand.plus.wikivoyage.explore; import android.os.Bundle; import android.view.View; -import android.webkit.WebView; +import android.widget.Toast; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; @@ -44,13 +44,13 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD BaseBottomSheetItem clearCacheItem = new BottomSheetItemWithDescription.Builder() .setDescription(getString(R.string.shared_string_clear)) - .setTitle(getString(R.string.images_cache) + ":") + .setTitle(getString(R.string.images_cache) + ": ???") // TODO : show images cache size .setLayoutId(R.layout.bottom_sheet_item_with_right_descr) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - new WebView(getContext()).clearCache(true); - dismiss(); + // TODO : implement clearing of cache + Toast.makeText(getContext(), "Currently in development", Toast.LENGTH_SHORT).show(); } }) .create(); From 3ad7d200965a929f3a43442d6c37ff6360bc307e Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Fri, 13 Apr 2018 19:00:34 +0300 Subject: [PATCH 08/11] Show cached images even if option "Show images" disabled --- .../article/WikivoyageArticleDialogFragment.java | 6 ++++-- .../wikivoyage/search/SearchRecyclerViewAdapter.java | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index fd5b3c0a00..f358e3d0c0 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -17,6 +17,7 @@ import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.TextView; @@ -117,9 +118,10 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen saveBtn = (TextView) mainView.findViewById(R.id.save_button); + boolean showImages = getSettings().WIKIVOYAGE_SHOW_IMAGES.get(); contentWebView = (WebView) mainView.findViewById(R.id.content_web_view); contentWebView.getSettings().setJavaScriptEnabled(true); - contentWebView.getSettings().setLoadsImagesAutomatically(getSettings().WIKIVOYAGE_SHOW_IMAGES.get()); + contentWebView.getSettings().setCacheMode(showImages ? WebSettings.LOAD_DEFAULT : WebSettings.LOAD_CACHE_ONLY); return mainView; } @@ -231,7 +233,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen StringBuilder sb = new StringBuilder(HEADER_INNER); String imageTitle = article.getImageTitle(); - if (!TextUtils.isEmpty(imageTitle) && getSettings().WIKIVOYAGE_SHOW_IMAGES.get()) { + if (!TextUtils.isEmpty(imageTitle)) { String url = WikivoyageArticle.getImageUrl(imageTitle, false); sb.append("
"); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java index f182249b16..300af389b0 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java @@ -12,7 +12,9 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import com.squareup.picasso.NetworkPolicy; import com.squareup.picasso.Picasso; +import com.squareup.picasso.RequestCreator; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -73,10 +75,12 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter Date: Fri, 13 Apr 2018 21:58:59 +0300 Subject: [PATCH 09/11] Show cached images even if option "Show images" disabled in Saved Articles list --- .../explore/SavedArticlesRvAdapter.java | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java index 461530c97d..393d295fd5 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -12,7 +12,9 @@ import android.widget.ImageView; import android.widget.TextView; import com.squareup.picasso.Callback; +import com.squareup.picasso.NetworkPolicy; import com.squareup.picasso.Picasso; +import com.squareup.picasso.RequestCreator; import net.osmand.AndroidUtils; import net.osmand.plus.IconsCache; @@ -76,24 +78,23 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter Date: Fri, 13 Apr 2018 23:50:53 +0300 Subject: [PATCH 10/11] Add the ability to clear wikivoyage images cache --- OsmAnd/src/net/osmand/PicassoUtils.java | 91 +++++++++++++++++++ .../WikivoyageExploreDialogFragment.java | 11 +++ ...oyageOptionsBottomSheetDialogFragment.java | 8 +- 3 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 OsmAnd/src/net/osmand/PicassoUtils.java diff --git a/OsmAnd/src/net/osmand/PicassoUtils.java b/OsmAnd/src/net/osmand/PicassoUtils.java new file mode 100644 index 0000000000..17caf47246 --- /dev/null +++ b/OsmAnd/src/net/osmand/PicassoUtils.java @@ -0,0 +1,91 @@ +package net.osmand; + +import android.content.Context; +import android.os.StatFs; +import android.support.annotation.NonNull; + +import com.squareup.picasso.LruCache; +import com.squareup.picasso.OkHttp3Downloader; +import com.squareup.picasso.Picasso; + +import java.io.File; +import java.io.IOException; + +import okhttp3.Cache; +import okhttp3.OkHttpClient; + +import static android.os.Build.VERSION.SDK_INT; +import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR2; + +public class PicassoUtils { + + private static final String PICASSO_CACHE = "picasso-cache"; + private static final int MIN_DISK_CACHE_SIZE = 5 * 1024 * 1024; // 5MB + private static final int MAX_DISK_CACHE_SIZE = 50 * 1024 * 1024; // 50MB + + private static Cache diskCache; + private static LruCache memoryCache; + + private static boolean initialized; + + public static void setupPicasso(@NonNull Context context) { + if (!initialized) { + File cacheDir = createDefaultCacheDir(context); + + diskCache = new Cache(cacheDir, calculateDiskCacheSize(cacheDir)); + memoryCache = new LruCache(context); + + Picasso picasso = new Picasso.Builder(context) + .downloader(new OkHttp3Downloader(new OkHttpClient.Builder().cache(diskCache).build())) + .memoryCache(memoryCache) + .build(); + + Picasso.setSingletonInstance(picasso); + + initialized = true; + } + } + + public static void clearAllPicassoCache() { + if (memoryCache != null) { + memoryCache.clear(); + } + if (diskCache != null) { + try { + diskCache.evictAll(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + private static File createDefaultCacheDir(Context context) { + File cache = new File(context.getApplicationContext().getCacheDir(), PICASSO_CACHE); + if (!cache.exists()) { + //noinspection ResultOfMethodCallIgnored + cache.mkdirs(); + } + return cache; + } + + private static long calculateDiskCacheSize(File dir) { + long size = MIN_DISK_CACHE_SIZE; + + try { + StatFs statFs = new StatFs(dir.getAbsolutePath()); + //noinspection deprecation + long blockCount = + SDK_INT < JELLY_BEAN_MR2 ? (long) statFs.getBlockCount() : statFs.getBlockCountLong(); + //noinspection deprecation + long blockSize = + SDK_INT < JELLY_BEAN_MR2 ? (long) statFs.getBlockSize() : statFs.getBlockSizeLong(); + long available = blockCount * blockSize; + // Target 2% of the total space. + size = available / 50; + } catch (IllegalArgumentException ignored) { + } + + // Bound inside min/max size for disk cache. + return Math.max(Math.min(size, MAX_DISK_CACHE_SIZE), MIN_DISK_CACHE_SIZE); + } +} diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java index 04d7be9e4b..b16dc7fb6c 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java @@ -1,5 +1,6 @@ package net.osmand.plus.wikivoyage.explore; +import android.content.Context; import android.content.res.ColorStateList; import android.os.Bundle; import android.support.annotation.NonNull; @@ -18,6 +19,7 @@ import android.widget.ImageView; import android.widget.TextView; import net.osmand.AndroidUtils; +import net.osmand.PicassoUtils; import net.osmand.plus.LockableViewPager; import net.osmand.plus.R; import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment; @@ -34,6 +36,15 @@ public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragmen private static final int EXPLORE_POSITION = 0; private static final int SAVED_ARTICLES_POSITION = 1; + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Context context = getContext(); + if (context != null) { + PicassoUtils.setupPicasso(context); + } + } + @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java index 8267318a80..a11039b7df 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java @@ -2,8 +2,9 @@ package net.osmand.plus.wikivoyage.explore; import android.os.Bundle; import android.view.View; -import android.widget.Toast; +import android.webkit.WebView; +import net.osmand.PicassoUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; @@ -49,8 +50,9 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - // TODO : implement clearing of cache - Toast.makeText(getContext(), "Currently in development", Toast.LENGTH_SHORT).show(); + new WebView(getContext()).clearCache(true); + PicassoUtils.clearAllPicassoCache(); + dismiss(); } }) .create(); From 4e2241ca33b631365bf17a9de541c4284a2e0693 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Fri, 13 Apr 2018 23:57:25 +0300 Subject: [PATCH 11/11] Change description text color --- .../explore/WikivoyageOptionsBottomSheetDialogFragment.java | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java index a11039b7df..b68a6f4d95 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java @@ -45,6 +45,7 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD BaseBottomSheetItem clearCacheItem = new BottomSheetItemWithDescription.Builder() .setDescription(getString(R.string.shared_string_clear)) + .setDescriptionColorId(nightMode ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light) .setTitle(getString(R.string.images_cache) + ": ???") // TODO : show images cache size .setLayoutId(R.layout.bottom_sheet_item_with_right_descr) .setOnClickListener(new View.OnClickListener() {