diff --git a/android/MapsWithMeLite/res/values/fb.xml b/android/MapsWithMeLite/res/values/fb.xml new file mode 100644 index 0000000000..0530e81010 --- /dev/null +++ b/android/MapsWithMeLite/res/values/fb.xml @@ -0,0 +1,4 @@ + + + 272257082798521 + \ No newline at end of file diff --git a/android/MapsWithMePro/res/values/fb.xml b/android/MapsWithMePro/res/values/fb.xml new file mode 100644 index 0000000000..f1c354e075 --- /dev/null +++ b/android/MapsWithMePro/res/values/fb.xml @@ -0,0 +1,4 @@ + + + 185237551520383 + \ No newline at end of file diff --git a/android/project.properties b/android/project.properties index 6af0a27211..95d5e54a61 100644 --- a/android/project.properties +++ b/android/project.properties @@ -11,3 +11,4 @@ target=android-19 android.library=true android.library.reference.1=3rd_party/HoloEverywhere/library +android.library.reference.2=3rd_party/facebook-android-sdk/facebook diff --git a/android/res/values/fb.xml b/android/res/values/fb.xml new file mode 100644 index 0000000000..7d0b1edd49 --- /dev/null +++ b/android/res/values/fb.xml @@ -0,0 +1,4 @@ + + + NOT_REALLY_KEY + \ No newline at end of file diff --git a/android/src/com/mapswithme/maps/DownloadResourcesActivity.java b/android/src/com/mapswithme/maps/DownloadResourcesActivity.java index b5a2e9e2f6..70f7a14e3a 100644 --- a/android/src/com/mapswithme/maps/DownloadResourcesActivity.java +++ b/android/src/com/mapswithme/maps/DownloadResourcesActivity.java @@ -398,6 +398,7 @@ public class DownloadResourcesActivity extends MapsWithMeBaseActivity super.onCreate(savedInstanceState); mApplication = (MWMApplication)getApplication(); + mApplication.OnMwmStart(this); final boolean isPro = mApplication.isProVersion(); if (checkLiteProPackages(isPro)) diff --git a/android/src/com/mapswithme/maps/MWMApplication.java b/android/src/com/mapswithme/maps/MWMApplication.java index 77ee0885a7..92dff885d6 100644 --- a/android/src/com/mapswithme/maps/MWMApplication.java +++ b/android/src/com/mapswithme/maps/MWMApplication.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import android.content.Context; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.AssetManager; import android.os.Build; @@ -21,6 +22,7 @@ import com.mapswithme.maps.guides.GuidesUtils; import com.mapswithme.maps.location.LocationService; import com.mapswithme.maps.state.AppStateManager; import com.mapswithme.maps.state.SuppotedState; +import com.mapswithme.util.FbUtil; import com.mapswithme.util.Utils; @@ -305,4 +307,9 @@ public class MWMApplication extends android.app.Application implements MapStorag public native double nativeGetDouble(String name, double defaultValue); public native void nativeSetDouble(String name, double value); + + public void OnMwmStart(Context context) + { + FbUtil.activate(context); + } } diff --git a/android/src/com/mapswithme/util/FbUtil.java b/android/src/com/mapswithme/util/FbUtil.java new file mode 100644 index 0000000000..faacb61dad --- /dev/null +++ b/android/src/com/mapswithme/util/FbUtil.java @@ -0,0 +1,48 @@ +package com.mapswithme.util; + +import android.content.Context; + +import com.facebook.AppEventsLogger; +import com.mapswithme.maps.R; +import com.mapswithme.util.log.Logger; +import com.mapswithme.util.log.SimpleLogger; + + + +public class FbUtil +{ + + public static Logger mLogger = SimpleLogger.get("MWM_FB"); + + public final static String[] SUPPORTED_PACKAGES = { + "com.mapswithme.maps", + "com.mapswithme.maps.pro", + }; + + public static void activate(Context context) + { + final String thisPackageName = context.getPackageName(); + + boolean supported = false; + for (final String pkg : SUPPORTED_PACKAGES) + { + if (pkg.equals(thisPackageName)) + { + supported = true; + break; + } + } + + // do not try to activate if package is not registered in FB + if (!supported) + { + mLogger.d("SKIPPING ACTIVATION"); + return; + } + + mLogger.d("ACTIVATING"); + AppEventsLogger.activateApp(context, context.getString(R.string.fb_app_id)); + } + + private FbUtil() {}; +}