├── .gitattributes ├── .gitignore ├── BmobShareSDK ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── assets │ └── yt_more.png ├── gen │ └── cn │ │ └── bomb │ │ └── social │ │ └── share │ │ ├── BuildConfig.java │ │ └── R.java ├── ic_launcher-web.png ├── libs │ ├── Android_SDK.jar │ ├── RennSDK-Android.jar │ ├── android-support-v4.jar │ ├── commons-httpclient-3.0.1.jar │ ├── libammsdk.jar │ ├── mta-sdk-1.0.0.jar │ ├── open_sdk.jar │ └── weibosdkcore.jar ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── drawable-xxhdpi │ │ └── ic_launcher.png │ ├── layout │ │ ├── activity_main.xml │ │ └── fragment_main.xml │ ├── values-w820dp │ │ └── dimens.xml │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml └── src │ └── cn │ └── bmob │ └── social │ └── share │ ├── core │ ├── BMCore.java │ ├── BMShareListener.java │ ├── ErrorInfo.java │ ├── activity │ │ └── ShareActivity.java │ ├── data │ │ ├── BMPlatform.java │ │ ├── PlatformKeyInfo.java │ │ └── ShareData.java │ ├── login │ │ ├── AuthActivity.java │ │ ├── AuthListener.java │ │ ├── AuthLogin.java │ │ └── AuthUserInfo.java │ ├── social │ │ ├── OtherShare.java │ │ ├── QQOpenShare.java │ │ ├── RennShare.java │ │ ├── SinaShare.java │ │ └── TencentWbShare.java │ ├── util │ │ ├── AccessTokenKeeper.java │ │ ├── BMLog.java │ │ ├── DownloadImage.java │ │ ├── FileUtils.java │ │ ├── PlatformAppHelper.java │ │ └── Util.java │ └── wxapi │ │ └── WXEntryActivity.java │ └── view │ ├── BMShare.java │ ├── ListPopup.java │ ├── ListPopupAdapter.java │ └── ShareList.java ├── BmobShareSDK_Test ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── assets │ ├── youtui_sdk.xml │ └── yt_left_arrow.png ├── bin │ ├── AndroidManifest.xml │ ├── R.txt │ ├── classes │ │ └── .gitignore │ └── jarlist.cache ├── gen │ └── .gitignore ├── ic_launcher-web.png ├── libs │ └── android-support-v4.jar ├── proguard-project.txt ├── project.properties ├── res │ ├── anim │ │ ├── sharepopup_fade_in.xml │ │ └── sharepopup_fade_out.xml │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── drawable-xxhdpi │ │ └── ic_launcher.png │ ├── drawable │ │ ├── yt_btn_style_alert_dialog_cancel_normal.9.png │ │ ├── yt_guide_dot_black.png │ │ ├── yt_guide_dot_white.png │ │ ├── yt_left_arrow.png │ │ ├── yt_lianjieact.png │ │ ├── yt_list_item_unselected_color_border.xml │ │ ├── yt_list_newmessage.png │ │ ├── yt_loadfail.png │ │ ├── yt_mailact.png │ │ ├── yt_messact.png │ │ ├── yt_more.png │ │ ├── yt_pyqact.png │ │ ├── yt_qqact.png │ │ ├── yt_qqkjact.png │ │ ├── yt_reddot.png │ │ ├── yt_renrenact.png │ │ ├── yt_side.9.png │ │ ├── yt_tengxunact.png │ │ ├── yt_wxact.png │ │ └── yt_xinlangact.png │ ├── layout │ │ ├── activity_main.xml │ │ ├── fragment_main.xml │ │ ├── yt_activity_main.xml │ │ ├── yt_pagergrid_item.xml │ │ ├── yt_popup_list.xml │ │ ├── yt_popup_viewpager.xml │ │ ├── yt_popup_whiteviewpager.xml │ │ ├── yt_share_pager.xml │ │ ├── yt_sharelist_item.xml │ │ └── yt_whiteviewpager_grid_item.xml │ ├── values-w820dp │ │ └── dimens.xml │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml └── src │ └── cn │ └── bmob │ └── socialshare │ └── test │ ├── MainActivity.java │ └── wxapi │ └── WXEntryActivity.java └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # ========================= 18 | # Operating System Files 19 | # ========================= 20 | 21 | # OSX 22 | # ========================= 23 | 24 | .DS_Store 25 | .AppleDouble 26 | .LSOverride 27 | 28 | # Icon must ends with two \r. 29 | Icon 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | -------------------------------------------------------------------------------- /BmobShareSDK/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /BmobShareSDK/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | BmobShareSDK 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /BmobShareSDK/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /BmobShareSDK/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.6 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.6 12 | -------------------------------------------------------------------------------- /BmobShareSDK/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /BmobShareSDK/assets/yt_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK/assets/yt_more.png -------------------------------------------------------------------------------- /BmobShareSDK/gen/cn/bomb/social/share/BuildConfig.java: -------------------------------------------------------------------------------- 1 | /** Automatically generated file. DO NOT MODIFY */ 2 | package cn.bomb.social.share; 3 | 4 | public final class BuildConfig { 5 | public final static boolean DEBUG = true; 6 | } -------------------------------------------------------------------------------- /BmobShareSDK/gen/cn/bomb/social/share/R.java: -------------------------------------------------------------------------------- 1 | /* AUTO-GENERATED FILE. DO NOT MODIFY. 2 | * 3 | * This class was automatically generated by the 4 | * aapt tool from the resource data it found. It 5 | * should not be modified by hand. 6 | */ 7 | 8 | package cn.bomb.social.share; 9 | 10 | public final class R { 11 | public static final class attr { 12 | } 13 | public static final class dimen { 14 | /** Default screen margins, per the Android Design guidelines. 15 | 16 | Example customization of dimensions originally defined in res/values/dimens.xml 17 | (such as screen margins) for screens with more than 820dp of available width. This 18 | would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). 19 | 20 | */ 21 | public static int activity_horizontal_margin=0x7f040000; 22 | public static int activity_vertical_margin=0x7f040001; 23 | } 24 | public static final class drawable { 25 | public static int ic_launcher=0x7f020000; 26 | } 27 | public static final class id { 28 | public static int container=0x7f070000; 29 | } 30 | public static final class layout { 31 | public static int activity_main=0x7f030000; 32 | public static int fragment_main=0x7f030001; 33 | } 34 | public static final class string { 35 | public static int action_settings=0x7f050002; 36 | public static int app_name=0x7f050000; 37 | public static int hello_world=0x7f050001; 38 | } 39 | public static final class style { 40 | /** 41 | Base application theme, dependent on API level. This theme is replaced 42 | by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 43 | 44 | 45 | Theme customizations available in newer API levels can go in 46 | res/values-vXX/styles.xml, while customizations related to 47 | backward-compatibility can go here. 48 | 49 | */ 50 | public static int AppBaseTheme=0x7f060000; 51 | /** Application theme. 52 | All customizations that are NOT specific to a particular API-level can go here. 53 | */ 54 | public static int AppTheme=0x7f060001; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /BmobShareSDK/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK/ic_launcher-web.png -------------------------------------------------------------------------------- /BmobShareSDK/libs/Android_SDK.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK/libs/Android_SDK.jar -------------------------------------------------------------------------------- /BmobShareSDK/libs/RennSDK-Android.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK/libs/RennSDK-Android.jar -------------------------------------------------------------------------------- /BmobShareSDK/libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK/libs/android-support-v4.jar -------------------------------------------------------------------------------- /BmobShareSDK/libs/commons-httpclient-3.0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK/libs/commons-httpclient-3.0.1.jar -------------------------------------------------------------------------------- /BmobShareSDK/libs/libammsdk.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK/libs/libammsdk.jar -------------------------------------------------------------------------------- /BmobShareSDK/libs/mta-sdk-1.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK/libs/mta-sdk-1.0.0.jar -------------------------------------------------------------------------------- /BmobShareSDK/libs/open_sdk.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK/libs/open_sdk.jar -------------------------------------------------------------------------------- /BmobShareSDK/libs/weibosdkcore.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK/libs/weibosdkcore.jar -------------------------------------------------------------------------------- /BmobShareSDK/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /BmobShareSDK/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-14 15 | android.library=true 16 | -------------------------------------------------------------------------------- /BmobShareSDK/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /BmobShareSDK/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /BmobShareSDK/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /BmobShareSDK/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /BmobShareSDK/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | -------------------------------------------------------------------------------- /BmobShareSDK/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /BmobShareSDK/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 64dp 9 | 10 | 11 | -------------------------------------------------------------------------------- /BmobShareSDK/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 8 | -------------------------------------------------------------------------------- /BmobShareSDK/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Bmob_SocialShare_SDK2 5 | Hello world! 6 | Settings 7 | 8 | 9 | -------------------------------------------------------------------------------- /BmobShareSDK/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/BMCore.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | import cn.bmob.social.share.core.activity.ShareActivity; 7 | import cn.bmob.social.share.core.data.BMPlatform; 8 | import cn.bmob.social.share.core.data.PlatformKeyInfo; 9 | import cn.bmob.social.share.core.data.ShareData; 10 | import cn.bmob.social.share.core.login.AuthListener; 11 | import cn.bmob.social.share.core.login.AuthLogin; 12 | import cn.bmob.social.share.core.login.AuthUserInfo; 13 | import cn.bmob.social.share.core.social.OtherShare; 14 | import cn.bmob.social.share.core.util.AccessTokenKeeper; 15 | import cn.bmob.social.share.core.util.BMLog; 16 | import cn.bmob.social.share.core.util.DownloadImage; 17 | import cn.bmob.social.share.core.util.PlatformAppHelper; 18 | import cn.bmob.social.share.core.util.Util; 19 | import cn.bmob.social.share.core.wxapi.WXEntryActivity; 20 | import android.app.Activity; 21 | import android.content.Context; 22 | import android.content.Intent; 23 | import android.content.res.Resources; 24 | import android.net.Uri; 25 | import android.os.Environment; 26 | import android.os.Handler; 27 | import android.os.Message; 28 | import android.telephony.TelephonyManager; 29 | import android.text.TextUtils; 30 | import android.util.Log; 31 | import android.widget.Toast; 32 | 33 | /** 34 | * 35 | * 分享操作类 36 | * @author 稻草人 37 | * @date 2014年7月18日 下午3:58:05 38 | * 39 | */ 40 | public class BMCore { 41 | /**应用包名*/ 42 | public static String packName; 43 | /**应用资源*/ 44 | public static Resources res; 45 | /**应用AppContent*/ 46 | public static Context appContext; 47 | /**实例*/ 48 | public static BMCore bmCore; 49 | /** 获取应用分享分享信息成功 */ 50 | private final int GET_APPSHAREDATA_SUCCESS = 0; 51 | /** 获取应用分享内容失败 */ 52 | private final int GET_APPSHAREDATA_FAIL = 1; 53 | /** 获取内容分享信息成功 */ 54 | private final int GET_CONTENTSHAREDATA_SUCCESS = 3; 55 | /** 获取内容分享内容失败 */ 56 | private final int GET_CONTENTSHAREDATA_FAIL = 4; 57 | /**传入的activity*/ 58 | private Activity act; 59 | /**分享平台*/ 60 | private BMPlatform platform; 61 | /**分享监听*/ 62 | private BMShareListener listener; 63 | /**处理获取待分享信息后的操作,获取到待分享信息就进行分享,没有获取到待分享信息则提醒用户*/ 64 | public Handler mHandler = new Handler() { 65 | public void handleMessage(android.os.Message msg) { 66 | Util.dismissDialog(); 67 | switch (msg.what) { 68 | //获取应用分享信息成功后进行分享操作 69 | case GET_APPSHAREDATA_SUCCESS: 70 | ShareData shareData = (ShareData) msg.obj; 71 | doShare(act, platform, listener,shareData); 72 | break; 73 | //获取应用分享信息失败,提醒用户 74 | case GET_APPSHAREDATA_FAIL: 75 | Toast.makeText(appContext, "获取分享内容失败,请检查分享的网络地址和网络连接情况...", Toast.LENGTH_SHORT).show(); 76 | break; 77 | //获取内容分享信息成功,进行分享操作 78 | case GET_CONTENTSHAREDATA_SUCCESS: 79 | ShareData contentShareData = (ShareData) msg.obj; 80 | doShare(act, platform, listener,contentShareData); 81 | break; 82 | //获取内容分享信息失败,提醒用户 83 | case GET_CONTENTSHAREDATA_FAIL: 84 | Toast.makeText(appContext, "获取分享内容失败,请检查分享的网络地址和网络连接情况...", Toast.LENGTH_SHORT).show(); 85 | break; 86 | 87 | default: 88 | break; 89 | } 90 | }; 91 | }; 92 | 93 | /** 获取友推sdk的实例 */ 94 | public static BMCore getInstance() { 95 | if (bmCore == null) { 96 | bmCore = new BMCore(); 97 | } 98 | return bmCore; 99 | } 100 | 101 | /** ytcore初始化操作 */ 102 | public static void init(final Context context) { 103 | // 读取手机信息 104 | getPhoneInfo(context); 105 | } 106 | 107 | /** 读取手机和应用信息 */ 108 | private static void getPhoneInfo(Context context) { 109 | packName = context.getPackageName(); 110 | res = context.getResources(); 111 | appContext = context.getApplicationContext(); 112 | } 113 | 114 | /** 分享到社交平台 */ 115 | public void share(Activity act, BMPlatform platform, BMShareListener listener,final ShareData shareData) { 116 | // 分享前操作 117 | this.act = act; 118 | this.platform = platform; 119 | this.listener = listener; 120 | 121 | Util.showProgressDialog(act, "获取分享数据中...", false); 122 | if (listener != null) { 123 | listener.onPreShare(); 124 | } 125 | // 获取分享信息 126 | new Thread() { 127 | public void run() { 128 | getShareData(shareData); 129 | }; 130 | }.start(); 131 | } 132 | 133 | /** 跳转到分享页面 */ 134 | private void doShare(Activity act, final BMPlatform platform, final BMShareListener listener,final ShareData shareData) { 135 | String shortUrl = null ; 136 | final String realUrl = shareData.getTarget_url(); 137 | if (!shareData.isAppShare && shareData.getTarget_url() != null && !shareData.getTarget_url().equals("")) { 138 | // 如果是应用分享,则从服务端获取应用分享信息 139 | // shortUrl = CMyEncrypt.shortUrl(shareData.getTarget_url())[0]; 140 | // sendUrl(KeyInfo.youTui_AppKey, platform.getChannleId(), shareData.getTarget_url(), !shareData.isAppShare, shortUrl); 141 | } 142 | 143 | // 处理链接 144 | // dealWithUrl(platform.getChannleId(), shortUrl,shareData); 145 | if (platform == BMPlatform.PLATFORM_WECHAT || platform == BMPlatform.PLATFORM_WECHATMOMENTS) { 146 | // 微信和朋友圈 147 | if (PlatformAppHelper.isWeixinExisted(act)) { 148 | try { 149 | Intent it = new Intent(act, Class.forName(packName + ".wxapi.WXEntryActivity")); 150 | WXEntryActivity.listener = listener; 151 | it.putExtra("platform", platform); 152 | it.putExtra("fromShare", true); 153 | it.putExtra("shortUrl", shortUrl); 154 | it.putExtra("realUrl", realUrl); 155 | WXEntryActivity.shareData = shareData; 156 | act.startActivity(it); 157 | } catch (ClassNotFoundException e) { 158 | BMLog.e(packName + ".wxapi.WXEntryActivity cann't be found"); 159 | e.printStackTrace(); 160 | } 161 | } else { 162 | Toast.makeText(act, "未安装微信。。。", Toast.LENGTH_SHORT).show(); 163 | } 164 | 165 | } else if (platform == BMPlatform.PLATFORM_EMAIL) { 166 | //分享到Email 167 | if(shareData.getTarget_url()!=null){ 168 | new OtherShare(act).sendMail(shareData.getText()+shareData.getTarget_url()); 169 | }else{ 170 | new OtherShare(act).sendMail(shareData.getText()); 171 | } 172 | } else if (platform == BMPlatform.PLATFORM_MESSAGE) { 173 | //分享到短信 174 | if(shareData.getTarget_url()!=null){ 175 | new OtherShare(act).sendSMS(shareData.getText()+shareData.getTarget_url()); 176 | }else{ 177 | new OtherShare(act).sendSMS(shareData.getText()); 178 | } 179 | } else if (platform == BMPlatform.PLATFORM_MORE_SHARE) { 180 | //更多分享 181 | moreShare(shareData); 182 | } else if (platform == BMPlatform.PLATFORM_TENCENTWEIBO) { 183 | //finalShortUrl用于传递shortUrl 184 | final String finalShortUrl = shortUrl; 185 | //分享到腾讯微博 186 | if (AccessTokenKeeper.isTencentWbAuthExpired(act)) { 187 | //如果腾讯微博授权过期,先获取授权 188 | AuthLogin tencentWbLogin = new AuthLogin(); 189 | AuthListener tencentWbListener = new AuthListener() { 190 | @Override 191 | public void onAuthSucess(Activity act, AuthUserInfo userInfo) { 192 | Intent qqWBIt = new Intent(act, ShareActivity.class); 193 | qqWBIt.putExtra("platform", platform); 194 | ShareActivity.shareData = shareData; 195 | WXEntryActivity.listener = listener; 196 | qqWBIt.putExtra("shortUrl", finalShortUrl); 197 | qqWBIt.putExtra("realUrl", realUrl); 198 | act.startActivityForResult(qqWBIt, PlatformKeyInfo.tencentWeiboIndex); 199 | } 200 | 201 | @Override 202 | public void onAuthFail(Activity act) { 203 | Toast.makeText(act, "授权失败...", Toast.LENGTH_SHORT).show(); 204 | } 205 | 206 | @Override 207 | public void onAuthCancel(Activity act) { 208 | Toast.makeText(act, "授权取消...", Toast.LENGTH_SHORT).show(); 209 | } 210 | 211 | }; 212 | 213 | tencentWbLogin.tencentWbAuth(act, tencentWbListener); 214 | } else { 215 | //如果已授权,进行分享 216 | Intent it = new Intent(act, ShareActivity.class); 217 | ShareActivity.listener = listener; 218 | it.putExtra("platform", platform); 219 | it.putExtra("shortUrl", shortUrl); 220 | it.putExtra("realUrl", realUrl); 221 | ShareActivity.shareData = shareData; 222 | act.startActivity(it); 223 | } 224 | 225 | } else if (platform == BMPlatform.PLATFORM_QQ || platform == BMPlatform.PLATFORM_QZONE) { 226 | //分享到qq和qq空间 227 | if(PlatformAppHelper.isTencentQQExisted(act)){ 228 | Intent it = new Intent(act, ShareActivity.class); 229 | ShareActivity.listener = listener; 230 | it.putExtra("platform", platform); 231 | it.putExtra("shortUrl", shortUrl); 232 | it.putExtra("realUrl", realUrl); 233 | ShareActivity.shareData = shareData; 234 | act.startActivity(it); 235 | }else{ 236 | Toast.makeText(act, "未安装QQ。。。", Toast.LENGTH_SHORT).show(); 237 | } 238 | 239 | } else if (platform == BMPlatform.PLATFORM_SINAWEIBO) { 240 | //分享到新浪微博 241 | if(PlatformAppHelper.isSinaWeiboExisted(act)){ 242 | Intent it = new Intent(act, ShareActivity.class); 243 | ShareActivity.listener = listener; 244 | it.putExtra("platform", platform); 245 | it.putExtra("shortUrl", shortUrl); 246 | it.putExtra("realUrl", realUrl); 247 | ShareActivity.shareData = shareData; 248 | act.startActivity(it); 249 | }else{ 250 | Toast.makeText(act, "未安装新浪微博。。。", Toast.LENGTH_SHORT).show(); 251 | //如果已授权,进行分享 252 | Intent it = new Intent(act, ShareActivity.class); 253 | ShareActivity.listener = listener; 254 | it.putExtra("platform", platform); 255 | it.putExtra("shortUrl", shortUrl); 256 | it.putExtra("realUrl", realUrl); 257 | ShareActivity.shareData = shareData; 258 | act.startActivity(it); 259 | } 260 | 261 | } else if (platform == BMPlatform.PLATFORM_RENN) { 262 | //分享到人人网 263 | if(PlatformAppHelper.isRenrenExisted(act)){ 264 | Intent it = new Intent(act, ShareActivity.class); 265 | ShareActivity.listener = listener; 266 | it.putExtra("platform", platform); 267 | it.putExtra("shortUrl", shortUrl); 268 | it.putExtra("realUrl", realUrl); 269 | ShareActivity.shareData = shareData; 270 | act.startActivity(it); 271 | }else{ 272 | Toast.makeText(act, "未安装人人网。。。", Toast.LENGTH_SHORT).show(); 273 | } 274 | }else if(platform == BMPlatform.PLATFORM_COPYLINK){ 275 | //复制链接 276 | if(shareData.getTarget_url()!=null){ 277 | Util.copyLink(mHandler, act, shareData.getTarget_url()); 278 | } 279 | } 280 | } 281 | 282 | /** 获取分享信息 */ 283 | private void getShareData(ShareData shareData) { 284 | Log.d("bmob", "isAppShare = "+shareData.isAppShare); 285 | if (shareData.isAppShare) { 286 | //如果是应用分享,则从服务器获取预先设置好的分享内容 287 | // getAppShareData(shareData); 288 | } else { 289 | // 如果是内容分享,设置了网络图片,则下载到本地再进行分享,并将imagePath设为下载到本地的图片路径 290 | if(!TextUtils.isEmpty(shareData.getImageUrl())){ 291 | String picPath = shareData.getImageUrl().substring(shareData.getImageUrl().lastIndexOf("/") + 1, shareData.getImageUrl().length()); 292 | try { 293 | DownloadImage.down_file(shareData.getImageUrl(), DownloadImage.FILE_SAVE_PATH, picPath); 294 | shareData.setImagePath(Environment.getExternalStorageDirectory() + DownloadImage.FILE_SAVE_PATH + picPath); 295 | BMLog.d("BMCore:" + "网络图片保存到本地的路径: "+shareData.getImagePath()); 296 | } catch (IOException e) { 297 | mHandler.sendEmptyMessage(GET_CONTENTSHAREDATA_FAIL); 298 | e.printStackTrace(); 299 | return; 300 | } 301 | } 302 | Message msg = Message.obtain(mHandler, GET_CONTENTSHAREDATA_SUCCESS, shareData); 303 | mHandler.sendMessage(msg); 304 | } 305 | } 306 | 307 | /** 系统分享 */ 308 | private void moreShare(ShareData shareData) { 309 | Intent it = new Intent(Intent.ACTION_SEND); 310 | it.setType("image/*"); 311 | if (shareData.getImagePath() != null) { 312 | File file = new File(shareData.getImagePath()); 313 | Uri uri = Uri.fromFile(file); 314 | it.putExtra(Intent.EXTRA_STREAM, uri); 315 | } 316 | it.putExtra(Intent.EXTRA_SUBJECT, shareData.getTitle()); 317 | it.putExtra(Intent.EXTRA_TEXT, shareData.getText()); 318 | it.putExtra(Intent.EXTRA_TITLE, shareData.getTitle()); 319 | act.startActivity(Intent.createChooser(it,shareData.getTitle())); 320 | } 321 | 322 | } 323 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/BMShareListener.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core; 2 | 3 | public abstract class BMShareListener { 4 | /**分享前操作*/ 5 | public abstract void onPreShare(); 6 | /**分享成功操作*/ 7 | public abstract void onSuccess(); 8 | /**分享错误操作*/ 9 | public abstract void onError(ErrorInfo error); 10 | /**分享取消操作*/ 11 | public abstract void onCancel(); 12 | } 13 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/ErrorInfo.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core; 2 | 3 | /** 4 | * 该类用于携带各个分享平台分享的返回信息 5 | * @author youtui 6 | * @since 14/6/9 7 | */ 8 | public class ErrorInfo { 9 | /**错误信息*/ 10 | private String ErrorMessage; 11 | /**获取错误信息*/ 12 | public String getErrorMessage() { 13 | return ErrorMessage; 14 | } 15 | /**设置错误信息*/ 16 | public void setErrorMessage(String errorMessage) { 17 | ErrorMessage = errorMessage; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/activity/ShareActivity.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.activity; 2 | 3 | import java.io.IOException; 4 | 5 | import cn.bmob.social.share.core.BMShareListener; 6 | import cn.bmob.social.share.core.ErrorInfo; 7 | import cn.bmob.social.share.core.data.BMPlatform; 8 | import cn.bmob.social.share.core.data.PlatformKeyInfo; 9 | import cn.bmob.social.share.core.data.ShareData; 10 | import cn.bmob.social.share.core.social.QQOpenShare; 11 | import cn.bmob.social.share.core.social.RennShare; 12 | import cn.bmob.social.share.core.social.SinaShare; 13 | import cn.bmob.social.share.core.social.TencentWbShare; 14 | import cn.bmob.social.share.core.util.BMLog; 15 | import cn.bmob.social.share.core.util.Util; 16 | 17 | import com.sina.weibo.sdk.api.share.BaseResponse; 18 | import com.sina.weibo.sdk.api.share.IWeiboHandler; 19 | import com.sina.weibo.sdk.api.share.IWeiboShareAPI; 20 | import com.sina.weibo.sdk.api.share.WeiboShareSDK; 21 | import com.sina.weibo.sdk.constant.WBConstants; 22 | 23 | import android.app.Activity; 24 | import android.content.Intent; 25 | import android.content.res.AssetManager; 26 | import android.graphics.Bitmap; 27 | import android.graphics.BitmapFactory; 28 | import android.graphics.drawable.BitmapDrawable; 29 | import android.os.Bundle; 30 | import android.os.Handler; 31 | import android.view.Gravity; 32 | import android.view.View; 33 | import android.view.ViewGroup.LayoutParams; 34 | import android.view.Window; 35 | import android.widget.EditText; 36 | import android.widget.ImageView; 37 | import android.widget.LinearLayout; 38 | import android.widget.RelativeLayout; 39 | import android.widget.TextView; 40 | import android.widget.Toast; 41 | 42 | /** 43 | * 分享界面 44 | * 45 | * @author youtui 46 | * @since 14/6/11 47 | */ 48 | public class ShareActivity extends Activity implements IWeiboHandler.Response { 49 | /** 分享的平台 */ 50 | private BMPlatform platform; 51 | /** 新浪微博分享操作类 */ 52 | private SinaShare sinaShare; 53 | /** 新浪微博分享接口 */ 54 | private IWeiboShareAPI iWeiboShareAPI; 55 | /** 返回按钮id */ 56 | private final int BACK_ID = 140901; 57 | /** 分享按钮id */ 58 | private final int SHAREBT_ID = 140902; 59 | /** 人人分享成功 */ 60 | public static final int RENN_SHARE_SUCCESS = 0; 61 | /** 人人分享错误 */ 62 | public static final int RENN_SHARE_ERROR = 1; 63 | /** 人人分享网络错误 */ 64 | public static final int RENN_HTTP_ERROR = 2; 65 | /** 人人分享图片未找到 */ 66 | public static final int RENN_PIC_NOTFOUND = 3; 67 | /** 待分享数据 */ 68 | public static ShareData shareData; 69 | /** 分享监听 */ 70 | public static BMShareListener listener; 71 | /** 短链接 */ 72 | private String shortUrl; 73 | /** 长连接 */ 74 | private String realUrl; 75 | /** 处理人人分享回调 */ 76 | private Handler mHandler = new Handler() { 77 | public void handleMessage(android.os.Message msg) { 78 | switch (msg.what) { 79 | // 人人分享成功 80 | case RENN_SHARE_SUCCESS: 81 | // if (shareData != null) { 82 | // BMShareListener.sharePoint(ShareActivity.this, PlatformKeyInfo.youTui_AppKey, ChannelId.RENN, realUrl, !shareData.isAppShare, shortUrl); 83 | // } 84 | if (listener != null) { 85 | ErrorInfo error = new ErrorInfo(); 86 | String errorMessage = (String) msg.obj; 87 | error.setErrorMessage(errorMessage); 88 | listener.onSuccess(); 89 | } 90 | ShareActivity.this.finish(); 91 | break; 92 | /** 处理人人分享错误 */ 93 | case RENN_SHARE_ERROR: 94 | if (listener != null) { 95 | ErrorInfo error = new ErrorInfo(); 96 | String errorMessage = (String) msg.obj; 97 | error.setErrorMessage(errorMessage); 98 | listener.onError(error); 99 | } 100 | ShareActivity.this.finish(); 101 | break; 102 | /** 处理人人分享网络错误 */ 103 | case RENN_HTTP_ERROR: 104 | Toast.makeText(ShareActivity.this, "连接到服务器错误...", Toast.LENGTH_SHORT).show(); 105 | ShareActivity.this.finish(); 106 | break; 107 | /** 处理人人分享图片未找到 */ 108 | case RENN_PIC_NOTFOUND: 109 | Toast.makeText(ShareActivity.this, "未找到分享图片,请重新设置分享图片路径...", Toast.LENGTH_SHORT).show(); 110 | break; 111 | default: 112 | break; 113 | } 114 | }; 115 | }; 116 | 117 | @Override 118 | protected void onCreate(Bundle savedInstanceState) { 119 | requestWindowFeature(Window.FEATURE_NO_TITLE); 120 | super.onCreate(savedInstanceState); 121 | doShare(); 122 | } 123 | 124 | /** 125 | * 分享操作 126 | */ 127 | private void doShare() { 128 | platform = (BMPlatform) getIntent().getExtras().get("platform"); 129 | shortUrl = getIntent().getExtras().getString("shortUrl"); 130 | realUrl = getIntent().getExtras().getString("realUrl"); 131 | boolean sinaWeiboIsNoKeyShare = getIntent().getExtras().getBoolean("sinaWeiboIsNoKeyShare"); 132 | 133 | switch (platform) { 134 | // 分享到新浪微博 135 | case PLATFORM_SINAWEIBO: 136 | if (sinaWeiboIsNoKeyShare) { 137 | initView("新浪微博", platform); 138 | } else { 139 | iWeiboShareAPI = WeiboShareSDK.createWeiboAPI(this, PlatformKeyInfo.sinaWeibo_AppKey); 140 | sinaShare = new SinaShare(ShareActivity.this, shareData); 141 | sinaShare.shareToSina(); 142 | } 143 | break; 144 | // 分享到qq 145 | case PLATFORM_QQ: 146 | new QQOpenShare(this, "QQ", listener, shareData).shareToQQ(); 147 | break; 148 | // 分享到qq空间 149 | case PLATFORM_QZONE: 150 | new QQOpenShare(this, "Qzone", listener, shareData).shareToQzone(); 151 | break; 152 | // 分享到腾讯微博 153 | case PLATFORM_TENCENTWEIBO: 154 | initView("腾讯微博", platform); 155 | break; 156 | // 分享到人人网 157 | case PLATFORM_RENN: 158 | initView("人人网", platform); 159 | break; 160 | default: 161 | break; 162 | } 163 | 164 | } 165 | 166 | /** 167 | * 新浪微博分享完会调用该方法 168 | */ 169 | @Override 170 | protected void onNewIntent(Intent intent) { 171 | setIntent(intent); 172 | if (platform == BMPlatform.PLATFORM_SINAWEIBO) { 173 | iWeiboShareAPI.handleWeiboResponse(intent, this); 174 | } 175 | super.onNewIntent(intent); 176 | } 177 | 178 | /** 179 | * 新浪分享回调 180 | */ 181 | @Override 182 | public void onResponse(BaseResponse baseResp) { 183 | switch (baseResp.errCode) { 184 | // 分享成功 185 | case WBConstants.ErrorCode.ERR_OK: 186 | // if (shareData != null) { 187 | // BMShareListener.sharePoint(this, PlatformKeyInfo.youTui_AppKey, ChannelId.SINAWEIBO, realUrl, !shareData.isAppShare, shortUrl); 188 | // } 189 | if (listener != null) { 190 | ErrorInfo error = new ErrorInfo(); 191 | error.setErrorMessage(baseResp.errMsg); 192 | listener.onSuccess(); 193 | } 194 | break; 195 | // 分享取消 196 | case WBConstants.ErrorCode.ERR_CANCEL: 197 | if (listener != null) { 198 | listener.onCancel(); 199 | } 200 | 201 | break; 202 | // 分享错误 203 | case WBConstants.ErrorCode.ERR_FAIL: 204 | // 新浪微博分享在这里有bug 205 | if ("auth faild!!!!".equals(baseResp.errMsg)) { 206 | Toast.makeText(this, "授权失败,请重新获取授权...", Toast.LENGTH_SHORT).show(); 207 | iWeiboShareAPI.registerApp(); 208 | } else { 209 | if (listener != null) { 210 | ErrorInfo error = new ErrorInfo(); 211 | error.setErrorMessage(baseResp.errMsg); 212 | listener.onError(error); 213 | } 214 | } 215 | break; 216 | 217 | default: 218 | break; 219 | } 220 | 221 | finish(); 222 | 223 | } 224 | 225 | @Override 226 | protected void onDestroy() { 227 | // activity摧毁时释放listener 228 | Util.dismissDialog(); 229 | shareData = null; 230 | listener = null; 231 | super.onDestroy(); 232 | } 233 | 234 | /** 腾讯微博和人人以及新浪的无key分享需要自己写分享编辑界面 */ 235 | private void initView(String platformName, final BMPlatform platform) { 236 | LinearLayout mainLinear = new LinearLayout(this); 237 | mainLinear.setOrientation(LinearLayout.VERTICAL); 238 | mainLinear.setBackgroundColor(0xffe9ecff); 239 | // 240 | RelativeLayout headerLayout = new RelativeLayout(this); 241 | RelativeLayout.LayoutParams headerLinearParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, Util.dip2px(this, 50)); 242 | headerLayout.setLayoutParams(headerLinearParams); 243 | headerLayout.setBackgroundColor(0xff66c0ff); 244 | 245 | // 返回键 246 | LinearLayout back = new LinearLayout(this); 247 | RelativeLayout.LayoutParams backParams = new RelativeLayout.LayoutParams(Util.dip2px(this, 50), RelativeLayout.LayoutParams.FILL_PARENT); 248 | backParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); 249 | back.setHorizontalGravity(Gravity.CENTER); 250 | back.setVerticalGravity(Gravity.CENTER); 251 | back.setId(BACK_ID); 252 | back.setOnClickListener(new View.OnClickListener() { 253 | 254 | @Override 255 | public void onClick(View v) { 256 | ShareActivity.this.finish(); 257 | 258 | } 259 | 260 | }); 261 | // 返回键图片 262 | ImageView backImage = new ImageView(this); 263 | LayoutParams backImageParams = new LayoutParams(Util.dip2px(this, 20), Util.dip2px(this, 20)); 264 | backImage.setLayoutParams(backImageParams); 265 | AssetManager asset = getAssets(); 266 | Bitmap backBitmap = null; 267 | try { 268 | backBitmap = BitmapFactory.decodeStream(asset.open("yt_left_arrow.png")); 269 | } catch (IOException e) { 270 | e.printStackTrace(); 271 | } 272 | backImage.setImageBitmap(backBitmap); 273 | back.addView(backImage); 274 | // 标题栏 275 | TextView title = new TextView(this); 276 | RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); 277 | titleParams.addRule(RelativeLayout.RIGHT_OF, BACK_ID); 278 | titleParams.addRule(RelativeLayout.LEFT_OF, SHAREBT_ID); 279 | title.setGravity(Gravity.CENTER_VERTICAL); 280 | title.setText(platformName); 281 | title.setTextSize(16); 282 | title.setTextColor(0xffffffff); 283 | 284 | // 分享按钮 285 | TextView shareBt = new TextView(this); 286 | shareBt.setId(SHAREBT_ID); 287 | RelativeLayout.LayoutParams shareBtParams = new RelativeLayout.LayoutParams(Util.dip2px(this, 50), RelativeLayout.LayoutParams.FILL_PARENT); 288 | shareBtParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); 289 | shareBt.setText("分享"); 290 | shareBt.setGravity(Gravity.CENTER_VERTICAL); 291 | shareBt.setTextColor(0xffffffff); 292 | 293 | shareBt.setOnClickListener(new View.OnClickListener() { 294 | 295 | @Override 296 | public void onClick(View v) { 297 | if (platform == BMPlatform.PLATFORM_RENN) { 298 | Util.showProgressDialog(ShareActivity.this, "分享中...", true); 299 | new RennShare(ShareActivity.this, mHandler, listener, shareData).shareToRenn(); 300 | } else if (platform == BMPlatform.PLATFORM_TENCENTWEIBO) { 301 | Util.showProgressDialog(ShareActivity.this, "分享中...", true); 302 | new TencentWbShare(ShareActivity.this, listener, shareData).shareToTencentWb(); 303 | } else if (platform == BMPlatform.PLATFORM_SINAWEIBO) { 304 | // 没有key的情况下进行新浪微博分享 305 | Util.showProgressDialog(ShareActivity.this, "分享中...", true); 306 | // SinaNoKeyShare.shareToSina(ShareActivity.this, shareData, listener, realUrl, shortUrl); 307 | } 308 | } 309 | }); 310 | 311 | headerLayout.addView(back, backParams); 312 | headerLayout.addView(title, titleParams); 313 | headerLayout.addView(shareBt, shareBtParams); 314 | // 分享内容框 315 | LinearLayout bodyLayout = new LinearLayout(this); 316 | bodyLayout.setOrientation(LinearLayout.VERTICAL); 317 | LinearLayout.LayoutParams bodyParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, Util.dip2px(this, 270)); 318 | bodyLayout.setLayoutParams(bodyParams); 319 | bodyLayout.setBackgroundColor(0xfff4f4f4); 320 | // 分享的文字 321 | EditText editText = new EditText(this); 322 | LinearLayout.LayoutParams editParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, Util.dip2px(this, 160)); 323 | editParams.setMargins(8, 8, 8, 8); 324 | editText.setLayoutParams(editParams); 325 | if (shareData != null && shareData.getText() != null) { 326 | editText.setText(shareData.getText()); 327 | } 328 | editText.setGravity(Gravity.TOP); 329 | editText.setTextColor(0xffa1a1a1); 330 | editText.setTextSize(13); 331 | editText.setBackgroundDrawable(null); 332 | // 分享的图片 333 | ImageView shareImage = new ImageView(this); 334 | LinearLayout.LayoutParams shareImageParams = new LinearLayout.LayoutParams(Util.dip2px(this, 100), Util.dip2px(this, 100)); 335 | shareImageParams.setMargins(8, 0, 8, 8); 336 | shareImage.setLayoutParams(shareImageParams); 337 | if (shareData != null && shareData.getImagePath() != null) { 338 | Bitmap imageBit = BitmapFactory.decodeFile(shareData.getImagePath()); 339 | BitmapDrawable bitDraw = new BitmapDrawable(imageBit); 340 | shareImage.setBackgroundDrawable(bitDraw); 341 | } 342 | 343 | bodyLayout.addView(editText); 344 | bodyLayout.addView(shareImage); 345 | 346 | mainLinear.addView(headerLayout, headerLinearParams); 347 | mainLinear.addView(bodyLayout, bodyParams); 348 | 349 | setContentView(mainLinear); 350 | } 351 | 352 | @Override 353 | protected void onRestart() { 354 | Util.dismissDialog(); 355 | finish(); 356 | super.onRestart(); 357 | } 358 | 359 | } 360 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/data/BMPlatform.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.data; 2 | 3 | /** 4 | * 5 | * 分享平台信息 6 | * @author 稻草人 7 | * @date 2014年7月18日 下午3:59:32 8 | * 9 | */ 10 | public enum BMPlatform { 11 | PLATFORM_SINAWEIBO, PLATFORM_TENCENTWEIBO, PLATFORM_QZONE, PLATFORM_WECHAT, PLATFORM_RENN, PLATFORM_QQ, PLATFORM_MESSAGE, PLATFORM_EMAIL, PLATFORM_WECHATMOMENTS, PLATFORM_MORE_SHARE, 12 | PLATFORM_COPYLINK; 13 | 14 | /** 15 | * 通过平台ID获取平台名字,如果没有该ID则返回null 16 | * @param platform 17 | * @return 18 | */ 19 | public static String getPlatfornName(BMPlatform platform) { 20 | switch (platform) { 21 | case PLATFORM_SINAWEIBO: 22 | return "SinaWeibo"; 23 | case PLATFORM_TENCENTWEIBO: 24 | return "TencentWeibo"; 25 | case PLATFORM_QZONE: 26 | return "QZone"; 27 | case PLATFORM_WECHAT: 28 | return "Wechat"; 29 | case PLATFORM_RENN: 30 | return "Renren"; 31 | case PLATFORM_QQ: 32 | return "QQ"; 33 | case PLATFORM_MESSAGE: 34 | return "ShortMessage"; 35 | case PLATFORM_EMAIL: 36 | return "Email"; 37 | case PLATFORM_MORE_SHARE: 38 | return "More"; 39 | case PLATFORM_WECHATMOMENTS: 40 | return "WechatMoments"; 41 | case PLATFORM_COPYLINK: 42 | return "CopyLink"; 43 | default: 44 | break; 45 | } 46 | return null; 47 | } 48 | 49 | public static BMPlatform getBMPlatformByName(String name){ 50 | if("Wechat".equals(name)){ 51 | return PLATFORM_WECHAT; 52 | }else if("WechatMoments".equals(name)){ 53 | return PLATFORM_WECHATMOMENTS; 54 | }else if("QQ".equals(name)){ 55 | return PLATFORM_QQ; 56 | }else if("QZone".equals(name)){ 57 | return PLATFORM_QZONE; 58 | }else if("TencentWeibo".equals(name)){ 59 | return PLATFORM_TENCENTWEIBO; 60 | }else if("SinaWeibo".equals(name)){ 61 | return PLATFORM_SINAWEIBO; 62 | }else if("Renren".equals(name)){ 63 | return PLATFORM_RENN; 64 | }else if("ShortMessage".equals(name)){ 65 | return PLATFORM_MESSAGE; 66 | }else if("Email".equals(name)){ 67 | return PLATFORM_EMAIL; 68 | }else if("CopyLink".equals(name)){ 69 | return PLATFORM_COPYLINK; 70 | }else if("More".equals(name)){ 71 | return PLATFORM_MORE_SHARE; 72 | }else { 73 | return null; 74 | } 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/data/PlatformKeyInfo.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.data; 2 | 3 | public class PlatformKeyInfo { 4 | 5 | /**新浪微博是否不设置key进行分享*/ 6 | // public static String sinaWeibo_IsNoKeyShare; 7 | /** 新浪微博AppKey */ 8 | public static String sinaWeibo_AppKey = "3282454679"; 9 | /** 新浪微博微博Appsecret */ 10 | public static String sinaWeibo_AppSecret = "dc4ac1d000339ca732a855a6c48ef05b"; 11 | /** 新浪微博Enable属性 */ 12 | public static String sinaWeibo_Enable = "true"; 13 | /** 新浪微博RedirectUrl */ 14 | public static String sinaWeibo_RedirectUrl = "https://openapi.baidu.com/social/oauth/2.0/receiver"; 15 | 16 | /** 微信AppId */ 17 | public static String wechat_AppId = "wx67741810defa3d60"; 18 | /** 微信Enable */ 19 | public static String wechat_Enable = "true"; 20 | /** 微信朋友圈AppId */ 21 | public static String wechatMoments_AppId = "wx67741810defa3d60"; 22 | /** 微信朋友圈Enable */ 23 | public static String WechatMoments_Enable = "true"; 24 | 25 | /** 腾讯微博AppKey */ 26 | public static String tencentWeibo_AppKey = "801260141"; 27 | /** 腾讯微博AppSecret */ 28 | public static String tencentWeibo_AppSecret = "bff578860abf8fcc83b6a3d16e2d14c1"; 29 | /** 腾讯微博Enable */ 30 | public static String tencentWeibo_Enable = "true"; 31 | /** 腾讯微博RedirectUrl */ 32 | public static String tencentWeibo_RedirectUrl = "http://www.google.com.hk"; 33 | 34 | /** qq AppKey */ 35 | public static String qQ_AppKey = "bbcb6eaea7cc7eb70d2befde80c7427e"; 36 | /** qq AppId */ 37 | public static String qQ_AppId = "100442925"; 38 | /** qq Enable */ 39 | public static String qQ_Enable = "true"; 40 | 41 | /** qq空间AppKey */ 42 | public static String qZone_AppKey = "bbcb6eaea7cc7eb70d2befde80c7427e"; 43 | /** qq空间AppId */ 44 | public static String qZone_AppId = "100442925"; 45 | /** qq空间Enable */ 46 | public static String qZone_Enable = "true"; 47 | 48 | /** 人人网AppKey */ 49 | public static String renren_AppKey = "ae6dbf913f4848249f106befe947d69c"; 50 | /** 人人网AppId */ 51 | public static String renren_AppId = "270223"; 52 | /** 人人网Enable */ 53 | public static String renren_Enable = "true"; 54 | /** 人人网SecretKey */ 55 | public static String renren_SecretKey = "2cc93b18e18c46c98b80010028fe0270"; 56 | 57 | /** 腾讯微博在分享列表中的位置 */ 58 | public static int tencentWeiboIndex; 59 | } 60 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/data/ShareData.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.data; 2 | 3 | /** 4 | * 5 | * 分享数据类 6 | * @author 稻草人 7 | * @date 2014年7月18日 下午4:01:05 8 | * 9 | */ 10 | public class ShareData { 11 | /**如果为app分享设置为true,如果为content分享则设置为false 12 | * app分享的内容由开发者预先保留在友推服务器上 13 | * content分享的内容由开发者给ShareData实例的各个字段赋值 14 | **/ 15 | public boolean isAppShare = false; 16 | /**分享的标题*/ 17 | private String title = "分享"; 18 | /**分享的描述*/ 19 | private String description = "描述"; 20 | /**分享的文字*/ 21 | private String text = "分享内容..."; 22 | /**分享的图片的本地路径*/ 23 | private String imagePath; 24 | /**分享的图片的网络url*/ 25 | private String imageUrl; 26 | /**分享的网页链接*/ 27 | private String target_url; 28 | /**是否有活动正在进行*/ 29 | private boolean isInProgress = false; 30 | /**图文分享,该分享类型为默认分享类型,如果开发者未设置,则使用默认分享类型*/ 31 | public static final int SHARETYPE_IMAGEANDTEXT = 0; 32 | public static final int SHARETYPE_IMAGE = 1; 33 | /**用来判断分享的类型*/ 34 | private int shareType = SHARETYPE_IMAGEANDTEXT; 35 | 36 | 37 | public String getTitle() { 38 | return title; 39 | } 40 | public void setTitle(String title) { 41 | this.title = title; 42 | } 43 | public String getDescription() { 44 | return description; 45 | } 46 | public void setDescription(String description) { 47 | this.description = description; 48 | } 49 | public String getText() { 50 | return text; 51 | } 52 | public void setText(String text) { 53 | this.text = text; 54 | } 55 | public String getImagePath() { 56 | return imagePath; 57 | } 58 | public void setImagePath(String imagePath) { 59 | this.imagePath = imagePath; 60 | } 61 | public String getImageUrl() { 62 | return imageUrl; 63 | } 64 | public void setImageUrl(String imageUrl) { 65 | this.imageUrl = imageUrl; 66 | } 67 | public String getTarget_url() { 68 | return target_url; 69 | } 70 | public void setTarget_url(String target_url) { 71 | this.target_url = target_url; 72 | } 73 | public boolean isInProgress() { 74 | return isInProgress; 75 | } 76 | public void setInProgress(boolean isInProgress) { 77 | this.isInProgress = isInProgress; 78 | } 79 | public int getShareType() { 80 | return shareType; 81 | } 82 | public void setShareType(int shareType) { 83 | this.shareType = shareType; 84 | } 85 | public void setIsAppShare(boolean isAppShare) { 86 | this.isAppShare = isAppShare; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/login/AuthActivity.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.login; 2 | 3 | import java.io.IOException; 4 | import java.lang.reflect.Method; 5 | 6 | import org.apache.http.HttpResponse; 7 | import org.apache.http.client.ClientProtocolException; 8 | import org.apache.http.client.HttpClient; 9 | import org.apache.http.client.methods.HttpGet; 10 | import org.apache.http.impl.client.DefaultHttpClient; 11 | import org.apache.http.util.EntityUtils; 12 | import org.json.JSONException; 13 | import org.json.JSONObject; 14 | 15 | import android.app.Activity; 16 | import android.app.AlertDialog; 17 | import android.app.Dialog; 18 | import android.app.ProgressDialog; 19 | import android.content.Context; 20 | import android.content.DialogInterface; 21 | import android.content.Intent; 22 | import android.graphics.Bitmap; 23 | import android.os.Build; 24 | import android.os.Bundle; 25 | import android.os.Handler; 26 | import android.os.Message; 27 | import android.util.DisplayMetrics; 28 | import android.view.View; 29 | import android.view.Window; 30 | import android.view.WindowManager; 31 | import android.webkit.WebChromeClient; 32 | import android.webkit.WebSettings; 33 | import android.webkit.WebView; 34 | import android.webkit.WebViewClient; 35 | import android.widget.LinearLayout; 36 | import android.widget.RelativeLayout; 37 | import android.widget.Toast; 38 | import cn.bmob.social.share.core.data.PlatformKeyInfo; 39 | import cn.bmob.social.share.core.util.AccessTokenKeeper; 40 | import cn.bmob.social.share.core.util.BMLog; 41 | import cn.bmob.social.share.core.util.PlatformAppHelper; 42 | 43 | import com.sina.weibo.sdk.auth.Oauth2AccessToken; 44 | import com.sina.weibo.sdk.auth.WeiboAuth; 45 | import com.sina.weibo.sdk.auth.WeiboAuthListener; 46 | import com.sina.weibo.sdk.auth.sso.SsoHandler; 47 | import com.sina.weibo.sdk.exception.WeiboException; 48 | import com.tencent.connect.UserInfo; 49 | import com.tencent.tauth.IUiListener; 50 | import com.tencent.tauth.Tencent; 51 | import com.tencent.tauth.UiError; 52 | import com.tencent.weibo.sdk.android.api.util.BackGroudSeletor; 53 | import com.tencent.weibo.sdk.android.api.util.Util; 54 | 55 | /** 56 | * 授权登录Activity 57 | * @author youtui 58 | * @since 14/4/26 59 | */ 60 | public final class AuthActivity extends Activity { 61 | /** 新浪accessToken */ 62 | private Oauth2AccessToken oauth2AccessToken; 63 | /** 新浪微博授权类 */ 64 | private WeiboAuth mWeiboAuth; 65 | /** 标示授权的平台 */ 66 | private String flag; 67 | /** 授权网页 */ 68 | private WebView webView; 69 | /** 授权网页状态 */ 70 | public static int WEBVIEWSTATE_1 = 0; 71 | /** 授权网站地址 */ 72 | private String path; 73 | /** a授权提醒diaolog */ 74 | private Dialog _dialog; 75 | /** 让dialog显示加载进度 */ 76 | public static final int PROGRESS_H = 3; 77 | /** 让dialog显示网络连接情况 */ 78 | public static final int ALERT_NETWORK = 4; 79 | /** 获取腾讯微博用户信息 */ 80 | public static final int GET_USERINFO_TENCENTWB = 5; 81 | /** 腾讯微博授权页面布局 */ 82 | private LinearLayout layout = null; 83 | /** 新浪微博授权回调页 */ 84 | private String redirectUri = null; 85 | /** 新浪微博授权id */ 86 | private String clientId = null; 87 | /** 腾讯授权qq类 */ 88 | private Tencent mTencent; 89 | /** 新浪微博sso授权类 */ 90 | private SsoHandler mSsoHandler; 91 | /** 腾讯微博accessToken */ 92 | private String tencentWbAccessToken; 93 | /** 腾讯微博openId */ 94 | private String tencentWbOpenid; 95 | /** 腾讯微博用户名 */ 96 | private String tencentWbname; 97 | /** 授权监听 */ 98 | public static AuthListener authListener; 99 | /**新浪微博授权成功*/ 100 | private static final int SINA_AUTH_SUCCESS = 0; 101 | /** 新浪微博授权失败 */ 102 | private static final int SINA_AUTH_FAIL = 1; 103 | //private static final int SINA_AUTH_CANCLE = 2; 104 | /**QQ授权成功 */ 105 | private static final int QQ_AUTH_SUCCESS = 3; 106 | //private static final int QQ_AUTH_FAIL = 4; 107 | //private static final int QQ_AUTH_CANCEL = 5; 108 | /** 腾讯微博授权成功 */ 109 | private static final int TENCENTWB_AUTH_SUCCESS = 6; 110 | //private static final int TENCENTWB_AUTH_CANCEL = 7; 111 | //private static final int TENCENTWB_FAIL = 8; 112 | /**提醒线程停止sleep*/ 113 | private static final int STOP_SLEEP = 101; 114 | /**处理分享结果*/ 115 | private Handler mHandler = new Handler() { 116 | AuthUserInfo userInfo = new AuthUserInfo(); 117 | 118 | public void handleMessage(Message msg) { 119 | switch (msg.what) { 120 | // 新浪授权成功操作 121 | case SINA_AUTH_SUCCESS: 122 | String str = (String) msg.obj; 123 | 124 | try { 125 | /** 解析获取的用户信息并赋值给保存用户信息的字段 */ 126 | JSONObject sinaJson = new JSONObject(str); 127 | userInfo.setSinaUid(sinaJson.getString("id")); 128 | userInfo.setSinaScreenname(sinaJson.getString("screen_name")); 129 | userInfo.setSinaProfileImageUrl(sinaJson.getString("profile_image_url")); 130 | if (sinaJson.getString("gender").equals("m")) { 131 | userInfo.setSinaGender("男"); 132 | } else { 133 | userInfo.setSinaGender("女"); 134 | } 135 | 136 | userInfo.setSinaName(sinaJson.getString("name")); 137 | cn.bmob.social.share.core.util.Util.showProgressDialog(AuthActivity.this, "加载中...", true); 138 | // 跳转的时候等待2秒 139 | new Thread() { 140 | public void run() { 141 | try { 142 | sleep(1500); 143 | sendEmptyMessage(STOP_SLEEP); 144 | } catch (InterruptedException e) { 145 | e.printStackTrace(); 146 | } 147 | }; 148 | }.start(); 149 | } catch (JSONException e) { 150 | BMLog.e("sinaUesrInfo JSONException : "+((JSONObject) msg.obj).toString()); 151 | if (authListener != null) { 152 | authListener.onAuthFail(AuthActivity.this); 153 | } 154 | e.printStackTrace(); 155 | AuthActivity.this.finish(); 156 | } 157 | break; 158 | // qq授权成功操作 159 | case QQ_AUTH_SUCCESS: 160 | JSONObject json = (JSONObject) msg.obj; 161 | userInfo.setQqOpenid(mTencent.getQQToken().getOpenId()); 162 | try { 163 | userInfo.setQqNickName(json.getString("nickname")); 164 | userInfo.setQqImageUrl(json.getString("figureurl_qq_1")); 165 | userInfo.setQqGender(json.getString("gender")); 166 | new Thread() { 167 | public void run() { 168 | try { 169 | sleep(1500); 170 | sendEmptyMessage(STOP_SLEEP); 171 | } catch (InterruptedException e) { 172 | e.printStackTrace(); 173 | } 174 | }; 175 | }.start(); 176 | } catch (JSONException e) { 177 | BMLog.e("sinaUesrInfo JSONException : "+((JSONObject) msg.obj).toString()); 178 | if (authListener != null) { 179 | authListener.onAuthFail(AuthActivity.this); 180 | } 181 | e.printStackTrace(); 182 | AuthActivity.this.finish(); 183 | } 184 | break; 185 | // 腾讯微博授权成功操作 186 | case TENCENTWB_AUTH_SUCCESS: 187 | JSONObject tencentWbJson = (JSONObject) msg.obj; 188 | try { 189 | userInfo.setTencentWbHead(tencentWbJson.getString("head")); 190 | userInfo.setTencentWbNick(tencentWbJson.getString("nick")); 191 | userInfo.setTencentWbName(tencentWbname); 192 | userInfo.setTencentWbOpenid(tencentWbOpenid); 193 | userInfo.setTencentWbGender(tencentWbJson.getString("sex")); 194 | if (tencentWbJson.getString("sex").equals("1")) { 195 | userInfo.setTencentWbGender("男"); 196 | } else { 197 | userInfo.setTencentWbGender("女"); 198 | } 199 | cn.bmob.social.share.core.util.Util.showProgressDialog(AuthActivity.this, "加载中...", true); 200 | new Thread() { 201 | public void run() { 202 | try { 203 | sleep(2000); 204 | sendEmptyMessage(STOP_SLEEP); 205 | } catch (InterruptedException e) { 206 | e.printStackTrace(); 207 | } 208 | }; 209 | }.start(); 210 | } catch (JSONException e) { 211 | e.printStackTrace(); 212 | AuthActivity.this.finish(); 213 | } 214 | break; 215 | case STOP_SLEEP: 216 | /** 避免用户在授权等待时取消操作造成错误,添加以下判断 */ 217 | if (userInfo != null && authListener != null) { 218 | Toast.makeText(AuthActivity.this, "授权成功", Toast.LENGTH_SHORT).show(); 219 | authListener.onAuthSucess(AuthActivity.this, userInfo); 220 | } else { 221 | Toast.makeText(AuthActivity.this, "授权取消", Toast.LENGTH_SHORT).show(); 222 | } 223 | cn.bmob.social.share.core.util.Util.dismissDialog(); 224 | AuthActivity.this.finish(); 225 | break; 226 | default: 227 | break; 228 | } 229 | }; 230 | }; 231 | 232 | @Override 233 | protected void onCreate(Bundle savedInstanceState) { 234 | requestWindowFeature(Window.FEATURE_NO_TITLE); 235 | super.onCreate(savedInstanceState); 236 | 237 | initData(); 238 | } 239 | 240 | /** 241 | * 判断授权的平台 242 | */ 243 | private void initData() { 244 | flag = getIntent().getExtras().getString("flag"); 245 | if ("sina".equals(flag)) { 246 | mWeiboAuth = new WeiboAuth(this, PlatformKeyInfo.sinaWeibo_AppKey, PlatformKeyInfo.sinaWeibo_RedirectUrl, PlatformAppHelper.SINA_WEIBO_SCOPE); 247 | if (PlatformAppHelper.isSinaWeiboExisted(this)) { 248 | mSsoHandler = new SsoHandler(this, mWeiboAuth); 249 | mSsoHandler.authorize(new SinaAuthListener()); 250 | } else { 251 | mWeiboAuth.anthorize(new SinaAuthListener()); 252 | } 253 | } else if ("tencentWb".equals(flag)) { 254 | initTencentWb(); 255 | } else if ("tencentWbShare".equals(flag)) { 256 | initTencentWb(); 257 | } else if ("qq".equals(flag)) { 258 | initQQ(); 259 | } 260 | } 261 | 262 | @Override 263 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 264 | if (mSsoHandler != null) { 265 | mSsoHandler.authorizeCallBack(requestCode, resultCode, data); 266 | } 267 | super.onActivityResult(requestCode, resultCode, data); 268 | } 269 | 270 | /** 271 | * qq授权 272 | */ 273 | private void initQQ() { 274 | mTencent = Tencent.createInstance(PlatformKeyInfo.qQ_AppId, this); 275 | mTencent.logout(this); 276 | mTencent.login(this, "all", listener); 277 | } 278 | 279 | /** 280 | * qq授权监听 281 | */ 282 | IUiListener listener = new IUiListener() { 283 | 284 | @Override 285 | public void onCancel() { 286 | Toast.makeText(AuthActivity.this, "授权取消", Toast.LENGTH_SHORT).show(); 287 | if (authListener != null) { 288 | authListener.onAuthCancel(AuthActivity.this); 289 | } 290 | AuthActivity.this.finish(); 291 | } 292 | 293 | @Override 294 | public void onComplete(Object obj) { 295 | UserInfo info = new UserInfo(AuthActivity.this, mTencent.getQQToken()); 296 | cn.bmob.social.share.core.util.Util.showProgressDialog(AuthActivity.this, "授权中...", true); 297 | info.getUserInfo(getInfoListener); 298 | } 299 | 300 | @Override 301 | public void onError(UiError arg0) { 302 | Toast.makeText(AuthActivity.this, "授权错误", Toast.LENGTH_SHORT).show(); 303 | if (authListener != null) { 304 | authListener.onAuthFail(AuthActivity.this); 305 | } 306 | AuthActivity.this.finish(); 307 | } 308 | 309 | }; 310 | 311 | /** 312 | * 获取QQ用户信息监听 313 | */ 314 | private IUiListener getInfoListener = new IUiListener() { 315 | 316 | @Override 317 | public void onCancel() { 318 | if (authListener != null) { 319 | authListener.onAuthFail(AuthActivity.this); 320 | } 321 | AuthActivity.this.finish(); 322 | } 323 | 324 | @Override 325 | public void onComplete(Object obj) { 326 | Message msg = Message.obtain(); 327 | msg.what = QQ_AUTH_SUCCESS; 328 | msg.obj = obj; 329 | mHandler.sendMessage(msg); 330 | } 331 | 332 | @Override 333 | public void onError(UiError arg0) { 334 | if (authListener != null) { 335 | authListener.onAuthFail(AuthActivity.this); 336 | } 337 | AuthActivity.this.finish(); 338 | } 339 | 340 | }; 341 | 342 | /** 343 | * 腾讯微博授权 344 | */ 345 | @SuppressWarnings("deprecation") 346 | private void initTencentWb() { 347 | cn.bmob.social.share.core.util.Util.showProgressDialog(this, "加载中...", true); 348 | if (!Util.isNetworkAvailable(this)) { 349 | this.showDialog(ALERT_NETWORK); 350 | } else { 351 | DisplayMetrics displaysMetrics = new DisplayMetrics(); 352 | getWindowManager().getDefaultDisplay().getMetrics(displaysMetrics); 353 | String pix = displaysMetrics.widthPixels + "x" + displaysMetrics.heightPixels; 354 | BackGroudSeletor.setPix(pix); 355 | 356 | try { 357 | clientId = PlatformKeyInfo.tencentWeibo_AppKey; 358 | redirectUri = PlatformKeyInfo.tencentWeibo_RedirectUrl; 359 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 360 | int state = (int) Math.random() * 1000 + 111; 361 | path = "https://open.t.qq.com/cgi-bin/oauth2/authorize?client_id=" + clientId + "&response_type=token&redirect_uri=" + redirectUri + "&state=" + state; 362 | this.initLayout(); 363 | } catch (Exception e) { 364 | e.printStackTrace(); 365 | } 366 | } 367 | } 368 | 369 | /** 370 | * 初始化腾讯微博授权界面,并设置相应监听 371 | * */ 372 | @SuppressWarnings("deprecation") 373 | public void initLayout() { 374 | RelativeLayout.LayoutParams fillParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); 375 | 376 | layout = new LinearLayout(this); 377 | layout.setLayoutParams(fillParams); 378 | layout.setOrientation(LinearLayout.VERTICAL); 379 | webView = new WebView(this); 380 | 381 | if (Build.VERSION.SDK_INT >= 11) { 382 | Class[] name = new Class[] { String.class }; 383 | Object[] rmMethodName = new Object[] { "searchBoxJavaBridge_" }; 384 | Method rji; 385 | try { 386 | rji = webView.getClass().getDeclaredMethod("removeJavascriptInterface", name); 387 | rji.invoke(webView, rmMethodName); 388 | } catch (Exception e) { 389 | e.printStackTrace(); 390 | } 391 | } 392 | webView.setLayoutParams(fillParams); 393 | WebSettings webSettings = webView.getSettings(); 394 | webView.setVerticalScrollBarEnabled(false); 395 | webSettings.setJavaScriptEnabled(true); 396 | webSettings.setUseWideViewPort(true); 397 | webSettings.setLoadWithOverviewMode(false); 398 | webView.loadUrl(path); 399 | webView.setWebChromeClient(new WebChromeClient() { 400 | 401 | @Override 402 | public void onProgressChanged(WebView view, int newProgress) { 403 | super.onProgressChanged(view, newProgress); 404 | if (newProgress >= 90) { 405 | cn.bmob.social.share.core.util.Util.dismissDialog(); 406 | } 407 | } 408 | 409 | }); 410 | webView.setWebViewClient(new WebViewClient() { 411 | @Override 412 | public boolean shouldOverrideUrlLoading(WebView view, String url) { 413 | if (url.indexOf("access_token") != -1) { 414 | jumpResultParser(url); 415 | webView.setVisibility(View.INVISIBLE); 416 | webView.destroy(); 417 | } 418 | return false; 419 | } 420 | 421 | @Override 422 | public void onPageStarted(WebView view, String url, Bitmap favicon) { 423 | 424 | if (url.indexOf("access_token") != -1) { 425 | jumpResultParser(url); 426 | webView.setVisibility(View.INVISIBLE); 427 | webView.destroy(); 428 | } 429 | super.onPageStarted(view, url, favicon); 430 | } 431 | 432 | @Override 433 | public void onPageFinished(WebView view, String url) { 434 | if (url.indexOf("access_token") != -1) { 435 | jumpResultParser(url); 436 | webView.setVisibility(View.INVISIBLE); 437 | webView.destroy(); 438 | } 439 | super.onPageFinished(view, url); 440 | } 441 | }); 442 | layout.addView(webView); 443 | this.setContentView(layout); 444 | } 445 | 446 | /** 447 | * 获取腾讯微博授权后的返回地址,并对其进行解析 448 | */ 449 | public void jumpResultParser(String result) { 450 | 451 | String resultParam = result.split("#")[1]; 452 | String params[] = resultParam.split("&"); 453 | String accessToken = params[0].split("=")[1]; 454 | String expiresIn = params[1].split("=")[1]; 455 | String openid = params[2].split("=")[1]; 456 | String openkey = params[3].split("=")[1]; 457 | String refreshToken = params[4].split("=")[1]; 458 | String state = params[5].split("=")[1]; 459 | String name = params[6].split("=")[1]; 460 | String nick = params[7].split("=")[1]; 461 | Context context = this.getApplicationContext(); 462 | if (accessToken != null && !"".equals(accessToken)) { 463 | Util.saveSharePersistent(context, "ACCESS_TOKEN", accessToken); 464 | tencentWbAccessToken = accessToken; 465 | Util.saveSharePersistent(context, "EXPIRES_IN", expiresIn); 466 | Util.saveSharePersistent(context, "OPEN_ID", openid); 467 | tencentWbOpenid = openid; 468 | Util.saveSharePersistent(context, "OPEN_KEY", openkey); 469 | Util.saveSharePersistent(context, "REFRESH_TOKEN", refreshToken); 470 | Util.saveSharePersistent(context, "NAME", name); 471 | tencentWbname = name; 472 | Util.saveSharePersistent(context, "NICK", nick); 473 | Util.saveSharePersistent(context, "CLIENT_ID", clientId); 474 | Util.saveSharePersistent(context, "AUTHORIZETIME", String.valueOf(System.currentTimeMillis() / 1000l)); 475 | if ("tencentWb".equals(flag)) { 476 | handle.sendEmptyMessage(GET_USERINFO_TENCENTWB); 477 | } 478 | } else { 479 | if (authListener != null) { 480 | authListener.onAuthFail(AuthActivity.this); 481 | } 482 | AuthActivity.this.finish(); 483 | } 484 | } 485 | 486 | Handler handle = new Handler() { 487 | @SuppressWarnings("deprecation") 488 | @Override 489 | public void handleMessage(Message msg) { 490 | super.handleMessage(msg); 491 | switch (msg.what) { 492 | case 100: 493 | AuthActivity.this.showDialog(ALERT_NETWORK); 494 | break; 495 | case GET_USERINFO_TENCENTWB: 496 | // 获取腾讯微博的用户信息 497 | new Thread() { 498 | public void run() { 499 | String url = "http://open.t.qq.com/api/user/info?format=json" + "&openid=" + tencentWbOpenid + "&oauth_consumer_key=" + PlatformKeyInfo.tencentWeibo_AppKey + "&access_token=" + tencentWbAccessToken + "&clientip=" + Util.getLocalIPAddress(AuthActivity.this) + "&oauth_version=2.a&scope=" + PlatformAppHelper.TENCENT_SCOPE; 500 | HttpClient client = new DefaultHttpClient(); 501 | HttpGet get = new HttpGet(url); 502 | try { 503 | 504 | HttpResponse resp = client.execute(get); 505 | String str = EntityUtils.toString(resp.getEntity()); 506 | JSONObject respJson = new JSONObject(str); 507 | if (Integer.valueOf(respJson.getString("ret")) != 0) { 508 | } else { 509 | JSONObject dataJson = respJson.getJSONObject("data"); 510 | Message msg = Message.obtain(); 511 | msg.what = TENCENTWB_AUTH_SUCCESS; 512 | msg.obj = dataJson; 513 | mHandler.sendMessage(msg); 514 | } 515 | } catch (ClientProtocolException e) { 516 | e.printStackTrace(); 517 | if (authListener != null) { 518 | authListener.onAuthFail(AuthActivity.this); 519 | } 520 | } catch (IOException e) { 521 | e.printStackTrace(); 522 | if (authListener != null) { 523 | authListener.onAuthFail(AuthActivity.this); 524 | } 525 | } catch (JSONException e) { 526 | e.printStackTrace(); 527 | if (authListener != null) { 528 | authListener.onAuthFail(AuthActivity.this); 529 | } 530 | } 531 | }; 532 | }.start(); 533 | break; 534 | default: 535 | break; 536 | } 537 | } 538 | }; 539 | 540 | /** 541 | * 腾讯微博授权提醒对话框 542 | */ 543 | @Override 544 | protected Dialog onCreateDialog(int id) { 545 | switch (id) { 546 | 547 | case PROGRESS_H: 548 | _dialog = new ProgressDialog(this); 549 | ((ProgressDialog) _dialog).setMessage("加载中..."); 550 | break; 551 | case ALERT_NETWORK: 552 | AlertDialog.Builder builder2 = new AlertDialog.Builder(this); 553 | builder2.setTitle("网络连接异常,是否重新连接?"); 554 | builder2.setPositiveButton("是", new DialogInterface.OnClickListener() { 555 | @Override 556 | public void onClick(DialogInterface dialog, int which) { 557 | if (Util.isNetworkAvailable(AuthActivity.this)) { 558 | webView.loadUrl(path); 559 | } else { 560 | Message msg = Message.obtain(); 561 | msg.what = 100; 562 | handle.sendMessage(msg); 563 | } 564 | } 565 | 566 | }); 567 | builder2.setNegativeButton("否", new DialogInterface.OnClickListener() { 568 | @Override 569 | public void onClick(DialogInterface dialog, int which) { 570 | AuthActivity.this.finish(); 571 | } 572 | }); 573 | _dialog = builder2.create(); 574 | break; 575 | } 576 | return _dialog; 577 | } 578 | 579 | /** 580 | * @author gaopan 新浪微博授权监听 581 | */ 582 | class SinaAuthListener implements WeiboAuthListener { 583 | @Override 584 | public void onCancel() { 585 | Toast.makeText(AuthActivity.this, "授权取消", Toast.LENGTH_SHORT).show(); 586 | if (authListener != null) { 587 | authListener.onAuthCancel(AuthActivity.this); 588 | } 589 | AuthActivity.this.finish(); 590 | } 591 | 592 | @Override 593 | public void onComplete(Bundle bundle) { 594 | 595 | oauth2AccessToken = Oauth2AccessToken.parseAccessToken(bundle); 596 | if (oauth2AccessToken.isSessionValid()) { 597 | AccessTokenKeeper.writeAccessToken(AuthActivity.this, oauth2AccessToken); 598 | } 599 | 600 | /** 获取新浪微博用户信息 */ 601 | new Thread() { 602 | public void run() { 603 | HttpClient client = new DefaultHttpClient(); 604 | String url = "https://api.weibo.com/2/users/show.json"; 605 | url += "?" + "access_token=" + oauth2AccessToken.getToken(); 606 | url += "&" + "uid=" + oauth2AccessToken.getUid(); 607 | HttpGet get = new HttpGet(url); 608 | try { 609 | HttpResponse resp = client.execute(get); 610 | String str = EntityUtils.toString(resp.getEntity()); 611 | Message msg = Message.obtain(); 612 | msg.what = SINA_AUTH_SUCCESS; 613 | msg.obj = str; 614 | mHandler.sendMessage(msg); 615 | } catch (ClientProtocolException e) { 616 | mHandler.sendEmptyMessage(SINA_AUTH_FAIL); 617 | e.printStackTrace(); 618 | } catch (IOException e) { 619 | mHandler.sendEmptyMessage(SINA_AUTH_FAIL); 620 | e.printStackTrace(); 621 | } 622 | }; 623 | }.start(); 624 | 625 | } 626 | 627 | @Override 628 | public void onWeiboException(WeiboException arg0) { 629 | Toast.makeText(AuthActivity.this, "授权错误", Toast.LENGTH_SHORT).show(); 630 | if (authListener != null) { 631 | authListener.onAuthFail(AuthActivity.this); 632 | } 633 | AuthActivity.this.finish(); 634 | } 635 | } 636 | 637 | @Override 638 | protected void onDestroy() { 639 | cn.bmob.social.share.core.util.Util.dismissDialog(); 640 | authListener = null; 641 | super.onDestroy(); 642 | } 643 | 644 | } 645 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/login/AuthListener.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.login; 2 | 3 | import android.app.Activity; 4 | 5 | /** 6 | * 第三方登录回调需要实现该接口 7 | * @author youtui 8 | * @since 14/5/19 9 | */ 10 | public interface AuthListener { 11 | /**授权成功*/ 12 | public abstract void onAuthSucess(Activity act, AuthUserInfo userInfo); 13 | /**授权失败*/ 14 | public abstract void onAuthFail(Activity act); 15 | /**授权取消*/ 16 | public abstract void onAuthCancel(Activity act); 17 | } -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/login/AuthLogin.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.login; 2 | 3 | import cn.bmob.social.share.core.util.Util; 4 | import android.app.Activity; 5 | import android.content.Intent; 6 | import android.widget.Toast; 7 | 8 | /** 9 | * 授权登录 10 | * @author youtui 11 | * @since 14/6/19 12 | */ 13 | public class AuthLogin { 14 | /** 15 | * 新浪授权登录 16 | * @param act 17 | */ 18 | public void sinaAuth(Activity act,AuthListener listener) { 19 | if (Util.isNetworkConnected(act)) { 20 | Intent sinaLogin = new Intent(act, AuthActivity.class); 21 | sinaLogin.putExtra("flag", "sina"); 22 | AuthActivity.authListener = listener; 23 | act.startActivity(sinaLogin); 24 | } else { 25 | Toast.makeText(act, "无网络连接...", Toast.LENGTH_SHORT).show(); 26 | } 27 | } 28 | 29 | /** 30 | * qq授权登录 31 | * @param act 32 | */ 33 | public void qqAuth(Activity act,AuthListener listener) { 34 | if (Util.isNetworkConnected(act)) { 35 | Intent qqLogin = new Intent(act, AuthActivity.class); 36 | qqLogin.putExtra("flag", "qq"); 37 | AuthActivity.authListener = listener; 38 | act.startActivity(qqLogin); 39 | 40 | } else { 41 | Toast.makeText(act, "无网络连接...", Toast.LENGTH_SHORT).show(); 42 | } 43 | 44 | } 45 | 46 | /** 47 | * 腾讯微博授权登录 48 | * @param act 49 | */ 50 | 51 | public void tencentWbAuth(Activity act,AuthListener listener) { 52 | if (Util.isNetworkConnected(act)) { 53 | Intent tencentWbLogin = new Intent(act, AuthActivity.class); 54 | tencentWbLogin.putExtra("flag", "tencentWb"); 55 | AuthActivity.authListener = listener; 56 | act.startActivity(tencentWbLogin); 57 | } else { 58 | Toast.makeText(act, "无网络连接...", Toast.LENGTH_SHORT).show(); 59 | } 60 | 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/login/AuthUserInfo.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.login; 2 | /** 3 | * 该类保存授权用户信息,用于第三方登录 4 | * @author youtui 5 | * @since 14/5/19 6 | */ 7 | public class AuthUserInfo { 8 | /**新浪微博用户id*/ 9 | private String sinaUid; 10 | /**新浪微博用户昵称*/ 11 | private String sinaScreenname; 12 | /**新浪微博用户头像url*/ 13 | private String sinaProfileImageUrl; 14 | /**新浪微博用户性别*/ 15 | private String sinaGender; 16 | /**新浪微博用户名*/ 17 | private String sinaName; 18 | /**qq用户性别*/ 19 | private String qqGender; 20 | /**qq用户头像url*/ 21 | private String qqImageUrl; 22 | /**qq用户名*/ 23 | private String qqNickName; 24 | /**qq用户openid*/ 25 | private String qqOpenid; 26 | /**腾讯微博用户名*/ 27 | private String tencentWbName; 28 | /**腾讯微博用户昵称*/ 29 | private String tencentWbNick; 30 | /**腾讯微博用户openid*/ 31 | private String tencentWbOpenid; 32 | /**腾讯微博用户头像url*/ 33 | private String tencentWbHead; 34 | /**腾讯微博用户性别*/ 35 | private String tencentWbGender; 36 | /***/ 37 | public String getQqGender() { 38 | return qqGender; 39 | } 40 | /**设置qq用户性别*/ 41 | public void setQqGender(String qqGender) { 42 | this.qqGender = qqGender; 43 | } 44 | /**获得qq用户头像url*/ 45 | public String getQqImageUrl() { 46 | return qqImageUrl; 47 | } 48 | /**设置qq用户头像url*/ 49 | public void setQqImageUrl(String qqImageUrl) { 50 | this.qqImageUrl = qqImageUrl; 51 | } 52 | /**获取qq用户昵称*/ 53 | public String getQqNickName() { 54 | return qqNickName; 55 | } 56 | /**设置qq用户昵称*/ 57 | public void setQqNickName(String qqNickName) { 58 | this.qqNickName = qqNickName; 59 | } 60 | /**获得qq openid*/ 61 | public String getQqOpenid() { 62 | return qqOpenid; 63 | } 64 | /**设置qq openid*/ 65 | public void setQqOpenid(String qqOpenid) { 66 | this.qqOpenid = qqOpenid; 67 | } 68 | /**获取腾讯微博用户名*/ 69 | public String getTencentWbName() { 70 | return tencentWbName; 71 | } 72 | /**设置腾讯微博用户名*/ 73 | public void setTencentWbName(String tencentWbName) { 74 | this.tencentWbName = tencentWbName; 75 | } 76 | /**获得腾讯微博用户昵称*/ 77 | public String getTencentWbNick() { 78 | return tencentWbNick; 79 | } 80 | /**设置腾讯微博用户昵称*/ 81 | public void setTencentWbNick(String tencentWbNick) { 82 | this.tencentWbNick = tencentWbNick; 83 | } 84 | /**获得腾讯微博openid*/ 85 | public String getTencentWbOpenid() { 86 | return tencentWbOpenid; 87 | } 88 | /**设置腾讯微博openid*/ 89 | public void setTencentWbOpenid(String tencentWbOpenid) { 90 | this.tencentWbOpenid = tencentWbOpenid; 91 | } 92 | /**获取腾讯微博用户头像url*/ 93 | public String getTencentWbHead() { 94 | return tencentWbHead; 95 | } 96 | /**设置腾讯微博用户头像url*/ 97 | public void setTencentWbHead(String tencentWbHead) { 98 | this.tencentWbHead = tencentWbHead; 99 | } 100 | /**获取新浪微博用户Id*/ 101 | public String getSinaUid() { 102 | return sinaUid; 103 | } 104 | /**设置新浪微博用户id*/ 105 | public void setSinaUid(String sinaUid) { 106 | this.sinaUid = sinaUid; 107 | } 108 | /**获得新浪微博用户昵称*/ 109 | public String getSinaScreenname() { 110 | return sinaScreenname; 111 | } 112 | /**设置新浪微博用户昵称*/ 113 | public void setSinaScreenname(String sinaScreenname) { 114 | this.sinaScreenname = sinaScreenname; 115 | } 116 | /**获得新浪微博用户头像url*/ 117 | public String getSinaProfileImageUrl() { 118 | return sinaProfileImageUrl; 119 | } 120 | /**设置新浪微博用户头像url*/ 121 | public void setSinaProfileImageUrl(String sinaProfileImageUrl) { 122 | this.sinaProfileImageUrl = sinaProfileImageUrl; 123 | } 124 | /**获得新浪微博用户性别*/ 125 | public String getSinaGender() { 126 | return sinaGender; 127 | } 128 | /**设置新浪微博用户性别*/ 129 | public void setSinaGender(String sinaGender) { 130 | this.sinaGender = sinaGender; 131 | } 132 | /**获得新浪微博用户名*/ 133 | public String getSinaName() { 134 | return sinaName; 135 | } 136 | /**设置新浪微博用户名*/ 137 | public void setSinaName(String sinaName) { 138 | this.sinaName = sinaName; 139 | } 140 | /**获得腾讯微博用户性别*/ 141 | public String getTencentWbGender() { 142 | return tencentWbGender; 143 | } 144 | /**设置腾讯微博用户性别*/ 145 | public void setTencentWbGender(String tencentWbGender) { 146 | this.tencentWbGender = tencentWbGender; 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/social/OtherShare.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.social; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | 7 | /** 8 | * 9 | * 邮件和短信分享功能的实现 10 | * @author 稻草人 11 | * @date 2014年7月21日 上午10:27:48 12 | * 13 | */ 14 | public class OtherShare { 15 | private Activity act; 16 | 17 | public OtherShare(Activity act) { 18 | this.act = act; 19 | } 20 | /** 21 | * 分享到短信 22 | * @param sms_body 23 | */ 24 | public void sendSMS(String sms_body) { 25 | Uri smsToUri = Uri.parse("smsto:"); 26 | Intent sendIntent = new Intent(Intent.ACTION_SENDTO, smsToUri); 27 | sendIntent.putExtra("sms_body", sms_body); 28 | // sendIntent.setType("vnd.android-dir/mms-sms"); 29 | act.startActivityForResult(sendIntent, 1002); 30 | } 31 | 32 | /** 33 | * 分享到Email 34 | * @param emailBody 35 | */ 36 | public void sendMail(String emailBody) { 37 | Intent email = new Intent(android.content.Intent.ACTION_SEND); 38 | email.setType("plain/text"); 39 | String emailSubject = "共享软件"; 40 | // 设置邮件默认地址 41 | // email.putExtra(android.content.Intent.EXTRA_EMAIL, emailReciver); 42 | // 设置邮件默认标题 43 | email.putExtra(android.content.Intent.EXTRA_SUBJECT, emailSubject); 44 | // 设置要默认发送的内容 45 | email.putExtra(android.content.Intent.EXTRA_TEXT, emailBody); 46 | // 调用系统的邮件系统 47 | act.startActivityForResult(Intent.createChooser(email, "请选择邮件发送软件"), 1001); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/social/QQOpenShare.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.social; 2 | 3 | import java.util.ArrayList; 4 | 5 | import org.json.JSONException; 6 | import org.json.JSONObject; 7 | 8 | import android.app.Activity; 9 | import android.content.SharedPreferences; 10 | import android.content.SharedPreferences.Editor; 11 | import android.content.pm.ApplicationInfo; 12 | import android.content.pm.PackageManager.NameNotFoundException; 13 | import android.os.Bundle; 14 | import android.widget.Toast; 15 | import cn.bmob.social.share.core.BMShareListener; 16 | import cn.bmob.social.share.core.ErrorInfo; 17 | import cn.bmob.social.share.core.data.PlatformKeyInfo; 18 | import cn.bmob.social.share.core.data.ShareData; 19 | 20 | import com.tencent.connect.share.QQShare; 21 | import com.tencent.tauth.IUiListener; 22 | import com.tencent.tauth.Tencent; 23 | import com.tencent.tauth.UiError; 24 | 25 | /** 26 | * 该类实现QQ,QZone分享和回调 27 | * @author youtui 28 | * @since 14/6/19 29 | */ 30 | public class QQOpenShare { 31 | /**传入的activity*/ 32 | private Activity act; 33 | /**qq分享类*/ 34 | private Tencent mTencent; 35 | /**判断是qq分享还是qq空间分享*/ 36 | private String flag; 37 | /**真实网址*/ 38 | private String realUrl; 39 | /**短链接*/ 40 | private String shortUrl; 41 | /**分享监听*/ 42 | private BMShareListener listener; 43 | /**待分享数据*/ 44 | private ShareData shareData; 45 | 46 | public QQOpenShare(Activity act, String flag,BMShareListener listener,ShareData shareData) { 47 | this.act = act; 48 | this.flag = flag; 49 | this.listener = listener; 50 | this.shareData = shareData; 51 | init(act); 52 | 53 | } 54 | 55 | /** 56 | * 初始化,如果没有授权则进行登录授权 57 | */ 58 | private void init(Activity act) { 59 | if(shareData!=null&&!shareData.isAppShare){ 60 | realUrl = act.getIntent().getExtras().getString("realUrl"); 61 | shortUrl = act.getIntent().getExtras().getString("shortUrl"); 62 | } 63 | 64 | if ("QQ".equals(flag)) { 65 | mTencent = Tencent.createInstance(PlatformKeyInfo.qQ_AppId, act); 66 | } else if ("Qzone".equals(flag)) { 67 | mTencent = Tencent.createInstance(PlatformKeyInfo.qZone_AppId, act); 68 | } 69 | } 70 | 71 | /** 72 | * 分享到qq 73 | */ 74 | public void shareToQQ() { 75 | if(shareData!=null){ 76 | Bundle params = new Bundle(); 77 | params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_DEFAULT); 78 | params.putString(QQShare.SHARE_TO_QQ_TARGET_URL,shareData.getTarget_url()); 79 | // 判断传输的是网络图片还是本地图片 80 | if (shareData.getImagePath() != null) { 81 | params.putString(QQShare.SHARE_TO_QQ_IMAGE_LOCAL_URL,shareData.getImagePath()); 82 | } else if (shareData.getImageUrl() != null) { 83 | params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL,shareData.getImageUrl()); 84 | } else { 85 | // 本地和网络图片都为空时 86 | } 87 | 88 | ApplicationInfo info = null; 89 | try { 90 | info = act.getPackageManager().getApplicationInfo(act.getPackageName(), 0); 91 | } catch (NameNotFoundException e) { 92 | e.printStackTrace(); 93 | } 94 | String appName = (String) act.getPackageManager().getApplicationLabel(info); 95 | params.putString(QQShare.SHARE_TO_QQ_APP_NAME, appName); 96 | params.putString(QQShare.SHARE_TO_QQ_TITLE, shareData.getTitle()); 97 | params.putString(QQShare.SHARE_TO_QQ_SUMMARY, shareData.getText()); 98 | params.putInt(QQShare.SHARE_TO_QQ_EXT_INT, 0); 99 | mTencent.shareToQQ(act, params, new MyQQShareUIListener()); 100 | } 101 | 102 | } 103 | 104 | /** 105 | * 分享到qq空间 106 | */ 107 | public void shareToQzone() { 108 | if(shareData!=null){ 109 | Bundle params = new Bundle(); 110 | params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_DEFAULT); 111 | 112 | params.putString(QQShare.SHARE_TO_QQ_TITLE, shareData.getTitle()); 113 | params.putString(QQShare.SHARE_TO_QQ_SUMMARY, shareData.getText()); 114 | 115 | params.putString(QQShare.SHARE_TO_QQ_TARGET_URL, shareData.getTarget_url()); 116 | 117 | ArrayList list = new ArrayList(); 118 | // 判断传输的是网络图片还是本地图片 119 | if (shareData.getImagePath() != null) { 120 | list.add(shareData.getImagePath()); 121 | } else if (shareData.getImageUrl() != null) { 122 | list.add(shareData.getImageUrl()); 123 | } else { 124 | 125 | } 126 | 127 | params.putStringArrayList(QQShare.SHARE_TO_QQ_IMAGE_URL, list); 128 | 129 | mTencent.shareToQzone(act, params, new MyQQShareUIListener()); 130 | } 131 | } 132 | 133 | /** 134 | * 分享回调 135 | */ 136 | class MyQQShareUIListener implements IUiListener { 137 | 138 | @Override 139 | public void onCancel() { 140 | if(listener!=null){ 141 | listener.onCancel(); 142 | } 143 | act.finish(); 144 | } 145 | 146 | @Override 147 | public void onComplete(Object arg0) { 148 | // 分享完成后的回调处理 149 | if ("QQ".equals(flag)) { 150 | if(listener!=null){ 151 | ErrorInfo error = new ErrorInfo(); 152 | JSONObject json = (JSONObject) arg0; 153 | String errorMessage = json.toString(); 154 | error.setErrorMessage(errorMessage); 155 | listener.onSuccess(); 156 | } 157 | } else if ("Qzone".equals(flag)) { 158 | if(listener!=null){ 159 | ErrorInfo error = new ErrorInfo(); 160 | JSONObject json = (JSONObject) arg0; 161 | String errorMessage = json.toString(); 162 | error.setErrorMessage(errorMessage); 163 | listener.onSuccess(); 164 | } 165 | } 166 | act.finish(); 167 | } 168 | 169 | @Override 170 | public void onError(UiError arg0) { 171 | 172 | if(listener!=null){ 173 | ErrorInfo error = new ErrorInfo(); 174 | String errorMessage = arg0.errorMessage; 175 | error.setErrorMessage(errorMessage); 176 | listener.onError(error); 177 | } 178 | act.finish(); 179 | } 180 | 181 | } 182 | 183 | /** 184 | * 授权回调 185 | */ 186 | 187 | class MyQQAuthUIListener implements IUiListener { 188 | 189 | @Override 190 | public void onCancel() { 191 | Toast.makeText(act, "授权取消", Toast.LENGTH_SHORT).show(); 192 | act.finish(); 193 | } 194 | 195 | @Override 196 | public void onComplete(Object object) { 197 | Toast.makeText(act, "授权成功", Toast.LENGTH_SHORT).show(); 198 | // 将access_token信息写入SharedPreferences中 199 | SharedPreferences sp = act.getSharedPreferences("tencent_open_access", 0); 200 | Editor edit = sp.edit(); 201 | JSONObject json = (JSONObject) object; 202 | 203 | try { 204 | edit.putString("openid", json.getString("openid")); 205 | edit.putString("access_token", json.getString("access_token")); 206 | edit.putString("expires_in", System.currentTimeMillis() + Long.parseLong(json.getString("expires_in")) + ""); 207 | edit.commit(); 208 | } catch (JSONException e) { 209 | e.printStackTrace(); 210 | } 211 | act.finish(); 212 | } 213 | 214 | @Override 215 | public void onError(UiError arg0) { 216 | Toast.makeText(act, "授权错误", Toast.LENGTH_SHORT).show(); 217 | act.finish(); 218 | } 219 | 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/social/RennShare.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.social; 2 | 3 | import java.io.File; 4 | import java.io.FileNotFoundException; 5 | import java.io.IOException; 6 | 7 | import org.apache.commons.httpclient.HttpClient; 8 | import org.apache.commons.httpclient.HttpException; 9 | import org.apache.commons.httpclient.methods.PostMethod; 10 | import org.apache.commons.httpclient.methods.multipart.FilePart; 11 | import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity; 12 | import org.apache.commons.httpclient.methods.multipart.Part; 13 | import org.apache.commons.httpclient.methods.multipart.StringPart; 14 | 15 | import android.app.Activity; 16 | import android.os.Handler; 17 | import android.os.Message; 18 | import android.text.TextUtils; 19 | import android.widget.Toast; 20 | import cn.bmob.social.share.core.BMShareListener; 21 | import cn.bmob.social.share.core.activity.ShareActivity; 22 | import cn.bmob.social.share.core.data.PlatformKeyInfo; 23 | import cn.bmob.social.share.core.data.ShareData; 24 | import cn.bmob.social.share.core.util.PlatformAppHelper; 25 | import cn.bmob.social.share.core.util.Util; 26 | 27 | import com.renn.rennsdk.RennClient; 28 | import com.renn.rennsdk.RennClient.LoginListener; 29 | import com.renn.rennsdk.RennExecutor.CallBack; 30 | import com.renn.rennsdk.RennResponse; 31 | import com.renn.rennsdk.exception.RennException; 32 | import com.renn.rennsdk.param.PutFeedParam; 33 | 34 | /** 35 | * 人人分享和回调 36 | * @author youtui 37 | * @since 14/6/19 38 | */ 39 | public class RennShare { 40 | /**传入的activity*/ 41 | private Activity act; 42 | /**人人分享接口*/ 43 | private RennClient client; 44 | /**传入的Handler,用于人人分享结果监听*/ 45 | private Handler handler; 46 | /**待分享数据*/ 47 | private ShareData shareData; 48 | 49 | public RennShare(Activity act,Handler handler,BMShareListener listener,ShareData shareData) { 50 | this.act = act; 51 | this.handler = handler; 52 | this.shareData = shareData; 53 | } 54 | 55 | /** 56 | * 分享到人人 57 | * 58 | * @throws IOException 59 | * @throws HttpException 60 | */ 61 | 62 | public void shareToRenn() { 63 | client = RennClient.getInstance(act); 64 | client.init(PlatformKeyInfo.renren_AppId, PlatformKeyInfo.renren_AppKey, PlatformKeyInfo.renren_SecretKey); 65 | 66 | client.setScope(PlatformAppHelper.RENREN_SCOPE); 67 | client.setLoginListener(new RennLoginListener()); 68 | 69 | if (!client.isLogin()) { 70 | client.login(act); 71 | return; 72 | } 73 | doShare(); 74 | } 75 | /** 76 | * 分享到人人,分享文字过多时进行剪裁 77 | */ 78 | private void doShare() { 79 | String text = shareData.getText(); 80 | 81 | if(text.length()>110){ 82 | text = text.substring(0, 109); 83 | text += "..."; 84 | } 85 | 86 | text += shareData.getTarget_url(); 87 | 88 | if(TextUtils.isEmpty(shareData.getImagePath())){ 89 | try { 90 | test(); 91 | } catch (RennException e) { 92 | // TODO Auto-generated catch block 93 | e.printStackTrace(); 94 | } 95 | }else { 96 | doRennShare(text, client); 97 | } 98 | } 99 | 100 | private void test() throws RennException{ 101 | PutFeedParam param = new PutFeedParam(); 102 | param.setTitle(shareData.getTitle()); 103 | param.setMessage(shareData.getText()); 104 | param.setDescription(shareData.getDescription()); 105 | param.setTargetUrl("http://www.56.com/u72/v_OTAyNTkxMDk.html"); 106 | 107 | client.getRennService().sendAsynRequest(param, new CallBack() { 108 | @Override 109 | public void onSuccess(RennResponse response){ 110 | // TODO Auto-generated method stub 111 | Message successMsg = Message.obtain(handler, ShareActivity.RENN_SHARE_SUCCESS, response.toString()); 112 | handler.sendMessage(successMsg); 113 | } 114 | @Override 115 | public void onFailed(String errorCode, String errorMessage) { 116 | // TODO Auto-generated method stub 117 | Message msg = Message.obtain(); 118 | msg.what=ShareActivity.RENN_SHARE_ERROR; 119 | msg.obj = errorMessage; 120 | handler.sendMessage(msg); 121 | } 122 | 123 | }); 124 | } 125 | 126 | 127 | /** 128 | * 分享到人人操作 129 | * @param text 130 | * @param client 131 | */ 132 | private void doRennShare(final String text, final RennClient client) { 133 | new Thread() { 134 | public void run() { 135 | try { 136 | PostMethod post = new PostMethod("https://api.renren.com/v2/photo/upload"); 137 | //设置图片描述 138 | StringPart description = new StringPart("description",text,"utf-8"); 139 | //设置access_token 140 | StringPart access_token = new StringPart("access_token", client.getAccessToken().accessToken,"utf-8"); 141 | File file = null; 142 | FilePart filePart = null; 143 | if (shareData.getImagePath() != null) { 144 | file = new File(shareData.getImagePath()); 145 | //设置图片 146 | filePart = new FilePart("file", file); 147 | 148 | } 149 | HttpClient httpClient = new HttpClient(); 150 | Part[] parts = { description, filePart, access_token }; 151 | MultipartRequestEntity mulEntity = new MultipartRequestEntity(parts, post.getParams()); 152 | 153 | post.setRequestEntity(mulEntity); 154 | httpClient.executeMethod(post); 155 | Message msg = Message.obtain(); 156 | String respJson = post.getResponseBodyAsString(); 157 | if(respJson.startsWith("{\"response\"")){ 158 | Message successMsg = Message.obtain(handler, ShareActivity.RENN_SHARE_SUCCESS, respJson); 159 | handler.sendMessage(successMsg); 160 | }else if(respJson.startsWith("{\"error\"")){ 161 | 162 | //发动到UI线程处理 163 | msg.what=ShareActivity.RENN_SHARE_ERROR; 164 | msg.obj = post.getResponseBodyAsString(); 165 | handler.sendMessage(msg); 166 | } 167 | //Log.i("--rennShare http--", post.getResponseBodyAsString()); 168 | 169 | } catch (FileNotFoundException e) { 170 | handler.sendEmptyMessage(ShareActivity.RENN_PIC_NOTFOUND); 171 | Util.dismissDialog(); 172 | e.printStackTrace(); 173 | } catch (HttpException e) { 174 | handler.sendEmptyMessage(ShareActivity.RENN_HTTP_ERROR); 175 | e.printStackTrace(); 176 | } catch (IOException e) { 177 | handler.sendEmptyMessage(ShareActivity.RENN_HTTP_ERROR); 178 | e.printStackTrace(); 179 | } 180 | }; 181 | 182 | }.start(); 183 | } 184 | /** 185 | * 登录回调 186 | * 187 | */ 188 | class RennLoginListener implements LoginListener { 189 | 190 | @Override 191 | public void onLoginCanceled() { 192 | Toast.makeText(act, "登录取消", Toast.LENGTH_SHORT).show(); 193 | act.finish(); 194 | } 195 | 196 | @Override 197 | public void onLoginSuccess() { 198 | Toast.makeText(act, "登录成功,请再点击进行分享", Toast.LENGTH_SHORT).show(); 199 | act.finish(); 200 | } 201 | 202 | } 203 | 204 | } 205 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/social/SinaShare.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.social; 2 | 3 | import java.io.IOException; 4 | import java.net.MalformedURLException; 5 | import java.net.URL; 6 | 7 | import org.apache.http.client.ClientProtocolException; 8 | 9 | import android.app.Activity; 10 | import android.content.Intent; 11 | import android.graphics.Bitmap; 12 | import android.graphics.BitmapFactory; 13 | import android.os.Bundle; 14 | import android.text.TextUtils; 15 | import android.util.Log; 16 | import android.widget.Toast; 17 | import cn.bmob.social.share.core.BMCore; 18 | import cn.bmob.social.share.core.data.PlatformKeyInfo; 19 | import cn.bmob.social.share.core.data.ShareData; 20 | import cn.bmob.social.share.core.util.AccessTokenKeeper; 21 | import cn.bmob.social.share.core.util.PlatformAppHelper; 22 | 23 | import com.sina.weibo.sdk.api.ImageObject; 24 | import com.sina.weibo.sdk.api.TextObject; 25 | import com.sina.weibo.sdk.api.WeiboMessage; 26 | import com.sina.weibo.sdk.api.WeiboMultiMessage; 27 | import com.sina.weibo.sdk.api.share.IWeiboShareAPI; 28 | import com.sina.weibo.sdk.api.share.SendMessageToWeiboRequest; 29 | import com.sina.weibo.sdk.api.share.SendMultiMessageToWeiboRequest; 30 | import com.sina.weibo.sdk.api.share.WeiboShareSDK; 31 | import com.sina.weibo.sdk.auth.Oauth2AccessToken; 32 | import com.sina.weibo.sdk.auth.WeiboAuth; 33 | import com.sina.weibo.sdk.auth.WeiboAuthListener; 34 | import com.sina.weibo.sdk.auth.sso.SsoHandler; 35 | import com.sina.weibo.sdk.exception.WeiboException; 36 | /** 37 | * 新浪微博分享操作以及分享回调 38 | * @author youtui 39 | * @since 14/4/25 40 | */ 41 | public class SinaShare { 42 | /**新浪微博分享接口*/ 43 | private IWeiboShareAPI iWeiboShareAPI; 44 | /**传入的activity*/ 45 | private Activity activity; 46 | /**新浪微博授权AccessToken*/ 47 | private Oauth2AccessToken oauth2AccessToken; 48 | /**分享微博授权接口*/ 49 | private WeiboAuth mWeiboAuth; 50 | /**新浪微博sso类*/ 51 | private SsoHandler mSsoHandler; 52 | /**待分享数据*/ 53 | private ShareData shareData; 54 | 55 | public SinaShare(Activity activity,ShareData shareData) { 56 | this.activity = activity; 57 | iWeiboShareAPI = WeiboShareSDK.createWeiboAPI(activity, PlatformKeyInfo.sinaWeibo_AppKey ); 58 | this.shareData = shareData; 59 | } 60 | 61 | /** 62 | * 发送共享到新浪微博 63 | * @param shareData 64 | * @return 该次分享的标示 65 | */ 66 | public void shareToSina() { 67 | // 新浪微博在10351以上版本支持多条微博发送 68 | if (iWeiboShareAPI.getWeiboAppSupportAPI() >= 10351) { 69 | sendMultiMessage(); 70 | } else { 71 | sendSingleMessage(); 72 | } 73 | 74 | } 75 | 76 | /** 77 | * 新浪微博sso授权 78 | */ 79 | public void sinaAuth() { 80 | mWeiboAuth = new WeiboAuth(activity, PlatformKeyInfo.sinaWeibo_AppKey, PlatformKeyInfo.sinaWeibo_RedirectUrl, PlatformAppHelper.SINA_WEIBO_SCOPE); 81 | mSsoHandler = new SsoHandler(activity, mWeiboAuth); 82 | mSsoHandler.authorize(new AuthListener()); 83 | } 84 | 85 | /** 86 | * sso回调需要 87 | */ 88 | 89 | public void sinaResult(int requestCode, int resultCode, Intent data) { 90 | if (mSsoHandler != null) { 91 | mSsoHandler.authorizeCallBack(requestCode, resultCode, data); 92 | } 93 | } 94 | 95 | /** 96 | * 第三方应用发送请求消息到微博,唤起微博分享界面 < 10351 时,只支持分享单条消息,该方法发送一条网页消息 97 | * 98 | * @throws IOException 99 | * @throws ClientProtocolException 100 | */ 101 | private boolean sendSingleMessage() { 102 | 103 | // 1. 初始化微博的分享消息 104 | WeiboMessage weiboMessage = new WeiboMessage(); 105 | weiboMessage.mediaObject = getImageObj(shareData); 106 | // 2. 初始化从第三方到微博的消息请求 107 | SendMessageToWeiboRequest request = new SendMessageToWeiboRequest(); 108 | // 用transaction唯一标识一个请求 109 | request.transaction = String.valueOf(System.currentTimeMillis()); 110 | request.message = weiboMessage; 111 | // 3. 发送请求消息到微博,唤起微博分享界面 112 | return iWeiboShareAPI.sendRequest(request); 113 | } 114 | 115 | /** 116 | * 第三方应用发送请求消息到微博,唤起微博分享界面 > 10351 时,支持分享多条消息,该方法发送一条网页消息和一条图片消息 117 | */ 118 | 119 | private void sendMultiMessage() { 120 | WeiboMultiMessage weiboMessage = new WeiboMultiMessage(); 121 | weiboMessage.imageObject = getImageObj(shareData); 122 | weiboMessage.textObject = getTextObject(shareData); 123 | 124 | // weiboMessage.imageObject.actionUrl = "http://www.baidu.com"; 125 | // weiboMessage.textObject.actionUrl = "http://www.baidu.com"; 126 | // weiboMessage.imageObject.imagePath = "http://file.bmob.cn/M00/02/B4/wKhkA1OuzHeATJ5KAAAMie-ZImI961.jpg"; 127 | // Log.d("bmob", "******55****"+weiboMessage.imageObject.actionUrl+" ---- "+weiboMessage.imageObject.imagePath); 128 | Log.d("bmob", "******88****"+weiboMessage.textObject.actionUrl+" ---- "+weiboMessage.textObject.text+" --- "+weiboMessage.textObject.title+" --- "+weiboMessage.textObject.description); 129 | // 2. 初始化从第三方到微博的消息请求 130 | SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest(); 131 | // 用transaction唯一标识一个请求 132 | request.transaction = String.valueOf(System.currentTimeMillis()); 133 | request.multiMessage = weiboMessage; 134 | // 3. 发送请求消息到微博,唤起微博分享界面 135 | iWeiboShareAPI.sendRequest(request); 136 | } 137 | 138 | /** 139 | * 获得要分享的文字信息 140 | * 141 | * @return 142 | */ 143 | private TextObject getTextObject(ShareData shareData) { 144 | 145 | TextObject textObject = new TextObject(); 146 | textObject.title = shareData.getTitle(); 147 | textObject.description = shareData.getDescription(); 148 | String text = shareData.getText(); 149 | //如果文字太长,截取部分,不然微博无法发送 150 | if(text.length()>110){ 151 | text = text.substring(0, 109); 152 | text += "..."; 153 | } 154 | //YtLog.i("shareData.getTarget_url()", shareData.getTarget_url()); 155 | textObject.text = TextUtils.isEmpty(shareData.getTarget_url()) ? text : text+shareData.getTarget_url(); 156 | textObject.actionUrl = shareData.getTarget_url(); 157 | 158 | return textObject; 159 | } 160 | 161 | /** 162 | * 获得要分享的图片信息 163 | * 164 | * @return 165 | */ 166 | private ImageObject getImageObj(ShareData shareData) { 167 | ImageObject image = new ImageObject(); 168 | Bitmap bitmap = null; 169 | if (shareData == null) { 170 | } else if (shareData.getImagePath() != null) { 171 | bitmap = BitmapFactory.decodeFile(shareData.getImagePath()); 172 | } else if (shareData.getImageUrl() != null) { 173 | try { 174 | bitmap = BitmapFactory.decodeStream(new URL(shareData.getImageUrl()).openStream()); 175 | } catch (MalformedURLException e) { 176 | e.printStackTrace(); 177 | } catch (IOException e) { 178 | e.printStackTrace(); 179 | } 180 | } 181 | 182 | if (bitmap == null) { 183 | return null; 184 | // bitmap = BitmapFactory.decodeResource(activity.getResources(), BMCore.res.getIdentifier("loadfail", "drawable", BMCore.packName)); 185 | } 186 | image.setImageObject(bitmap); 187 | image.actionUrl = shareData.getTarget_url(); 188 | image.description = shareData.getText(); 189 | return image; 190 | } 191 | 192 | /** 193 | * 监听新浪微博授权结果 194 | */ 195 | 196 | class AuthListener implements WeiboAuthListener { 197 | 198 | @Override 199 | public void onCancel() { 200 | Toast.makeText(activity, "授权取消", Toast.LENGTH_SHORT).show(); 201 | activity.finish(); 202 | } 203 | 204 | @Override 205 | public void onComplete(Bundle bundle) { 206 | oauth2AccessToken = Oauth2AccessToken.parseAccessToken(bundle); 207 | if (oauth2AccessToken.isSessionValid()) { 208 | AccessTokenKeeper.writeAccessToken(activity, oauth2AccessToken); 209 | } 210 | iWeiboShareAPI.registerApp(); 211 | Toast.makeText(activity, "授权成功,请点击进行分享", Toast.LENGTH_SHORT).show(); 212 | activity.finish(); 213 | } 214 | 215 | @Override 216 | public void onWeiboException(WeiboException arg0) { 217 | Toast.makeText(activity, "授权错误", Toast.LENGTH_SHORT).show(); 218 | activity.finish(); 219 | } 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/social/TencentWbShare.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.social; 2 | 3 | import android.app.Activity; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | import android.text.TextUtils; 7 | import android.util.Log; 8 | import android.widget.Toast; 9 | import cn.bmob.social.share.core.BMShareListener; 10 | import cn.bmob.social.share.core.ErrorInfo; 11 | import cn.bmob.social.share.core.data.ShareData; 12 | import cn.bmob.social.share.core.util.Util; 13 | 14 | import com.tencent.weibo.sdk.android.api.WeiboAPI; 15 | import com.tencent.weibo.sdk.android.api.util.SharePersistent; 16 | import com.tencent.weibo.sdk.android.model.ModelResult; 17 | import com.tencent.weibo.sdk.android.network.HttpCallback; 18 | /** 19 | * 腾讯微博分享 20 | * @author youtui 21 | * @since 14/5/8 22 | */ 23 | public class TencentWbShare { 24 | /**传入的activity*/ 25 | private Activity act; 26 | /**短链接*/ 27 | private String shortUrl; 28 | /**真实网址*/ 29 | private String realUrl; 30 | /**分享监听*/ 31 | private BMShareListener listener; 32 | /**标示,用于Log输出*/ 33 | private final String TAG = "at class TencentWbShare"; 34 | /**待分享数据*/ 35 | private ShareData shareData; 36 | 37 | public TencentWbShare(Activity act,BMShareListener listener,ShareData shareData) { 38 | this.listener = listener; 39 | this.act = act; 40 | this.shareData = shareData; 41 | shortUrl = act.getIntent().getExtras().getString("shortUrl"); 42 | realUrl = act.getIntent().getExtras().getString("realUrl"); 43 | } 44 | 45 | /** 46 | * 分享到腾讯微博 47 | */ 48 | public void shareToTencentWb() { 49 | WeiboAPI weibo = new WeiboAPI(SharePersistent.getInstance().getAccount(act)); 50 | Bitmap bm = BitmapFactory.decodeFile(shareData.getImagePath()); 51 | String text = shareData.getText(); 52 | // 如果腾讯微博分享文字过长,截取前面内容和跳转url 53 | if(text.length()>110){ 54 | text = text.substring(0, 109); 55 | text+="..."; 56 | } 57 | text = TextUtils.isEmpty(shareData.getTarget_url()) ? text : text+shareData.getTarget_url(); 58 | 59 | if(bm==null){ 60 | // Toast.makeText(act, "加载分享图片失败,请重新设置分享图片...", Toast.LENGTH_SHORT).show(); 61 | // Util.dismissDialog(); 62 | weibo.addWeibo(act, text, "json", 0d, 0d, -1, 0, mCallBack, null, 4); 63 | }else{ 64 | weibo.addPic(act, text, "json", 0d, 0d, bm, -1, 0, mCallBack, null, 4); 65 | } 66 | } 67 | 68 | /** 69 | * 腾讯微博分享回调 70 | */ 71 | HttpCallback mCallBack = new HttpCallback() { 72 | @Override 73 | public void onResult(Object object) { 74 | ModelResult result = (ModelResult) object; 75 | if (result != null && result.isSuccess()) { 76 | // 分享成功 77 | // YtShareListener.sharePoint(act, KeyInfo.youTui_AppKey, ChannelId.TENCENTWEIBO, realUrl, !shareData.isAppShare, shortUrl); 78 | if(listener!=null){ 79 | ErrorInfo error = new ErrorInfo(); 80 | String errorMessage = result.getError_message(); 81 | error.setErrorMessage(errorMessage); 82 | listener.onSuccess(); 83 | } 84 | act.finish(); 85 | } else { 86 | if(listener!=null){ 87 | ErrorInfo error = new ErrorInfo(); 88 | String errorMessage = null; 89 | if(result != null){ 90 | errorMessage = result.getError_message(); 91 | }else{ 92 | errorMessage = null; 93 | } 94 | error.setErrorMessage(errorMessage); 95 | listener.onError(error); 96 | } 97 | act.finish(); 98 | } 99 | } 100 | }; 101 | 102 | }; 103 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/util/AccessTokenKeeper.java: -------------------------------------------------------------------------------- 1 | 2 | package cn.bmob.social.share.core.util; 3 | 4 | import android.content.Context; 5 | import android.content.SharedPreferences; 6 | import android.content.SharedPreferences.Editor; 7 | 8 | import com.sina.weibo.sdk.auth.Oauth2AccessToken; 9 | 10 | /** 11 | * 该类定义了AccessToken相关的操作 12 | * @author youtui 13 | * @since 14/3/25 14 | */ 15 | public class AccessTokenKeeper { 16 | /**新浪微博保存的授权信息文件名*/ 17 | private static final String PREFERENCES_NAME = "com_weibo_sdk_android"; 18 | /**新浪微博授权文件保存用户id的字段*/ 19 | private static final String KEY_UID = "uid"; 20 | /**新浪微博授权文件保存access_token的字段*/ 21 | private static final String KEY_ACCESS_TOKEN = "access_token"; 22 | /**新浪微博授权文件保存过期时间的字段*/ 23 | private static final String KEY_EXPIRES_IN = "expires_in"; 24 | /**腾讯QQ授权文件保存openid的字段*/ 25 | private static final String KEY_OPENID = "openid"; 26 | 27 | /** 28 | * 读取腾讯开放平台AccessToken 29 | */ 30 | public static String readQQAccessToken(Context context){ 31 | SharedPreferences sp = context.getSharedPreferences("tencent_open_access", 0); 32 | return sp.getString(KEY_ACCESS_TOKEN, null); 33 | } 34 | /** 35 | * 读取腾讯开放平台Expires 36 | */ 37 | public static String readQQExpires(Context context){ 38 | SharedPreferences sp = context.getSharedPreferences("tencent_open_access", 0); 39 | return sp.getString(KEY_EXPIRES_IN, null); 40 | } 41 | /** 42 | * 读取腾讯开放平台openid 43 | */ 44 | 45 | public static String readQQOpenid(Context context){ 46 | SharedPreferences sp = context.getSharedPreferences("tencent_open_access", 0); 47 | return sp.getString(KEY_OPENID, null); 48 | } 49 | 50 | 51 | 52 | 53 | /** 54 | * 保存 Token 对象到 SharedPreferences。 55 | * 56 | * @param context 应用程序上下文环境 57 | * @param token Token 对象 58 | */ 59 | public static void writeAccessToken(Context context, Oauth2AccessToken token) { 60 | if (null == context || null == token) { 61 | return; 62 | } 63 | 64 | SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND); 65 | Editor editor = pref.edit(); 66 | editor.putString(KEY_UID, token.getUid()); 67 | editor.putString(KEY_ACCESS_TOKEN, token.getToken()); 68 | editor.putLong(KEY_EXPIRES_IN, token.getExpiresTime()); 69 | editor.commit(); 70 | } 71 | 72 | /** 73 | * 从 SharedPreferences 读取 Token 信息。 74 | * 75 | * @param context 应用程序上下文环境 76 | * 77 | * @return 返回 Token 对象 78 | */ 79 | public static Oauth2AccessToken readAccessToken(Context context) { 80 | if (null == context) { 81 | return null; 82 | } 83 | 84 | Oauth2AccessToken token = new Oauth2AccessToken(); 85 | SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND); 86 | token.setUid(pref.getString(KEY_UID, "")); 87 | token.setToken(pref.getString(KEY_ACCESS_TOKEN, "")); 88 | token.setExpiresTime(pref.getLong(KEY_EXPIRES_IN, 0)); 89 | return token; 90 | } 91 | 92 | /** 93 | * 清空 SharedPreferences 中 Token信息。 94 | * 95 | * @param context 应用程序上下文环境 96 | */ 97 | public static void clear(Context context) { 98 | if (null == context) { 99 | return; 100 | } 101 | 102 | SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND); 103 | Editor editor = pref.edit(); 104 | editor.clear(); 105 | editor.commit(); 106 | } 107 | /** 108 | * 判断腾讯微博授权是否过期 109 | */ 110 | public static boolean isTencentWbAuthExpired(Context context){ 111 | boolean expired = true; 112 | SharedPreferences preference = context.getSharedPreferences("ANDROID_SDK", 0); 113 | String authorizeTimeStr = preference.getString("AUTHORIZETIME", null); 114 | String expiresTime = preference.getString( "EXPIRES_IN",null); 115 | long currentTime = System.currentTimeMillis() / 1000; 116 | if (expiresTime != null&&expiresTime!="" && authorizeTimeStr != null&&authorizeTimeStr!="") { 117 | if ((Long.valueOf(authorizeTimeStr) + Long.valueOf(expiresTime)) > currentTime) { 118 | expired = false; 119 | } 120 | } 121 | return expired; 122 | } 123 | 124 | 125 | } 126 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/util/BMLog.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.util; 2 | 3 | import android.util.Log; 4 | 5 | public class BMLog { 6 | private static String TAG = "bmob"; 7 | public static boolean showLog = true; 8 | 9 | public static void i(String msg){ 10 | if(showLog){ 11 | Log.i(TAG, msg); 12 | } 13 | } 14 | 15 | public static void d(String msg){ 16 | if(showLog){ 17 | Log.d(TAG, msg); 18 | } 19 | } 20 | 21 | public static void e(String msg){ 22 | if(showLog){ 23 | Log.e(TAG, msg); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/util/DownloadImage.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.util; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileNotFoundException; 6 | import java.io.FileOutputStream; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.net.URL; 10 | import java.net.URLConnection; 11 | 12 | import android.graphics.Bitmap; 13 | import android.graphics.BitmapFactory; 14 | /** 15 | * 下载图片 16 | * @author youtui 17 | * @since 14/6/19 18 | */ 19 | public class DownloadImage { 20 | private static final String TAG = "at class DownloadImage: "; 21 | 22 | /**文件保存路径*/ 23 | public static final String FILE_SAVE_PATH = "/bmshare/"; 24 | 25 | /** 26 | * 加载系统本地图片 27 | */ 28 | @SuppressWarnings("unused") 29 | public static Bitmap loadImage(final String url, final String filename) { 30 | try { 31 | FileInputStream fis = new FileInputStream(url + filename); 32 | if (fis != null) { 33 | return BitmapFactory.decodeStream(fis); 34 | } else { 35 | return null; 36 | } 37 | } catch (FileNotFoundException e) { 38 | e.printStackTrace(); 39 | return null; 40 | } 41 | } 42 | 43 | /** 44 | * 下载文件功能 45 | * 46 | * @throws IOException 47 | */ 48 | public static void down_file(String url, String path, String filename) throws IOException { 49 | BMLog.i(TAG+"start down shared image"); 50 | URL myURL = new URL(url); 51 | URLConnection conn = myURL.openConnection(); 52 | conn.connect(); 53 | InputStream is = conn.getInputStream(); 54 | int fileSize = conn.getContentLength();// 根据响应获取文件大小 55 | if (fileSize <= 0) 56 | throw new RuntimeException("无法获知文件大小 "); 57 | if (is == null) 58 | throw new RuntimeException("stream is null"); 59 | FileUtils util = new FileUtils(); 60 | util.creatSDDir(path); 61 | File file = util.creatSDFile(path + filename);// 保存的文件名 62 | @SuppressWarnings("resource") 63 | FileOutputStream fos = new FileOutputStream(file); 64 | 65 | // 把数据存入路径+文件名 66 | byte buf[] = new byte[1024]; 67 | do { 68 | // 循环读取 69 | int numread = is.read(buf); 70 | if (numread == -1) { 71 | break; 72 | } 73 | fos.write(buf, 0, numread); 74 | } while (true); 75 | is.close(); 76 | BMLog.i(TAG+"down shared image complete"); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/util/FileUtils.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.util; 2 | import java.io.File; 3 | import java.io.FileOutputStream; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.OutputStream; 7 | 8 | import android.os.Environment; 9 | /** 10 | * 文件操作 11 | * @author youtui 12 | * @since 14/6/19 13 | */ 14 | public class FileUtils { 15 | public static String SDPATH = Environment.getExternalStorageDirectory()+ "/"; 16 | 17 | public String getSDPATH() { 18 | return SDPATH; 19 | 20 | } 21 | 22 | /** 23 | * 得到当前外部存储设备的目录 24 | */ 25 | public FileUtils() { 26 | //SDPATH = Environment.getExternalStorageDirectory()+ "/"; 27 | } 28 | 29 | /** 30 | * 在SD卡上创建文件 31 | */ 32 | public File creatSDFile(String fileName) throws IOException { 33 | File file = new File(SDPATH + fileName); 34 | if(file.exists()){ 35 | file.createNewFile(); 36 | } 37 | return file; 38 | } 39 | 40 | /** 41 | * 在SD卡上创建目录 42 | */ 43 | public File creatSDDir(String dirName) { 44 | File dir = new File(SDPATH + dirName); 45 | dir.mkdir(); 46 | return dir; 47 | } 48 | 49 | /** 50 | * 判断SD卡上的文件是否存在 51 | * 52 | * @param fileName 53 | * @return 54 | */ 55 | public boolean isFileExist(String fileName) { 56 | File file = new File(SDPATH + fileName); 57 | return file.exists(); 58 | } 59 | 60 | /** 61 | * 将一个InputStream里面的数据写入到SD卡中 62 | * 63 | * @param path:要写入SDCARD的目录 64 | * @param fileName:要写入的文件名 65 | * @param inpout:要写入的数据 66 | * @return 67 | */ 68 | public File write2SDFromInput(String path, String fileName, 69 | InputStream input) { 70 | File file = null; 71 | OutputStream output = null; 72 | try { 73 | creatSDDir(path); 74 | file = creatSDFile(path + fileName); 75 | output = new FileOutputStream(file); 76 | byte[] buffer = new byte[4 * 1024]; 77 | while (input.read(buffer) != -1) { 78 | output.write(buffer); 79 | } 80 | output.flush(); 81 | } catch (Exception e) { 82 | e.printStackTrace(); 83 | } finally { 84 | try { 85 | output.close(); 86 | } catch (IOException e) { 87 | e.printStackTrace(); 88 | } 89 | } 90 | return file; 91 | } 92 | 93 | 94 | /**判断两个文件是否内容相同*/ 95 | public static boolean isSame(byte[] file1,byte[] file2){ 96 | int length = file1.length packs = pm.getInstalledPackages(0); 43 | for (PackageInfo pi : packs) { 44 | if (pi.applicationInfo.packageName.equals(packageName)) { 45 | return true; 46 | } 47 | } 48 | return false; 49 | } 50 | 51 | /** 52 | * 检查新浪微博是否已经安装 53 | */ 54 | public static boolean isSinaWeiboExisted(Context context) { 55 | if (checkApp(context, PACKAGE_NAME_SINA_WEIBO)) { 56 | return true; 57 | } else { 58 | return false; 59 | } 60 | } 61 | 62 | /** 63 | * 检查腾讯QQ是否已经安装 64 | */ 65 | public static boolean isTencentQQExisted(Context context) { 66 | if (checkApp(context, PACKAGE_NAME_TENCENT_QQ)) { 67 | return true; 68 | } else { 69 | return false; 70 | } 71 | } 72 | 73 | /** 74 | * 检查人人客户端是否已经安装 75 | */ 76 | public static boolean isRenrenExisted(Context context) { 77 | if (checkApp(context, PACKAGE_NAME_RENREN)) { 78 | return true; 79 | } else { 80 | return false; 81 | } 82 | } 83 | 84 | /** 85 | * 检查微信是否已经安装 86 | */ 87 | public static boolean isWeixinExisted(Context context) { 88 | if (checkApp(context, PACKAGE_NAME_WEIXIN)) { 89 | return true; 90 | } else { 91 | return false; 92 | } 93 | } 94 | 95 | /** 96 | * 用于检测该intent能否可以使用 97 | */ 98 | public static boolean isIntentAvailable(Context context, Intent intent) { 99 | final PackageManager packageManager = context.getPackageManager(); 100 | List list = packageManager.queryIntentActivities(intent, 101 | PackageManager.GET_ACTIVITIES); 102 | return list.size() > 0; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/util/Util.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.util; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | import android.annotation.SuppressLint; 7 | import android.app.Activity; 8 | import android.app.ProgressDialog; 9 | import android.content.Context; 10 | import android.content.DialogInterface; 11 | import android.content.res.AssetManager; 12 | import android.graphics.Bitmap; 13 | import android.graphics.BitmapFactory; 14 | import android.net.ConnectivityManager; 15 | import android.net.NetworkInfo; 16 | import android.os.Handler; 17 | import android.widget.Toast; 18 | 19 | public class Util { 20 | 21 | private static ProgressDialog mProgressDialog; 22 | 23 | /** 24 | * 显示ProgressDialog 25 | */ 26 | public static final void showProgressDialog(final Activity act, String message,final boolean isFinishActivity) { 27 | dismissDialog(); 28 | mProgressDialog = new ProgressDialog(act); 29 | // 设置进度条风格,风格为圆形,旋转的 30 | mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); 31 | // 设置ProgressDialog 提示信息 32 | mProgressDialog.setMessage(message); 33 | // 设置ProgressDialog 的进度条是否不明确 34 | mProgressDialog.setIndeterminate(false); 35 | // 设置ProgressDialog 是否可以按退回按键取消 36 | mProgressDialog.setCancelable(true); 37 | mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { 38 | 39 | @Override 40 | public void onCancel(DialogInterface dialog) { 41 | if(isFinishActivity){ 42 | act.finish(); 43 | } 44 | } 45 | }); 46 | mProgressDialog.show(); 47 | } 48 | /** 49 | * dismiss ProgressDialog 50 | */ 51 | public static final void dismissDialog() { 52 | if (mProgressDialog != null) { 53 | mProgressDialog.dismiss(); 54 | mProgressDialog = null; 55 | } 56 | } 57 | 58 | /** 59 | * 判断网络是否连接 60 | * 61 | * @param context 62 | * @return 63 | */ 64 | public static Boolean isNetworkConnected(Context context) { 65 | ConnectivityManager conn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); 66 | NetworkInfo info = conn.getActiveNetworkInfo(); 67 | if (info != null&&info.isAvailable()) { 68 | return true; 69 | } 70 | return false; 71 | } 72 | 73 | /** 74 | * 复制链接 复制链接 API 11之前用android.text.ClipboardManager; API 75 | * 11之后用android.content.ClipboardManager 76 | * 77 | * @param mHandler 78 | * @param act 79 | * @param message 80 | */ 81 | public static void copyLink(Handler mHandler, final Context act, final String message) { 82 | mHandler.post(new Runnable() { 83 | @SuppressWarnings("deprecation") 84 | @SuppressLint("NewApi") 85 | public void run() { 86 | if (android.os.Build.VERSION.SDK_INT >= 11) { 87 | android.content.ClipboardManager clip = (android.content.ClipboardManager) act.getSystemService(Context.CLIPBOARD_SERVICE); 88 | clip.setPrimaryClip(android.content.ClipData.newPlainText("link", message)); 89 | if (clip.hasPrimaryClip()) { 90 | Toast.makeText(act, "复制成功", Toast.LENGTH_SHORT).show(); 91 | } else { 92 | Toast.makeText(act, "复制失败,请手动复制", Toast.LENGTH_SHORT).show(); 93 | } 94 | } else { 95 | android.text.ClipboardManager clip = (android.text.ClipboardManager) act.getSystemService(Context.CLIPBOARD_SERVICE); 96 | clip.setText(message); 97 | if (clip.hasText()) { 98 | Toast.makeText(act, "复制成功", Toast.LENGTH_SHORT).show(); 99 | } else { 100 | Toast.makeText(act, "复制失败,请手动复制", Toast.LENGTH_SHORT).show(); 101 | } 102 | } 103 | } 104 | }); 105 | } 106 | 107 | /** 108 | * dp to px 109 | */ 110 | public static int dip2px(Context context, float dpValue) { 111 | final float scale = context.getResources().getDisplayMetrics().density; 112 | return (int) (dpValue * scale + 0.5f); 113 | } 114 | 115 | /** 116 | * px to dp 117 | */ 118 | public static int px2dip(Context context, float pxValue) { 119 | final float scale = context.getResources().getDisplayMetrics().density; 120 | return (int) (pxValue / scale + 0.5f); 121 | } 122 | 123 | /** 124 | * 读取Assets文件夹中的图片资源 125 | * @param context 126 | * @param fileName 图片名称 127 | * @return 128 | */ 129 | public static Bitmap getImageFromAssetsFile(Context context, String fileName) { 130 | Bitmap image = null; 131 | AssetManager am = context.getAssets(); 132 | try { 133 | InputStream is = am.open(fileName); 134 | image = BitmapFactory.decodeStream(is); 135 | is.close(); 136 | } catch (IOException e) { 137 | e.printStackTrace(); 138 | } 139 | return image; 140 | } 141 | 142 | } 143 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/core/wxapi/WXEntryActivity.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.core.wxapi; 2 | 3 | import cn.bmob.social.share.core.BMCore; 4 | import cn.bmob.social.share.core.BMShareListener; 5 | import cn.bmob.social.share.core.ErrorInfo; 6 | import cn.bmob.social.share.core.data.BMPlatform; 7 | import cn.bmob.social.share.core.data.PlatformKeyInfo; 8 | import cn.bmob.social.share.core.data.ShareData; 9 | import cn.bmob.social.share.core.util.BMLog; 10 | import cn.bmob.social.share.core.util.Util; 11 | 12 | import com.tencent.mm.sdk.openapi.BaseReq; 13 | import com.tencent.mm.sdk.openapi.BaseResp; 14 | import com.tencent.mm.sdk.openapi.IWXAPI; 15 | import com.tencent.mm.sdk.openapi.IWXAPIEventHandler; 16 | import com.tencent.mm.sdk.openapi.SendMessageToWX; 17 | import com.tencent.mm.sdk.openapi.WXAPIFactory; 18 | import com.tencent.mm.sdk.openapi.WXImageObject; 19 | import com.tencent.mm.sdk.openapi.WXMediaMessage; 20 | import com.tencent.mm.sdk.openapi.WXTextObject; 21 | import com.tencent.mm.sdk.openapi.WXWebpageObject; 22 | 23 | import android.app.Activity; 24 | import android.content.Intent; 25 | import android.graphics.Bitmap; 26 | import android.graphics.BitmapFactory; 27 | import android.os.Bundle; 28 | import android.text.TextUtils; 29 | import android.util.Log; 30 | import android.view.Window; 31 | 32 | /** 33 | * 微信分享activity 34 | * @author youtui 35 | * @since 14/5/4 36 | */ 37 | public class WXEntryActivity extends Activity implements IWXAPIEventHandler{ 38 | /**微信接口*/ 39 | private IWXAPI mIWXAPI; 40 | /**待分享图片*/ 41 | private Bitmap bitmap; 42 | /**分享图片的缩略图*/ 43 | private Bitmap bmpThum; 44 | /**短链接*/ 45 | private String shortUrl; 46 | /**真实网址*/ 47 | private String realUrl ; 48 | /**微信是否为分享时打开*/ 49 | private boolean fromShare; 50 | /**分享事件监听*/ 51 | public static BMShareListener listener; 52 | /**分享的平台,用于区别微信好友和微信朋友圈*/ 53 | private BMPlatform platform; 54 | /**待分享数据*/ 55 | public static ShareData shareData; 56 | 57 | @Override 58 | protected void onCreate(Bundle savedInstanceState) { 59 | requestWindowFeature(Window.FEATURE_NO_TITLE); 60 | super.onCreate(savedInstanceState); 61 | // 判断是否为朋友圈 62 | platform = (BMPlatform) getIntent().getExtras().get("platform"); 63 | fromShare = getIntent().getExtras().getBoolean("fromShare"); 64 | shortUrl = getIntent().getExtras().getString("shortUrl"); 65 | realUrl = getIntent().getExtras().getString("realUrl"); 66 | 67 | // 传入的pointArr不为null时 68 | if (platform == BMPlatform.PLATFORM_WECHATMOMENTS) { 69 | mIWXAPI = WXAPIFactory.createWXAPI(WXEntryActivity.this, PlatformKeyInfo.wechatMoments_AppId, false); 70 | mIWXAPI.registerApp(PlatformKeyInfo.wechatMoments_AppId); 71 | } else { 72 | mIWXAPI = WXAPIFactory.createWXAPI(WXEntryActivity.this, PlatformKeyInfo.wechat_AppId, false); 73 | mIWXAPI.registerApp(PlatformKeyInfo.wechat_AppId); 74 | } 75 | mIWXAPI.handleIntent(getIntent(), WXEntryActivity.this); 76 | shareToWx(); 77 | } 78 | 79 | /** 80 | * 分享到微信或朋友圈 当微信没有登陆时,分享会先进入登陆界面,登录后再次启动该activity, 81 | * 导致通过Intent传入的ShareData.shareData和pointArr读取都为null 此时在shareToWx不需要做操作 82 | */ 83 | protected void shareToWx() { 84 | if (shareData != null) { 85 | WXMediaMessage msg = new WXMediaMessage(); 86 | if (shareData.getImagePath() != null) { 87 | bitmap = BitmapFactory.decodeFile(shareData.getImagePath()); 88 | } 89 | msg.title = shareData.getTitle(); 90 | msg.description = shareData.getText(); 91 | 92 | // bitmap为空时微信分享会没有响应,所以要设置一个默认图片让用户知道 93 | if (bitmap != null) { 94 | bmpThum = Bitmap.createScaledBitmap(bitmap, 150, 150, true); 95 | } else { 96 | bmpThum = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), BMCore.res.getIdentifier("yt_loadfail", "drawable", BMCore.packName)), 150, 150, true); 97 | } 98 | 99 | if(TextUtils.isEmpty(shareData.getImagePath()) 100 | && TextUtils.isEmpty(shareData.getImageUrl()) 101 | && TextUtils.isEmpty(shareData.getTarget_url())){ 102 | // 纯文字分享 103 | WXTextObject textObject = new WXTextObject(); 104 | textObject.text = shareData.getText(); 105 | msg.mediaObject = textObject; 106 | // msg.description = shareData.getText(); 107 | // BMLog.d("纯文字分享"); 108 | }else if(!TextUtils.isEmpty(shareData.getImagePath()) 109 | && TextUtils.isEmpty(shareData.getImageUrl())){ 110 | // 纯图片分享 111 | WXImageObject imageObject = new WXImageObject(); 112 | // imageObject.imageUrl = "(图片地址)"; 113 | imageObject.imagePath = shareData.getImagePath(); 114 | msg.mediaObject = imageObject; 115 | msg.setThumbImage(bmpThum); 116 | // BMLog.d("纯图片分享"); 117 | }else if(!TextUtils.isEmpty(shareData.getImageUrl()) 118 | && TextUtils.isEmpty(shareData.getTarget_url())){ 119 | // 图文分享 120 | WXWebpageObject pageObject = new WXWebpageObject(); 121 | pageObject.webpageUrl = shareData.getImageUrl(); 122 | msg.mediaObject = pageObject; 123 | msg.setThumbImage(bmpThum); 124 | // BMLog.d("图文分享"); 125 | }else if(!TextUtils.isEmpty(shareData.getTarget_url()) 126 | && TextUtils.isEmpty(shareData.getImagePath()) 127 | && TextUtils.isEmpty(shareData.getImageUrl())){ 128 | // 链接分享 129 | WXWebpageObject pageObject = new WXWebpageObject(); 130 | pageObject.webpageUrl = shareData.getTarget_url(); 131 | msg.mediaObject = pageObject; 132 | // msg.description = shareData.getText(); 133 | // BMLog.d("链接分享"); 134 | }else { 135 | msg.setThumbImage(bmpThum); 136 | WXWebpageObject pageObject = new WXWebpageObject(); 137 | pageObject.webpageUrl = shareData.getTarget_url(); 138 | msg.mediaObject = pageObject; 139 | } 140 | 141 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 142 | req.transaction = buildTransaction("测试"); 143 | req.message = msg; 144 | if (fromShare) { 145 | if (platform == BMPlatform.PLATFORM_WECHATMOMENTS) { 146 | req.scene = SendMessageToWX.Req.WXSceneTimeline; 147 | } else { 148 | req.scene = SendMessageToWX.Req.WXSceneSession; 149 | } 150 | mIWXAPI.sendReq(req); 151 | } 152 | } else { 153 | } 154 | 155 | } 156 | 157 | @Override 158 | protected void onNewIntent(Intent intent) { 159 | super.onNewIntent(intent); 160 | handIntent(intent); 161 | } 162 | /** 163 | * 微信监听分享结果 164 | * @param intent 165 | */ 166 | public void handIntent(Intent intent) { 167 | setIntent(intent); 168 | // 监听分享后的返回结果 169 | mIWXAPI.handleIntent(intent, this); 170 | } 171 | 172 | /** 173 | * 创建唯一标示 174 | * @param type 175 | * @return 唯一标示字符串 176 | */ 177 | protected String buildTransaction(final String type) { 178 | return (type == null) ? String.valueOf(System.currentTimeMillis()) : type + System.currentTimeMillis(); 179 | } 180 | 181 | @Override 182 | public void onReq(BaseReq req) { 183 | 184 | } 185 | 186 | @Override 187 | protected void onRestart() { 188 | Util.dismissDialog(); 189 | finish(); 190 | super.onRestart(); 191 | } 192 | 193 | @Override 194 | protected void onDestroy() { 195 | shareData = null; 196 | listener = null; 197 | super.onDestroy(); 198 | } 199 | 200 | 201 | @Override 202 | /** 203 | * 微信分享监听 204 | */ 205 | public void onResp(BaseResp response) { 206 | switch (response.errCode) { 207 | case BaseResp.ErrCode.ERR_OK: 208 | BMLog.d("分享到微信成功"+listener); 209 | if (platform == BMPlatform.PLATFORM_WECHATMOMENTS) { 210 | // YtShareListener.sharePoint(this, KeyInfo.youTui_AppKey, ChannelId.WECHATFRIEND, realUrl, !shareData.isAppShare, shortUrl); 211 | if(listener!=null){ 212 | ErrorInfo error = new ErrorInfo(); 213 | String errorMessage = response.errStr; 214 | error.setErrorMessage(errorMessage); 215 | listener.onSuccess(); 216 | } 217 | } else { 218 | // YtShareListener.sharePoint(this, KeyInfo.youTui_AppKey, ChannelId.WECHAT, realUrl, !shareData.isAppShare, shortUrl); 219 | if(listener!= null){ 220 | ErrorInfo error = new ErrorInfo(); 221 | String errorMessage = response.errStr; 222 | error.setErrorMessage(errorMessage); 223 | listener.onSuccess(); 224 | } 225 | } 226 | break; 227 | case BaseResp.ErrCode.ERR_SENT_FAILED: 228 | BMLog.d("分享到微信失败"+listener); 229 | if(listener!=null){ 230 | ErrorInfo error = new ErrorInfo(); 231 | String errorMessage = response.errStr; 232 | error.setErrorMessage(errorMessage); 233 | listener.onError(error); 234 | } 235 | break; 236 | case BaseResp.ErrCode.ERR_COMM: 237 | if(listener!=null){ 238 | ErrorInfo error = new ErrorInfo(); 239 | String errorMessage = response.errStr; 240 | error.setErrorMessage(errorMessage); 241 | listener.onError(error); 242 | } 243 | break; 244 | case BaseResp.ErrCode.ERR_USER_CANCEL: 245 | BMLog.d("取消分享到微信"+listener); 246 | if(listener!=null){ 247 | listener.onCancel(); 248 | } 249 | case BaseResp.ErrCode.ERR_AUTH_DENIED: 250 | break; 251 | default: 252 | break; 253 | } 254 | finish(); 255 | } 256 | 257 | } 258 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/view/BMShare.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.view; 2 | 3 | import java.util.HashMap; 4 | 5 | import android.app.Activity; 6 | import cn.bmob.social.share.core.BMCore; 7 | import cn.bmob.social.share.core.BMShareListener; 8 | import cn.bmob.social.share.core.data.BMPlatform; 9 | import cn.bmob.social.share.core.data.ShareData; 10 | import cn.bmob.social.share.core.util.BMLog; 11 | 12 | public class BMShare { 13 | private Activity act; 14 | 15 | private HashMap listenerMap = new HashMap(); 16 | private HashMap shareDataMap = new HashMap(); 17 | 18 | private ShareData shareData; 19 | 20 | public BMShare(Activity act){ 21 | this.act = act; 22 | BMCore.init(act); 23 | } 24 | 25 | /** 26 | * 为单独的平台添加分享数据 27 | * @param platform 28 | * @param shareData 29 | */ 30 | public void addData(BMPlatform platform, ShareData shareData) { 31 | shareDataMap.put(platform, shareData); 32 | } 33 | /** 34 | * 获取指定平台的分享信息 35 | * @param platform 36 | * @return 指定平台的分享信息 37 | */ 38 | public ShareData getData(BMPlatform platform){ 39 | return shareDataMap.get(platform); 40 | } 41 | /** 42 | * 添加分享监听 43 | * @param platform 44 | * @param listener 45 | */ 46 | public void addListener(BMPlatform platform, BMShareListener listener) { 47 | BMLog.d("**1*** "+platform+" --- "+listener); 48 | listenerMap.put(platform, listener); 49 | } 50 | /** 51 | * 获得监听事件 52 | * @param platform 53 | * @return 监听事件 54 | */ 55 | public BMShareListener getListener(BMPlatform platform) { 56 | return listenerMap.get(platform); 57 | } 58 | 59 | /**调出分享界面*/ 60 | public void show(){ 61 | new ListPopup(act, this, shareData).show(); 62 | } 63 | 64 | /** 65 | * 该方法用于设置所有平台的待分享数据,如果开发者没有使用addData(YtPlatform platform, ShareData shareData)方法为特定平台设置待分享数据,则平台分享的内容为此处设置的内容 66 | * @param shareData 67 | */ 68 | public void setShareData(ShareData shareData){ 69 | this.shareData = shareData; 70 | } 71 | 72 | /** 73 | * 分享到各个平台, 用于白色列表样式的listview 74 | * 75 | * @param position 76 | */ 77 | public void doListShare(BMPlatform bmPlatform, ShareData shareData){ 78 | switch (bmPlatform) { 79 | case PLATFORM_WECHAT: 80 | // 分享到微信 81 | // 判断是否有单独设置该平台的分享内容 82 | if(getData(BMPlatform.PLATFORM_WECHAT)!=null){ 83 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_WECHAT, getListener(BMPlatform.PLATFORM_WECHAT), getData(BMPlatform.PLATFORM_WECHAT)); 84 | }else { 85 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_WECHAT, getListener(BMPlatform.PLATFORM_WECHAT), shareData); 86 | } 87 | break; 88 | case PLATFORM_WECHATMOMENTS: 89 | BMLog.d("***** "+listenerMap.size()); 90 | BMLog.d("***** "+getListener(BMPlatform.PLATFORM_WECHATMOMENTS)); 91 | // 分享到微信朋友圈 92 | if(getData(BMPlatform.PLATFORM_WECHATMOMENTS)!=null){ 93 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_WECHATMOMENTS, getListener(BMPlatform.PLATFORM_WECHATMOMENTS),getData(BMPlatform.PLATFORM_WECHATMOMENTS)); 94 | }else{ 95 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_WECHATMOMENTS, getListener(BMPlatform.PLATFORM_WECHATMOMENTS),shareData); 96 | } 97 | break; 98 | case PLATFORM_QQ: 99 | // 分享到QQ 100 | if(getData(BMPlatform.PLATFORM_QQ)!=null){ 101 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_QQ, getListener(BMPlatform.PLATFORM_QQ), getData(BMPlatform.PLATFORM_QQ)); 102 | }else{ 103 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_QQ, getListener(BMPlatform.PLATFORM_QQ), shareData); 104 | } 105 | break; 106 | case PLATFORM_QZONE: 107 | // 分享到QQ空间 108 | if(getData(BMPlatform.PLATFORM_QZONE)!=null){ 109 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_QZONE, getListener(BMPlatform.PLATFORM_QZONE), getData(BMPlatform.PLATFORM_QZONE)); 110 | }else{ 111 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_QZONE, getListener(BMPlatform.PLATFORM_QZONE), shareData); 112 | } 113 | break; 114 | case PLATFORM_TENCENTWEIBO: 115 | // 分享到腾讯微博 116 | if(getData(BMPlatform.PLATFORM_TENCENTWEIBO)!=null){ 117 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_TENCENTWEIBO, getListener(BMPlatform.PLATFORM_TENCENTWEIBO), getData(BMPlatform.PLATFORM_TENCENTWEIBO)); 118 | }else{ 119 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_TENCENTWEIBO, getListener(BMPlatform.PLATFORM_TENCENTWEIBO), shareData); 120 | } 121 | break; 122 | case PLATFORM_SINAWEIBO: 123 | // 分享到新浪微博 124 | if(getData(BMPlatform.PLATFORM_SINAWEIBO)!=null){ 125 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_SINAWEIBO, getListener(BMPlatform.PLATFORM_SINAWEIBO), getData(BMPlatform.PLATFORM_SINAWEIBO)); 126 | }else{ 127 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_SINAWEIBO, getListener(BMPlatform.PLATFORM_SINAWEIBO), shareData); 128 | } 129 | break; 130 | case PLATFORM_RENN: 131 | // 分享到人人网 132 | if(getData(BMPlatform.PLATFORM_RENN)!=null){ 133 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_RENN, getListener(BMPlatform.PLATFORM_RENN), getData(BMPlatform.PLATFORM_RENN)); 134 | }else{ 135 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_RENN, getListener(BMPlatform.PLATFORM_RENN), shareData); 136 | } 137 | break; 138 | case PLATFORM_EMAIL: 139 | // 分享到邮箱 140 | if(getData(BMPlatform.PLATFORM_EMAIL)!=null){ 141 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_EMAIL, getListener(BMPlatform.PLATFORM_EMAIL), getData(BMPlatform.PLATFORM_EMAIL)); 142 | }else{ 143 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_EMAIL, getListener(BMPlatform.PLATFORM_EMAIL), shareData); 144 | } 145 | break; 146 | case PLATFORM_MESSAGE: 147 | // 分享到短信 148 | if(getData(BMPlatform.PLATFORM_MESSAGE)!=null){ 149 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_MESSAGE, getListener(BMPlatform.PLATFORM_MESSAGE), getData(BMPlatform.PLATFORM_MESSAGE)); 150 | }else{ 151 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_MESSAGE, getListener(BMPlatform.PLATFORM_MESSAGE), shareData); 152 | } 153 | break; 154 | case PLATFORM_COPYLINK: 155 | // 复制链接 156 | if(getData(BMPlatform.PLATFORM_COPYLINK)!=null){ 157 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_COPYLINK, getListener(BMPlatform.PLATFORM_COPYLINK), getData(BMPlatform.PLATFORM_COPYLINK)); 158 | }else{ 159 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_COPYLINK, getListener(BMPlatform.PLATFORM_COPYLINK), shareData); 160 | } 161 | break; 162 | case PLATFORM_MORE_SHARE: 163 | // 更多分享 164 | if(getData(BMPlatform.PLATFORM_MORE_SHARE)!=null){ 165 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_MORE_SHARE, getListener(BMPlatform.PLATFORM_MORE_SHARE), getData(BMPlatform.PLATFORM_MORE_SHARE)); 166 | }else{ 167 | BMCore.getInstance().share(act, BMPlatform.PLATFORM_MORE_SHARE, getListener(BMPlatform.PLATFORM_MORE_SHARE), shareData); 168 | } 169 | break; 170 | 171 | default: 172 | break; 173 | } 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/view/ListPopup.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.view; 2 | 3 | import java.util.ArrayList; 4 | 5 | import cn.bmob.social.share.core.BMCore; 6 | import cn.bmob.social.share.core.data.BMPlatform; 7 | import cn.bmob.social.share.core.data.ShareData; 8 | import cn.bmob.social.share.core.util.BMLog; 9 | import cn.bmob.social.share.core.util.Util; 10 | import android.app.Activity; 11 | import android.graphics.Color; 12 | import android.graphics.drawable.BitmapDrawable; 13 | import android.view.Gravity; 14 | import android.view.View; 15 | import android.view.animation.TranslateAnimation; 16 | import android.widget.AdapterView; 17 | import android.widget.AdapterView.OnItemClickListener; 18 | import android.widget.LinearLayout; 19 | import android.widget.ListView; 20 | import android.widget.PopupWindow; 21 | import android.widget.TextView; 22 | import android.widget.Toast; 23 | 24 | public class ListPopup extends PopupWindow implements OnItemClickListener{ 25 | 26 | /** 主分享界面实例 */ 27 | protected static ListPopup instance; 28 | /**传入的activity*/ 29 | protected static Activity act; 30 | private BMShare bmShare; 31 | private ShareData shareData; 32 | private ListPopupAdapter adapter; 33 | /**用于判断分享页面是否正在运行*/ 34 | private ArrayList enList = new ArrayList(); 35 | 36 | public ListPopup(Activity act,BMShare bmShare, ShareData shareData){ 37 | this.act = act; 38 | this.bmShare = bmShare; 39 | this.shareData = shareData; 40 | instance = this; 41 | 42 | enList.add(BMPlatform.getPlatfornName(BMPlatform.PLATFORM_WECHAT)); 43 | enList.add(BMPlatform.getPlatfornName(BMPlatform.PLATFORM_WECHATMOMENTS)); 44 | enList.add(BMPlatform.getPlatfornName(BMPlatform.PLATFORM_TENCENTWEIBO)); 45 | enList.add(BMPlatform.getPlatfornName(BMPlatform.PLATFORM_EMAIL)); 46 | enList.add(BMPlatform.getPlatfornName(BMPlatform.PLATFORM_MESSAGE)); 47 | enList.add(BMPlatform.getPlatfornName(BMPlatform.PLATFORM_COPYLINK)); 48 | enList.add(BMPlatform.getPlatfornName(BMPlatform.PLATFORM_MORE_SHARE)); 49 | enList.add(BMPlatform.getPlatfornName(BMPlatform.PLATFORM_SINAWEIBO)); 50 | enList.add(BMPlatform.getPlatfornName(BMPlatform.PLATFORM_RENN)); 51 | enList.add(BMPlatform.getPlatfornName(BMPlatform.PLATFORM_QQ)); 52 | enList.add(BMPlatform.getPlatfornName(BMPlatform.PLATFORM_QZONE)); 53 | 54 | } 55 | 56 | public void show(){ 57 | LinearLayout mainLinear = new LinearLayout(act); 58 | mainLinear.setOrientation(LinearLayout.VERTICAL); 59 | 60 | LinearLayout.LayoutParams mainLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, Util.dip2px(act, 350)); 61 | mainLinear.setLayoutParams(mainLayoutParams); 62 | 63 | 64 | LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, Util.dip2px(act, 48)); 65 | TextView titleView = new TextView(act); 66 | titleView.setText("请选择分享平台"); 67 | titleView.setLayoutParams(titleParams); 68 | titleView.setGravity(Gravity.CENTER); 69 | titleView.setTextSize(14); 70 | titleView.setTextColor(Color.parseColor("#9BC7E4")); 71 | // titleView.setBackgroundColor(Color.CYAN); 72 | 73 | ListView listView = new ListView(act); 74 | LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); 75 | listView.setLayoutParams(layoutParams); 76 | 77 | adapter = new ListPopupAdapter(act, enList); 78 | listView.setAdapter(adapter); 79 | listView.setOnItemClickListener(this); 80 | 81 | LinearLayout.LayoutParams viewParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 1); 82 | 83 | View view = new View(act); 84 | View view2 = new View(act); 85 | view.setBackgroundColor(Color.GRAY); 86 | view2.setBackgroundColor(Color.GRAY); 87 | view.setLayoutParams(viewParams); 88 | view2.setLayoutParams(viewParams); 89 | 90 | mainLinear.addView(view); 91 | mainLinear.addView(titleView); 92 | mainLinear.addView(view2); 93 | mainLinear.addView(listView); 94 | 95 | // 设置popupwindow的属 96 | setFocusable(true); 97 | setOutsideTouchable(true); 98 | // setBackgroundDrawable(BMCore.res.getDrawable(BMCore.res.getIdentifier("yt_side", "drawable", BMCore.packName))); 99 | setBackgroundDrawable(new BitmapDrawable()); 100 | setContentView(mainLinear); 101 | setWidth(act.getWindowManager().getDefaultDisplay().getWidth()); 102 | setHeight(Util.dip2px(act, 350)); 103 | setAnimationStyle(android.R.style.Animation_InputMethod); 104 | 105 | showAtLocation(getContentView(), Gravity.BOTTOM, 0, 0); 106 | // BMLog.d("显示pop窗口"); 107 | 108 | } 109 | 110 | @Override 111 | public void onItemClick(AdapterView parent, View view, int position, long id) { 112 | if (Util.isNetworkConnected(act)) { 113 | this.bmShare.doListShare(BMPlatform.getBMPlatformByName(enList.get(position)), shareData); 114 | dismiss(); 115 | } else { 116 | Toast.makeText(act, "无网络连接,请查看您的网络情况", Toast.LENGTH_SHORT).show(); 117 | } 118 | 119 | } 120 | 121 | /** 122 | * 关闭分享界面 123 | */ 124 | @Override 125 | public void dismiss() { 126 | super.dismiss(); 127 | } 128 | /**关闭 分享界面*/ 129 | public static void close(){ 130 | if(instance!= null){ 131 | instance.dismiss(); 132 | } 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/view/ListPopupAdapter.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.view; 2 | 3 | import java.util.ArrayList; 4 | 5 | import junit.framework.Test; 6 | import cn.bmob.social.share.core.util.Util; 7 | import android.app.Activity; 8 | import android.view.Gravity; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.BaseAdapter; 13 | import android.widget.ImageView; 14 | import android.widget.LinearLayout; 15 | import android.widget.LinearLayout.LayoutParams; 16 | import android.widget.TextView; 17 | 18 | public class ListPopupAdapter extends BaseAdapter { 19 | 20 | private Activity act; 21 | private ArrayList list; 22 | 23 | public ListPopupAdapter(Activity act, ArrayList list){ 24 | this.act = act; 25 | this.list = list; 26 | } 27 | 28 | @Override 29 | public int getCount() { 30 | // TODO Auto-generated method stub 31 | return list.size(); 32 | } 33 | 34 | @Override 35 | public Object getItem(int position) { 36 | // TODO Auto-generated method stub 37 | return list.get(position); 38 | } 39 | 40 | @Override 41 | public long getItemId(int position) { 42 | // TODO Auto-generated method stub 43 | return position; 44 | } 45 | 46 | @Override 47 | public View getView(int position, View convertView, ViewGroup parent) { 48 | // TODO Auto-generated method stub 49 | 50 | if (convertView == null) { 51 | // LayoutInflater.from(act).inflate(YtCore.res.getIdentifier("yt_sharelist_item", "layout", YtCore.packName), null); 52 | LinearLayout mainLinear = new LinearLayout(act); 53 | mainLinear.setOrientation(LinearLayout.HORIZONTAL); 54 | mainLinear.setPadding(0, 4, 0, 4); 55 | mainLinear.setGravity(Gravity.CENTER_VERTICAL); 56 | 57 | ImageView imageView = new ImageView(act); 58 | imageView.setId(888); 59 | LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(Util.dip2px(act, 40), Util.dip2px(act, 40)); 60 | imageParams.leftMargin = 15; 61 | 62 | TextView textView = new TextView(act); 63 | textView.setId(999); 64 | textView.setPadding(18, 0, 0, 0); 65 | textView.setTextSize(14); 66 | LinearLayout.LayoutParams textViewParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); 67 | 68 | mainLinear.addView(imageView, imageParams); 69 | mainLinear.addView(textView, textViewParams); 70 | 71 | convertView = mainLinear; 72 | 73 | } 74 | 75 | ImageView imageView = (ImageView) convertView.findViewById(888); 76 | TextView textView = (TextView) convertView.findViewById(999); 77 | 78 | // 设置社交平台logo 79 | imageView.setImageResource(ShareList.getLogo(list.get(position), act)); 80 | // imageView.setImageBitmap(Util.getImageFromAssetsFile(act, "yt_more.png")); 81 | // imageView.setImageBitmap(Util.getImageFromAssetsFile(act, "yt_left_arrow.png")); 82 | // 积分textview 83 | textView.setText(ShareList.getTitle(list.get(position))); 84 | 85 | return convertView; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /BmobShareSDK/src/cn/bmob/social/share/view/ShareList.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.social.share.view; 2 | 3 | import android.content.Context; 4 | import android.content.res.Resources; 5 | 6 | /** 7 | * 获取分享平台的logo和名字 8 | * @author youtui 9 | * @since 2014/3/25 10 | */ 11 | 12 | public class ShareList { 13 | /**微信*/ 14 | public static final String WECHAT = "Wechat"; 15 | /**朋友圈*/ 16 | public static final String WECHATMOMENTS = "WechatMoments"; 17 | /**新浪微博*/ 18 | public static final String SINAWEIBO = "SinaWeibo"; 19 | /**QQ*/ 20 | public static final String QQ = "QQ"; 21 | /**QQ空间*/ 22 | public static final String QZONE = "QZone"; 23 | /**腾讯微博*/ 24 | public static final String TENCENTWEIBO = "TencentWeibo"; 25 | /**人人网*/ 26 | public static final String RENREN = "Renren"; 27 | /**短信*/ 28 | public static final String SHORTMESSAGE = "ShortMessage"; 29 | /**邮件*/ 30 | public static final String EMAIL = "Email"; 31 | /**更多分享*/ 32 | public static final String MORE_SHARE = "More"; 33 | /**复制链接*/ 34 | public static final String COPYLINK = "CopyLink"; 35 | /** 36 | * 获取分享平台的lolo 37 | * @param name 38 | * @param context 39 | * @return 40 | */ 41 | public static int getLogo(String name,Context context){ 42 | String packName = context.getPackageName(); 43 | Resources res = context.getResources(); 44 | if(WECHAT.equals(name)){ 45 | 46 | return res.getIdentifier("yt_wxact", "drawable", packName); 47 | }else if(WECHATMOMENTS.equals(name)){ 48 | 49 | return res.getIdentifier("yt_pyqact", "drawable", packName); 50 | }else if(SINAWEIBO.equals(name)){ 51 | 52 | return res.getIdentifier("yt_xinlangact", "drawable", packName); 53 | }else if(QQ.equals(name)){ 54 | 55 | return res.getIdentifier("yt_qqact", "drawable", packName); 56 | }else if(QZONE.equals(name)){ 57 | 58 | return res.getIdentifier("yt_qqkjact", "drawable", packName); 59 | }else if(TENCENTWEIBO.equals(name)){ 60 | 61 | return res.getIdentifier("yt_tengxunact", "drawable", packName); 62 | }else if(RENREN.equals(name)){ 63 | 64 | return res.getIdentifier("yt_renrenact", "drawable", packName); 65 | }else if(SHORTMESSAGE.equals(name)){ 66 | 67 | return res.getIdentifier("yt_messact", "drawable", packName); 68 | }else if(EMAIL.equals(name)){ 69 | 70 | return res.getIdentifier("yt_mailact", "drawable", packName); 71 | }else if(MORE_SHARE.equals(name)){ 72 | 73 | return res.getIdentifier("yt_more", "drawable", packName); 74 | }else if(COPYLINK.equals(name)){ 75 | return res.getIdentifier("yt_lianjieact", "drawable", packName); 76 | } 77 | return -1; 78 | } 79 | /** 80 | * 获取分享平台的名字 81 | * @param name 82 | * @return 83 | */ 84 | public static String getTitle(String name) { 85 | if(WECHAT.equals(name)){ 86 | return "微信"; 87 | }else if(WECHATMOMENTS.equals(name)){ 88 | return "微信朋友圈"; 89 | }else if(SINAWEIBO.equals(name)){ 90 | return "新浪微博"; 91 | }else if(QQ.equals(name)){ 92 | return "QQ"; 93 | }else if(QZONE.equals(name)){ 94 | return "QQ空间"; 95 | }else if(TENCENTWEIBO.equals(name)){ 96 | return "腾讯微博"; 97 | }else if(RENREN.equals(name)){ 98 | return "人人网"; 99 | }else if(SHORTMESSAGE.equals(name)){ 100 | return "短信"; 101 | }else if(EMAIL.equals(name)){ 102 | return "邮件"; 103 | }else if(MORE_SHARE.equals(name)){ 104 | return "更多"; 105 | }else if(COPYLINK.equals(name)){ 106 | return "复制链接"; 107 | } 108 | return ""; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | BmobShareSDK_Test 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 33 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 58 | 59 | 60 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 78 | 79 | 80 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/assets/youtui_sdk.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 19 | 20 | 23 | 24 | 25 | 26 | 32 | 33 | 34 | 35 | 39 | 40 | 44 | 45 | 51 | 52 | 53 | 54 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/assets/yt_left_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/assets/yt_left_arrow.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/bin/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 33 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 58 | 59 | 60 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 78 | 79 | 80 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/bin/R.txt: -------------------------------------------------------------------------------- 1 | int anim sharepopup_fade_in 0x7f040000 2 | int anim sharepopup_fade_out 0x7f040001 3 | int dimen activity_horizontal_margin 0x7f050000 4 | int dimen activity_vertical_margin 0x7f050001 5 | int drawable ic_launcher 0x7f020000 6 | int drawable yt_btn_style_alert_dialog_cancel_normal 0x7f020001 7 | int drawable yt_guide_dot_black 0x7f020002 8 | int drawable yt_guide_dot_white 0x7f020003 9 | int drawable yt_left_arrow 0x7f020004 10 | int drawable yt_lianjieact 0x7f020005 11 | int drawable yt_list_item_unselected_color_border 0x7f020006 12 | int drawable yt_list_newmessage 0x7f020007 13 | int drawable yt_loadfail 0x7f020008 14 | int drawable yt_mailact 0x7f020009 15 | int drawable yt_messact 0x7f02000a 16 | int drawable yt_more 0x7f02000b 17 | int drawable yt_pyqact 0x7f02000c 18 | int drawable yt_qqact 0x7f02000d 19 | int drawable yt_qqkjact 0x7f02000e 20 | int drawable yt_reddot 0x7f02000f 21 | int drawable yt_renrenact 0x7f020010 22 | int drawable yt_side 0x7f020011 23 | int drawable yt_tengxunact 0x7f020012 24 | int drawable yt_wxact 0x7f020013 25 | int drawable yt_xinlangact 0x7f020014 26 | int id btn_openShare 0x7f080002 27 | int id container 0x7f080000 28 | int id frameLayout1 0x7f080003 29 | int id frameLayout2 0x7f08000f 30 | int id griditem_point_tv 0x7f080016 31 | int id list_bt 0x7f080004 32 | int id logo_imageview 0x7f080015 33 | int id logo_textview 0x7f080013 34 | int id main 0x7f080001 35 | int id main_item_framelayout 0x7f08000b 36 | int id main_point_tv 0x7f08000e 37 | int id main_point_tv1 0x7f080005 38 | int id main_point_tv2 0x7f080011 39 | int id main_qq_imageview 0x7f080008 40 | int id main_sina_imageview 0x7f080007 41 | int id main_sinashare_imageview 0x7f08000d 42 | int id main_tencentwb_imageview 0x7f080009 43 | int id main_test_bt 0x7f08000c 44 | int id main_whiteviewpager_bt 0x7f080012 45 | int id mian_login_linear 0x7f080006 46 | int id pagergrid_item_framelayout 0x7f080014 47 | int id popup_bt 0x7f080010 48 | int id popup_list_line 0x7f080018 49 | int id popup_whiteviewpage_indicator_linelay 0x7f080021 50 | int id popup_whiteviewpage_viewpager 0x7f080020 51 | int id popup_whiteviewpager_line 0x7f080022 52 | int id share_viewpager 0x7f08001f 53 | int id sharelist_knowaction_btn 0x7f08001b 54 | int id sharelist_point_linelay 0x7f08001a 55 | int id sharelist_selectplatform_text 0x7f080017 56 | int id sharelist_share_list 0x7f080019 57 | int id sharelistitem_logo_image 0x7f080024 58 | int id sharelistitem_platform_text 0x7f080025 59 | int id sharelistitem_point_text 0x7f080026 60 | int id sharepager_grid 0x7f080023 61 | int id sharepopup_indicator_linelay 0x7f08001c 62 | int id sharepopup_one_iv 0x7f08001e 63 | int id sharepopup_zero_iv 0x7f08001d 64 | int id textView1 0x7f08000a 65 | int id whitepagergrid_item_framelayout 0x7f080028 66 | int id whitepagergrid_logo_imageview 0x7f080029 67 | int id whitepagergrid_logo_textview 0x7f080027 68 | int id whitepagergrid_point_tv 0x7f08002a 69 | int layout activity_main 0x7f030000 70 | int layout fragment_main 0x7f030001 71 | int layout yt_activity_main 0x7f030002 72 | int layout yt_pagergrid_item 0x7f030003 73 | int layout yt_popup_list 0x7f030004 74 | int layout yt_popup_viewpager 0x7f030005 75 | int layout yt_popup_whiteviewpager 0x7f030006 76 | int layout yt_share_pager 0x7f030007 77 | int layout yt_sharelist_item 0x7f030008 78 | int layout yt_whiteviewpager_grid_item 0x7f030009 79 | int string action_settings 0x7f060002 80 | int string app_name 0x7f060000 81 | int string hello_world 0x7f060001 82 | int style AppBaseTheme 0x7f070000 83 | int style AppTheme 0x7f070001 84 | int style YtSharePopupAnim 0x7f070002 85 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/bin/classes/.gitignore: -------------------------------------------------------------------------------- 1 | /cn/ 2 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/bin/jarlist.cache: -------------------------------------------------------------------------------- 1 | # cache for current jar dependency. DO NOT EDIT. 2 | # format is 3 | # Encoding is UTF-8 4 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/gen/.gitignore: -------------------------------------------------------------------------------- 1 | /cn/ 2 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/ic_launcher-web.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/libs/android-support-v4.jar -------------------------------------------------------------------------------- /BmobShareSDK_Test/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-14 15 | android.library.reference.1=../BmobShareSDK 16 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/anim/sharepopup_fade_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/anim/sharepopup_fade_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_btn_style_alert_dialog_cancel_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_btn_style_alert_dialog_cancel_normal.9.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_guide_dot_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_guide_dot_black.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_guide_dot_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_guide_dot_white.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_left_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_left_arrow.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_lianjieact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_lianjieact.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_list_item_unselected_color_border.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_list_newmessage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_list_newmessage.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_loadfail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_loadfail.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_mailact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_mailact.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_messact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_messact.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_more.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_pyqact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_pyqact.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_qqact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_qqact.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_qqkjact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_qqkjact.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_reddot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_reddot.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_renrenact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_renrenact.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_side.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_side.9.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_tengxunact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_tengxunact.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_wxact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_wxact.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/drawable/yt_xinlangact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-android-social-share/ff0f69e14400b60bb459ed87ff6d84deab01899f/BmobShareSDK_Test/res/drawable/yt_xinlangact.png -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | -------------------------------------------------------------------------------- /BmobShareSDK_Test/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 17 | 18 |