From 8c4875d258c4dda4aeb58aaf3aeeb88e17bc1d95 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Mon, 23 Apr 2018 14:23:22 +0300 Subject: [PATCH] Adapt wikivoyage welcome screen for landscape --- .../fragment_wikivoyage_welcome_dialog.xml | 10 ++ .../fragment_wikivoyage_welcome_dialog.xml | 83 +---------------- .../res/layout/wikivoyage_welcome_screen.xml | 91 +++++++++++++++++++ .../WikivoyageWelcomeDialogFragment.java | 8 +- 4 files changed, 109 insertions(+), 83 deletions(-) create mode 100644 OsmAnd/res/layout-land/fragment_wikivoyage_welcome_dialog.xml create mode 100644 OsmAnd/res/layout/wikivoyage_welcome_screen.xml diff --git a/OsmAnd/res/layout-land/fragment_wikivoyage_welcome_dialog.xml b/OsmAnd/res/layout-land/fragment_wikivoyage_welcome_dialog.xml new file mode 100644 index 0000000000..dee268a622 --- /dev/null +++ b/OsmAnd/res/layout-land/fragment_wikivoyage_welcome_dialog.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/OsmAnd/res/layout/fragment_wikivoyage_welcome_dialog.xml b/OsmAnd/res/layout/fragment_wikivoyage_welcome_dialog.xml index 2a9df61fba..e5de9cd2de 100644 --- a/OsmAnd/res/layout/fragment_wikivoyage_welcome_dialog.xml +++ b/OsmAnd/res/layout/fragment_wikivoyage_welcome_dialog.xml @@ -1,92 +1,11 @@ - - - - - - - - - - - - - - - - - - - - - + diff --git a/OsmAnd/res/layout/wikivoyage_welcome_screen.xml b/OsmAnd/res/layout/wikivoyage_welcome_screen.xml new file mode 100644 index 0000000000..80f0951586 --- /dev/null +++ b/OsmAnd/res/layout/wikivoyage_welcome_screen.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWelcomeDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWelcomeDialogFragment.java index d72e085dbf..6b859889c0 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWelcomeDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWelcomeDialogFragment.java @@ -9,8 +9,10 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import android.widget.ImageView.ScaleType; import net.osmand.plus.R; +import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.wikivoyage.explore.WikivoyageExploreDialogFragment; public class WikivoyageWelcomeDialogFragment extends WikivoyageBaseDialogFragment { @@ -20,6 +22,8 @@ public class WikivoyageWelcomeDialogFragment extends WikivoyageBaseDialogFragmen @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + final boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity()); + View mainView = inflate(R.layout.fragment_wikivoyage_welcome_dialog, container); ImageView backBtn = (ImageView) mainView.findViewById(R.id.back_button); @@ -32,7 +36,9 @@ public class WikivoyageWelcomeDialogFragment extends WikivoyageBaseDialogFragmen }); int imgId = nightMode ? R.drawable.img_start_screen_travel_night : R.drawable.img_start_screen_travel_day; - ((ImageView) mainView.findViewById(R.id.main_image)).setImageResource(imgId); + ImageView mainImage = (ImageView) mainView.findViewById(R.id.main_image); + mainImage.setScaleType(portrait ? ScaleType.CENTER_CROP : ScaleType.CENTER_INSIDE); + mainImage.setImageResource(imgId); mainView.findViewById(R.id.continue_button).setOnClickListener(new View.OnClickListener() { @Override