From 4ea5ab16db2b8fb1f007c018522241fcb480ded3 Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 12 Apr 2018 17:29:42 +0300 Subject: [PATCH 1/7] 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 2/7] 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 3/7] 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 4/7] 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 5/7] 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 6/7] 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 7/7] 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();