Mapsme 5159 disable ugc (#6759)

* [android] Added UGC flag and refactored MapObject building code in Java

* [android] Added passing the 'shouldsShowUGC' flag through JNI
This commit is contained in:
Aleksandr Zatsepin 2017-08-01 15:39:08 +03:00 committed by Roman Kuznetsov
parent 94fcfc413a
commit 4514c4c9e3
8 changed files with 54 additions and 38 deletions

View file

@ -41,7 +41,7 @@ jobject CreateMapObject(JNIEnv * env, string const & mwmName, int64_t mwmVersion
double lon, string const & address, Metadata const & metadata,
string const & apiId, jobjectArray jbanners, jintArray jTaxiTypes,
string const & bookingSearchUrl, jobject const & localAdInfo,
jobject const & routingPointInfo, bool isExtendedView)
jobject const & routingPointInfo, bool isExtendedView, bool shouldShowUGC)
{
// public MapObject(@NonNull FeatureId featureId,
// @MapObjectType int mapObjectType, String title, @Nullable String
@ -56,7 +56,7 @@ jobject CreateMapObject(JNIEnv * env, string const & mwmName, int64_t mwmVersion
"String;Ljava/lang/String;Ljava/lang/String;DDLjava/lang/"
"String;[Lcom/mapswithme/maps/ads/Banner;[ILjava/lang/String;"
"Lcom/mapswithme/maps/ads/LocalAdInfo;"
"Lcom/mapswithme/maps/routing/RoutePointInfo;Z)V");
"Lcom/mapswithme/maps/routing/RoutePointInfo;ZZ)V");
//public FeatureId(@NonNull String mwmName, long mwmVersion, int featureIndex)
static jmethodID const featureCtorId =
jni::GetConstructorID(env, g_featureIdClazz, "(Ljava/lang/String;JI)V");
@ -75,7 +75,7 @@ jobject CreateMapObject(JNIEnv * env, string const & mwmName, int64_t mwmVersion
env->NewObject(g_mapObjectClazz, ctorId, jFeatureId.get(), mapObjectType, jTitle.get(),
jSecondaryTitle.get(), jSubtitle.get(), jAddress.get(), lat, lon, jApiId.get(),
jbanners, jTaxiTypes, jBookingSearchUrl.get(), localAdInfo, routingPointInfo,
static_cast<jboolean>(isExtendedView));
static_cast<jboolean>(isExtendedView), static_cast<jboolean>(shouldShowUGC));
InjectMetadata(env, g_mapObjectClazz, mapObject, metadata);
return mapObject;
@ -109,7 +109,7 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
"Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;"
"[Lcom/mapswithme/maps/ads/Banner;[ILjava/lang/String;"
"Lcom/mapswithme/maps/ads/LocalAdInfo;"
"Lcom/mapswithme/maps/routing/RoutePointInfo;Z)V");
"Lcom/mapswithme/maps/routing/RoutePointInfo;ZZ)V");
// public FeatureId(@NonNull String mwmName, long mwmVersion, int featureIndex)
static jmethodID const featureCtorId =
jni::GetConstructorID(env, g_featureIdClazz, "(Ljava/lang/String;JI)V");
@ -132,7 +132,7 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
g_bookmarkClazz, ctorId, jFeatureId.get(), static_cast<jint>(bac.m_categoryIndex),
static_cast<jint>(bac.m_bookmarkIndex), jTitle.get(), jSecondaryTitle.get(), jSubtitle.get(),
jAddress.get(), jbanners.get(), jTaxiTypes.get(), jBookingSearchUrl.get(),
localAdInfo.get(), routingPointInfo.get(), info.IsPreviewExtended());
localAdInfo.get(), routingPointInfo.get(), info.IsPreviewExtended(), info.ShouldShowUGC());
if (info.IsFeature())
InjectMetadata(env, g_mapObjectClazz, mapObject, info.GetMetadata());
@ -149,7 +149,7 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
info.GetSecondaryTitle(), info.GetSubtitle(), ll.lat, ll.lon,
info.GetAddress(), {}, "", jbanners.get(), jTaxiTypes.get(),
info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get(),
info.IsPreviewExtended());
info.IsPreviewExtended(), info.ShouldShowUGC());
}
if (info.HasApiUrl())
@ -158,7 +158,8 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
env, info.GetID().GetMwmName(), info.GetID().GetMwmVersion(), info.GetID().m_index,
kApiPoint, info.GetTitle(), info.GetSecondaryTitle(), info.GetSubtitle(), ll.lat, ll.lon,
info.GetAddress(), info.GetMetadata(), info.GetApiUrl(), jbanners.get(), jTaxiTypes.get(),
info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get(), info.IsPreviewExtended());
info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get(), info.IsPreviewExtended(),
info.ShouldShowUGC());
}
return CreateMapObject(
@ -166,7 +167,7 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
info.GetTitle(), info.GetSecondaryTitle(), info.GetSubtitle(), ll.lat, ll.lon,
info.GetAddress(), info.IsFeature() ? info.GetMetadata() : Metadata(), "", jbanners.get(),
jTaxiTypes.get(), info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get(),
info.IsPreviewExtended());
info.IsPreviewExtended(), info.ShouldShowUGC());
}
jobjectArray ToBannersArray(JNIEnv * env, vector<ads::Banner> const & banners)

View file

@ -1514,13 +1514,10 @@ public class MwmActivity extends BaseMwmFragmentActivity
RoutingController.get().setRouterType(data.mRouterType);
final RoutePoint from = data.mPoints[0];
final RoutePoint to = data.mPoints[1];
RoutingController.get().prepare(new MapObject(FeatureId.EMPTY, MapObject.API_POINT, from.mName,
"", "", "", from.mLat, from.mLon, "", null,
null, "", null, null, false /* isExtendedView */),
new MapObject(FeatureId.EMPTY, MapObject.API_POINT, to.mName,
"", "", "", to.mLat, to.mLon, "", null,
null, "", null, null, false /* isExtendedView */),
true);
RoutingController.get().prepare(MapObject.createMapObject(FeatureId.EMPTY, MapObject.API_POINT,
from.mName, "", from.mLat, from.mLon),
MapObject.createMapObject(FeatureId.EMPTY, MapObject.API_POINT,
to.mName, "", to.mLat, to.mLon), true);
return true;
case ParsedUrlMwmRequest.RESULT_SEARCH:
final ParsedSearchRequest request = Framework.nativeGetParsedSearchRequest();
@ -2254,9 +2251,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
@NonNull
private static MapObject fromLatLon(double lat, double lon)
{
return new MapObject(FeatureId.EMPTY, MapObject.API_POINT, "",
"", "", "", lat, lon, "", null,
null, "", null, null, false /* isExtendedView */);
return MapObject.createMapObject(FeatureId.EMPTY, MapObject.API_POINT, "", "", lat, lon);
}
BuildRouteTask(double latTo, double lonTo)

View file

@ -28,11 +28,12 @@ public class Bookmark extends MapObject
@Nullable String subtitle, @Nullable String address, @Nullable Banner[] banners,
@TaxiManager.TaxiType int[] reachableByTaxiTypes,
@Nullable String bookingSearchUrl, @Nullable LocalAdInfo localAdInfo,
@Nullable RoutePointInfo routePointInfo, boolean isExtendedView)
@Nullable RoutePointInfo routePointInfo, boolean isExtendedView,
boolean shouldShowUGC)
{
super(featureId, BOOKMARK, title, secondaryTitle, subtitle, address, 0, 0, "",
banners, reachableByTaxiTypes, bookingSearchUrl, localAdInfo, routePointInfo,
isExtendedView);
isExtendedView, shouldShowUGC);
mCategoryId = categoryId;
mBookmarkId = bookmarkId;

View file

@ -57,17 +57,19 @@ public class MapObject implements Parcelable
@Nullable
private RoutePointInfo mRoutePointInfo;
private boolean mExtendedView;
private boolean mShouldShowUGC;
public MapObject(@NonNull FeatureId featureId, @MapObjectType int mapObjectType, String title,
@Nullable String secondaryTitle, String subtitle, String address,
double lat, double lon, String apiId,
@Nullable Banner[] banners, @Nullable @TaxiManager.TaxiType int[] types,
@Nullable String bookingSearchUrl, @Nullable LocalAdInfo localAdInfo,
@Nullable RoutePointInfo routePointInfo, boolean isExtendedView)
@Nullable RoutePointInfo routePointInfo, boolean isExtendedView,
boolean shouldShowUGC)
{
this(featureId, mapObjectType, title, secondaryTitle,
subtitle, address, lat, lon, new Metadata(), apiId, banners,
types, bookingSearchUrl, localAdInfo, routePointInfo, isExtendedView);
types, bookingSearchUrl, localAdInfo, routePointInfo, isExtendedView, shouldShowUGC);
}
public MapObject(@NonNull FeatureId featureId, @MapObjectType int mapObjectType,
@ -75,7 +77,8 @@ public class MapObject implements Parcelable
String subtitle, String address, double lat, double lon, Metadata metadata,
String apiId, @Nullable Banner[] banners, @Nullable @TaxiManager.TaxiType int[] taxiTypes,
@Nullable String bookingSearchUrl, @Nullable LocalAdInfo localAdInfo,
@Nullable RoutePointInfo routePointInfo, boolean isExtendedView)
@Nullable RoutePointInfo routePointInfo, boolean isExtendedView,
boolean shouldShowUGC)
{
mFeatureId = featureId;
mMapObjectType = mapObjectType;
@ -91,6 +94,7 @@ public class MapObject implements Parcelable
mLocalAdInfo = localAdInfo;
mRoutePointInfo = routePointInfo;
mExtendedView = isExtendedView;
mShouldShowUGC = shouldShowUGC;
if (banners != null)
mBanners = new ArrayList<>(Arrays.asList(banners));
if (taxiTypes != null)
@ -119,12 +123,23 @@ public class MapObject implements Parcelable
source.readString(), // BookingSearchUrl
(LocalAdInfo) source.readParcelable(LocalAdInfo.class.getClassLoader()), // LocalAdInfo
(RoutePointInfo) source.readParcelable(RoutePointInfo.class.getClassLoader()), // RoutePointInfo
source.readInt() == 1);
source.readInt() == 1, // mExtendedView
source.readInt() == 1); // mShouldShowUGC
mBanners = readBanners(source);
mReachableByTaxiTypes = readTaxiTypes(source);
}
@NonNull
public static MapObject createMapObject(@NonNull FeatureId featureId, @MapObjectType int mapObjectType,
@NonNull String title, @NonNull String subtitle, double lat, double lon)
{
return new MapObject(featureId, mapObjectType, title,
"", subtitle, "", lat, lon, "", null,
null, "", null, null, false /* isExtendedView */,
false /* shouldShowUGC */);
}
@Nullable
private List<Banner> readBanners(@NonNull Parcel source)
{
@ -282,6 +297,11 @@ public class MapObject implements Parcelable
return mExtendedView;
}
public boolean shouldShowUGC()
{
return mShouldShowUGC;
}
@NonNull
public FeatureId getFeatureId()
{
@ -322,6 +342,7 @@ public class MapObject implements Parcelable
dest.writeParcelable(mLocalAdInfo, 0);
dest.writeParcelable(mRoutePointInfo, 0);
dest.writeInt(mExtendedView ? 1 : 0);
dest.writeInt(mShouldShowUGC ? 1 : 0);
dest.writeTypedList(mBanners);
dest.writeList(mReachableByTaxiTypes);
}

View file

@ -215,9 +215,8 @@ public enum LocationHelper
return null;
if (mMyPosition == null)
mMyPosition = new MapObject(FeatureId.EMPTY, MapObject.MY_POSITION, "", "", "", "",
mSavedLocation.getLatitude(), mSavedLocation.getLongitude(), "",
null, null, "", null, null, false /* isExtendedView */);
mMyPosition = MapObject.createMapObject(FeatureId.EMPTY, MapObject.MY_POSITION, "", "",
mSavedLocation.getLatitude(), mSavedLocation.getLongitude());
return mMyPosition;
}

View file

@ -524,9 +524,9 @@ public class RoutingController implements TaxiManager.TaxiListener
@NonNull
private MapObject toMapObject(@NonNull RouteMarkData point)
{
return new MapObject(FeatureId.EMPTY, point.mIsMyPosition ? MapObject.MY_POSITION : MapObject.POI,
point.mTitle, null, point.mSubtitle, null, point.mLat, point.mLon, null,
null, null, null, null, null, false /* isExtendedView */);
return MapObject.createMapObject(FeatureId.EMPTY, point.mIsMyPosition ? MapObject.MY_POSITION : MapObject.POI,
point.mTitle == null ? "" : point.mTitle,
point.mSubtitle == null ? "" : point.mSubtitle, point.mLat, point.mLon);
}
public boolean isStopPointAllowed()

View file

@ -465,10 +465,9 @@ public class SearchFragment extends BaseMwmFragment
if (RoutingController.get().isWaitingPoiPick())
{
SearchResult.Description description = result.description;
final MapObject point = new MapObject(FeatureId.EMPTY, MapObject.SEARCH, result.name, "",
description != null ? description.featureType : "", "",
result.lat, result.lon, "", null, null, "", null, null,
false /* isExtendedView */);
final MapObject point = MapObject.createMapObject(FeatureId.EMPTY, MapObject.SEARCH, result.name,
description != null ? description.featureType : "",
result.lat, result.lon);
RoutingController.get().onPoiSelected(point);
}

View file

@ -1298,12 +1298,12 @@ public class PlacePageView extends RelativeLayout
detachCountry();
if (mMapObject != null)
{
// TODO: mock implementation for test only
FeatureId fid = mMapObject.getFeatureId();
if (fid.getFeatureIndex() == 218028)
// TODO: Be careful, shouldShowUgc can return true only when all ui work about UGC is done.
// Now (01.08.2017) UI is not ready for UGC yet.
if (mMapObject.shouldShowUGC())
{
UGC.setListener(this);
UGC.requestUGC(fid);
UGC.requestUGC(mMapObject.getFeatureId());
refreshViews(policy);
return;
}