Merge pull request #5333 from osmandapp/WikipediaImprovements
Wikipedia improvements
This commit is contained in:
commit
dac34e8a44
18 changed files with 232 additions and 301 deletions
|
@ -29,6 +29,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:textSize="@dimen/dialog_header_text_size"
|
android:textSize="@dimen/dialog_header_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium" />
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
|
@ -717,8 +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_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_ARROWS_TO_FIRST_MARKERS = new BooleanPreference("show_arrows_to_first_markers", false).makeProfile();
|
||||||
|
|
||||||
public final CommonPreference<Boolean> WIKIVOYAGE_SHOW_IMAGES_ASKED = new BooleanPreference("wikivoyage_show_images_asked", false).makeGlobal();
|
public final CommonPreference<Boolean> WIKI_ARTICLE_SHOW_IMAGES_ASKED = new BooleanPreference("wikivoyage_show_images_asked", false).makeGlobal();
|
||||||
public final CommonPreference<WikivoyageShowImages> WIKIVOYAGE_SHOW_IMAGES = new EnumIntPreference<>("wikivoyage_show_imgs", WikivoyageShowImages.OFF, WikivoyageShowImages.values()).makeGlobal();
|
public final CommonPreference<WikiArticleShowImages> WIKI_ARTICLE_SHOW_IMAGES = new EnumIntPreference<>("wikivoyage_show_imgs", WikiArticleShowImages.OFF, WikiArticleShowImages.values()).makeGlobal();
|
||||||
|
|
||||||
public final CommonPreference<Boolean> SELECT_MARKER_ON_SINGLE_TAP = new BooleanPreference("select_marker_on_single_tap", false).makeProfile();
|
public final CommonPreference<Boolean> SELECT_MARKER_ON_SINGLE_TAP = new BooleanPreference("select_marker_on_single_tap", false).makeProfile();
|
||||||
|
|
||||||
|
@ -3315,14 +3315,14 @@ public class OsmandSettings {
|
||||||
EMPTY
|
EMPTY
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum WikivoyageShowImages {
|
public enum WikiArticleShowImages {
|
||||||
ON(R.string.shared_string_on),
|
ON(R.string.shared_string_on),
|
||||||
OFF(R.string.shared_string_off),
|
OFF(R.string.shared_string_off),
|
||||||
WIFI(R.string.shared_string_wifi_only);
|
WIFI(R.string.shared_string_wifi_only);
|
||||||
|
|
||||||
public final int name;
|
public final int name;
|
||||||
|
|
||||||
WikivoyageShowImages(int name) {
|
WikiArticleShowImages(int name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
|
||||||
settings.MAPILLARY_FIRST_DIALOG_SHOWN.set(false);
|
settings.MAPILLARY_FIRST_DIALOG_SHOWN.set(false);
|
||||||
settings.WEBGL_SUPPORTED.set(true);
|
settings.WEBGL_SUPPORTED.set(true);
|
||||||
settings.METRIC_SYSTEM_CHANGED_MANUALLY.set(false);
|
settings.METRIC_SYSTEM_CHANGED_MANUALLY.set(false);
|
||||||
settings.WIKIVOYAGE_SHOW_IMAGES_ASKED.set(false);
|
settings.WIKI_ARTICLE_SHOW_IMAGES_ASKED.set(false);
|
||||||
|
|
||||||
getMyApplication().showToastMessage(R.string.shared_string_ok);
|
getMyApplication().showToastMessage(R.string.shared_string_ok);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -34,7 +34,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.FontCache;
|
import net.osmand.plus.helpers.FontCache;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
import net.osmand.plus.mapcontextmenu.WikipediaDialogFragment;
|
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
|
||||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
import net.osmand.plus.views.POIMapLayer;
|
import net.osmand.plus.views.POIMapLayer;
|
||||||
|
|
|
@ -17,7 +17,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.WikipediaDialogFragment;
|
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
|
||||||
import net.osmand.plus.mapcontextmenu.builders.AmenityMenuBuilder;
|
import net.osmand.plus.mapcontextmenu.builders.AmenityMenuBuilder;
|
||||||
import net.osmand.plus.render.RenderingIcons;
|
import net.osmand.plus.render.RenderingIcons;
|
||||||
import net.osmand.plus.resources.TransportIndexRepository;
|
import net.osmand.plus.resources.TransportIndexRepository;
|
||||||
|
|
|
@ -0,0 +1,154 @@
|
||||||
|
package net.osmand.plus.wikipedia;
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.support.annotation.ColorRes;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.webkit.WebSettings;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.IndexConstants;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.wikivoyage.WikiBaseDialogFragment;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public abstract class WikiArticleBaseDialogFragment extends WikiBaseDialogFragment {
|
||||||
|
|
||||||
|
protected static final String HEADER_INNER = "<html><head>\n" +
|
||||||
|
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n" +
|
||||||
|
"<meta http-equiv=\"cleartype\" content=\"on\" />\n" +
|
||||||
|
"<link href=\"article_style.css\" type=\"text/css\" rel=\"stylesheet\"/>\n" +
|
||||||
|
"<script type=\"text/javascript\">" +
|
||||||
|
"function showNavigation() {" +
|
||||||
|
" Android.showNavigation();" +
|
||||||
|
"}" +
|
||||||
|
"</script>" +
|
||||||
|
"</head>";
|
||||||
|
protected static final String FOOTER_INNER = "<script>var coll = document.getElementsByTagName(\"H2\");" +
|
||||||
|
"var i;" +
|
||||||
|
"for (i = 0; i < coll.length; i++) {" +
|
||||||
|
" coll[i].addEventListener(\"click\", function() {" +
|
||||||
|
" this.classList.toggle(\"active\");" +
|
||||||
|
" var content = this.nextElementSibling;" +
|
||||||
|
" if (content.style.display === \"block\") {" +
|
||||||
|
" content.style.display = \"none\";" +
|
||||||
|
" } else {" +
|
||||||
|
" content.style.display = \"block\";" +
|
||||||
|
" }" +
|
||||||
|
" });" +
|
||||||
|
"}" +
|
||||||
|
"document.addEventListener(\"DOMContentLoaded\", function(event) {\n" +
|
||||||
|
" document.querySelectorAll('img').forEach(function(img) {\n" +
|
||||||
|
" img.onerror = function() {\n" +
|
||||||
|
" this.style.display = 'none';\n" +
|
||||||
|
" var caption = img.parentElement.nextElementSibling;\n" +
|
||||||
|
" if (caption.className == \"thumbnailcaption\") {\n" +
|
||||||
|
" caption.style.display = 'none';\n" +
|
||||||
|
" }\n" +
|
||||||
|
" };\n" +
|
||||||
|
" })\n" +
|
||||||
|
"});" +
|
||||||
|
"function scrollAnchor(id, title) {" +
|
||||||
|
"openContent(title);" +
|
||||||
|
"window.location.hash = id;}\n" +
|
||||||
|
"function openContent(id) {\n" +
|
||||||
|
" var doc = document.getElementById(id).parentElement;\n" +
|
||||||
|
" doc.classList.toggle(\"active\");\n" +
|
||||||
|
" var content = doc.nextElementSibling;\n" +
|
||||||
|
" content.style.display = \"block\";\n" +
|
||||||
|
" collapseActive(doc);" +
|
||||||
|
"}" +
|
||||||
|
"function collapseActive(doc) {" +
|
||||||
|
" var coll = document.getElementsByTagName(\"H2\");" +
|
||||||
|
" var i;" +
|
||||||
|
" for (i = 0; i < coll.length; i++) {" +
|
||||||
|
" var item = coll[i];" +
|
||||||
|
" if (item != doc && item.classList.contains(\"active\")) {" +
|
||||||
|
" item.classList.toggle(\"active\");" +
|
||||||
|
" var content = item.nextElementSibling;" +
|
||||||
|
" if (content.style.display === \"block\") {" +
|
||||||
|
" content.style.display = \"none\";" +
|
||||||
|
" }" +
|
||||||
|
" }" +
|
||||||
|
" }" +
|
||||||
|
"}</script>"
|
||||||
|
+ "</body></html>";
|
||||||
|
|
||||||
|
protected WebView contentWebView;
|
||||||
|
protected TextView selectedLangTv;
|
||||||
|
protected TextView articleToolbarText;
|
||||||
|
|
||||||
|
|
||||||
|
protected void updateWebSettings() {
|
||||||
|
OsmandSettings.WikiArticleShowImages showImages = getSettings().WIKI_ARTICLE_SHOW_IMAGES.get();
|
||||||
|
WebSettings webSettings = contentWebView.getSettings();
|
||||||
|
switch (showImages) {
|
||||||
|
case ON:
|
||||||
|
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
|
||||||
|
break;
|
||||||
|
case OFF:
|
||||||
|
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ONLY);
|
||||||
|
break;
|
||||||
|
case WIFI:
|
||||||
|
webSettings.setCacheMode(getMyApplication().getSettings().isWifiConnected() ?
|
||||||
|
WebSettings.LOAD_DEFAULT : WebSettings.LOAD_CACHE_ONLY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
protected String getBaseUrl() {
|
||||||
|
File wikivoyageDir = getMyApplication().getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR);
|
||||||
|
if (new File(wikivoyageDir, "article_style.css").exists()) {
|
||||||
|
return "file://" + wikivoyageDir.getAbsolutePath() + "/";
|
||||||
|
}
|
||||||
|
return "file:///android_asset/";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeOutHTML(StringBuilder sb, File file) {
|
||||||
|
BufferedWriter writer = null;
|
||||||
|
try {
|
||||||
|
writer = new BufferedWriter(new FileWriter(file));
|
||||||
|
writer.write(sb.toString());
|
||||||
|
writer.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.w("ArticleDialog", e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void moveToAnchor(String id, String title) {
|
||||||
|
contentWebView.loadUrl("javascript:scrollAnchor(\"" + id + "\", \"" + title.trim() + "\")");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
protected Drawable getSelectedLangIcon() {
|
||||||
|
Drawable normal = getContentIcon(R.drawable.ic_action_map_language);
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
Drawable active = getActiveIcon(R.drawable.ic_action_map_language);
|
||||||
|
return AndroidUtils.createPressedStateListDrawable(normal, active);
|
||||||
|
}
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@ColorRes
|
||||||
|
protected int getStatusBarColor() {
|
||||||
|
return nightMode ? R.color.status_bar_wikivoyage_article_dark : R.color.status_bar_wikivoyage_article_light;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void showPopupLangMenu(View view, final String langSelected);
|
||||||
|
|
||||||
|
protected abstract void populateArticle();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
protected abstract String createHtmlContent();
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package net.osmand.plus.mapcontextmenu;
|
package net.osmand.plus.wikipedia;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
@ -6,10 +6,7 @@ import android.content.Context;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.ColorInt;
|
|
||||||
import android.support.annotation.ColorRes;
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.customtabs.CustomTabsIntent;
|
import android.support.customtabs.CustomTabsIntent;
|
||||||
|
@ -24,51 +21,38 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.IndexConstants;
|
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
|
||||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
|
||||||
public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
public class WikipediaDialogFragment extends WikiArticleBaseDialogFragment {
|
||||||
|
|
||||||
public static final String TAG = "WikipediaDialogFragment";
|
public static final String TAG = "WikipediaDialogFragment";
|
||||||
|
|
||||||
private static final String HEADER_INNER = "<html><head>\n" +
|
|
||||||
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n" +
|
|
||||||
"<meta http-equiv=\"cleartype\" content=\"on\" />\n" +
|
|
||||||
"<link href=\"article_style.css\" type=\"text/css\" rel=\"stylesheet\"/>\n" +
|
|
||||||
"</head>";
|
|
||||||
private static final String FOOTER_INNER = "</body></html>";
|
|
||||||
|
|
||||||
private static final int MENU_ITEM_NO_ID = 0;
|
private static final int MENU_ITEM_NO_ID = 0;
|
||||||
private static final int MENU_ITEM_SHOW_ID = 1;
|
private static final int MENU_ITEM_SHOW_ID = 1;
|
||||||
private static final int MENU_ITEM_WIFI_ID = 2;
|
private static final int MENU_ITEM_WIFI_ID = 2;
|
||||||
|
|
||||||
private WebView contentWebView;
|
|
||||||
private TextView articleToolbarText;
|
|
||||||
private TextView readFullArticleButton;
|
private TextView readFullArticleButton;
|
||||||
private TextView selectLanguageTextView;
|
|
||||||
|
|
||||||
private boolean darkMode;
|
|
||||||
private Amenity amenity;
|
private Amenity amenity;
|
||||||
private String lang;
|
private String lang;
|
||||||
|
private String title;
|
||||||
|
private String article;
|
||||||
|
|
||||||
public void setAmenity(Amenity amenity) {
|
public void setAmenity(Amenity amenity) {
|
||||||
this.amenity = amenity;
|
this.amenity = amenity;
|
||||||
|
@ -78,32 +62,6 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
this.lang = lang;
|
this.lang = lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
OsmandApplication app = getMyApplication();
|
|
||||||
darkMode = app.getDaynightHelper().isNightMode() || !app.getSettings().isLightContent();
|
|
||||||
int themeId = darkMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
|
||||||
setStyle(STYLE_NO_FRAME, themeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
int themeId = darkMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme_LightStatusBar;
|
|
||||||
Dialog dialog = new Dialog(getContext(), themeId);
|
|
||||||
Window window = dialog.getWindow();
|
|
||||||
if (window != null) {
|
|
||||||
if (!getSettings().DO_NOT_USE_ANIMATIONS.get()) {
|
|
||||||
window.getAttributes().windowAnimations = R.style.Animations_Alpha;
|
|
||||||
}
|
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
|
||||||
window.setStatusBarColor(getResolvedColor(getStatusBarColor()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
|
@ -114,18 +72,18 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
|
|
||||||
articleToolbarText = (TextView) mainView.findViewById(R.id.title_text_view);
|
articleToolbarText = (TextView) mainView.findViewById(R.id.title_text_view);
|
||||||
|
|
||||||
ColorStateList buttonColorStateList = AndroidUtils.createPressedColorStateList(getContext(), darkMode,
|
ColorStateList buttonColorStateList = AndroidUtils.createPressedColorStateList(getContext(), nightMode,
|
||||||
R.color.ctx_menu_controller_button_text_color_light_n, R.color.ctx_menu_controller_button_text_color_light_p,
|
R.color.ctx_menu_controller_button_text_color_light_n, R.color.ctx_menu_controller_button_text_color_light_p,
|
||||||
R.color.ctx_menu_controller_button_text_color_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p);
|
R.color.ctx_menu_controller_button_text_color_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p);
|
||||||
|
|
||||||
ColorStateList selectedLangColorStateList = AndroidUtils.createPressedColorStateList(
|
ColorStateList selectedLangColorStateList = AndroidUtils.createPressedColorStateList(
|
||||||
getContext(), darkMode,
|
getContext(), nightMode,
|
||||||
R.color.icon_color, R.color.wikivoyage_active_light,
|
R.color.icon_color, R.color.wikivoyage_active_light,
|
||||||
R.color.icon_color, R.color.wikivoyage_active_dark
|
R.color.icon_color, R.color.wikivoyage_active_dark
|
||||||
);
|
);
|
||||||
|
|
||||||
readFullArticleButton = (TextView) mainView.findViewById(R.id.read_full_article);
|
readFullArticleButton = (TextView) mainView.findViewById(R.id.read_full_article);
|
||||||
readFullArticleButton.setBackgroundResource(darkMode ? R.drawable.bt_round_long_night : R.drawable.bt_round_long_day);
|
readFullArticleButton.setBackgroundResource(nightMode ? R.drawable.bt_round_long_night : R.drawable.bt_round_long_day);
|
||||||
readFullArticleButton.setTextColor(buttonColorStateList);
|
readFullArticleButton.setTextColor(buttonColorStateList);
|
||||||
readFullArticleButton.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_world_globe_dark), null, null, null);
|
readFullArticleButton.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_world_globe_dark), null, null, null);
|
||||||
readFullArticleButton.setCompoundDrawablePadding((int) getResources().getDimension(R.dimen.content_padding_small));
|
readFullArticleButton.setCompoundDrawablePadding((int) getResources().getDimension(R.dimen.content_padding_small));
|
||||||
|
@ -133,47 +91,30 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
int paddingRight = (int) getResources().getDimension(R.dimen.dialog_content_margin);
|
int paddingRight = (int) getResources().getDimension(R.dimen.dialog_content_margin);
|
||||||
readFullArticleButton.setPadding(paddingLeft, 0, paddingRight, 0);
|
readFullArticleButton.setPadding(paddingLeft, 0, paddingRight, 0);
|
||||||
|
|
||||||
selectLanguageTextView = (TextView) mainView.findViewById(R.id.select_language_text_view);
|
selectedLangTv = (TextView) mainView.findViewById(R.id.select_language_text_view);
|
||||||
selectLanguageTextView.setTextColor(selectedLangColorStateList);
|
selectedLangTv.setTextColor(selectedLangColorStateList);
|
||||||
selectLanguageTextView.setCompoundDrawablesWithIntrinsicBounds(getSelectedLangIcon(), null, null, null);
|
selectedLangTv.setCompoundDrawablesWithIntrinsicBounds(getSelectedLangIcon(), null, null, null);
|
||||||
selectLanguageTextView.setBackgroundResource(darkMode
|
selectedLangTv.setBackgroundResource(nightMode
|
||||||
? R.drawable.wikipedia_select_lang_bg_dark_n : R.drawable.wikipedia_select_lang_bg_light_n);
|
? R.drawable.wikipedia_select_lang_bg_dark_n : R.drawable.wikipedia_select_lang_bg_light_n);
|
||||||
|
|
||||||
contentWebView = (WebView) mainView.findViewById(R.id.content_web_view);
|
contentWebView = (WebView) mainView.findViewById(R.id.content_web_view);
|
||||||
WebSettings webSettings = contentWebView.getSettings();
|
WebSettings webSettings = contentWebView.getSettings();
|
||||||
webSettings.setJavaScriptEnabled(true);
|
webSettings.setJavaScriptEnabled(true);
|
||||||
contentWebView.setWebViewClient(new WikipediaWebViewClient(getActivity(), darkMode));
|
contentWebView.setWebViewClient(new WikipediaWebViewClient(getActivity(), nightMode));
|
||||||
updateWebSettings();
|
updateWebSettings();
|
||||||
|
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@NonNull
|
@NonNull
|
||||||
private Drawable getSelectedLangIcon() {
|
protected String createHtmlContent() {
|
||||||
Drawable normal = getIcon(R.drawable.ic_action_map_language, R.color.icon_color);
|
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
|
||||||
Drawable active = getActiveIcon(R.drawable.ic_action_map_language);
|
|
||||||
return AndroidUtils.createPressedStateListDrawable(normal, active);
|
|
||||||
}
|
|
||||||
return normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private String getBaseUrl() {
|
|
||||||
File wikivoyageDir = getMyApplication().getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR);
|
|
||||||
if (new File(wikivoyageDir, "article_style.css").exists()) {
|
|
||||||
return "file://" + wikivoyageDir.getAbsolutePath() + "/";
|
|
||||||
}
|
|
||||||
return "file:///android_asset/";
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private String createHtmlContent(@NonNull String article) {
|
|
||||||
StringBuilder sb = new StringBuilder(HEADER_INNER);
|
StringBuilder sb = new StringBuilder(HEADER_INNER);
|
||||||
String nightModeClass = darkMode ? " nightmode" : "";
|
String nightModeClass = nightMode ? " nightmode" : "";
|
||||||
sb.append("<div class=\"main");
|
sb.append("<div class=\"main");
|
||||||
sb.append(nightModeClass);
|
sb.append(nightModeClass);
|
||||||
sb.append("\">\n");
|
sb.append("\">\n");
|
||||||
|
sb.append("<h1>").append(title).append("</h1>");
|
||||||
sb.append(article);
|
sb.append(article);
|
||||||
sb.append(FOOTER_INNER);
|
sb.append(FOOTER_INNER);
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
@ -181,7 +122,7 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
populateWiki();
|
populateArticle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -193,7 +134,8 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateWiki() {
|
@Override
|
||||||
|
protected void populateArticle() {
|
||||||
if (amenity != null) {
|
if (amenity != null) {
|
||||||
String preferredLanguage = lang;
|
String preferredLanguage = lang;
|
||||||
if (TextUtils.isEmpty(preferredLanguage)) {
|
if (TextUtils.isEmpty(preferredLanguage)) {
|
||||||
|
@ -206,26 +148,25 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
final String langSelected = lng;
|
final String langSelected = lng;
|
||||||
final String title = amenity.getName(langSelected);
|
article = amenity.getDescription(langSelected);
|
||||||
|
title = amenity.getName(langSelected);
|
||||||
articleToolbarText.setText(title);
|
articleToolbarText.setText(title);
|
||||||
readFullArticleButton.setOnClickListener(new View.OnClickListener() {
|
readFullArticleButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
String article = "https://" + langSelected.toLowerCase() + ".wikipedia.org/wiki/" + title.replace(' ', '_');
|
String article = "https://" + langSelected.toLowerCase() + ".wikipedia.org/wiki/" + title.replace(' ', '_');
|
||||||
showFullArticle(getContext(), Uri.parse(article), darkMode);
|
showFullArticle(getContext(), Uri.parse(article), nightMode);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
selectLanguageTextView.setText(Algorithms.capitalizeFirstLetter(langSelected));
|
selectedLangTv.setText(Algorithms.capitalizeFirstLetter(langSelected));
|
||||||
selectLanguageTextView.setOnClickListener(new View.OnClickListener() {
|
selectedLangTv.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
showPopupLangMenu(selectLanguageTextView, langSelected);
|
showPopupLangMenu(selectedLangTv, langSelected);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(), "text/html", "UTF-8", null);
|
||||||
String content = amenity.getDescription(langSelected);
|
|
||||||
contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(content), "text/html", "UTF-8", null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +177,8 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
customTabsIntent.launchUrl(context, uri);
|
customTabsIntent.launchUrl(context, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPopupLangMenu(View view, final String langSelected) {
|
@Override
|
||||||
|
protected void showPopupLangMenu(View view, final String langSelected) {
|
||||||
final PopupMenu optionsMenu = new PopupMenu(getContext(), view, Gravity.RIGHT);
|
final PopupMenu optionsMenu = new PopupMenu(getContext(), view, Gravity.RIGHT);
|
||||||
Set<String> namesSet = new TreeSet<>();
|
Set<String> namesSet = new TreeSet<>();
|
||||||
namesSet.addAll(amenity.getNames("content", "en"));
|
namesSet.addAll(amenity.getNames("content", "en"));
|
||||||
|
@ -258,7 +200,7 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
setLanguage(langSelected);
|
setLanguage(langSelected);
|
||||||
populateWiki();
|
populateArticle();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -269,7 +211,7 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
setLanguage(e.getKey());
|
setLanguage(e.getKey());
|
||||||
populateWiki();
|
populateArticle();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -278,12 +220,7 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getIcon(int resId) {
|
private Drawable getIcon(int resId) {
|
||||||
int colorId = darkMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n;
|
int colorId = nightMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n;
|
||||||
return getIcon(resId, colorId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Drawable getActiveIcon(int resId) {
|
|
||||||
int colorId = darkMode ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light;
|
|
||||||
return getIcon(resId, colorId);
|
return getIcon(resId, colorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,32 +243,15 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateWebSettings() {
|
|
||||||
OsmandSettings.WikivoyageShowImages showImages = getSettings().WIKIVOYAGE_SHOW_IMAGES.get();
|
|
||||||
WebSettings webSettings = contentWebView.getSettings();
|
|
||||||
switch (showImages) {
|
|
||||||
case ON:
|
|
||||||
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
|
|
||||||
break;
|
|
||||||
case OFF:
|
|
||||||
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ONLY);
|
|
||||||
break;
|
|
||||||
case WIFI:
|
|
||||||
webSettings.setCacheMode(getMyApplication().getSettings().isWifiConnected() ?
|
|
||||||
WebSettings.LOAD_DEFAULT : WebSettings.LOAD_CACHE_ONLY);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean showInstance(AppCompatActivity activity, Amenity amenity) {
|
public static boolean showInstance(AppCompatActivity activity, Amenity amenity) {
|
||||||
return showInstance(activity, amenity, null);
|
return showInstance(activity, amenity, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupToolbar(Toolbar toolbar) {
|
protected void setupToolbar(Toolbar toolbar) {
|
||||||
toolbar.setNavigationIcon(getIcon(R.drawable.ic_arrow_back, R.color.icon_color));
|
super.setupToolbar(toolbar);
|
||||||
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
|
toolbar.setOverflowIcon(getIcon(R.drawable.ic_overflow_menu_white, R.color.icon_color));
|
||||||
Menu menu = toolbar.getMenu();
|
|
||||||
|
|
||||||
|
Menu menu = toolbar.getMenu();
|
||||||
MenuItem.OnMenuItemClickListener itemClickListener = new MenuItem.OnMenuItemClickListener() {
|
MenuItem.OnMenuItemClickListener itemClickListener = new MenuItem.OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
@ -339,13 +259,13 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
int itemId = item.getItemId();
|
int itemId = item.getItemId();
|
||||||
if (itemId == MENU_ITEM_SHOW_ID) {
|
if (itemId == MENU_ITEM_SHOW_ID) {
|
||||||
app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(OsmandSettings.WikivoyageShowImages.ON);
|
app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(OsmandSettings.WikiArticleShowImages.ON);
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == MENU_ITEM_WIFI_ID) {
|
} else if (itemId == MENU_ITEM_WIFI_ID) {
|
||||||
app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(OsmandSettings.WikivoyageShowImages.WIFI);
|
app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(OsmandSettings.WikiArticleShowImages.WIFI);
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == MENU_ITEM_NO_ID) {
|
} else if (itemId == MENU_ITEM_NO_ID) {
|
||||||
app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(OsmandSettings.WikivoyageShowImages.OFF);
|
app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(OsmandSettings.WikiArticleShowImages.OFF);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,28 +273,11 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
MenuItem itemShow = menu.add(0,MENU_ITEM_SHOW_ID,0,R.string.shared_string_show);
|
MenuItem itemShow = menu.add(0, MENU_ITEM_SHOW_ID, 0, R.string.shared_string_show);
|
||||||
itemShow.setOnMenuItemClickListener(itemClickListener);
|
itemShow.setOnMenuItemClickListener(itemClickListener);
|
||||||
MenuItem itemWifi = menu.add(0,MENU_ITEM_WIFI_ID,0,R.string.shared_string_only_with_wifi);
|
MenuItem itemWifi = menu.add(0, MENU_ITEM_WIFI_ID, 0, R.string.shared_string_only_with_wifi);
|
||||||
itemWifi.setOnMenuItemClickListener(itemClickListener);
|
itemWifi.setOnMenuItemClickListener(itemClickListener);
|
||||||
MenuItem itemNo = menu.add(0,MENU_ITEM_NO_ID,0,R.string.shared_string_dont);
|
MenuItem itemNo = menu.add(0, MENU_ITEM_NO_ID, 0, R.string.shared_string_dont);
|
||||||
itemNo.setOnMenuItemClickListener(itemClickListener);
|
itemNo.setOnMenuItemClickListener(itemClickListener);
|
||||||
|
|
||||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@ColorRes
|
|
||||||
protected int getStatusBarColor() {
|
|
||||||
return darkMode ? R.color.status_bar_wikivoyage_article_dark : R.color.status_bar_wikivoyage_article_light;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ColorInt
|
|
||||||
protected int getResolvedColor(@ColorRes int colorId) {
|
|
||||||
return ContextCompat.getColor(getContext(), colorId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package net.osmand.plus.mapcontextmenu;
|
package net.osmand.plus.wikipedia;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
|
@ -22,9 +22,8 @@ import android.view.Window;
|
||||||
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
||||||
import net.osmand.plus.wikivoyage.explore.WikivoyageExploreDialogFragment;
|
|
||||||
|
|
||||||
public class WikivoyageBaseDialogFragment extends BaseOsmAndDialogFragment {
|
public class WikiBaseDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
|
|
||||||
protected boolean nightMode;
|
protected boolean nightMode;
|
||||||
|
|
|
@ -16,7 +16,7 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings.WikivoyageShowImages;
|
import net.osmand.plus.OsmandSettings.WikiArticleShowImages;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
@ -38,7 +38,7 @@ public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragm
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(WikivoyageShowImages.OFF);
|
app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(WikiArticleShowImages.OFF);
|
||||||
}
|
}
|
||||||
sendResult();
|
sendResult();
|
||||||
dismiss();
|
dismiss();
|
||||||
|
@ -52,7 +52,7 @@ public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragm
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(WikivoyageShowImages.WIFI);
|
app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(WikiArticleShowImages.WIFI);
|
||||||
}
|
}
|
||||||
sendResult();
|
sendResult();
|
||||||
dismiss();
|
dismiss();
|
||||||
|
@ -65,7 +65,7 @@ public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragm
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(WikivoyageShowImages.ON);
|
app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(WikiArticleShowImages.ON);
|
||||||
}
|
}
|
||||||
sendResult();
|
sendResult();
|
||||||
dismiss();
|
dismiss();
|
||||||
|
|
|
@ -8,7 +8,7 @@ import net.osmand.plus.OsmandSettings;
|
||||||
public class WikivoyageUtils {
|
public class WikivoyageUtils {
|
||||||
|
|
||||||
public static void setupNetworkPolicy(OsmandSettings settings, RequestCreator rc) {
|
public static void setupNetworkPolicy(OsmandSettings settings, RequestCreator rc) {
|
||||||
switch (settings.WIKIVOYAGE_SHOW_IMAGES.get()) {
|
switch (settings.WIKI_ARTICLE_SHOW_IMAGES.get()) {
|
||||||
case ON:
|
case ON:
|
||||||
break;
|
break;
|
||||||
case OFF:
|
case OFF:
|
||||||
|
|
|
@ -25,7 +25,7 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapcontextmenu.WikipediaDialogFragment;
|
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
|
||||||
import net.osmand.plus.resources.AmenityIndexRepositoryBinary;
|
import net.osmand.plus.resources.AmenityIndexRepositoryBinary;
|
||||||
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
|
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
|
||||||
import net.osmand.plus.wikivoyage.article.WikivoyageArticleWikiLinkFragment;
|
import net.osmand.plus.wikivoyage.article.WikivoyageArticleWikiLinkFragment;
|
||||||
|
|
|
@ -15,7 +15,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.wikivoyage.explore.WikivoyageExploreDialogFragment;
|
import net.osmand.plus.wikivoyage.explore.WikivoyageExploreDialogFragment;
|
||||||
|
|
||||||
public class WikivoyageWelcomeDialogFragment extends WikivoyageBaseDialogFragment {
|
public class WikivoyageWelcomeDialogFragment extends WikiBaseDialogFragment {
|
||||||
|
|
||||||
public static final String TAG = WikivoyageWelcomeDialogFragment.class.getSimpleName();
|
public static final String TAG = WikivoyageWelcomeDialogFragment.class.getSimpleName();
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
@ -14,7 +13,6 @@ import android.support.v4.app.FragmentManager.BackStackEntry;
|
||||||
import android.support.v7.widget.PopupMenu;
|
import android.support.v7.widget.PopupMenu;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
@ -29,12 +27,11 @@ import net.osmand.IndexConstants;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.WikivoyageShowImages;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.TrackActivity;
|
import net.osmand.plus.activities.TrackActivity;
|
||||||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment;
|
import net.osmand.plus.wikipedia.WikiArticleBaseDialogFragment;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageShowPicturesDialogFragment;
|
import net.osmand.plus.wikivoyage.WikivoyageShowPicturesDialogFragment;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageWebViewClient;
|
import net.osmand.plus.wikivoyage.WikivoyageWebViewClient;
|
||||||
import net.osmand.plus.wikivoyage.data.TravelArticle;
|
import net.osmand.plus.wikivoyage.data.TravelArticle;
|
||||||
|
@ -42,22 +39,18 @@ import net.osmand.plus.wikivoyage.data.TravelDbHelper;
|
||||||
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
|
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static net.osmand.plus.OsmandSettings.WikivoyageShowImages.OFF;
|
import static net.osmand.plus.OsmandSettings.WikiArticleShowImages.OFF;
|
||||||
|
|
||||||
|
|
||||||
public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragment {
|
public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragment {
|
||||||
|
|
||||||
public static final String TAG = "WikivoyageArticleDialogFragment";
|
public static final String TAG = "WikivoyageArticleDialogFragment";
|
||||||
|
|
||||||
|
@ -67,66 +60,6 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
private static final String LANGS_KEY = "langs_key";
|
private static final String LANGS_KEY = "langs_key";
|
||||||
private static final String SELECTED_LANG_KEY = "selected_lang_key";
|
private static final String SELECTED_LANG_KEY = "selected_lang_key";
|
||||||
|
|
||||||
private static final String HEADER_INNER = "<html><head>\n" +
|
|
||||||
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n" +
|
|
||||||
"<meta http-equiv=\"cleartype\" content=\"on\" />\n" +
|
|
||||||
"<link href=\"article_style.css\" type=\"text/css\" rel=\"stylesheet\"/>\n" +
|
|
||||||
"<script type=\"text/javascript\">" +
|
|
||||||
"function showNavigation() {" +
|
|
||||||
" Android.showNavigation();" +
|
|
||||||
"}" +
|
|
||||||
"</script>" +
|
|
||||||
"</head>";
|
|
||||||
private static final String FOOTER_INNER = "<script>var coll = document.getElementsByTagName(\"H2\");" +
|
|
||||||
"var i;" +
|
|
||||||
"for (i = 0; i < coll.length; i++) {" +
|
|
||||||
" coll[i].addEventListener(\"click\", function() {" +
|
|
||||||
" this.classList.toggle(\"active\");" +
|
|
||||||
" var content = this.nextElementSibling;" +
|
|
||||||
" if (content.style.display === \"block\") {" +
|
|
||||||
" content.style.display = \"none\";" +
|
|
||||||
" } else {" +
|
|
||||||
" content.style.display = \"block\";" +
|
|
||||||
" }" +
|
|
||||||
" });" +
|
|
||||||
"}" +
|
|
||||||
"document.addEventListener(\"DOMContentLoaded\", function(event) {\n" +
|
|
||||||
" document.querySelectorAll('img').forEach(function(img) {\n" +
|
|
||||||
" img.onerror = function() {\n" +
|
|
||||||
" this.style.display = 'none';\n" +
|
|
||||||
" var caption = img.parentElement.nextElementSibling;\n" +
|
|
||||||
" if (caption.className == \"thumbnailcaption\") {\n" +
|
|
||||||
" caption.style.display = 'none';\n" +
|
|
||||||
" }\n" +
|
|
||||||
" };\n" +
|
|
||||||
" })\n" +
|
|
||||||
"});" +
|
|
||||||
"function scrollAnchor(id, title) {" +
|
|
||||||
"openContent(title);" +
|
|
||||||
"window.location.hash = id;}\n" +
|
|
||||||
"function openContent(id) {\n" +
|
|
||||||
" var doc = document.getElementById(id).parentElement;\n" +
|
|
||||||
" doc.classList.toggle(\"active\");\n" +
|
|
||||||
" var content = doc.nextElementSibling;\n" +
|
|
||||||
" content.style.display = \"block\";\n" +
|
|
||||||
" collapseActive(doc);" +
|
|
||||||
"}" +
|
|
||||||
"function collapseActive(doc) {" +
|
|
||||||
" var coll = document.getElementsByTagName(\"H2\");" +
|
|
||||||
" var i;" +
|
|
||||||
" for (i = 0; i < coll.length; i++) {" +
|
|
||||||
" var item = coll[i];" +
|
|
||||||
" if (item != doc && item.classList.contains(\"active\")) {" +
|
|
||||||
" item.classList.toggle(\"active\");" +
|
|
||||||
" var content = item.nextElementSibling;" +
|
|
||||||
" if (content.style.display === \"block\") {" +
|
|
||||||
" content.style.display = \"none\";" +
|
|
||||||
" }" +
|
|
||||||
" }" +
|
|
||||||
" }" +
|
|
||||||
"}</script>"
|
|
||||||
+ "</body></html>";
|
|
||||||
|
|
||||||
private static final String EMPTY_URL = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d4//";
|
private static final String EMPTY_URL = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d4//";
|
||||||
|
|
||||||
private long cityId = NO_VALUE;
|
private long cityId = NO_VALUE;
|
||||||
|
@ -135,11 +68,8 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
private TravelArticle article;
|
private TravelArticle article;
|
||||||
|
|
||||||
private TextView trackButton;
|
private TextView trackButton;
|
||||||
private TextView selectedLangTv;
|
|
||||||
private TextView saveBtn;
|
private TextView saveBtn;
|
||||||
private WebView contentWebView;
|
|
||||||
|
|
||||||
private TextView articleToolbarText;
|
|
||||||
private WikivoyageWebViewClient webViewClient;
|
private WikivoyageWebViewClient webViewClient;
|
||||||
|
|
||||||
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
|
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
|
||||||
|
@ -174,7 +104,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
selectedLangTv.setOnClickListener(new View.OnClickListener() {
|
selectedLangTv.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
showPopupLangMenu(v);
|
showPopupLangMenu(v, selectedLang);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -277,40 +207,18 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
OsmandSettings settings = getMyApplication().getSettings();
|
OsmandSettings settings = getMyApplication().getSettings();
|
||||||
if (!settings.WIKIVOYAGE_SHOW_IMAGES_ASKED.get()) {
|
if (!settings.WIKI_ARTICLE_SHOW_IMAGES_ASKED.get()) {
|
||||||
FragmentActivity activity = getActivity();
|
FragmentActivity activity = getActivity();
|
||||||
FragmentManager fm = getFragmentManager();
|
FragmentManager fm = getFragmentManager();
|
||||||
if (activity != null && fm != null) {
|
if (activity != null && fm != null) {
|
||||||
WikivoyageShowPicturesDialogFragment fragment = new WikivoyageShowPicturesDialogFragment();
|
WikivoyageShowPicturesDialogFragment fragment = new WikivoyageShowPicturesDialogFragment();
|
||||||
fragment.setTargetFragment(this, WikivoyageShowPicturesDialogFragment.SHOW_PICTURES_CHANGED_REQUEST_CODE);
|
fragment.setTargetFragment(this, WikivoyageShowPicturesDialogFragment.SHOW_PICTURES_CHANGED_REQUEST_CODE);
|
||||||
fragment.show(fm, WikivoyageShowPicturesDialogFragment.TAG);
|
fragment.show(fm, WikivoyageShowPicturesDialogFragment.TAG);
|
||||||
settings.WIKIVOYAGE_SHOW_IMAGES_ASKED.set(true);
|
settings.WIKI_ARTICLE_SHOW_IMAGES_ASKED.set(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getStatusBarColor() {
|
|
||||||
return nightMode ? R.color.status_bar_wikivoyage_article_dark : R.color.status_bar_wikivoyage_article_light;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateWebSettings() {
|
|
||||||
WikivoyageShowImages showImages = getSettings().WIKIVOYAGE_SHOW_IMAGES.get();
|
|
||||||
WebSettings webSettings = contentWebView.getSettings();
|
|
||||||
switch (showImages) {
|
|
||||||
case ON:
|
|
||||||
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
|
|
||||||
break;
|
|
||||||
case OFF:
|
|
||||||
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ONLY);
|
|
||||||
break;
|
|
||||||
case WIFI:
|
|
||||||
webSettings.setCacheMode(getMyApplication().getSettings().isWifiConnected() ?
|
|
||||||
WebSettings.LOAD_DEFAULT : WebSettings.LOAD_CACHE_ONLY);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateSaveButton() {
|
private void updateSaveButton() {
|
||||||
if (article != null) {
|
if (article != null) {
|
||||||
final TravelLocalDataHelper helper = getMyApplication().getTravelDbHelper().getLocalDataHelper();
|
final TravelLocalDataHelper helper = getMyApplication().getTravelDbHelper().getLocalDataHelper();
|
||||||
|
@ -335,7 +243,8 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPopupLangMenu(View view) {
|
@Override
|
||||||
|
protected void showPopupLangMenu(View view, String langSelected) {
|
||||||
if (langs == null) {
|
if (langs == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +271,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
popup.show();
|
popup.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateArticle() {
|
protected void populateArticle() {
|
||||||
if (cityId == NO_VALUE || langs == null) {
|
if (cityId == NO_VALUE || langs == null) {
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
|
@ -392,15 +301,11 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
|
|
||||||
updateSaveButton();
|
updateSaveButton();
|
||||||
selectedLangTv.setText(Algorithms.capitalizeFirstLetter(selectedLang));
|
selectedLangTv.setText(Algorithms.capitalizeFirstLetter(selectedLang));
|
||||||
contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(article), "text/html", "UTF-8", null);
|
contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(), "text/html", "UTF-8", null);
|
||||||
}
|
|
||||||
|
|
||||||
private void moveToAnchor(String id, String title) {
|
|
||||||
contentWebView.loadUrl("javascript:scrollAnchor(\"" + id + "\", \"" + title.trim() + "\")");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private String createHtmlContent(@NonNull TravelArticle article) {
|
protected String createHtmlContent() {
|
||||||
StringBuilder sb = new StringBuilder(HEADER_INNER);
|
StringBuilder sb = new StringBuilder(HEADER_INNER);
|
||||||
String[] rtlLanguages = new String[]{"ar","dv","he","iw","fa","nqo","ps","sd","ug","ur","yi"};
|
String[] rtlLanguages = new String[]{"ar","dv","he","iw","fa","nqo","ps","sd","ug","ur","yi"};
|
||||||
Set<String> rtls = new HashSet<>(Arrays.asList(rtlLanguages));
|
Set<String> rtls = new HashSet<>(Arrays.asList(rtlLanguages));
|
||||||
|
@ -428,7 +333,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String url = TravelArticle.getImageUrl(imageTitle, false);
|
String url = TravelArticle.getImageUrl(imageTitle, false);
|
||||||
if (!TextUtils.isEmpty(imageTitle) && getSettings().WIKIVOYAGE_SHOW_IMAGES.get() != OFF &&
|
if (!TextUtils.isEmpty(imageTitle) && getSettings().WIKI_ARTICLE_SHOW_IMAGES.get() != OFF &&
|
||||||
!url.startsWith(EMPTY_URL)) {
|
!url.startsWith(EMPTY_URL)) {
|
||||||
sb.append("<div class=\"title-image"+nightModeClass+"\" style=\"background-image: url(").append(url).append(")\"></div>");
|
sb.append("<div class=\"title-image"+nightModeClass+"\" style=\"background-image: url(").append(url).append(")\"></div>");
|
||||||
}
|
}
|
||||||
|
@ -440,42 +345,11 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
sb.append(article.getContent());
|
sb.append(article.getContent());
|
||||||
sb.append(FOOTER_INNER);
|
sb.append(FOOTER_INNER);
|
||||||
if (OsmandPlugin.getEnabledPlugin(OsmandDevelopmentPlugin.class) != null) {
|
if (OsmandPlugin.getEnabledPlugin(OsmandDevelopmentPlugin.class) != null) {
|
||||||
writeOutHTML(sb);
|
writeOutHTML(sb, new File(getMyApplication().getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), "page.html"));
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeOutHTML(StringBuilder sb) {
|
|
||||||
File file = new File(getMyApplication().getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), "page.html");
|
|
||||||
BufferedWriter writer = null;
|
|
||||||
try {
|
|
||||||
writer = new BufferedWriter(new FileWriter(file));
|
|
||||||
writer.write(sb.toString());
|
|
||||||
writer.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.w("ArticleDialog", e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private String getBaseUrl() {
|
|
||||||
File wikivoyageDir = getMyApplication().getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR);
|
|
||||||
if (new File(wikivoyageDir, "article_style.css").exists()) {
|
|
||||||
return "file://" + wikivoyageDir.getAbsolutePath() + "/";
|
|
||||||
}
|
|
||||||
return "file:///android_asset/";
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private Drawable getSelectedLangIcon() {
|
|
||||||
Drawable normal = getContentIcon(R.drawable.ic_action_map_language);
|
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
|
||||||
Drawable active = getActiveIcon(R.drawable.ic_action_map_language);
|
|
||||||
return AndroidUtils.createPressedStateListDrawable(normal, active);
|
|
||||||
}
|
|
||||||
return normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean showInstance(@NonNull OsmandApplication app,
|
public static boolean showInstance(@NonNull OsmandApplication app,
|
||||||
@NonNull FragmentManager fm,
|
@NonNull FragmentManager fm,
|
||||||
long cityId,
|
long cityId,
|
||||||
|
|
|
@ -18,7 +18,7 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleDividerItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleDividerItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||||
import net.osmand.plus.download.DownloadActivity;
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
import net.osmand.plus.mapcontextmenu.WikipediaDialogFragment;
|
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
|
||||||
|
|
||||||
import static net.osmand.plus.download.ui.SearchDialogFragment.SHOW_WIKI_KEY;
|
import static net.osmand.plus.download.ui.SearchDialogFragment.SHOW_WIKI_KEY;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ import net.osmand.plus.LockableViewPager;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.download.DownloadIndexesThread;
|
import net.osmand.plus.download.DownloadIndexesThread;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment;
|
import net.osmand.plus.wikivoyage.WikiBaseDialogFragment;
|
||||||
import net.osmand.plus.wikivoyage.data.TravelDbHelper;
|
import net.osmand.plus.wikivoyage.data.TravelDbHelper;
|
||||||
import net.osmand.plus.wikivoyage.search.WikivoyageSearchDialogFragment;
|
import net.osmand.plus.wikivoyage.search.WikivoyageSearchDialogFragment;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragment implements DownloadIndexesThread.DownloadEvents {
|
public class WikivoyageExploreDialogFragment extends WikiBaseDialogFragment implements DownloadIndexesThread.DownloadEvents {
|
||||||
|
|
||||||
public static final String TAG = "WikivoyageExploreDialogFragment";
|
public static final String TAG = "WikivoyageExploreDialogFragment";
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import android.webkit.WebView;
|
||||||
import net.osmand.PicassoUtils;
|
import net.osmand.PicassoUtils;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.WikivoyageShowImages;
|
import net.osmand.plus.OsmandSettings.WikiArticleShowImages;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
|
@ -41,7 +41,7 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD
|
||||||
@Override
|
@Override
|
||||||
public void createMenuItems(Bundle savedInstanceState) {
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
final OsmandApplication app = getMyApplication();
|
final OsmandApplication app = getMyApplication();
|
||||||
final OsmandSettings.CommonPreference<WikivoyageShowImages> showImagesPref = app.getSettings().WIKIVOYAGE_SHOW_IMAGES;
|
final OsmandSettings.CommonPreference<WikiArticleShowImages> showImagesPref = app.getSettings().WIKI_ARTICLE_SHOW_IMAGES;
|
||||||
final TravelDbHelper dbHelper = app.getTravelDbHelper();
|
final TravelDbHelper dbHelper = app.getTravelDbHelper();
|
||||||
|
|
||||||
items.add(new TitleItem(getString(R.string.shared_string_options)));
|
items.add(new TitleItem(getString(R.string.shared_string_options)));
|
||||||
|
@ -76,7 +76,7 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final PopupMenu popup = new PopupMenu(v.getContext(), v, Gravity.END);
|
final PopupMenu popup = new PopupMenu(v.getContext(), v, Gravity.END);
|
||||||
for (final WikivoyageShowImages showImages : WikivoyageShowImages.values()) {
|
for (final WikiArticleShowImages showImages : WikiArticleShowImages.values()) {
|
||||||
MenuItem item = popup.getMenu().add(getString(showImages.name));
|
MenuItem item = popup.getMenu().add(getString(showImages.name));
|
||||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,7 +20,7 @@ import android.widget.ProgressBar;
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment;
|
import net.osmand.plus.wikivoyage.WikiBaseDialogFragment;
|
||||||
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
|
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
|
||||||
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
|
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageSearchHistoryItem;
|
import net.osmand.plus.wikivoyage.data.WikivoyageSearchHistoryItem;
|
||||||
|
@ -29,7 +29,7 @@ import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class WikivoyageSearchDialogFragment extends WikivoyageBaseDialogFragment {
|
public class WikivoyageSearchDialogFragment extends WikiBaseDialogFragment {
|
||||||
|
|
||||||
public static final String TAG = "WikivoyageSearchDialogFragment";
|
public static final String TAG = "WikivoyageSearchDialogFragment";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue