[android] Added statistics v1 for elevation profile place page

This commit is contained in:
Александр Зацепин 2020-04-07 14:32:47 +03:00 committed by Vladimir Byko-Ianko
parent 3132dadb84
commit 4ad3f42c30
4 changed files with 56 additions and 3 deletions

View file

@ -13,10 +13,12 @@ import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.data.ElevationInfo;
import com.mapswithme.maps.routing.RoutingController;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.statistics.Statistics;
import java.util.Objects;
public class ElevationProfileViewRenderer implements PlacePageViewRenderer<PlacePageData>
public class ElevationProfileViewRenderer implements PlacePageViewRenderer<PlacePageData>,
PlacePageStateObserver
{
// Must be correspond to map/elevation_info.hpp constants.
private static final int MAX_DIFFICULTY_LEVEL = 3;
@ -146,4 +148,27 @@ public class ElevationProfileViewRenderer implements PlacePageViewRenderer<Place
mScrollView.scrollTo(0, 0);
mChartController.onHide();
}
@Override
public void onPlacePageDetails()
{
if (mElevationInfo != null)
Statistics.INSTANCE.trackElevationProfilePageOpen(mElevationInfo.getServerId(),
Statistics.ParamValue.FULL);
}
@Override
public void onPlacePagePreview()
{
if (mElevationInfo != null)
Statistics.INSTANCE.trackElevationProfilePageOpen(mElevationInfo.getServerId(),
Statistics.ParamValue.PREVIEW);
}
@Override
public void onPlacePageClosed()
{
if (mElevationInfo != null)
Statistics.INSTANCE.trackElevationProfilePageClose(mElevationInfo.getServerId());
}
}

View file

@ -188,6 +188,7 @@ class PlacePageControllerComposite implements PlacePageController
private static PlacePageController createSimplePlacePageController(
@NonNull PlacePageController.SlideListener listener)
{
return new SimplePlacePageController(listener, new ElevationProfileViewRenderer());
ElevationProfileViewRenderer renderer = new ElevationProfileViewRenderer();
return new SimplePlacePageController(listener, renderer, renderer);
}
}

View file

@ -35,6 +35,8 @@ public class SimplePlacePageController implements PlacePageController
private int mViewPortMinWidth;
@NonNull
private final PlacePageViewRenderer<PlacePageData> mViewRenderer;
@Nullable
private final PlacePageStateObserver mStateObserver;
@NonNull
private final BottomSheetChangedListener mBottomSheetChangedListener =
new BottomSheetChangedListener()
@ -43,6 +45,8 @@ public class SimplePlacePageController implements PlacePageController
public void onSheetHidden()
{
onHiddenInternal();
if (mStateObserver != null)
mStateObserver.onPlacePageClosed();
}
@Override
@ -59,6 +63,8 @@ public class SimplePlacePageController implements PlacePageController
{
if (UiUtils.isLandscape(mApplication))
PlacePageUtils.moveViewPortRight(mSheet, mViewPortMinWidth);
if (mStateObserver != null)
mStateObserver.onPlacePageDetails();
}
@Override
@ -66,6 +72,8 @@ public class SimplePlacePageController implements PlacePageController
{
if (UiUtils.isLandscape(mApplication))
PlacePageUtils.moveViewPortRight(mSheet, mViewPortMinWidth);
if (mStateObserver != null)
mStateObserver.onPlacePagePreview();
}
@Override
@ -93,10 +101,12 @@ public class SimplePlacePageController implements PlacePageController
private boolean mDeactivateMapSelection = true;
SimplePlacePageController(@NonNull SlideListener slideListener,
@NonNull PlacePageViewRenderer<PlacePageData> renderer)
@NonNull PlacePageViewRenderer<PlacePageData> renderer,
@Nullable PlacePageStateObserver stateObserver)
{
mSlideListener = slideListener;
mViewRenderer = renderer;
mStateObserver = stateObserver;
}
@Override

View file

@ -70,6 +70,7 @@ import static com.mapswithme.util.statistics.Statistics.EventName.BM_SYNC_PROPOS
import static com.mapswithme.util.statistics.Statistics.EventName.BM_SYNC_PROPOSAL_TOGGLE;
import static com.mapswithme.util.statistics.Statistics.EventName.BM_SYNC_SUCCESS;
import static com.mapswithme.util.statistics.Statistics.EventName.DOWNLOADER_DIALOG_ERROR;
import static com.mapswithme.util.statistics.Statistics.EventName.ELEVATION_PROFILE_PAGE_OPEN;
import static com.mapswithme.util.statistics.Statistics.EventName.GUIDES_BOOKMARK_SELECT;
import static com.mapswithme.util.statistics.Statistics.EventName.GUIDES_OPEN;
import static com.mapswithme.util.statistics.Statistics.EventName.GUIDES_SHOWN;
@ -459,6 +460,10 @@ public enum Statistics
public static final String PP_HOTEL_SEARCH_SIMILAR = "Placepage_Hotel_search_similar";
static final String PP_OWNERSHIP_BUTTON_CLICK = "Placepage_OwnershipButton_click";
//elevation profile
static final String ELEVATION_PROFILE_PAGE_OPEN = "ElevationProfilePage_open";
static final String ELEVATION_PROFILE_PAGE_CLOSE = "ElevationProfilePage_close";
// toolbar actions
public static final String TOOLBAR_MY_POSITION = "Toolbar. MyPosition";
static final String TOOLBAR_CLICK = "Toolbar_click";
@ -789,6 +794,8 @@ public enum Statistics
public static final String WIKIPEDIA = "wikipedia";
static final String TRUE = "True";
static final String FALSE = "False";
public static final String PREVIEW = "preview";
public static final String FULL = "full";
}
// Initialized once in constructor and does not change until the process restarts.
@ -1782,6 +1789,16 @@ public enum Statistics
trackEvent(event, params.add(FIRST_LAUNCH, isFirstLaunch ? TRUE : FALSE));
}
public void trackElevationProfilePageOpen(@Nullable String serverId, @NonNull String state)
{
trackEvent(ELEVATION_PROFILE_PAGE_OPEN, params().add(SERVER_ID, serverId).add(STATE, state));
}
public void trackElevationProfilePageClose(@Nullable String serverId)
{
trackEvent(ELEVATION_PROFILE_PAGE_CLOSE, params().add(SERVER_ID, serverId));
}
@NonNull
public static ParameterBuilder makeParametersFromType(@NonNull String type)
{