forked from organicmaps/organicmaps
Fixes for 2.3 devices(used simple layout without any animations).
This commit is contained in:
parent
f62bde0057
commit
9f39b6132f
6 changed files with 85 additions and 209 deletions
44
android/res/layout-v11/place_page.xml
Normal file
44
android/res/layout-v11/place_page.xml
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<include
|
||||
android:id="@+id/pp__preview"
|
||||
layout="@layout/place_page_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/pp__buttons"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/pp__details"
|
||||
layout="@layout/place_page_details"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/pp__buttons"
|
||||
android:layout_marginTop="56dp"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/view_bottom_white"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/place_page_buttons_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@color/bg_top_panels"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/pp__buttons"
|
||||
layout="@layout/place_page_buttons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"/>
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/base_green"
|
||||
android:visibility="gone"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||
app:theme="@style/MwmToolbar"/>
|
||||
|
||||
</merge>
|
|
@ -1,29 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<include
|
||||
android:id="@+id/pp__preview"
|
||||
layout="@layout/place_page_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/pp__buttons"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/pp__details"
|
||||
layout="@layout/place_page_details"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/pp__buttons"
|
||||
android:layout_marginTop="56dp"/>
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:id="@+id/view_bottom_white"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/place_page_buttons_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@color/bg_top_panels"
|
||||
android:visibility="gone"/>
|
||||
<include
|
||||
android:id="@+id/pp__preview"
|
||||
layout="@layout/place_page_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/pp__details"
|
||||
layout="@layout/place_page_details"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include
|
||||
android:id="@+id/pp__buttons"
|
||||
|
@ -32,13 +26,4 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"/>
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/base_green"
|
||||
android:visibility="gone"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||
app:theme="@style/MwmToolbar"/>
|
||||
|
||||
</merge>
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bg_top_panels"
|
||||
android:overScrollMode="never">
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
android:id="@+id/rl__place_details"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/bg_top_panels"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/margin_medium_and_half"
|
||||
android:paddingRight="@dimen/margin_medium_and_half"
|
||||
|
|
|
@ -1296,10 +1296,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
{
|
||||
setVerticalToolbarVisible(false);
|
||||
if (!isVisible)
|
||||
{
|
||||
Framework.deactivatePopup();
|
||||
hidePlacePage();
|
||||
}
|
||||
if (previewIntersectsBottomMenu())
|
||||
mBottomToolbar.setVisibility(isVisible ? View.GONE : View.VISIBLE);
|
||||
if (previewIntersectsZoomButtons())
|
||||
|
|
|
@ -2,43 +2,20 @@ package com.mapswithme.maps.widget.placepage;
|
|||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.view.GestureDetectorCompat;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.widget.placepage.PlacePageView.State;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.nineoldandroids.animation.ValueAnimator;
|
||||
import com.nineoldandroids.view.ViewHelper;
|
||||
|
||||
// TODO remove this class after minSdk will be 11+
|
||||
public class CompatPlacePageAnimationController extends BasePlacePageAnimationController
|
||||
{
|
||||
private final Toolbar mToolbar;
|
||||
|
||||
public CompatPlacePageAnimationController(@NonNull PlacePageView placePage)
|
||||
{
|
||||
super(placePage);
|
||||
mToolbar = (Toolbar) mPlacePage.findViewById(R.id.toolbar);
|
||||
if (mToolbar != null)
|
||||
{
|
||||
UiUtils.showHomeUpButton(mToolbar);
|
||||
mToolbar.setNavigationOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
mPlacePage.setState(State.HIDDEN);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,14 +25,13 @@ public class CompatPlacePageAnimationController extends BasePlacePageAnimationCo
|
|||
{
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
mIsGestureHandled = false;
|
||||
mDownCoord = event.getY();
|
||||
mDownCoord = event.getY() - ((ViewGroup) mPreview.getParent()).getTop();
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
final float yDiff = mDownCoord - event.getY();
|
||||
final float buttonsY = ViewHelper.getY(mButtons);
|
||||
if (mDownCoord < ViewHelper.getY(mPreview) || mDownCoord > buttonsY ||
|
||||
(mDownCoord > ViewHelper.getY(mDetails) && mDownCoord < buttonsY &&
|
||||
(mDetails.getHeight() != mDetails.getChildAt(0).getHeight() && (mDetails.getScrollY() != 0 || yDiff > 0))))
|
||||
final float buttonsY = mButtons.getTop();
|
||||
if (mDownCoord < mPreview.getTop() || mDownCoord > buttonsY ||
|
||||
(mDownCoord > mDetails.getTop() && mDownCoord < buttonsY))
|
||||
return false;
|
||||
if (Math.abs(yDiff) > mTouchSlop)
|
||||
return true;
|
||||
|
@ -68,7 +44,7 @@ public class CompatPlacePageAnimationController extends BasePlacePageAnimationCo
|
|||
@Override
|
||||
protected boolean onTouchEvent(@NonNull MotionEvent event)
|
||||
{
|
||||
if (mDownCoord < ViewHelper.getY(mPreview) || mDownCoord > ViewHelper.getY(mButtons))
|
||||
if (mDownCoord < mPreview.getTop() || mDownCoord > mButtons.getTop())
|
||||
return false;
|
||||
|
||||
super.onTouchEvent(event);
|
||||
|
@ -115,7 +91,7 @@ public class CompatPlacePageAnimationController extends BasePlacePageAnimationCo
|
|||
@Override
|
||||
public boolean onSingleTapConfirmed(MotionEvent e)
|
||||
{
|
||||
if (mDownCoord < ViewHelper.getY(mPreview) && mDownCoord < ViewHelper.getY(mDetails))
|
||||
if (mDownCoord < mPreview.getTop() && mDownCoord < mDetails.getTop())
|
||||
return false;
|
||||
|
||||
if (mPlacePage.getState() == State.PREVIEW)
|
||||
|
@ -137,181 +113,56 @@ public class CompatPlacePageAnimationController extends BasePlacePageAnimationCo
|
|||
hidePlacePage();
|
||||
break;
|
||||
case PREVIEW:
|
||||
showPreview(currentState);
|
||||
showPreview();
|
||||
break;
|
||||
case BOOKMARK:
|
||||
showBookmark(currentState);
|
||||
showBookmark();
|
||||
break;
|
||||
case DETAILS:
|
||||
showDetails(currentState);
|
||||
showDetails();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void showPreview(final State currentState)
|
||||
protected void showPreview()
|
||||
{
|
||||
mPlacePage.setVisibility(View.VISIBLE);
|
||||
mPreview.setVisibility(View.VISIBLE);
|
||||
if (mToolbar != null)
|
||||
mToolbar.setVisibility(View.GONE);
|
||||
mDetails.setVisibility(View.GONE);
|
||||
|
||||
ValueAnimator animator;
|
||||
Interpolator interpolator;
|
||||
if (currentState == State.HIDDEN)
|
||||
{
|
||||
setMargin(mPreview, 0f);
|
||||
setMargin(mDetails, 0f);
|
||||
mDetails.setVisibility(View.GONE);
|
||||
interpolator = new AccelerateInterpolator();
|
||||
animator = ValueAnimator.ofFloat(mPreview.getHeight() + mButtons.getHeight(), 0f);
|
||||
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
|
||||
{
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation)
|
||||
{
|
||||
setMargin(mButtons, -((Float) animation.getAnimatedValue()));
|
||||
setMargin(mPreview, -((Float) animation.getAnimatedValue()));
|
||||
|
||||
if (isAnimationCompleted(animation))
|
||||
{
|
||||
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()
|
||||
{
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation)
|
||||
{
|
||||
setMargin(mPreview, -(Float) animation.getAnimatedValue());
|
||||
setMargin(mDetails, -(Float) animation.getAnimatedValue() - detailsHeight);
|
||||
|
||||
if (isAnimationCompleted(animation))
|
||||
{
|
||||
mDetails.setVisibility(View.GONE);
|
||||
mIsPlacePageVisible = false;
|
||||
mIsPreviewVisible = true;
|
||||
notifyVisibilityListener();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
animator.setDuration(SHORT_ANIM_DURATION);
|
||||
animator.setInterpolator(interpolator);
|
||||
animator.start();
|
||||
mIsPlacePageVisible = false;
|
||||
mIsPreviewVisible = true;
|
||||
notifyVisibilityListener();
|
||||
}
|
||||
|
||||
private void setMargin(ViewGroup view, Float margin)
|
||||
{
|
||||
final RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) view.getLayoutParams();
|
||||
params.bottomMargin = margin.intValue();
|
||||
view.setLayoutParams(params);
|
||||
}
|
||||
|
||||
protected void showDetails(final State currentState)
|
||||
protected void showDetails()
|
||||
{
|
||||
mPlacePage.setVisibility(View.VISIBLE);
|
||||
mPreview.setVisibility(View.VISIBLE);
|
||||
mDetails.setVisibility(View.VISIBLE);
|
||||
mBookmarkDetails.setVisibility(View.GONE);
|
||||
|
||||
ValueAnimator animator;
|
||||
final float bookmarkHeight = mBookmarkDetails.getHeight();
|
||||
final float detailsHeight = mDetails.getHeight();
|
||||
if (currentState == State.PREVIEW)
|
||||
animator = ValueAnimator.ofFloat(detailsHeight, bookmarkHeight);
|
||||
else
|
||||
animator = ValueAnimator.ofFloat(0f, bookmarkHeight);
|
||||
|
||||
animator.addUpdateListener(createDetailsUpdateListener(detailsHeight, animator));
|
||||
|
||||
animator.setDuration(SHORT_ANIM_DURATION);
|
||||
animator.setInterpolator(new AccelerateInterpolator());
|
||||
animator.start();
|
||||
mIsPreviewVisible = mIsPlacePageVisible = true;
|
||||
notifyVisibilityListener();
|
||||
}
|
||||
|
||||
private ValueAnimator.AnimatorUpdateListener createDetailsUpdateListener(final float detailsHeight, final ValueAnimator animator)
|
||||
{
|
||||
return new ValueAnimator.AnimatorUpdateListener()
|
||||
{
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation)
|
||||
{
|
||||
setMargin(mPreview, detailsHeight - (Float) animation.getAnimatedValue());
|
||||
setMargin(mDetails, -(Float) animation.getAnimatedValue());
|
||||
|
||||
if (isAnimationCompleted(animation))
|
||||
{
|
||||
refreshToolbarVisibility();
|
||||
mIsPreviewVisible = mIsPlacePageVisible = true;
|
||||
notifyVisibilityListener();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void showBookmark(final State currentState)
|
||||
void showBookmark()
|
||||
{
|
||||
mPlacePage.setVisibility(View.VISIBLE);
|
||||
mPreview.setVisibility(View.VISIBLE);
|
||||
mDetails.setVisibility(View.VISIBLE);
|
||||
mBookmarkDetails.setVisibility(View.VISIBLE);
|
||||
mButtons.setVisibility(View.VISIBLE);
|
||||
mButtons.bringToFront();
|
||||
|
||||
ValueAnimator animator;
|
||||
final float bookmarkHeight = mBookmarkDetails.getHeight();
|
||||
final float detailsHeight = mDetails.getHeight();
|
||||
if (currentState == State.DETAILS)
|
||||
animator = ValueAnimator.ofFloat(bookmarkHeight, 0f);
|
||||
else
|
||||
animator = ValueAnimator.ofFloat(detailsHeight, 0f);
|
||||
animator.addUpdateListener(createDetailsUpdateListener(detailsHeight, animator));
|
||||
|
||||
animator.setDuration(SHORT_ANIM_DURATION);
|
||||
animator.setInterpolator(new AccelerateInterpolator());
|
||||
animator.start();
|
||||
}
|
||||
|
||||
private void refreshToolbarVisibility()
|
||||
{
|
||||
if (mToolbar != null)
|
||||
mToolbar.setVisibility(ViewHelper.getY(mDetails) < mPreview.getHeight() ? View.VISIBLE : View.GONE);
|
||||
mIsPreviewVisible = mIsPlacePageVisible = true;
|
||||
notifyVisibilityListener();
|
||||
}
|
||||
|
||||
protected void hidePlacePage()
|
||||
{
|
||||
if (mToolbar != null)
|
||||
mToolbar.setVisibility(View.GONE);
|
||||
|
||||
final float animHeight = mPlacePage.getHeight() - mPreview.getTop() - ViewHelper.getTranslationY(mPreview);
|
||||
final ValueAnimator animator = ValueAnimator.ofFloat(0f, animHeight);
|
||||
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
|
||||
{
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation)
|
||||
{
|
||||
setMargin(mPlacePage, -(Float) animation.getAnimatedValue());
|
||||
|
||||
|
||||
if (isAnimationCompleted(animation))
|
||||
{
|
||||
mIsPreviewVisible = mIsPlacePageVisible = false;
|
||||
setMargin(mPlacePage, 0f);
|
||||
setMargin(mPreview, 0f);
|
||||
setMargin(mDetails, 0f);
|
||||
notifyVisibilityListener();
|
||||
mPlacePage.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
animator.setDuration(SHORT_ANIM_DURATION);
|
||||
animator.setInterpolator(new AccelerateInterpolator());
|
||||
animator.start();
|
||||
mPlacePage.setVisibility(View.GONE);
|
||||
mIsPreviewVisible = mIsPlacePageVisible = false;
|
||||
notifyVisibilityListener();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue