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";