forked from organicmaps/organicmaps
[android] Added booking search botton for non sponsored hotels
This commit is contained in:
parent
74d5094b72
commit
1f6f9712a5
8 changed files with 68 additions and 22 deletions
|
@ -38,19 +38,21 @@ jobject CreateBanner(JNIEnv * env, string const & id, jint type)
|
|||
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, jobjectArray jbanners,
|
||||
bool isReachableByTaxi)
|
||||
bool isReachableByTaxi, string const & bookingSearchUrl)
|
||||
{
|
||||
// public MapObject(@MapObjectType int mapObjectType, String title, String subtitle, double lat,
|
||||
// double lon, String address, String apiId, @NonNull Banner banner, boolean reachableByTaxi)
|
||||
// double lon, String address, String apiId, @NonNull Banner banner, boolean reachableByTaxi,
|
||||
// @Nullable String bookingSearchUrl)
|
||||
static jmethodID const ctorId =
|
||||
jni::GetConstructorID(env, g_mapObjectClazz,
|
||||
"(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;DDLjava/lang/"
|
||||
"String;[Lcom/mapswithme/maps/ads/Banner;Z)V");
|
||||
"String;[Lcom/mapswithme/maps/ads/Banner;ZLjava/lang/String;)V");
|
||||
|
||||
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), jbanners, isReachableByTaxi);
|
||||
jni::ToJavaString(env, apiId), jbanners, isReachableByTaxi,
|
||||
jni::ToJavaString(env, bookingSearchUrl));
|
||||
|
||||
InjectMetadata(env, g_mapObjectClazz, mapObject, metadata);
|
||||
return mapObject;
|
||||
|
@ -66,9 +68,10 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
|||
{
|
||||
// public Bookmark(@IntRange(from = 0) int categoryId, @IntRange(from = 0) int bookmarkId,
|
||||
// String name, @Nullable String objectTitle, @NonNull Banner banner, boolean reachableByTaxi)
|
||||
static jmethodID const ctorId = jni::GetConstructorID(
|
||||
env, g_bookmarkClazz,
|
||||
"(IILjava/lang/String;Ljava/lang/String;[Lcom/mapswithme/maps/ads/Banner;Z)V");
|
||||
static jmethodID const ctorId =
|
||||
jni::GetConstructorID(env, g_bookmarkClazz,
|
||||
"(IILjava/lang/String;Ljava/lang/String;[Lcom/mapswithme/maps/ads/"
|
||||
"Banner;ZLjava/lang/String;)V");
|
||||
|
||||
auto const & bac = info.GetBookmarkAndCategory();
|
||||
BookmarkCategory * cat = g_framework->NativeFramework()->GetBmCategory(bac.m_categoryIndex);
|
||||
|
@ -77,10 +80,11 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
|||
|
||||
jni::TScopedLocalRef jName(env, jni::ToJavaString(env, data.GetName()));
|
||||
jni::TScopedLocalRef jTitle(env, jni::ToJavaString(env, info.GetTitle()));
|
||||
jni::TScopedLocalRef jBookingSearchUrl(env, jni::ToJavaString(env, info.GetBookingSearchUrl()));
|
||||
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(), jTitle.get(),
|
||||
jbanners, info.IsReachableByTaxi());
|
||||
jbanners, info.IsReachableByTaxi(), jBookingSearchUrl.get());
|
||||
if (info.IsFeature())
|
||||
InjectMetadata(env, g_mapObjectClazz, mapObject, info.GetMetadata());
|
||||
return mapObject;
|
||||
|
@ -94,17 +98,18 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
|||
// TODO(yunikkk): Should we pass localized strings here and in other methods as byte arrays?
|
||||
if (info.IsMyPosition())
|
||||
return CreateMapObject(env, kMyPosition, info.GetTitle(), info.GetSubtitle(), ll.lat, ll.lon,
|
||||
address.FormatAddress(), {}, "", jbanners, info.IsReachableByTaxi());
|
||||
address.FormatAddress(), {}, "", jbanners, info.IsReachableByTaxi(),
|
||||
info.GetBookingSearchUrl());
|
||||
|
||||
if (info.HasApiUrl())
|
||||
return CreateMapObject(env, kApiPoint, info.GetTitle(), info.GetSubtitle(), ll.lat, ll.lon,
|
||||
address.FormatAddress(), info.GetMetadata(), info.GetApiUrl(),
|
||||
jbanners, info.IsReachableByTaxi());
|
||||
address.FormatAddress(), info.GetMetadata(), info.GetApiUrl(), jbanners,
|
||||
info.IsReachableByTaxi(), info.GetBookingSearchUrl());
|
||||
|
||||
return CreateMapObject(env, kPoi, info.GetTitle(), info.GetSubtitle(), ll.lat, ll.lon,
|
||||
address.FormatAddress(),
|
||||
info.IsFeature() ? info.GetMetadata() : Metadata(), "", jbanners,
|
||||
info.IsReachableByTaxi());
|
||||
info.IsReachableByTaxi(), info.GetBookingSearchUrl());
|
||||
}
|
||||
|
||||
jobjectArray ToBannersArray(JNIEnv * env, vector<ads::Banner> const & banners)
|
||||
|
|
|
@ -1390,9 +1390,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, "", null, false),
|
||||
from.mLat, from.mLon, "", null, false, ""),
|
||||
new MapObject(MapObject.API_POINT, to.mName, "", "",
|
||||
to.mLat, to.mLon, "", null, false));
|
||||
to.mLat, to.mLon, "", null, false, ""));
|
||||
return true;
|
||||
case ParsedUrlMwmRequest.RESULT_SEARCH:
|
||||
final ParsedSearchRequest request = Framework.nativeGetParsedSearchRequest();
|
||||
|
|
|
@ -24,9 +24,10 @@ public class Bookmark extends MapObject
|
|||
private final String mObjectTitle;
|
||||
|
||||
Bookmark(@IntRange(from = 0) int categoryId, @IntRange(from = 0) int bookmarkId, String title,
|
||||
@Nullable String objectTitle, @Nullable Banner[] banners, boolean reachableByTaxi)
|
||||
@Nullable String objectTitle, @Nullable Banner[] banners, boolean reachableByTaxi,
|
||||
@Nullable String bookingSearchUrl)
|
||||
{
|
||||
super(BOOKMARK, title, "", "", 0, 0, "", banners, reachableByTaxi);
|
||||
super(BOOKMARK, title, "", "", 0, 0, "", banners, reachableByTaxi, bookingSearchUrl);
|
||||
|
||||
mCategoryId = categoryId;
|
||||
mBookmarkId = bookmarkId;
|
||||
|
|
|
@ -40,18 +40,20 @@ public class MapObject implements Parcelable
|
|||
@Nullable
|
||||
private Banner[] mBanners;
|
||||
private boolean mReachableByTaxi;
|
||||
@Nullable
|
||||
private String mBookingSearchUrl;
|
||||
|
||||
public MapObject(@MapObjectType int mapObjectType, String title, String subtitle, String address,
|
||||
double lat, double lon, String apiId, @Nullable Banner[] banners,
|
||||
boolean reachableByTaxi)
|
||||
boolean reachableByTaxi, @Nullable String bookingSearchUrl)
|
||||
{
|
||||
this(mapObjectType, title, subtitle, address, lat, lon, new Metadata(), apiId, banners,
|
||||
reachableByTaxi);
|
||||
reachableByTaxi, bookingSearchUrl);
|
||||
}
|
||||
|
||||
public MapObject(@MapObjectType int mapObjectType, String title, String subtitle, String address,
|
||||
double lat, double lon, Metadata metadata, String apiId, @Nullable Banner[] banners,
|
||||
boolean reachableByTaxi)
|
||||
boolean reachableByTaxi, @Nullable String bookingSearchUrl)
|
||||
{
|
||||
mMapObjectType = mapObjectType;
|
||||
mTitle = title;
|
||||
|
@ -63,6 +65,7 @@ public class MapObject implements Parcelable
|
|||
mApiId = apiId;
|
||||
mBanners = banners;
|
||||
mReachableByTaxi = reachableByTaxi;
|
||||
mBookingSearchUrl = bookingSearchUrl;
|
||||
}
|
||||
|
||||
protected MapObject(Parcel source)
|
||||
|
@ -77,7 +80,8 @@ public class MapObject implements Parcelable
|
|||
(Metadata) source.readParcelable(Metadata.class.getClassLoader()),
|
||||
source.readString(), // ApiId;
|
||||
null, // mBanners
|
||||
source.readByte() != 0); // ReachableByTaxi
|
||||
source.readByte() != 0, // ReachableByTaxi
|
||||
source.readString()); // BookingSearchUrl
|
||||
mBanners = readBanners(source);
|
||||
}
|
||||
|
||||
|
@ -203,6 +207,12 @@ public class MapObject implements Parcelable
|
|||
return object != null && object.getMapObjectType() == type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getBookingSearchUrl()
|
||||
{
|
||||
return mBookingSearchUrl;
|
||||
}
|
||||
|
||||
protected static MapObject readFromParcel(Parcel source)
|
||||
{
|
||||
@MapObjectType int type = source.readInt();
|
||||
|
@ -232,6 +242,7 @@ public class MapObject implements Parcelable
|
|||
dest.writeString(mApiId);
|
||||
dest.writeTypedArray(mBanners, 0);
|
||||
dest.writeByte((byte) (mReachableByTaxi ? 1 : 0));
|
||||
dest.writeString(mBookingSearchUrl);
|
||||
}
|
||||
|
||||
public static final Creator<MapObject> CREATOR = new Creator<MapObject>()
|
||||
|
|
|
@ -219,7 +219,7 @@ public enum LocationHelper
|
|||
|
||||
if (mMyPosition == null)
|
||||
mMyPosition = new MapObject(MapObject.MY_POSITION, "", "", "", mSavedLocation.getLatitude(),
|
||||
mSavedLocation.getLongitude(), "", null, false);
|
||||
mSavedLocation.getLongitude(), "", null, false, "");
|
||||
|
||||
return mMyPosition;
|
||||
}
|
||||
|
|
|
@ -467,7 +467,7 @@ public class SearchFragment extends BaseMwmFragment
|
|||
{
|
||||
//noinspection ConstantConditions
|
||||
final MapObject point = new MapObject(MapObject.SEARCH, result.name,
|
||||
result.description.featureType, "", result.lat, result.lon, "", null, false);
|
||||
result.description.featureType, "", result.lat, result.lon, "", null, false, "");
|
||||
RoutingController.get().onPoiSelected(point);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,21 @@ final class PlacePageButtons
|
|||
}
|
||||
},
|
||||
|
||||
BOOKING_SEARCH
|
||||
{
|
||||
@Override
|
||||
int getTitle()
|
||||
{
|
||||
return R.string.book_button;
|
||||
}
|
||||
|
||||
@Override
|
||||
int getIcon()
|
||||
{
|
||||
return R.drawable.ic_menu_search;
|
||||
}
|
||||
},
|
||||
|
||||
OPENTABLE
|
||||
{
|
||||
@Override
|
||||
|
@ -203,6 +218,7 @@ final class PlacePageButtons
|
|||
|
||||
preserveRoutingButtons(res, Item.CALL);
|
||||
preserveRoutingButtons(res, Item.BOOKING);
|
||||
preserveRoutingButtons(res, Item.BOOKING_SEARCH);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
|
@ -403,6 +403,11 @@ public class PlacePageView extends RelativeLayout
|
|||
color = Color.WHITE;
|
||||
break;
|
||||
|
||||
case BOOKING_SEARCH:
|
||||
frame.setBackgroundResource(R.drawable.button_booking);
|
||||
color = Color.WHITE;
|
||||
break;
|
||||
|
||||
case OPENTABLE:
|
||||
frame.setBackgroundResource(R.drawable.button_opentable);
|
||||
color = Color.WHITE;
|
||||
|
@ -501,6 +506,11 @@ public class PlacePageView extends RelativeLayout
|
|||
onSponsoredClick(true /* book */, false);
|
||||
break;
|
||||
|
||||
case BOOKING_SEARCH:
|
||||
if (mMapObject != null)
|
||||
followUrl(mMapObject.getBookingSearchUrl());
|
||||
break;
|
||||
|
||||
case CALL:
|
||||
Utils.callPhone(getContext(), mTvPhone.getText().toString());
|
||||
break;
|
||||
|
@ -1336,6 +1346,9 @@ public class PlacePageView extends RelativeLayout
|
|||
}
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(mapObject.getBookingSearchUrl()))
|
||||
buttons.add(PlacePageButtons.Item.BOOKING_SEARCH);
|
||||
|
||||
if (mapObject.hasPhoneNumber())
|
||||
buttons.add(PlacePageButtons.Item.CALL);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue