From 5ba5b45bd60fa9912e02d128ec00103fc5964dbf Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Tue, 13 Sep 2016 15:09:12 +0400 Subject: [PATCH 01/22] [android] facility types --- map/booking_api.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map/booking_api.cpp b/map/booking_api.cpp index 1e3aef6e73..95bad8fe36 100644 --- a/map/booking_api.cpp +++ b/map/booking_api.cpp @@ -90,7 +90,7 @@ void BookingApi::GetMinPrice(string const & hotelId, string const & currency, } catch (my::Json::Exception const & e) { - LOG(LERROR, (e.Msg())); +// LOG(LERROR, (e.Msg())); minPrice.clear(); priceCurrency.clear(); } From 0331f95ff6560fe320a663811628e75bd39d2cc1 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Thu, 22 Sep 2016 16:48:32 +0400 Subject: [PATCH 02/22] [android] changed behavior of the appearance of the object cards in bottom mode. --- .../BasePlacePageAnimationController.java | 7 ++ .../BottomPlacePageAnimationController.java | 90 +++++++++++++++---- .../maps/widget/placepage/PlacePageView.java | 3 +- 3 files changed, 83 insertions(+), 17 deletions(-) diff --git a/android/src/com/mapswithme/maps/widget/placepage/BasePlacePageAnimationController.java b/android/src/com/mapswithme/maps/widget/placepage/BasePlacePageAnimationController.java index c795ae4724..37b97b1f9c 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/BasePlacePageAnimationController.java +++ b/android/src/com/mapswithme/maps/widget/placepage/BasePlacePageAnimationController.java @@ -23,6 +23,7 @@ import com.mapswithme.util.UiUtils; */ public abstract class BasePlacePageAnimationController { + private static final float DETAIL_RATIO = 0.7f; protected static final int DURATION = MwmApplication.get().getResources().getInteger(R.integer.anim_placepage); protected static final TimeInterpolator INTERPOLATOR = new AccelerateInterpolator(); protected State mState = State.HIDDEN; @@ -40,6 +41,9 @@ public abstract class BasePlacePageAnimationController protected float mDownCoord; protected float mTouchSlop; + protected float mScreenHeight; + protected float mDetailMaxHeight; + protected OnVisibilityChangedListener mVisibilityListener; public interface OnVisibilityChangedListener @@ -80,6 +84,9 @@ public abstract class BasePlacePageAnimationController mDetailsFrame.setLayoutParams(lp); } + mScreenHeight = placePage.getResources().getDisplayMetrics().heightPixels; + mDetailMaxHeight = mScreenHeight * DETAIL_RATIO; + initialVisibility(); } diff --git a/android/src/com/mapswithme/maps/widget/placepage/BottomPlacePageAnimationController.java b/android/src/com/mapswithme/maps/widget/placepage/BottomPlacePageAnimationController.java index db102ccaf3..125c2f0ffb 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/BottomPlacePageAnimationController.java +++ b/android/src/com/mapswithme/maps/widget/placepage/BottomPlacePageAnimationController.java @@ -39,7 +39,8 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { - if (mState == State.DETAILS && v.getId() == mDetailsFrame.getId() && top != oldTop) + if ((mState == State.DETAILS || mState == State.FULLSCREEN) + && v.getId() == mDetailsFrame.getId() && top != oldTop) { mPreview.setTranslationY(-mDetailsContent.getHeight()); refreshToolbarVisibility(); @@ -121,7 +122,8 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle private boolean isDetailsScrollable() { - return mDetailsFrame.getHeight() < mDetailsContent.getHeight(); + return mPlacePage.getState() == State.FULLSCREEN + && mDetailsFrame.getHeight() < mDetailsContent.getHeight(); } private boolean canScroll(float delta) @@ -175,7 +177,19 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - mPlacePage.setState(velocityY > 0 ? State.HIDDEN : State.DETAILS); + if (velocityY > 0) { + if (mPlacePage.getState() == State.HIDDEN) { + mPlacePage.setState(State.DETAILS); + } else if (mDetailsFrame.getHeight() < mDetailsContent.getHeight()) { + mPlacePage.setState(State.FULLSCREEN); + } + } else { + if (mPlacePage.getState() == State.FULLSCREEN) { + mPlacePage.setState(State.DETAILS); + } else { + mPlacePage.setState(State.HIDDEN); + } + } return super.onFling(e1, e2, velocityX, velocityY); } @@ -210,10 +224,21 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle @SuppressWarnings("UnnecessaryLocalVariable") final float deltaTop = currentTranslation; - final float deltaBottom = mDetailsContent.getHeight() - currentTranslation; + final float deltaBottom = mScreenHeight - currentTranslation; - mPlacePage.setState(deltaBottom > deltaTop ? State.DETAILS - : State.PREVIEW); + if (deltaBottom > deltaTop) { + if (mPlacePage.getState() == State.PREVIEW) { + mPlacePage.setState(State.DETAILS); + } else if (mDetailsFrame.getHeight() < mDetailsContent.getHeight()) { + mPlacePage.setState(State.FULLSCREEN); + } + } else { + if (mPlacePage.getState() == State.FULLSCREEN) { + mPlacePage.setState(State.DETAILS); + } else { + mPlacePage.setState(State.PREVIEW); + } + } } private void translateBy(float distanceY) @@ -253,6 +278,9 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle case DETAILS: showDetails(currentState); break; + case FULLSCREEN: + showFullscreen(currentState); + break; } } }); @@ -286,9 +314,12 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle } break; case DETAILS: - UiUtils.show(mPlacePage, mPreview, mDetailsFrame); + UiUtils.show(mPlacePage, mPreview, mDetailsFrame, mButtons); UiUtils.showIf(type == MapObject.BOOKMARK, mBookmarkDetails); break; + case FULLSCREEN: + UiUtils.invisible(mButtons); + break; } } @@ -344,25 +375,52 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle protected void showDetails(final State currentState) { + final float previewTranslation = mPreview.getHeight() + mButtons.getHeight(); final float detailsScreenHeight = mDetailsScroll.getHeight(); + final float targetTranslation = Math + .min(detailsScreenHeight, mDetailMaxHeight - previewTranslation); - mCurrentAnimator = ValueAnimator.ofFloat(mPreview.getTranslationY(), -detailsScreenHeight); - mCurrentAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() - { + mCurrentAnimator = ValueAnimator.ofFloat(mPreview.getTranslationY(), -targetTranslation); + mCurrentAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override - public void onAnimationUpdate(ValueAnimator animation) - { + public void onAnimationUpdate(ValueAnimator animation) { float translationY = (Float) animation.getAnimatedValue(); mPreview.setTranslationY(translationY); mDetailsFrame.setTranslationY(translationY + detailsScreenHeight); notifyProgress(); } }); - mCurrentAnimator.addListener(new UiUtils.SimpleAnimatorListener() - { + mCurrentAnimator.addListener(new UiUtils.SimpleAnimatorListener() { @Override - public void onAnimationEnd(Animator animation) - { + public void onAnimationEnd(Animator animation) { + refreshToolbarVisibility(); + notifyVisibilityListener(true, true); + mDetailsScroll.scrollTo(0, 0); + notifyProgress(); + } + }); + + startDefaultAnimator(); + } + + protected void showFullscreen(final State currentState) { + final float detailsScreenHeight = mDetailsScroll.getHeight(); + final float targetTranslation = mPreview.getTranslationY() + (mButtons.getHeight() + - mDetailsFrame.getY()); + + mCurrentAnimator = ValueAnimator.ofFloat(mPreview.getTranslationY(), targetTranslation); + mCurrentAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + float translationY = (Float) animation.getAnimatedValue(); + mPreview.setTranslationY(translationY); + mDetailsFrame.setTranslationY(translationY + detailsScreenHeight); + notifyProgress(); + } + }); + mCurrentAnimator.addListener(new UiUtils.SimpleAnimatorListener() { + @Override + public void onAnimationEnd(Animator animation) { refreshToolbarVisibility(); notifyVisibilityListener(true, true); mDetailsScroll.scrollTo(0, 0); diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 7a679cd25e..130ffcdb29 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -218,7 +218,8 @@ public class PlacePageView extends RelativeLayout { HIDDEN, PREVIEW, - DETAILS + DETAILS, + FULLSCREEN } public PlacePageView(Context context) From ca76c46aef970717398c77228d321ff04aee73a8 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Fri, 23 Sep 2016 09:01:17 +0400 Subject: [PATCH 03/22] [android] fix place page open state restore --- android/src/com/mapswithme/maps/MwmActivity.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 9313971013..2e5dc8be10 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -107,7 +107,7 @@ public class MwmActivity extends BaseMwmFragmentActivity EditorHostFragment.class.getName(), ReportFragment.class.getName() }; // Instance state - private static final String STATE_PP_OPENED = "PpOpened"; + private static final String STATE_PP = "PpState"; private static final String STATE_MAP_OBJECT = "MapObject"; // Map tasks that we run AFTER rendering initialized @@ -734,7 +734,7 @@ public class MwmActivity extends BaseMwmFragmentActivity { if (!mPlacePage.isHidden()) { - outState.putBoolean(STATE_PP_OPENED, true); + outState.putInt(STATE_PP, mPlacePage.getState().ordinal()); outState.putParcelable(STATE_MAP_OBJECT, mPlacePage.getMapObject()); } @@ -760,8 +760,7 @@ public class MwmActivity extends BaseMwmFragmentActivity { super.onRestoreInstanceState(savedInstanceState); - if (savedInstanceState.getBoolean(STATE_PP_OPENED)) - mPlacePage.setState(State.PREVIEW); + mPlacePage.setState(State.values()[savedInstanceState.getInt(STATE_PP, 0)]); if (!mIsFragmentContainer && RoutingController.get().isPlanning()) mRoutingPlanInplaceController.restoreState(savedInstanceState); @@ -1026,7 +1025,9 @@ public class MwmActivity extends BaseMwmFragmentActivity setFullscreen(false); mPlacePage.setMapObject(object, true); - mPlacePage.setState(State.PREVIEW); + if (mPlacePage.getState() == State.HIDDEN) { + mPlacePage.setState(State.PREVIEW); + } if (UiUtils.isVisible(mFadeView)) mFadeView.fadeOut(); From d2fbbf92f84cb0e0bb5ae995e2e75ced2cd11089 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Fri, 23 Sep 2016 10:06:49 +0400 Subject: [PATCH 04/22] [android] Fix place page open state for tablets. Refactoring --- .../BottomPlacePageAnimationController.java | 51 +++++++++++++++---- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/android/src/com/mapswithme/maps/widget/placepage/BottomPlacePageAnimationController.java b/android/src/com/mapswithme/maps/widget/placepage/BottomPlacePageAnimationController.java index 125c2f0ffb..e87e084354 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/BottomPlacePageAnimationController.java +++ b/android/src/com/mapswithme/maps/widget/placepage/BottomPlacePageAnimationController.java @@ -123,7 +123,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle private boolean isDetailsScrollable() { return mPlacePage.getState() == State.FULLSCREEN - && mDetailsFrame.getHeight() < mDetailsContent.getHeight(); + && isDetailContentScrollable(); } private boolean canScroll(float delta) @@ -180,7 +180,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle if (velocityY > 0) { if (mPlacePage.getState() == State.HIDDEN) { mPlacePage.setState(State.DETAILS); - } else if (mDetailsFrame.getHeight() < mDetailsContent.getHeight()) { + } else if (isDetailContentScrollable()) { mPlacePage.setState(State.FULLSCREEN); } } else { @@ -199,8 +199,15 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle if (!isInPreview(e.getY())) return false; - mPlacePage.setState(mPlacePage.getState() == State.PREVIEW ? State.DETAILS - : State.PREVIEW); + if (mPlacePage.getState() == State.PREVIEW) { + if (isDetailContentScrollable()) { + mPlacePage.setState(State.DETAILS); + } else { + mPlacePage.setState(State.FULLSCREEN); + } + } else { + mPlacePage.setState(State.PREVIEW); + } return true; } @@ -224,23 +231,40 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle @SuppressWarnings("UnnecessaryLocalVariable") final float deltaTop = currentTranslation; - final float deltaBottom = mScreenHeight - currentTranslation; + float deltaBottom = mScreenHeight - currentTranslation; + if(mDetailsFrame.getHeight() >= mDetailsContent.getHeight()) { + deltaBottom = mDetailsFrame.getHeight() - currentTranslation; + } if (deltaBottom > deltaTop) { if (mPlacePage.getState() == State.PREVIEW) { - mPlacePage.setState(State.DETAILS); - } else if (mDetailsFrame.getHeight() < mDetailsContent.getHeight()) { + if (isDetailContentScrollable()) { + mPlacePage.setState(State.DETAILS); + } else { + mPlacePage.setState(State.FULLSCREEN); + } + } else if (isDetailContentScrollable()) { mPlacePage.setState(State.FULLSCREEN); + } else if (mDetailsFrame.getTranslationY() > 0) { + mPlacePage.setState(State.DETAILS); } } else { if (mPlacePage.getState() == State.FULLSCREEN) { - mPlacePage.setState(State.DETAILS); + if (isDetailContentScrollable()) { + mPlacePage.setState(State.DETAILS); + } else { + mPlacePage.setState(State.PREVIEW); + } } else { mPlacePage.setState(State.PREVIEW); } } } + private boolean isDetailContentScrollable() { + return mDetailsFrame.getHeight() < mDetailsContent.getHeight(); + } + private void translateBy(float distanceY) { final float detailsHeight = mDetailsScroll.getHeight(); @@ -250,6 +274,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle { detailsTranslation = 0; previewTranslation = -detailsHeight; + mPlacePage.setState(State.FULLSCREEN); } mPreview.setTranslationY(previewTranslation); @@ -318,7 +343,9 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle UiUtils.showIf(type == MapObject.BOOKMARK, mBookmarkDetails); break; case FULLSCREEN: - UiUtils.invisible(mButtons); + if(isDetailContentScrollable()) { + UiUtils.invisible(mButtons); + } break; } } @@ -408,7 +435,11 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle final float targetTranslation = mPreview.getTranslationY() + (mButtons.getHeight() - mDetailsFrame.getY()); - mCurrentAnimator = ValueAnimator.ofFloat(mPreview.getTranslationY(), targetTranslation); + if(!isDetailContentScrollable()) { + mCurrentAnimator = ValueAnimator.ofFloat(mPreview.getTranslationY(), -detailsScreenHeight); + } else { + mCurrentAnimator = ValueAnimator.ofFloat(mPreview.getTranslationY(), targetTranslation); + } mCurrentAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { From 49787f4c93791e4ab9fc3d94a94e8808c4afa47d Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Tue, 27 Sep 2016 09:20:23 +0400 Subject: [PATCH 05/22] [android] Change place page open behavior. Change place page swipe detection. --- .../src/com/mapswithme/maps/MwmActivity.java | 4 +- .../BasePlacePageAnimationController.java | 7 -- .../BottomPlacePageAnimationController.java | 94 ++++++++++++++----- .../maps/widget/placepage/PlacePageView.java | 3 +- 4 files changed, 72 insertions(+), 36 deletions(-) diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 2e5dc8be10..52e7c11e67 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -1025,9 +1025,7 @@ public class MwmActivity extends BaseMwmFragmentActivity setFullscreen(false); mPlacePage.setMapObject(object, true); - if (mPlacePage.getState() == State.HIDDEN) { - mPlacePage.setState(State.PREVIEW); - } + mPlacePage.setState(State.PREVIEW); if (UiUtils.isVisible(mFadeView)) mFadeView.fadeOut(); diff --git a/android/src/com/mapswithme/maps/widget/placepage/BasePlacePageAnimationController.java b/android/src/com/mapswithme/maps/widget/placepage/BasePlacePageAnimationController.java index 37b97b1f9c..c795ae4724 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/BasePlacePageAnimationController.java +++ b/android/src/com/mapswithme/maps/widget/placepage/BasePlacePageAnimationController.java @@ -23,7 +23,6 @@ import com.mapswithme.util.UiUtils; */ public abstract class BasePlacePageAnimationController { - private static final float DETAIL_RATIO = 0.7f; protected static final int DURATION = MwmApplication.get().getResources().getInteger(R.integer.anim_placepage); protected static final TimeInterpolator INTERPOLATOR = new AccelerateInterpolator(); protected State mState = State.HIDDEN; @@ -41,9 +40,6 @@ public abstract class BasePlacePageAnimationController protected float mDownCoord; protected float mTouchSlop; - protected float mScreenHeight; - protected float mDetailMaxHeight; - protected OnVisibilityChangedListener mVisibilityListener; public interface OnVisibilityChangedListener @@ -84,9 +80,6 @@ public abstract class BasePlacePageAnimationController mDetailsFrame.setLayoutParams(lp); } - mScreenHeight = placePage.getResources().getDisplayMetrics().heightPixels; - mDetailMaxHeight = mScreenHeight * DETAIL_RATIO; - initialVisibility(); } diff --git a/android/src/com/mapswithme/maps/widget/placepage/BottomPlacePageAnimationController.java b/android/src/com/mapswithme/maps/widget/placepage/BottomPlacePageAnimationController.java index e87e084354..73be03d0a5 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/BottomPlacePageAnimationController.java +++ b/android/src/com/mapswithme/maps/widget/placepage/BottomPlacePageAnimationController.java @@ -24,6 +24,8 @@ import com.mapswithme.util.concurrency.UiThread; class BottomPlacePageAnimationController extends BasePlacePageAnimationController { private static final String TAG = BottomPlacePageAnimationController.class.getSimpleName(); + private static final float DETAIL_RATIO = 0.7f; + private static final float SWIPE_RATIO = 0.15f; private final ViewGroup mLayoutToolbar; private final AnimationHelper mAnimationHelper = new AnimationHelper(); @@ -32,6 +34,9 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle private boolean mIsGestureStartedInsideView; private boolean mIsGestureFinished; + private float mDetailMaxHeight; + private float mSwipeHeight; + private class AnimationHelper { final View.OnLayoutChangeListener mListener = new View.OnLayoutChangeListener() @@ -39,7 +44,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { - if ((mState == State.DETAILS || mState == State.FULLSCREEN) + if ((mState == State.DETAILS || mState == State.FULLSCREEN || mState == State.SCROLL) && v.getId() == mDetailsFrame.getId() && top != oldTop) { mPreview.setTranslationY(-mDetailsContent.getHeight()); @@ -69,6 +74,10 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle } }); } + + float screenHeight = placePage.getResources().getDisplayMetrics().heightPixels; + mDetailMaxHeight = screenHeight * DETAIL_RATIO; + mSwipeHeight = screenHeight * SWIPE_RATIO; } @Override @@ -122,7 +131,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle private boolean isDetailsScrollable() { - return mPlacePage.getState() == State.FULLSCREEN + return mPlacePage.getState() == State.SCROLL && isDetailContentScrollable(); } @@ -145,7 +154,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle finishedDrag) { mIsGestureFinished = true; - finishDrag(); + finishDrag(mDownCoord - event.getY()); return false; } @@ -168,7 +177,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle if (isVertical) { mIsDragging = true; - translateBy(-distanceY); + translateBy(-distanceY, e1.getY() - e2.getY()); } return true; @@ -220,7 +229,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle && y < (mPreview.getBottom() + mPreview.getTranslationY()); } - private void finishDrag() + private void finishDrag(float distance) { final float currentTranslation = mDetailsFrame.getTranslationY(); if (currentTranslation > mDetailsScroll.getHeight()) @@ -229,27 +238,34 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle return; } - @SuppressWarnings("UnnecessaryLocalVariable") - final float deltaTop = currentTranslation; - float deltaBottom = mScreenHeight - currentTranslation; - if(mDetailsFrame.getHeight() >= mDetailsContent.getHeight()) { - deltaBottom = mDetailsFrame.getHeight() - currentTranslation; + boolean isSwipe = Math.abs(distance) > mSwipeHeight; + if (!isDetailContentScrollable() + && Math.abs(distance) >= mDetailsFrame.getHeight() * SWIPE_RATIO) + { + isSwipe = true; } - if (deltaBottom > deltaTop) { + if (distance >= 0.0f && isSwipe) { if (mPlacePage.getState() == State.PREVIEW) { if (isDetailContentScrollable()) { mPlacePage.setState(State.DETAILS); } else { - mPlacePage.setState(State.FULLSCREEN); + mPlacePage.setState(State.SCROLL); } } else if (isDetailContentScrollable()) { - mPlacePage.setState(State.FULLSCREEN); + if (mPlacePage.getState() == State.FULLSCREEN) + { + mPlacePage.setState(State.SCROLL); + } else + { + mPlacePage.setState(State.FULLSCREEN); + } } else if (mDetailsFrame.getTranslationY() > 0) { mPlacePage.setState(State.DETAILS); } - } else { - if (mPlacePage.getState() == State.FULLSCREEN) { + } else if (isSwipe) { + if (mPlacePage.getState() == State.SCROLL + || mPlacePage.getState() == State.FULLSCREEN) { if (isDetailContentScrollable()) { mPlacePage.setState(State.DETAILS); } else { @@ -258,6 +274,8 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle } else { mPlacePage.setState(State.PREVIEW); } + } else { + mPlacePage.setState(mPlacePage.getState()); } } @@ -265,7 +283,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle return mDetailsFrame.getHeight() < mDetailsContent.getHeight(); } - private void translateBy(float distanceY) + private void translateBy(float distanceY, float distanceFromBegin) { final float detailsHeight = mDetailsScroll.getHeight(); float detailsTranslation = mDetailsFrame.getTranslationY() + distanceY; @@ -274,11 +292,14 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle { detailsTranslation = 0; previewTranslation = -detailsHeight; - mPlacePage.setState(State.FULLSCREEN); + mIsDragging = false; + mIsGestureFinished = true; + finishDrag(distanceFromBegin); } mPreview.setTranslationY(previewTranslation); mDetailsFrame.setTranslationY(detailsTranslation); + refreshToolbarVisibility(); } @Override @@ -306,6 +327,9 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle case FULLSCREEN: showFullscreen(currentState); break; + case SCROLL: + showScroll(currentState); + break; } } }); @@ -339,14 +363,9 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle } break; case DETAILS: - UiUtils.show(mPlacePage, mPreview, mDetailsFrame, mButtons); + UiUtils.show(mPlacePage, mPreview, mDetailsFrame); UiUtils.showIf(type == MapObject.BOOKMARK, mBookmarkDetails); break; - case FULLSCREEN: - if(isDetailContentScrollable()) { - UiUtils.invisible(mButtons); - } - break; } } @@ -432,8 +451,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle protected void showFullscreen(final State currentState) { final float detailsScreenHeight = mDetailsScroll.getHeight(); - final float targetTranslation = mPreview.getTranslationY() + (mButtons.getHeight() - - mDetailsFrame.getY()); + final float targetTranslation = -mPreview.getTop(); if(!isDetailContentScrollable()) { mCurrentAnimator = ValueAnimator.ofFloat(mPreview.getTranslationY(), -detailsScreenHeight); @@ -462,6 +480,32 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle startDefaultAnimator(); } + protected void showScroll(final State currentState) { + final float detailsScreenHeight = mDetailsScroll.getHeight(); + + mCurrentAnimator = ValueAnimator.ofFloat(mPreview.getTranslationY(), -detailsScreenHeight); + mCurrentAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + float translationY = (Float) animation.getAnimatedValue(); + mPreview.setTranslationY(translationY); + mDetailsFrame.setTranslationY(translationY + detailsScreenHeight); + notifyProgress(); + } + }); + mCurrentAnimator.addListener(new UiUtils.SimpleAnimatorListener() { + @Override + public void onAnimationEnd(Animator animation) { + refreshToolbarVisibility(); + notifyVisibilityListener(true, true); + mDetailsScroll.scrollTo(0, 0); + notifyProgress(); + } + }); + + startDefaultAnimator(); + } + @SuppressLint("NewApi") protected void hidePlacePage() { diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 130ffcdb29..2fcc5235af 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -219,7 +219,8 @@ public class PlacePageView extends RelativeLayout HIDDEN, PREVIEW, DETAILS, - FULLSCREEN + FULLSCREEN, + SCROLL } public PlacePageView(Context context) From 705cabf5c3a8e4c99f56492ee935c89383d9b6cb Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Tue, 27 Sep 2016 12:43:17 +0400 Subject: [PATCH 06/22] [android] Change place page toolbar icon. Refactoring. --- android/res/layout/toolbar_elevated.xml | 2 +- android/res/values/styles.xml | 8 ++ .../BottomPlacePageAnimationController.java | 129 +++++++----------- .../maps/widget/placepage/PlacePageView.java | 4 +- 4 files changed, 63 insertions(+), 80 deletions(-) diff --git a/android/res/layout/toolbar_elevated.xml b/android/res/layout/toolbar_elevated.xml index a1a47ad9ea..e86ba03c60 100644 --- a/android/res/layout/toolbar_elevated.xml +++ b/android/res/layout/toolbar_elevated.xml @@ -8,7 +8,7 @@ style="@style/MwmWidget.ToolbarStyle" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" - android:theme="@style/MwmWidget.ToolbarTheme"/> + android:theme="@style/MwmWidget.ToolbarTheme.DownButton"/> true + +