Skip to content

Commit

Permalink
Facebook Android SDK 3.6.0
Browse files Browse the repository at this point in the history
Summary:
Modified
+ AppEventsLogger is now out of Beta, setLimitEventUsage is deprecated and moved to Settings as setLimitEventAndDataUsage

Added
+ Added setSelection methods on FriendPickerFragment to allow pre-selection of friends.
+ Added example use of setSelection API in Friend Picker Sample
+ Added support for Gradle.

Fixed
+ Fixed bug in WebDialogs where the dialog would not display properly for large displays with soft keyboards
+ Fixed bug where the callback for NewPermissionsRequest was not called
+ Fixed bug in AuthorizationClient where it can hang on orientation changes

Test Plan: Tested on emulator

Reviewers: clang

Reviewed By: clang

CC: platform-diffs@lists

Differential Revision: https://phabricator.fb.com/D1089971
  • Loading branch information
mingflifb committed Dec 10, 2013
1 parent 2a15e79 commit aa04d8a
Show file tree
Hide file tree
Showing 47 changed files with 1,084 additions and 126 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Gradle
.gradle
build

*~
*.DS_Store
*.class
Expand Down
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
23 changes: 23 additions & 0 deletions facebook/TestApp/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apply plugin: 'android'

dependencies {
compile project(':facebook')
}

android {
compileSdkVersion 19
buildToolsVersion "19"

defaultConfig {
minSdkVersion 8
targetSdkVersion 19
}

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
23 changes: 23 additions & 0 deletions facebook/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apply plugin: 'android-library'

dependencies {
compile 'com.android.support:support-v4:13.0.+'
}

android {
compileSdkVersion 19
buildToolsVersion "19"

defaultConfig {
minSdkVersion 8
targetSdkVersion 19
}

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
2 changes: 0 additions & 2 deletions facebook/src/com/facebook/AppEventsConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
/**
* Predefined event and parameter names for logging events common to many apps. Logging occurs through the
* {@link AppEventsLogger#logEvent(String, android.os.Bundle)} family of methods.
*
* @beta
*/
public class AppEventsConstants {
// Event names
Expand Down
85 changes: 21 additions & 64 deletions facebook/src/com/facebook/AppEventsLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
Expand Down Expand Up @@ -103,7 +102,6 @@
* The length of each parameter value can be no more than on the order of 100 characters.
* </li>
* </ul>
* @beta
*/
public class AppEventsLogger {
// Enums
Expand Down Expand Up @@ -160,8 +158,6 @@ SuppressionTimeoutBehavior getBehavior() {
private static final int APP_SUPPORTS_ATTRIBUTION_ID_RECHECK_PERIOD_IN_SECONDS = 60 * 60 * 24;
private static final int APP_ACTIVATE_SUPPRESSION_PERIOD_IN_SECONDS = 5 * 60;

private static final String APP_EVENT_PREFERENCES = "com.facebook.sdk.appEventPreferences";

// Instance member variables
private final Context context;
private final AccessTokenAppIdPair accessTokenAppId;
Expand All @@ -174,6 +170,7 @@ SuppressionTimeoutBehavior getBehavior() {
private static boolean requestInFlight;
private static Context applicationContext;
private static Object staticLock = new Object();
private static String hashedDeviceAndAppId;
private static Map<String, Date> mapEventsToSuppressionTime = new HashMap<String, Date>();
@SuppressWarnings("serial")
private static Map<String, EventSuppression> mapEventNameToSuppress = new HashMap<String, EventSuppression>() {
Expand Down Expand Up @@ -247,34 +244,19 @@ private Object writeReplace() {
}

/**
* Sets whether events sent to Facebook should be restricted from being used for purposes than analytics and
* conversions, such as remarketing for this user. Defaults to false. This value is stored on the device and
* persists across app launches.
*
* @param context Used to read the value.
*
* @beta
* This method is deprecated. Use {@link Settings#getLimitEventAndDataUsage(Context)} instead.
*/
@Deprecated
public static boolean getLimitEventUsage(Context context) {
SharedPreferences preferences = context.getSharedPreferences(APP_EVENT_PREFERENCES, Context.MODE_PRIVATE);
return preferences.getBoolean("limitEventUsage", false);
return Settings.getLimitEventAndDataUsage(context);
}

/**
* Sets whether events sent to Facebook should be restricted from being used for purposes than analytics and
* conversions, such as remarketing for this user. Defaults to false. This value is stored on the device and
* persists across app launches. Changes to this setting will apply to any events currently queued to be
* flushed, as well as any subsequent events.
*
* @param context Used to persist this value across app runs.
*
* @beta
* This method is deprecated. Use {@link Settings#setLimitEventAndDataUsage(Context, boolean)} instead.
*/
@Deprecated
public static void setLimitEventUsage(Context context, boolean limitEventUsage) {
SharedPreferences preferences = context.getSharedPreferences(APP_EVENT_PREFERENCES, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("limitEventUsage", limitEventUsage);
editor.commit();
Settings.setLimitEventAndDataUsage(context, limitEventUsage);
}

/**
Expand All @@ -285,8 +267,6 @@ public static void setLimitEventUsage(Context context, boolean limitEventUsage)
* {@link AppEventsLogger#activateApp(android.content.Context, String)}.
*
* @param context Used to access the applicationId and the attributionId for non-authenticated users.
*
* @beta
*/
public static void activateApp(Context context) {
activateApp(context, Utility.getMetadataApplicationId(context));
Expand All @@ -299,8 +279,6 @@ public static void activateApp(Context context) {
* @param context Used to access the attributionId for non-authenticated users.
*
* @param applicationId The specific applicationId to report the activation for.
*
* @beta
*/
@SuppressWarnings("deprecation")
public static void activateApp(Context context, String applicationId) {
Expand All @@ -324,8 +302,6 @@ public static void activateApp(Context context, String applicationId) {
* @param context Used to access the applicationId and the attributionId for non-authenticated users.
*
* @return AppEventsLogger instance to invoke log* methods on.
*
* @beta
*/
public static AppEventsLogger newLogger(Context context) {
return new AppEventsLogger(context, null, null);
Expand All @@ -340,8 +316,6 @@ public static AppEventsLogger newLogger(Context context) {
* app ID specified via the app ID specified in the package metadata.
*
* @return AppEventsLogger instance to invoke log* methods on.
*
* @beta
*/
public static AppEventsLogger newLogger(Context context, Session session) {
return new AppEventsLogger(context, null, session);
Expand All @@ -358,8 +332,6 @@ public static AppEventsLogger newLogger(Context context, Session session) {
* app ID.
*
* @return AppEventsLogger instance to invoke log* methods on.
*
* @beta
*/
public static AppEventsLogger newLogger(Context context, String applicationId, Session session) {
return new AppEventsLogger(context, applicationId, session);
Expand All @@ -375,8 +347,6 @@ public static AppEventsLogger newLogger(Context context, String applicationId, S
* in the package metadata will be used.
*
* @return AppEventsLogger instance to invoke log* methods on.
*
* @beta
*/
public static AppEventsLogger newLogger(Context context, String applicationId) {
return new AppEventsLogger(context, applicationId, null);
Expand All @@ -396,8 +366,6 @@ public static AppEventsLogger newLogger(Context context, String applicationId) {
* Access the behavior that AppEventsLogger uses to determine when to flush logged events to the server. This
* setting applies to all instances of AppEventsLogger.
* @return specified flush behavior.
*
* @beta
*/
public static FlushBehavior getFlushBehavior() {
synchronized (staticLock) {
Expand All @@ -409,8 +377,6 @@ public static FlushBehavior getFlushBehavior() {
* Set the behavior that this AppEventsLogger uses to determine when to flush logged events to the server. This
* setting applies to all instances of AppEventsLogger.
* @param flushBehavior the desired behavior.
*
* @beta
*/
public static void setFlushBehavior(FlushBehavior flushBehavior) {
synchronized (staticLock) {
Expand All @@ -426,9 +392,7 @@ public static void setFlushBehavior(FlushBehavior flushBehavior) {
* Event names should be 40 characters or less, alphanumeric, and can include spaces, underscores
* or hyphens, but mustn't have a space or hyphen as the first character. Any given app should
* have no more than ~300 distinct event names.
*
* @beta
*/
*/
public void logEvent(String eventName) {
logEvent(eventName, null);
}
Expand All @@ -444,8 +408,6 @@ public void logEvent(String eventName) {
* * @param eventName
* @param valueToSum a value to associate with the event which will be summed up in Insights for across all
* instances of the event, so that average values can be determined, etc.
*
* @beta
*/
public void logEvent(String eventName, double valueToSum) {
logEvent(eventName, valueToSum, null);
Expand All @@ -465,8 +427,6 @@ public void logEvent(String eventName, double valueToSum) {
* parameter in the, at most, thousands. As an example, don't attempt to provide a unique
* parameter value for each unique user in your app. You won't get meaningful aggregate reporting
* on so many parameter values. The values in the bundles should be Strings or numeric values.
*
* @beta
*/
public void logEvent(String eventName, Bundle parameters) {
logEvent(eventName, null, parameters, false);
Expand All @@ -488,8 +448,6 @@ public void logEvent(String eventName, Bundle parameters) {
* parameter in the, at most, thousands. As an example, don't attempt to provide a unique
* parameter value for each unique user in your app. You won't get meaningful aggregate reporting
* on so many parameter values. The values in the bundles should be Strings or numeric values.
*
* @beta
*/
public void logEvent(String eventName, double valueToSum, Bundle parameters) {
logEvent(eventName, valueToSum, parameters, false);
Expand All @@ -501,8 +459,6 @@ public void logEvent(String eventName, double valueToSum, Bundle parameters) {
* @param purchaseAmount Amount of purchase, in the currency specified by the 'currency' parameter. This value
* will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
* @param currency Currency used to specify the amount.
*
* @beta
*/
public void logPurchase(BigDecimal purchaseAmount, Currency currency) {
logPurchase(purchaseAmount, currency, null);
Expand All @@ -517,8 +473,6 @@ public void logPurchase(BigDecimal purchaseAmount, Currency currency) {
* @param currency Currency used to specify the amount.
* @param parameters Arbitrary additional information for describing this event. Should have no more than
* 10 entries, and keys should be mostly consistent from one purchase event to the next.
*
* @beta
*/
public void logPurchase(BigDecimal purchaseAmount, Currency currency, Bundle parameters) {

Expand All @@ -542,8 +496,6 @@ public void logPurchase(BigDecimal purchaseAmount, Currency currency, Bundle par
/**
* Explicitly flush any stored events to the server. Implicit flushes may happen depending on the value
* of getFlushBehavior. This method allows for explicit, app invoked flushing.
*
* @beta
*/
public void flush() {
flush(FlushReason.EXPLICIT);
Expand All @@ -556,8 +508,6 @@ public void flush() {
* may trigger an I/O operation on the calling thread. Explicit use of this method is not necessary
* if the consumer is making use of {@link UiLifecycleHelper}, which will take care of making the call
* in its own onStop() callback.
*
* @beta
*/
public static void onContextStop() {
PersistedEvents.persistEvents(applicationContext, stateMap);
Expand Down Expand Up @@ -625,6 +575,11 @@ private AppEventsLogger(Context context, String applicationId, Session session)
}

synchronized (staticLock) {

if (hashedDeviceAndAppId == null) {
hashedDeviceAndAppId = Utility.getHashedDeviceAndAppID(context, applicationId);
}

if (applicationContext == null) {
applicationContext = context.getApplicationContext();
}
Expand Down Expand Up @@ -751,7 +706,7 @@ private static SessionEventsState getSessionEventsState(Context context, AccessT
// Retrieve attributionId, but we will only send it if attribution is supported for the app.
String attributionId = Settings.getAttributionId(context.getContentResolver());

state = new SessionEventsState(attributionId, context.getPackageName());
state = new SessionEventsState(attributionId, context.getPackageName(), hashedDeviceAndAppId);
stateMap.put(accessTokenAppId, state);
}
return state;
Expand Down Expand Up @@ -809,7 +764,7 @@ private static void flushAndWait(final FlushReason reason) {
private static FlushStatistics buildAndExecuteRequests(FlushReason reason, Set<AccessTokenAppIdPair> keysToFlush) {
FlushStatistics flushResults = new FlushStatistics();

boolean limitEventUsage = getLimitEventUsage(applicationContext);
boolean limitEventUsage = Settings.getLimitEventAndDataUsage(applicationContext);

List<Request> requestsToExecute = new ArrayList<Request>();
for (AccessTokenAppIdPair accessTokenAppId : keysToFlush) {
Expand Down Expand Up @@ -976,16 +931,18 @@ static class SessionEventsState {
private int numSkippedEventsDueToFullBuffer;
private String attributionId;
private String packageName;
private String hashedDeviceAndAppId;

public static final String EVENT_COUNT_KEY = "event_count";
public static final String ENCODED_EVENTS_KEY = "encoded_events";
public static final String NUM_SKIPPED_KEY = "num_skipped";

private final int MAX_ACCUMULATED_LOG_EVENTS = 1000;

public SessionEventsState(String attributionId, String packageName) {
public SessionEventsState(String attributionId, String packageName, String hashedDeviceAndAppId) {
this.attributionId = attributionId;
this.packageName = packageName;
this.hashedDeviceAndAppId = hashedDeviceAndAppId;
}

// Synchronize here and in other methods on this class, because could be coming in from different
Expand Down Expand Up @@ -1062,11 +1019,11 @@ private void populateRequest(Request request, int numSkipped, JSONArray events,
publishParams.setProperty("num_skipped_events", numSkipped);
}

if (includeAttribution && attributionId != null) {
publishParams.setProperty("attribution", attributionId);
if (includeAttribution) {
Utility.setAppEventAttributionParameters(publishParams, attributionId,
hashedDeviceAndAppId, limitEventUsage);
}

publishParams.setProperty("application_tracking_enabled", !limitEventUsage);
publishParams.setProperty("application_package_name", packageName);

request.setGraphObject(publishParams);
Expand Down
7 changes: 7 additions & 0 deletions facebook/src/com/facebook/AuthorizationClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,13 @@ void cancel() {
}
}

@Override
boolean needsRestart() {
// if the getTokenClient is null, that means an orientation change has occurred, and we need
// to recreate the GetTokenClient, so return true to indicate we need a restart
return getTokenClient == null;
}

boolean tryAuthorize(final AuthorizationRequest request) {
getTokenClient = new GetTokenClient(context, request.getApplicationId());
if (!getTokenClient.start()) {
Expand Down
4 changes: 2 additions & 2 deletions facebook/src/com/facebook/FacebookSdkVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
package com.facebook;

final class FacebookSdkVersion {
public static final String BUILD = "3.5.2";
public static final String MIGRATION_BUNDLE = "fbsdk:20130708";
public static final String BUILD = "3.6.0";
public static final String MIGRATION_BUNDLE = "fbsdk:20131203";
}
Loading

0 comments on commit aa04d8a

Please sign in to comment.