Merge pull request #4951 from milchakov/uber_place_page_android

[android] Uber in place page
This commit is contained in:
Aleksandr Zatsepin 2016-12-14 13:01:07 +03:00 committed by GitHub
commit 204594068e
48 changed files with 229 additions and 41 deletions

View file

@ -38,14 +38,15 @@ jobject CreateMapObject(JNIEnv * env, int mapObjectType, string const & title,
string const & subtitle, double lat, double lon, string const & address,
Metadata const & metadata, string const & apiId, bool hasBanner,
string const & bannerTitleId, string const & bannerMessageId,
string const & bannerIconId, string const & bannerUrl)
string const & bannerIconId, string const & bannerUrl,
bool isReachableByTaxi)
{
// public MapObject(@MapObjectType int mapObjectType, String title, String subtitle, double lat,
// double lon, String address, String apiId, @NonNull Banner banner)
// double lon, String address, String apiId, @NonNull Banner banner, boolean reachableByTaxi)
static jmethodID const ctorId =
jni::GetConstructorID(env, g_mapObjectClazz,
"(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;DDLjava/lang/"
"String;Lcom/mapswithme/maps/bookmarks/data/Banner;)V");
"String;Lcom/mapswithme/maps/bookmarks/data/Banner;Z)V");
jobject jbanner = nullptr;
if (hasBanner)
@ -54,7 +55,7 @@ jobject CreateMapObject(JNIEnv * env, int mapObjectType, string const & title,
jobject mapObject =
env->NewObject(g_mapObjectClazz, ctorId, mapObjectType, jni::ToJavaString(env, title),
jni::ToJavaString(env, subtitle), jni::ToJavaString(env, address), lat, lon,
jni::ToJavaString(env, apiId), jbanner);
jni::ToJavaString(env, apiId), jbanner, isReachableByTaxi);
InjectMetadata(env, g_mapObjectClazz, mapObject, metadata);
return mapObject;
@ -65,9 +66,9 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
if (info.IsBookmark())
{
// public Bookmark(@IntRange(from = 0) int categoryId, @IntRange(from = 0) int bookmarkId,
// String name)
// String name, @NonNull Banner banner, boolean reachableByTaxi)
static jmethodID const ctorId = jni::GetConstructorID(
env, g_bookmarkClazz, "(IILjava/lang/String;Lcom/mapswithme/maps/bookmarks/data/Banner;)V");
env, g_bookmarkClazz, "(IILjava/lang/String;Lcom/mapswithme/maps/bookmarks/data/Banner;Z)V");
jobject jbanner = nullptr;
if (info.HasBanner())
@ -82,7 +83,8 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
jni::TScopedLocalRef jName(env, jni::ToJavaString(env, data.GetName()));
jobject mapObject =
env->NewObject(g_bookmarkClazz, ctorId, static_cast<jint>(info.m_bac.m_categoryIndex),
static_cast<jint>(info.m_bac.m_bookmarkIndex), jName.get(), jbanner);
static_cast<jint>(info.m_bac.m_bookmarkIndex), jName.get(), jbanner,
info.IsReachableByTaxi());
if (info.IsFeature())
InjectMetadata(env, g_mapObjectClazz, mapObject, info.GetMetadata());
return mapObject;
@ -98,18 +100,18 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
return CreateMapObject(env, kMyPosition, info.GetTitle(), info.GetSubtitle(), ll.lat, ll.lon,
address.FormatAddress(), {}, "", info.HasBanner(),
info.GetBannerTitleId(), info.GetBannerMessageId(),
info.GetBannerIconId(), info.GetBannerUrl());
info.GetBannerIconId(), info.GetBannerUrl(), info.IsReachableByTaxi());
if (info.HasApiUrl())
return CreateMapObject(env, kApiPoint, info.GetTitle(), info.GetSubtitle(), ll.lat, ll.lon,
address.FormatAddress(), info.GetMetadata(), info.GetApiUrl(),
info.HasBanner(), info.GetBannerTitleId(), info.GetBannerMessageId(),
info.GetBannerIconId(), info.GetBannerUrl());
info.GetBannerIconId(), info.GetBannerUrl(), info.IsReachableByTaxi());
return CreateMapObject(env, kPoi, info.GetTitle(), info.GetSubtitle(), ll.lat, ll.lon,
address.FormatAddress(),
info.IsFeature() ? info.GetMetadata() : Metadata(), "", info.HasBanner(),
info.GetBannerTitleId(), info.GetBannerMessageId(), info.GetBannerIconId(),
info.GetBannerUrl());
info.GetBannerUrl(), info.IsReachableByTaxi());
}
} // namespace usermark_helper

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

View file

@ -55,14 +55,18 @@
<include layout="@layout/place_page_email"/>
<include layout="@layout/place_page_latlon"/>
<include layout="@layout/place_page_wifi"/>
<include layout="@layout/place_page_operator"/>
<include layout="@layout/place_page_cuisine"/>
<include layout="@layout/place_page_latlon"/>
<include layout="@layout/divider_horizontal"/>
<include layout="@layout/place_page_taxi"/>
<include layout="@layout/place_page_hotel_nearby"/>
<include layout="@layout/place_page_hotel_rating"/>

View file

@ -80,14 +80,18 @@
<include layout="@layout/place_page_opening_hours"/>
<include layout="@layout/place_page_latlon"/>
<include layout="@layout/place_page_wifi"/>
<include layout="@layout/place_page_operator"/>
<include layout="@layout/place_page_cuisine"/>
<include layout="@layout/place_page_latlon"/>
<include layout="@layout/divider_horizontal"/>
<include layout="@layout/place_page_taxi"/>
<include layout="@layout/place_page_hotel_nearby"/>
<include layout="@layout/place_page_hotel_rating"/>

View file

@ -41,14 +41,18 @@
<include layout="@layout/place_page_email"/>
<include layout="@layout/place_page_latlon"/>
<include layout="@layout/place_page_wifi"/>
<include layout="@layout/place_page_operator"/>
<include layout="@layout/place_page_cuisine"/>
<include layout="@layout/place_page_latlon"/>
<include layout="@layout/divider_horizontal"/>
<include layout="@layout/place_page_taxi"/>
<include layout="@layout/place_page_hotel_nearby"/>
<include layout="@layout/place_page_hotel_rating"/>

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ll__place_page_taxi"
style="@style/PlacePageItemFrame"
android:paddingTop="@dimen/placepage_taxi_padding_vert"
android:paddingBottom="@dimen/placepage_taxi_padding_vert"
android:clickable="false">
<ImageView
android:id="@+id/iv__place_page_taxi"
style="@style/PlacePageMetadataIcon"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="@drawable/ic_placepage_taxi"/>
<TextView
android:id="@+id/tv__place_page_taxi"
style="@style/PlacePageMetadataText"
android:layout_toRightOf="@id/iv__place_page_taxi"
android:layout_toEndOf="@id/iv__place_page_taxi"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:text="@string/uber"/>
<TextView
android:id="@+id/tv__place_page_order_taxi"
style="@style/PlacePageMetadataText.Button"
android:layout_centerVertical="true"
android:background="?selectableItemBackgroundBorderless"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:text="@string/taxi_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="@dimen/placepage_taxi_button_min_width"
android:paddingLeft="@dimen/margin_half"
android:paddingRight="@dimen/margin_half"
android:paddingTop="@dimen/placepage_taxi_button_padding_vert"
android:paddingBottom="@dimen/placepage_taxi_button_padding_vert"/>
</RelativeLayout>

View file

@ -166,4 +166,8 @@
<dimen name="placepage_banner_icon_size">22dp</dimen>
<dimen name="placepage_banner_icon_size_full">40dp</dimen>
<!-- Place page taxi-->
<dimen name="placepage_taxi_button_min_width">96dp</dimen>
<dimen name="placepage_taxi_padding_vert">14dp</dimen>
<dimen name="placepage_taxi_button_padding_vert">10dp</dimen>
</resources>

View file

@ -1063,4 +1063,6 @@
<string name="whatsnew_font_size">Font Size</string>
<!-- january -->
<string name="whatsnew_font_size_text">Labels on the map can be made bigger.</string>
<!-- "Translation is no needed, because it's a company name" -->
<string name="uber">Uber</string>
</resources>

View file

@ -1261,9 +1261,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
final RoutePoint from = data.mPoints[0];
final RoutePoint to = data.mPoints[1];
RoutingController.get().prepare(new MapObject(MapObject.API_POINT, from.mName, "", "",
from.mLat, from.mLon, "", Banner.EMPTY),
from.mLat, from.mLon, "", Banner.EMPTY, false),
new MapObject(MapObject.API_POINT, to.mName, "", "",
to.mLat, to.mLon, "", Banner.EMPTY));
to.mLat, to.mLon, "", Banner.EMPTY, false));
return true;
}

View file

@ -20,9 +20,9 @@ public class Bookmark extends MapObject
private double mMerY;
Bookmark(@IntRange(from = 0) int categoryId, @IntRange(from = 0) int bookmarkId, String title,
@Nullable Banner banner)
@Nullable Banner banner, boolean reachableByTaxi)
{
super(BOOKMARK, title, "", "", 0, 0, "", banner);
super(BOOKMARK, title, "", "", 0, 0, "", banner, reachableByTaxi);
mCategoryId = categoryId;
mBookmarkId = bookmarkId;
@ -36,8 +36,8 @@ public class Bookmark extends MapObject
mMerX = ll.x;
mMerY = ll.y;
mLat = Math.toDegrees(2.0 * Math.atan(Math.exp(Math.toRadians(ll.y))) - Math.PI / 2.0);
mLon = ll.x;
setLat(Math.toDegrees(2.0 * Math.atan(Math.exp(Math.toRadians(ll.y))) - Math.PI / 2.0));
setLon(ll.x);
}
@Override

View file

@ -27,23 +27,27 @@ public class MapObject implements Parcelable
@MapObjectType protected final int mMapObjectType;
protected String mTitle;
protected String mSubtitle;
protected double mLat;
protected double mLon;
protected String mAddress;
protected Metadata mMetadata;
protected String mApiId;
private String mSubtitle;
private double mLat;
private double mLon;
private String mAddress;
private Metadata mMetadata;
private String mApiId;
@Nullable
protected Banner mBanner;
private Banner mBanner;
private boolean mReachableByTaxi;
public MapObject(@MapObjectType int mapObjectType, String title, String subtitle, String address,
double lat, double lon, String apiId, @Nullable Banner banner)
double lat, double lon, String apiId, @Nullable Banner banner,
boolean reachableByTaxi)
{
this(mapObjectType, title, subtitle, address, lat, lon, new Metadata(), apiId, banner);
this(mapObjectType, title, subtitle, address, lat, lon, new Metadata(), apiId, banner,
reachableByTaxi);
}
public MapObject(@MapObjectType int mapObjectType, String title, String subtitle, String address,
double lat, double lon, Metadata metadata, String apiId, @Nullable Banner banner)
double lat, double lon, Metadata metadata, String apiId, @Nullable Banner banner,
boolean reachableByTaxi)
{
mMapObjectType = mapObjectType;
mTitle = title;
@ -54,6 +58,7 @@ public class MapObject implements Parcelable
mMetadata = metadata;
mApiId = apiId;
mBanner = banner;
mReachableByTaxi = reachableByTaxi;
}
protected MapObject(Parcel source)
@ -67,7 +72,8 @@ public class MapObject implements Parcelable
source.readDouble(), // Lon
(Metadata) source.readParcelable(Metadata.class.getClassLoader()),
source.readString(), // ApiId;
(Banner) source.readParcelable(Banner.class.getClassLoader()));
(Banner) source.readParcelable(Banner.class.getClassLoader()),
source.readByte() != 0); // ReachableByTaxi
}
/**
@ -138,6 +144,11 @@ public class MapObject implements Parcelable
return mBanner;
}
public boolean isReachableByTaxi()
{
return mReachableByTaxi;
}
public void setLat(double lat)
{
mLat = lat;
@ -202,6 +213,7 @@ public class MapObject implements Parcelable
dest.writeParcelable(mMetadata, 0);
dest.writeString(mApiId);
dest.writeParcelable(mBanner, 0);
dest.writeByte((byte) (mReachableByTaxi ? 1 : 0));
}
public static final Creator<MapObject> CREATOR = new Creator<MapObject>()

View file

@ -305,7 +305,7 @@ public enum LocationHelper
if (mMyPosition == null)
mMyPosition = new MapObject(MapObject.MY_POSITION, "", "", "", mSavedLocation.getLatitude(),
mSavedLocation.getLongitude(), "", Banner.EMPTY);
mSavedLocation.getLongitude(), "", Banner.EMPTY, false);
return mMyPosition;
}

View file

@ -340,14 +340,21 @@ public class RoutingController
return;
}
if (startPoint != null && endPoint != null)
mLastRouterType = Framework.nativeGetBestRouter(startPoint.getLat(), startPoint.getLon(),
endPoint.getLat(), endPoint.getLon());
prepare(startPoint, endPoint, mLastRouterType);
}
public void prepare(@Nullable MapObject startPoint, @Nullable MapObject endPoint,
@Framework.RouterType int routerType)
{
cancel();
mStartPoint = startPoint;
mEndPoint = endPoint;
setState(State.PREPARE);
if (mStartPoint != null && mEndPoint != null)
mLastRouterType = Framework.nativeGetBestRouter(mStartPoint.getLat(), mStartPoint.getLon(),
mEndPoint.getLat(), mEndPoint.getLon());
mLastRouterType = routerType;
Framework.nativeSetRouter(mLastRouterType);
if (mContainer != null)

View file

@ -353,7 +353,7 @@ public class SearchFragment extends BaseMwmFragment
{
//noinspection ConstantConditions
final MapObject point = new MapObject(MapObject.SEARCH, result.name,
result.description.featureType, "", result.lat, result.lon, "", Banner.EMPTY);
result.description.featureType, "", result.lat, result.lon, "", Banner.EMPTY, false);
RoutingController.get().onPoiSelected(point);
}

View file

@ -68,6 +68,7 @@ import com.mapswithme.maps.widget.ObservableScrollView;
import com.mapswithme.maps.widget.ScrollViewShadowController;
import com.mapswithme.maps.widget.recycler.DividerItemDecoration;
import com.mapswithme.maps.widget.recycler.RecyclerClickListener;
import com.mapswithme.util.ConnectionState;
import com.mapswithme.util.Graphics;
import com.mapswithme.util.StringUtils;
import com.mapswithme.util.ThemeUtils;
@ -138,6 +139,7 @@ public class PlacePageView extends RelativeLayout
private View mWiki;
private View mEntrance;
private TextView mTvEntrance;
private View mTaxi;
private View mEditPlace;
private View mAddOrganisation;
private View mAddPlace;
@ -304,6 +306,9 @@ public class PlacePageView extends RelativeLayout
mWiki.setOnClickListener(this);
mEntrance = mDetails.findViewById(R.id.ll__place_entrance);
mTvEntrance = (TextView) mEntrance.findViewById(R.id.tv__place_entrance);
mTaxi = mDetails.findViewById(R.id.ll__place_page_taxi);
TextView orderTaxi = (TextView) mTaxi.findViewById(R.id.tv__place_page_order_taxi);
orderTaxi.setOnClickListener(this);
mEditPlace = mDetails.findViewById(R.id.ll__place_editor);
mEditPlace.setOnClickListener(this);
mAddOrganisation = mDetails.findViewById(R.id.ll__add_organisation);
@ -988,9 +993,16 @@ public class PlacePageView extends RelativeLayout
refreshMetadataOrHide(mMapObject.getMetadata(Metadata.MetadataType.FMD_FLATS), mEntrance, mTvEntrance);
refreshOpeningHours();
if (RoutingController.get().isNavigating() ||
RoutingController.get().isPlanning() ||
MapManager.nativeIsLegacyMode())
boolean showTaxiOffer = mMapObject.isReachableByTaxi() &&
LocationHelper.INSTANCE.getMyPosition() != null &&
ConnectionState.isConnected();
UiUtils.showIf(showTaxiOffer, mTaxi);
boolean inRouting = RoutingController.get().isNavigating() ||
RoutingController.get().isPlanning();
if (inRouting || MapManager.nativeIsLegacyMode())
{
UiUtils.hide(mEditPlace, mAddOrganisation, mAddPlace);
}
@ -1322,6 +1334,12 @@ public class PlacePageView extends RelativeLayout
mSponsored.mRating, mReviewAdapter.getItems()
.size(), mSponsored.mUrl);
break;
case R.id.tv__place_page_order_taxi:
RoutingController.get().prepare(LocationHelper.INSTANCE.getMyPosition(), mMapObject,
Framework.ROUTER_TYPE_TAXI);
hide();
Framework.nativeDeactivatePopup();
break;
}
}

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "يمكن جعل التسميات على الخريطة أكبر.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Popisky na mapě lze zvětšit.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Etiketterne på kortet kan gøres større.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Bezeichnungen auf der Karte können vergrößert werden.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Labels on the map can be made bigger.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Labels on the map can be made bigger.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Las etiquetas del mapa pueden ampliarse.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Kartan selityksiä voi suurentaa.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Les étiquettes sur la carte peuvent être agrandies.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "A térképen a címkék lehetnek nagyobbak.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Label pada peta bisa dijadikan lebih besar.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Le etichette sulla mappa possono essere ingrandite.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "地図上のラベルを大きくすることができます。";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "지도의 레이블을 더 크게 할 수 있습니다.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Etiketter på kartet kan gjøres større.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Labels op de map kunnen groter gemaakt worden.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Etykiety na mapie dają się powiększyć.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "É possível aumentar o tamanho das letras do mapa.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Etichetele de pe hartă pot fi făcute mai mari.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Названия объектов на карте теперь можно сделать крупнее.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Nápisy na mape je možné zväčšiť.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Etiketter på kartan kan göras större.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "ป้ายบนแผนที่สามารถทำให้ใหญ่ขึ้นได้";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Harita üzerindeki etiketler daha büyük hale getirilebilir.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Можливість збільшення розміру написів на карті.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "Các nhãn mác trên bản đồ có thể được phóng to hơn.";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "可以增大地图上的标签。";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -1791,3 +1791,6 @@
/* january */
"whatsnew_font_size_text" = "可將地圖上的標籤變大。";
/* "Translation is no needed, because it's a company name" */
"uber" = "Uber";

View file

@ -22067,3 +22067,7 @@
hi = नक्शे पर लेबलों को बड़ा किया जा सकता है।
pt-BR = Os rótulos no mapa podem ser ampliados.
sk = Nápisy na mape je možné zväčšiť.
[uber]
comment = "Translation is no needed, because it's a company name"
en = Uber