diff --git a/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java index 4b625e9515..aae560d9ec 100644 --- a/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java @@ -1,6 +1,7 @@ package net.osmand.plus.base; import android.animation.Animator; +import android.animation.Animator.AnimatorListener; import android.animation.AnimatorListenerAdapter; import android.annotation.TargetApi; import android.app.Activity; @@ -884,32 +885,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment updateMainViewLayout(posY); } if (animated) { - mainView.animate().y(posY) - .setDuration(ANIMATION_DURATION) - .setInterpolator(new DecelerateInterpolator()) - .setListener(new AnimatorListenerAdapter() { - - boolean canceled = false; - - @Override - public void onAnimationCancel(Animator animation) { - canceled = true; - } - - @Override - public void onAnimationEnd(Animator animation) { - if (!canceled) { - if (needCloseMenu && isHideable()) { - dismiss(); - } else { - updateMainViewLayout(posY); - if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) { - doAfterMenuStateChange(previousMenuState, newMenuState); - } - } - } - } - }).start(); + animateMainView(posY, needCloseMenu, previousMenuState, newMenuState); } else { if (needCloseMenu && isHideable()) { dismiss(); @@ -929,10 +905,37 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment return posY; } - public void animateView(@NonNull View view, int y) { + protected void animateMainView(final int posY, final boolean needCloseMenu, final int previousMenuState, final int newMenuState) { + animateView(mainView, posY, new AnimatorListenerAdapter() { + + boolean canceled = false; + + @Override + public void onAnimationCancel(Animator animation) { + canceled = true; + } + + @Override + public void onAnimationEnd(Animator animation) { + if (!canceled) { + if (needCloseMenu && isHideable()) { + dismiss(); + } else { + updateMainViewLayout(posY); + if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) { + doAfterMenuStateChange(previousMenuState, newMenuState); + } + } + } + } + }); + } + + public void animateView(@NonNull View view, int y, @Nullable AnimatorListener listener) { view.animate().y(y) .setDuration(ANIMATION_DURATION) .setInterpolator(new DecelerateInterpolator()) + .setListener(listener) .start(); } diff --git a/OsmAnd/src/net/osmand/plus/base/ContextMenuScrollFragment.java b/OsmAnd/src/net/osmand/plus/base/ContextMenuScrollFragment.java index 5ba853e147..03c0be526e 100644 --- a/OsmAnd/src/net/osmand/plus/base/ContextMenuScrollFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/ContextMenuScrollFragment.java @@ -133,7 +133,7 @@ public abstract class ContextMenuScrollFragment extends ContextMenuFragment impl if (mapControlsView != null) { int zoomY = y - getMapControlsHeight(); if (animated) { - fragment.animateView(mapControlsView, zoomY); + fragment.animateView(mapControlsView, zoomY, null); } else { mapControlsView.setY(zoomY); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java index 99d6a5c0cd..89afe180e2 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java @@ -767,7 +767,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe int pagesY = y - getPagesViewHeight() + fragment.getShadowHeight() + (Build.VERSION.SDK_INT >= 21 ? AndroidUtils.getStatusBarHeight(pagesView.getContext()) : 0); if (animated) { - fragment.animateView(pagesView, pagesY); + fragment.animateView(pagesView, pagesY, null); } else { pagesView.setY(pagesY); } @@ -780,7 +780,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe int zoomY = y - getZoomButtonsHeight() + (Build.VERSION.SDK_INT >= 21 ? AndroidUtils.getStatusBarHeight(zoomButtonsView.getContext()) : 0); if (animated) { - fragment.animateView(zoomButtonsView, zoomY); + fragment.animateView(zoomButtonsView, zoomY, null); } else { zoomButtonsView.setY(zoomY); } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index b86df52652..0249a67a55 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -155,6 +155,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card private LatLon latLon; private int menuTitleHeight; + private int menuHeaderHeight; private int toolbarHeightPx; private boolean mapPositionAdjusted; @@ -300,7 +301,11 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card updateHeader(); setupButtons(view); updateCardsLayout(); - calculateLayoutAndUpdateMenuState(); + if (menuType == TrackMenuType.OVERVIEW && isPortrait()) { + calculateLayoutAndShowHeader(); + } else { + calculateLayoutAndUpdateMenuState(); + } } return view; } @@ -484,8 +489,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card @Override protected void calculateLayout(View view, boolean initLayout) { - menuTitleHeight = routeMenuTopShadowAll.getHeight() - + bottomNav.getHeight(); + menuHeaderHeight = headerContainer.getHeight(); + menuTitleHeight = routeMenuTopShadowAll.getHeight() + bottomNav.getHeight(); super.calculateLayout(view, initLayout); } @@ -913,6 +918,20 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card }); } + private void calculateLayoutAndShowHeader() { + runLayoutListener(new Runnable() { + @Override + public void run() { + int posY = getViewHeight() - menuHeaderHeight - menuTitleHeight - getShadowHeight(); + if (posY < getViewY()) { + updateMainViewLayout(posY); + } + animateMainView(posY, false, getCurrentMenuState(), getCurrentMenuState()); + updateMapControlsPos(TrackMenuFragment.this, posY, true); + } + }); + } + private void updateMenuState() { if (menuType == TrackMenuType.OPTIONS) { openMenuFullScreen();