diff --git a/OsmAnd/res/drawable-land/first_splash_screen_free.xml b/OsmAnd/res/drawable-land/first_splash_screen_free.xml deleted file mode 100644 index 4e12cbfe75..0000000000 --- a/OsmAnd/res/drawable-land/first_splash_screen_free.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/drawable-land/first_splash_screen_free_dev.xml b/OsmAnd/res/drawable-land/first_splash_screen_free_dev.xml deleted file mode 100644 index 4e12cbfe75..0000000000 --- a/OsmAnd/res/drawable-land/first_splash_screen_free_dev.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/drawable-land/first_splash_screen_plus.xml b/OsmAnd/res/drawable-land/first_splash_screen_plus.xml deleted file mode 100644 index dbaa837eb9..0000000000 --- a/OsmAnd/res/drawable-land/first_splash_screen_plus.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/drawable/first_splash_screen_free.xml b/OsmAnd/res/drawable/first_splash_screen_free.xml index 92b8a6f82d..b3d6f99388 100644 --- a/OsmAnd/res/drawable/first_splash_screen_free.xml +++ b/OsmAnd/res/drawable/first_splash_screen_free.xml @@ -2,14 +2,9 @@ - + - - - \ No newline at end of file diff --git a/OsmAnd/res/drawable/first_splash_screen_free_dev.xml b/OsmAnd/res/drawable/first_splash_screen_free_dev.xml index 92b8a6f82d..b3d6f99388 100644 --- a/OsmAnd/res/drawable/first_splash_screen_free_dev.xml +++ b/OsmAnd/res/drawable/first_splash_screen_free_dev.xml @@ -2,14 +2,9 @@ - + - - - \ No newline at end of file diff --git a/OsmAnd/res/drawable/first_splash_screen_plus.xml b/OsmAnd/res/drawable/first_splash_screen_plus.xml index 231252cffd..1dc65ed611 100644 --- a/OsmAnd/res/drawable/first_splash_screen_plus.xml +++ b/OsmAnd/res/drawable/first_splash_screen_plus.xml @@ -2,7 +2,7 @@ - + diff --git a/OsmAnd/res/values-land/sizes.xml b/OsmAnd/res/values-land/sizes.xml index 79aeb33d21..7cf56d5d90 100644 --- a/OsmAnd/res/values-land/sizes.xml +++ b/OsmAnd/res/values-land/sizes.xml @@ -1,4 +1,7 @@ 200dp + + 24dp + 48dp \ No newline at end of file diff --git a/OsmAnd/res/values-sw600dp-land/sizes.xml b/OsmAnd/res/values-sw600dp-land/sizes.xml new file mode 100644 index 0000000000..aaecd82cda --- /dev/null +++ b/OsmAnd/res/values-sw600dp-land/sizes.xml @@ -0,0 +1,5 @@ + + + 200dp + 150dp + \ No newline at end of file diff --git a/OsmAnd/res/values-sw600dp-port/sizes.xml b/OsmAnd/res/values-sw600dp-port/sizes.xml new file mode 100644 index 0000000000..e4cf1852c8 --- /dev/null +++ b/OsmAnd/res/values-sw600dp-port/sizes.xml @@ -0,0 +1,5 @@ + + + 300dp + 200dp + \ No newline at end of file diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 16dd668b42..0a922ea0a4 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -138,4 +138,7 @@ 10sp 20sp + + 150dp + 128dp \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/SecondSplashScreenFragment.java b/OsmAnd/src/net/osmand/SecondSplashScreenFragment.java index 5c1c08afdb..e65f4cc30c 100644 --- a/OsmAnd/src/net/osmand/SecondSplashScreenFragment.java +++ b/OsmAnd/src/net/osmand/SecondSplashScreenFragment.java @@ -6,14 +6,12 @@ import android.os.Bundle; import android.os.Handler; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.RelativeLayout; -import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.activities.MapActivity; @@ -24,7 +22,7 @@ public class SecondSplashScreenFragment extends Fragment { public static boolean SHOW = true; private static final int SECOND_SPLASH_TIME_OUT = 2000; - public boolean hasNavBar () { + private boolean hasNavBar() { int id = getResources().getIdentifier("config_showNavigationBar", "bool", "android"); if (id > 0) return getResources().getBoolean(id); @@ -32,7 +30,7 @@ public class SecondSplashScreenFragment extends Fragment { return false; } - public int getStatusBarHeight() { + private int getStatusBarHeight() { int statusBarHeight = 0; int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { @@ -41,42 +39,29 @@ public class SecondSplashScreenFragment extends Fragment { return statusBarHeight; } - public int getNavigationBarHeight () { + private int getNavigationBarHeight() { if (!hasNavBar()) return 0; - int orientation = getResources().getConfiguration().orientation; - boolean isSmartphone = getResources().getConfiguration().smallestScreenWidthDp < 600; if (isSmartphone && Configuration.ORIENTATION_LANDSCAPE == orientation) return 0; - int id = getResources().getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android"); if (id > 0) return getResources().getDimensionPixelSize(id); - return 0; } - public boolean isSmartphone() { - return getResources().getConfiguration().smallestScreenWidthDp < 600; - } - - public int getNavigationBarWidth () - { + private int getNavigationBarWidth() { if (!hasNavBar()) return 0; - int orientation = getResources().getConfiguration().orientation; - boolean isSmartphone = getResources().getConfiguration().smallestScreenWidthDp < 600; - if (orientation == Configuration.ORIENTATION_LANDSCAPE && isSmartphone) { int id = getResources().getIdentifier("navigation_bar_width", "dimen", "android"); if (id > 0) return getResources().getDimensionPixelSize(id); } - return 0; } @@ -91,34 +76,6 @@ public class SecondSplashScreenFragment extends Fragment { 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); - if (AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || - AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) { - int defaultLogoMarginTop = AndroidUtils.dpToPx(getActivity(), 150); - logoLayoutParams.setMargins(0, defaultLogoMarginTop - getStatusBarHeight(), 0, 0); - } else if (AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || - AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) { - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) { - if (AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { - int defaultLogoMarginTop = AndroidUtils.dpToPx(getActivity(), 24); - int logoPaddingLeft = getNavigationBarWidth(); - logo.setPadding(logoPaddingLeft, 0, 0, 0); - logoLayoutParams.setMargins(0, defaultLogoMarginTop - getStatusBarHeight(), 0, 0); - } else if (AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) { - int defaultLogoMarginTop = AndroidUtils.dpToPx(getActivity(), 24); - int logoPaddingRight = getNavigationBarWidth(); - logo.setPadding(0, 0, logoPaddingRight, 0); - logoLayoutParams.setMargins(0, defaultLogoMarginTop - getStatusBarHeight(), 0, 0); - } - } else { - int defaultLogoMarginTop = AndroidUtils.dpToPx(getActivity(), 24); - int logoPaddingLeft = getNavigationBarWidth(); - logo.setPadding(logoPaddingLeft, 0, 0, 0); - logoLayoutParams.setMargins(0, defaultLogoMarginTop - getStatusBarHeight(), 0, 0); - } - } - logo.setLayoutParams(logoLayoutParams); - view.addView(logo); - ImageView text = new ImageView(getActivity()); if (Version.isFreeVersion(((MapActivity) getActivity()).getMyApplication())) { text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand)); @@ -129,50 +86,53 @@ public class SecondSplashScreenFragment extends Fragment { RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); textLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); textLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL); - if (AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || - AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) { - int defaultTextMarginBottom = AndroidUtils.dpToPx(getActivity(), 128); - Log.d("PORTRAIT", "defaultTextMarginBottom: " + defaultTextMarginBottom); - Log.d("PORTRAIT", "getNavigationBarHeight: " + getNavigationBarHeight()); - textLayoutParams.setMargins(0, 0, 0, defaultTextMarginBottom - getNavigationBarHeight()); - } else if (AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || - AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) { - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) { - if (AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { - int defaultTextMarginBottom = AndroidUtils.dpToPx(getActivity(), 48); - int textPaddingLeft = getNavigationBarWidth(); - text.setPadding(textPaddingLeft, 0, 0, 0); - textLayoutParams.setMargins(0, 0, 0, defaultTextMarginBottom); - } else if (AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) { - int defaultTextMarginBottom = AndroidUtils.dpToPx(getActivity(), 48); - int textPaddingRight = getNavigationBarWidth(); - text.setPadding(0, 0, textPaddingRight, 0); - textLayoutParams.setMargins(0, 0, 0, defaultTextMarginBottom); - } - } else { - int defaultTextMarginBottom = AndroidUtils.dpToPx(getActivity(), 48); - int textPaddingLeft = getNavigationBarWidth(); - text.setPadding(textPaddingLeft, 0, 0, 0); - textLayoutParams.setMargins(0, 0, 0, defaultTextMarginBottom); + int defaultLogoMarginTop = (int) getResources().getDimension(R.dimen.splash_screen_logo_top); + int logoMarginTop = defaultLogoMarginTop - 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; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) { + if (AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { + logoPaddingLeft = getNavigationBarWidth(); + textPaddingLeft = getNavigationBarWidth(); + } else if (AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) { + logoPaddingRight = getNavigationBarWidth(); + textPaddingRight = getNavigationBarWidth(); } + } else { + logoPaddingLeft = getNavigationBarWidth(); + textPaddingLeft = getNavigationBarWidth(); } + logoLayoutParams.setMargins(0, logoMarginTop, 0, 0); + logo.setPadding(logoPaddingLeft, 0, logoPaddingRight, 0); + logo.setLayoutParams(logoLayoutParams); + view.addView(logo); + textLayoutParams.setMargins(0, 0, 0, textMarginBottom); + text.setPadding(textPaddingLeft, 0, textPaddingRight, 0); text.setLayoutParams(textLayoutParams); view.addView(text); + return view; + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); new Handler().postDelayed(new Runnable() { @Override public void run() { -// getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); -// if (((MapActivity)getActivity()).getMyApplication().getSettings().MAP_SCREEN_ORIENTATION.get() != getActivity().getRequestedOrientation()) { -// getActivity().setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get()); -// // can't return from this method we are not sure if activity will be recreated or not -// } + getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); + if (((MapActivity)getActivity()).getMyApplication().getSettings().MAP_SCREEN_ORIENTATION.get() != getActivity().getRequestedOrientation()) { + getActivity().setRequestedOrientation(((MapActivity)getActivity()).getMyApplication().getSettings().MAP_SCREEN_ORIENTATION.get()); + // can't return from this method we are not sure if activity will be recreated or not + } getActivity().getSupportFragmentManager().beginTransaction().remove(SecondSplashScreenFragment.this).commitAllowingStateLoss(); } }, SECOND_SPLASH_TIME_OUT); - - return view; } @Override diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 2997bb5228..c01d74dc5c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -191,7 +191,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven @Override public void onCreate(Bundle savedInstanceState) { -// setRequestedOrientation(AndroidUiHelper.getScreenOrientation(this)); + setRequestedOrientation(AndroidUiHelper.getScreenOrientation(this)); overridePendingTransition(0, 0); long tm = System.currentTimeMillis(); app = getMyApplication(); @@ -548,10 +548,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven if (getSupportActionBar() != null) { getSupportActionBar().hide(); } - if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) { - setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get()); - // can't return from this method we are not sure if activity will be recreated or not - } app.getLocationProvider().checkIfLastKnownLocationIsValid(); // for voice navigation @@ -697,14 +693,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven FirstUsageWelcomeFragment.SHOW = false; if (SecondSplashScreenFragment.SHOW) { getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, new SecondSplashScreenFragment(), SecondSplashScreenFragment.TAG).commitAllowingStateLoss(); + } else { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); + if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) { + setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get()); + // can't return from this method we are not sure if activity will be recreated or not + } } -// else { -// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); -// if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) { -// setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get()); -// // can't return from this method we are not sure if activity will be recreated or not -// } -// } SecondSplashScreenFragment.SHOW = false; }