Use new layouts.

This commit is contained in:
Dmitry Yunitsky 2015-02-13 15:48:58 +03:00 committed by Alex Zolotarev
parent 8ef463e170
commit f22a7e46c6
11 changed files with 468 additions and 261 deletions

View file

@ -93,6 +93,13 @@
android:scaleType="center"
android:src="@drawable/ic_bookmark_off"/>
<ProgressBar
android:id="@+id/pb__routing_progress"
android:layout_width="@dimen/routing_progress_size"
android:layout_height="@dimen/routing_progress_size"
android:layout_centerInParent="true"
android:visibility="gone"/>
<TextView
android:id="@+id/tv__bookmark"
android:layout_width="wrap_content"

View file

@ -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="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="vertical">

View file

@ -1,5 +1,6 @@
<?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">
@ -21,7 +22,8 @@
android:id="@+id/info_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar_search"/>
android:layout_alignParentBottom="true"
placePage:animationType="bottom"/>
<RelativeLayout
android:id="@+id/rl__routing_box"

View file

@ -1,29 +1,40 @@
<?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="match_parent"
android:orientation="vertical">
<include android:id="@+id/pp__preview"
layout="@layout/preview_place_page"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<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:visibility="gone"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/pp__buttons"
android:visibility="visible"/>
<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"/>
<include
android:id="@+id/pp__preview"
layout="@layout/preview_place_page"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/pp__details"/>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_above="@id/pp__buttons"
android:background="?android:attr/listDivider"/>
<include android:id="@+id/pp__buttons"
layout="@layout/buttons_place_page"/>
</LinearLayout>
</RelativeLayout>

View file

@ -2,7 +2,7 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="56dp"
android:background="@drawable/bg_place_page_back"
android:gravity="center_vertical"
android:orientation="horizontal"

View file

@ -4,10 +4,18 @@
<attr name="progressColor" format="color"/>
<attr name="secondaryColor" format="color"/>
<attr name="wheelThickness" format="dimension"/>
<attr name="clickableBackground" format="reference"/>
</declare-styleable>
<declare-styleable name="PlacePageView">
<attr name="animationType" format="enum">
<enum name="bottom" value="0"/>
<enum name="top" value="1"/>
<enum name="leftTop" value="2"/>
<enum name="leftSide" value="3"/>
</attr>
</declare-styleable>
<bool name="isTablet">false</bool>
</resources>

View file

@ -113,9 +113,10 @@ public class MWMActivity extends NvEventQueueActivity
private StoragePathManager mPathManager = new StoragePathManager();
private AlertDialog mStorageDisconnectedDialog = null;
private ImageButton mLocationButton;
// Info box (place page).
private PlacePageView mInfoView;
private ImageView mIvStartRouting;
// Place page
private PlacePageView mPlacePage;
private View mIvStartRouting;
// Routing
private TextView mTvRoutingDistance;
private RelativeLayout mRlRoutingBox;
private RelativeLayout mLayoutRoutingGo;
@ -126,7 +127,6 @@ public class MWMActivity extends NvEventQueueActivity
private ImageView mIvTurn;
private TextView mTvTurnDistance;
private boolean mNeedCheckUpdate = true;
private boolean mRenderingInitialized = false;
private int mLocationStateModeListenerId = -1;
@ -719,7 +719,7 @@ public class MWMActivity extends NvEventQueueActivity
{
mLocationButton = (ImageButton) findViewById(R.id.map_button_myposition);
yotaSetup();
setUpInfoBox();
setUpPlacePage();
setUpRoutingBox();
setUpToolbars();
if (findViewById(R.id.fragment_container) != null)
@ -804,13 +804,13 @@ public class MWMActivity extends NvEventQueueActivity
}
}
private void setUpInfoBox()
private void setUpPlacePage()
{
mInfoView = (PlacePageView) findViewById(R.id.info_box);
mInfoView.setOnVisibilityChangedListener(this);
mIvStartRouting = (ImageView) mInfoView.findViewById(R.id.iv__start_routing);
mPlacePage = (PlacePageView) findViewById(R.id.info_box);
mPlacePage.setOnVisibilityChangedListener(this);
mIvStartRouting = mPlacePage.findViewById(R.id.rl__route);
mIvStartRouting.setOnClickListener(this);
mPbRoutingProgress = (ProgressBar) mInfoView.findViewById(R.id.pb__routing_progress);
mPbRoutingProgress = (ProgressBar) mPlacePage.findViewById(R.id.pb__routing_progress);
}
private void setUpRoutingBox()
@ -990,8 +990,8 @@ public class MWMActivity extends NvEventQueueActivity
l.getSpeed(),
l.getBearing());
if (mInfoView.getState() != State.HIDDEN)
mInfoView.updateLocation(l);
if (mPlacePage.getState() != State.HIDDEN)
mPlacePage.refreshLocation(l);
updateRoutingDistance();
}
@ -1067,8 +1067,8 @@ public class MWMActivity extends NvEventQueueActivity
nativeCompassUpdated(time, angles[0], angles[1], accuracy);
final double north = (angles[1] >= 0.0) ? angles[1] : angles[0];
if (mInfoView.getState() != State.HIDDEN)
mInfoView.updateAzimuth(north);
if (mPlacePage.getState() != State.HIDDEN)
mPlacePage.refreshAzimuth(north);
}
// Callback from native location state mode element processing.
@ -1124,7 +1124,7 @@ public class MWMActivity extends NvEventQueueActivity
findViewById(R.id.map_button_minus));
SearchController.getInstance().onResume();
mInfoView.onResume();
mPlacePage.onResume();
tryResumeRouting();
mLocationPredictor.resume();
mLikesManager.showLikeDialogs();
@ -1240,7 +1240,7 @@ public class MWMActivity extends NvEventQueueActivity
@Override
public void onBackPressed()
{
if (mInfoView.getState() != State.HIDDEN)
if (mPlacePage.getState() != State.HIDDEN)
{
hideInfoView();
Framework.deactivatePopup();
@ -1314,14 +1314,14 @@ public class MWMActivity extends NvEventQueueActivity
@Override
public void run()
{
mInfoView.bringToFront();
mPlacePage.bringToFront();
final String poiType = ParsedMmwRequest.getCurrentRequest().getCallerName(MWMApplication.get()).toString();
final ApiPoint apiPoint = new ApiPoint(name, id, poiType, lat, lon);
if (!mInfoView.hasMapObject(apiPoint))
if (!mPlacePage.hasMapObject(apiPoint))
{
mInfoView.setMapObject(apiPoint);
mInfoView.setState(State.PREVIEW_ONLY);
mPlacePage.setMapObject(apiPoint);
mPlacePage.setState(State.PREVIEW_ONLY);
mIvStartRouting.setVisibility(View.VISIBLE);
mPbRoutingProgress.setVisibility(View.GONE);
if (popFragment() && isMapFaded())
@ -1342,11 +1342,11 @@ public class MWMActivity extends NvEventQueueActivity
@Override
public void run()
{
mInfoView.bringToFront();
if (!mInfoView.hasMapObject(poi))
mPlacePage.bringToFront();
if (!mPlacePage.hasMapObject(poi))
{
mInfoView.setMapObject(poi);
mInfoView.setState(State.PREVIEW_ONLY);
mPlacePage.setMapObject(poi);
mPlacePage.setState(State.PREVIEW_ONLY);
mIvStartRouting.setVisibility(View.VISIBLE);
mPbRoutingProgress.setVisibility(View.GONE);
if (popFragment() && isMapFaded())
@ -1364,12 +1364,12 @@ public class MWMActivity extends NvEventQueueActivity
@Override
public void run()
{
mInfoView.bringToFront();
mPlacePage.bringToFront();
final Bookmark b = BookmarkManager.getBookmarkManager().getBookmark(category, bookmarkIndex);
if (!mInfoView.hasMapObject(b))
if (!mPlacePage.hasMapObject(b))
{
mInfoView.setMapObject(b);
mInfoView.setState(State.PREVIEW_ONLY);
mPlacePage.setMapObject(b);
mPlacePage.setState(State.PREVIEW_ONLY);
mIvStartRouting.setVisibility(View.VISIBLE);
mPbRoutingProgress.setVisibility(View.GONE);
if (popFragment() && isMapFaded())
@ -1391,11 +1391,11 @@ public class MWMActivity extends NvEventQueueActivity
{
if (!Framework.nativeIsRoutingActive())
{
mInfoView.bringToFront();
if (!mInfoView.hasMapObject(mypos))
mPlacePage.bringToFront();
if (!mPlacePage.hasMapObject(mypos))
{
mInfoView.setMapObject(mypos);
mInfoView.setState(State.PREVIEW_ONLY);
mPlacePage.setMapObject(mypos);
mPlacePage.setState(State.PREVIEW_ONLY);
mIvStartRouting.setVisibility(View.GONE);
mPbRoutingProgress.setVisibility(View.GONE);
if (popFragment() && isMapFaded())
@ -1414,12 +1414,12 @@ public class MWMActivity extends NvEventQueueActivity
@Override
public void run()
{
mInfoView.bringToFront();
mPlacePage.bringToFront();
final MapObject sr = new MapObject.SearchResult(name, type, lat, lon);
if (!mInfoView.hasMapObject(sr))
if (!mPlacePage.hasMapObject(sr))
{
mInfoView.setMapObject(sr);
mInfoView.setState(State.PREVIEW_ONLY);
mPlacePage.setMapObject(sr);
mPlacePage.setState(State.PREVIEW_ONLY);
mPbRoutingProgress.setVisibility(View.GONE);
mIvStartRouting.setVisibility(View.VISIBLE);
if (popFragment() && isMapFaded())
@ -1431,14 +1431,14 @@ public class MWMActivity extends NvEventQueueActivity
private void hideInfoView()
{
mInfoView.setState(State.HIDDEN);
mInfoView.setMapObject(null);
mPlacePage.setState(State.HIDDEN);
mPlacePage.setMapObject(null);
}
@Override
public void onDismiss()
{
if (!mInfoView.hasMapObject(null))
if (!mPlacePage.hasMapObject(null))
{
runOnUiThread(new Runnable()
{
@ -1540,7 +1540,7 @@ public class MWMActivity extends NvEventQueueActivity
return;
}
final MapObject mapObject = mInfoView.getMapObject();
final MapObject mapObject = mPlacePage.getMapObject();
if (mapObject != null)
{
mIvStartRouting.setVisibility(View.INVISIBLE);
@ -1548,7 +1548,7 @@ public class MWMActivity extends NvEventQueueActivity
Framework.nativeBuildRoute(mapObject.getLat(), mapObject.getLon());
}
else
Log.d(MWMActivity.class.getName(), "buildRoute(). MapObject is null. MapInfoView visibility : " + mInfoView.getVisibility());
Log.d(MWMActivity.class.getName(), "buildRoute(). MapObject is null. MapInfoView visibility : " + mPlacePage.getVisibility());
}
private void showRoutingDisclaimer()
@ -1580,7 +1580,7 @@ public class MWMActivity extends NvEventQueueActivity
private void closeRouting()
{
mInfoView.bringToFront();
mPlacePage.bringToFront();
mRlRoutingBox.clearAnimation();
UiUtils.hide(mRlRoutingBox, mPbRoutingProgress, mRlTurnByTurnBox);
mIvStartRouting.setVisibility(View.VISIBLE);
@ -1598,7 +1598,7 @@ public class MWMActivity extends NvEventQueueActivity
setVerticalToolbarVisible(false);
result = true;
}
if (mInfoView.getState() == State.FULL_PLACEPAGE)
if (mPlacePage.getState() == State.FULL_PLACEPAGE)
{
Framework.deactivatePopup();
hideInfoView();

View file

@ -3,8 +3,8 @@ package com.mapswithme.maps.widget.placepage;
import android.support.annotation.NonNull;
import android.support.v4.view.GestureDetectorCompat;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import com.mapswithme.maps.R;
@ -17,8 +17,9 @@ public abstract class BasePlacePageAnimationController
protected static final int LONG_ANIM_DURATION = 400;
protected PlacePageView mPlacePage;
protected View mPreview;
protected View mPlacePageDetails;
protected ViewGroup mPreview;
protected ViewGroup mDetails;
protected ViewGroup mButtons;
// Gestures
protected GestureDetectorCompat mGestureDetector;
protected boolean mIsGestureHandled;
@ -47,8 +48,9 @@ public abstract class BasePlacePageAnimationController
public BasePlacePageAnimationController(@NonNull PlacePageView placePage)
{
mPlacePage = placePage;
mPreview = placePage.findViewById(R.id.preview);
mPlacePageDetails = placePage.findViewById(R.id.place_page);
mPreview = (ViewGroup) placePage.findViewById(R.id.pp__preview);
mDetails = (ViewGroup) placePage.findViewById(R.id.pp__details);
mButtons = (ViewGroup) placePage.findViewById(R.id.pp__buttons);
initGestureDetector();
mTouchSlop = ViewConfiguration.get(mPlacePage.getContext()).getScaledTouchSlop();
@ -61,9 +63,9 @@ public abstract class BasePlacePageAnimationController
abstract boolean onInterceptTouchEvent(MotionEvent event);
protected void onTouchEvent(@NonNull MotionEvent event)
protected boolean onTouchEvent(@NonNull MotionEvent event)
{
mPlacePage.requestDisallowInterceptTouchEvent(false);
mGestureDetector.onTouchEvent(event);
// mPlacePage.requestDisallowInterceptTouchEvent(false);
return mGestureDetector.onTouchEvent(event);
}
}

View file

@ -0,0 +1,198 @@
package com.mapswithme.maps.widget.placepage;
import android.support.annotation.NonNull;
import android.support.v4.view.GestureDetectorCompat;
import android.util.Log;
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.Framework;
import com.mapswithme.maps.widget.placepage.PlacePageView.State;
import com.mapswithme.util.UiUtils;
public class BottomPlacePageAnimationController extends BasePlacePageAnimationController
{
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();
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())
return false;
if (Math.abs(mDownY - event.getRawY()) > mTouchSlop)
return true;
break;
}
return false;
}
@Override
protected void initGestureDetector()
{
// Gestures
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)
{
if (mPlacePage.getState() == State.FULL_PLACEPAGE)
mPlacePage.setState(State.PREVIEW_ONLY);
else
{
mPlacePage.setState(State.HIDDEN);
Framework.deactivatePopup();
}
}
else
mPlacePage.setState(State.FULL_PLACEPAGE);
mIsGestureHandled = true;
}
return true;
}
return false;
}
@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())
return false;
if (mPlacePage.getState() == State.FULL_PLACEPAGE)
mPlacePage.setState(State.PREVIEW_ONLY);
else
mPlacePage.setState(State.FULL_PLACEPAGE);
return true;
}
});
}
protected void showPreview(final boolean show)
{
mPlacePage.setVisibility(View.VISIBLE);
mDetails.setVisibility(View.GONE);
if (mIsPreviewVisible == show)
return;
TranslateAnimation slide;
if (show)
{
slide = UiUtils.generateRelativeSlideAnimation(0, 0, 1, 0);
mPreview.setVisibility(View.VISIBLE);
}
else
{
slide = UiUtils.generateRelativeSlideAnimation(0, 0, 0, 1);
slide.setAnimationListener(new UiUtils.SimpleAnimationListener()
{
@Override
public void onAnimationEnd(Animation animation)
{
mPlacePage.setVisibility(View.GONE);
}
});
}
slide.setDuration(SHORT_ANIM_DURATION);
mPreview.startAnimation(slide);
mButtons.startAnimation(slide);
if (mVisibilityChangedListener != null)
mVisibilityChangedListener.onPreviewVisibilityChanged(show);
mIsPreviewVisible = show;
}
protected void showPlacePage(final boolean show)
{
mPlacePage.setVisibility(View.VISIBLE);
if (mIsPlacePageVisible == show)
return; // if state is already same as we need
TranslateAnimation slide;
if (show) // slide up
{
slide = UiUtils.generateRelativeSlideAnimation(0, 0, 1, 0);
slide.setDuration(SHORT_ANIM_DURATION);
mDetails.setVisibility(View.VISIBLE);
}
else // slide down
{
slide = UiUtils.generateRelativeSlideAnimation(0, 0, 0, 1);
slide.setDuration(SHORT_ANIM_DURATION);
slide.setAnimationListener(new UiUtils.SimpleAnimationListener()
{
@Override
public void onAnimationEnd(Animation animation)
{
mDetails.setVisibility(View.GONE);
}
});
}
mDetails.startAnimation(slide);
if (mVisibilityChangedListener != null)
mVisibilityChangedListener.onPlacePageVisibilityChanged(show);
mIsPlacePageVisible = show;
}
protected void hidePlacePage()
{
final TranslateAnimation slideDown = UiUtils.generateRelativeSlideAnimation(0, 0, 0, 1);
slideDown.setDuration(LONG_ANIM_DURATION);
slideDown.setAnimationListener(new UiUtils.SimpleAnimationListener()
{
@Override
public void onAnimationEnd(Animation animation)
{
mIsPlacePageVisible = false;
mIsPreviewVisible = false;
mPlacePage.setVisibility(View.GONE);
if (mVisibilityChangedListener != null)
{
mVisibilityChangedListener.onPreviewVisibilityChanged(false);
mVisibilityChangedListener.onPlacePageVisibilityChanged(false);
}
}
});
mPlacePage.startAnimation(slideDown);
}
}

View file

@ -4,17 +4,14 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.content.res.TypedArray;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.os.Build;
import android.support.annotation.NonNull;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ImageSpan;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
@ -22,22 +19,18 @@ import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.ToggleButton;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.R;
import com.mapswithme.maps.api.ParsedMmwRequest;
import com.mapswithme.maps.bookmarks.BookmarkActivity;
import com.mapswithme.maps.bookmarks.IconsAdapter;
import com.mapswithme.maps.bookmarks.data.Bookmark;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
@ -48,7 +41,6 @@ import com.mapswithme.maps.bookmarks.data.MapObject.MapObjectType;
import com.mapswithme.maps.bookmarks.data.MapObject.Poi;
import com.mapswithme.maps.bookmarks.data.MapObject.SearchResult;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.widget.ArrowView;
import com.mapswithme.util.ShareAction;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
@ -59,25 +51,32 @@ import java.util.List;
public class PlacePageView extends LinearLayout implements View.OnClickListener, View.OnLongClickListener
{
private static final float SPAN_SIZE = 25;
private static final int COLOR_CHOOSER_COLUMN_NUM = 4;
private ViewGroup mPlacePageGroup;
private ScrollView mPlacePageContainer;
// Preview
private TextView mTitle;
private TextView mSubtitle;
private ToggleButton mIsBookmarked;
private ImageButton mEditBtn;
private LayoutInflater mInflater;
private View mArrow;
// Place page
private RelativeLayout mGeoLayout;
private TextView mTvLat;
private TextView mTvLon;
private ArrowView mAvDirection;
// Preview
private TextView mTvTitle;
private TextView mTvSubtitle;
private TextView mTvOpened;
private ImageView mAvDirection;
private TextView mTvDistance;
// Place page details
private ViewGroup mPpDetails;
private ScrollView mPlacePageContainer;
private LinearLayout mLlAddress;
private TextView mTvAddress;
private LinearLayout mLlPhone;
private TextView mTvPhone;
private LinearLayout mLlWebsite;
private TextView mTvWebsite;
private LinearLayout mLlLatlon;
private TextView mTvLatlon;
private LinearLayout mLlSchedule;
private TextView mTvSchedule;
private ImageView mIvColor;
// Place page buttons
private RelativeLayout mRlApiBack;
private ImageView mIvBookmark;
// Animations
private BasePlacePageAnimationController mAnimationController;
// Data
@ -119,50 +118,89 @@ public class PlacePageView extends LinearLayout implements View.OnClickListener,
mBookmarkManager = BookmarkManager.getBookmarkManager();
mIcons = mBookmarkManager.getIcons();
initAnimationController();
initAnimationController(attrs, defStyleAttr);
setVisibility(View.GONE);
}
private void initViews()
{
View mView = mInflater.inflate(R.layout.info_box, this, true);
View mView = mInflater.inflate(R.layout.place_page, this, true);
mView.setOnClickListener(this);
ViewGroup mPreviewGroup = (ViewGroup) mView.findViewById(R.id.preview);
mPreviewGroup.bringToFront();
mPlacePageGroup = (ViewGroup) mView.findViewById(R.id.place_page);
ViewGroup ppPreview = (ViewGroup) mView.findViewById(R.id.pp__preview);
mTvTitle = (TextView) ppPreview.findViewById(R.id.tv__title);
mTvSubtitle = (TextView) ppPreview.findViewById(R.id.tv__subtitle);
mTvOpened = (TextView) ppPreview.findViewById(R.id.tv__opened_till);
mTvDistance = (TextView) ppPreview.findViewById(R.id.tv__straight_distance);
mAvDirection = (ImageView) ppPreview.findViewById(R.id.iv__direction);
// mAvDirection.setDrawCircle(true);
// mAvDirection.setVisibility(View.GONE); // should be hidden until first compass update
// Preview
mTitle = (TextView) mPreviewGroup.findViewById(R.id.info_title);
mSubtitle = (TextView) mPreviewGroup.findViewById(R.id.info_subtitle);
mIsBookmarked = (ToggleButton) mPreviewGroup.findViewById(R.id.info_box_is_bookmarked);
// We don't want to use OnCheckedChangedListener because it gets called
// if someone calls setChecked() from code. We need only user interaction.
mIsBookmarked.setOnClickListener(this);
mArrow = mPreviewGroup.findViewById(R.id.iv_arrow);
mEditBtn = (ImageButton) mPreviewGroup.findViewById(R.id.btn_edit_title);
mPpDetails = (ViewGroup) mView.findViewById(R.id.pp__details);
mLlAddress = (LinearLayout) mPpDetails.findViewById(R.id.ll__place_name);
mTvAddress = (TextView) mPpDetails.findViewById(R.id.tv__place_address);
mLlPhone = (LinearLayout) mPpDetails.findViewById(R.id.ll__place_phone);
mTvPhone = (TextView) mPpDetails.findViewById(R.id.tv__place_phone);
mLlWebsite = (LinearLayout) mPpDetails.findViewById(R.id.ll__place_website);
mTvWebsite = (TextView) mPpDetails.findViewById(R.id.tv__place_website);
mLlLatlon = (LinearLayout) mPpDetails.findViewById(R.id.ll__place_latlon);
mTvLatlon = (TextView) mPpDetails.findViewById(R.id.tv__place_latlon);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
mTvLatlon.setOnLongClickListener(this);
mLlSchedule = (LinearLayout) mPpDetails.findViewById(R.id.ll__place_schedule);
mTvSchedule = (TextView) mPpDetails.findViewById(R.id.tv__place_schedule);
ViewGroup ppButtons = (ViewGroup) mView.findViewById(R.id.pp__buttons);
mRlApiBack = (RelativeLayout) ppButtons.findViewById(R.id.rl__api_back);
mRlApiBack.setOnClickListener(this);
final ViewGroup bookmarkGroup = (ViewGroup) ppButtons.findViewById(R.id.rl__bookmark);
bookmarkGroup.setOnClickListener(this);
mIvBookmark = (ImageView) bookmarkGroup.findViewById(R.id.iv__bookmark);
ppButtons.findViewById(R.id.rl__share).setOnClickListener(this);
ppButtons.findViewById(R.id.rl__route).setOnClickListener(this);
// Place Page
mPlacePageContainer = (ScrollView) mPlacePageGroup.findViewById(R.id.place_page_container);
mPlacePageContainer = (ScrollView) mPpDetails.findViewById(R.id.place_page_container);
}
private void initAnimationController()
private void initAnimationController(AttributeSet attrs, int defStyleAttr)
{
// TODO get appropriate controller
mAnimationController = new TopPlacePageAnimationController(this);
mAnimationController.hidePlacePage();
final TypedArray attrArray = getContext().obtainStyledAttributes(attrs, R.styleable.PlacePageView, defStyleAttr, 0);
final int animationType = attrArray.getInt(R.styleable.PlacePageView_animationType, 0);
Log.d("TEST", "AnimationType = " + animationType);
attrArray.recycle();
switch (animationType)
{
case 0:
mAnimationController = new BottomPlacePageAnimationController(this);
break;
case 1:
// FIXME
mAnimationController = new TopPlacePageAnimationController(this);
break;
case 2:
// FIXME
mAnimationController = new TopPlacePageAnimationController(this);
break;
case 3:
// FIXME
mAnimationController = new TopPlacePageAnimationController(this);
break;
}
}
@Override
public boolean onTouchEvent(@NonNull MotionEvent event)
{
mAnimationController.onTouchEvent(event);
return super.onTouchEvent(event);
return mAnimationController.onTouchEvent(event);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event)
{
return mAnimationController.onInterceptTouchEvent(event);
boolean res = mAnimationController.onInterceptTouchEvent(event);
Log.d("TEST", "Intercept - " + res);
return res;
}
public State getState()
@ -232,11 +270,12 @@ public class PlacePageView extends LinearLayout implements View.OnClickListener,
throw new IllegalArgumentException("Unknown MapObject type:" + mo.getType());
}
mIsBookmarked.setChecked(isChecked);
// TODO
// mIvBookmark.setChecked(isChecked);
setUpPreview();
setUpGeoInformation();
setUpBottomButtons();
refreshPreview();
refreshDetails();
refreshButtons();
}
}
}
@ -246,83 +285,34 @@ public class PlacePageView extends LinearLayout implements View.OnClickListener,
return mMapObject;
}
private void setUpPreview()
private void refreshPreview()
{
mTitle.setText(mMapObject.getName());
mSubtitle.setText(mMapObject.getPoiTypeName());
if (mMapObject.getType() == MapObjectType.BOOKMARK)
{
mEditBtn.setOnClickListener(this);
UiUtils.show(mEditBtn);
}
else
UiUtils.hide(mEditBtn);
mAnimationController.showPreview(true);
mTvTitle.setText(mMapObject.getName());
mTvSubtitle.setText(mMapObject.getPoiTypeName());
// mTvOpened
// mTvDistance
// mAvDirection
}
private void setUpBottomButtons()
private void refreshDetails()
{
mPlacePageGroup.findViewById(R.id.info_box_share).setOnClickListener(this);
final TextView tvBackToCaller = (TextView) mPlacePageGroup.findViewById(R.id.info_box_back_to_caller);
UiUtils.hide(tvBackToCaller);
refreshLocation(LocationHelper.INSTANCE.getLastLocation());
refreshLatLon();
// TODO refresh full details
}
private void refreshButtons()
{
if (mMapObject.getType() == MapObjectType.API_POINT ||
(ParsedMmwRequest.hasRequest() && ParsedMmwRequest.getCurrentRequest().isPickPointMode()))
{
// API
final ParsedMmwRequest r = ParsedMmwRequest.getCurrentRequest();
// Text and icon
final String txtPattern = String
.format("%s {icon} %s", getResources().getString(R.string.more_info), r.getCallerName(getContext()));
final int spanStart = txtPattern.indexOf("{icon}");
final int spanEnd = spanStart + "{icon}".length();
final Drawable icon = r.getIcon(getContext());
final int spanSize = (int) (SPAN_SIZE * getResources().getDisplayMetrics().density);
icon.setBounds(0, 0, spanSize, spanSize);
final ImageSpan callerIconSpan = new ImageSpan(icon, ImageSpan.ALIGN_BOTTOM);
final SpannableString ss = new SpannableString(txtPattern);
ss.setSpan(callerIconSpan, spanStart, spanEnd, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
UiUtils.show(tvBackToCaller);
tvBackToCaller.setText(ss, TextView.BufferType.SPANNABLE);
tvBackToCaller.setOnClickListener(this);
}
mRlApiBack.setVisibility(View.VISIBLE);
else
mRlApiBack.setVisibility(View.GONE);
}
private void setUpGeoInformation()
public void refreshLocation(Location l)
{
mGeoLayout = (RelativeLayout) mPlacePageContainer.findViewById(R.id.info_box_geo_ref);
mTvDistance = (TextView) mGeoLayout.findViewById(R.id.info_box_geo_distance);
mAvDirection = (ArrowView) mGeoLayout.findViewById(R.id.av_direction);
mAvDirection.setDrawCircle(true);
mAvDirection.setVisibility(View.GONE); // should be hidden until first compass update
mTvLat = (TextView) mGeoLayout.findViewById(R.id.info_box_lat);
mTvLat.setOnClickListener(this);
mTvLon = (TextView) mGeoLayout.findViewById(R.id.info_box_lon);
mTvLon.setOnClickListener(this);
final Location lastKnown = LocationHelper.INSTANCE.getLastLocation();
updateLocation(lastKnown);
updateCoords();
// Context menu for the coordinates copying.
if (Utils.apiEqualOrGreaterThan(Build.VERSION_CODES.HONEYCOMB))
{
mTvLat.setOnLongClickListener(this);
mTvLon.setOnLongClickListener(this);
}
}
public void updateLocation(Location l)
{
if (mGeoLayout != null && mMapObject != null)
if (mMapObject != null)
{
if (mMapObject.getType() == MapObjectType.MY_POSITION)
{
@ -332,13 +322,13 @@ public class PlacePageView extends LinearLayout implements View.OnClickListener,
if (l.hasSpeed())
builder.append(" ").
append(Framework.nativeFormatSpeed(l.getSpeed()));
mSubtitle.setText(builder.toString());
mTvSubtitle.setText(builder.toString());
mTvDistance.setVisibility(View.GONE);
mMapObject.setLat(l.getLatitude());
mMapObject.setLon(l.getLongitude());
updateCoords();
refreshLatLon();
}
else
{
@ -355,21 +345,18 @@ public class PlacePageView extends LinearLayout implements View.OnClickListener,
}
}
private void updateCoords()
private void refreshLatLon()
{
final double lat = mMapObject.getLat();
final double lon = mMapObject.getLon();
final String[] latLon = Framework.nativeFormatLatLonToArr(lat, lon, mIsLatLonDms);
if (latLon.length == 2)
{
mTvLat.setText(latLon[0]);
mTvLon.setText(latLon[1]);
}
mTvLatlon.setText(latLon[0] + ", " + latLon[1]);
}
public void updateAzimuth(double northAzimuth)
public void refreshAzimuth(double northAzimuth)
{
if (mGeoLayout != null && mMapObject != null && mMapObject.getType() != MapObjectType.MY_POSITION)
if (mMapObject != null && mMapObject.getType() != MapObjectType.MY_POSITION)
{
final Location l = LocationHelper.INSTANCE.getLastLocation();
if (l != null)
@ -381,7 +368,7 @@ public class PlacePageView extends LinearLayout implements View.OnClickListener,
if (da.getAthimuth() >= 0)
{
mAvDirection.setVisibility(View.VISIBLE);
mAvDirection.setAzimut(da.getAthimuth());
// mAvDirection.setAzimut(da.getAthimuth());
}
}
}
@ -389,70 +376,70 @@ public class PlacePageView extends LinearLayout implements View.OnClickListener,
private void fillPlacePagePoi(MapObject poi)
{
mPlacePageContainer.removeAllViews();
final View poiView = mInflater.inflate(R.layout.info_box_poi, this, false);
mPlacePageContainer.addView(poiView);
// mPlacePageContainer.removeAllViews();
// final View poiView = mInflater.inflate(R.layout.info_box_poi, this, false);
// mPlacePageContainer.addView(poiView);
}
private void fillPlacePageBookmark(final Bookmark bmk)
{
mPlacePageContainer.removeAllViews();
final View bmkView = mInflater.inflate(R.layout.info_box_bookmark, this, false);
bmkView.setOnClickListener(this);
// mPlacePageContainer.removeAllViews();
// final View bmkView = mInflater.inflate(R.layout.info_box_bookmark, this, false);
// bmkView.setOnClickListener(this);
// Description of BMK
final WebView descriptionWv = (WebView) bmkView.findViewById(R.id.info_box_bookmark_descr);
final String descriptionTxt = bmk.getBookmarkDescription();
if (TextUtils.isEmpty(descriptionTxt))
UiUtils.hide(descriptionWv);
else
{
descriptionWv.loadData(descriptionTxt, "text/html; charset=UTF-8", null);
descriptionWv.setBackgroundColor(Color.TRANSPARENT);
descriptionWv.setOnTouchListener(new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
PlacePageView.this.requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
PlacePageView.this.requestDisallowInterceptTouchEvent(false);
break;
}
v.onTouchEvent(event);
return true;
}
});
UiUtils.show(descriptionWv);
}
mIvColor = (ImageView) bmkView.findViewById(R.id.color_image);
mIvColor.setOnClickListener(this);
mIvColor.setVisibility(View.VISIBLE);
updateColorChooser(bmk.getIcon());
mPlacePageContainer.addView(bmkView);
// final WebView descriptionWv = (WebView) bmkView.findViewById(R.id.info_box_bookmark_descr);
// final String descriptionTxt = bmk.getBookmarkDescription();
//
// if (TextUtils.isEmpty(descriptionTxt))
// UiUtils.hide(descriptionWv);
// else
// {
// descriptionWv.loadData(descriptionTxt, "text/html; charset=UTF-8", null);
// descriptionWv.setBackgroundColor(Color.TRANSPARENT);
// descriptionWv.setOnTouchListener(new OnTouchListener()
// {
// @Override
// public boolean onTouch(View v, MotionEvent event)
// {
// switch (event.getAction())
// {
// case MotionEvent.ACTION_DOWN:
// PlacePageView.this.requestDisallowInterceptTouchEvent(true);
// break;
// case MotionEvent.ACTION_UP:
// PlacePageView.this.requestDisallowInterceptTouchEvent(false);
// break;
// }
//
// v.onTouchEvent(event);
// return true;
// }
// });
//
// UiUtils.show(descriptionWv);
// }
//
// mIvColor = (ImageView) bmkView.findViewById(R.id.color_image);
// mIvColor.setOnClickListener(this);
// mIvColor.setVisibility(View.VISIBLE);
// updateColorChooser(bmk.getIcon());
//
// mPlacePageContainer.addView(bmkView);
}
private void fillPlacePageLayer(SearchResult sr)
{
mPlacePageContainer.removeAllViews();
final View addLayerView = mInflater.inflate(R.layout.info_box_additional_layer, this, false);
mPlacePageContainer.addView(addLayerView);
// mPlacePageContainer.removeAllViews();
// final View addLayerView = mInflater.inflate(R.layout.info_box_additional_layer, this, false);
// mPlacePageContainer.addView(addLayerView);
}
private void fillPlacePageApi(MapObject mo)
{
mPlacePageContainer.removeAllViews();
final View apiView = mInflater.inflate(R.layout.info_box_api, this, false);
mPlacePageContainer.addView(apiView);
// mPlacePageContainer.removeAllViews();
// final View apiView = mInflater.inflate(R.layout.info_box_api, this, false);
// mPlacePageContainer.addView(apiView);
}
public void setOnVisibilityChangedListener(BasePlacePageAnimationController.OnVisibilityChangedListener listener)
@ -571,7 +558,7 @@ public class PlacePageView extends LinearLayout implements View.OnClickListener,
case R.id.color_image:
showColorChooser();
break;
case R.id.info_box_is_bookmarked:
case R.id.rl__bookmark:
if (mMapObject == null)
return;
if (mMapObject.getType() == MapObjectType.BOOKMARK)
@ -601,24 +588,19 @@ public class PlacePageView extends LinearLayout implements View.OnClickListener,
// without listening this event some bug may appear.
// check that and remove after investigation
break;
case R.id.info_box_share:
case R.id.rl__share:
ShareAction.getAnyShare().shareMapObject((Activity) getContext(), mMapObject);
break;
case R.id.info_box_back_to_caller:
case R.id.rl__api_back:
if (ParsedMmwRequest.hasRequest() && ParsedMmwRequest.getCurrentRequest().isPickPointMode())
ParsedMmwRequest.getCurrentRequest().setPointData(mMapObject.getLat(), mMapObject.getLon(), mMapObject.getName(), "");
ParsedMmwRequest.getCurrentRequest().sendResponseAndFinish((Activity) getContext(), true);
break;
case R.id.btn_edit_title:
Bookmark bmk = (Bookmark) mMapObject;
BookmarkActivity.startWithBookmark((Activity) getContext(), bmk.getCategoryId(), bmk.getBookmarkId());
break;
case R.id.info_box_lat:
case R.id.info_box_lon:
case R.id.ll__place_latlon:
mIsLatLonDms = !mIsLatLonDms;
getContext().getSharedPreferences(getContext().getString(R.string.pref_file_name),
Context.MODE_PRIVATE).edit().putBoolean(PREF_USE_DMS, mIsLatLonDms).commit();
updateCoords();
refreshLatLon();
break;
default:
break;

View file

@ -101,8 +101,7 @@ public class TopPlacePageAnimationController extends BasePlacePageAnimationContr
{
slide = UiUtils.generateRelativeSlideAnimation(0, 0, -1, 0);
slide.setDuration(SHORT_ANIM_DURATION);
UiUtils.show(mPlacePageDetails);
// UiUtils.hide(mArrow);
UiUtils.show(mDetails);
if (mVisibilityChangedListener != null)
mVisibilityChangedListener.onPlacePageVisibilityChanged(show);
}
@ -113,20 +112,19 @@ public class TopPlacePageAnimationController extends BasePlacePageAnimationContr
slide.setDuration(SHORT_ANIM_DURATION);
slide.setFillEnabled(true);
slide.setFillBefore(true);
// UiUtils.show(mArrow);
slide.setAnimationListener(new UiUtils.SimpleAnimationListener()
{
@Override
public void onAnimationEnd(Animation animation)
{
UiUtils.hide(mPlacePageDetails);
UiUtils.hide(mDetails);
if (mVisibilityChangedListener != null)
mVisibilityChangedListener.onPlacePageVisibilityChanged(show);
}
});
}
mPlacePageDetails.startAnimation(slide);
mDetails.startAnimation(slide);
mIsPlacePageVisible = show;
}
@ -168,7 +166,6 @@ public class TopPlacePageAnimationController extends BasePlacePageAnimationContr
slide.setDuration(SHORT_ANIM_DURATION);
mPreview.startAnimation(slide);
mIsPreviewVisible = show;
// UiUtils.show(mArrow);
}
protected void hidePlacePage()
@ -185,7 +182,7 @@ public class TopPlacePageAnimationController extends BasePlacePageAnimationContr
mIsPreviewVisible = false;
UiUtils.hide(mPreview);
UiUtils.hide(mPlacePageDetails);
UiUtils.hide(mDetails);
if (mVisibilityChangedListener != null)
{
mVisibilityChangedListener.onPreviewVisibilityChanged(false);