[AND] FB Integration.

[AND] Build for 19 API.
This commit is contained in:
Dmitry Kunin 2013-11-11 16:38:30 +03:00 committed by Alex Zolotarev
parent 596b41fc75
commit 34c74e7d6c
7 changed files with 69 additions and 0 deletions

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<resources>
<string name="fb_app_id">272257082798521</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<resources>
<string name="fb_app_id">185237551520383</string>
</resources>

View file

@ -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

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<resources>
<string name="fb_app_id">NOT_REALLY_KEY</string>
</resources>

View file

@ -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))

View file

@ -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);
}
}

View file

@ -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() {};
}