From dd59773afc0a2798f7154bdc22122dd5ba3eb32c Mon Sep 17 00:00:00 2001 From: alexzatsepin Date: Mon, 24 Aug 2020 20:46:44 +0300 Subject: [PATCH] [android] Implemented quick filter click event --- .../maps/widget/InteractiveCounterView.java | 16 ++++++++++++++++ .../widget/menu/GuestsRoomsMenuRenderer.java | 19 ++++++++++++++++++- .../util/statistics/Statistics.java | 13 ++++++++++++- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/android/src/com/mapswithme/maps/widget/InteractiveCounterView.java b/android/src/com/mapswithme/maps/widget/InteractiveCounterView.java index 65b90b2ebd..3a5965c2ad 100644 --- a/android/src/com/mapswithme/maps/widget/InteractiveCounterView.java +++ b/android/src/com/mapswithme/maps/widget/InteractiveCounterView.java @@ -36,6 +36,8 @@ public class InteractiveCounterView extends RelativeLayout private int mDefaultValue; @DrawableRes private int mIconRes; + @Nullable + private CounterChangeListener mChangeListener; @NonNull private final OnClickListener mPlusClickListener = new OnClickListener() { @@ -45,6 +47,8 @@ public class InteractiveCounterView extends RelativeLayout int value = getCurrentValue(); mCounterView.setText(String.valueOf(++value)); updateConstraints(); + if (mChangeListener != null) + mChangeListener.onChange(); } }; @@ -57,6 +61,8 @@ public class InteractiveCounterView extends RelativeLayout int value = getCurrentValue(); mCounterView.setText(String.valueOf(--value)); updateConstraints(); + if (mChangeListener != null) + mChangeListener.onChange(); } }; @@ -142,4 +148,14 @@ public class InteractiveCounterView extends RelativeLayout mMinusView.setEnabled(value != mMinValue); mPlusView.setEnabled(value != mMaxValue); } + + public void setChangeListener(@Nullable CounterChangeListener listener) + { + mChangeListener = listener; + } + + public interface CounterChangeListener + { + void onChange(); + } } diff --git a/android/src/com/mapswithme/maps/widget/menu/GuestsRoomsMenuRenderer.java b/android/src/com/mapswithme/maps/widget/menu/GuestsRoomsMenuRenderer.java index 52998b3e18..23078b8809 100644 --- a/android/src/com/mapswithme/maps/widget/menu/GuestsRoomsMenuRenderer.java +++ b/android/src/com/mapswithme/maps/widget/menu/GuestsRoomsMenuRenderer.java @@ -7,6 +7,7 @@ import androidx.annotation.Nullable; import com.mapswithme.maps.R; import com.mapswithme.maps.search.FilterUtils; import com.mapswithme.maps.widget.InteractiveCounterView; +import com.mapswithme.util.statistics.Statistics; import java.util.Objects; @@ -65,14 +66,30 @@ public class GuestsRoomsMenuRenderer implements MenuRenderer { Objects.requireNonNull(view); mRoomsView = view.findViewById(R.id.rooms); + mRoomsView.setChangeListener(() -> onChangeCounterValue(Statistics.EventParam.ROOMS, + mRoomsView.getCurrentValue())); mAdultsView = view.findViewById(R.id.adults); + mAdultsView.setChangeListener(() -> onChangeCounterValue(Statistics.EventParam.ADULTS, + mAdultsView.getCurrentValue())); mChildrenView = view.findViewById(R.id.children); + mChildrenView.setChangeListener(() -> onChangeCounterValue(Statistics.EventParam.CHILDREN, + mChildrenView.getCurrentValue())); mInfantsView = view.findViewById(R.id.infants); + mInfantsView.setChangeListener(() -> onChangeCounterValue(Statistics.EventParam.INFANTS, + mInfantsView.getCurrentValue())); } @Override public void destroy() { - // No op. + mRoomsView.setChangeListener(null); + mAdultsView.setChangeListener(null); + mChildrenView.setChangeListener(null); + mInfantsView.setChangeListener(null); + } + + private void onChangeCounterValue(@NonNull String name, int count) + { + Statistics.INSTANCE.trackQuickFilterClick(Statistics.EventParam.HOTEL, name, count); } } diff --git a/android/src/com/mapswithme/util/statistics/Statistics.java b/android/src/com/mapswithme/util/statistics/Statistics.java index e1506001c0..28748ed8be 100644 --- a/android/src/com/mapswithme/util/statistics/Statistics.java +++ b/android/src/com/mapswithme/util/statistics/Statistics.java @@ -101,6 +101,7 @@ import static com.mapswithme.util.statistics.Statistics.EventName.ROUTING_PLAN_T import static com.mapswithme.util.statistics.Statistics.EventName.ROUTING_ROUTE_FINISH; import static com.mapswithme.util.statistics.Statistics.EventName.ROUTING_ROUTE_START; import static com.mapswithme.util.statistics.Statistics.EventName.SEARCH_FILTER_CLICK; +import static com.mapswithme.util.statistics.Statistics.EventName.SEARCH_QUICKFILTER_CLICK; import static com.mapswithme.util.statistics.Statistics.EventName.SEARCH_QUICKFILTER_OPEN; import static com.mapswithme.util.statistics.Statistics.EventName.TIPS_TRICKS_CLOSE; import static com.mapswithme.util.statistics.Statistics.EventName.TOOLBAR_CLICK; @@ -450,7 +451,8 @@ public enum Statistics public static final String SEARCH_FILTER_CANCEL = "Search_Filter_Cancel"; public static final String SEARCH_FILTER_RESET = "Search_Filter_Reset"; public static final String SEARCH_FILTER_APPLY = "Search_Filter_Apply"; - public static final String SEARCH_QUICKFILTER_OPEN = "Search_QuickFilter_Open"; + static final String SEARCH_QUICKFILTER_OPEN = "Search_QuickFilter_Open"; + static final String SEARCH_QUICKFILTER_CLICK = "Search_QuickFilter_Click"; static final String SEARCH_CAT_CLICKED = "Search. Category clicked"; static final String SEARCH_TAB_SELECTED = "Search_Tab_selected"; static final String SEARCH_FILTER_CLICK = "Search_Filter_Click"; @@ -671,6 +673,10 @@ public enum Statistics public static final String EXPORT_BOOKMARKS = "export_bookmarks"; public static final String BOOKMARKS_BACKUP = "bookmarks_backup"; public static final String AFTER_SAVE_REVIEW = "after_save_review"; + public static final String ROOMS = "rooms"; + public static final String ADULTS = "adults"; + public static final String CHILDREN = "children"; + public static final String INFANTS = "infants"; static final String BANNER = "banner"; static final String BATTERY = "battery"; static final String CALLER_ID = "Caller ID"; @@ -1604,6 +1610,11 @@ public enum Statistics .add(NETWORK, getConnectionState()).get()); } + public void trackQuickFilterClick(@NonNull String category, @NonNull String name, int count) + { + trackEvent(SEARCH_QUICKFILTER_CLICK, params().add(CATEGORY, category).add(name, count).get()); + } + public void trackFilterEvent(@NonNull String event, @NonNull String category) { trackEvent(event, params()