diff --git a/android/res/layout-sw600dp-land/map.xml b/android/res/layout-sw600dp-land/map.xml index 47878ae1d7..97d5d6d107 100644 --- a/android/res/layout-sw600dp-land/map.xml +++ b/android/res/layout-sw600dp-land/map.xml @@ -1,5 +1,6 @@ @@ -16,7 +17,8 @@ android:layout_width="@dimen/panel_width" android:layout_height="wrap_content" android:layout_below="@+id/toolbar_search" - android:layout_margin="@dimen/margin_medium"/> + android:layout_margin="@dimen/margin_medium" + placePage:animationType="leftTop"/> @@ -16,7 +17,8 @@ android:layout_width="@dimen/panel_width" android:layout_height="wrap_content" android:layout_below="@+id/toolbar_search" - android:layout_margin="@dimen/margin_medium"/> + android:layout_margin="@dimen/margin_medium" + placePage:animationType="leftTop"/> mButtons.getY()) + return false; + if (Math.abs(mDownCoord - event.getRawY()) > mTouchSlop) + return true; + break; + } + + return false; + } + + @Override + protected boolean onTouchEvent(@NonNull MotionEvent event) + { + if (mDownCoord < mPreview.getY() || mDownCoord > mButtons.getY()) + return false; + + super.onTouchEvent(event); + return true; + } + + @Override + protected void initGestureDetector() + { + mGestureDetector = new GestureDetectorCompat(mPlacePage.getContext(), new GestureDetector.SimpleOnGestureListener() + { + private static final int Y_MIN = 1; + private static final int Y_MAX = 100; + private static final int X_TO_Y_SCROLL_RATIO = 2; + + @Override + public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) + { + final boolean isVertical = Math.abs(distanceY) > X_TO_Y_SCROLL_RATIO * Math.abs(distanceX); + final boolean isInRange = Math.abs(distanceY) > Y_MIN && Math.abs(distanceY) < Y_MAX; + + if (isVertical && isInRange) + { + if (!mIsGestureHandled) + { + if (distanceY < 0) + { + mPlacePage.setState(State.HIDDEN); + Framework.deactivatePopup(); + } + + mIsGestureHandled = true; + } + + return true; + } + + return false; + } + }); + } + + @Override + protected void showPlacePage(final boolean show) + { + if (mIsPlacePageVisible == show) + return; // if state is already same as we need + + mPlacePage.setVisibility(View.VISIBLE); + ValueAnimator animator; + if (show) + { + animator = ValueAnimator.ofFloat(mPlacePage.getHeight(), 0f); + animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() + { + @Override + public void onAnimationUpdate(ValueAnimator animation) + { + ViewHelper.setTranslationY(mPlacePage, (Float) animation.getAnimatedValue()); + } + }); + } + else + { + animator = ValueAnimator.ofFloat(0, mPlacePage.getHeight()); + animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() + { + @Override + public void onAnimationUpdate(ValueAnimator animation) + { + ViewHelper.setTranslationY(mPlacePage, (Float) animation.getAnimatedValue()); + + if (1f - animation.getAnimatedFraction() < 0.01) + { + mPlacePage.setVisibility(View.INVISIBLE); + mPlacePage.setMapObject(null); + } + } + }); + } + animator.setDuration(LONG_ANIM_DURATION); + animator.setInterpolator(new AccelerateInterpolator()); + animator.start(); + + mIsPlacePageVisible = show; + if (mVisibilityChangedListener != null) + { + mVisibilityChangedListener.onPreviewVisibilityChanged(mIsPlacePageVisible); + mVisibilityChangedListener.onPlacePageVisibilityChanged(mIsPlacePageVisible); + } + } + + @Override + protected void showPreview(final boolean show) + { + showPlacePage(show); + } + + @Override + protected void hidePlacePage() + { + showPlacePage(false); + } +} diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 367bf56619..82c706ac33 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -174,6 +174,7 @@ public class PlacePageView extends LinearLayout implements View.OnClickListener, final TypedArray attrArray = getContext().obtainStyledAttributes(attrs, R.styleable.PlacePageView, defStyleAttr, 0); final int animationType = attrArray.getInt(R.styleable.PlacePageView_animationType, 0); attrArray.recycle(); + // switch with values from "animationType" from attrs.xml switch (animationType) { case 0: @@ -183,8 +184,7 @@ public class PlacePageView extends LinearLayout implements View.OnClickListener, mAnimationController = new TopPlacePageAnimationController(this); break; case 2: - // FIXME - mAnimationController = new TopPlacePageAnimationController(this); + mAnimationController = new LeftFloatPlacePageAnimationController(this); break; case 3: mAnimationController = new LeftFullAnimationController(this);