diff --git a/README.mdown b/README.mdown index 73a4b4d6e4..aace7b7b5b 100644 --- a/README.mdown +++ b/README.mdown @@ -68,25 +68,25 @@ include the appropriate dependency (or dependencies) listed below in your `app/b dependencies { // Facebook Core only (Analytics) - implementation 'com.facebook.android:facebook-core:4.31.0' + implementation 'com.facebook.android:facebook-core:4.32.0' // Facebook Login only - implementation 'com.facebook.android:facebook-login:4.31.0' + implementation 'com.facebook.android:facebook-login:4.32.0' // Facebook Share only - implementation 'com.facebook.android:facebook-share:4.31.0' + implementation 'com.facebook.android:facebook-share:4.32.0' // Facebook Places only - implementation 'com.facebook.android:facebook-places:4.31.0' + implementation 'com.facebook.android:facebook-places:4.32.0' // Facbeook Messenger only - implementation 'com.facebook.android:facebook-messenger:4.31.0' + implementation 'com.facebook.android:facebook-messenger:4.32.0' // Facebook App Links only - implementation 'com.facebook.android:facebook-applinks:4.31.0' + implementation 'com.facebook.android:facebook-applinks:4.32.0' // Facebook Android SDK (everything) - implementation 'com.facebook.android:facebook-android-sdk:4.31.0' + implementation 'com.facebook.android:facebook-android-sdk:4.32.0' } You may also need to add the following to your project/build.gradle file. diff --git a/facebook-core/src/main/java/com/facebook/FacebookSdkVersion.java b/facebook-core/src/main/java/com/facebook/FacebookSdkVersion.java index c7df2770cb..8546b5d8ad 100644 --- a/facebook-core/src/main/java/com/facebook/FacebookSdkVersion.java +++ b/facebook-core/src/main/java/com/facebook/FacebookSdkVersion.java @@ -21,5 +21,5 @@ package com.facebook; final class FacebookSdkVersion { - public static final String BUILD = "4.31.0"; + public static final String BUILD = "4.32.0"; } diff --git a/facebook-core/src/main/java/com/facebook/GraphRequest.java b/facebook-core/src/main/java/com/facebook/GraphRequest.java index 35dbf155fd..a9656a7ecb 100644 --- a/facebook-core/src/main/java/com/facebook/GraphRequest.java +++ b/facebook-core/src/main/java/com/facebook/GraphRequest.java @@ -1442,7 +1442,11 @@ private void addCommonParameters() { } } - private String appendParametersToBaseUrl(String baseUrl) { + private String appendParametersToBaseUrl(String baseUrl, Boolean isBatch) { + if (!isBatch && httpMethod == HttpMethod.POST) { + return baseUrl; + } + Uri.Builder uriBuilder = Uri.parse(baseUrl).buildUpon(); Set keys = this.parameters.keySet(); @@ -1480,7 +1484,7 @@ final String getRelativeUrlForBatchedRequest() { String baseUrl = String.format("%s/%s", ServerProtocol.getGraphUrlBase(), getGraphPathWithVersion()); addCommonParameters(); - String fullUrl = appendParametersToBaseUrl(baseUrl); + String fullUrl = appendParametersToBaseUrl(baseUrl, true); Uri uri = Uri.parse(fullUrl); String relativeUrl = String.format("%s?%s", uri.getPath(), uri.getQuery()); return relativeUrl; @@ -1502,7 +1506,7 @@ final String getUrlForSingleRequest() { String baseUrl = String.format("%s/%s", graphBaseUrlBase, getGraphPathWithVersion()); addCommonParameters(); - return appendParametersToBaseUrl(baseUrl); + return appendParametersToBaseUrl(baseUrl, false); } private String getGraphPathWithVersion() { diff --git a/facebook-core/src/main/java/com/facebook/appevents/AppEventsConstants.java b/facebook-core/src/main/java/com/facebook/appevents/AppEventsConstants.java index d824fe573b..f680304f94 100644 --- a/facebook-core/src/main/java/com/facebook/appevents/AppEventsConstants.java +++ b/facebook-core/src/main/java/com/facebook/appevents/AppEventsConstants.java @@ -107,8 +107,28 @@ public class AppEventsConstants { */ public static final String EVENT_NAME_SPENT_CREDITS = "fb_mobile_spent_credits"; + /** + * Log the live streaming events from sdk + */ + public static final String EVENT_NAME_LIVE_STREAMING_START = "fb_sdk_live_streaming_start"; + public static final String EVENT_NAME_LIVE_STREAMING_STOP = "fb_sdk_live_streaming_stop"; + public static final String EVENT_NAME_LIVE_STREAMING_PAUSE = "fb_sdk_live_streaming_pause"; + public static final String EVENT_NAME_LIVE_STREAMING_RESUME = "fb_sdk_live_streaming_resume"; + public static final String EVENT_NAME_LIVE_STREAMING_ERROR = "fb_sdk_live_streaming_error"; + public static final String EVENT_NAME_LIVE_STREAMING_UPDATE_STATUS = + "fb_sdk_live_streaming_update_status"; + // Event parameters + /** + * Paramete keys for live streaming events + * + */ + public static final String EVENT_PARAM_LIVE_STREAMING_PREV_STATUS = + "live_streaming_prev_status"; + public static final String EVENT_PARAM_LIVE_STREAMING_STATUS = "live_streaming_status"; + public static final String EVENT_PARAM_LIVE_STREAMING_ERROR = "live_streaming_error"; + /** * Parameter key used to specify currency used with logged event. E.g. "USD", "EUR", "GBP". See * ISO-4217 diff --git a/facebook-core/src/main/java/com/facebook/appevents/internal/AutomaticAnalyticsLogger.java b/facebook-core/src/main/java/com/facebook/appevents/internal/AutomaticAnalyticsLogger.java index 76edb1817e..9e55fbbfb5 100644 --- a/facebook-core/src/main/java/com/facebook/appevents/internal/AutomaticAnalyticsLogger.java +++ b/facebook-core/src/main/java/com/facebook/appevents/internal/AutomaticAnalyticsLogger.java @@ -78,24 +78,26 @@ public static void logActivateAppEvent() { } public static void logActivityTimeSpentEvent(String activityName, long timeSpentInSeconds) { - final Context context = FacebookSdk.getApplicationContext(); - final String appId = FacebookSdk.getApplicationId(); - Validate.notNull(context, "context"); - final FetchedAppSettings settings = FetchedAppSettingsManager.queryAppSettings( - appId, false); - if (settings != null && settings.getAutomaticLoggingEnabled() && timeSpentInSeconds > 0) { - AppEventsLogger appEventsLogger = AppEventsLogger.newLogger(context); - Bundle params = new Bundle(1); - params.putCharSequence(Constants.AA_TIME_SPENT_SCREEN_PARAMETER_NAME, activityName); - appEventsLogger.logEvent( - Constants.AA_TIME_SPENT_EVENT_NAME, timeSpentInSeconds, params); + final Context context = FacebookSdk.getApplicationContext(); + final String appId = FacebookSdk.getApplicationId(); + Validate.notNull(context, "context"); + final FetchedAppSettings settings = FetchedAppSettingsManager.queryAppSettings( + appId, false); + if (settings != null + && settings.getAutomaticLoggingEnabled() + && timeSpentInSeconds > 0) { + AppEventsLogger appEventsLogger = AppEventsLogger.newLogger(context); + Bundle params = new Bundle(1); + params.putCharSequence(Constants.AA_TIME_SPENT_SCREEN_PARAMETER_NAME, activityName); + appEventsLogger.logEvent( + Constants.AA_TIME_SPENT_EVENT_NAME, timeSpentInSeconds, params); + } } - } public static boolean logInAppPurchaseEvent( - final Context context, - int resultCode, - Intent data) { + final Context context, + int resultCode, + Intent data) { if (data == null || !isImplicitPurchaseLoggingEnabled()) { return false; diff --git a/facebook-core/src/main/java/com/facebook/internal/FetchedAppSettings.java b/facebook-core/src/main/java/com/facebook/internal/FetchedAppSettings.java index 42ca0ee36d..e678a4be9e 100644 --- a/facebook-core/src/main/java/com/facebook/internal/FetchedAppSettings.java +++ b/facebook-core/src/main/java/com/facebook/internal/FetchedAppSettings.java @@ -46,6 +46,7 @@ public final class FetchedAppSettings { private String smartLoginBookmarkIconURL; private String smartLoginMenuIconURL; private boolean IAPAutomaticLoggingEnabled; + private String sdkUpdateMessage; public FetchedAppSettings(boolean supportsImplicitLogging, String nuxContent, @@ -58,7 +59,8 @@ public FetchedAppSettings(boolean supportsImplicitLogging, FacebookRequestErrorClassification errorClassification, String smartLoginBookmarkIconURL, String smartLoginMenuIconURL, - boolean IAPAutomaticLoggingEnabled + boolean IAPAutomaticLoggingEnabled, + String sdkUpdateMessage ) { this.supportsImplicitLogging = supportsImplicitLogging; this.nuxContent = nuxContent; @@ -72,6 +74,7 @@ public FetchedAppSettings(boolean supportsImplicitLogging, this.smartLoginBookmarkIconURL = smartLoginBookmarkIconURL; this.smartLoginMenuIconURL = smartLoginMenuIconURL; this.IAPAutomaticLoggingEnabled = IAPAutomaticLoggingEnabled; + this.sdkUpdateMessage = sdkUpdateMessage; } public boolean supportsImplicitLogging() { @@ -117,6 +120,8 @@ public boolean getIAPAutomaticLoggingEnabled() { return IAPAutomaticLoggingEnabled; } + public String getSdkUpdateMessage() { return sdkUpdateMessage; } + public static class DialogFeatureConfig { private static final String DIALOG_CONFIG_DIALOG_NAME_FEATURE_NAME_SEPARATOR = "\\|"; private static final String DIALOG_CONFIG_NAME_KEY = "name"; diff --git a/facebook-core/src/main/java/com/facebook/internal/FetchedAppSettingsManager.java b/facebook-core/src/main/java/com/facebook/internal/FetchedAppSettingsManager.java index 75cf952047..febd2e96a6 100644 --- a/facebook-core/src/main/java/com/facebook/internal/FetchedAppSettingsManager.java +++ b/facebook-core/src/main/java/com/facebook/internal/FetchedAppSettingsManager.java @@ -25,16 +25,20 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.text.TextUtils; +import android.util.Log; import com.facebook.FacebookSdk; import com.facebook.GraphRequest; import com.facebook.appevents.internal.AutomaticAnalyticsLogger; import com.facebook.appevents.internal.Constants; +import com.facebook.core.BuildConfig; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import java.util.Arrays; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -72,6 +76,7 @@ public final class FetchedAppSettingsManager { "seamless_login"; private static final String SMART_LOGIN_BOOKMARK_ICON_URL = "smart_login_bookmark_icon_url"; private static final String SMART_LOGIN_MENU_ICON_URL = "smart_login_menu_icon_url"; + private static final String SDK_UPDATE_MESSAGE = "sdk_update_message"; private static final String[] APP_SETTING_FIELDS = new String[]{ APP_SETTING_SUPPORTS_IMPLICIT_SDK_LOGGING, @@ -84,7 +89,7 @@ public final class FetchedAppSettingsManager { APP_SETTING_APP_EVENTS_FEATURE_BITMASK, APP_SETTING_SMART_LOGIN_OPTIONS, SMART_LOGIN_BOOKMARK_ICON_URL, - SMART_LOGIN_MENU_ICON_URL, + SMART_LOGIN_MENU_ICON_URL }; private static final String APPLICATION_FIELDS = "fields"; @@ -92,6 +97,8 @@ public final class FetchedAppSettingsManager { new ConcurrentHashMap(); private static AtomicBoolean loadingSettings = new AtomicBoolean(false); + private static boolean printedSDKUpdatedMessage = false; + public static void loadAppSettingsAsync() { final Context context = FacebookSdk.getApplicationContext(); final String applicationId = FacebookSdk.getApplicationId(); @@ -112,6 +119,7 @@ public void run() { APP_SETTINGS_PREFS_STORE, Context.MODE_PRIVATE); String settingsJSONString = sharedPrefs.getString(settingsKey, null); + FetchedAppSettings appSettings = null; if (!Utility.isNullOrEmpty(settingsJSONString)) { JSONObject settingsJSON = null; try { @@ -120,7 +128,7 @@ public void run() { Utility.logd(Utility.LOG_TAG, je); } if (settingsJSON != null) { - parseAppSettingsFromJSON(applicationId, settingsJSON); + appSettings = parseAppSettingsFromJSON(applicationId, settingsJSON); } } @@ -133,6 +141,17 @@ public void run() { .apply(); } + // Print log to notify developers to upgrade SDK when version is too old + if (appSettings != null) { + String updateMessage = appSettings.getSdkUpdateMessage(); + if (!printedSDKUpdatedMessage + && updateMessage != null + && updateMessage.length() > 0) { + printedSDKUpdatedMessage = true; + Log.w(TAG, updateMessage); + } + } + // Start log activate & deactivate app events, in case autoLogAppEvents flag is set AutomaticAnalyticsLogger.logActivateAppEvent(); @@ -197,7 +216,8 @@ private static FetchedAppSettings parseAppSettingsFromJSON( errorClassification, settingsJSON.optString(SMART_LOGIN_BOOKMARK_ICON_URL), settingsJSON.optString(SMART_LOGIN_MENU_ICON_URL), - inAppPurchaseAutomaticLoggingEnabled + inAppPurchaseAutomaticLoggingEnabled, + settingsJSON.optString(SDK_UPDATE_MESSAGE) ); fetchedAppSettings.put(applicationId, result); @@ -209,7 +229,13 @@ private static FetchedAppSettings parseAppSettingsFromJSON( // main thread. private static JSONObject getAppSettingsQueryResponse(String applicationId) { Bundle appSettingsParams = new Bundle(); - appSettingsParams.putString(APPLICATION_FIELDS, TextUtils.join(",", APP_SETTING_FIELDS)); + ArrayList appSettingFields = new ArrayList<>(Arrays.asList(APP_SETTING_FIELDS)); + + if (BuildConfig.DEBUG) { + appSettingFields.add(SDK_UPDATE_MESSAGE); + } + + appSettingsParams.putString(APPLICATION_FIELDS, TextUtils.join(",", appSettingFields)); GraphRequest request = GraphRequest.newGraphPathRequest(null, applicationId, null); request.setSkipClientToken(true); diff --git a/samples/LoginSample/build.gradle b/samples/LoginSample/build.gradle index 44e036d8b8..399e25fecf 100644 --- a/samples/LoginSample/build.gradle +++ b/samples/LoginSample/build.gradle @@ -14,11 +14,12 @@ android { buildTypes { debug { - minifyEnabled true + minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } release { minifyEnabled true + useProguard true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } diff --git a/samples/RPSSample/gradle/wrapper/gradle-wrapper.jar b/samples/RPSSample/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000..13372aef5e Binary files /dev/null and b/samples/RPSSample/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/RPSSample/gradle/wrapper/gradle-wrapper.properties b/samples/RPSSample/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..519effa656 --- /dev/null +++ b/samples/RPSSample/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Feb 21 15:51:04 PST 2018 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/settings.gradle b/settings.gradle index 609ee7435a..227da688a5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,7 @@ // Facebook SDK include ':facebook-core' include ':facebook-common', ':facebook-login', ':facebook-share', ':facebook-places', ':facebook-applinks', ':facebook-messenger' - +include ':facebook-loginkit' include ':facebook'