Add firebase log event for free app with gp services
This commit is contained in:
parent
2c8d7d0f74
commit
6f803ea8b9
4 changed files with 30 additions and 3 deletions
|
@ -350,9 +350,17 @@ repositories {
|
|||
// mavenCentral()
|
||||
}
|
||||
|
||||
def analytics = (System.getenv("APP_FEATURES") && System.getenv("APP_FEATURES").contains("+play_market") &&
|
||||
System.getenv("PACKAGE_TO_BUILT").equals("net.osmand") ) || System.getenv("USE_FIREBASE")
|
||||
dependencies {
|
||||
compile project(path: ':OsmAnd-java', configuration: 'android')
|
||||
|
||||
if(analytics) {
|
||||
compile 'com.google.firebase:firebase-core:9.8.0'
|
||||
compile 'com.google.firebase:firebase-config:9.8.0'
|
||||
|
||||
}
|
||||
|
||||
|
||||
// compile project(':eclipse-compile:design')
|
||||
// compile project(':eclipse-compile:cardview')
|
||||
|
@ -368,8 +376,7 @@ dependencies {
|
|||
qtcoreCompile "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar"
|
||||
qtcoreCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
|
||||
}
|
||||
if(System.getenv("APP_FEATURES") && System.getenv("APP_FEATURES").contains("+play_market") &&
|
||||
System.getenv("PACKAGE_TO_BUILT").equals("net.osmand")) {
|
||||
if(analytics) {
|
||||
println "Apply GMS plugin"
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||
import android.content.res.Configuration;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.multidex.MultiDex;
|
||||
|
@ -57,6 +58,7 @@ import java.io.File;
|
|||
import java.io.FileWriter;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -776,4 +778,18 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public void logEvent(Activity ctx, String event) {
|
||||
try {
|
||||
if(Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)) {
|
||||
Class<?> cl = Class.forName("com.google.firebase.analytics.FirebaseAnalytics");
|
||||
Method mm = cl.getMethod("getInstance", Context.class);
|
||||
Object inst = mm.invoke(null, ctx == null ? this : ctx);
|
||||
Method log = cl.getMethod("logEvent", String.class, Bundle.class);
|
||||
log.invoke(inst, event, new Bundle());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,6 +264,9 @@ public class DownloadIndexesThread {
|
|||
return;
|
||||
}
|
||||
}
|
||||
if(uiActivity instanceof Activity) {
|
||||
app.logEvent((Activity) uiActivity, "download_files");
|
||||
}
|
||||
for(IndexItem item : items) {
|
||||
if (!item.equals(currentDownloadingItem) && !indexItemDownloading.contains(item)) {
|
||||
indexItemDownloading.add(item);
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.views;
|
|||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
|
@ -26,7 +27,6 @@ import android.widget.ImageView;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.core.android.MapRendererContext;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -582,6 +582,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
mapRouteInfoMenu.show();
|
||||
} else {
|
||||
touchEvent = 0;
|
||||
app.logEvent(mapActivity, "start_navigation");
|
||||
app.getSettings().APPLICATION_MODE.set(routingHelper.getAppMode());
|
||||
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
||||
app.getSettings().FOLLOW_THE_ROUTE.set(true);
|
||||
|
|
Loading…
Reference in a new issue