From 80db67a8be3d03c79cf09ae27be97e4693859491 Mon Sep 17 00:00:00 2001 From: Nazar Date: Wed, 17 Jul 2019 11:59:41 +0300 Subject: [PATCH] add text "Powered by OpenStreetMap data." to the second splash screen (cherry picked from commit 805fc00e0b985dbea2bbeb2f39e7a8304906ba0d) --- OsmAnd/res/values-land/sizes.xml | 5 ++- .../osmand/SecondSplashScreenFragment.java | 44 ++++++++++++------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/OsmAnd/res/values-land/sizes.xml b/OsmAnd/res/values-land/sizes.xml index 0481b5e2ba..a927d1e718 100644 --- a/OsmAnd/res/values-land/sizes.xml +++ b/OsmAnd/res/values-land/sizes.xml @@ -2,8 +2,9 @@ 200dp - 24dp - 48dp + 12dp + 12dp + 12dp 39dp 39dp diff --git a/OsmAnd/src/net/osmand/SecondSplashScreenFragment.java b/OsmAnd/src/net/osmand/SecondSplashScreenFragment.java index 2ba2a2e889..dc56191fd0 100644 --- a/OsmAnd/src/net/osmand/SecondSplashScreenFragment.java +++ b/OsmAnd/src/net/osmand/SecondSplashScreenFragment.java @@ -22,6 +22,10 @@ import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.inapp.InAppPurchaseHelper; public class SecondSplashScreenFragment extends BaseOsmAndFragment { + private final static int LOGO_ID = 1001; + private final static int TEXT_ID = 1002; + private final static int OSM_TEXT_ID = 1003; + public static final String TAG = "SecondSplashScreenFragment"; public static boolean SHOW = true; public static boolean VISIBLE = false; @@ -86,6 +90,7 @@ public class SecondSplashScreenFragment extends BaseOsmAndFragment { view.setBackgroundColor(getResources().getColor(R.color.map_background_color_light)); ImageView logo = new ImageView(getContext()); + logo.setId(LOGO_ID); if (Version.isFreeVersion(app)) { logo.setImageDrawable(getResources().getDrawable(R.drawable.ic_logo_splash_osmand)); } else if (Version.isPaidVersion(app) || Version.isDeveloperVersion(app)) { @@ -94,7 +99,9 @@ public class SecondSplashScreenFragment extends BaseOsmAndFragment { RelativeLayout.LayoutParams logoLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); logoLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); logoLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL); + ImageView text = new ImageView(activity); + text.setId(TEXT_ID); if (Version.isFreeVersion(app)) { if (InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) { text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_osmlive)); @@ -111,37 +118,44 @@ public class SecondSplashScreenFragment extends BaseOsmAndFragment { } } RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); - textLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); + textLayoutParams.addRule(RelativeLayout.ABOVE, OSM_TEXT_ID); textLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL); + + ImageView osmText = new ImageView(activity); + osmText.setId(OSM_TEXT_ID); + osmText.setImageDrawable(getResources().getDrawable(R.drawable.image_text_openstreetmap)); + RelativeLayout.LayoutParams osmTextLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + osmTextLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); + osmTextLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL); + int defaultLogoMarginTop = (int) getResources().getDimension(R.dimen.splash_screen_logo_top); int logoMarginTop = defaultLogoMarginTop - (Build.VERSION.SDK_INT >= 21 ? 0 : getStatusBarHeight()); - int logoPaddingLeft = 0; - int logoPaddingRight = 0; - int defaultTextMarginBottom = (int) getResources().getDimension(R.dimen.splash_screen_text_bottom); - int textMarginBottom = defaultTextMarginBottom - getNavigationBarHeight(); - int textPaddingLeft = 0; - int textPaddingRight = 0; + int textMarginBottom = (int) getResources().getDimension(R.dimen.splash_screen_text_bottom); + int osmTextMarginBottom = (int) getResources().getDimension(R.dimen.splash_screen_osm_text_bottom); + int elementsPaddingLeft = 0; + int elementsPaddingRight = 0; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) { int screenOrientation = AndroidUiHelper.getScreenOrientation(activity); if (screenOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { - logoPaddingLeft = getNavigationBarWidth(); - textPaddingLeft = getNavigationBarWidth(); + elementsPaddingLeft = getNavigationBarWidth(); } else if (screenOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) { - logoPaddingRight = getNavigationBarWidth(); - textPaddingRight = getNavigationBarWidth(); + elementsPaddingRight = getNavigationBarWidth(); } } else { - logoPaddingLeft = getNavigationBarWidth(); - textPaddingLeft = getNavigationBarWidth(); + elementsPaddingLeft = getNavigationBarWidth(); } logoLayoutParams.setMargins(0, logoMarginTop, 0, 0); - logo.setPadding(logoPaddingLeft, 0, logoPaddingRight, 0); + logo.setPadding(elementsPaddingLeft, 0, elementsPaddingRight, 0); logo.setLayoutParams(logoLayoutParams); view.addView(logo); textLayoutParams.setMargins(0, 0, 0, textMarginBottom); - text.setPadding(textPaddingLeft, 0, textPaddingRight, 0); + text.setPadding(elementsPaddingLeft, 0, elementsPaddingRight, 0); text.setLayoutParams(textLayoutParams); view.addView(text); + osmTextLayoutParams.setMargins(0, 0, 0, osmTextMarginBottom); + osmText.setPadding(elementsPaddingLeft, 0, elementsPaddingRight, 0); + osmText.setLayoutParams(osmTextLayoutParams); + view.addView(osmText); return view; }