Skip to content

Commit

Permalink
Facebook Android SDK 3.21
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Lang committed Dec 1, 2014
1 parent 2c7e82a commit 9a83129
Show file tree
Hide file tree
Showing 138 changed files with 256 additions and 82 deletions.
Binary file modified facebook/TestApp/res/drawable-hdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/TestApp/res/drawable-ldpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/TestApp/res/drawable-mdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/res/drawable-hdpi/com_facebook_button_blue_normal.9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/res/drawable-hdpi/com_facebook_button_blue_pressed.9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/res/drawable-hdpi/com_facebook_button_grey_normal.9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/res/drawable-hdpi/com_facebook_button_grey_pressed.9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/res/drawable-hdpi/com_facebook_button_like_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/res/drawable-hdpi/com_facebook_close.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/res/drawable-hdpi/com_facebook_inverse_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/res/drawable-hdpi/com_facebook_logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/res/drawable-hdpi/com_facebook_picker_magnifier.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/res/drawable-hdpi/com_facebook_tooltip_black_topnub.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/res/drawable-hdpi/com_facebook_tooltip_black_xout.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/res/drawable-hdpi/com_facebook_tooltip_blue_topnub.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/res/drawable-hdpi/com_facebook_tooltip_blue_xout.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified facebook/res/drawable-ldpi/com_facebook_close.png
Binary file modified facebook/res/drawable-mdpi/com_facebook_button_blue_normal.9.png
Binary file modified facebook/res/drawable-mdpi/com_facebook_inverse_icon.png
Binary file modified facebook/res/drawable-mdpi/com_facebook_picker_magnifier.png
Binary file modified facebook/res/drawable-mdpi/com_facebook_tooltip_black_topnub.png
Binary file modified facebook/res/drawable-mdpi/com_facebook_tooltip_black_xout.png
Binary file modified facebook/res/drawable-mdpi/com_facebook_tooltip_blue_topnub.png
Binary file modified facebook/res/drawable-mdpi/com_facebook_tooltip_blue_xout.png
Binary file modified facebook/res/drawable-xhdpi/com_facebook_button_blue_pressed.9.png
Binary file modified facebook/res/drawable-xhdpi/com_facebook_button_grey_pressed.9.png
Binary file modified facebook/res/drawable-xhdpi/com_facebook_button_like_icon.png
Binary file modified facebook/res/drawable-xhdpi/com_facebook_close.png
Binary file modified facebook/res/drawable-xhdpi/com_facebook_inverse_icon.png
Binary file modified facebook/res/drawable-xhdpi/com_facebook_logo.png
Binary file modified facebook/res/drawable-xhdpi/com_facebook_picker_magnifier.png
Binary file modified facebook/res/drawable-xhdpi/com_facebook_tooltip_black_xout.png
Binary file modified facebook/res/drawable-xhdpi/com_facebook_tooltip_blue_topnub.png
Binary file modified facebook/res/drawable-xhdpi/com_facebook_tooltip_blue_xout.png
Binary file modified facebook/res/drawable-xxhdpi/com_facebook_button_like_icon.png
Binary file modified facebook/res/drawable/com_facebook_button_blue_focused.9.png
Binary file modified facebook/res/drawable/com_facebook_button_blue_normal.9.png
Binary file modified facebook/res/drawable/com_facebook_button_blue_pressed.9.png
Binary file modified facebook/res/drawable/com_facebook_button_check_off.png
Binary file modified facebook/res/drawable/com_facebook_button_grey_focused.9.png
Binary file modified facebook/res/drawable/com_facebook_button_grey_normal.9.png
Binary file modified facebook/res/drawable/com_facebook_button_grey_pressed.9.png
Binary file modified facebook/res/drawable/com_facebook_button_like_background.png
Binary file modified facebook/res/drawable/com_facebook_button_like_icon.png
Binary file modified facebook/res/drawable/com_facebook_button_like_icon_selected.png
Binary file modified facebook/res/drawable/com_facebook_close.png
Binary file modified facebook/res/drawable/com_facebook_inverse_icon.png
Binary file modified facebook/res/drawable/com_facebook_list_divider.9.png
Binary file modified facebook/res/drawable/com_facebook_logo.png
Binary file modified facebook/res/drawable/com_facebook_picker_list_focused.9.png
Binary file modified facebook/res/drawable/com_facebook_picker_list_longpressed.9.png
Binary file modified facebook/res/drawable/com_facebook_picker_list_pressed.9.png
14 changes: 7 additions & 7 deletions facebook/src/com/facebook/NativeAppCallAttachmentStore.java
Expand Up @@ -76,22 +76,22 @@ public void processAttachment(Bitmap attachment, File outputFile) throws IOExcep
}

/**
* Adds a number of bitmap attachment files associated with a native app call. The attachments will be
* Adds a number of bitmap/video attachment files associated with a native app call. The attachments will be
* served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
*
* @param context the Context the call is being made from
* @param callId the unique ID of the call
* @param imageAttachments a Map of attachment names to Files containing the bitmaps; the attachment names will be
* part of the URI processed by openFile
* @param mediaAttachmentFiles a Map of attachment names to Files containing the bitmaps/videos; the attachment
* names will be part of the URI processed by openFile
* @throws java.io.IOException
*/
public void addAttachmentFilesForCall(Context context, UUID callId, Map<String, File> imageAttachmentFiles) {
public void addAttachmentFilesForCall(Context context, UUID callId, Map<String, File> mediaAttachmentFiles) {
Validate.notNull(context, "context");
Validate.notNull(callId, "callId");
Validate.containsNoNulls(imageAttachmentFiles.values(), "imageAttachmentFiles");
Validate.containsNoNullOrEmpty(imageAttachmentFiles.keySet(), "imageAttachmentFiles");
Validate.containsNoNulls(mediaAttachmentFiles.values(), "mediaAttachmentFiles");
Validate.containsNoNullOrEmpty(mediaAttachmentFiles.keySet(), "mediaAttachmentFiles");

addAttachments(context, callId, imageAttachmentFiles, new ProcessAttachment<File>() {
addAttachments(context, callId, mediaAttachmentFiles, new ProcessAttachment<File>() {
@Override
public void processAttachment(File attachment, File outputFile) throws IOException {
FileOutputStream outputStream = new FileOutputStream(outputFile);
Expand Down
1 change: 1 addition & 0 deletions facebook/src/com/facebook/internal/AnalyticsEvents.java
Expand Up @@ -37,6 +37,7 @@ public class AnalyticsEvents {
public static final String EVENT_NATIVE_DIALOG_TYPE_OG_MESSAGE = "fb_dialogs_present_message_og";
public static final String EVENT_NATIVE_DIALOG_TYPE_PHOTO_SHARE = "fb_dialogs_present_share_photo";
public static final String EVENT_NATIVE_DIALOG_TYPE_PHOTO_MESSAGE = "fb_dialogs_present_message_photo";
public static final String EVENT_NATIVE_DIALOG_TYPE_VIDEO_SHARE = "fb_dialogs_present_share_video";
public static final String EVENT_NATIVE_DIALOG_TYPE_LIKE = "fb_dialogs_present_like";

public static final String EVENT_LIKE_VIEW_CANNOT_PRESENT_DIALOG = "fb_like_control_cannot_present_dialog";
Expand Down
Expand Up @@ -24,14 +24,11 @@
import android.os.Looper;
import android.webkit.WebView;
import com.facebook.FacebookException;
import com.facebook.android.Util;
import com.facebook.widget.FacebookDialog;
import com.facebook.widget.WebDialog;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.EnumSet;

/**
* com.facebook.internal is solely for the use of other packages within the Facebook SDK for Android. Use of
* any of the classes in this package is unsupported, and they may be modified or removed without warning at
Expand Down
96 changes: 72 additions & 24 deletions facebook/src/com/facebook/internal/LikeActionController.java
Expand Up @@ -683,26 +683,42 @@ private FacebookDialog.Callback getFacebookDialogCallback(final Bundle analytics
return new FacebookDialog.Callback() {
@Override
public void onComplete(FacebookDialog.PendingCall pendingCall, Bundle data) {
if (!data.containsKey(LIKE_DIALOG_RESPONSE_OBJECT_IS_LIKED_KEY)) {
// This is an empty result that we can't handle. Don't lose like state.
if (data == null || !data.containsKey(LIKE_DIALOG_RESPONSE_OBJECT_IS_LIKED_KEY)) {
// This is an empty result that we can't handle.
return;
}

boolean isObjectLiked = data.getBoolean(LIKE_DIALOG_RESPONSE_OBJECT_IS_LIKED_KEY);
String likeCountString = data.getString(LIKE_DIALOG_RESPONSE_LIKE_COUNT_STRING_KEY);
String socialSentence = data.getString(LIKE_DIALOG_RESPONSE_SOCIAL_SENTENCE_KEY);
String unlikeToken = data.getString(LIKE_DIALOG_RESPONSE_UNLIKE_TOKEN_KEY);

// Default to known/cached state, if properties are missing.
String likeCountStringWithLike = LikeActionController.this.likeCountStringWithLike;
String likeCountStringWithoutLike = LikeActionController.this.likeCountStringWithoutLike;
if (data.containsKey(LIKE_DIALOG_RESPONSE_LIKE_COUNT_STRING_KEY)) {
likeCountStringWithLike = data.getString(LIKE_DIALOG_RESPONSE_LIKE_COUNT_STRING_KEY);
likeCountStringWithoutLike = likeCountStringWithLike;
}

String socialSentenceWithLike = LikeActionController.this.socialSentenceWithLike;
String socialSentenceWithoutWithoutLike = LikeActionController.this.socialSentenceWithoutLike;
if (data.containsKey(LIKE_DIALOG_RESPONSE_SOCIAL_SENTENCE_KEY)) {
socialSentenceWithLike = data.getString(LIKE_DIALOG_RESPONSE_SOCIAL_SENTENCE_KEY);
socialSentenceWithoutWithoutLike = socialSentenceWithLike;
}

String unlikeToken = data.containsKey(LIKE_DIALOG_RESPONSE_OBJECT_IS_LIKED_KEY)
? data.getString(LIKE_DIALOG_RESPONSE_UNLIKE_TOKEN_KEY)
: LikeActionController.this.unlikeToken;

Bundle logParams = (analyticsParameters == null) ? new Bundle() : analyticsParameters;
logParams.putString(AnalyticsEvents.PARAMETER_CALL_ID, pendingCall.getCallId().toString());
appEventsLogger.logSdkEvent(AnalyticsEvents.EVENT_LIKE_VIEW_DIALOG_DID_SUCCEED, null, logParams);

updateState(
isObjectLiked,
likeCountString,
likeCountString,
socialSentence,
socialSentence,
likeCountStringWithLike,
likeCountStringWithoutLike,
socialSentenceWithLike,
socialSentenceWithoutWithoutLike,
unlikeToken);
}

Expand Down Expand Up @@ -918,17 +934,37 @@ private void refreshStatusViaService() {
LikeStatusClient.CompletedListener callback = new LikeStatusClient.CompletedListener() {
@Override
public void completed(Bundle result) {
// Don't lose old state if the service response is incomplete.
if (result == null || !result.containsKey(NativeProtocol.EXTRA_OBJECT_IS_LIKED)) {
// Don't lose old state if the service response is incomplete.
return;
}

boolean objectIsLiked = result.getBoolean(NativeProtocol.EXTRA_OBJECT_IS_LIKED);
String likeCountWithLike = result.getString(NativeProtocol.EXTRA_LIKE_COUNT_STRING_WITH_LIKE);
String likeCountWithoutLike = result.getString(NativeProtocol.EXTRA_LIKE_COUNT_STRING_WITHOUT_LIKE);
String socialSentenceWithLike = result.getString(NativeProtocol.EXTRA_SOCIAL_SENTENCE_WITH_LIKE);
String socialSentenceWithoutLike = result.getString(NativeProtocol.EXTRA_SOCIAL_SENTENCE_WITHOUT_LIKE);
String unlikeToken = result.getString(NativeProtocol.EXTRA_UNLIKE_TOKEN);

String likeCountWithLike =
result.containsKey(NativeProtocol.EXTRA_LIKE_COUNT_STRING_WITH_LIKE)
? result.getString(NativeProtocol.EXTRA_LIKE_COUNT_STRING_WITH_LIKE)
: LikeActionController.this.likeCountStringWithLike;

String likeCountWithoutLike =
result.containsKey(NativeProtocol.EXTRA_LIKE_COUNT_STRING_WITHOUT_LIKE)
? result.getString(NativeProtocol.EXTRA_LIKE_COUNT_STRING_WITHOUT_LIKE)
: LikeActionController.this.likeCountStringWithoutLike;

String socialSentenceWithLike =
result.containsKey(NativeProtocol.EXTRA_SOCIAL_SENTENCE_WITH_LIKE)
? result.getString(NativeProtocol.EXTRA_SOCIAL_SENTENCE_WITH_LIKE)
: LikeActionController.this.socialSentenceWithLike;

String socialSentenceWithoutLike =
result.containsKey(NativeProtocol.EXTRA_SOCIAL_SENTENCE_WITHOUT_LIKE)
? result.getString(NativeProtocol.EXTRA_SOCIAL_SENTENCE_WITHOUT_LIKE)
: LikeActionController.this.socialSentenceWithoutLike;

String unlikeToken =
result.containsKey(NativeProtocol.EXTRA_UNLIKE_TOKEN)
? result.getString(NativeProtocol.EXTRA_UNLIKE_TOKEN)
: LikeActionController.this.unlikeToken;

updateState(
objectIsLiked,
Expand Down Expand Up @@ -1162,7 +1198,9 @@ protected void processError(FacebookRequestError error) {
}

private class GetOGObjectLikesRequestWrapper extends AbstractRequestWrapper {
boolean objectIsLiked;
// Initialize the like status to what we currently have. This way, empty/error responses don't end
// up clearing out the state.
boolean objectIsLiked = LikeActionController.this.isObjectLiked;
String unlikeToken;

GetOGObjectLikesRequestWrapper(String objectId) {
Expand Down Expand Up @@ -1204,10 +1242,12 @@ protected void processError(FacebookRequestError error) {
}

private class GetEngagementRequestWrapper extends AbstractRequestWrapper {
String likeCountStringWithLike;
String likeCountStringWithoutLike;
String socialSentenceStringWithLike;
String socialSentenceStringWithoutLike;
// Initialize the like status to what we currently have. This way, empty/error responses don't end
// up clearing out the state.
String likeCountStringWithLike = LikeActionController.this.likeCountStringWithLike;
String likeCountStringWithoutLike = LikeActionController.this.likeCountStringWithoutLike;
String socialSentenceStringWithLike = LikeActionController.this.socialSentenceWithLike;
String socialSentenceStringWithoutLike = LikeActionController.this.socialSentenceWithoutLike;

GetEngagementRequestWrapper(String objectId) {
super(objectId);
Expand All @@ -1228,10 +1268,18 @@ private class GetEngagementRequestWrapper extends AbstractRequestWrapper {
protected void processSuccess(Response response) {
JSONObject engagementResults = Utility.tryGetJSONObjectFromResponse(response.getGraphObject(), "engagement");
if (engagementResults != null) {
likeCountStringWithLike = engagementResults.optString("count_string_with_like");
likeCountStringWithoutLike = engagementResults.optString("count_string_without_like");
socialSentenceStringWithLike = engagementResults.optString("social_sentence_with_like");
socialSentenceStringWithoutLike = engagementResults.optString("social_sentence_without_like");
// Missing properties in the response should default to cached like status
likeCountStringWithLike =
engagementResults.optString("count_string_with_like", likeCountStringWithLike);

likeCountStringWithoutLike =
engagementResults.optString("count_string_without_like", likeCountStringWithoutLike);

socialSentenceStringWithLike =
engagementResults.optString("social_sentence_with_like", socialSentenceStringWithLike);

socialSentenceStringWithoutLike =
engagementResults.optString("social_sentence_without_like", socialSentenceStringWithoutLike);
}
}

Expand Down
31 changes: 25 additions & 6 deletions facebook/src/com/facebook/internal/NativeProtocol.java
Expand Up @@ -62,6 +62,8 @@ public final class NativeProtocol {
public static final int PROTOCOL_VERSION_20140324 = 20140324;
public static final int PROTOCOL_VERSION_20140701 = 20140701;
public static final int PROTOCOL_VERSION_20141001 = 20141001;
public static final int PROTOCOL_VERSION_20141028 = 20141028;
public static final int PROTOCOL_VERSION_20141107 = 20141107; // Bucketed Result Intents

public static final String EXTRA_PROTOCOL_VERSION = "com.facebook.platform.protocol.PROTOCOL_VERSION";
public static final String EXTRA_PROTOCOL_ACTION = "com.facebook.platform.protocol.PROTOCOL_ACTION";
Expand Down Expand Up @@ -150,6 +152,11 @@ public final class NativeProtocol {
"com.facebook.platform.extra.EXPIRES_SECONDS_SINCE_EPOCH";
// EXTRA_PERMISSIONS

public static final String RESULT_ARGS_ACCESS_TOKEN = "access_token";
public static final String RESULT_ARGS_EXPIRES_SECONDS_SINCE_EPOCH =
"expires_seconds_since_epoch";
public static final String RESULT_ARGS_PERMISSIONS = "permissions";

// Extras supported for ACTION_FEED_DIALOG:
public static final String EXTRA_PLACE_TAG = "com.facebook.platform.extra.PLACE";
public static final String EXTRA_FRIEND_TAGS = "com.facebook.platform.extra.FRIENDS";
Expand All @@ -172,6 +179,7 @@ public final class NativeProtocol {
public static final String METHOD_ARGS_REF = "REF";
public static final String METHOD_ARGS_DATA_FAILURES_FATAL = "DATA_FAILURES_FATAL";
public static final String METHOD_ARGS_PHOTOS = "PHOTOS";
public static final String METHOD_ARGS_VIDEO = "VIDEO";

// Extras supported for ACTION_OGACTIONPUBLISH_DIALOG:
public static final String EXTRA_ACTION = "com.facebook.platform.extra.ACTION";
Expand Down Expand Up @@ -213,6 +221,12 @@ public final class NativeProtocol {
public static final String STATUS_ERROR_SUBCODE = "com.facebook.platform.status.ERROR_SUBCODE";
public static final String STATUS_ERROR_JSON = "com.facebook.platform.status.ERROR_JSON";

public static final String BRIDGE_ARG_ERROR_TYPE = "error_type";
public static final String BRIDGE_ARG_ERROR_DESCRIPTION = "error_description";
public static final String BRIDGE_ARG_ERROR_CODE = "error_code";
public static final String BRIDGE_ARG_ERROR_SUBCODE = "error_subcode";
public static final String BRIDGE_ARG_ERROR_JSON = "error_json";

// Expected values for ERROR_KEY_TYPE. Clients should tolerate other values:
public static final String ERROR_UNKNOWN_ERROR = "UnknownError";
public static final String ERROR_PROTOCOL_ERROR = "ProtocolError";
Expand Down Expand Up @@ -428,6 +442,8 @@ public static final int getLatestKnownVersion() {
// Note: be sure this stays sorted in descending order; add new versions at the beginning
private static final List<Integer> KNOWN_PROTOCOL_VERSIONS =
Arrays.asList(
PROTOCOL_VERSION_20141107,
PROTOCOL_VERSION_20141028,
PROTOCOL_VERSION_20141001,
PROTOCOL_VERSION_20140701,
PROTOCOL_VERSION_20140324,
Expand Down Expand Up @@ -578,8 +594,6 @@ public static Bundle getErrorDataFromResultIntent(Intent resultIntent) {
Bundle bridgeArgs = getBridgeArgumentsFromIntent(resultIntent);
if (bridgeArgs != null) {
return bridgeArgs.getBundle(BRIDGE_ARG_ERROR_BUNDLE);


}

return resultIntent.getExtras();
Expand All @@ -590,10 +604,15 @@ public static Exception getExceptionFromErrorData(Bundle errorData) {
return null;
}

// TODO This is not going to work for JS dialogs, where the keys are not STATUS_ERROR_TYPE etc.
// TODO However, it should keep existing dialogs functional
String type = errorData.getString(STATUS_ERROR_TYPE);
String description = errorData.getString(STATUS_ERROR_DESCRIPTION);
String type = errorData.getString(BRIDGE_ARG_ERROR_TYPE);
if (type == null) {
type = errorData.getString(STATUS_ERROR_TYPE);
}

String description = errorData.getString(BRIDGE_ARG_ERROR_DESCRIPTION);
if (description == null) {
description = errorData.getString(STATUS_ERROR_DESCRIPTION);
}

if (type != null && type.equalsIgnoreCase(ERROR_USER_CANCELED)) {
return new FacebookOperationCanceledException(description);
Expand Down

0 comments on commit 9a83129

Please sign in to comment.