forked from organicmaps/organicmaps
[android] Added core initialization, change geofence registry configuration, added correct Ad Event Type(visit)
This commit is contained in:
parent
a5094218d1
commit
ada9105009
6 changed files with 43 additions and 38 deletions
|
@ -75,17 +75,6 @@ public class Framework
|
|||
public static final int DO_AFTER_UPDATE_ASK_FOR_UPDATE = 2;
|
||||
public static final int DO_AFTER_UPDATE_MIGRATE = 3;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({LOCAL_ADS_EVENT_SHOW_POINT, LOCAL_ADS_EVENT_OPEN_INFO, LOCAL_ADS_EVENT_CLICKED_PHONE,
|
||||
LOCAL_ADS_EVENT_CLICKED_WEBSITE, LOCAL_ADS_EVENT_VISIT})
|
||||
public @interface LocalAdsEventType {}
|
||||
|
||||
public static final int LOCAL_ADS_EVENT_SHOW_POINT = 0;
|
||||
public static final int LOCAL_ADS_EVENT_OPEN_INFO = 1;
|
||||
public static final int LOCAL_ADS_EVENT_CLICKED_PHONE = 2;
|
||||
public static final int LOCAL_ADS_EVENT_CLICKED_WEBSITE = 3;
|
||||
public static final int LOCAL_ADS_EVENT_VISIT = 4;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({ROUTE_REBUILD_AFTER_POINTS_LOADING})
|
||||
public @interface RouteRecommendationType {}
|
||||
|
@ -203,7 +192,7 @@ public class Framework
|
|||
return Bitmap.createBitmap(altitudeChartBits, width, height, Bitmap.Config.ARGB_8888);
|
||||
}
|
||||
|
||||
public static void logLocalAdsEvent(@Framework.LocalAdsEventType int type,
|
||||
public static void logLocalAdsEvent(@NonNull LocalAdsEventType type,
|
||||
@NonNull MapObject mapObject)
|
||||
{
|
||||
LocalAdInfo info = mapObject.getLocalAdInfo();
|
||||
|
@ -214,7 +203,7 @@ public class Framework
|
|||
double lat = location != null ? location.getLatitude() : 0;
|
||||
double lon = location != null ? location.getLongitude() : 0;
|
||||
int accuracy = location != null ? (int) location.getAccuracy() : 0;
|
||||
nativeLogLocalAdsEvent(type, lat, lon, accuracy);
|
||||
nativeLogLocalAdsEvent(type.ordinal(), lat, lon, accuracy);
|
||||
}
|
||||
|
||||
@FilterUtils.RatingDef
|
||||
|
@ -449,7 +438,7 @@ public class Framework
|
|||
// Navigation.
|
||||
public static native boolean nativeIsRouteFinished();
|
||||
|
||||
private static native void nativeLogLocalAdsEvent(@LocalAdsEventType int eventType,
|
||||
private static native void nativeLogLocalAdsEvent(int eventType,
|
||||
double lat, double lon, int accuracy);
|
||||
|
||||
public static native void nativeRunFirstLaunchAnimation();
|
||||
|
@ -527,4 +516,13 @@ public class Framework
|
|||
public static native void nativeOnBatteryLevelChanged(int level);
|
||||
public static native void nativeSetPowerManagerFacility(int facilityType, boolean state);
|
||||
public static native void nativeSetPowerManagerScheme(int schemeType);
|
||||
|
||||
public enum LocalAdsEventType
|
||||
{
|
||||
LOCAL_ADS_EVENT_SHOW_POINT,
|
||||
LOCAL_ADS_EVENT_OPEN_INFO,
|
||||
LOCAL_ADS_EVENT_CLICKED_PHONE,
|
||||
LOCAL_ADS_EVENT_CLICKED_WEBSITE,
|
||||
LOCAL_ADS_EVENT_VISIT
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@ public class LightFramework
|
|||
public static void logLocalAdsEvent(@NonNull GeofenceLocation location,
|
||||
@NonNull GeoFenceFeature feature)
|
||||
{
|
||||
nativeLogLocalAdsEvent(1, location.getLat(), location.getLon(),
|
||||
nativeLogLocalAdsEvent(Framework.LocalAdsEventType.LOCAL_ADS_EVENT_VISIT.ordinal(),
|
||||
location.getLat(), location.getLon(),
|
||||
/* FIXME */
|
||||
(int) location.getRadiusInMeters(), feature.getMwmVersion(),
|
||||
feature.getCountryId(), feature.getFeatureIndex());
|
||||
|
|
|
@ -1505,7 +1505,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (object != null)
|
||||
{
|
||||
mPlacePage.setState(object.isExtendedView() ? State.DETAILS : State.PREVIEW);
|
||||
Framework.logLocalAdsEvent(Framework.LOCAL_ADS_EVENT_OPEN_INFO, object);
|
||||
Framework.logLocalAdsEvent(Framework.LocalAdsEventType.LOCAL_ADS_EVENT_OPEN_INFO, object);
|
||||
}
|
||||
}
|
||||
mPlacePageRestored = false;
|
||||
|
|
|
@ -52,22 +52,20 @@ public class GeofenceRegistryImpl implements GeofenceRegistry
|
|||
|
||||
List<GeoFenceFeature> features = LightFramework.getLocalAdsFeatures(
|
||||
location.getLat(), location.getLon(), location.getRadiusInMeters(), GEOFENCE_MAX_COUNT);
|
||||
/*
|
||||
|
||||
if (features.isEmpty())
|
||||
return;*/
|
||||
return;
|
||||
for (GeoFenceFeature each : features)
|
||||
{
|
||||
|
||||
Geofence geofence = new Geofence.Builder()
|
||||
.setRequestId(each.getId())
|
||||
.setCircularRegion(each.getLatitude(), each.getLongitude(), PREFERRED_GEOFENCE_RADIUS)
|
||||
.setExpirationDuration(TimeUnit.DAYS.toMillis(GEOFENCE_TTL_IN_DAYS))
|
||||
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER
|
||||
| Geofence.GEOFENCE_TRANSITION_EXIT)
|
||||
.build();
|
||||
mGeofences.add(new GeofenceAndFeature(geofence, each));
|
||||
}
|
||||
Geofence geofence = new Geofence.Builder()
|
||||
.setRequestId(String.valueOf(System.currentTimeMillis()))
|
||||
.setCircularRegion(location.getLat(), location.getLon(), PREFERRED_GEOFENCE_RADIUS)
|
||||
.setExpirationDuration(TimeUnit.DAYS.toMillis(GEOFENCE_TTL_IN_DAYS))
|
||||
.setLoiteringDelay(1000)
|
||||
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_DWELL)
|
||||
.build();
|
||||
mGeofences.add(new GeofenceAndFeature(geofence, null));
|
||||
GeofencingRequest geofencingRequest = makeGeofencingRequest();
|
||||
PendingIntent intent = makeGeofencePendingIntent();
|
||||
mGeofencingClient.addGeofences(geofencingRequest, intent)
|
||||
|
@ -142,7 +140,7 @@ public class GeofenceRegistryImpl implements GeofenceRegistry
|
|||
private GeofencingRequest makeGeofencingRequest()
|
||||
{
|
||||
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
|
||||
return builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_DWELL)
|
||||
return builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER)
|
||||
.addGeofences(collectGeofences())
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -48,9 +48,9 @@ public class GeofenceTransitionsIntentService extends JobIntentService
|
|||
{
|
||||
int transitionType = geofencingEvent.getGeofenceTransition();
|
||||
|
||||
if (transitionType == Geofence.GEOFENCE_TRANSITION_DWELL)
|
||||
if (transitionType == Geofence.GEOFENCE_TRANSITION_ENTER)
|
||||
onGeofenceEnter(geofencingEvent);
|
||||
else if (transitionType == Geofence.GEOFENCE_TRANSITION_ENTER)
|
||||
else if (transitionType == Geofence.GEOFENCE_TRANSITION_EXIT)
|
||||
onGeofenceExit(geofencingEvent);
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ public class GeofenceTransitionsIntentService extends JobIntentService
|
|||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
public void runInternal()
|
||||
{
|
||||
requestLocationCheck();
|
||||
}
|
||||
|
@ -133,9 +133,6 @@ public class GeofenceTransitionsIntentService extends JobIntentService
|
|||
{
|
||||
LOG.d(TAG, "Geofences = " + Arrays.toString(mGeofences.toArray()));
|
||||
|
||||
if (!getApplication().arePlatformAndCoreInitialized())
|
||||
getApplication().initCore();
|
||||
|
||||
GeofenceLocation geofenceLocation = getGeofenceLocation();
|
||||
GeofenceRegistry registry = GeofenceRegistryImpl.from(getApplication());
|
||||
for (Geofence each : mGeofences)
|
||||
|
@ -155,7 +152,7 @@ public class GeofenceTransitionsIntentService extends JobIntentService
|
|||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
public void runInternal()
|
||||
{
|
||||
GeofenceLocation location = getGeofenceLocation();
|
||||
GeofenceRegistry geofenceRegistry = GeofenceRegistryImpl.from(getApplication());
|
||||
|
@ -167,7 +164,7 @@ public class GeofenceTransitionsIntentService extends JobIntentService
|
|||
}
|
||||
catch (LocationPermissionNotGrantedException e)
|
||||
{
|
||||
LOG.d(TAG, "Location permission not granted!", e);
|
||||
LOG.e(TAG, "Location permission not granted!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,6 +183,17 @@ public class GeofenceTransitionsIntentService extends JobIntentService
|
|||
mGeofenceLocation = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!getApplication().arePlatformAndCoreInitialized())
|
||||
getApplication().initCore();
|
||||
|
||||
runInternal();
|
||||
}
|
||||
|
||||
protected abstract void runInternal();
|
||||
|
||||
@NonNull
|
||||
protected MwmApplication getApplication()
|
||||
{
|
||||
|
|
|
@ -1841,12 +1841,12 @@ public class PlacePageView extends RelativeLayout
|
|||
case R.id.ll__place_phone:
|
||||
Utils.callPhone(getContext(), mTvPhone.getText().toString());
|
||||
if (mMapObject != null)
|
||||
Framework.logLocalAdsEvent(Framework.LOCAL_ADS_EVENT_CLICKED_PHONE, mMapObject);
|
||||
Framework.logLocalAdsEvent(Framework.LocalAdsEventType.LOCAL_ADS_EVENT_CLICKED_PHONE, mMapObject);
|
||||
break;
|
||||
case R.id.ll__place_website:
|
||||
Utils.openUrl(getContext(), mTvWebsite.getText().toString());
|
||||
if (mMapObject != null)
|
||||
Framework.logLocalAdsEvent(Framework.LOCAL_ADS_EVENT_CLICKED_WEBSITE, mMapObject);
|
||||
Framework.logLocalAdsEvent(Framework.LocalAdsEventType.LOCAL_ADS_EVENT_CLICKED_WEBSITE, mMapObject);
|
||||
break;
|
||||
case R.id.ll__place_wiki:
|
||||
// TODO: Refactor and use separate getters for Wiki and all other PP meta info too.
|
||||
|
|
Loading…
Add table
Reference in a new issue