forked from organicmaps/organicmaps
[android] Added visiblity tracking PP views
This commit is contained in:
parent
9b83cdfe98
commit
c8a3702ed0
5 changed files with 109 additions and 1 deletions
|
@ -98,6 +98,7 @@ import com.mapswithme.util.permissions.PermissionsResult;
|
|||
import com.mapswithme.util.sharing.ShareOption;
|
||||
import com.mapswithme.util.sharing.SharingHelper;
|
||||
import com.mapswithme.util.statistics.AlohaHelper;
|
||||
import com.mapswithme.util.statistics.PlacePageTracker;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -190,6 +191,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
private boolean mRestoreRoutingPlanFragmentNeeded;
|
||||
@Nullable
|
||||
private Bundle mSavedForTabletState;
|
||||
@Nullable
|
||||
private PlacePageTracker mPlacePageTracker;
|
||||
|
||||
@NonNull
|
||||
private final OnClickListener mOnMyPositionClickListener = new OnClickListener()
|
||||
|
@ -525,6 +528,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
{
|
||||
mPlacePage.setOnVisibilityChangedListener(this);
|
||||
mPlacePage.setOnAnimationListener(this);
|
||||
mPlacePageTracker = new PlacePageTracker(mPlacePage);
|
||||
}
|
||||
|
||||
if (!mIsFragmentContainer)
|
||||
|
@ -956,7 +960,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (mPlacePage != null && state != State.HIDDEN)
|
||||
{
|
||||
mPlacePageRestored = true;
|
||||
mPlacePage.setMapObject((MapObject) savedInstanceState.getParcelable(STATE_MAP_OBJECT), true,
|
||||
MapObject mapObject = (MapObject) savedInstanceState.getParcelable(STATE_MAP_OBJECT);
|
||||
mPlacePage.setMapObject(mapObject, true,
|
||||
new PlacePageView.SetMapObjectListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -965,6 +970,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
mPlacePage.setState(state);
|
||||
}
|
||||
});
|
||||
if (mPlacePageTracker != null)
|
||||
mPlacePageTracker.setMapObject(mapObject);
|
||||
}
|
||||
|
||||
if (mIsFragmentContainer)
|
||||
|
@ -1282,6 +1289,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
mPlacePageRestored = false;
|
||||
}
|
||||
});
|
||||
if (mPlacePageTracker != null)
|
||||
mPlacePageTracker.setMapObject(object);
|
||||
}
|
||||
|
||||
if (UiUtils.isVisible(mFadeView))
|
||||
|
@ -1400,6 +1409,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
Framework.nativeDeactivatePopup();
|
||||
if (mPlacePage != null)
|
||||
mPlacePage.setMapObject(null, false, null);
|
||||
if (mPlacePageTracker != null)
|
||||
mPlacePageTracker.onHide();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1420,6 +1431,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
{
|
||||
if (mNavAnimationController != null)
|
||||
mNavAnimationController.onPlacePageMoved(translationY);
|
||||
if (mPlacePageTracker != null)
|
||||
mPlacePageTracker.onMove();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -157,6 +157,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
|
|||
mDetailsScroll.scrollTo(0, 0);
|
||||
}
|
||||
refreshToolbarVisibility();
|
||||
notifyProgress();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -105,11 +105,20 @@ class LeftPlacePageAnimationController extends BasePlacePageAnimationController
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(int left, int top)
|
||||
{
|
||||
super.onScroll(left, top);
|
||||
notifyProgress(0, 0);
|
||||
}
|
||||
|
||||
private void startTracking(boolean collapsed)
|
||||
{
|
||||
MwmActivity.LeftAnimationTrackListener tracker = mPlacePage.getLeftAnimationTrackListener();
|
||||
if (tracker != null)
|
||||
tracker.onTrackStarted(collapsed);
|
||||
|
||||
notifyProgress(0, 0);
|
||||
}
|
||||
|
||||
private void finishTracking(boolean collapsed)
|
||||
|
@ -117,6 +126,8 @@ class LeftPlacePageAnimationController extends BasePlacePageAnimationController
|
|||
MwmActivity.LeftAnimationTrackListener tracker = mPlacePage.getLeftAnimationTrackListener();
|
||||
if (tracker != null)
|
||||
tracker.onTrackFinished(collapsed);
|
||||
|
||||
notifyProgress(0, 0);
|
||||
}
|
||||
|
||||
private void track(ValueAnimator animation)
|
||||
|
@ -133,6 +144,8 @@ class LeftPlacePageAnimationController extends BasePlacePageAnimationController
|
|||
MwmActivity.LeftAnimationTrackListener tracker = mPlacePage.getLeftAnimationTrackListener();
|
||||
if (tracker != null)
|
||||
tracker.onTrackLeftAnimation(offset + mPlacePage.getDockedWidth());
|
||||
|
||||
notifyProgress(0, 0);
|
||||
}
|
||||
|
||||
private void showPlacePage(final State currentState)
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
package com.mapswithme.util.statistics;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Rect;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.taxi.TaxiManager;
|
||||
import com.mapswithme.maps.widget.placepage.PlacePageView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static android.view.View.INVISIBLE;
|
||||
|
||||
public class PlacePageTracker
|
||||
{
|
||||
private final int mBottomPadding;
|
||||
@NonNull
|
||||
private final PlacePageView mPlacePageView;
|
||||
@NonNull
|
||||
private final View mTaxi;
|
||||
@Nullable
|
||||
private MapObject mMapObject;
|
||||
|
||||
private boolean mTracked;
|
||||
|
||||
public PlacePageTracker(@NonNull PlacePageView placePageView)
|
||||
{
|
||||
mPlacePageView = placePageView;
|
||||
mTaxi = mPlacePageView.findViewById(R.id.ll__place_page_taxi);
|
||||
Activity activity = (Activity) placePageView.getContext();
|
||||
mBottomPadding = activity.getResources().getDimensionPixelOffset(R.dimen.place_page_buttons_height);
|
||||
}
|
||||
|
||||
public void setMapObject(@Nullable MapObject mapObject)
|
||||
{
|
||||
mMapObject = mapObject;
|
||||
}
|
||||
|
||||
public void onMove()
|
||||
{
|
||||
trackTaxiVisibility();
|
||||
}
|
||||
|
||||
public void onHide()
|
||||
{
|
||||
mTracked = false;
|
||||
}
|
||||
|
||||
private void trackTaxiVisibility()
|
||||
{
|
||||
if (!mTracked && isViewOnScreen(mTaxi) && mMapObject != null)
|
||||
{
|
||||
List<Integer> taxiTypes = mMapObject.getReachableByTaxiTypes();
|
||||
if (taxiTypes != null && !taxiTypes.isEmpty())
|
||||
{
|
||||
@TaxiManager.TaxiType
|
||||
int type = taxiTypes.get(0);
|
||||
Statistics.INSTANCE.trackTaxiEvent(Statistics.EventName.ROUTING_TAXI_REAL_SHOW_IN_PP, type);
|
||||
mTracked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isViewOnScreen(@NonNull View view) {
|
||||
|
||||
if (mPlacePageView.getVisibility() == INVISIBLE)
|
||||
return false;
|
||||
|
||||
Rect localRect = new Rect();
|
||||
Rect globalRect = new Rect();
|
||||
view.getLocalVisibleRect(localRect);
|
||||
view.getGlobalVisibleRect(globalRect);
|
||||
return localRect.bottom >= view.getHeight() && localRect.top == 0
|
||||
&& globalRect.bottom <= mPlacePageView.getBottom() - mBottomPadding;
|
||||
}
|
||||
}
|
|
@ -194,6 +194,7 @@ public enum Statistics
|
|||
public static final String ROUTING_TAXI_ORDER = "Routing_Taxi_order";
|
||||
public static final String ROUTING_TAXI_INSTALL = "Routing_Taxi_install";
|
||||
public static final String ROUTING_TAXI_SHOW_IN_PP = "Placepage_Taxi_show";
|
||||
public static final String ROUTING_TAXI_REAL_SHOW_IN_PP = "Placepage_Taxi_show_real";
|
||||
public static final String ROUTING_TAXI_CLICK_IN_PP = "Placepage_Taxi_click";
|
||||
public static final String ROUTING_TAXI_ROUTE_BUILT = "Routing_Build_Taxi";
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue