public static void setupAppCallForErrorResult(AppCall appCall, FacebookException exception) { if (exception == null) { return; } Validate.hasFacebookActivity(FacebookSdk.getApplicationContext()); Intent errorResultIntent = new Intent(); errorResultIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); errorResultIntent.setAction(FacebookActivity.PASS_THROUGH_CANCEL_ACTION); NativeProtocol.setupProtocolRequestIntent( errorResultIntent, appCall.getCallId().toString(), null, NativeProtocol.getLatestKnownVersion(), NativeProtocol.createBundleForException(exception)); appCall.setRequestIntent(errorResultIntent); }
public static void setupAppCallForWebDialog( AppCall appCall, String actionName, Bundle parameters) { Validate.hasFacebookActivity(FacebookSdk.getApplicationContext()); Validate.hasInternetPermissions(FacebookSdk.getApplicationContext()); Bundle intentParameters = new Bundle(); intentParameters.putString(NativeProtocol.WEB_DIALOG_ACTION, actionName); intentParameters.putBundle(NativeProtocol.WEB_DIALOG_PARAMS, parameters); Intent webDialogIntent = new Intent(); NativeProtocol.setupProtocolRequestIntent( webDialogIntent, appCall.getCallId().toString(), actionName, NativeProtocol.getLatestKnownVersion(), intentParameters); webDialogIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); webDialogIntent.setAction(FacebookDialogFragment.TAG); appCall.setRequestIntent(webDialogIntent); }
public static void hasFacebookActivity(Context context, boolean shouldThrow) { Validate.notNull(context, "context"); PackageManager pm = context.getPackageManager(); ActivityInfo activityInfo = null; if (pm != null) { ComponentName componentName = new ComponentName(context, FacebookActivity.class); try { activityInfo = pm.getActivityInfo(componentName, PackageManager.GET_ACTIVITIES); } catch (PackageManager.NameNotFoundException e) { } } if (activityInfo == null) { if (shouldThrow) { throw new IllegalStateException(FACEBOOK_ACTIVITY_NOT_FOUND_REASON); } else { Log.w(TAG, FACEBOOK_ACTIVITY_NOT_FOUND_REASON); } } }
public static void setupAppCallForErrorResult(AppCall appCall, FacebookException exception) { if (exception == null) { return; } Intent errorResultIntent = new Intent(); errorResultIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); errorResultIntent.setAction(FacebookActivity.PASS_THROUGH_CANCEL_ACTION); NativeProtocol.setupProtocolRequestIntent( errorResultIntent, appCall.getCallId().toString(), null, NativeProtocol.getLatestKnownVersion(), NativeProtocol.createBundleForException(exception)); appCall.setRequestIntent(errorResultIntent); }
public static void setupAppCallForWebDialog( AppCall appCall, String actionName, Bundle parameters) { Bundle intentParameters = new Bundle(); intentParameters.putString(NativeProtocol.WEB_DIALOG_ACTION, actionName); intentParameters.putBundle(NativeProtocol.WEB_DIALOG_PARAMS, parameters); Intent webDialogIntent = new Intent(); NativeProtocol.setupProtocolRequestIntent( webDialogIntent, appCall.getCallId().toString(), actionName, NativeProtocol.getLatestKnownVersion(), intentParameters); webDialogIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); webDialogIntent.setAction(FacebookDialogFragment.TAG); appCall.setRequestIntent(webDialogIntent); }
private Intent getFacebookActivityIntent(LoginClient.Request request) { Intent intent = new Intent(); intent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); intent.setAction(request.getLoginBehavior().toString()); // Let FacebookActivity populate extras appropriately LoginClient.Request authClientRequest = request; Bundle extras = new Bundle(); extras.putParcelable(LoginFragment.EXTRA_REQUEST, request); intent.putExtras(extras); return intent; }
@Test public void testRecyclerViewFBShareClicked_ShouldStartFBActivity() throws Exception { int positionToClick = 0; setUpShadowAdapter(positionToClick); shadowAdapter.itemVisible(positionToClick); shadowAdapter.performItemClickOverViewInHolder(positionToClick, R.id.fbShare); Intent intent = shadowActivity.peekNextStartedActivity(); assertEquals(new ComponentName(RuntimeEnvironment.application, FacebookActivity.class), intent.getComponent()); }
@Test public void testRecyclerViewFBSendClicked_ShouldStartFBActivity() throws Exception { int positionToClick = 0; setUpShadowAdapter(positionToClick); shadowAdapter.itemVisible(positionToClick); shadowAdapter.performItemClickOverViewInHolder(positionToClick, R.id.fbSend); Intent intent = shadowActivity.peekNextStartedActivity(); assertEquals(new ComponentName(RuntimeEnvironment.application, FacebookActivity.class), intent.getComponent()); }
private Intent getLoginActivityIntent(LoginClient.Request request) { Intent intent = new Intent(); intent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); intent.setAction(request.getLoginBehavior().toString()); // Let LoginActivity populate extras appropriately LoginClient.Request authClientRequest = request; Bundle extras = LoginFragment.populateIntentExtras(authClientRequest); intent.putExtras(extras); return intent; }
private Intent getFacebookActivityIntent(LoginClient.Request request) { Intent intent = new Intent(); intent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); intent.setAction(request.getLoginBehavior().toString()); // Let FacebookActivity populate extras appropriately LoginClient.Request authClientRequest = request; Bundle extras = LoginFragment.populateIntentExtras(authClientRequest); intent.putExtras(extras); return intent; }
public static void setupAppCallForWebFallbackDialog( AppCall appCall, Bundle parameters, DialogFeature feature) { Validate.hasFacebookActivity(FacebookSdk.getApplicationContext()); Validate.hasInternetPermissions(FacebookSdk.getApplicationContext()); String featureName = feature.name(); Uri fallbackUrl = getDialogWebFallbackUri(feature); if (fallbackUrl == null) { throw new FacebookException( "Unable to fetch the Url for the DialogFeature : '" + featureName + "'"); } // Since we're talking to the server here, let's use the latest version we know about. // We know we are going to be communicating over a bucketed protocol. int protocolVersion = NativeProtocol.getLatestKnownVersion(); Bundle webParams = ServerProtocol.getQueryParamsForPlatformActivityIntentWebFallback( appCall.getCallId().toString(), protocolVersion, parameters); if (webParams == null) { throw new FacebookException("Unable to fetch the app's key-hash"); } // Now form the Uri if (fallbackUrl.isRelative()) { fallbackUrl = Utility.buildUri( ServerProtocol.getDialogAuthority(), fallbackUrl.toString(), webParams); } else { fallbackUrl = Utility.buildUri( fallbackUrl.getAuthority(), fallbackUrl.getPath(), webParams); } Bundle intentParameters = new Bundle(); intentParameters.putString(NativeProtocol.WEB_DIALOG_URL, fallbackUrl.toString()); intentParameters.putBoolean(NativeProtocol.WEB_DIALOG_IS_FALLBACK, true); Intent webDialogIntent = new Intent(); NativeProtocol.setupProtocolRequestIntent( webDialogIntent, appCall.getCallId().toString(), feature.getAction(), NativeProtocol.getLatestKnownVersion(), intentParameters); webDialogIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); webDialogIntent.setAction(FacebookDialogFragment.TAG); appCall.setRequestIntent(webDialogIntent); }
public static void setupAppCallForWebFallbackDialog( AppCall appCall, Bundle parameters, DialogFeature feature) { String featureName = feature.name(); Uri fallbackUrl = getDialogWebFallbackUri(feature); if (fallbackUrl == null) { throw new FacebookException( "Unable to fetch the Url for the DialogFeature : '" + featureName + "'"); } // Since we're talking to the server here, let's use the latest version we know about. // We know we are going to be communicating over a bucketed protocol. int protocolVersion = NativeProtocol.getLatestKnownVersion(); Bundle webParams = ServerProtocol.getQueryParamsForPlatformActivityIntentWebFallback( appCall.getCallId().toString(), protocolVersion, parameters); if (webParams == null) { throw new FacebookException("Unable to fetch the app's key-hash"); } // Now form the Uri if (fallbackUrl.isRelative()) { fallbackUrl = Utility.buildUri( ServerProtocol.getDialogAuthority(), fallbackUrl.toString(), webParams); } else { fallbackUrl = Utility.buildUri( fallbackUrl.getAuthority(), fallbackUrl.getPath(), webParams); } Bundle intentParameters = new Bundle(); intentParameters.putString(NativeProtocol.WEB_DIALOG_URL, fallbackUrl.toString()); intentParameters.putBoolean(NativeProtocol.WEB_DIALOG_IS_FALLBACK, true); Intent webDialogIntent = new Intent(); NativeProtocol.setupProtocolRequestIntent( webDialogIntent, appCall.getCallId().toString(), feature.getAction(), NativeProtocol.getLatestKnownVersion(), intentParameters); webDialogIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); webDialogIntent.setAction(FacebookDialogFragment.TAG); appCall.setRequestIntent(webDialogIntent); }