Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated docs for v1.6.2

  • Loading branch information...
commit 6383fe0a311489d2f78a652841336e6de5e868fc 1 parent 298e5e3
@jasonpolites jasonpolites authored
Showing with 254 additions and 2,578 deletions.
  1. +1 −0  sample/src/socialize_ui_mock_socialize_beans.xml
  2. +0 −199 sdk/deprecated/BaseShareClickListener.java
  3. +0 −62 sdk/deprecated/EmailShareClickListener.java
  4. +0 −120 sdk/deprecated/FacebookShareClickListener.java
  5. +0 −106 sdk/deprecated/InternalShareClickListener.java
  6. +0 −65 sdk/deprecated/OtherShareClickListener.java
  7. +0 −11 sdk/deprecated/ShareClickListener.java
  8. +0 −81 sdk/deprecated/SimpleShareClickListener.java
  9. +0 −60 sdk/deprecated/SmsShareClickListener.java
  10. +0 −130 sdk/deprecated/TwitterShareClickListener.java
  11. +0 −255 sdk/deprecated/fb/AsyncFacebookRunner.java
  12. +0 −51 sdk/deprecated/fb/DialogError.java
  13. +0 −724 sdk/deprecated/fb/Facebook.java
  14. +0 −50 sdk/deprecated/fb/FacebookError.java
  15. +0 −203 sdk/deprecated/fb/FbDialog.java
  16. +0 −75 sdk/deprecated/fb/RequestListener.java
  17. +0 −323 sdk/deprecated/fb/Util.java
  18. +11 −3 sdk/doc/sphinx/source/config.rst
  19. BIN  sdk/doc/sphinx/source/images/direct_alerts.png
  20. +0 −1  sdk/doc/sphinx/source/push_notifications.rst
  21. +22 −0 sdk/doc/sphinx/source/whats_new.rst
  22. +4 −51 sdk/src/com/socialize/auth/AuthProviderInfoBuilder.java
  23. +81 −0 sdk/src/com/socialize/auth/DefaultAuthProviderInfoBuilder.java
  24. +4 −3 sdk/src/com/socialize/config/SocializeConfig.java
  25. +4 −1 sdk/src/com/socialize/ui/actionbar/ActionBarLayoutView.java
  26. +1 −1  sdk/src/socialize_core_beans.xml
  27. +5 −0 test/src/com/socialize/test/ui/integrationtest/actionbar/ActionBarLikeAutoTest.java
  28. +5 −0 test/src/com/socialize/test/ui/integrationtest/actionbar/ActionBarLikeManualTest.java
  29. +1 −1  test/src/com/socialize/test/ui/integrationtest/actionbar/ActionBarLikeStateTest.java
  30. +115 −2 test/src/com/socialize/test/ui/integrationtest/actionbar/ActionBarTestUtils2.java
View
1  sample/src/socialize_ui_mock_socialize_beans.xml
@@ -19,6 +19,7 @@
<proxy ref="alertDialogFactory" />
<proxy ref="actionButtonHandlers" />
+ <proxy ref="authProviderInfoBuilder" />
<proxy ref="authRequestDialogFactory" />
<bean id="initializationAsserter" class="com.socialize.test.mock.MockInitializationAsserter" />
View
199 sdk/deprecated/BaseShareClickListener.java
@@ -1,199 +0,0 @@
-/*
- * Copyright (c) 2011 Socialize Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.socialize.ui.share;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.view.View;
-import android.widget.EditText;
-
-import com.socialize.Socialize;
-import com.socialize.api.ShareMessageBuilder;
-import com.socialize.api.action.ShareType;
-import com.socialize.entity.Entity;
-import com.socialize.entity.Share;
-import com.socialize.error.SocializeErrorHandler;
-import com.socialize.error.SocializeException;
-import com.socialize.listener.share.ShareAddListener;
-import com.socialize.log.SocializeLogger;
-import com.socialize.ui.actionbar.ActionBarView;
-import com.socialize.ui.actionbar.OnActionBarEventListener;
-
-/**
- * @author Jason Polites
- *
- */
-@Deprecated
-public abstract class BaseShareClickListener implements ShareClickListener {
-
- private SocializeLogger logger;
- private ActionBarView actionBarView;
- private EditText commentView;
- private SocializeErrorHandler errorHandler;
-
- protected ShareMessageBuilder shareMessageBuilder;
- protected OnActionBarEventListener onActionBarEventListener;
-
- public BaseShareClickListener(ActionBarView actionBarView) {
- this(actionBarView, null, null);
- }
-
- public BaseShareClickListener(ActionBarView actionBarView, EditText commentView, OnActionBarEventListener onActionBarEventListener) {
- super();
- this.actionBarView = actionBarView;
- this.onActionBarEventListener = onActionBarEventListener;
- this.commentView = commentView;
- }
-
- protected Activity getActivity(View v) {
- Context context = v.getContext();
-
- if(context instanceof Activity) {
- return (Activity) context;
- }
- else {
- String warn = "Context instance in [" + getClass().getName() + "] is not an Activity";
-
- if(logger != null) {
- logger.warn(warn);
- }
- else {
- System.err.println(warn);
- }
- }
-
- return null;
- }
-
- @Override
- public final void onClick(View v) {
-
- try {
-
- Activity activity = getActivity(v);
-
- String comment = null;
-
- if(commentView != null) {
- comment = commentView.getText().toString();
- }
-
- Entity entity = actionBarView.getEntity();
-
- if(entity != null) {
-
- String text = comment;
-
- // Record the share in Socialize
- if(isDoShareInline()) {
- Socialize.getSocialize().addShare(activity, entity, text, getShareType(), getShareAddListener());
- }
-
- doShare(activity, entity, text, getShareAddListener());
- }
- else {
- if(logger != null) {
- logger.error("Unable to complete share. Entity key was not found in actionBarView.");
- }
- }
- }
- catch (Exception e) {
- if(errorHandler != null) {
- errorHandler.handleError(v.getContext(), e);
- }
- }
- }
-
- public void setLogger(SocializeLogger logger) {
- this.logger = logger;
- }
-
- public void setShareMessageBuilder(ShareMessageBuilder shareMessageBuilder) {
- this.shareMessageBuilder = shareMessageBuilder;
- }
-
- protected ShareAddListener getShareAddListener() {
- return new ShareAddListener() {
-
- @Override
- public void onError(SocializeException error) {
- if(logger != null) {
- logger.error("Error creating share", error);
- }
- else {
- error.printStackTrace();
- }
- }
-
- @Override
- public void onCreate(Share share) {
- // TOOD: Update UI?
- if(onActionBarEventListener != null) {
- onActionBarEventListener.onPostShare(actionBarView, share);
- }
- }
- };
- }
-
- protected abstract void doShare(Activity context, Entity entity, String comment, ShareAddListener listener);
-
- protected abstract boolean isHtml();
-
- protected abstract boolean isIncludeSocialize();
-
- /* (non-Javadoc)
- * @see com.socialize.ui.share.ShareClickListener#isAvailableOnDevice(android.app.Activity)
- */
- @Override
- public abstract boolean isAvailableOnDevice(Activity parent);
-
- /**
- * Returns true if this listener should do a share to Socialize.
- * Subclasses override.
- * @return
- */
- protected boolean isDoShareInline() {
- return true;
- }
-
- protected abstract ShareType getShareType();
-
- protected boolean isAvailable(Activity parent, Intent intent) {
- return parent.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null;
- }
-
- protected boolean isGenerateShareMessage() {
- return true;
- }
-
- public void setOnActionBarEventListener(OnActionBarEventListener onActionBarEventListener) {
- this.onActionBarEventListener = onActionBarEventListener;
- }
-
- public void setErrorHandler(SocializeErrorHandler errorHandler) {
- this.errorHandler = errorHandler;
- }
-
-
-}
View
62 sdk/deprecated/EmailShareClickListener.java
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2011 Socialize Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.socialize.ui.share;
-
-import android.widget.EditText;
-
-import com.socialize.api.action.ShareType;
-import com.socialize.ui.actionbar.ActionBarView;
-import com.socialize.ui.actionbar.OnActionBarEventListener;
-
-
-/**
- * @author Jason Polites
- */
-@Deprecated
-public class EmailShareClickListener extends SimpleShareClickListener {
-
-
- public EmailShareClickListener(ActionBarView actionBarView) {
- super(actionBarView);
- }
-
-
- public EmailShareClickListener(ActionBarView actionBarView, EditText commentView, OnActionBarEventListener onActionBarEventListener) {
- super(actionBarView, commentView, onActionBarEventListener);
- }
-
-
- @Override
- protected String getMimeType() {
- return "message/rfc822";
- }
-
- @Override
- protected boolean isHtml() {
- return true;
- }
-
- @Override
- protected ShareType getShareType() {
- return ShareType.EMAIL;
- }
-}
View
120 sdk/deprecated/FacebookShareClickListener.java
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2011 Socialize Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.socialize.ui.share;
-
-import android.app.Activity;
-import android.app.ProgressDialog;
-import android.widget.EditText;
-
-import com.socialize.Socialize;
-import com.socialize.SocializeService;
-import com.socialize.api.action.ShareType;
-import com.socialize.auth.AuthProviderType;
-import com.socialize.entity.Entity;
-import com.socialize.listener.share.ShareAddListener;
-import com.socialize.networks.SocialNetwork;
-import com.socialize.networks.SocialNetworkListener;
-import com.socialize.networks.facebook.FacebookSharer;
-import com.socialize.ui.actionbar.ActionBarView;
-import com.socialize.ui.actionbar.OnActionBarEventListener;
-import com.socialize.ui.dialog.AlertDialogFactory;
-import com.socialize.ui.dialog.ProgressDialogFactory;
-
-/**
- * @author Jason Polites
- *
- */
-@Deprecated
-public class FacebookShareClickListener extends BaseShareClickListener {
-
- private ProgressDialogFactory progressDialogFactory;
- private AlertDialogFactory alertDialogFactory;
- private FacebookSharer facebookSharer;
-
- public FacebookShareClickListener(ActionBarView actionBarView) {
- super(actionBarView);
- }
-
- public FacebookShareClickListener(ActionBarView actionBarView, EditText commentView, OnActionBarEventListener onActionBarEventListener) {
- super(actionBarView, commentView, onActionBarEventListener);
- }
-
- @Override
- public boolean isAvailableOnDevice(Activity parent) {
- return getSocialize().isSupported(AuthProviderType.FACEBOOK);
- }
-
- @Override
- protected void doShare(Activity context, Entity entity, String comment, ShareAddListener listener) {
- facebookSharer.shareEntity(context, entity, comment, true, new SocialNetworkListener() {
- ProgressDialog dialog;
-
- @Override
- public void onBeforePost(Activity parent, SocialNetwork network) {
- dialog = progressDialogFactory.show(parent, "Share", "Sharing to Facebook...");
- }
-
- @Override
- public void onAfterPost(Activity parent, SocialNetwork network) {
- if(dialog != null) dialog.dismiss();
- alertDialogFactory.show(parent, "Success", "Share successful!");
- }
-
- @Override
- public void onError(Activity parent, SocialNetwork network, String message, Throwable error) {
- if(dialog != null) dialog.dismiss();
- alertDialogFactory.show(parent, "Error", "Share failed. Please try again");
- }
- });
- }
-
- @Override
- protected boolean isHtml() {
- return false;
- }
-
- @Override
- protected boolean isIncludeSocialize() {
- return true;
- }
-
- @Override
- protected ShareType getShareType() {
- return ShareType.FACEBOOK;
- }
-
- protected SocializeService getSocialize() {
- return Socialize.getSocialize();
- }
-
- public void setProgressDialogFactory(ProgressDialogFactory progressDialogFactory) {
- this.progressDialogFactory = progressDialogFactory;
- }
-
- public void setAlertDialogFactory(AlertDialogFactory alertDialogFactory) {
- this.alertDialogFactory = alertDialogFactory;
- }
-
- public void setFacebookSharer(FacebookSharer facebookSharer) {
- this.facebookSharer = facebookSharer;
- }
-}
View
106 sdk/deprecated/InternalShareClickListener.java
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2011 Socialize Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.socialize.ui.share;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.widget.EditText;
-import com.socialize.Socialize;
-import com.socialize.config.SocializeConfig;
-import com.socialize.entity.Entity;
-import com.socialize.launcher.LaunchAction;
-import com.socialize.listener.ListenerHolder;
-import com.socialize.listener.share.ShareAddListener;
-import com.socialize.ui.SocializeLaunchActivity;
-import com.socialize.ui.actionbar.ActionBarView;
-import com.socialize.ui.actionbar.OnActionBarEventListener;
-
-/**
- * @author Jason Polites
- *
- */
-@Deprecated
-public abstract class InternalShareClickListener extends BaseShareClickListener {
-
- private ListenerHolder listenerHolder;
-
- public InternalShareClickListener(ActionBarView actionBarView, EditText commentView, OnActionBarEventListener onActionBarEventListener) {
- super(actionBarView, commentView, onActionBarEventListener);
- }
-
- public InternalShareClickListener(ActionBarView actionBarView) {
- super(actionBarView);
- }
-
- /* (non-Javadoc)
- * @see com.socialize.ui.share.BaseShareClickListener#doShare(android.app.Activity, com.socialize.entity.Entity, java.lang.String)
- */
- @Override
- protected void doShare(Activity context, Entity entity, String comment, ShareAddListener listener) {
-
- if(isDoShareInline()) {
- String title = "Share";
- String subject = null;
- String body = null;
- if(isGenerateShareMessage()) {
- subject = shareMessageBuilder.buildShareSubject(entity);
- body = shareMessageBuilder.buildShareMessage(entity, comment, isHtml(), isIncludeSocialize());
- }
- doShare(context, title, subject, body, comment);
- }
- else {
- Intent intent = new Intent(context, SocializeLaunchActivity.class);
-
- intent.putExtra(SocializeLaunchActivity.LAUNCH_ACTION, LaunchAction.LOCAL_SHARE.name());
-
- intent.putExtra(Socialize.ENTITY_OBJECT, entity);
-
- intent.putExtra(SocializeConfig.SOCIALIZE_SHARE_IS_HTML, isHtml());
- intent.putExtra(SocializeConfig.SOCIALIZE_SHARE_COMMENT, comment);
- intent.putExtra(SocializeConfig.SOCIALIZE_SHARE_MIME_TYPE, getMimeType());
- intent.putExtra(SocializeConfig.SOCIALIZE_SHARE_LISTENER_KEY, entity.getKey());
-
- if(listenerHolder != null) {
- listenerHolder.put(entity.getKey(), listener);
- }
-
- startActivity(context, intent);
- }
- }
-
- // So we can mock
- protected void startActivity(Context context, Intent intent) {
- context.startActivity(intent);
- }
-
- public void setListenerHolder(ListenerHolder listenerHolder) {
- this.listenerHolder = listenerHolder;
- }
-
- protected String getMimeType() {
- return "text/plain";
- }
-
- protected abstract void doShare(Activity parent, String title, String subject, String body, String comment);
-
-}
View
65 sdk/deprecated/OtherShareClickListener.java
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2011 Socialize Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.socialize.ui.share;
-
-import android.widget.EditText;
-
-import com.socialize.api.action.ShareType;
-import com.socialize.ui.actionbar.ActionBarView;
-import com.socialize.ui.actionbar.OnActionBarEventListener;
-
-
-/**
- * @author Jason Polites
- *
- */
-@Deprecated
-public class OtherShareClickListener extends SimpleShareClickListener {
-
- public OtherShareClickListener(ActionBarView actionBarView) {
- super(actionBarView);
- }
-
- public OtherShareClickListener(ActionBarView actionBarView, EditText commentView, OnActionBarEventListener onActionBarEventListener) {
- super(actionBarView, commentView, onActionBarEventListener);
- }
-
- @Override
- protected boolean isDoShareInline() {
- return false;
- }
-
- @Override
- protected String getMimeType() {
- return "text/plain";
- }
-
- @Override
- protected boolean isHtml() {
- return false;
- }
-
- @Override
- protected ShareType getShareType() {
- return ShareType.OTHER;
- }
-}
View
11 sdk/deprecated/ShareClickListener.java
@@ -1,11 +0,0 @@
-package com.socialize.ui.share;
-
-import android.app.Activity;
-import android.view.View.OnClickListener;
-
-@Deprecated
-public interface ShareClickListener extends OnClickListener {
-
- public boolean isAvailableOnDevice(Activity parent);
-
-}
View
81 sdk/deprecated/SimpleShareClickListener.java
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2011 Socialize Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.socialize.ui.share;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.text.Html;
-import android.widget.EditText;
-
-import com.socialize.ui.actionbar.ActionBarView;
-import com.socialize.ui.actionbar.OnActionBarEventListener;
-
-/**
- * @author Jason Polites
- */
-@Deprecated
-public abstract class SimpleShareClickListener extends InternalShareClickListener {
-
- private Intent sendIntent = null;
-
- public SimpleShareClickListener(ActionBarView actionBarView) {
- super(actionBarView);
- }
-
- public SimpleShareClickListener(ActionBarView actionBarView, EditText commentView, OnActionBarEventListener onActionBarEventListener) {
- super(actionBarView, commentView, onActionBarEventListener);
- }
-
- @Override
- protected void doShare(Activity parent, String title, String subject, String body, String comment) {
- Intent msg = getIntent();
- msg.putExtra(Intent.EXTRA_TITLE, title);
-
- if(isHtml()) {
- msg.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
- }
- else {
- msg.putExtra(Intent.EXTRA_TEXT, body);
- }
-
- msg.putExtra(Intent.EXTRA_SUBJECT, subject);
- parent.startActivity(Intent.createChooser(msg, title));
- }
-
- protected Intent getIntent() {
- if(sendIntent == null) {
- sendIntent = new Intent(android.content.Intent.ACTION_SEND);
- sendIntent.setType(getMimeType());
- }
- return sendIntent;
- }
-
- @Override
- public boolean isAvailableOnDevice(Activity parent) {
- return isAvailable(parent, getIntent());
- }
-
- @Override
- protected boolean isIncludeSocialize() {
- return true;
- }
-}
View
60 sdk/deprecated/SmsShareClickListener.java
@@ -1,60 +0,0 @@
-package com.socialize.ui.share;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.widget.EditText;
-
-import com.socialize.api.action.ShareType;
-import com.socialize.ui.actionbar.ActionBarView;
-import com.socialize.ui.actionbar.OnActionBarEventListener;
-
-@Deprecated
-public class SmsShareClickListener extends InternalShareClickListener {
-
- public SmsShareClickListener(ActionBarView actionBarView) {
- super(actionBarView);
- }
-
-
- public SmsShareClickListener(ActionBarView actionBarView, EditText commentView, OnActionBarEventListener onActionBarEventListener) {
- super(actionBarView, commentView, onActionBarEventListener);
- }
-
- @Override
- protected void doShare(Activity parent, String title, String subject, String body, String comment) {
- Intent sendIntent = getIntent();
- sendIntent.putExtra("sms_body", body);
- parent.startActivity(sendIntent);
- }
-
- protected Intent getIntent() {
- Intent sendIntent = new Intent(Intent.ACTION_VIEW);
- sendIntent.setType(getMimeType());
- return sendIntent;
- }
-
-
- protected String getMimeType() {
- return "vnd.android-dir/mms-sms";
- }
-
- @Override
- public boolean isAvailableOnDevice(Activity parent) {
- return isAvailable(parent, getIntent());
- }
-
- @Override
- protected boolean isHtml() {
- return false;
- }
-
- @Override
- protected boolean isIncludeSocialize() {
- return true;
- }
-
- @Override
- protected ShareType getShareType() {
- return ShareType.SMS;
- }
-}
View
130 sdk/deprecated/TwitterShareClickListener.java
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2011 Socialize Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.socialize.ui.share;
-
-import android.app.Activity;
-import android.app.ProgressDialog;
-import android.widget.EditText;
-
-import com.socialize.Socialize;
-import com.socialize.SocializeService;
-import com.socialize.api.action.ShareType;
-import com.socialize.auth.AuthProviderType;
-import com.socialize.entity.Entity;
-import com.socialize.entity.Share;
-import com.socialize.error.SocializeException;
-import com.socialize.listener.share.ShareAddListener;
-import com.socialize.networks.ShareOptions;
-import com.socialize.networks.SocialNetwork;
-import com.socialize.ui.actionbar.ActionBarView;
-import com.socialize.ui.actionbar.OnActionBarEventListener;
-import com.socialize.ui.dialog.AlertDialogFactory;
-import com.socialize.ui.dialog.ProgressDialogFactory;
-
-/**
- * @author Jason Polites
- *
- */
-@Deprecated
-public class TwitterShareClickListener extends BaseShareClickListener {
-
- private ProgressDialogFactory progressDialogFactory;
- private AlertDialogFactory alertDialogFactory;
-
- public TwitterShareClickListener(ActionBarView actionBarView) {
- super(actionBarView);
- }
-
- public TwitterShareClickListener(ActionBarView actionBarView, EditText commentView, OnActionBarEventListener onActionBarEventListener) {
- super(actionBarView, commentView, onActionBarEventListener);
- }
-
- @Override
- public boolean isAvailableOnDevice(Activity parent) {
- return getSocialize().isSupported(AuthProviderType.TWITTER);
- }
-
- @Override
- protected boolean isDoShareInline() {
- return false;
- }
-
- @Override
- protected void doShare(final Activity context, Entity entity, String comment, final ShareAddListener listener) {
- final ProgressDialog dialog = progressDialogFactory.show(context, "Share", "Sharing to Twitter...");
- ShareOptions options = new ShareOptions();
- options.setShareTo(SocialNetwork.TWITTER);
- options.setShareLocation(true);
- Socialize.getSocialize().share(context, entity, comment, options, new ShareAddListener() {
-
- @Override
- public void onError(SocializeException error) {
- error.printStackTrace();
- if(dialog != null) dialog.dismiss();
-
- if(listener != null) {
- listener.onError(error);
- }
-
- alertDialogFactory.show(context, "Error", "Share failed. Please try again");
- }
-
- @Override
- public void onCreate(Share entity) {
- if(dialog != null) dialog.dismiss();
-
- if(listener != null) {
- listener.onCreate(entity);
- }
-
- alertDialogFactory.show(context, "Success", "Share successful!");
- }
- });
- }
-
- @Override
- protected boolean isHtml() {
- return false;
- }
-
- @Override
- protected boolean isIncludeSocialize() {
- return true;
- }
-
- @Override
- protected ShareType getShareType() {
- return ShareType.TWITTER;
- }
-
- protected SocializeService getSocialize() {
- return Socialize.getSocialize();
- }
-
- public void setProgressDialogFactory(ProgressDialogFactory progressDialogFactory) {
- this.progressDialogFactory = progressDialogFactory;
- }
-
- public void setAlertDialogFactory(AlertDialogFactory alertDialogFactory) {
- this.alertDialogFactory = alertDialogFactory;
- }
-}
View
255 sdk/deprecated/fb/AsyncFacebookRunner.java
@@ -1,255 +0,0 @@
-/*
- * Copyright 2010 Facebook, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.socialize.facebook;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-
-import android.content.Context;
-import android.os.Bundle;
-
-/**
- * A sample implementation of asynchronous API requests. This class provides the
- * ability to execute API methods and have the call return immediately, without
- * blocking the calling thread. This is necessary when accessing the API in the
- * UI thread, for instance. The request response is returned to the caller via a
- * callback interface, which the developer must implement.
- *
- * This sample implementation simply spawns a new thread for each request, and
- * makes the API call immediately. This may work in many applications, but more
- * sophisticated users may re-implement this behavior using a thread pool, a
- * network thread, a request queue, or other mechanism. Advanced functionality
- * could be built, such as rate-limiting of requests, as per a specific
- * application's needs.
- *
- * @see RequestListener The callback interface.
- *
- * @author Jim Brusstar (jimbru@fb.com), Yariv Sadan (yariv@fb.com), Luke
- * Shepard (lshepard@fb.com)
- */
-public class AsyncFacebookRunner {
-
- Facebook fb;
-
- public AsyncFacebookRunner(Facebook fb) {
- this.fb = fb;
- }
-
- /**
- * Invalidate the current user session by removing the access token in
- * memory, clearing the browser cookies, and calling auth.expireSession
- * through the API. The application will be notified when logout is complete
- * via the callback interface.
- *
- * Note that this method is asynchronous and the callback will be invoked in
- * a background thread; operations that affect the UI will need to be posted
- * to the UI thread or an appropriate handler.
- *
- * @param context
- * The Android context in which the logout should be called: it
- * should be the same context in which the login occurred in
- * order to clear any stored cookies
- * @param listener
- * Callback interface to notify the application when the request
- * has completed.
- * @param state
- * An arbitrary object used to identify the request when it
- * returns to the callback. This has no effect on the request
- * itself.
- */
- public void logout(final Context context, final RequestListener listener, final Object state) {
- new Thread() {
- @Override
- public void run() {
- try {
- String response = fb.logout(context);
- if (response.length() == 0 || response.equals("false")) {
- listener.onFacebookError(new FacebookError("auth.expireSession failed"), state);
- return;
- }
- listener.onComplete(response, state);
- }
- catch (FileNotFoundException e) {
- listener.onFileNotFoundException(e, state);
- }
- catch (MalformedURLException e) {
- listener.onMalformedURLException(e, state);
- }
- catch (IOException e) {
- listener.onIOException(e, state);
- }
- }
- }.start();
- }
-
- public void logout(final Context context, final RequestListener listener) {
- logout(context, listener, /* state */null);
- }
-
- /**
- * Make a request to Facebook's old (pre-graph) API with the given
- * parameters. One of the parameter keys must be "method" and its value
- * should be a valid REST server API method.
- *
- * See http://developers.facebook.com/docs/reference/rest/
- *
- * Note that this method is asynchronous and the callback will be invoked in
- * a background thread; operations that affect the UI will need to be posted
- * to the UI thread or an appropriate handler.
- *
- * Example: <code>
- * Bundle parameters = new Bundle();
- * parameters.putString("method", "auth.expireSession", new Listener());
- * String response = request(parameters);
- * </code>
- *
- * @param parameters
- * Key-value pairs of parameters to the request. Refer to the
- * documentation: one of the parameters must be "method".
- * @param listener
- * Callback interface to notify the application when the request
- * has completed.
- * @param state
- * An arbitrary object used to identify the request when it
- * returns to the callback. This has no effect on the request
- * itself.
- */
- public void request(Bundle parameters, RequestListener listener, final Object state) {
- request(null, parameters, "GET", listener, state);
- }
-
- public void request(Bundle parameters, RequestListener listener) {
- request(null, parameters, "GET", listener, /* state */null);
- }
-
- /**
- * Make a request to the Facebook Graph API without any parameters.
- *
- * See http://developers.facebook.com/docs/api
- *
- * Note that this method is asynchronous and the callback will be invoked in
- * a background thread; operations that affect the UI will need to be posted
- * to the UI thread or an appropriate handler.
- *
- * @param graphPath
- * Path to resource in the Facebook graph, e.g., to fetch data
- * about the currently logged authenticated user, provide "me",
- * which will fetch http://graph.facebook.com/me
- * @param listener
- * Callback interface to notify the application when the request
- * has completed.
- * @param state
- * An arbitrary object used to identify the request when it
- * returns to the callback. This has no effect on the request
- * itself.
- */
- public void request(String graphPath, RequestListener listener, final Object state) {
- request(graphPath, new Bundle(), "GET", listener, state);
- }
-
- public void request(String graphPath, RequestListener listener) {
- request(graphPath, new Bundle(), "GET", listener, /* state */null);
- }
-
- /**
- * Make a request to the Facebook Graph API with the given string parameters
- * using an HTTP GET (default method).
- *
- * See http://developers.facebook.com/docs/api
- *
- * Note that this method is asynchronous and the callback will be invoked in
- * a background thread; operations that affect the UI will need to be posted
- * to the UI thread or an appropriate handler.
- *
- * @param graphPath
- * Path to resource in the Facebook graph, e.g., to fetch data
- * about the currently logged authenticated user, provide "me",
- * which will fetch http://graph.facebook.com/me
- * @param parameters
- * key-value string parameters, e.g. the path "search" with
- * parameters "q" : "facebook" would produce a query for the
- * following graph resource:
- * https://graph.facebook.com/search?q=facebook
- * @param listener
- * Callback interface to notify the application when the request
- * has completed.
- * @param state
- * An arbitrary object used to identify the request when it
- * returns to the callback. This has no effect on the request
- * itself.
- */
- public void request(String graphPath, Bundle parameters, RequestListener listener, final Object state) {
- request(graphPath, parameters, "GET", listener, state);
- }
-
- public void request(String graphPath, Bundle parameters, RequestListener listener) {
- request(graphPath, parameters, "GET", listener, /* state */null);
- }
-
- /**
- * Make a request to the Facebook Graph API with the given HTTP method and
- * string parameters. Note that binary data parameters (e.g. pictures) are
- * not yet supported by this helper function.
- *
- * See http://developers.facebook.com/docs/api
- *
- * Note that this method is asynchronous and the callback will be invoked in
- * a background thread; operations that affect the UI will need to be posted
- * to the UI thread or an appropriate handler.
- *
- * @param graphPath
- * Path to resource in the Facebook graph, e.g., to fetch data
- * about the currently logged authenticated user, provide "me",
- * which will fetch http://graph.facebook.com/me
- * @param parameters
- * key-value string parameters, e.g. the path "search" with
- * parameters {"q" : "facebook"} would produce a query for the
- * following graph resource:
- * https://graph.facebook.com/search?q=facebook
- * @param httpMethod
- * http verb, e.g. "POST", "DELETE"
- * @param listener
- * Callback interface to notify the application when the request
- * has completed.
- * @param state
- * An arbitrary object used to identify the request when it
- * returns to the callback. This has no effect on the request
- * itself.
- */
- public void request(final String graphPath, final Bundle parameters, final String httpMethod, final RequestListener listener, final Object state) {
- new Thread() {
- @Override
- public void run() {
- try {
- String resp = fb.request(graphPath, parameters, httpMethod);
- listener.onComplete(resp, state);
- }
- catch (FileNotFoundException e) {
- listener.onFileNotFoundException(e, state);
- }
- catch (MalformedURLException e) {
- listener.onMalformedURLException(e, state);
- }
- catch (IOException e) {
- listener.onIOException(e, state);
- }
- }
- }.start();
- }
-}
View
51 sdk/deprecated/fb/DialogError.java
@@ -1,51 +0,0 @@
-/*
- * Copyright 2010 Facebook, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.socialize.facebook;
-
-/**
- * Encapsulation of Dialog Error.
- *
- * @author ssoneff@facebook.com
- */
-public class DialogError extends Throwable {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * The ErrorCode received by the WebView: see
- * http://developer.android.com/reference/android/webkit/WebViewClient.html
- */
- private int mErrorCode;
-
- /** The URL that the dialog was trying to load */
- private String mFailingUrl;
-
- public DialogError(String message, int errorCode, String failingUrl) {
- super(message);
- mErrorCode = errorCode;
- mFailingUrl = failingUrl;
- }
-
- int getErrorCode() {
- return mErrorCode;
- }
-
- String getFailingUrl() {
- return mFailingUrl;
- }
-
-}
View
724 sdk/deprecated/fb/Facebook.java
@@ -1,724 +0,0 @@
-/*
- * Copyright 2010 Facebook, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.socialize.facebook;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-import android.Manifest;
-import android.app.Activity;
-import android.content.ActivityNotFoundException;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.ResolveInfo;
-import android.content.pm.Signature;
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.util.Log;
-import android.webkit.CookieSyncManager;
-
-import com.socialize.ui.dialog.DialogRegistration;
-
-/**
- * Main Facebook object for interacting with the Facebook developer API.
- * Provides methods to log in and log out a user, make requests using the REST
- * and Graph APIs, and start user interface interactions with the API (such as
- * pop-ups promoting for credentials, permissions, stream posts, etc.)
- *
- * @author Jim Brusstar (jimbru@facebook.com), Yariv Sadan (yariv@facebook.com),
- * Luke Shepard (lshepard@facebook.com)
- */
-public class Facebook {
-
- // Strings used in the authorization flow
- public static final String REDIRECT_URI = "fbconnect://success";
- public static final String CANCEL_URI = "fbconnect://cancel";
- public static final String TOKEN = "access_token";
- public static final String EXPIRES = "expires_in";
- public static final String SINGLE_SIGN_ON_DISABLED = "service_disabled";
-
- public static final int FORCE_DIALOG_AUTH = -1;
-
- private static final String LOGIN = "oauth";
-
- // Used as default activityCode by authorize(). See authorize() below.
- private static final int DEFAULT_AUTH_ACTIVITY_CODE = 32665;
-
- // Facebook server endpoints: may be modified in a subclass for testing
- protected static String DIALOG_BASE_URL = "https://m.facebook.com/dialog/";
- protected static String GRAPH_BASE_URL = "https://graph.facebook.com/";
- protected static String RESTSERVER_URL = "https://api.facebook.com/restserver.php";
-
- private String mAccessToken = null;
- private long mAccessExpires = 0;
- private String mAppId;
-
- private Activity mAuthActivity;
- private String[] mAuthPermissions;
- private int mAuthActivityCode;
- private DialogListener mAuthDialogListener;
-
- public Facebook() {
- super();
- }
-
- /**
- * Constructor for Facebook object.
- *
- * @param appId
- * Your Facebook application ID. Found at
- * www.facebook.com/developers/apps.php.
- */
- public Facebook(String appId) {
- if (appId == null) {
- throw new IllegalArgumentException("You must specify your application ID when instantiating " + "a Facebook object. See README for details.");
- }
- mAppId = appId;
- }
-
- /**
- * Default authorize method. Grants only basic permissions.
- *
- * See authorize() below for @params.
- */
- public void authorize(Activity activity, final DialogListener listener) {
- authorize(activity, new String[] {}, DEFAULT_AUTH_ACTIVITY_CODE, listener);
- }
-
- /**
- * Authorize method that grants custom permissions.
- *
- * See authorize() below for @params.
- */
- public void authorize(Activity activity, String[] permissions, final DialogListener listener) {
- authorize(activity, permissions, DEFAULT_AUTH_ACTIVITY_CODE, listener);
- }
-
- /**
- * Full authorize method.
- *
- * Starts either an Activity or a dialog which prompts the user to log in to
- * Facebook and grant the requested permissions to the given application.
- *
- * This method will, when possible, use Facebook's single sign-on for
- * Android to obtain an access token. This involves proxying a call through
- * the Facebook for Android stand-alone application, which will handle the
- * authentication flow, and return an OAuth access token for making API
- * calls.
- *
- * Because this process will not be available for all users, if single
- * sign-on is not possible, this method will automatically fall back to the
- * OAuth 2.0 User-Agent flow. In this flow, the user credentials are handled
- * by Facebook in an embedded WebView, not by the client application. As
- * such, the dialog makes a network request and renders HTML content rather
- * than a native UI. The access token is retrieved from a redirect to a
- * special URL that the WebView handles.
- *
- * Note that User credentials could be handled natively using the OAuth 2.0
- * Username and Password Flow, but this is not supported by this SDK.
- *
- * See http://developers.facebook.com/docs/authentication/ and
- * http://wiki.oauth.net/OAuth-2 for more details.
- *
- * Note that this method is asynchronous and the callback will be invoked in
- * the original calling thread (not in a background thread).
- *
- * Also note that requests may be made to the API without calling authorize
- * first, in which case only public information is returned.
- *
- * IMPORTANT: Note that single sign-on authentication will not function
- * correctly if you do not include a call to the authorizeCallback() method
- * in your onActivityResult() function! Please see below for more
- * information. single sign-on may be disabled by passing FORCE_DIALOG_AUTH
- * as the activityCode parameter in your call to authorize().
- *
- * @param activity
- * The Android activity in which we want to display the
- * authorization dialog.
- * @param permissions
- * A list of permissions required for this application: e.g.
- * "read_stream", "publish_stream", "offline_access", etc. see
- * http://developers.facebook.com/docs/authentication/permissions
- * This parameter should not be null -- if you do not require any
- * permissions, then pass in an empty String array.
- * @param activityCode
- * Single sign-on requires an activity result to be called back
- * to the client application -- if you are waiting on other
- * activities to return data, pass a custom activity code here to
- * avoid collisions. If you would like to force the use of legacy
- * dialog-based authorization, pass FORCE_DIALOG_AUTH for this
- * parameter. Otherwise just omit this parameter and Facebook
- * will use a suitable default. See
- * http://developer.android.com/reference/android/
- * app/Activity.html for more information.
- * @param listener
- * Callback interface for notifying the calling application when
- * the authentication dialog has completed, failed, or been
- * canceled.
- */
- public void authorize(Activity activity, String[] permissions, int activityCode, final DialogListener listener) {
-
- boolean singleSignOnStarted = false;
-
- mAuthDialogListener = listener;
-
- // Prefer single sign-on, where available.
- if (activityCode >= 0) {
- singleSignOnStarted = startSingleSignOn(activity, mAppId, permissions, activityCode);
- }
- // Otherwise fall back to traditional dialog.
- if (!singleSignOnStarted) {
- startDialogAuth(activity, permissions);
- }
- }
-
- /**
- * Internal method to handle single sign-on backend for authorize().
- *
- * @param activity
- * The Android Activity that will parent the ProxyAuth Activity.
- * @param applicationId
- * The Facebook application identifier.
- * @param permissions
- * A list of permissions required for this application. If you do
- * not require any permissions, pass an empty String array.
- * @param activityCode
- * Activity code to uniquely identify the result Intent in the
- * callback.
- */
- private boolean startSingleSignOn(Activity activity, String applicationId, String[] permissions, int activityCode) {
- boolean didSucceed = true;
- Intent intent = new Intent();
-
- intent.setClassName("com.facebook.katana", "com.facebook.katana.ProxyAuth");
- intent.putExtra("client_id", applicationId);
- if (permissions.length > 0) {
- intent.putExtra("scope", TextUtils.join(",", permissions));
- }
-
- // Verify that the application whose package name is
- // com.facebook.katana.ProxyAuth
- // has the expected FB app signature.
- if (!validateAppSignatureForIntent(activity, intent)) {
- return false;
- }
-
- mAuthActivity = activity;
- mAuthPermissions = permissions;
- mAuthActivityCode = activityCode;
- try {
- activity.startActivityForResult(intent, activityCode);
- }
- catch (ActivityNotFoundException e) {
- didSucceed = false;
- }
-
- return didSucceed;
- }
-
- /**
- * Query the signature for the application that would be invoked by the
- * given intent and verify that it matches the FB application's signature.
- *
- * @param activity
- * @param intent
- * @param validSignature
- * @return true if the app's signature matches the expected signature.
- */
- private boolean validateAppSignatureForIntent(Activity activity, Intent intent) {
-
- ResolveInfo resolveInfo = activity.getPackageManager().resolveActivity(intent, 0);
- if (resolveInfo == null) {
- return false;
- }
-
- String packageName = resolveInfo.activityInfo.packageName;
- PackageInfo packageInfo;
- try {
- packageInfo = activity.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
- }
- catch (NameNotFoundException e) {
- return false;
- }
-
- for (Signature signature : packageInfo.signatures) {
- if (signature.toCharsString().equals(FB_APP_SIGNATURE)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Internal method to handle dialog-based authentication backend for
- * authorize().
- *
- * @param activity
- * The Android Activity that will parent the auth dialog.
- * @param applicationId
- * The Facebook application identifier.
- * @param permissions
- * A list of permissions required for this application. If you do
- * not require any permissions, pass an empty String array.
- */
- private void startDialogAuth(Activity activity, String[] permissions) {
- Bundle params = new Bundle();
- if (permissions.length > 0) {
- params.putString("scope", TextUtils.join(",", permissions));
- }
- CookieSyncManager.createInstance(activity);
- dialog(activity, LOGIN, params, new DialogListener() {
-
- public void onComplete(Bundle values) {
- // ensure any cookies set by the dialog are saved
- CookieSyncManager.getInstance().sync();
- setAccessToken(values.getString(TOKEN));
- setAccessExpiresIn(values.getString(EXPIRES));
- if (isSessionValid()) {
- Log.d("Facebook-authorize", "Login Success! access_token=" + getAccessToken() + " expires=" + getAccessExpires());
- mAuthDialogListener.onComplete(values);
- }
- else {
- mAuthDialogListener.onFacebookError(new FacebookError("Failed to receive access token."));
- }
- }
-
- public void onError(DialogError error) {
- Log.d("Facebook-authorize", "Login failed: " + error);
- mAuthDialogListener.onError(error);
- }
-
- public void onFacebookError(FacebookError error) {
- Log.d("Facebook-authorize", "Login failed: " + error);
- mAuthDialogListener.onFacebookError(error);
- }
-
- public void onCancel() {
- Log.d("Facebook-authorize", "Login canceled");
- mAuthDialogListener.onCancel();
- }
- });
- }
-
- /**
- * IMPORTANT: This method must be invoked at the top of the calling
- * activity's onActivityResult() function or Facebook authentication will
- * not function properly!
- *
- * If your calling activity does not currently implement onActivityResult(),
- * you must implement it and include a call to this method if you intend to
- * use the authorize() method in this SDK.
- *
- * For more information, see
- * http://developer.android.com/reference/android/app/
- * Activity.html#onActivityResult(int, int, android.content.Intent)
- */
- public void authorizeCallback(int requestCode, int resultCode, Intent data) {
- if (requestCode == mAuthActivityCode) {
-
- // Successfully redirected.
- if (resultCode == Activity.RESULT_OK) {
-
- // Check OAuth 2.0/2.10 error code.
- String error = data.getStringExtra("error");
- if (error == null) {
- error = data.getStringExtra("error_type");
- }
-
- // A Facebook error occurred.
- if (error != null) {
- if (error.equals(SINGLE_SIGN_ON_DISABLED) || error.equals("AndroidAuthKillSwitchException")) {
- Log.d("Facebook-authorize", "Hosted auth currently " + "disabled. Retrying dialog auth...");
- startDialogAuth(mAuthActivity, mAuthPermissions);
- }
- else if (error.equals("access_denied") || error.equals("OAuthAccessDeniedException")) {
- Log.d("Facebook-authorize", "Login canceled by user.");
- mAuthDialogListener.onCancel();
- }
- else {
- String description = data.getStringExtra("error_description");
- if (description != null) {
- error = error + ":" + description;
- }
- Log.d("Facebook-authorize", "Login failed: " + error);
- mAuthDialogListener.onFacebookError(new FacebookError(error));
- }
-
- // No errors.
- }
- else {
- setAccessToken(data.getStringExtra(TOKEN));
- setAccessExpiresIn(data.getStringExtra(EXPIRES));
- if (isSessionValid()) {
- Log.d("Facebook-authorize", "Login Success! access_token=" + getAccessToken() + " expires=" + getAccessExpires());
- mAuthDialogListener.onComplete(data.getExtras());
- }
- else {
- mAuthDialogListener.onFacebookError(new FacebookError("Failed to receive access token."));
- }
- }
-
- // An error occurred before we could be redirected.
- }
- else if (resultCode == Activity.RESULT_CANCELED) {
-
- // An Android error occured.
- if (data != null) {
- Log.d("Facebook-authorize", "Login failed: " + data.getStringExtra("error"));
- mAuthDialogListener.onError(new DialogError(data.getStringExtra("error"), data.getIntExtra("error_code", -1), data.getStringExtra("failing_url")));
-
- // User pressed the 'back' button.
- }
- else {
- Log.d("Facebook-authorize", "Login canceled by user.");
- mAuthDialogListener.onCancel();
- }
- }
- }
- }
-
- /**
- * Invalidate the current user session by removing the access token in
- * memory, clearing the browser cookie, and calling auth.expireSession
- * through the API.
- *
- * Note that this method blocks waiting for a network response, so do not
- * call it in a UI thread.
- *
- * @param context
- * The Android context in which the logout should be called: it
- * should be the same context in which the login occurred in
- * order to clear any stored cookies
- * @throws IOException
- * @throws MalformedURLException
- * @return JSON string representation of the auth.expireSession response
- * ("true" if successful)
- */
- public String logout(Context context) throws MalformedURLException, IOException {
- Util.clearCookies(context);
- Bundle b = new Bundle();
- b.putString("method", "auth.expireSession");
- String response = request(b);
- setAccessToken(null);
- setAccessExpires(0);
- return response;
- }
-
- /**
- * Make a request to Facebook's old (pre-graph) API with the given
- * parameters. One of the parameter keys must be "method" and its value
- * should be a valid REST server API method.
- *
- * See http://developers.facebook.com/docs/reference/rest/
- *
- * Note that this method blocks waiting for a network response, so do not
- * call it in a UI thread.
- *
- * Example: <code>
- * Bundle parameters = new Bundle();
- * parameters.putString("method", "auth.expireSession");
- * String response = request(parameters);
- * </code>
- *
- * @param parameters
- * Key-value pairs of parameters to the request. Refer to the
- * documentation: one of the parameters must be "method".
- * @throws IOException
- * if a network error occurs
- * @throws MalformedURLException
- * if accessing an invalid endpoint
- * @throws IllegalArgumentException
- * if one of the parameters is not "method"
- * @return JSON string representation of the response
- */
- public String request(Bundle parameters) throws MalformedURLException, IOException {
- if (!parameters.containsKey("method")) {
- throw new IllegalArgumentException("API method must be specified. " + "(parameters must contain key \"method\" and value). See" + " http://developers.facebook.com/docs/reference/rest/");
- }
- return request(null, parameters, "GET");
- }
-
- /**
- * Make a request to the Facebook Graph API without any parameters.
- *
- * See http://developers.facebook.com/docs/api
- *
- * Note that this method blocks waiting for a network response, so do not
- * call it in a UI thread.
- *
- * @param graphPath
- * Path to resource in the Facebook graph, e.g., to fetch data
- * about the currently logged authenticated user, provide "me",
- * which will fetch http://graph.facebook.com/me
- * @throws IOException
- * @throws MalformedURLException
- * @return JSON string representation of the response
- */
- public String request(String graphPath) throws MalformedURLException, IOException {
- return request(graphPath, new Bundle(), "GET");
- }
-
- /**
- * Make a request to the Facebook Graph API with the given string parameters
- * using an HTTP GET (default method).
- *
- * See http://developers.facebook.com/docs/api
- *
- * Note that this method blocks waiting for a network response, so do not
- * call it in a UI thread.
- *
- * @param graphPath
- * Path to resource in the Facebook graph, e.g., to fetch data
- * about the currently logged authenticated user, provide "me",
- * which will fetch http://graph.facebook.com/me
- * @param parameters
- * key-value string parameters, e.g. the path "search" with
- * parameters "q" : "facebook" would produce a query for the
- * following graph resource:
- * https://graph.facebook.com/search?q=facebook
- * @throws IOException
- * @throws MalformedURLException
- * @return JSON string representation of the response
- */
- public String request(String graphPath, Bundle parameters) throws MalformedURLException, IOException {
- return request(graphPath, parameters, "GET");
- }
-
- /**
- * Synchronously make a request to the Facebook Graph API with the given
- * HTTP method and string parameters. Note that binary data parameters (e.g.
- * pictures) are not yet supported by this helper function.
- *
- * See http://developers.facebook.com/docs/api
- *
- * Note that this method blocks waiting for a network response, so do not
- * call it in a UI thread.
- *
- * @param graphPath
- * Path to resource in the Facebook graph, e.g., to fetch data
- * about the currently logged authenticated user, provide "me",
- * which will fetch http://graph.facebook.com/me
- * @param params
- * Key-value string parameters, e.g. the path "search" with
- * parameters {"q" : "facebook"} would produce a query for the
- * following graph resource:
- * https://graph.facebook.com/search?q=facebook
- * @param httpMethod
- * http verb, e.g. "GET", "POST", "DELETE"
- * @throws IOException
- * @throws MalformedURLException
- * @return JSON string representation of the response
- */
- public String request(String graphPath, Bundle params, String httpMethod) throws FileNotFoundException, MalformedURLException, IOException {
- params.putString("format", "json");
- if (isSessionValid()) {
- params.putString(TOKEN, getAccessToken());
- }
- String url = (graphPath != null) ? GRAPH_BASE_URL + graphPath : RESTSERVER_URL;
- return Util.openUrl(url, httpMethod, params);
- }
-
- /**
- * Generate a UI dialog for the request action in the given Android context.
- *
- * Note that this method is asynchronous and the callback will be invoked in
- * the original calling thread (not in a background thread).
- *
- * @param context
- * The Android context in which we will generate this dialog.
- * @param action
- * String representation of the desired method: e.g. "login",
- * "stream.publish", ...
- * @param listener
- * Callback interface to notify the application when the dialog
- * has completed.
- */
- public void dialog(Context context, String action, DialogListener listener) {
- dialog(context, action, new Bundle(), listener);
- }
-
- /**
- * Generate a UI dialog for the request action in the given Android context
- * with the provided parameters.
- *
- * Note that this method is asynchronous and the callback will be invoked in
- * the original calling thread (not in a background thread).
- *
- * @param context
- * The Android context in which we will generate this dialog.
- * @param action
- * String representation of the desired method: e.g. "feed" ...
- * @param parameters
- * String key-value pairs to be passed as URL parameters.
- * @param listener
- * Callback interface to notify the application when the dialog
- * has completed.
- */
- public void dialog(Context context, String action, Bundle parameters, final DialogListener listener) {
-
- String endpoint = DIALOG_BASE_URL + action;
- parameters.putString("display", "touch");
- parameters.putString("redirect_uri", REDIRECT_URI);
-
- if (action.equals(LOGIN)) {
- parameters.putString("type", "user_agent");
- parameters.putString("client_id", mAppId);
- }
- else {
- parameters.putString("app_id", mAppId);
- }
-
- if (isSessionValid()) {
- parameters.putString(TOKEN, getAccessToken());
- }
- String url = endpoint + "?" + Util.encodeUrl(parameters);
- if (context.checkCallingOrSelfPermission(Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED) {
- Util.showAlert(context, "Error", "Application requires permission to access the Internet");
- }
- else {
- FbDialog fbDialog = new FbDialog(context, url, listener);
- DialogRegistration.register(context, fbDialog);
- fbDialog.show();
- }
- }
-
- /**
- * @return boolean - whether this object has an non-expired session token
- */
- public boolean isSessionValid() {
- return (getAccessToken() != null) && ((getAccessExpires() == 0) || (System.currentTimeMillis() < getAccessExpires()));
- }
-
- /**
- * Retrieve the OAuth 2.0 access token for API access: treat with care.
- * Returns null if no session exists.
- *
- * @return String - access token
- */
- public String getAccessToken() {
- return mAccessToken;
- }
-
- /**
- * Retrieve the current session's expiration time (in milliseconds since
- * Unix epoch), or 0 if the session doesn't expire or doesn't exist.
- *
- * @return long - session expiration time
- */
- public long getAccessExpires() {
- return mAccessExpires;
- }
-
- /**
- * Set the OAuth 2.0 access token for API access.
- *
- * @param token
- * - access token
- */
- public void setAccessToken(String token) {
- mAccessToken = token;
- }
-
- /**
- * Set the current session's expiration time (in milliseconds since Unix
- * epoch), or 0 if the session doesn't expire.
- *
- * @param time
- * - timestamp in milliseconds
- */
- public void setAccessExpires(long time) {
- mAccessExpires = time;
- }
-
- /**
- * Set the current session's duration (in seconds since Unix epoch).
- *
- * @param expiresIn
- * - duration in seconds
- */
- public void setAccessExpiresIn(String expiresIn) {
- if (expiresIn != null && !expiresIn.equals("0")) {
- setAccessExpires(System.currentTimeMillis() + Integer.parseInt(expiresIn) * 1000);
- }
- }
-
- public String getAppId() {
- return mAppId;
- }
-
- public void setAppId(String appId) {
- mAppId = appId;
- }
-
- /**
- * Callback interface for dialog requests.
- *
- */
- public static interface DialogListener {
-
- /**
- * Called when a dialog completes.
- *
- * Executed by the thread that initiated the dialog.
- *
- * @param values
- * Key-value string pairs extracted from the response.
- */
- public void onComplete(Bundle values);
-
- /**
- * Called when a Facebook responds to a dialog with an error.
- *
- * Executed by the thread that initiated the dialog.
- *
- */
- public void onFacebookError(FacebookError e);
-
- /**
- * Called when a dialog has an error.
- *
- * Executed by the thread that initiated the dialog.
- *
- */
- public void onError(DialogError e);
-
- /**
- * Called when a dialog is canceled by the user.
- *
- * Executed by the thread that initiated the dialog.
- *
- */
- public void onCancel();
-
- }
-
- public static final String FB_APP_SIGNATURE = "30820268308201d102044a9c4610300d06092a864886f70d0101040500307a310" + "b3009060355040613025553310b30090603550408130243413112301006035504"
- + "07130950616c6f20416c746f31183016060355040a130f46616365626f6f6b204" + "d6f62696c653111300f060355040b130846616365626f6f6b311d301b06035504"
- + "03131446616365626f6f6b20436f72706f726174696f6e3020170d30393038333" + "13231353231365a180f32303530303932353231353231365a307a310b30090603"
- + "55040613025553310b30090603550408130243413112301006035504071309506" + "16c6f20416c746f31183016060355040a130f46616365626f6f6b204d6f62696c"
- + "653111300f060355040b130846616365626f6f6b311d301b06035504031314466" + "16365626f6f6b20436f72706f726174696f6e30819f300d06092a864886f70d01"
- + "0101050003818d0030818902818100c207d51df8eb8c97d93ba0c8c1002c928fa" + "b00dc1b42fca5e66e99cc3023ed2d214d822bc59e8e35ddcf5f44c7ae8ade50d7"
- + "e0c434f500e6c131f4a2834f987fc46406115de2018ebbb0d5a3c261bd97581cc" + "fef76afc7135a6d59e8855ecd7eacc8f8737e794c60a761c536b72b11fac8e603"
- + "f5da1a2d54aa103b8a13c0dbc10203010001300d06092a864886f70d010104050" + "0038181005ee9be8bcbb250648d3b741290a82a1c9dc2e76a0af2f2228f1d9f9c"
- + "4007529c446a70175c5a900d5141812866db46be6559e2141616483998211f4a6" + "73149fb2232a10d247663b26a9031e15f84bc1c74d141ff98a02d76f85b2c8ab2"
- + "571b6469b232d8e768a7f7ca04f7abe4a775615916c07940656b58717457b42bd" + "928a2";
-
-}
View
50 sdk/deprecated/fb/FacebookError.java
@@ -1,50 +0,0 @@
-/*
- * Copyright 2010 Facebook, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.socialize.facebook;
-
-/**
- * Encapsulation of a Facebook Error: a Facebook request that could not be
- * fulfilled.
- *
- * @author ssoneff@facebook.com
- */
-public class FacebookError extends Throwable {
-
- private static final long serialVersionUID = 1L;
-
- private int mErrorCode = 0;
- private String mErrorType;
-
- public FacebookError(String message) {
- super(message);
- }
-
- public FacebookError(String message, String type, int code) {
- super(message);
- mErrorType = type;
- mErrorCode = code;
- }
-
- public int getErrorCode() {
- return mErrorCode;
- }
-
- public String getErrorType() {
- return mErrorType;
- }
-
-}
View
203 sdk/deprecated/fb/FbDialog.java
@@ -1,203 +0,0 @@
-/*
- * Copyright 2010 Facebook, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.socialize.facebook;
-
-import android.R;
-import android.app.Dialog;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.Color;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewGroup.LayoutParams;
-import android.view.Window;
-import android.webkit.WebView;
-import android.webkit.WebViewClient;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-
-import com.socialize.facebook.Facebook.DialogListener;
-
-public class FbDialog extends Dialog {
-
- static final int FB_BLUE = 0xFF6D84B4;
- static final float[] DIMENSIONS_DIFF_LANDSCAPE = { 20, 60 };
- static final float[] DIMENSIONS_DIFF_PORTRAIT = { 40, 60 };
- static final FrameLayout.LayoutParams FILL = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
- static final int MARGIN = 4;
- static final int PADDING = 2;
- static final String DISPLAY_STRING = "touch";
- static final String FB_ICON = "icon.png";
-
- private String mUrl;
- private DialogListener mListener;
- private ProgressDialog mSpinner;
- private ImageView mCrossImage;
- private WebView mWebView;
- private FrameLayout mContent;
-
- public FbDialog(Context context, String url, DialogListener listener) {
- super(context, android.R.style.Theme_Translucent_NoTitleBar);
- mUrl = url;
- mListener = listener;
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mSpinner = new ProgressDialog(getContext());
- mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
- mSpinner.setMessage("Loading...");
-
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- mContent = new FrameLayout(getContext());
-
- /*
- * Create the 'x' image, but don't add to the mContent layout yet at
- * this point, we only need to know its drawable width and height to
- * place the webview
- */
- createCrossImage();
-
- /*
- * Now we know 'x' drawable width and height, layout the webivew and add
- * it the mContent layout
- */
- int crossWidth = mCrossImage.getDrawable().getIntrinsicWidth();
- setUpWebView(crossWidth / 2);
-
- /*
- * Finally add the 'x' image to the mContent layout and add mContent to
- * the Dialog view
- */
- mContent.addView(mCrossImage, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
- addContentView(mContent, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
- }
-
- private void createCrossImage() {
- mCrossImage = new ImageView(getContext());
- // Dismiss the dialog when user click on the 'x'
- mCrossImage.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mListener.onCancel();
- FbDialog.this.dismiss();
- }
- });
-
-
-
- Drawable crossDrawable = getContext().getResources().getDrawable(R.drawable.btn_dialog);
-// Drawable crossDrawable = drawables.getDrawable("fb_cross.png");
- mCrossImage.setImageDrawable(crossDrawable);
- /*
- * 'x' should not be visible while webview is loading make it visible
- * only after webview has fully loaded
- */
- mCrossImage.setVisibility(View.INVISIBLE);
- }
-
- private void setUpWebView(int margin) {
- LinearLayout webViewContainer = new LinearLayout(getContext());
- mWebView = new WebView(getContext());
- mWebView.setVerticalScrollBarEnabled(false);
- mWebView.setHorizontalScrollBarEnabled(false);
- mWebView.setWebViewClient(new FbDialog.FbWebViewClient());
- mWebView.getSettings().setJavaScriptEnabled(true);
- mWebView.loadUrl(mUrl);
- mWebView.setLayoutParams(FILL);
- mWebView.setVisibility(View.INVISIBLE);
-
- webViewContainer.setPadding(margin, margin, margin, margin);
- webViewContainer.addView(mWebView);
- mContent.addView(webViewContainer);
- }
-
- private class FbWebViewClient extends WebViewClient {
-
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, String url) {
- Log.d("Facebook-WebView", "Redirect URL: " + url);
- if (url.startsWith(Facebook.REDIRECT_URI)) {
- Bundle values = Util.parseUrl(url);
-
- String error = values.getString("error");
- if (error == null) {
- error = values.getString("error_type");
- }
-
- if (error == null) {
- mListener.onComplete(values);
- }
- else if (error.equals("access_denied") || error.equals("OAuthAccessDeniedException")) {
- mListener.onCancel();
- }
- else {
- mListener.onFacebookError(new FacebookError(error));
- }
-
- FbDialog.this.dismiss();
- return true;
- }
- else if (url.startsWith(Facebook.CANCEL_URI)) {
- mListener.onCancel();
- FbDialog.this.dismiss();
- return true;
- }
- else if (url.contains(DISPLAY_STRING)) {
- return false;
- }
- // launch non-dialog URLs in a full browser
- getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
- return true;
- }
-
- @Override
- public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
- super.onReceivedError(view, errorCode, description, failingUrl);
- mListener.onError(new DialogError(description, errorCode, failingUrl));
- FbDialog.this.dismiss();
- }
-
- @Override
- public void onPageStarted(WebView view, String url, Bitmap favicon) {
- Log.d("Facebook-WebView", "Webview loading URL: " + url);
- super.onPageStarted(view, url, favicon);
- mSpinner.show();
- }
-
- @Override
- public void onPageFinished(WebView view, String url) {
- super.onPageFinished(view, url);
- mSpinner.dismiss();
- /*
- * Once webview is fully loaded, set the mContent background to be
- * transparent and make visible the 'x' image.
- */
- mContent.setBackgroundColor(Color.TRANSPARENT);
- mWebView.setVisibility(View.VISIBLE);
- mCrossImage.setVisibility(View.VISIBLE);
- }
- }
-}
View
75 sdk/deprecated/fb/RequestListener.java
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2012 Socialize Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.socialize.facebook;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-
-/**
- * Callback interface for API requests.
- *
- * Each method includes a 'state' parameter that identifies the calling
- * request. It will be set to the value passed when originally calling the
- * request method, or null if none was passed.
- */
-public interface RequestListener {
-
- /**
- * Called when a request completes with the given response.
- *
- * Executed by a background thread: do not update the UI in this method.
- */
- public void onComplete(String response, Object state);
-
- /**
- * Called when a request has a network or request error.
- *
- * Executed by a background thread: do not update the UI in this method.
- */
- public void onIOException(IOException e, Object state);
-
- /**
- * Called when a request fails because the requested resource is invalid
- * or does not exist.
- *
- * Executed by a background thread: do not update the UI in this method.
- */
- public void onFileNotFoundException(FileNotFoundException e, Object state);
-
- /**
- * Called if an invalid graph path is provided (which may result in a
- * malformed URL).
- *
- * Executed by a background thread: do not update the UI in this method.
- */
- public void onMalformedURLException(MalformedURLException e, Object state);
-
- /**
- * Called when the server-side Facebook method fails.
- *
- * Executed by a background thread: do not update the UI in this method.
- */
- public void onFacebookError(FacebookError e, Object state);
-
-}
View
323 sdk/deprecated/fb/Util.java
@@ -1,323 +0,0 @@
-/*
- * Copyright 2010 Facebook, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.socialize.facebook;
-
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import android.app.AlertDialog.Builder;
-import android.content.Context;
-import android.os.Bundle;
-import android.util.Log;
-import android.webkit.CookieManager;
-import android.webkit.CookieSyncManager;
-
-/**
- * Utility class supporting the Facebook Object.
- *
- * @author ssoneff@facebook.com
- *
- */
-public final class Util {
-
- /**
- * Generate the multi-part post body providing the parameters and boundary
- * string
- *
- * @param parameters
- * the parameters need to be posted
- * @param boundary
- * the random string as boundary
- * @return a string of the post body
- */
- public static String encodePostBody(Bundle parameters, String boundary) {
- if (parameters == null)
- return "";
- StringBuilder sb = new StringBuilder();
-
- for (String key : parameters.keySet()) {
-
- Object object = parameters.get(key);
-
- if (object instanceof byte[]) {
- continue;
- }
- else if (object instanceof String) {
- sb.append("Content-Disposition: form-data; name=\"" + key + "\"\r\n\r\n" + object.toString());
- sb.append("\r\n" + "--" + boundary + "\r\n");
- }
-
- // if (parameters.getByteArray(key) != null) {
- // continue;
- // }
- }
-
- return sb.toString();
- }
-
- public static String encodeUrl(Bundle parameters) {
- if (parameters == null) {
- return "";
- }
-
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- for (String key : parameters.keySet()) {
- if (first)
- first = false;
- else
- sb.append("&");
- sb.append(URLEncoder.encode(key) + "=" + URLEncoder.encode(parameters.getString(key)));
- }
- return sb.toString();
- }
-
- public static Bundle decodeUrl(String s) {
- Bundle params = new Bundle();
- if (s != null) {
- String array[] = s.split("&");
- for (String parameter : array) {
- String v[] = parameter.split("=");
- params.putString(URLDecoder.decode(v[0]), URLDecoder.decode(v[1]));
- }
- }
- return params;
- }
-
- /**
- * Parse a URL query and fragment parameters into a key-value bundle.
- *
- * @param url
- * the URL to parse
- * @return a dictionary bundle of keys and values
- */
- public static Bundle parseUrl(String url) {
- // hack to prevent MalformedURLException
- url = url.replace("fbconnect", "http");
- try {
- URL u = new URL(url);
- Bundle b = decodeUrl(u.getQuery());
- b.putAll(decodeUrl(u.getRef()));
- return b;
- }
- catch (MalformedURLException e) {
- return new Bundle();
- }
- }
-
- /**
- * Connect to an HTTP URL and return the response as a string.
- *
- * Note that the HTTP method override is used on non-GET requests. (i.e.
- * requests are made as "POST" with method specified in the body).
- *
- * @param url
- * - the resource to open: must be a welformed URL
- * @param method
- * - the HTTP method to use ("GET", "POST", etc.)
- * @param params
- * - the query parameter for the URL (e.g. access_token=foo)
- * @return the URL contents as a String
- * @throws MalformedURLException
- * - if the URL format is invalid
- * @throws IOException
- * - if a network problem occurs
- */
- public static String openUrl(String url, String method, Bundle params) throws MalformedURLException, IOException {
- // random string as boundary for multi-part http post
- String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f";
- String endLine = "\r\n";
-
- OutputStream os = null;
-
- try {
-
- if (method.equals("GET")) {
- url = url + "?" + encodeUrl(params);
- }
- Log.d("Facebook-Util", method + " URL: " + url);
- HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
- conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " FacebookAndroidSDK");
- if (!method.equals("GET")) {