[android] add: PlacePage routing buttons added.

This commit is contained in:
Alexander Marchuk 2015-10-26 18:45:00 +03:00
parent 47737a70c6
commit e69c339f22
2 changed files with 65 additions and 78 deletions

View file

@ -1,63 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_base"
android:background="@color/bg_place_page_buttons"
android:orientation="vertical"
android:paddingLeft="@dimen/margin_half_plus"
android:paddingRight="@dimen/margin_half_plus"
android:clickable="true"
tools:ignore="UseCompoundDrawables">
android:background="@color/bg_place_page_buttons"
android:clickable="true">
<LinearLayout
android:id="@+id/general"
android:layout_width="match_parent"
android:layout_height="@dimen/place_page_buttons_height"
android:baselineAligned="false"
android:orientation="horizontal"
android:paddingLeft="@dimen/margin_half_plus"
android:paddingRight="@dimen/margin_half_plus">
tools:ignore="UseCompoundDrawables">
<LinearLayout
android:id="@+id/ll__api_back"
style="@style/PlacePageButton">
<ImageView
android:id="@+id/iv__api_back"
style="@style/PlacePageButtonImage"
android:contentDescription="@string/back"
android:src="@drawable/ic_back_api"/>
<TextView
android:id="@+id/tv__api_back"
style="@style/PlacePageButtonText"
android:text="@string/back"/>
</LinearLayout>
<LinearLayout
android:id="@+id/ll__share"
style="@style/PlacePageButton">
<ImageView
android:id="@+id/iv__share"
style="@style/PlacePageButtonImage"
android:contentDescription="@string/share"
android:src="@drawable/ic_share"/>
<TextView
android:id="@+id/tv__share"
style="@style/PlacePageButtonText"
android:text="@string/share"/>
</LinearLayout>
<LinearLayout
android:id="@+id/ll__bookmark"
style="@style/PlacePageButton">
<ImageView
android:id="@+id/iv__bookmark"
style="@style/PlacePageButtonImage"
@ -65,29 +52,45 @@
android:src="@drawable/ic_bookmarks_off"/>
<TextView
android:id="@+id/tv__bookmark"
style="@style/PlacePageButtonText"
android:text="@string/bookmark"/>
</LinearLayout>
<LinearLayout
android:id="@+id/ll__route"
style="@style/PlacePageButton">
<ImageView
android:id="@+id/iv__route"
style="@style/PlacePageButtonImage"
android:contentDescription="@string/route"
android:src="@drawable/ic_route"/>
<TextView
android:id="@+id/tv__route"
style="@style/PlacePageButtonText"
android:text="@string/route"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/routing"
android:layout_width="match_parent"
android:layout_height="@dimen/place_page_buttons_height"
android:orientation="horizontal"
android:visibility="gone"
tools:visibility="visible"
tools:layout_marginTop="60dp">
<TextView
android:id="@+id/from"
style="@style/PlacePageButtonText.Route"
android:text="@string/routing_from"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/divider_standard"/>
<TextView
android:id="@+id/to"
style="@style/PlacePageButtonText.Route"
android:text="@string/routing_to"/>
</LinearLayout>
</FrameLayout>

View file

@ -16,48 +16,21 @@ import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.*;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.RatingBar;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.MwmActivity;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import android.widget.*;
import com.mapswithme.maps.*;
import com.mapswithme.maps.api.ParsedMwmRequest;
import com.mapswithme.maps.bookmarks.ChooseBookmarkCategoryFragment;
import com.mapswithme.maps.bookmarks.data.Bookmark;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut;
import com.mapswithme.maps.bookmarks.data.Icon;
import com.mapswithme.maps.bookmarks.data.MapObject;
import com.mapswithme.maps.bookmarks.data.*;
import com.mapswithme.maps.bookmarks.data.MapObject.MapObjectType;
import com.mapswithme.maps.bookmarks.data.MapObject.Poi;
import com.mapswithme.maps.bookmarks.data.Metadata;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.widget.ArrowView;
import com.mapswithme.maps.widget.BaseShadowController;
import com.mapswithme.maps.widget.ObservableScrollView;
import com.mapswithme.maps.widget.ScrollViewShadowController;
import com.mapswithme.util.InputUtils;
import com.mapswithme.util.LocationUtils;
import com.mapswithme.util.StringUtils;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
import com.mapswithme.util.*;
import com.mapswithme.util.concurrency.UiThread;
import com.mapswithme.util.sharing.ShareOption;
import com.mapswithme.util.statistics.AlohaHelper;
@ -115,11 +88,15 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
private Button mBtnEditHtmlDescription;
private TextView mTvBookmarkGroup;
// Place page buttons
private BaseShadowController mShadowController;
private LinearLayout mApiBack;
private View mGeneralButtonsFrame;
private View mRouteButtonsFrame;
private View mApiBack;
private ImageView mIvBookmark;
private View mRoutingButton;
private View mRouteButtonFrom;
private View mRouteButtonTo;
// Animations
private BaseShadowController mShadowController;
private BasePlacePageAnimationController mAnimationController;
private MwmActivity.LeftAnimationTrackListener mLeftAnimationTrackListener;
// Data
@ -225,13 +202,19 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
mBtnEditHtmlDescription.setOnClickListener(this);
ViewGroup ppButtons = (ViewGroup) findViewById(R.id.pp__buttons);
mApiBack = (LinearLayout) ppButtons.findViewById(R.id.ll__api_back);
mGeneralButtonsFrame = ppButtons.findViewById(R.id.general);
mApiBack = mGeneralButtonsFrame.findViewById(R.id.ll__api_back);
mApiBack.setOnClickListener(this);
final ViewGroup bookmarkGroup = (ViewGroup) ppButtons.findViewById(R.id.ll__bookmark);
final View bookmarkGroup = mGeneralButtonsFrame.findViewById(R.id.ll__bookmark);
bookmarkGroup.setOnClickListener(this);
mIvBookmark = (ImageView) bookmarkGroup.findViewById(R.id.iv__bookmark);
ppButtons.findViewById(R.id.ll__share).setOnClickListener(this);
mRoutingButton = ppButtons.findViewById(R.id.ll__route);
mGeneralButtonsFrame.findViewById(R.id.ll__share).setOnClickListener(this);
mRoutingButton = mGeneralButtonsFrame.findViewById(R.id.ll__route);
mRouteButtonsFrame = ppButtons.findViewById(R.id.routing);
mRouteButtonFrom = mRouteButtonsFrame.findViewById(R.id.from);
mRouteButtonTo = mRouteButtonsFrame.findViewById(R.id.to);
mShadowController = new ScrollViewShadowController((ObservableScrollView) mPpDetails)
.addBottomShadow()
@ -465,6 +448,8 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
private void refreshButtons(boolean showBackButton, boolean showRoutingButton)
{
// TODO: Select button layout
UiUtils.showIf(showBackButton || ParsedMwmRequest.isPickPointMode(), mApiBack);
UiUtils.showIf(showRoutingButton, mRoutingButton);
}
@ -555,21 +540,20 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
public void refreshAzimuth(double northAzimuth)
{
if (mMapObject != null && mMapObject.getType() != MapObjectType.MY_POSITION)
{
final Location l = LocationHelper.INSTANCE.getLastLocation();
if (l != null)
{
final DistanceAndAzimut da = Framework.nativeGetDistanceAndAzimutFromLatLon(
mMapObject.getLat(), mMapObject.getLon(),
l.getLatitude(), l.getLongitude(), northAzimuth);
if (getState() == State.HIDDEN || mMapObject == null || mMapObject.getType() == MapObjectType.MY_POSITION)
return;
if (da.getAzimuth() >= 0)
{
mAvDirection.setVisibility(View.VISIBLE);
mAvDirection.setAzimuth(da.getAzimuth());
}
}
final Location l = LocationHelper.INSTANCE.getLastLocation();
if (l == null)
return;
double azimuth = Framework.nativeGetDistanceAndAzimutFromLatLon(mMapObject.getLat(), mMapObject.getLon(),
l.getLatitude(), l.getLongitude(), northAzimuth)
.getAzimuth();
if (azimuth >= 0)
{
UiUtils.show(mAvDirection);
mAvDirection.setAzimuth(azimuth);
}
}