Mapsme 4968 pp opening for sponsored (#6737)

* [android] Added Details state as initial for sponsored map objects

* [android] Added isExtendedView flag usage to open details mode for PP immediately when it's needed

* [android] Refactored resetting scroll a bit

* [android] Added error statistics for CIAN

* [android] Added whitespace before /* isExtendedView*/ comment
This commit is contained in:
Aleksandr Zatsepin 2017-07-28 11:44:59 +03:00 committed by Arsentiy Milchakov
parent 8a01c5135f
commit 5e357a20c8
10 changed files with 62 additions and 55 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)
jobject const & routingPointInfo, bool isExtendedView)
{
// 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;)V");
"Lcom/mapswithme/maps/routing/RoutePointInfo;Z)V");
//public FeatureId(@NonNull String mwmName, long mwmVersion, int featureIndex)
static jmethodID const featureCtorId =
jni::GetConstructorID(env, g_featureIdClazz, "(Ljava/lang/String;JI)V");
@ -74,7 +74,8 @@ jobject CreateMapObject(JNIEnv * env, string const & mwmName, int64_t mwmVersion
jobject mapObject =
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);
jbanners, jTaxiTypes, jBookingSearchUrl.get(), localAdInfo, routingPointInfo,
static_cast<jboolean>(isExtendedView));
InjectMetadata(env, g_mapObjectClazz, mapObject, metadata);
return mapObject;
@ -108,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;)V");
"Lcom/mapswithme/maps/routing/RoutePointInfo;Z)V");
// public FeatureId(@NonNull String mwmName, long mwmVersion, int featureIndex)
static jmethodID const featureCtorId =
jni::GetConstructorID(env, g_featureIdClazz, "(Ljava/lang/String;JI)V");
@ -131,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());
localAdInfo.get(), routingPointInfo.get(), info.IsPreviewExtended());
if (info.IsFeature())
InjectMetadata(env, g_mapObjectClazz, mapObject, info.GetMetadata());
@ -147,7 +148,8 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
info.GetID().m_index, kMyPosition, info.GetTitle(),
info.GetSecondaryTitle(), info.GetSubtitle(), ll.lat, ll.lon,
info.GetAddress(), {}, "", jbanners.get(), jTaxiTypes.get(),
info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get());
info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get(),
info.IsPreviewExtended());
}
if (info.HasApiUrl())
@ -156,14 +158,15 @@ 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.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get(), info.IsPreviewExtended());
}
return CreateMapObject(
env, info.GetID().GetMwmName(), info.GetID().GetMwmVersion(), info.GetID().m_index, kPoi,
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());
jTaxiTypes.get(), info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get(),
info.IsPreviewExtended());
}
jobjectArray ToBannersArray(JNIEnv * env, vector<ads::Banner> const & banners)

View file

@ -1286,9 +1286,11 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
if (!mPlacePageRestored)
{
mPlacePage.setState(State.PREVIEW);
if (object != null)
{
mPlacePage.setState(object.isExtendedView() ? State.DETAILS : State.PREVIEW);
Framework.logLocalAdsEvent(Framework.LOCAL_ADS_EVENT_OPEN_INFO, object);
}
}
mPlacePageRestored = false;
}
@ -1514,10 +1516,10 @@ public class MwmActivity extends BaseMwmFragmentActivity
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),
null, "", null, null, false /* isExtendedView */),
new MapObject(FeatureId.EMPTY, MapObject.API_POINT, to.mName,
"", "", "", to.mLat, to.mLon, "", null,
null, "", null, null),
null, "", null, null, false /* isExtendedView */),
true);
return true;
case ParsedUrlMwmRequest.RESULT_SEARCH:
@ -2254,7 +2256,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
return new MapObject(FeatureId.EMPTY, MapObject.API_POINT, "",
"", "", "", lat, lon, "", null,
null, "", null, null);
null, "", null, null, false /* isExtendedView */);
}
BuildRouteTask(double latTo, double lonTo)

View file

@ -28,10 +28,11 @@ 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)
@Nullable RoutePointInfo routePointInfo, boolean isExtendedView)
{
super(featureId, BOOKMARK, title, secondaryTitle, subtitle, address, 0, 0, "",
banners, reachableByTaxiTypes, bookingSearchUrl, localAdInfo, routePointInfo);
banners, reachableByTaxiTypes, bookingSearchUrl, localAdInfo, routePointInfo,
isExtendedView);
mCategoryId = categoryId;
mBookmarkId = bookmarkId;

View file

@ -56,17 +56,18 @@ public class MapObject implements Parcelable
private LocalAdInfo mLocalAdInfo;
@Nullable
private RoutePointInfo mRoutePointInfo;
private boolean mExtendedView;
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)
@Nullable RoutePointInfo routePointInfo, boolean isExtendedView)
{
this(featureId, mapObjectType, title, secondaryTitle,
subtitle, address, lat, lon, new Metadata(), apiId, banners,
types, bookingSearchUrl, localAdInfo, routePointInfo);
types, bookingSearchUrl, localAdInfo, routePointInfo, isExtendedView);
}
public MapObject(@NonNull FeatureId featureId, @MapObjectType int mapObjectType,
@ -74,7 +75,7 @@ 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)
@Nullable RoutePointInfo routePointInfo, boolean isExtendedView)
{
mFeatureId = featureId;
mMapObjectType = mapObjectType;
@ -89,6 +90,7 @@ public class MapObject implements Parcelable
mBookingSearchUrl = bookingSearchUrl;
mLocalAdInfo = localAdInfo;
mRoutePointInfo = routePointInfo;
mExtendedView = isExtendedView;
if (banners != null)
mBanners = new ArrayList<>(Arrays.asList(banners));
if (taxiTypes != null)
@ -116,7 +118,8 @@ public class MapObject implements Parcelable
null, // mReachableByTaxiTypes
source.readString(), // BookingSearchUrl
(LocalAdInfo) source.readParcelable(LocalAdInfo.class.getClassLoader()), // LocalAdInfo
(RoutePointInfo) source.readParcelable(RoutePointInfo.class.getClassLoader())); // RoutePointInfo
(RoutePointInfo) source.readParcelable(RoutePointInfo.class.getClassLoader()), // RoutePointInfo
source.readInt() == 1);
mBanners = readBanners(source);
mReachableByTaxiTypes = readTaxiTypes(source);
@ -274,6 +277,11 @@ public class MapObject implements Parcelable
return mRoutePointInfo;
}
public boolean isExtendedView()
{
return mExtendedView;
}
@NonNull
public FeatureId getFeatureId()
{
@ -313,6 +321,7 @@ public class MapObject implements Parcelable
dest.writeString(mBookingSearchUrl);
dest.writeParcelable(mLocalAdInfo, 0);
dest.writeParcelable(mRoutePointInfo, 0);
dest.writeInt(mExtendedView ? 1 : 0);
dest.writeTypedList(mBanners);
dest.writeList(mReachableByTaxiTypes);
}

View file

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

View file

@ -529,7 +529,7 @@ public class RoutingController implements TaxiManager.TaxiListener
{
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);
null, null, null, null, null, false /* isExtendedView */);
}
public boolean isStopPointAllowed()

View file

@ -467,7 +467,8 @@ public class SearchFragment extends BaseMwmFragment
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);
result.lat, result.lon, "", null, null, "", null, null,
false /* isExtendedView */);
RoutingController.get().onPoiSelected(point);
}

View file

@ -148,18 +148,19 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
public void onScroll(int left, int top)
{
super.onScroll(left, top);
if (mCurrentScrollY > 0 && mDetailsScroll.getTranslationY() > 0)
{
if (mState != State.PREVIEW)
mPlacePage.setState(State.HIDDEN);
else
mDetailsScroll.scrollTo(0, 0);
}
resetDetailsScrollIfNeeded();
refreshToolbarVisibility();
notifyProgress();
}
private void resetDetailsScrollIfNeeded()
{
if (mCurrentScrollY > 0 && mDetailsScroll.getTranslationY() > 0)
{
mDetailsScroll.scrollTo(0, 0);
}
}
/**
* @return whether gesture is scrolling of details content(and not dragging PP itself).
*/
@ -465,17 +466,14 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
private void showDetails()
{
final float translation;
if (isDetailContentScrollable())
{
mCurrentAnimator = ValueAnimator.ofFloat(mDetailsScroll.getTranslationY(),
mDetailsScroll.getHeight() - mDetailMaxHeight + mButtons
.getHeight());
}
translation = mDetailMaxHeight - mButtons.getHeight();
else
{
mCurrentAnimator = ValueAnimator.ofFloat(mDetailsScroll.getTranslationY(),
mDetailsScroll.getHeight() - mContentHeight);
}
translation = mContentHeight > mDetailMaxHeight ? mDetailMaxHeight : mContentHeight;
mCurrentAnimator = ValueAnimator.ofFloat(mDetailsScroll.getTranslationY(),
mDetailsScroll.getHeight() - translation);
mCurrentAnimator.addUpdateListener(new UpdateListener());
mCurrentAnimator.addListener(new AnimationListener());
@ -574,11 +572,6 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
mBannerOpenListener = bannerOpenListener;
}
private boolean isOverDetailsState()
{
return mDetailsScroll.getTranslationY() < mScreenHeight - mDetailMaxHeight;
}
private void onContentSizeChanged()
{
if (mIsDragging || mCurrentScrollY > 0)
@ -586,12 +579,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
MapObject object = mPlacePage.getMapObject();
if (object != null)
{
State newState = getState();
if (isOverDetailsState())
newState = State.FULLSCREEN;
onStateChanged(getState(), newState, object.getMapObjectType());
}
onStateChanged(getState(), getState(), object.getMapObjectType());
}
@Override

View file

@ -862,7 +862,7 @@ public class PlacePageView extends RelativeLayout
}
@Override
public void onErrorReceived(int httpCode)
public void onErrorReceived(int errorCode)
{
if (mSponsoredAdapter == null || !mSponsoredAdapter.containsLoading())
{
@ -874,7 +874,7 @@ public class PlacePageView extends RelativeLayout
mSponsoredAdapter.setLoadingError(Sponsored.TYPE_CIAN,
mSponsored != null ? mSponsored.getUrl() : "");
}
Statistics.INSTANCE.trackSponsoredGalleryError(Sponsored.TYPE_CIAN);
Statistics.INSTANCE.trackSponsoredGalleryError(Sponsored.TYPE_CIAN, String.valueOf(errorCode));
}
private void initSponsoredGalleryView()
@ -904,7 +904,8 @@ public class PlacePageView extends RelativeLayout
{
mSponsoredAdapter.setLoadingError(Sponsored.TYPE_VIATOR, cityUrl);
}
Statistics.INSTANCE.trackSponsoredGalleryError(Sponsored.TYPE_VIATOR);
Statistics.INSTANCE.trackSponsoredGalleryError(Sponsored.TYPE_VIATOR,
Statistics.ParamValue.NO_PRODUCTS);
}
else
{
@ -942,7 +943,8 @@ public class PlacePageView extends RelativeLayout
{
mSponsoredAdapter.setLoadingError(Sponsored.TYPE_CIAN, url);
}
Statistics.INSTANCE.trackSponsoredGalleryError(Sponsored.TYPE_CIAN);
Statistics.INSTANCE.trackSponsoredGalleryError(Sponsored.TYPE_CIAN,
Statistics.ParamValue.NO_PRODUCTS);
}
else
{

View file

@ -342,6 +342,7 @@ public enum Statistics
public static final String VIATOR = "Viator.Com";
public static final String GEOCHAT = "Geochat";
public static final String CIAN = "Cian";
public static final String NO_PRODUCTS = "no_products";
}
// Initialized once in constructor and does not change until the process restarts.
@ -746,10 +747,10 @@ public enum Statistics
trackEvent(PP_SPONSORED_SHOWN, Statistics.params().add(PROVIDER, convertToSponsor(type)).get());
}
public void trackSponsoredGalleryError(@Sponsored.SponsoredType int type)
public void trackSponsoredGalleryError(@Sponsored.SponsoredType int type, String errorCode)
{
trackEvent(PP_SPONSORED_ERROR, Statistics.params().add(PROVIDER, convertToSponsor(type))
.add(ERROR, "N/A").get());
.add(ERROR, errorCode).get());
}
public void trackSponsoredGalleryItemSelected(@NonNull String eventName,