Landscape smartphones PP.

This commit is contained in:
Dmitry Yunitsky 2015-02-19 12:43:56 +03:00 committed by Alex Zolotarev
parent 021ddcc103
commit 0bd8679b73
11 changed files with 390 additions and 19 deletions

View file

@ -168,7 +168,6 @@
<activity
android:name="com.mapswithme.maps.MWMActivity"
android:configChanges="orientation|screenLayout|screenSize"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="behind"

View file

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:placePage="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom">
<android.view.SurfaceView
android:id="@+id/map_surfaceview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|center_horizontal"
android:background="@android:color/transparent"/>
<include
android:id="@+id/toolbar_search"
layout="@layout/toolbar_with_search"
android:layout_width="match_parent"
android:layout_height="@dimen/search_box_height"/>
<com.mapswithme.maps.widget.placepage.PlacePageView
android:id="@+id/info_box"
android:layout_width="450dp"
android:layout_height="match_parent"
placePage:animationType="leftFull"/>
<RelativeLayout
android:id="@+id/rl__routing_box"
android:layout_width="match_parent"
android:layout_height="@dimen/routing_pp_height"
android:layout_below="@id/toolbar_search"
android:background="@color/bg_top_panels">
<RelativeLayout
android:id="@+id/rl__routing_go"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/iv__routing_close">
<TextView
android:id="@+id/tv__routing_go"
android:layout_width="wrap_content"
android:layout_height="@dimen/routing_button_height"
android:layout_centerVertical="true"
android:background="?attr/clickableBackground"
android:gravity="bottom"
android:includeFontPadding="false"
android:paddingBottom="10dp"
android:paddingLeft="18dp"
android:paddingRight="18dp"
android:text="@string/routing_go"
android:textColor="@color/downloader_green"
android:textSize="18sp"/>
<View
android:layout_width="20dp"
android:layout_height="2dp"
android:layout_alignLeft="@id/tv__routing_go"
android:layout_alignParentBottom="true"
android:layout_alignRight="@id/tv__routing_go"
android:background="@color/downloader_green"/>
</RelativeLayout>
<ImageView
android:id="@+id/iv__routing_close"
android:layout_width="@dimen/routing_button_width"
android:layout_height="@dimen/routing_button_height"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="?attr/clickableBackground"
android:padding="@dimen/margin_medium"
android:scaleType="center"
android:src="@drawable/ic_close_routing"/>
<TextView
android:id="@+id/tv__routing_distance"
style="@style/TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="@dimen/routing_button_height"
android:layout_centerVertical="true"
android:gravity="bottom"
android:includeFontPadding="false"
android:paddingBottom="1dp"
android:paddingLeft="10dp"
android:paddingRight="9dp"/>
</RelativeLayout>
<include
android:id="@+id/layout__turn_instructions"
layout="@layout/map_turn_instructions"
android:layout_width="match_parent"
android:layout_height="@dimen/routing_pp_height"
android:layout_below="@+id/toolbar_search"
android:visibility="gone"/>
<include
android:id="@+id/navigation_buttons_container_ref"
layout="@layout/map_navigation_buttons"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="@id/rl__routing_box"/>
<ImageView
android:id="@+id/fade_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@android:color/black"
android:visibility="gone"/>
<include
android:id="@+id/map_bottom_toolbar"
layout="@layout/map_bottom_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_panel_height"
android:layout_alignParentBottom="true"/>
<include
android:id="@+id/map_bottom_vertical_toolbar"
layout="@layout/map_bottom_vertical_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/white">
<include
android:id="@+id/pp__preview"
layout="@layout/preview_place_page"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_place_page_back"/>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_below="@+id/pp__preview"
android:background="?android:attr/listDivider"/>
<include
android:id="@+id/pp__details"
layout="@layout/details_place_page"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/pp__preview"
android:layout_marginBottom="56dp"
android:layout_marginTop="1px"
android:visibility="visible"/>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_below="@id/pp__details"
android:background="?android:attr/listDivider"/>
<include
android:id="@+id/pp__buttons"
layout="@layout/buttons_place_page"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>

View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="56dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingBottom="@dimen/margin_small_and_half"
android:paddingLeft="@dimen/margin_medium"
android:paddingRight="@dimen/margin_medium"
android:paddingTop="@dimen/margin_medium_and_half">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="@+id/tv__title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TEST TITLE"
android:textColor="@color/text_place_page"
android:textSize="@dimen/place_page_title"/>
<TextView
android:id="@+id/tv__subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv__title"
android:text="TEST subtitle"
android:textColor="@color/text_place_page_subtitle"
android:textSize="@dimen/place_page_subtitle"/>
<TextView
android:id="@+id/tv__opened_till"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv__subtitle"
android:drawableLeft="@drawable/ic_open"
android:gravity="center_vertical"
android:text="TEST schedule"
android:textColor="@color/text_place_page_subtitle"
android:textSize="@dimen/place_page_subtitle"/>
</RelativeLayout>
<TextView
android:id="@+id/tv__straight_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_small"
android:text="TEST"
android:textSize="@dimen/place_page_subtitle"/>
<ImageButton
android:id="@+id/iv__direction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/clickableBackground"
android:contentDescription="direction"
android:src="@drawable/ic_direction_pagepreview"/>
</LinearLayout>

View file

@ -20,6 +20,8 @@
android:id="@+id/tv__title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:text="TEST TITLE"
android:textColor="@color/text_place_page"
android:textSize="@dimen/place_page_title"/>

View file

@ -12,7 +12,7 @@
<enum name="bottom" value="0"/>
<enum name="top" value="1"/>
<enum name="leftTop" value="2"/>
<enum name="leftSide" value="3"/>
<enum name="leftFull" value="3"/>
</attr>
</declare-styleable>

View file

@ -23,7 +23,7 @@ public abstract class BasePlacePageAnimationController
// Gestures
protected GestureDetectorCompat mGestureDetector;
protected boolean mIsGestureHandled;
protected float mDownY;
protected float mDownCoord;
protected float mTouchSlop;
// Visibility
protected boolean mIsPreviewVisible;

View file

@ -18,27 +18,21 @@ public class BottomPlacePageAnimationController extends BasePlacePageAnimationCo
public BottomPlacePageAnimationController(@NonNull PlacePageView placePage)
{
super(placePage);
mPreview.bringToFront();
mDetails.requestDisallowInterceptTouchEvent(true);
mButtons.bringToFront();
mButtons.requestDisallowInterceptTouchEvent(true);
}
@Override
boolean onInterceptTouchEvent(MotionEvent event)
{
Log.d("TEST", "Intercept! Ev " + event);
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
mIsGestureHandled = false;
mDownY = event.getRawY();
mDownCoord = event.getRawY();
break;
case MotionEvent.ACTION_MOVE:
Log.d("TEST", "Intercept! DownY " + mDownY + "; preview Y " + mPreview.getY() + "; buttons Y " + mButtons.getY());
if (mDownY < mPreview.getY() || mDownY > mButtons.getY())
if (mDownCoord < mPreview.getY() || mDownCoord > mButtons.getY())
return false;
if (Math.abs(mDownY - event.getRawY()) > mTouchSlop)
if (Math.abs(mDownCoord - event.getRawY()) > mTouchSlop)
return true;
break;
}
@ -46,6 +40,16 @@ public class BottomPlacePageAnimationController extends BasePlacePageAnimationCo
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()
{
@ -91,8 +95,7 @@ public class BottomPlacePageAnimationController extends BasePlacePageAnimationCo
@Override
public boolean onSingleTapConfirmed(MotionEvent e)
{
Log.d("TEST", "Detector, tap confirmed. Y " + mDownY + "; preview Y " + mPreview.getY() + "; details Y " + mDetails.getY());
if (mDownY < mPreview.getY() && mDownY < mDetails.getY())
if (mDownCoord < mPreview.getY() && mDownCoord < mDetails.getY())
return false;
if (mPlacePage.getState() == State.FULL_PLACEPAGE)
@ -105,6 +108,7 @@ public class BottomPlacePageAnimationController extends BasePlacePageAnimationCo
});
}
@Override
protected void showPreview(final boolean show)
{
mPlacePage.setVisibility(View.VISIBLE);
@ -139,6 +143,7 @@ public class BottomPlacePageAnimationController extends BasePlacePageAnimationCo
mIsPreviewVisible = show;
}
@Override
protected void showPlacePage(final boolean show)
{
mPlacePage.setVisibility(View.VISIBLE);
@ -172,6 +177,7 @@ public class BottomPlacePageAnimationController extends BasePlacePageAnimationCo
mIsPlacePageVisible = show;
}
@Override
protected void hidePlacePage()
{
final TranslateAnimation slideDown = UiUtils.generateRelativeSlideAnimation(0, 0, 0, 1);

View file

@ -0,0 +1,130 @@
package com.mapswithme.maps.widget.placepage;
import android.support.annotation.NonNull;
import android.support.v4.view.GestureDetectorCompat;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import com.mapswithme.maps.widget.placepage.PlacePageView.State;
import com.mapswithme.util.UiUtils;
public class LeftFullAnimationController extends BasePlacePageAnimationController
{
public LeftFullAnimationController(@NonNull PlacePageView placePage)
{
super(placePage);
}
@Override
boolean onInterceptTouchEvent(MotionEvent event)
{
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
mIsGestureHandled = false;
mDownCoord = event.getRawX();
break;
case MotionEvent.ACTION_MOVE:
if (mDownCoord > mPlacePage.getRight())
return false;
if (Math.abs(mDownCoord - event.getRawX()) > mTouchSlop)
return true;
break;
}
return false;
}
@Override
protected boolean onTouchEvent(@NonNull MotionEvent event)
{
if (mDownCoord > mPlacePage.getRight())
return false;
super.onTouchEvent(event);
return true;
}
@Override
protected void initGestureDetector()
{
mGestureDetector = new GestureDetectorCompat(mPlacePage.getContext(), new GestureDetector.SimpleOnGestureListener()
{
private static final int X_MIN = 1;
private static final int X_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 isHorizontal = Math.abs(distanceX) > X_TO_Y_SCROLL_RATIO * Math.abs(distanceY);
final boolean isInRange = Math.abs(distanceX) > X_MIN && Math.abs(distanceX) < X_MAX;
if (isHorizontal && isInRange)
{
if (!mIsGestureHandled)
{
if (distanceX > 0)
mPlacePage.setState(State.HIDDEN);
mIsGestureHandled = true;
}
return true;
}
return false;
}
});
}
@Override
protected void showPreview(final boolean show)
{
showPlacePage(show);
}
@Override
protected void showPlacePage(final boolean show)
{
if (mIsPlacePageVisible == show)
return;
TranslateAnimation slide;
if (show)
{
slide = UiUtils.generateRelativeSlideAnimation(-1, 0, 0, 0);
}
else
{
slide = UiUtils.generateRelativeSlideAnimation(0, -1, 0, 0);
slide.setAnimationListener(new UiUtils.SimpleAnimationListener()
{
@Override
public void onAnimationEnd(Animation animation)
{
mIsPlacePageVisible = false;
mIsPreviewVisible = false;
mPlacePage.setVisibility(View.GONE);
}
});
}
slide.setDuration(LONG_ANIM_DURATION);
mPlacePage.startAnimation(slide);
mPlacePage.setVisibility(View.VISIBLE);
if (mVisibilityChangedListener != null)
{
mVisibilityChangedListener.onPlacePageVisibilityChanged(true);
mIsPlacePageVisible = true;
}
}
@Override
protected void hidePlacePage()
{
showPlacePage(false);
}
}

View file

@ -180,7 +180,6 @@ public class PlacePageView extends LinearLayout implements View.OnClickListener,
mAnimationController = new BottomPlacePageAnimationController(this);
break;
case 1:
// FIXME
mAnimationController = new TopPlacePageAnimationController(this);
break;
case 2:
@ -188,8 +187,7 @@ public class PlacePageView extends LinearLayout implements View.OnClickListener,
mAnimationController = new TopPlacePageAnimationController(this);
break;
case 3:
// FIXME
mAnimationController = new TopPlacePageAnimationController(this);
mAnimationController = new LeftFullAnimationController(this);
break;
}
}

View file

@ -25,10 +25,10 @@ public class TopPlacePageAnimationController extends BasePlacePageAnimationContr
{
case MotionEvent.ACTION_DOWN:
mIsGestureHandled = false;
mDownY = event.getRawY();
mDownCoord = event.getRawY();
break;
case MotionEvent.ACTION_MOVE:
if (Math.abs(mDownY - event.getRawY()) > mTouchSlop)
if (Math.abs(mDownCoord - event.getRawY()) > mTouchSlop)
return true;
break;
}
@ -91,6 +91,7 @@ public class TopPlacePageAnimationController extends BasePlacePageAnimationContr
});
}
@Override
protected void showPlacePage(final boolean show)
{
if (mIsPlacePageVisible == show)
@ -129,6 +130,7 @@ public class TopPlacePageAnimationController extends BasePlacePageAnimationContr
mIsPlacePageVisible = show;
}
@Override
protected void showPreview(final boolean show)
{
if (mIsPreviewVisible == show)
@ -168,6 +170,7 @@ public class TopPlacePageAnimationController extends BasePlacePageAnimationContr
mIsPreviewVisible = show;
}
@Override
protected void hidePlacePage()
{
final TranslateAnimation slideDown = UiUtils.generateRelativeSlideAnimation(0, 0, 0, -1);