[android] Added support jni call when tip shown

This commit is contained in:
Dmitry Donskoy 2018-09-07 21:18:25 +03:00 committed by Aleksandr Zatsepin
parent 18840f8b67
commit cace5dfe38
4 changed files with 79 additions and 8 deletions

View file

@ -42,6 +42,7 @@
#include "base/logging.hpp"
#include "base/math.hpp"
#include "base/sunrise_sunset.hpp"
#include "metrics/eye.hpp"
#include <memory>
#include <string>
@ -1776,6 +1777,14 @@ Java_com_mapswithme_maps_Framework_nativeGetCurrentTipsApi(JNIEnv * env, jclass)
return tipsApi.GetTip().is_initialized() ? static_cast<jint>(tipsApi.GetTip().get()) : -1;
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_Framework_nativeTipsShown(JNIEnv * env, jclass,
jint type, jint event)
{
auto const & typeValue = static_cast<eye::Tip::Type>(type);
auto const & eventValue = static_cast<eye::Tip::Event>(event);
eye::Eye::Event::TipShown(typeValue, eventValue);
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_Framework_nativeHasActiveSubscription(JNIEnv *, jclass)
{

View file

@ -24,6 +24,8 @@ import com.mapswithme.maps.routing.RoutePointInfo;
import com.mapswithme.maps.routing.RoutingInfo;
import com.mapswithme.maps.routing.TransitRouteInfo;
import com.mapswithme.maps.search.FilterUtils;
import com.mapswithme.maps.tips.TipsAction;
import com.mapswithme.maps.tips.TipsProvider;
import com.mapswithme.util.Constants;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
@ -223,6 +225,11 @@ public class Framework
return FilterUtils.RATING_ANY;
}
public static void tipsShown(@NonNull TipsProvider tipsProvider)
{
nativeTipsShown(tipsProvider.ordinal(), TipsAction.ACTION_CLICKED.ordinal());
}
public static native void nativeShowTrackRect(long track);
public static native int nativeGetDrawScale();
@ -476,4 +483,6 @@ public class Framework
public static native boolean nativeHasActiveSubscription();
public static native int nativeGetCurrentTipsApi();
private static native void nativeTipsShown(int tipType, int event);
}

View file

@ -0,0 +1,7 @@
package com.mapswithme.maps.tips;
public enum TipsAction
{
ACTION_CLICKED,
GOT_IT_CLICKED
}

View file

@ -165,39 +165,85 @@ public enum TipsProvider
{
void onInterceptClick(@NonNull MwmActivity params);
class OpenBookmarksCatalog implements ClickInterceptor
abstract class AbstractClickInterceptor implements ClickInterceptor
{
@NonNull
private final TipsProvider mTipsProvider;
AbstractClickInterceptor(@NonNull TipsProvider tipsProvider)
{
mTipsProvider = tipsProvider;
}
@NonNull
TipsProvider getType()
{
return mTipsProvider;
}
@Override
public void onInterceptClick(@NonNull MwmActivity params)
public final void onInterceptClick(@NonNull MwmActivity params)
{
Framework.tipsShown(getType());
onInterceptClickInternal(params);
}
protected abstract void onInterceptClickInternal(@NonNull MwmActivity params);
}
class OpenBookmarksCatalog extends AbstractClickInterceptor
{
OpenBookmarksCatalog()
{
super(BOOKMARKS);
}
@Override
public void onInterceptClickInternal(@NonNull MwmActivity params)
{
BookmarksCatalogActivity.startForResult(params,
BookmarkCategoriesActivity.REQ_CODE_DOWNLOAD_BOOKMARK_CATEGORY);
}
}
class ActivateSubwayLayer implements ClickInterceptor
class ActivateSubwayLayer extends AbstractClickInterceptor
{
ActivateSubwayLayer()
{
super(MAP_LAYERS);
}
@Override
public void onInterceptClick(@NonNull MwmActivity params)
public void onInterceptClickInternal(@NonNull MwmActivity params)
{
Mode.SUBWAY.setEnabled(params, true);
params.onSubwayLayerSelected();
}
}
class SearchHotels implements ClickInterceptor
class SearchHotels extends AbstractClickInterceptor
{
SearchHotels()
{
super(SEARCH);
}
@Override
public void onInterceptClick(@NonNull MwmActivity params)
public void onInterceptClickInternal(@NonNull MwmActivity params)
{
params.showSearch(params.getString(R.string.hotel));
}
}
class OpenDiscoveryScreen implements ClickInterceptor
class OpenDiscoveryScreen extends AbstractClickInterceptor
{
OpenDiscoveryScreen()
{
super(DISCOVERY);
}
@Override
public void onInterceptClick(@NonNull MwmActivity params)
public void onInterceptClickInternal(@NonNull MwmActivity params)
{
params.showDiscovery();
}