Hide zoom buttons and menu, when PP intersects it.

This commit is contained in:
Dmitry Yunitsky 2015-03-10 20:08:30 +03:00 committed by Alex Zolotarev
parent a87df99dcb
commit 0559222e88
6 changed files with 92 additions and 28 deletions

View file

@ -6,6 +6,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Point;
import android.location.Location;
import android.os.Build;
@ -110,6 +111,7 @@ public class MWMActivity extends MWMFragmentActivity
private ImageButton mLocationButton;
// map
private MapFragment mMapFragment;
private View mNavigationButtons;
// Place page
private PlacePageView mPlacePage;
private View mRlStartRouting;
@ -387,7 +389,7 @@ public class MWMActivity extends MWMFragmentActivity
if (getSupportFragmentManager().findFragmentByTag(SearchFragment.class.getName()) != null) // search is already shown
return;
setVerticalToolbarVisible(false);
hideInfoView();
hidePlacePage();
Framework.deactivatePopup();
popFragment();
@ -410,7 +412,7 @@ public class MWMActivity extends MWMFragmentActivity
(mVerticalToolbar.getVisibility() != View.VISIBLE && !showVerticalToolbar))
return;
hideInfoView();
hidePlacePage();
Framework.deactivatePopup();
popFragment();
@ -522,7 +524,7 @@ public class MWMActivity extends MWMFragmentActivity
return;
setVerticalToolbarVisible(false);
popFragment();
hideInfoView();
hidePlacePage();
SearchController.getInstance().cancel();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
@ -644,8 +646,9 @@ public class MWMActivity extends MWMFragmentActivity
});
}
findViewById(R.id.map_button_plus).setOnClickListener(this);
findViewById(R.id.map_button_minus).setOnClickListener(this);
mNavigationButtons = findViewById(R.id.navigation_buttons_container_ref);
mNavigationButtons.findViewById(R.id.map_button_plus).setOnClickListener(this);
mNavigationButtons.findViewById(R.id.map_button_minus).setOnClickListener(this);
}
private void setupPlacePage()
@ -1113,7 +1116,7 @@ public class MWMActivity extends MWMFragmentActivity
{
if (mPlacePage.getState() != State.HIDDEN)
{
hideInfoView();
hidePlacePage();
Framework.deactivatePopup();
}
else if (mVerticalToolbar.getVisibility() == View.VISIBLE)
@ -1308,7 +1311,7 @@ public class MWMActivity extends MWMFragmentActivity
});
}
private void hideInfoView()
private void hidePlacePage()
{
mPlacePage.setState(State.HIDDEN);
mPlacePage.setMapObject(null);
@ -1324,7 +1327,7 @@ public class MWMActivity extends MWMFragmentActivity
@Override
public void run()
{
hideInfoView();
hidePlacePage();
Framework.deactivatePopup();
}
});
@ -1335,12 +1338,33 @@ public class MWMActivity extends MWMFragmentActivity
public void onPreviewVisibilityChanged(boolean isVisible)
{
setVerticalToolbarVisible(false);
if (!isVisible)
{
Framework.deactivatePopup();
hidePlacePage();
}
if (previewIntersectsBottomMenu())
mBottomToolbar.setVisibility(isVisible ? View.GONE : View.VISIBLE);
}
private boolean previewIntersectsBottomMenu()
{
return !(getResources().getBoolean(R.bool.isBigTablet) ||
(getResources().getBoolean(R.bool.isTablet) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE));
}
@Override
public void onPlacePageVisibilityChanged(boolean isVisible)
{
setVerticalToolbarVisible(false);
if (placePageIntersectsZoomButtons())
mNavigationButtons.setVisibility(isVisible ? View.GONE : View.VISIBLE);
}
private boolean placePageIntersectsZoomButtons()
{
return !(getResources().getBoolean(R.bool.isBigTablet) ||
(getResources().getBoolean(R.bool.isTablet) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE));
}
@Override
@ -1490,7 +1514,7 @@ public class MWMActivity extends MWMFragmentActivity
if (mPlacePage.getState() == State.DETAILS || mPlacePage.getState() == State.BOOKMARK)
{
Framework.deactivatePopup();
hideInfoView();
hidePlacePage();
result = true;
}
result |= mMapFragment.onTouch(view, event);
@ -1549,7 +1573,7 @@ public class MWMActivity extends MWMFragmentActivity
mRlRoutingBox.setVisibility(View.VISIBLE);
mRlRoutingBox.bringToFront();
hideInfoView();
hidePlacePage();
Framework.deactivatePopup();
updateRoutingDistance();
}

View file

@ -86,4 +86,13 @@ public abstract class BasePlacePageAnimationController
{
return mGestureDetector.onTouchEvent(event);
}
protected void notifyVisibilityListener()
{
if (mVisibilityChangedListener != null)
{
mVisibilityChangedListener.onPreviewVisibilityChanged(mIsPreviewVisible);
mVisibilityChangedListener.onPlacePageVisibilityChanged(mIsPlacePageVisible);
}
}
}

View file

@ -6,6 +6,8 @@ import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.widget.placepage.PlacePageView.State;
@ -127,9 +129,11 @@ public class BottomPlacePageAnimationController extends BasePlacePageAnimationCo
mPreview.setVisibility(View.VISIBLE);
ValueAnimator animator;
Interpolator interpolator;
if (currentState == State.HIDDEN)
{
mDetails.setVisibility(View.INVISIBLE);
interpolator = new OvershootInterpolator();
animator = ValueAnimator.ofFloat(mPreview.getHeight() + mButtons.getHeight(), 0f);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
{
@ -138,12 +142,20 @@ public class BottomPlacePageAnimationController extends BasePlacePageAnimationCo
{
ViewHelper.setTranslationY(mPreview, (Float) animation.getAnimatedValue());
ViewHelper.setTranslationY(mButtons, (Float) animation.getAnimatedValue());
if (animation.getAnimatedFraction() > .99f)
{
mIsPlacePageVisible = false;
mIsPreviewVisible = true;
notifyVisibilityListener();
}
}
});
}
else
{
final float detailsHeight = mDetails.getHeight();
interpolator = new AccelerateInterpolator();
animator = ValueAnimator.ofFloat(ViewHelper.getTranslationY(mPreview), 0f);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
{
@ -154,12 +166,17 @@ public class BottomPlacePageAnimationController extends BasePlacePageAnimationCo
ViewHelper.setTranslationY(mDetails, (Float) animation.getAnimatedValue() + detailsHeight);
if (animation.getAnimatedFraction() > .99f)
{
mDetails.setVisibility(View.INVISIBLE);
mIsPlacePageVisible = false;
mIsPreviewVisible = true;
notifyVisibilityListener();
}
}
});
}
animator.setDuration(SHORT_ANIM_DURATION);
animator.setInterpolator(new AccelerateInterpolator());
animator.setInterpolator(interpolator);
animator.start();
}
@ -176,6 +193,7 @@ public class BottomPlacePageAnimationController extends BasePlacePageAnimationCo
animator = ValueAnimator.ofFloat(detailsHeight, bookmarkHeight);
else
animator = ValueAnimator.ofFloat(0f, bookmarkHeight);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
{
@Override
@ -183,6 +201,12 @@ public class BottomPlacePageAnimationController extends BasePlacePageAnimationCo
{
ViewHelper.setTranslationY(mPreview, (Float) animation.getAnimatedValue() - detailsHeight);
ViewHelper.setTranslationY(mDetails, (Float) animation.getAnimatedValue());
if (animation.getAnimatedFraction() > .99f)
{
mIsPreviewVisible = mIsPlacePageVisible = true;
notifyVisibilityListener();
}
}
});
@ -213,6 +237,12 @@ public class BottomPlacePageAnimationController extends BasePlacePageAnimationCo
{
ViewHelper.setTranslationY(mPreview, (Float) animation.getAnimatedValue() - detailsHeight);
ViewHelper.setTranslationY(mDetails, (Float) animation.getAnimatedValue());
if (animation.getAnimatedFraction() > .99f)
{
mIsPreviewVisible = mIsPlacePageVisible = true;
notifyVisibilityListener();
}
}
});
@ -234,16 +264,11 @@ public class BottomPlacePageAnimationController extends BasePlacePageAnimationCo
if (animation.getAnimatedFraction() > .99f)
{
mIsPlacePageVisible = false;
mIsPreviewVisible = false;
mIsPreviewVisible = mIsPlacePageVisible = false;
mPlacePage.setVisibility(View.INVISIBLE);
ViewHelper.setTranslationY(mPlacePage, 0);
if (mVisibilityChangedListener != null)
{
mVisibilityChangedListener.onPreviewVisibilityChanged(false);
mVisibilityChangedListener.onPlacePageVisibilityChanged(false);
}
notifyVisibilityListener();
}
}
});

View file

@ -114,6 +114,12 @@ public class LeftFloatPlacePageAnimationController extends BasePlacePageAnimatio
public void onAnimationUpdate(ValueAnimator animation)
{
ViewHelper.setTranslationY(mPlacePage, (Float) animation.getAnimatedValue());
if (animation.getAnimatedFraction() > 0.99f)
{
mIsPlacePageVisible = mIsPreviewVisible = true;
notifyVisibilityListener();
}
}
});
@ -121,8 +127,6 @@ public class LeftFloatPlacePageAnimationController extends BasePlacePageAnimatio
animator.setInterpolator(new AccelerateInterpolator());
animator.start();
}
mVisibilityChangedListener.onPlacePageVisibilityChanged(true);
mVisibilityChangedListener.onPreviewVisibilityChanged(true);
}
protected void hidePlacePage()
@ -139,8 +143,8 @@ public class LeftFloatPlacePageAnimationController extends BasePlacePageAnimatio
if (animation.getAnimatedFraction() > 0.99f)
{
mPlacePage.setVisibility(View.INVISIBLE);
mVisibilityChangedListener.onPlacePageVisibilityChanged(false);
mVisibilityChangedListener.onPreviewVisibilityChanged(false);
mIsPlacePageVisible = mIsPreviewVisible = false;
notifyVisibilityListener();
}
}
});

View file

@ -111,6 +111,12 @@ public class LeftFullPlacePageAnimationController extends BasePlacePageAnimation
public void onAnimationUpdate(ValueAnimator animation)
{
ViewHelper.setTranslationX(mPlacePage, (Float) animation.getAnimatedValue());
if (animation.getAnimatedFraction() > .99f)
{
mIsPlacePageVisible = mIsPreviewVisible = true;
notifyVisibilityListener();
}
}
});
@ -118,8 +124,6 @@ public class LeftFullPlacePageAnimationController extends BasePlacePageAnimation
animator.setInterpolator(new AccelerateInterpolator());
animator.start();
}
mVisibilityChangedListener.onPlacePageVisibilityChanged(true);
mVisibilityChangedListener.onPreviewVisibilityChanged(true);
}
protected void hidePlacePage()
@ -136,8 +140,8 @@ public class LeftFullPlacePageAnimationController extends BasePlacePageAnimation
if (animation.getAnimatedFraction() > 0.99f)
{
mPlacePage.setVisibility(View.INVISIBLE);
mVisibilityChangedListener.onPlacePageVisibilityChanged(false);
mVisibilityChangedListener.onPreviewVisibilityChanged(false);
mIsPlacePageVisible = mIsPreviewVisible = false;
notifyVisibilityListener();
}
}
});

View file

@ -13,7 +13,6 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
@ -231,7 +230,6 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
{
if (!hasMapObject(mo))
{
Log.d("TEST", "Set map object : " + mo);
mMapObject = mo;
refreshViews();
}