add options for icons cache and history

This commit is contained in:
Chumva 2018-04-12 17:29:42 +03:00
parent e7f3d987d8
commit 4ea5ab16db
6 changed files with 94 additions and 4 deletions

View file

@ -12,6 +12,9 @@
<string name="download_maps_travel">Travel maps</string>
<string name="shared_string_wikivoyage">Wikivoyage</string>
<string name="article_removed">Article removed</string>
<string name="wikivoyage_images_cache">Images cache</string>
<string name="shared_string_delete_search_history">Delete search history</string>
<string name="wikivoyage_show_images">Show images</string>
<string name="wikivoyage_search_hint">Search: Country, City, Province</string>
<string name="shared_string_read">Read</string>
<string name="saved_articles">Saved articles</string>
@ -311,7 +314,7 @@
<string name="depth_contour_descr">Sea depth contour lines and nautical point maps.</string>
<string name="sea_depth_thanks">Thank you for purchasing nautical depth contours</string>
<string name="index_item_depth_contours_osmand_ext">Nautical depth contours</string>
<string name="index_item_world_wikivoyage">Worldwide Wikivoyage articles</string>
<string name="index_item_depth_points_southern_hemisphere">Southern hemisphere nautical depth points </string>
<string name="index_item_depth_points_northern_hemisphere">Northern hemisphere nautical depth points</string>

View file

@ -717,6 +717,8 @@ public class OsmandSettings {
public final CommonPreference<Boolean> SHOW_LINES_TO_FIRST_MARKERS = new BooleanPreference("show_lines_to_first_markers", false).makeProfile();
public final CommonPreference<Boolean> SHOW_ARROWS_TO_FIRST_MARKERS = new BooleanPreference("show_arrows_to_first_markers", false).makeProfile();
public final CommonPreference<Boolean> SHOW_WEBVIEW_IMAGES = new BooleanPreference("show_webview_images", false);
public final CommonPreference<Boolean> SELECT_MARKER_ON_SINGLE_TAP = new BooleanPreference("select_marker_on_single_tap", false).makeProfile();
public final CommonPreference<Boolean> COORDS_INPUT_USE_RIGHT_SIDE = new BooleanPreference("coords_input_use_right_side", true).makeGlobal();

View file

@ -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("<div class=\"title-image\" style=\"background-image: url(").append(url).append(")\"></div>");
}

View file

@ -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);
}
}

View file

@ -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);

View file

@ -74,7 +74,8 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView
if (item instanceof WikivoyageSearchResult) {
WikivoyageSearchResult searchRes = (WikivoyageSearchResult) item;
Picasso.get()
.load(WikivoyageArticle.getImageUrl(searchRes.getImageTitle(), true))
.load(app.getSettings().SHOW_WEBVIEW_IMAGES.get() ?
WikivoyageArticle.getImageUrl(searchRes.getImageTitle(), true) : null)
.transform(new CropCircleTransformation())
.placeholder(placeholder)
.into(holder.icon);