From d5ece50d204746215c0e7e4c0f570ec239ed0820 Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 3 May 2018 11:56:07 +0300 Subject: [PATCH 01/10] fixed toolbar overflowIcon color --- .../osmand/plus/mapcontextmenu/WikipediaDialogFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java index cb00eb78f5..d1ab50d829 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -330,8 +330,9 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { protected void setupToolbar(Toolbar toolbar) { toolbar.setNavigationIcon(getIcon(R.drawable.ic_arrow_back, R.color.icon_color)); toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); - Menu menu = toolbar.getMenu(); + toolbar.setOverflowIcon(getIcon(R.drawable.ic_overflow_menu_white, R.color.icon_color)); + Menu menu = toolbar.getMenu(); MenuItem.OnMenuItemClickListener itemClickListener = new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { From be5566ad836de2c6d62929bf042fb128f68445af Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 3 May 2018 12:35:03 +0300 Subject: [PATCH 02/10] add header, js and fixed title textview --- .../res/layout/wikipedia_dialog_fragment.xml | 1 + .../WikipediaDialogFragment.java | 54 ++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml index 5bc645d6b2..db6b07919f 100644 --- a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml +++ b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml @@ -29,6 +29,7 @@ android:layout_height="match_parent" android:layout_weight="1" android:ellipsize="end" + android:maxLines="1" android:gravity="center_vertical" android:textSize="@dimen/dialog_header_text_size" osmand:typeface="@string/font_roboto_medium" /> diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java index d1ab50d829..2b13e97fe4 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -55,7 +55,55 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { "\n" + "\n" + ""; - private static final String FOOTER_INNER = ""; + private static final String FOOTER_INNER = "" + + ""; private static final int MENU_ITEM_NO_ID = 0; private static final int MENU_ITEM_SHOW_ID = 1; @@ -69,6 +117,7 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { private boolean darkMode; private Amenity amenity; private String lang; + private String title; public void setAmenity(Amenity amenity) { this.amenity = amenity; @@ -174,6 +223,7 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { sb.append("
\n"); + sb.append("

").append(title).append("

"); sb.append(article); sb.append(FOOTER_INNER); return sb.toString(); @@ -206,7 +256,7 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { } final String langSelected = lng; - final String title = amenity.getName(langSelected); + title = amenity.getName(langSelected); articleToolbarText.setText(title); readFullArticleButton.setOnClickListener(new View.OnClickListener() { @Override From 8cf93a209d3976f60071fadcdb525b35beedee38 Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 3 May 2018 14:07:24 +0300 Subject: [PATCH 03/10] add ArticleBaseDialogFragment and refactored Wikivoyage and Wikipedia dialog fragments --- .../WikipediaDialogFragment.java | 206 +++--------------- .../wikipedia/ArticleBaseDialogFragment.java | 145 ++++++++++++ .../WikivoyageBaseDialogFragment.java | 1 - .../WikivoyageArticleDialogFragment.java | 128 +---------- 4 files changed, 187 insertions(+), 293 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java index 2b13e97fe4..1d082ccff6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -6,10 +6,7 @@ import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.os.Build; import android.os.Bundle; -import android.support.annotation.ColorInt; -import android.support.annotation.ColorRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.customtabs.CustomTabsIntent; @@ -24,100 +21,39 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.view.Window; import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.TextView; import net.osmand.AndroidUtils; -import net.osmand.IndexConstants; import net.osmand.data.Amenity; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; -import net.osmand.plus.base.BaseOsmAndDialogFragment; import net.osmand.plus.helpers.FileNameTranslationHelper; +import net.osmand.plus.wikipedia.ArticleBaseDialogFragment; import net.osmand.util.Algorithms; -import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.TreeSet; -public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { +public class WikipediaDialogFragment extends ArticleBaseDialogFragment { public static final String TAG = "WikipediaDialogFragment"; - private static final String HEADER_INNER = "\n" + - "\n" + - "\n" + - "\n" + - ""; - private static final String FOOTER_INNER = "" - + ""; - private static final int MENU_ITEM_NO_ID = 0; private static final int MENU_ITEM_SHOW_ID = 1; private static final int MENU_ITEM_WIFI_ID = 2; - private WebView contentWebView; - private TextView articleToolbarText; private TextView readFullArticleButton; - private TextView selectLanguageTextView; - private boolean darkMode; private Amenity amenity; private String lang; private String title; + private String article; public void setAmenity(Amenity amenity) { this.amenity = amenity; @@ -130,29 +66,10 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { @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; + int themeId = nightMode ? 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") @Nullable @Override @@ -163,18 +80,18 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { 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_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p); 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_dark ); 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.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_world_globe_dark), null, null, null); readFullArticleButton.setCompoundDrawablePadding((int) getResources().getDimension(R.dimen.content_padding_small)); @@ -182,44 +99,26 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { int paddingRight = (int) getResources().getDimension(R.dimen.dialog_content_margin); readFullArticleButton.setPadding(paddingLeft, 0, paddingRight, 0); - selectLanguageTextView = (TextView) mainView.findViewById(R.id.select_language_text_view); - selectLanguageTextView.setTextColor(selectedLangColorStateList); - selectLanguageTextView.setCompoundDrawablesWithIntrinsicBounds(getSelectedLangIcon(), null, null, null); - selectLanguageTextView.setBackgroundResource(darkMode + selectedLangTv = (TextView) mainView.findViewById(R.id.select_language_text_view); + selectedLangTv.setTextColor(selectedLangColorStateList); + selectedLangTv.setCompoundDrawablesWithIntrinsicBounds(getSelectedLangIcon(), null, null, null); + selectedLangTv.setBackgroundResource(nightMode ? 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); WebSettings webSettings = contentWebView.getSettings(); webSettings.setJavaScriptEnabled(true); - contentWebView.setWebViewClient(new WikipediaWebViewClient(getActivity(), darkMode)); + contentWebView.setWebViewClient(new WikipediaWebViewClient(getActivity(), nightMode)); updateWebSettings(); return mainView; } + @Override @NonNull - private Drawable getSelectedLangIcon() { - 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) { + protected String createHtmlContent() { StringBuilder sb = new StringBuilder(HEADER_INNER); - String nightModeClass = darkMode ? " nightmode" : ""; + String nightModeClass = nightMode ? " nightmode" : ""; sb.append("
\n"); @@ -231,7 +130,7 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { - populateWiki(); + populateArticle(); } @Override @@ -243,7 +142,8 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { super.onDestroyView(); } - private void populateWiki() { + @Override + protected void populateArticle() { if (amenity != null) { String preferredLanguage = lang; if (TextUtils.isEmpty(preferredLanguage)) { @@ -256,26 +156,25 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { } final String langSelected = lng; + article = amenity.getDescription(langSelected); title = amenity.getName(langSelected); articleToolbarText.setText(title); readFullArticleButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { 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)); - selectLanguageTextView.setOnClickListener(new View.OnClickListener() { + selectedLangTv.setText(Algorithms.capitalizeFirstLetter(langSelected)); + selectedLangTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - showPopupLangMenu(selectLanguageTextView, langSelected); + showPopupLangMenu(selectedLangTv, langSelected); } }); - - String content = amenity.getDescription(langSelected); - contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(content), "text/html", "UTF-8", null); + contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(), "text/html", "UTF-8", null); } } @@ -286,7 +185,8 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { 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); Set namesSet = new TreeSet<>(); namesSet.addAll(amenity.getNames("content", "en")); @@ -308,7 +208,7 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { @Override public boolean onMenuItemClick(MenuItem item) { setLanguage(langSelected); - populateWiki(); + populateArticle(); return true; } }); @@ -319,7 +219,7 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { @Override public boolean onMenuItemClick(MenuItem item) { setLanguage(e.getKey()); - populateWiki(); + populateArticle(); return true; } }); @@ -328,12 +228,7 @@ public class WikipediaDialogFragment extends BaseOsmAndDialogFragment { } 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; - return getIcon(resId, colorId); - } - - private Drawable getActiveIcon(int resId) { - int colorId = darkMode ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light; + 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); } @@ -356,30 +251,12 @@ 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) { return showInstance(activity, amenity, null); } protected void setupToolbar(Toolbar toolbar) { - toolbar.setNavigationIcon(getIcon(R.drawable.ic_arrow_back, R.color.icon_color)); - toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); + super.setupToolbar(toolbar); toolbar.setOverflowIcon(getIcon(R.drawable.ic_overflow_menu_white, R.color.icon_color)); Menu menu = toolbar.getMenu(); @@ -404,28 +281,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); - 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); - 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); - - 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); } } diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java new file mode 100644 index 0000000000..32adc2842d --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java @@ -0,0 +1,145 @@ +package net.osmand.plus.wikipedia; + +import android.graphics.drawable.Drawable; +import android.os.Build; +import android.support.annotation.NonNull; +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.WikivoyageBaseDialogFragment; + +import java.io.File; + +public class ArticleBaseDialogFragment extends WikivoyageBaseDialogFragment { + + protected static final String HEADER_INNER = "\n" + + "\n" + + "\n" + + "\n" + + "" + + ""; + protected static final String FOOTER_INNER = "" + + ""; + + protected WebView contentWebView; + protected TextView selectedLangTv; + protected TextView articleToolbarText; + + + protected 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; + } + } + + @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 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 + protected int getStatusBarColor() { + return nightMode ? R.color.status_bar_wikivoyage_article_dark : R.color.status_bar_wikivoyage_article_light; + } + + protected void showPopupLangMenu(View view, final String langSelected) { + } + + protected void populateArticle() { + } + + @NonNull + protected String createHtmlContent() { + return ""; + } + + protected void writeOutHTML(StringBuilder sb) { + } + +} diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java index f76689c45e..b452c9495e 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java @@ -22,7 +22,6 @@ import android.view.Window; import net.osmand.plus.R; import net.osmand.plus.base.BaseOsmAndDialogFragment; -import net.osmand.plus.wikivoyage.explore.WikivoyageExploreDialogFragment; public class WikivoyageBaseDialogFragment extends BaseOsmAndDialogFragment { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index d110935b41..9bfbaeb360 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -4,7 +4,6 @@ import android.annotation.SuppressLint; import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; -import android.os.Build; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -29,12 +28,11 @@ import net.osmand.IndexConstants; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; -import net.osmand.plus.OsmandSettings.WikivoyageShowImages; import net.osmand.plus.R; import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.helpers.FileNameTranslationHelper; -import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment; +import net.osmand.plus.wikipedia.ArticleBaseDialogFragment; import net.osmand.plus.wikivoyage.WikivoyageShowPicturesDialogFragment; import net.osmand.plus.wikivoyage.WikivoyageWebViewClient; import net.osmand.plus.wikivoyage.data.TravelArticle; @@ -50,14 +48,13 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Set; import static net.osmand.plus.OsmandSettings.WikivoyageShowImages.OFF; -public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragment { +public class WikivoyageArticleDialogFragment extends ArticleBaseDialogFragment { public static final String TAG = "WikivoyageArticleDialogFragment"; @@ -67,66 +64,6 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen private static final String LANGS_KEY = "langs_key"; private static final String SELECTED_LANG_KEY = "selected_lang_key"; - private static final String HEADER_INNER = "\n" + - "\n" + - "\n" + - "\n" + - "" + - ""; - private static final String FOOTER_INNER = "" - + ""; - private static final String EMPTY_URL = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d4//"; private long cityId = NO_VALUE; @@ -135,11 +72,8 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen private TravelArticle article; private TextView trackButton; - private TextView selectedLangTv; private TextView saveBtn; - private WebView contentWebView; - private TextView articleToolbarText; private WikivoyageWebViewClient webViewClient; @SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"}) @@ -174,7 +108,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen selectedLangTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - showPopupLangMenu(v); + showPopupLangMenu(v, selectedLang); } }); @@ -289,28 +223,6 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen } } - @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() { if (article != null) { final TravelLocalDataHelper helper = getMyApplication().getTravelDbHelper().getLocalDataHelper(); @@ -335,7 +247,8 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen } } - private void showPopupLangMenu(View view) { + @Override + protected void showPopupLangMenu(View view, String langSelected) { if (langs == null) { return; } @@ -362,7 +275,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen popup.show(); } - private void populateArticle() { + protected void populateArticle() { if (cityId == NO_VALUE || langs == null) { Bundle args = getArguments(); if (args != null) { @@ -392,15 +305,11 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen updateSaveButton(); selectedLangTv.setText(Algorithms.capitalizeFirstLetter(selectedLang)); - contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(article), "text/html", "UTF-8", null); - } - - private void moveToAnchor(String id, String title) { - contentWebView.loadUrl("javascript:scrollAnchor(\"" + id + "\", \"" + title.trim() + "\")"); + contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(), "text/html", "UTF-8", null); } @NonNull - private String createHtmlContent(@NonNull TravelArticle article) { + protected String createHtmlContent() { StringBuilder sb = new StringBuilder(HEADER_INNER); String[] rtlLanguages = new String[]{"ar","dv","he","iw","fa","nqo","ps","sd","ug","ur","yi"}; Set rtls = new HashSet<>(Arrays.asList(rtlLanguages)); @@ -445,7 +354,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen return sb.toString(); } - private void writeOutHTML(StringBuilder sb) { + protected void writeOutHTML(StringBuilder sb) { File file = new File(getMyApplication().getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), "page.html"); BufferedWriter writer = null; try { @@ -457,25 +366,6 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen } } - @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, @NonNull FragmentManager fm, long cityId, From 567d8274ace9f23978273bbf7075574545e7fd6e Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 3 May 2018 14:18:03 +0300 Subject: [PATCH 04/10] made methods abstract and moved writeOutHTML to ArticleBaseDialogFragment --- .../wikipedia/ArticleBaseDialogFragment.java | 25 +++++++++++++------ .../WikivoyageArticleDialogFragment.java | 12 --------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java index 32adc2842d..31ea93b628 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java @@ -3,6 +3,7 @@ package net.osmand.plus.wikipedia; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.NonNull; +import android.util.Log; import android.view.View; import android.webkit.WebSettings; import android.webkit.WebView; @@ -14,9 +15,12 @@ import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment; +import java.io.BufferedWriter; import java.io.File; +import java.io.FileWriter; +import java.io.IOException; -public class ArticleBaseDialogFragment extends WikivoyageBaseDialogFragment { +public abstract class ArticleBaseDialogFragment extends WikivoyageBaseDialogFragment { protected static final String HEADER_INNER = "\n" + "\n" + @@ -128,18 +132,23 @@ public class ArticleBaseDialogFragment extends WikivoyageBaseDialogFragment { return nightMode ? R.color.status_bar_wikivoyage_article_dark : R.color.status_bar_wikivoyage_article_light; } - protected void showPopupLangMenu(View view, final String langSelected) { - } + protected abstract void showPopupLangMenu(View view, final String langSelected); - protected void populateArticle() { - } + protected abstract void populateArticle(); @NonNull - protected String createHtmlContent() { - return ""; - } + protected abstract String createHtmlContent(); protected 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); + } } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 9bfbaeb360..fdf0c96d5f 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -354,18 +354,6 @@ public class WikivoyageArticleDialogFragment extends ArticleBaseDialogFragment { return sb.toString(); } - protected 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); - } - } - public static boolean showInstance(@NonNull OsmandApplication app, @NonNull FragmentManager fm, long cityId, From 89916ddc2a5095aec419baabbb2c6ef162d9720c Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 3 May 2018 14:23:02 +0300 Subject: [PATCH 05/10] moved writeOutHTML --- .../wikipedia/ArticleBaseDialogFragment.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java index 31ea93b628..b1cff7cdf7 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java @@ -113,6 +113,18 @@ public abstract class ArticleBaseDialogFragment extends WikivoyageBaseDialogFrag return "file:///android_asset/"; } + protected 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); + } + } + protected void moveToAnchor(String id, String title) { contentWebView.loadUrl("javascript:scrollAnchor(\"" + id + "\", \"" + title.trim() + "\")"); } @@ -138,17 +150,4 @@ public abstract class ArticleBaseDialogFragment extends WikivoyageBaseDialogFrag @NonNull protected abstract String createHtmlContent(); - - protected 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); - } - } - } From c14ba4f0fd4c5f763c3c5f6e06a876a9b1d46917 Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 3 May 2018 14:40:55 +0300 Subject: [PATCH 06/10] moved WikipediaWebViewClient and WikipediaWebViewClient to wikipedia package --- .../osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java | 2 +- .../plus/mapcontextmenu/controllers/AmenityMenuController.java | 2 +- .../{mapcontextmenu => wikipedia}/WikipediaDialogFragment.java | 2 +- .../{mapcontextmenu => wikipedia}/WikipediaWebViewClient.java | 2 +- .../src/net/osmand/plus/wikivoyage/WikivoyageWebViewClient.java | 2 +- .../wikivoyage/article/WikivoyageArticleWikiLinkFragment.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) rename OsmAnd/src/net/osmand/plus/{mapcontextmenu => wikipedia}/WikipediaDialogFragment.java (99%) rename OsmAnd/src/net/osmand/plus/{mapcontextmenu => wikipedia}/WikipediaWebViewClient.java (97%) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index f4259f7dd0..d4d74333e4 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -34,7 +34,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.FontCache; 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.poi.PoiUIFilter; import net.osmand.plus.views.POIMapLayer; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index ae4474d3a0..9c5d48894a 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -17,7 +17,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MenuBuilder; 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.render.RenderingIcons; import net.osmand.plus.resources.TransportIndexRepository; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java similarity index 99% rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java rename to OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java index 1d082ccff6..1b18ac6cac 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java @@ -1,4 +1,4 @@ -package net.osmand.plus.mapcontextmenu; +package net.osmand.plus.wikipedia; import android.annotation.SuppressLint; import android.app.Dialog; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaWebViewClient.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaWebViewClient.java similarity index 97% rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaWebViewClient.java rename to OsmAnd/src/net/osmand/plus/wikipedia/WikipediaWebViewClient.java index a4c336ec70..7ea63b8184 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaWebViewClient.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaWebViewClient.java @@ -1,4 +1,4 @@ -package net.osmand.plus.mapcontextmenu; +package net.osmand.plus.wikipedia; import android.content.Context; import android.content.DialogInterface; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWebViewClient.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWebViewClient.java index 74982c22e1..f10c962121 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWebViewClient.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWebViewClient.java @@ -25,7 +25,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; 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.wikivoyage.article.WikivoyageArticleDialogFragment; import net.osmand.plus.wikivoyage.article.WikivoyageArticleWikiLinkFragment; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleWikiLinkFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleWikiLinkFragment.java index 1d30bdc1af..e53b346086 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleWikiLinkFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleWikiLinkFragment.java @@ -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.TitleItem; 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; From 81449c9c2de548a9fb64f710149fa7cc2a5596af Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 3 May 2018 15:27:47 +0300 Subject: [PATCH 07/10] renamed show image settings and refactored writeOutHTML --- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 8 ++++---- .../SettingsDevelopmentActivity.java | 2 +- ...java => WikiArticleBaseDialogFragment.java} | 7 +++---- .../wikipedia/WikipediaDialogFragment.java | 9 ++++----- .../WikivoyageShowPicturesDialogFragment.java | 8 ++++---- .../plus/wikivoyage/WikivoyageUtils.java | 2 +- .../WikivoyageArticleDialogFragment.java | 18 +++++++----------- ...voyageOptionsBottomSheetDialogFragment.java | 6 +++--- 8 files changed, 27 insertions(+), 33 deletions(-) rename OsmAnd/src/net/osmand/plus/wikipedia/{ArticleBaseDialogFragment.java => WikiArticleBaseDialogFragment.java} (93%) diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index fbe4f3e981..0b7f387a4a 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -717,8 +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 WIKIVOYAGE_SHOW_IMAGES_ASKED = new BooleanPreference("wikivoyage_show_images_asked", false).makeGlobal(); - public final CommonPreference WIKIVOYAGE_SHOW_IMAGES = new EnumIntPreference<>("wikivoyage_show_imgs", WikivoyageShowImages.OFF, WikivoyageShowImages.values()).makeGlobal(); + public final CommonPreference WIKI_ARTICLE_SHOW_IMAGES_ASKED = new BooleanPreference("wikivoyage_show_images_asked", false).makeGlobal(); + public final CommonPreference WIKI_ARTICLE_SHOW_IMAGES = new EnumIntPreference<>("wikivoyage_show_imgs", WikiArticleShowImages.OFF, WikiArticleShowImages.values()).makeGlobal(); public final CommonPreference SELECT_MARKER_ON_SINGLE_TAP = new BooleanPreference("select_marker_on_single_tap", false).makeProfile(); @@ -3315,14 +3315,14 @@ public class OsmandSettings { EMPTY } - public enum WikivoyageShowImages { + public enum WikiArticleShowImages { ON(R.string.shared_string_on), OFF(R.string.shared_string_off), WIFI(R.string.shared_string_wifi_only); public final int name; - WikivoyageShowImages(int name) { + WikiArticleShowImages(int name) { this.name = name; } } diff --git a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java index 190452c22a..bece3ea19a 100644 --- a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java +++ b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java @@ -76,7 +76,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity { settings.MAPILLARY_FIRST_DIALOG_SHOWN.set(false); settings.WEBGL_SUPPORTED.set(true); 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); return true; diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java similarity index 93% rename from OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java rename to OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java index b1cff7cdf7..c5b09a9463 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java @@ -20,7 +20,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; -public abstract class ArticleBaseDialogFragment extends WikivoyageBaseDialogFragment { +public abstract class WikiArticleBaseDialogFragment extends WikivoyageBaseDialogFragment { protected static final String HEADER_INNER = "\n" + "\n" + @@ -88,7 +88,7 @@ public abstract class ArticleBaseDialogFragment extends WikivoyageBaseDialogFrag protected void updateWebSettings() { - OsmandSettings.WikivoyageShowImages showImages = getSettings().WIKIVOYAGE_SHOW_IMAGES.get(); + OsmandSettings.WikiArticleShowImages showImages = getSettings().WIKI_ARTICLE_SHOW_IMAGES.get(); WebSettings webSettings = contentWebView.getSettings(); switch (showImages) { case ON: @@ -113,8 +113,7 @@ public abstract class ArticleBaseDialogFragment extends WikivoyageBaseDialogFrag return "file:///android_asset/"; } - protected void writeOutHTML(StringBuilder sb) { - File file = new File(getMyApplication().getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), "page.html"); + protected void writeOutHTML(StringBuilder sb, File file) { BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(file)); diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java index 1b18ac6cac..94d93d39b4 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java @@ -31,7 +31,6 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.helpers.FileNameTranslationHelper; -import net.osmand.plus.wikipedia.ArticleBaseDialogFragment; import net.osmand.util.Algorithms; import java.util.HashMap; @@ -40,7 +39,7 @@ import java.util.Set; import java.util.TreeSet; -public class WikipediaDialogFragment extends ArticleBaseDialogFragment { +public class WikipediaDialogFragment extends WikiArticleBaseDialogFragment { public static final String TAG = "WikipediaDialogFragment"; @@ -267,13 +266,13 @@ public class WikipediaDialogFragment extends ArticleBaseDialogFragment { if (app != null) { int itemId = item.getItemId(); 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; } 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; } 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; } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageShowPicturesDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageShowPicturesDialogFragment.java index 6811e23da9..4a15189776 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageShowPicturesDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageShowPicturesDialogFragment.java @@ -16,7 +16,7 @@ import android.widget.TextView; import net.osmand.AndroidUtils; 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.base.BottomSheetDialogFragment; import net.osmand.plus.helpers.AndroidUiHelper; @@ -38,7 +38,7 @@ public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragm public void onClick(View v) { OsmandApplication app = getMyApplication(); if (app != null) { - app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(WikivoyageShowImages.OFF); + app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(WikiArticleShowImages.OFF); } sendResult(); dismiss(); @@ -52,7 +52,7 @@ public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragm public void onClick(View v) { OsmandApplication app = getMyApplication(); if (app != null) { - app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(WikivoyageShowImages.WIFI); + app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(WikiArticleShowImages.WIFI); } sendResult(); dismiss(); @@ -65,7 +65,7 @@ public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragm public void onClick(View v) { OsmandApplication app = getMyApplication(); if (app != null) { - app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(WikivoyageShowImages.ON); + app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(WikiArticleShowImages.ON); } sendResult(); dismiss(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageUtils.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageUtils.java index 70f500d176..42bb7f8f5a 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageUtils.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageUtils.java @@ -8,7 +8,7 @@ import net.osmand.plus.OsmandSettings; public class WikivoyageUtils { public static void setupNetworkPolicy(OsmandSettings settings, RequestCreator rc) { - switch (settings.WIKIVOYAGE_SHOW_IMAGES.get()) { + switch (settings.WIKI_ARTICLE_SHOW_IMAGES.get()) { case ON: break; case OFF: diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index fdf0c96d5f..98cd31fe51 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -13,7 +13,6 @@ import android.support.v4.app.FragmentManager.BackStackEntry; import android.support.v7.widget.PopupMenu; import android.support.v7.widget.Toolbar; import android.text.TextUtils; -import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MenuItem; @@ -32,7 +31,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.helpers.FileNameTranslationHelper; -import net.osmand.plus.wikipedia.ArticleBaseDialogFragment; +import net.osmand.plus.wikipedia.WikiArticleBaseDialogFragment; import net.osmand.plus.wikivoyage.WikivoyageShowPicturesDialogFragment; import net.osmand.plus.wikivoyage.WikivoyageWebViewClient; import net.osmand.plus.wikivoyage.data.TravelArticle; @@ -40,10 +39,7 @@ import net.osmand.plus.wikivoyage.data.TravelDbHelper; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; import net.osmand.util.Algorithms; -import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -51,10 +47,10 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import static net.osmand.plus.OsmandSettings.WikivoyageShowImages.OFF; +import static net.osmand.plus.OsmandSettings.WikiArticleShowImages.OFF; -public class WikivoyageArticleDialogFragment extends ArticleBaseDialogFragment { +public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragment { public static final String TAG = "WikivoyageArticleDialogFragment"; @@ -211,14 +207,14 @@ public class WikivoyageArticleDialogFragment extends ArticleBaseDialogFragment { public void onResume() { super.onResume(); OsmandSettings settings = getMyApplication().getSettings(); - if (!settings.WIKIVOYAGE_SHOW_IMAGES_ASKED.get()) { + if (!settings.WIKI_ARTICLE_SHOW_IMAGES_ASKED.get()) { FragmentActivity activity = getActivity(); FragmentManager fm = getFragmentManager(); if (activity != null && fm != null) { WikivoyageShowPicturesDialogFragment fragment = new WikivoyageShowPicturesDialogFragment(); fragment.setTargetFragment(this, WikivoyageShowPicturesDialogFragment.SHOW_PICTURES_CHANGED_REQUEST_CODE); fragment.show(fm, WikivoyageShowPicturesDialogFragment.TAG); - settings.WIKIVOYAGE_SHOW_IMAGES_ASKED.set(true); + settings.WIKI_ARTICLE_SHOW_IMAGES_ASKED.set(true); } } } @@ -337,7 +333,7 @@ public class WikivoyageArticleDialogFragment extends ArticleBaseDialogFragment { } } 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)) { sb.append("
"); } @@ -349,7 +345,7 @@ public class WikivoyageArticleDialogFragment extends ArticleBaseDialogFragment { sb.append(article.getContent()); sb.append(FOOTER_INNER); if (OsmandPlugin.getEnabledPlugin(OsmandDevelopmentPlugin.class) != null) { - writeOutHTML(sb); + writeOutHTML(sb, new File(getMyApplication().getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), "page.html")); } return sb.toString(); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java index f5e9500bb9..98d6bfd5d5 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java @@ -15,7 +15,7 @@ import android.webkit.WebView; import net.osmand.PicassoUtils; import net.osmand.plus.OsmandApplication; 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.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; @@ -40,7 +40,7 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD @Override public void createMenuItems(Bundle savedInstanceState) { final OsmandApplication app = getMyApplication(); - final OsmandSettings.CommonPreference showImagesPref = app.getSettings().WIKIVOYAGE_SHOW_IMAGES; + final OsmandSettings.CommonPreference showImagesPref = app.getSettings().WIKI_ARTICLE_SHOW_IMAGES; final TravelDbHelper dbHelper = app.getTravelDbHelper(); items.add(new TitleItem(getString(R.string.shared_string_options))); @@ -75,7 +75,7 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD @Override public void onClick(View v) { 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)); item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override From 896e325353d685e5a7a1ed81eeb4aeff4580fe62 Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 3 May 2018 15:30:33 +0300 Subject: [PATCH 08/10] changed parent class to BaseOsmAndDialogFragment --- .../WikiArticleBaseDialogFragment.java | 88 ++++++++++++++++++- 1 file changed, 85 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java index c5b09a9463..80dc01c18f 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java @@ -1,10 +1,25 @@ package net.osmand.plus.wikipedia; +import android.app.Dialog; import android.graphics.drawable.Drawable; import android.os.Build; +import android.os.Bundle; +import android.support.annotation.ColorInt; +import android.support.annotation.ColorRes; +import android.support.annotation.DrawableRes; +import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentTransaction; +import android.support.v4.content.ContextCompat; +import android.support.v7.widget.Toolbar; import android.util.Log; +import android.view.ContextThemeWrapper; +import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; +import android.view.Window; import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.TextView; @@ -13,14 +28,14 @@ import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; -import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment; +import net.osmand.plus.base.BaseOsmAndDialogFragment; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; -public abstract class WikiArticleBaseDialogFragment extends WikivoyageBaseDialogFragment { +public abstract class WikiArticleBaseDialogFragment extends BaseOsmAndDialogFragment { protected static final String HEADER_INNER = "\n" + "\n" + @@ -86,6 +101,73 @@ public abstract class WikiArticleBaseDialogFragment extends WikivoyageBaseDialog protected TextView selectedLangTv; protected TextView articleToolbarText; + protected boolean nightMode; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + nightMode = isNightMode(false); + } + + @NonNull + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + int themeId = nightMode ? 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; + } + + @Override + public void show(FragmentManager manager, String tag) { + FragmentTransaction ft = manager.beginTransaction(); + ft.add(this, tag); + ft.addToBackStack(tag); + ft.commit(); + } + + @Override + protected Drawable getContentIcon(int id) { + return getIcon(id, R.color.icon_color); + } + + protected Drawable getActiveIcon(@DrawableRes int iconId) { + return getIcon(iconId, nightMode ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light); + } + + @ColorInt + protected int getResolvedColor(@ColorRes int colorId) { + return ContextCompat.getColor(getContext(), colorId); + } + + protected View inflate(@LayoutRes int layoutId, @Nullable ViewGroup container) { + int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; + return LayoutInflater.from(new ContextThemeWrapper(getContext(), themeRes)) + .inflate(layoutId, container, false); + } + + protected void setupToolbar(Toolbar toolbar) { + toolbar.setNavigationIcon(getContentIcon(R.drawable.ic_arrow_back)); + toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + closeFragment(); + } + }); + } + + protected void closeFragment() { + dismiss(); + } protected void updateWebSettings() { OsmandSettings.WikiArticleShowImages showImages = getSettings().WIKI_ARTICLE_SHOW_IMAGES.get(); @@ -138,7 +220,7 @@ public abstract class WikiArticleBaseDialogFragment extends WikivoyageBaseDialog return normal; } - @Override + @ColorRes protected int getStatusBarColor() { return nightMode ? R.color.status_bar_wikivoyage_article_dark : R.color.status_bar_wikivoyage_article_light; } From 942027635b884087652e7b29970c94e57618f0fa Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 3 May 2018 15:37:55 +0300 Subject: [PATCH 09/10] changed class name --- .../WikiArticleBaseDialogFragment.java | 86 +------------------ ...gment.java => WikiBaseDialogFragment.java} | 2 +- .../WikivoyageWelcomeDialogFragment.java | 2 +- .../WikivoyageExploreDialogFragment.java | 4 +- .../WikivoyageSearchDialogFragment.java | 4 +- 5 files changed, 9 insertions(+), 89 deletions(-) rename OsmAnd/src/net/osmand/plus/wikivoyage/{WikivoyageBaseDialogFragment.java => WikiBaseDialogFragment.java} (97%) diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java index 80dc01c18f..9bf4103a5a 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java @@ -1,25 +1,11 @@ package net.osmand.plus.wikipedia; -import android.app.Dialog; import android.graphics.drawable.Drawable; import android.os.Build; -import android.os.Bundle; -import android.support.annotation.ColorInt; import android.support.annotation.ColorRes; -import android.support.annotation.DrawableRes; -import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentTransaction; -import android.support.v4.content.ContextCompat; -import android.support.v7.widget.Toolbar; import android.util.Log; -import android.view.ContextThemeWrapper; -import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; -import android.view.Window; import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.TextView; @@ -28,14 +14,14 @@ import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; -import net.osmand.plus.base.BaseOsmAndDialogFragment; +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 BaseOsmAndDialogFragment { +public abstract class WikiArticleBaseDialogFragment extends WikiBaseDialogFragment { protected static final String HEADER_INNER = "\n" + "\n" + @@ -101,73 +87,6 @@ public abstract class WikiArticleBaseDialogFragment extends BaseOsmAndDialogFrag protected TextView selectedLangTv; protected TextView articleToolbarText; - protected boolean nightMode; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - nightMode = isNightMode(false); - } - - @NonNull - @Override - public Dialog onCreateDialog(Bundle savedInstanceState) { - int themeId = nightMode ? 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; - } - - @Override - public void show(FragmentManager manager, String tag) { - FragmentTransaction ft = manager.beginTransaction(); - ft.add(this, tag); - ft.addToBackStack(tag); - ft.commit(); - } - - @Override - protected Drawable getContentIcon(int id) { - return getIcon(id, R.color.icon_color); - } - - protected Drawable getActiveIcon(@DrawableRes int iconId) { - return getIcon(iconId, nightMode ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light); - } - - @ColorInt - protected int getResolvedColor(@ColorRes int colorId) { - return ContextCompat.getColor(getContext(), colorId); - } - - protected View inflate(@LayoutRes int layoutId, @Nullable ViewGroup container) { - int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; - return LayoutInflater.from(new ContextThemeWrapper(getContext(), themeRes)) - .inflate(layoutId, container, false); - } - - protected void setupToolbar(Toolbar toolbar) { - toolbar.setNavigationIcon(getContentIcon(R.drawable.ic_arrow_back)); - toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); - toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - closeFragment(); - } - }); - } - - protected void closeFragment() { - dismiss(); - } protected void updateWebSettings() { OsmandSettings.WikiArticleShowImages showImages = getSettings().WIKI_ARTICLE_SHOW_IMAGES.get(); @@ -220,6 +139,7 @@ public abstract class WikiArticleBaseDialogFragment extends BaseOsmAndDialogFrag return normal; } + @Override @ColorRes protected int getStatusBarColor() { return nightMode ? R.color.status_bar_wikivoyage_article_dark : R.color.status_bar_wikivoyage_article_light; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikiBaseDialogFragment.java similarity index 97% rename from OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java rename to OsmAnd/src/net/osmand/plus/wikivoyage/WikiBaseDialogFragment.java index b452c9495e..8a24895151 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikiBaseDialogFragment.java @@ -23,7 +23,7 @@ import android.view.Window; import net.osmand.plus.R; import net.osmand.plus.base.BaseOsmAndDialogFragment; -public class WikivoyageBaseDialogFragment extends BaseOsmAndDialogFragment { +public class WikiBaseDialogFragment extends BaseOsmAndDialogFragment { protected boolean nightMode; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWelcomeDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWelcomeDialogFragment.java index bef0832780..a69ff557ec 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWelcomeDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWelcomeDialogFragment.java @@ -15,7 +15,7 @@ import net.osmand.plus.R; import net.osmand.plus.helpers.AndroidUiHelper; 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(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java index c86d4b3b73..425c018096 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreDialogFragment.java @@ -26,7 +26,7 @@ import net.osmand.plus.LockableViewPager; import net.osmand.plus.R; import net.osmand.plus.base.BaseOsmAndFragment; 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.search.WikivoyageSearchDialogFragment; @@ -35,7 +35,7 @@ import java.util.Arrays; 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"; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/search/WikivoyageSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/search/WikivoyageSearchDialogFragment.java index 25a7266da4..ed71622482 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/search/WikivoyageSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/search/WikivoyageSearchDialogFragment.java @@ -20,7 +20,7 @@ import android.widget.ProgressBar; import net.osmand.ResultMatcher; import net.osmand.plus.OsmandApplication; 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.data.TravelLocalDataHelper; 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.List; -public class WikivoyageSearchDialogFragment extends WikivoyageBaseDialogFragment { +public class WikivoyageSearchDialogFragment extends WikiBaseDialogFragment { public static final String TAG = "WikivoyageSearchDialogFragment"; From 61c2d4572863a4bcf86fba66576f68576a4753d9 Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 3 May 2018 15:51:20 +0300 Subject: [PATCH 10/10] removed onCreate --- .../net/osmand/plus/wikipedia/WikipediaDialogFragment.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java index 94d93d39b4..f78f23be54 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java @@ -62,13 +62,6 @@ public class WikipediaDialogFragment extends WikiArticleBaseDialogFragment { this.lang = lang; } - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - int themeId = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; - setStyle(STYLE_NO_FRAME, themeId); - } - @SuppressLint("SetJavaScriptEnabled") @Nullable @Override