diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index e23b913414..2102ec38da 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -142,6 +142,8 @@ #8a4e00 #13171a #0d0f0f + #f2f2f2 + #222526 #0000 @@ -384,4 +386,15 @@ #808080 + #f0f0f0 + #17191a + #ffffff + #222526 + #f0f0f0 + #2d3133 + #237bff + #d28521 + #f2f2f2 + #222526 + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index f04d9febc8..b9622add6a 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -5,19 +5,16 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.FragmentManager; import android.support.v7.widget.Toolbar; -import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; -import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.plus.base.BaseOsmAndDialogFragment; import net.osmand.plus.wikivoyage.data.WikivoyageArticle; import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult; -public class WikivoyageArticleDialogFragment extends BaseOsmAndDialogFragment { +public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragment { public static final String TAG = "WikivoyageArticleDialogFragment"; @@ -26,24 +23,12 @@ public class WikivoyageArticleDialogFragment extends BaseOsmAndDialogFragment { @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - final OsmandApplication app = getMyApplication(); - final int themeRes = isNightMode(false) ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; + final View mainView = inflate(R.layout.fragment_wikivoyage_article_dialog, container); - final View mainView = LayoutInflater.from(new ContextThemeWrapper(app, themeRes)) - .inflate(R.layout.fragment_wikivoyage_article_dialog, container, false); - - Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.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) { - dismiss(); - } - }); + setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar)); WikivoyageSearchResult searchResult = (WikivoyageSearchResult) getArguments().getParcelable(SEARCH_RESULT_KEY); - WikivoyageArticle article = app.getWikivoyageDbHelper() + WikivoyageArticle article = getMyApplication().getWikivoyageDbHelper() .getArticle(searchResult.getCityId(), searchResult.getLang().get(0)); WebView contentWebView = (WebView) mainView.findViewById(R.id.content_web_view); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java new file mode 100644 index 0000000000..7b9082f576 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java @@ -0,0 +1,47 @@ +package net.osmand.plus.wikivoyage; + +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.support.annotation.LayoutRes; +import android.support.annotation.Nullable; +import android.support.v7.widget.Toolbar; +import android.view.ContextThemeWrapper; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import net.osmand.plus.R; +import net.osmand.plus.base.BaseOsmAndDialogFragment; + +public class WikivoyageBaseDialogFragment extends BaseOsmAndDialogFragment { + + protected boolean nightMode; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + nightMode = isNightMode(false); + } + + @Override + protected Drawable getContentIcon(int id) { + return getIcon(id, R.color.icon_color); + } + + 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) { + dismiss(); + } + }); + } +} diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageExploreDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageExploreDialogFragment.java index 6281312c10..016d785521 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageExploreDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageExploreDialogFragment.java @@ -5,39 +5,24 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.FragmentManager; import android.support.v7.widget.Toolbar; -import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; -import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.plus.base.BaseOsmAndDialogFragment; import net.osmand.plus.wikivoyage.search.WikivoyageSearchDialogFragment; -public class WikivoyageExploreDialogFragment extends BaseOsmAndDialogFragment { +public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragment { public static final String TAG = "WikivoyageExploreDialogFragment"; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - final OsmandApplication app = getMyApplication(); - final int themeRes = isNightMode(false) ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; + final View mainView = inflate(R.layout.fragment_wikivoyage_explore_dialog, container); - final View mainView = LayoutInflater.from(new ContextThemeWrapper(app, themeRes)) - .inflate(R.layout.fragment_wikivoyage_explore_dialog, container, false); - - Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.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) { - dismiss(); - } - }); + setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar)); ((ImageView) mainView.findViewById(R.id.search_icon)) .setImageDrawable(getContentIcon(R.drawable.ic_action_search_dark)); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/search/WikivoyageSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/search/WikivoyageSearchDialogFragment.java index 269e5f7180..8d63257ca0 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/search/WikivoyageSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/search/WikivoyageSearchDialogFragment.java @@ -9,7 +9,6 @@ import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; -import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -18,15 +17,14 @@ import android.widget.ImageButton; import android.widget.ProgressBar; import net.osmand.ResultMatcher; -import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.plus.base.BaseOsmAndDialogFragment; import net.osmand.plus.wikivoyage.WikivoyageArticleDialogFragment; +import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment; import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult; import java.util.List; -public class WikivoyageSearchDialogFragment extends BaseOsmAndDialogFragment { +public class WikivoyageSearchDialogFragment extends WikivoyageBaseDialogFragment { public static final String TAG = "WikivoyageSearchDialogFragment"; @@ -45,22 +43,12 @@ public class WikivoyageSearchDialogFragment extends BaseOsmAndDialogFragment { @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - final OsmandApplication app = getMyApplication(); - searchHelper = new WikivoyageSearchHelper(app); - final int themeRes = isNightMode(false) ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; + searchHelper = new WikivoyageSearchHelper(getMyApplication()); - final View mainView = LayoutInflater.from(new ContextThemeWrapper(app, themeRes)) - .inflate(R.layout.fragment_wikivoyage_search_dialog, container, false); + final View mainView = inflate(R.layout.fragment_wikivoyage_search_dialog, container); Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.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) { - dismiss(); - } - }); + setupToolbar(toolbar); searchEt = (EditText) toolbar.findViewById(R.id.searchEditText); searchEt.setHint(R.string.shared_string_search);