├── share
├── OAuth
│ ├── .gitignore
│ ├── libs
│ │ ├── open_sdk_r5886_lite.jar
│ │ ├── org.apache.http.legacy.jar
│ │ └── core-4.1.0-openDefaultRelease.aar
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ └── values
│ │ │ │ │ └── strings.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── yanxuwen
│ │ │ │ │ └── OAuth
│ │ │ │ │ ├── AuthPlatform.java
│ │ │ │ │ ├── AuthType.java
│ │ │ │ │ ├── OAuthListener.java
│ │ │ │ │ ├── OAuthPlatformListener.java
│ │ │ │ │ ├── PlatformWeixin
│ │ │ │ │ ├── WXInfo.java
│ │ │ │ │ ├── WXLogin.java
│ │ │ │ │ ├── WeixinUtils.java
│ │ │ │ │ ├── Util.java
│ │ │ │ │ ├── MyWXEntryActivity.java
│ │ │ │ │ └── WXShare.java
│ │ │ │ │ ├── OAuthID.java
│ │ │ │ │ ├── PlatformSina
│ │ │ │ │ ├── SinaLogin.java
│ │ │ │ │ ├── SinaUtils.java
│ │ │ │ │ └── SinaShare.java
│ │ │ │ │ ├── Utils
│ │ │ │ │ ├── JsonUtils.java
│ │ │ │ │ ├── HTTPSTrustManager.java
│ │ │ │ │ └── TrustAllSSLSocketFactory.java
│ │ │ │ │ ├── PlatformQQ
│ │ │ │ │ ├── QQLogin.java
│ │ │ │ │ ├── QQInfo.java
│ │ │ │ │ ├── QQUtils.java
│ │ │ │ │ └── QQShare2.java
│ │ │ │ │ └── OAuthUtils.java
│ │ │ └── AndroidManifest.xml
│ │ └── test
│ │ │ └── java
│ │ │ └── renovate
│ │ │ └── umshare
│ │ │ └── ExampleUnitTest.java
│ ├── res
│ │ └── values
│ │ │ ├── umeng_socialize_shareview_strings.xml
│ │ │ ├── umeng_socialize_colors.xml
│ │ │ ├── umeng_socialize_strings.xml
│ │ │ └── umeng_socialize_style.xml
│ ├── proguard-rules.pro
│ └── build.gradle
├── app
│ ├── .gitignore
│ ├── debug.keystore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ └── styles.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ └── layout
│ │ │ │ │ └── activity_main.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ ├── zhengchen
│ │ │ │ │ └── yixinxiangfo
│ │ │ │ │ │ └── wxapi
│ │ │ │ │ │ └── WXEntryActivity.java
│ │ │ │ │ └── yanxuwen
│ │ │ │ │ └── share
│ │ │ │ │ ├── WelcomeActivity.java
│ │ │ │ │ └── MainActivity.java
│ │ │ └── AndroidManifest.xml
│ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── yanxuwen
│ │ │ └── share
│ │ │ └── ExampleUnitTest.java
│ ├── proguard-rules.pro
│ └── build.gradle
├── settings.gradle
├── .idea
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── modules.xml
│ ├── runConfigurations.xml
│ ├── gradle.xml
│ ├── compiler.xml
│ └── misc.xml
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── .gitignore
├── build.gradle
├── gradle.properties
├── gradlew.bat
└── gradlew
└── README.md
/share/OAuth/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/share/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/share/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':OAuth'
2 |
--------------------------------------------------------------------------------
/share/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/app/debug.keystore
--------------------------------------------------------------------------------
/share/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | share
3 |
4 |
--------------------------------------------------------------------------------
/share/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/share/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/share/OAuth/libs/open_sdk_r5886_lite.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/OAuth/libs/open_sdk_r5886_lite.jar
--------------------------------------------------------------------------------
/share/OAuth/libs/org.apache.http.legacy.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/OAuth/libs/org.apache.http.legacy.jar
--------------------------------------------------------------------------------
/share/OAuth/libs/core-4.1.0-openDefaultRelease.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/OAuth/libs/core-4.1.0-openDefaultRelease.aar
--------------------------------------------------------------------------------
/share/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/share/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/share/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/share/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/share/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/share/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/share/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/share/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/share/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/share/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/share/HEAD/share/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/share/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | UMShare
3 | 文件不存在
4 |
5 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/AuthPlatform.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth;
2 |
3 | /**
4 | * Created by yanxuwen on 2017/9/22.
5 | * 授权平台
6 | */
7 |
8 | public enum AuthPlatform {
9 | QQ,WX,SINA
10 | }
11 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/AuthType.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth;
2 |
3 | /**
4 | * Created by yanxuwen on 2017/9/26.
5 | * 授权类型
6 | */
7 |
8 | public enum AuthType {
9 | LOGIN,USERINFO,SHARE
10 | }
11 |
--------------------------------------------------------------------------------
/share/app/src/main/java/com/zhengchen/yixinxiangfo/wxapi/WXEntryActivity.java:
--------------------------------------------------------------------------------
1 | package com.zhengchen.yixinxiangfo.wxapi;
2 |
3 | import com.yanxuwen.OAuth.PlatformWeixin.MyWXEntryActivity;
4 |
5 | public class WXEntryActivity extends MyWXEntryActivity {}
--------------------------------------------------------------------------------
/share/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Sep 26 17:29:54 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/share/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #FFFFFFFF
7 |
8 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/OAuthListener.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth;
2 |
3 | /**
4 | * Created by yanxuwen on 2017/9/22.
5 | */
6 |
7 | public interface OAuthListener {
8 | public void onAuthError(AuthPlatform platform,AuthType mAuthType);
9 | public void onAuthComplete(AuthPlatform mplatform,AuthType mAuthType,Object object);
10 | public void onAuthCancel(AuthPlatform platform,AuthType mAuthType);
11 | }
12 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/OAuthPlatformListener.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth;
2 |
3 | /**
4 | * Created by yanxuwen on 2017/9/22.
5 | */
6 |
7 | public interface OAuthPlatformListener {
8 | public void onPlatformError(AuthPlatform platform,AuthType mAuthType);
9 | public void onPlatformComplete(AuthPlatform platform,AuthType mAuthType,Object object);
10 | public void onPlatformCancel(AuthPlatform platform,AuthType mAuthType);
11 | }
12 |
--------------------------------------------------------------------------------
/share/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/share/app/src/main/java/com/yanxuwen/share/WelcomeActivity.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.share;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 |
7 | /**
8 | * Created by yanxuwen on 2017/9/29.
9 | */
10 |
11 | public class WelcomeActivity extends Activity{
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | startActivity(new Intent(this,MainActivity.class));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/share/OAuth/src/test/java/renovate/umshare/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package renovate.umshare;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/share/app/src/test/java/com/yanxuwen/share/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.share;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/share/OAuth/res/values/umeng_socialize_shareview_strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 分享到新浪微博
4 | 分享到豆瓣
5 | 分享到人人网
6 |
7 | 分享到腾讯微博
8 | 分享到twitter
9 | 分享到领英
10 |
--------------------------------------------------------------------------------
/share/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/share/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/share/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/share/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/share/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.1'
9 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 |
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | jcenter()
21 | maven { url "https://jitpack.io" }
22 | }
23 | }
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
--------------------------------------------------------------------------------
/share/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/PlatformWeixin/WXInfo.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.PlatformWeixin;
2 |
3 | /**
4 | * Created by yanxuwen on 2017/9/26.
5 | */
6 |
7 | public class WXInfo {
8 | /**
9 | * nickname : xxx
10 | * sex :
11 | * headimgurl : xxxx
12 | */
13 |
14 | private String nickname;
15 | private String sex;
16 | private String headimgurl;
17 |
18 | public String getNickname() {
19 | return nickname;
20 | }
21 |
22 | public void setNickname(String nickname) {
23 | this.nickname = nickname;
24 | }
25 |
26 | public String getSex() {
27 | return sex;
28 | }
29 |
30 | public void setSex(String sex) {
31 | this.sex = sex;
32 | }
33 |
34 | public String getHeadimgurl() {
35 | return headimgurl;
36 | }
37 |
38 | public void setHeadimgurl(String headimgurl) {
39 | this.headimgurl = headimgurl;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/share/OAuth/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/share/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/share/OAuth/res/values/umeng_socialize_colors.xml:
--------------------------------------------------------------------------------
1 |
2 | #F4F4F4
3 | #2c3035
4 | #333333
5 | #FFFFFF
6 | #E6E6E6
7 | #999999
8 | #464f61
9 | #959696
10 | #666666
11 | #EEEEEE
12 | #595959
13 | #C4C4C4
14 | #F8F8F8
15 | #F4F4F4
16 | #D4E0E5
17 | #ffffff
18 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/OAuthID.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth;
2 |
3 | import android.content.Context;
4 |
5 | import com.sina.weibo.sdk.WbSdk;
6 | import com.sina.weibo.sdk.auth.AuthInfo;
7 |
8 | /**
9 | * Created by yanxuwen on 2017/9/30.
10 | */
11 |
12 | public class OAuthID {
13 | public static String QQkey="";
14 | public static String WXkey="";
15 | public static String WX_secret="";
16 | public static String SINAkey="";
17 | public static String redirectUrl="";//新浪的回调地址
18 | public static final String SCOPE =
19 | "email,direct_messages_read,direct_messages_write,"
20 | + "friendships_groups_read,friendships_groups_write,statuses_to_me_read,"
21 | + "follow_app_official_microblog," + "invitation_write";
22 |
23 | /**
24 | * 配置第三方登录
25 | * @param context
26 | * @param QQ QQkey 必传
27 | * @param WX 微信 key 必传
28 | * @param WX_secret 微信secret 可选,没有传的话,只能获取code,无法获取token跟用户信息
29 | * @param SINA 新浪key 必传
30 | * @param redirectUrl 必传
31 | */
32 | public static void init(Context context,String QQ, String WX,String WX_secret, String SINA, String redirectUrl){
33 | OAuthID.QQkey=QQ;
34 | OAuthID.WXkey=WX;
35 | OAuthID.WX_secret=WX_secret;
36 | OAuthID.SINAkey=SINA;
37 | OAuthID.redirectUrl=redirectUrl;
38 | WbSdk.install(context,new AuthInfo(context,OAuthID.SINAkey,redirectUrl,OAuthID.SCOPE));
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/PlatformSina/SinaLogin.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.PlatformSina;
2 |
3 | /**
4 | * Created by yanxuwen on 2017/9/27.
5 | */
6 |
7 | public class SinaLogin {
8 | /**
9 | * uid : xxx
10 | * access_token :
11 | * expires_in :
12 | * refresh_token :
13 | * phone_num :
14 | */
15 |
16 | private String uid;
17 | private String access_token;
18 | private String expires_in;
19 | private String refresh_token;
20 | private String phone_num;
21 |
22 | public String getUid() {
23 | return uid;
24 | }
25 |
26 | public void setUid(String uid) {
27 | this.uid = uid;
28 | }
29 |
30 | public String getAccess_token() {
31 | return access_token;
32 | }
33 |
34 | public void setAccess_token(String access_token) {
35 | this.access_token = access_token;
36 | }
37 |
38 | public String getExpires_in() {
39 | return expires_in;
40 | }
41 |
42 | public void setExpires_in(String expires_in) {
43 | this.expires_in = expires_in;
44 | }
45 |
46 | public String getRefresh_token() {
47 | return refresh_token;
48 | }
49 |
50 | public void setRefresh_token(String refresh_token) {
51 | this.refresh_token = refresh_token;
52 | }
53 |
54 | public String getPhone_num() {
55 | return phone_num;
56 | }
57 |
58 | public void setPhone_num(String phone_num) {
59 | this.phone_num = phone_num;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/share/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
20 |
26 |
33 |
39 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/PlatformWeixin/WXLogin.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.PlatformWeixin;
2 |
3 | /**
4 | * Created by yanxuwen on 2017/9/26.
5 | */
6 |
7 | public class WXLogin {
8 | /**
9 | * access_token : 5_zJy4ZN-coP-NDGOSM62zBSfQQOX8dGWcSssWm1vAnpIDpe6FEKhJzJP7dqzY9rmUE0l_Epwixri1WCOu7yQji-3V18xvmQy5r0Zzz2xfSDc
10 | * expires_in : 7200
11 | * refresh_token : 5_Khpancdq5P3insUtRDzUIWcqJwXtv2UqbX9tUFhEPumHanMt2AYkrZ_e8TePCrkH7OOIIpsxVUXfcGzAtEf1jTyr0qcWgYm2fDA5YorVMd8
12 | * openid : oII-t01afhS5ZWsHCXJBmtpgqwx4
13 | * scope : snsapi_userinfo
14 | * unionid : okGoa1u_lXDdjco4yPYE71Nv3u1I
15 | */
16 | private String code;
17 | private String access_token;
18 | private int expires_in;
19 | private String refresh_token;
20 | private String openid;
21 | private String scope;
22 | private String unionid;
23 |
24 | public String getCode() {
25 | return code;
26 | }
27 |
28 | public void setCode(String code) {
29 | this.code = code;
30 | }
31 |
32 | public String getAccess_token() {
33 | return access_token;
34 | }
35 |
36 | public void setAccess_token(String access_token) {
37 | this.access_token = access_token;
38 | }
39 |
40 | public int getExpires_in() {
41 | return expires_in;
42 | }
43 |
44 | public void setExpires_in(int expires_in) {
45 | this.expires_in = expires_in;
46 | }
47 |
48 | public String getRefresh_token() {
49 | return refresh_token;
50 | }
51 |
52 | public void setRefresh_token(String refresh_token) {
53 | this.refresh_token = refresh_token;
54 | }
55 |
56 | public String getOpenid() {
57 | return openid;
58 | }
59 |
60 | public void setOpenid(String openid) {
61 | this.openid = openid;
62 | }
63 |
64 | public String getScope() {
65 | return scope;
66 | }
67 |
68 | public void setScope(String scope) {
69 | this.scope = scope;
70 | }
71 |
72 | public String getUnionid() {
73 | return unionid;
74 | }
75 |
76 | public void setUnionid(String unionid) {
77 | this.unionid = unionid;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/share/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/share/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/Utils/JsonUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014-2015 Imtoy Technologies. All rights reserved.
3 | * @charset UTF-8
4 | * @author xiongxunxiang
5 | */
6 | package com.yanxuwen.OAuth.Utils;
7 |
8 | import org.apache.http.HttpEntity;
9 | import org.apache.http.HttpResponse;
10 | import org.apache.http.client.ClientProtocolException;
11 | import org.apache.http.client.methods.HttpGet;
12 | import org.apache.http.conn.ClientConnectionManager;
13 | import org.apache.http.conn.scheme.PlainSocketFactory;
14 | import org.apache.http.conn.scheme.Scheme;
15 | import org.apache.http.conn.scheme.SchemeRegistry;
16 | import org.apache.http.impl.client.DefaultHttpClient;
17 | import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
18 | import org.apache.http.params.BasicHttpParams;
19 | import org.apache.http.params.HttpConnectionParams;
20 | import org.apache.http.params.HttpParams;
21 | import org.json.JSONException;
22 | import org.json.JSONObject;
23 |
24 | import java.io.BufferedReader;
25 | import java.io.IOException;
26 | import java.io.InputStreamReader;
27 |
28 | public class JsonUtils {
29 | public static JSONObject initSSLWithHttpClinet(String path)
30 | throws ClientProtocolException, IOException {
31 | HTTPSTrustManager.allowAllSSL();
32 | JSONObject jsonObject = null;
33 | int timeOut = 30 * 1000;
34 | HttpParams param = new BasicHttpParams();
35 | HttpConnectionParams.setConnectionTimeout(param, timeOut);
36 | HttpConnectionParams.setSoTimeout(param, timeOut);
37 | HttpConnectionParams.setTcpNoDelay(param, true);
38 |
39 | SchemeRegistry registry = new SchemeRegistry();
40 | registry.register(new Scheme("http", PlainSocketFactory .getSocketFactory(), 80));
41 | registry.register(new Scheme("https", TrustAllSSLSocketFactory .getDefault(), 443));
42 | ClientConnectionManager manager = new ThreadSafeClientConnManager( param, registry);
43 | DefaultHttpClient client = new DefaultHttpClient(manager, param);
44 |
45 | HttpGet request = new HttpGet(path);
46 | // HttpGet request = new HttpGet("https://www.alipay.com/");
47 | HttpResponse response = client.execute(request);
48 | HttpEntity entity = response.getEntity();
49 | BufferedReader reader = new BufferedReader(new InputStreamReader( entity.getContent()));
50 | StringBuilder result = new StringBuilder();
51 | String line = "";
52 | while ((line = reader.readLine()) != null) {
53 | result.append(line);
54 | try {
55 | jsonObject = new JSONObject(line);
56 | } catch (JSONException e) {
57 | e.printStackTrace();
58 | }
59 | }
60 | return jsonObject;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/share/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion "25.0.3"
6 | useLibrary 'org.apache.http.legacy'
7 | defaultConfig {
8 | applicationId "com.yanxuwen.share"
9 | minSdkVersion 15
10 | targetSdkVersion 26
11 | versionCode 1
12 | versionName "1.0"
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | }
15 |
16 | signingConfigs {
17 | debug {
18 | storeFile file("./GuangYaoTianRun.jks")
19 | storePassword "guangyaotianrun"
20 | keyAlias "shandengwanhua"
21 | keyPassword "shandengwanhua"
22 | v2SigningEnabled false
23 | }
24 | release {
25 | storeFile file("./GuangYaoTianRun.jks")
26 | storePassword "guangyaotianrun"
27 | keyAlias "shandengwanhua"
28 | keyPassword "shandengwanhua"
29 | v2SigningEnabled false
30 | }
31 | aaa {
32 | storeFile file('./debug.keystore')
33 | storePassword "android"
34 | keyAlias "androiddebugkey"
35 | keyPassword "android"
36 | }
37 | }
38 | buildTypes {
39 | debug {
40 | minifyEnabled false
41 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
42 | //签名
43 | signingConfig signingConfigs.debug
44 | }
45 | release {
46 | minifyEnabled false
47 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
48 | //签名
49 | signingConfig signingConfigs.release
50 | }
51 | aaa {
52 | minifyEnabled false
53 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
54 | //签名
55 | signingConfig signingConfigs.aaa
56 | }
57 | }
58 | productFlavors {
59 | ceshi {
60 | applicationId "com.zhengchen.yixinxiangfo"
61 | versionCode 6
62 | versionName "1.0.1"
63 | manifestPlaceholders=[
64 | tencentKey:"tencent1105929954"]
65 | }
66 | }
67 | repositories {
68 | flatDir {
69 | dirs '../OAuth/libs';dirs 'libs' // 申明本地库
70 | }
71 | }
72 | }
73 |
74 | dependencies {
75 | compile fileTree(include: ['*.jar'], dir: 'libs')
76 | testCompile 'junit:junit:4.12'
77 | compile 'com.android.support:appcompat-v7:26+'
78 | compile project(path: ':OAuth')
79 | }
80 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/PlatformWeixin/WeixinUtils.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.PlatformWeixin;
2 |
3 | import android.app.Activity;
4 | import android.widget.Toast;
5 |
6 | import com.tencent.mm.opensdk.modelmsg.SendAuth;
7 | import com.tencent.mm.opensdk.openapi.IWXAPI;
8 | import com.tencent.mm.opensdk.openapi.WXAPIFactory;
9 | import com.yanxuwen.OAuth.AuthPlatform;
10 | import com.yanxuwen.OAuth.AuthType;
11 | import com.yanxuwen.OAuth.OAuthPlatformListener;
12 |
13 | /**
14 | * Created by yanxuwen on 2017/9/26.
15 | */
16 |
17 | public class WeixinUtils implements MyWXEntryActivity.OnWXAuthListener {
18 | Activity context;
19 | AuthPlatform mplatform;
20 | private IWXAPI api;
21 | OAuthPlatformListener mOAuthPlatformListener=null;
22 | String appid="";
23 | public void setOAuthWXListener(OAuthPlatformListener l){mOAuthPlatformListener=l;}
24 | public WeixinUtils(Activity context, AuthPlatform mplatform, String appid){
25 | this.context=context;
26 | this.mplatform=mplatform;
27 | this.appid=appid;
28 | api = WXAPIFactory.createWXAPI(context,appid,false);
29 |
30 | if (!api.isWXAppInstalled()) {
31 | Toast.makeText(context,"未安装微信",Toast.LENGTH_SHORT).show();
32 | return;
33 | }
34 | // 将该app注册到微信
35 | api.registerApp(appid);
36 | MyWXEntryActivity.api=api;
37 | MyWXEntryActivity.setOnWXAuthListener(this);
38 |
39 |
40 | }
41 | public void login(String AppSecret,boolean isUserInfo) {
42 | MyWXEntryActivity.isUserInfo=isUserInfo;
43 | MyWXEntryActivity.APP_ID=appid;
44 | MyWXEntryActivity.APP_SECRET=AppSecret;
45 | final SendAuth.Req req = new SendAuth.Req();
46 | req.scope = "snsapi_userinfo";
47 | req.state = "none";
48 | api.sendReq(req);
49 | }
50 | public void getUserInfo(String AppSecret) {
51 | MyWXEntryActivity.APP_ID=appid;
52 | MyWXEntryActivity.APP_SECRET=AppSecret;
53 | login(AppSecret,true);
54 | }
55 | @Override
56 | public void onWXAuthError(AuthType mAuthType) {
57 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformError(mplatform,mAuthType);
58 | }
59 |
60 | @Override
61 | public void onWXAuthComplete(AuthType mAuthType, Object object) {
62 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformComplete(mplatform,mAuthType,object);
63 | }
64 |
65 | @Override
66 | public void onWXAuthCancel(AuthType mAuthType) {
67 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformCancel(mplatform,mAuthType);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/share/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/Utils/HTTPSTrustManager.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.Utils;
2 | import java.security.KeyManagementException;
3 | import java.security.NoSuchAlgorithmException;
4 | import java.security.SecureRandom;
5 | import java.security.cert.X509Certificate;
6 |
7 | import javax.net.ssl.HostnameVerifier;
8 | import javax.net.ssl.HttpsURLConnection;
9 | import javax.net.ssl.SSLContext;
10 | import javax.net.ssl.SSLSession;
11 | import javax.net.ssl.TrustManager;
12 | import javax.net.ssl.X509TrustManager;
13 | public class HTTPSTrustManager implements X509TrustManager {
14 |
15 | private static TrustManager[] trustManagers;
16 | private static final X509Certificate[] _AcceptedIssuers = new X509Certificate[] {};
17 |
18 | /**
19 | * 该方法检查客户端的证书,若不信任该证书则抛出异常。由于我们不需要对客户端进行认证,
20 | * 因此我们只需要执行默认的信任管理器的这个方法。JSSE中,默认的信任管理器类为TrustManager。
21 | */
22 | @Override
23 | public void checkClientTrusted(
24 | X509Certificate[] x509Certificates, String s)
25 | throws java.security.cert.CertificateException {
26 | // To change body of implemented methods use File | Settings | File
27 | // Templates.
28 | }
29 |
30 | /**
31 | * 该方法检查服务器的证书,若不信任该证书同样抛出异常。通过自己实现该方法,可以使之信任我们指定的任何证书。在实现该方法时,
32 | * 也可以简单的不做任何处理,即一个空的函数体,由于不会抛出异常,它就会信任任何证书。
33 | */
34 | @Override
35 | public void checkServerTrusted(
36 | X509Certificate[] x509Certificates, String s)
37 | throws java.security.cert.CertificateException {
38 | // To change body of implemented methods use File | Settings | File
39 | // Templates.
40 | }
41 |
42 | public boolean isClientTrusted(X509Certificate[] chain) {
43 | return true;
44 | }
45 |
46 | public boolean isServerTrusted(X509Certificate[] chain) {
47 | return true;
48 | }
49 |
50 | @Override
51 | public X509Certificate[] getAcceptedIssuers() {
52 | return _AcceptedIssuers;
53 | }
54 |
55 | public static void allowAllSSL() {
56 | HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
57 |
58 | @Override
59 | public boolean verify(String arg0, SSLSession arg1) {
60 | return true;
61 | }
62 |
63 | });
64 |
65 | SSLContext context = null;
66 | if (trustManagers == null) {
67 | trustManagers = new TrustManager[] { new HTTPSTrustManager() };
68 | }
69 |
70 | try {
71 | context = SSLContext.getInstance("TLS");
72 | context.init(null, trustManagers, new SecureRandom());
73 | } catch (NoSuchAlgorithmException e) {
74 | e.printStackTrace();
75 | } catch (KeyManagementException e) {
76 | e.printStackTrace();
77 | }
78 |
79 | HttpsURLConnection.setDefaultSSLSocketFactory(context
80 | .getSocketFactory());
81 | }
82 |
83 | }
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/PlatformQQ/QQLogin.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.PlatformQQ;
2 |
3 | /**
4 | * Created by yanxuwen on 2017/9/22.
5 | */
6 |
7 | public class QQLogin {
8 | /**
9 | * ret : 0
10 | * openid : 388DE9F0094D621F86649423FFE81D53
11 | * access_token : A457EDE37E808FC1DBBF8D257ADB2F62
12 | * pay_token : 19B82CDEE8D6BD01F69CE93CF9DC841E
13 | * expires_in : 7776000
14 | * pf : desktop_m_qq-10000144-android-2002-
15 | * pfkey : d7bd80600af149138050e8fc6c9a310e
16 | * msg :
17 | * login_cost : 90
18 | * query_authority_cost : 247
19 | * authority_cost : 0
20 | */
21 |
22 | private String ret;
23 | private String openid;
24 | private String access_token;
25 | private String pay_token;
26 | private String expires_in;
27 | private String pf;
28 | private String pfkey;
29 | private String msg;
30 | private String login_cost;
31 | private String query_authority_cost;
32 | private String authority_cost;
33 |
34 | public String getRet() {
35 | return ret;
36 | }
37 |
38 | public void setRet(String ret) {
39 | this.ret = ret;
40 | }
41 |
42 | public String getOpenid() {
43 | return openid;
44 | }
45 |
46 | public void setOpenid(String openid) {
47 | this.openid = openid;
48 | }
49 |
50 | public String getAccess_token() {
51 | return access_token;
52 | }
53 |
54 | public void setAccess_token(String access_token) {
55 | this.access_token = access_token;
56 | }
57 |
58 | public String getPay_token() {
59 | return pay_token;
60 | }
61 |
62 | public void setPay_token(String pay_token) {
63 | this.pay_token = pay_token;
64 | }
65 |
66 | public String getExpires_in() {
67 | return expires_in;
68 | }
69 |
70 | public void setExpires_in(String expires_in) {
71 | this.expires_in = expires_in;
72 | }
73 |
74 | public String getPf() {
75 | return pf;
76 | }
77 |
78 | public void setPf(String pf) {
79 | this.pf = pf;
80 | }
81 |
82 | public String getPfkey() {
83 | return pfkey;
84 | }
85 |
86 | public void setPfkey(String pfkey) {
87 | this.pfkey = pfkey;
88 | }
89 |
90 | public String getMsg() {
91 | return msg;
92 | }
93 |
94 | public void setMsg(String msg) {
95 | this.msg = msg;
96 | }
97 |
98 | public String getLogin_cost() {
99 | return login_cost;
100 | }
101 |
102 | public void setLogin_cost(String login_cost) {
103 | this.login_cost = login_cost;
104 | }
105 |
106 | public String getQuery_authority_cost() {
107 | return query_authority_cost;
108 | }
109 |
110 | public void setQuery_authority_cost(String query_authority_cost) {
111 | this.query_authority_cost = query_authority_cost;
112 | }
113 |
114 | public String getAuthority_cost() {
115 | return authority_cost;
116 | }
117 |
118 | public void setAuthority_cost(String authority_cost) {
119 | this.authority_cost = authority_cost;
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/share/OAuth/res/values/umeng_socialize_strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 12dip
5 | 350dip
6 | 580dip
7 |
8 | 腾讯微博
9 | 微信收藏
10 | 微博
11 | QQ
12 | QQ空间
13 | 人人网
14 | 豆瓣
15 | 微信
16 | 微信朋友圈
17 | 微信收藏
18 | 请配置用户平台
19 | 社交分享
20 | 分享中…
21 | 说点啥…
22 | 取消
23 | 发送
24 |
25 | 女
26 | 男
27 |
28 | 分享
29 |
30 | 邮件
31 | 短信
32 | 新浪
33 | 易信
34 | 易信朋友圈
35 |
36 | 点点虫动态
37 | 印象笔记
38 | 有道云笔记
39 | Facebook
40 | Facebook Messager
41 | Twitter
42 | Instagram
43 | Pinterest
44 | Pocket
45 | Linkedin
46 | Foursquare
47 | WhatsApp
48 | LINE
49 | Flickr
50 | Tumblr
51 | 支付宝
52 | KakaoTalk
53 | GooglePlus
54 | 更多
55 | 钉钉
56 | VKontakte
57 | DropBox
58 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/PlatformSina/SinaUtils.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.PlatformSina;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 |
6 | import com.sina.weibo.sdk.WbSdk;
7 | import com.sina.weibo.sdk.api.WeiboMultiMessage;
8 | import com.sina.weibo.sdk.auth.AccessTokenKeeper;
9 | import com.sina.weibo.sdk.auth.AuthInfo;
10 | import com.sina.weibo.sdk.auth.Oauth2AccessToken;
11 | import com.sina.weibo.sdk.auth.WbConnectErrorMessage;
12 | import com.sina.weibo.sdk.auth.sso.SsoHandler;
13 | import com.sina.weibo.sdk.share.WbShareHandler;
14 | import com.tencent.connect.common.Constants;
15 | import com.tencent.tauth.Tencent;
16 | import com.yanxuwen.OAuth.AuthPlatform;
17 | import com.yanxuwen.OAuth.AuthType;
18 | import com.yanxuwen.OAuth.OAuthPlatformListener;
19 |
20 | /**
21 | * Created by yanxuwen on 2017/9/26.
22 | */
23 |
24 | public class SinaUtils {
25 | public final String SCOPE =
26 | "email,direct_messages_read,direct_messages_write,"
27 | + "friendships_groups_read,friendships_groups_write,statuses_to_me_read,"
28 | + "follow_app_official_microblog," + "invitation_write";
29 | Activity context;
30 | AuthPlatform mplatform;
31 | /** 注意:SsoHandler 仅当 SDK 支持 SSO 时有效 */
32 | private SsoHandler mSsoHandler;
33 | private Oauth2AccessToken mAccessToken;
34 |
35 | OAuthPlatformListener mOAuthPlatformListener=null;
36 | String appid="";
37 | public void setOAuthWXListener(OAuthPlatformListener l){mOAuthPlatformListener=l;}
38 | public SinaUtils(Activity context, AuthPlatform mplatform, String appid,String redirectUrl){
39 | this.context=context;
40 | this.mplatform=mplatform;
41 | this.appid=appid;
42 | mSsoHandler = new SsoHandler(context);
43 |
44 |
45 | }
46 | public void login() {
47 | mSsoHandler.authorize(new SelfWbAuthListener());
48 | }
49 | public void onActivityResult(int requestCode, int resultCode, Intent data){
50 | if (mSsoHandler != null) {
51 | mSsoHandler.authorizeCallBack(requestCode, resultCode, data);
52 | }
53 | }
54 | private class SelfWbAuthListener implements com.sina.weibo.sdk.auth.WbAuthListener{
55 | @Override
56 | public void onSuccess(final Oauth2AccessToken token) {
57 | context.runOnUiThread(new Runnable() {
58 | @Override
59 | public void run() {
60 | mAccessToken = token;
61 | if (mAccessToken.isSessionValid()) {
62 | // 保存 Token 到 SharedPreferences
63 | AccessTokenKeeper.writeAccessToken(context, mAccessToken);
64 | SinaLogin mSinaLogin=new SinaLogin();
65 | mSinaLogin.setUid(token.getUid());
66 | mSinaLogin.setAccess_token(token.getToken());
67 | mSinaLogin.setRefresh_token(token.getRefreshToken());
68 | mSinaLogin.setExpires_in(token.getExpiresTime()+"");
69 | mSinaLogin.setPhone_num(token.getPhoneNum());
70 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformComplete(mplatform, AuthType.LOGIN,mSinaLogin);
71 | }
72 | }
73 | });
74 | }
75 |
76 | @Override
77 | public void cancel() {
78 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformCancel(mplatform,AuthType.LOGIN);
79 | }
80 |
81 | @Override
82 | public void onFailure(WbConnectErrorMessage errorMessage) {
83 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformError(mplatform,AuthType.LOGIN);
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/Utils/TrustAllSSLSocketFactory.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.Utils;
2 |
3 | import android.os.Build;
4 |
5 | import org.apache.http.conn.scheme.SocketFactory;
6 | import org.apache.http.conn.ssl.SSLSocketFactory;
7 | import org.apache.http.conn.ssl.X509HostnameVerifier;
8 |
9 | import java.io.IOException;
10 | import java.lang.reflect.Field;
11 | import java.net.InetAddress;
12 | import java.net.Socket;
13 | import java.net.UnknownHostException;
14 | import java.security.KeyManagementException;
15 | import java.security.KeyStoreException;
16 | import java.security.NoSuchAlgorithmException;
17 | import java.security.UnrecoverableKeyException;
18 | import java.security.cert.CertificateException;
19 | import java.security.cert.X509Certificate;
20 |
21 | import javax.net.ssl.SSLContext;
22 | import javax.net.ssl.SSLException;
23 | import javax.net.ssl.SSLSession;
24 | import javax.net.ssl.SSLSocket;
25 | import javax.net.ssl.TrustManager;
26 | import javax.net.ssl.X509TrustManager;
27 |
28 | /**
29 | *
30 |
31 | */
32 | public class TrustAllSSLSocketFactory extends SSLSocketFactory {
33 |
34 | private javax.net.ssl.SSLSocketFactory factory;
35 | private static TrustAllSSLSocketFactory instance;
36 |
37 | private TrustAllSSLSocketFactory() throws KeyManagementException, UnrecoverableKeyException,
38 | NoSuchAlgorithmException, KeyStoreException {
39 | super(null);
40 |
41 | SSLContext context = SSLContext.getInstance("TLS");
42 | context.init(null, new TrustManager[] { new TrustAllManager() }, null);
43 | factory = context.getSocketFactory();
44 | setHostnameVerifier(new X509HostnameVerifier() {
45 |
46 | @Override
47 | public void verify(String host, String[] cns, String[] subjectAlts) throws SSLException {
48 |
49 | }
50 |
51 | @Override
52 | public void verify(String host, X509Certificate cert) throws SSLException {
53 |
54 | }
55 |
56 | @Override
57 | public void verify(String host, SSLSocket ssl) throws IOException {
58 |
59 | }
60 |
61 | @Override
62 | public boolean verify(String host, SSLSession session) {
63 | return true;
64 | }
65 | });
66 | }
67 |
68 | public static SocketFactory getDefault() {
69 | if (instance == null) {
70 | try {
71 | instance = new TrustAllSSLSocketFactory();
72 | } catch (Exception e) {
73 | e.printStackTrace();
74 | }
75 | }
76 | return instance;
77 | }
78 |
79 | @Override
80 | public Socket createSocket() throws IOException {
81 | return factory.createSocket();
82 | }
83 |
84 | @Override
85 | public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
86 | throws IOException, UnknownHostException {
87 | if (Build.VERSION.SDK_INT < 11) { // 3.0
88 | injectHostname(socket, host);
89 | }
90 |
91 | return factory.createSocket(socket, host, port, autoClose);
92 | }
93 |
94 | private void injectHostname(Socket socket, String host) {
95 | try {
96 | Field field = InetAddress.class.getDeclaredField("hostName");
97 | field.setAccessible(true);
98 | field.set(socket.getInetAddress(), host);
99 | } catch (Exception ignored) {
100 | }
101 | }
102 |
103 | public class TrustAllManager implements X509TrustManager {
104 |
105 | @Override
106 | public void checkClientTrusted(X509Certificate[] arg0, String arg1)
107 | throws CertificateException {
108 |
109 | }
110 |
111 | @Override
112 | public void checkServerTrusted(X509Certificate[] arg0, String arg1)
113 | throws CertificateException {
114 |
115 | }
116 |
117 | @Override
118 | public X509Certificate[] getAcceptedIssuers() {
119 | return null;
120 | }
121 | }
122 |
123 | }
--------------------------------------------------------------------------------
/share/OAuth/res/values/umeng_socialize_style.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
18 |
19 |
25 |
26 |
36 |
37 |
38 |
48 |
49 |
50 |
54 |
55 |
56 |
57 |
62 |
63 |
70 |
71 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/share/OAuth/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | //配置插件
4 | apply plugin: 'com.github.dcendents.android-maven'
5 | apply plugin: 'com.jfrog.bintray'
6 | version = "1.0.0"
7 |
8 | android {
9 | compileSdkVersion 25
10 | buildToolsVersion "25.0.0"
11 | defaultConfig {
12 | minSdkVersion 15
13 | targetSdkVersion 25
14 | versionCode 1
15 | versionName "1.0"
16 |
17 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
18 |
19 | }
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | repositories {
27 | flatDir {
28 | dirs 'libs'
29 | }
30 | }
31 | }
32 |
33 | dependencies {
34 | compile fileTree(include: ['*.jar'], dir: 'libs')
35 | testCompile 'junit:junit:4.12'
36 | compile 'com.android.support:appcompat-v7:25+'
37 | compile 'com.google.code.gson:gson:2.8.2'
38 | compile 'com.google.code.gson:gson-parent:2.8.2'
39 | //微信第三方
40 | compile 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+'
41 | //微博第三方
42 | compile 'com.sina.weibo.sdk:core:4.1.0:openDefaultRelease@aar'
43 | }
44 | def siteUrl = 'https://github.com/yanxuwen/OAuth' // 项目的主页 这个是说明,可随便填
45 | def gitUrl = 'https://github.com/yanxuwen/OAuth.git' // Git仓库的url 这个是说明,可随便填
46 | group = "com.yanxuwen.OAuth" // 这里是groupId ,必须填写 一般填你唯一的包名
47 |
48 | install {
49 | repositories.mavenInstaller {
50 | // This generates POM.xml with proper parameters
51 | pom {
52 | project {
53 | packaging 'aar'
54 | // Add your description here
55 | name 'this is a OAuth' //项目描述
56 | url siteUrl
57 | // Set your license
58 | licenses {
59 | license {
60 | name 'The Apache Software License, Version 2.0'
61 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
62 | }
63 | }
64 | developers {
65 | developer {
66 | id 'yxe' //填写开发者的一些基本信息
67 | name 'yanxuwen' //填写开发者的一些基本信息
68 | email '420255048@qq.com' //填写开发者的一些基本信息
69 | }
70 | }
71 | scm {
72 | connection gitUrl
73 | developerConnection gitUrl
74 | url siteUrl
75 | }
76 | }
77 | }
78 | }
79 | }
80 |
81 | task sourcesJar(type: Jar) {
82 | from android.sourceSets.main.java.srcDirs
83 | classifier = 'sources'
84 | }
85 | task javadoc(type: Javadoc) {
86 | source = android.sourceSets.main.java.srcDirs
87 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
88 | }
89 | task javadocJar(type: Jar, dependsOn: javadoc) {
90 | classifier = 'javadoc'
91 | from javadoc.destinationDir
92 | }
93 | artifacts {
94 | archives javadocJar
95 | archives sourcesJar
96 | }
97 |
98 | Properties properties = new Properties()
99 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
100 | bintray {
101 | user = properties.getProperty("bintray.user") //读取 local.properties 文件里面的 bintray.user
102 | key = properties.getProperty("bintray.apikey") //读取 local.properties 文件里面的 bintray.apikey
103 | configurations = ['archives']
104 | pkg {
105 | repo = "maven"
106 | name = "OAuth" //发布到JCenter上的项目名字,必须填写
107 | websiteUrl = siteUrl
108 | vcsUrl = gitUrl
109 | licenses = ["Apache-2.0"]
110 | publish = true
111 | }
112 | }
113 | javadoc {
114 | options{
115 | encoding "UTF-8"
116 | charSet 'UTF-8'
117 | author true
118 | version true
119 | links "http://docs.oracle.com/javase/7/docs/api"
120 | }
121 | }
122 |
123 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/PlatformQQ/QQInfo.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.PlatformQQ;
2 |
3 | /**
4 | * Created by yanxuwen on 2017/9/22.
5 | */
6 |
7 | public class QQInfo {
8 |
9 | /**
10 | * ret : 0
11 | * msg :
12 | * is_lost : 0
13 | * nickname : 歇斯底里,的苦笑
14 | * gender : 男
15 | * province : 福建
16 | * city : 漳州
17 | * figureurl : http://qzapp.qlogo.cn/qzapp/1105929954/388DE9F0094D621F86649423FFE81D53/30
18 | * figureurl_1 : http://qzapp.qlogo.cn/qzapp/1105929954/388DE9F0094D621F86649423FFE81D53/50
19 | * figureurl_2 : http://qzapp.qlogo.cn/qzapp/1105929954/388DE9F0094D621F86649423FFE81D53/100
20 | * figureurl_qq_1 : http://q.qlogo.cn/qqapp/1105929954/388DE9F0094D621F86649423FFE81D53/40
21 | * figureurl_qq_2 : http://q.qlogo.cn/qqapp/1105929954/388DE9F0094D621F86649423FFE81D53/100
22 | * is_yellow_vip : 1
23 | * vip : 1
24 | * yellow_vip_level : 7
25 | * level : 7
26 | * is_yellow_year_vip : 0
27 | */
28 |
29 | private String ret;
30 | private String msg;
31 | private String is_lost;
32 | private String nickname;
33 | private String gender;
34 | private String province;
35 | private String city;
36 | private String figureurl;
37 | private String figureurl_1;
38 | private String figureurl_2;
39 | private String figureurl_qq_1;
40 | private String figureurl_qq_2;
41 | private String is_yellow_vip;
42 | private String vip;
43 | private String yellow_vip_level;
44 | private String level;
45 | private String is_yellow_year_vip;
46 |
47 | public String getRet() {
48 | return ret;
49 | }
50 |
51 | public void setRet(String ret) {
52 | this.ret = ret;
53 | }
54 |
55 | public String getMsg() {
56 | return msg;
57 | }
58 |
59 | public void setMsg(String msg) {
60 | this.msg = msg;
61 | }
62 |
63 | public String getIs_lost() {
64 | return is_lost;
65 | }
66 |
67 | public void setIs_lost(String is_lost) {
68 | this.is_lost = is_lost;
69 | }
70 |
71 | public String getNickname() {
72 | return nickname;
73 | }
74 |
75 | public void setNickname(String nickname) {
76 | this.nickname = nickname;
77 | }
78 |
79 | public String getGender() {
80 | return gender;
81 | }
82 |
83 | public void setGender(String gender) {
84 | this.gender = gender;
85 | }
86 |
87 | public String getProvince() {
88 | return province;
89 | }
90 |
91 | public void setProvince(String province) {
92 | this.province = province;
93 | }
94 |
95 | public String getCity() {
96 | return city;
97 | }
98 |
99 | public void setCity(String city) {
100 | this.city = city;
101 | }
102 |
103 | public String getFigureurl() {
104 | return figureurl;
105 | }
106 |
107 | public void setFigureurl(String figureurl) {
108 | this.figureurl = figureurl;
109 | }
110 |
111 | public String getFigureurl_1() {
112 | return figureurl_1;
113 | }
114 |
115 | public void setFigureurl_1(String figureurl_1) {
116 | this.figureurl_1 = figureurl_1;
117 | }
118 |
119 | public String getFigureurl_2() {
120 | return figureurl_2;
121 | }
122 |
123 | public void setFigureurl_2(String figureurl_2) {
124 | this.figureurl_2 = figureurl_2;
125 | }
126 |
127 | public String getFigureurl_qq_1() {
128 | return figureurl_qq_1;
129 | }
130 |
131 | public void setFigureurl_qq_1(String figureurl_qq_1) {
132 | this.figureurl_qq_1 = figureurl_qq_1;
133 | }
134 |
135 | public String getFigureurl_qq_2() {
136 | return figureurl_qq_2;
137 | }
138 |
139 | public void setFigureurl_qq_2(String figureurl_qq_2) {
140 | this.figureurl_qq_2 = figureurl_qq_2;
141 | }
142 |
143 | public String getIs_yellow_vip() {
144 | return is_yellow_vip;
145 | }
146 |
147 | public void setIs_yellow_vip(String is_yellow_vip) {
148 | this.is_yellow_vip = is_yellow_vip;
149 | }
150 |
151 | public String getVip() {
152 | return vip;
153 | }
154 |
155 | public void setVip(String vip) {
156 | this.vip = vip;
157 | }
158 |
159 | public String getYellow_vip_level() {
160 | return yellow_vip_level;
161 | }
162 |
163 | public void setYellow_vip_level(String yellow_vip_level) {
164 | this.yellow_vip_level = yellow_vip_level;
165 | }
166 |
167 | public String getLevel() {
168 | return level;
169 | }
170 |
171 | public void setLevel(String level) {
172 | this.level = level;
173 | }
174 |
175 | public String getIs_yellow_year_vip() {
176 | return is_yellow_year_vip;
177 | }
178 |
179 | public void setIs_yellow_year_vip(String is_yellow_year_vip) {
180 | this.is_yellow_year_vip = is_yellow_year_vip;
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/share/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/PlatformSina/SinaShare.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.PlatformSina;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.graphics.Bitmap;
6 | import android.graphics.BitmapFactory;
7 | import android.graphics.drawable.BitmapDrawable;
8 | import android.media.ThumbnailUtils;
9 | import android.net.Uri;
10 | import android.os.Environment;
11 | import android.util.Patterns;
12 |
13 | import com.sina.weibo.sdk.api.ImageObject;
14 | import com.sina.weibo.sdk.api.TextObject;
15 | import com.sina.weibo.sdk.api.VideoSourceObject;
16 | import com.sina.weibo.sdk.api.WebpageObject;
17 | import com.sina.weibo.sdk.api.WeiboMultiMessage;
18 | import com.sina.weibo.sdk.share.WbShareCallback;
19 | import com.sina.weibo.sdk.share.WbShareHandler;
20 | import com.sina.weibo.sdk.utils.Utility;
21 | import com.tencent.connect.share.QQShare;
22 | import com.tencent.tauth.Tencent;
23 | import com.yanxuwen.OAuth.AuthPlatform;
24 | import com.yanxuwen.OAuth.AuthType;
25 | import com.yanxuwen.OAuth.OAuthPlatformListener;
26 | import com.yanxuwen.OAuth.PlatformQQ.QQShare2;
27 |
28 | import java.io.File;
29 |
30 | /**
31 | * Created by yanxuwen on 2017/9/29.
32 | */
33 |
34 | public class SinaShare implements WbShareCallback {
35 | private static final int THUMB_SIZE = 100;
36 | WbShareHandler shareHandler;
37 | Activity activity;
38 | OAuthPlatformListener mOAuthPlatformListener=null;
39 | public void setShareSinaListener(OAuthPlatformListener l){mOAuthPlatformListener=l;}
40 | public SinaShare(Activity activity){
41 | this.activity=activity;
42 | shareHandler = new WbShareHandler(activity);
43 | shareHandler.registerApp();
44 | shareHandler.setProgressColor(0xff33b5e5);
45 |
46 | }
47 | public void onNewIntent(Intent intent) {
48 | shareHandler.doResultIntent(intent,this);
49 | }
50 |
51 | /**
52 | * 分享默认的,也就是图文消息
53 | * @param title 标题
54 | * @param text 文本
55 | * @param actionUrl 跳转url
56 | * @param bitmap 图片
57 | */
58 | public void shareDefault(String title,String text,String actionUrl,Bitmap bitmap){
59 | TextObject textObject = new TextObject();
60 | textObject.text =text;
61 | textObject.title =title;
62 | textObject.actionUrl = actionUrl;
63 |
64 | ImageObject imageObject = new ImageObject();
65 | imageObject.setImageObject(bitmap);
66 |
67 | WeiboMultiMessage weiboMessage = new WeiboMultiMessage();
68 | weiboMessage.textObject = textObject;
69 | weiboMessage.imageObject = imageObject;
70 | shareHandler.shareMessage(weiboMessage, false);
71 | }
72 | /**
73 | * 分享文本消息对象。
74 | * @param title 标题
75 | * @param text 文本
76 | * @param actionUrl 跳转url
77 | */
78 | public void shareText(String title,String text,String actionUrl) {
79 | TextObject textObject = new TextObject();
80 | textObject.text =text;
81 | textObject.title =title;
82 | textObject.actionUrl = actionUrl;
83 | WeiboMultiMessage weiboMessage = new WeiboMultiMessage();
84 | weiboMessage.textObject = textObject;
85 | shareHandler.shareMessage(weiboMessage, false);
86 | }
87 | /**
88 | * 分享图片
89 | * @param bitmap 图片
90 | */
91 | public void shareImage(Bitmap bitmap) {
92 | ImageObject imageObject = new ImageObject();
93 | imageObject.setImageObject(bitmap);
94 | WeiboMultiMessage weiboMessage = new WeiboMultiMessage();
95 | weiboMessage.imageObject = imageObject;
96 | shareHandler.shareMessage(weiboMessage, false);
97 | }
98 | /**
99 | * 创建多媒体(网页)消息对象。
100 | *
101 | * @return 多媒体(网页)消息对象。
102 | */
103 | private void shareWeb(String title,String description,String defaultText,String actionUrl,Bitmap bitmap) {
104 | WebpageObject mediaObject = new WebpageObject();
105 | mediaObject.identify = Utility.generateGUID();
106 | mediaObject.title =title;
107 | mediaObject.description = description;
108 | //压缩图片
109 | Bitmap thumbBmp = Bitmap.createScaledBitmap(bitmap, THUMB_SIZE, THUMB_SIZE, true);
110 | mediaObject.setThumbImage(thumbBmp);
111 | mediaObject.actionUrl =actionUrl;
112 | mediaObject.defaultText = defaultText;
113 | WeiboMultiMessage weiboMessage = new WeiboMultiMessage();
114 | weiboMessage.mediaObject = mediaObject;
115 | shareHandler.shareMessage(weiboMessage, false);
116 | }
117 |
118 | /**
119 | * 分享视频
120 | * @param title 标题
121 | * @param description 描述
122 | * @param uri 视频地址
123 | */
124 | private void shareVideo(String title,String description,Uri uri){
125 | VideoSourceObject videoSourceObject = new VideoSourceObject();
126 | videoSourceObject.identify = Utility.generateGUID();
127 | videoSourceObject.title =title;
128 | videoSourceObject.description = description;
129 | //获取视频
130 | videoSourceObject.videoPath =uri;
131 | WeiboMultiMessage weiboMessage = new WeiboMultiMessage();
132 | weiboMessage.mediaObject = videoSourceObject;
133 | shareHandler.shareMessage(weiboMessage, false);
134 |
135 | }
136 |
137 | @Override
138 | public void onWbShareSuccess() {
139 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformComplete(AuthPlatform.SINA, AuthType.SHARE,"");
140 | }
141 |
142 | @Override
143 | public void onWbShareCancel() {
144 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformCancel(AuthPlatform.SINA, AuthType.SHARE);
145 |
146 | }
147 |
148 | @Override
149 | public void onWbShareFail() {
150 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformError(AuthPlatform.SINA, AuthType.SHARE);
151 |
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/PlatformQQ/QQUtils.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.PlatformQQ;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.widget.Toast;
6 |
7 | import com.google.gson.Gson;
8 | import com.tencent.connect.UserInfo;
9 | import com.tencent.connect.common.Constants;
10 | import com.tencent.tauth.IUiListener;
11 | import com.tencent.tauth.Tencent;
12 | import com.tencent.tauth.UiError;
13 |
14 | import org.json.JSONObject;
15 |
16 | import com.yanxuwen.OAuth.AuthPlatform;
17 | import com.yanxuwen.OAuth.AuthType;
18 | import com.yanxuwen.OAuth.OAuthPlatformListener;
19 |
20 | /**
21 | * Created by yanxuwen on 2017/9/22.
22 | */
23 |
24 | public class QQUtils {
25 | private Tencent mTencent; //qq主操作对象
26 | LoginIUiListener loginListener ;
27 | UserInfoIUiListener userInfoListener ;
28 |
29 | Activity context;
30 | AuthPlatform mplatform;
31 | OAuthPlatformListener mOAuthPlatformListener=null;
32 | public void setOAuthQQListener(OAuthPlatformListener l){mOAuthPlatformListener=l;}
33 |
34 | public QQUtils(Activity context, AuthPlatform mplatform, String appid){
35 | this.context=context;
36 | this.mplatform=mplatform;
37 | mTencent = Tencent.createInstance(appid,context);
38 | loginListener=new LoginIUiListener();
39 | userInfoListener=new UserInfoIUiListener();
40 | }
41 | public void login() {
42 | login(false);
43 | }
44 | public void login(boolean isUserInfo) {
45 | //如果session无效,就开始登录
46 | if (!mTencent.isSessionValid()) {
47 | loginListener.setIsUserInfo(isUserInfo);
48 | //开始qq授权登录
49 | mTencent.login(context, "all", loginListener);
50 | }else if(isUserInfo){
51 | getUserInfo();
52 | }
53 | }
54 | private void getUserInfo(){
55 | if(mTencent.getQQToken()!=null){
56 | UserInfo info = new UserInfo(context,mTencent.getQQToken());
57 | info.getUserInfo(userInfoListener);
58 | }else{
59 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformError(mplatform,AuthType.USERINFO);
60 | }
61 |
62 | }
63 | public IUiListener getIUiListener(){
64 | return loginListener;
65 | }
66 | public void onActivityResult(int requestCode, int resultCode, Intent data){
67 | if (requestCode == Constants.REQUEST_LOGIN) {
68 | Tencent.handleResultData(data, getIUiListener());
69 | }
70 | }
71 | public class LoginIUiListener implements IUiListener {
72 | boolean isUserInfo;
73 | public void setIsUserInfo(boolean isUserInfo){
74 | this.isUserInfo=isUserInfo;
75 | }
76 | @Override
77 | public void onError(UiError arg0) {
78 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformError(mplatform,AuthType.LOGIN);
79 |
80 | }
81 | @Override
82 | public void onComplete(Object value) {
83 | if (value == null) {
84 | return;
85 | }
86 | try {
87 | JSONObject jo = (JSONObject) value;
88 | int ret = jo.getInt("ret");
89 |
90 | if (ret == 0) {
91 | Gson gson =new Gson();
92 | QQLogin mQQLogin=gson.fromJson(jo.toString(),QQLogin.class);
93 | String openID = mQQLogin.getOpenid();
94 | String accessToken =mQQLogin.getAccess_token();
95 | String expires = mQQLogin.getExpires_in()+"";
96 | mTencent.setOpenId(openID);
97 | mTencent.setAccessToken(accessToken, expires);
98 | if(isUserInfo){
99 | getUserInfo();
100 | }else{
101 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformComplete(mplatform, AuthType.LOGIN,mQQLogin);
102 | }
103 |
104 | }else {
105 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformError(mplatform,AuthType.LOGIN);
106 | }
107 |
108 | } catch (Exception e) {
109 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformError(mplatform,AuthType.LOGIN);
110 | }
111 |
112 | }
113 |
114 | @Override
115 | public void onCancel() {
116 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformCancel(mplatform,AuthType.LOGIN);
117 | }
118 | }
119 | public class UserInfoIUiListener implements IUiListener {
120 | @Override
121 | public void onError(UiError arg0) {
122 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformError(mplatform,AuthType.USERINFO);
123 | }
124 | @Override
125 | public void onComplete(Object value) {
126 | if (value == null) {
127 | return;
128 | }
129 | try {
130 | JSONObject jo = (JSONObject) value;
131 | int ret = jo.getInt("ret");
132 | if (ret == 0) {
133 | Gson gson =new Gson();
134 | QQInfo mQQInfo=gson.fromJson(jo.toString(),QQInfo.class);
135 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformComplete(mplatform,AuthType.USERINFO,mQQInfo);
136 | }else{
137 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformError(mplatform,AuthType.USERINFO);
138 | }
139 |
140 | } catch (Exception e) {
141 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformError(mplatform,AuthType.USERINFO);
142 | }
143 |
144 | }
145 |
146 | @Override
147 | public void onCancel() {
148 | Toast.makeText(context, "授权取消",
149 | Toast.LENGTH_LONG).show();
150 | }
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/OAuthUtils.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 |
6 | import com.sina.weibo.sdk.WbSdk;
7 | import com.sina.weibo.sdk.auth.AuthInfo;
8 | import com.yanxuwen.OAuth.PlatformQQ.QQShare2;
9 | import com.yanxuwen.OAuth.PlatformQQ.QQUtils;
10 | import com.yanxuwen.OAuth.PlatformSina.SinaShare;
11 | import com.yanxuwen.OAuth.PlatformSina.SinaUtils;
12 | import com.yanxuwen.OAuth.PlatformWeixin.WXShare;
13 | import com.yanxuwen.OAuth.PlatformWeixin.WeixinUtils;
14 |
15 | import java.io.Serializable;
16 |
17 | /**
18 | * Created by yanxuwen on 2017/9/22.
19 | */
20 |
21 | public class OAuthUtils implements OAuthPlatformListener ,Serializable{
22 | private static final long serialVersionUID = 1L;
23 | Activity activity;
24 | AuthPlatform mplatform;
25 | AuthType mAuthType;
26 | QQUtils mQQUtils;
27 | QQShare2 mQQShare2;
28 | WeixinUtils mWxUtils;
29 | WXShare mWXShare;
30 | SinaUtils mSinaUtils;
31 | SinaShare mSinaShare;
32 | public static OAuthUtils mOAuthUtils;
33 | public OAuthUtils(Activity activity){
34 | this.activity=activity;
35 | }
36 | public void login(AuthPlatform mplatform){
37 | String APPID="";
38 | String AppSecret="";
39 | switch (mplatform){
40 | case QQ:
41 | APPID=OAuthID.QQkey;
42 | break;
43 | case WX:
44 | APPID=OAuthID.WXkey;
45 | AppSecret=OAuthID.WX_secret;
46 | break;
47 | case SINA:
48 | APPID=OAuthID.SINAkey;
49 | break;
50 | }
51 | login(mplatform,APPID,false,AppSecret);
52 | }
53 |
54 | /**
55 | * 返回微信分享类
56 | */
57 | public WXShare shareWX(){
58 | mWXShare=new WXShare(activity,OAuthID.WXkey);
59 | mWXShare.setShareWXListener(this);
60 | mplatform=AuthPlatform.WX;
61 | mAuthType=AuthType.SHARE;
62 | return mWXShare;
63 | }
64 |
65 | public QQShare2 shareQQ(){
66 | mQQShare2=new QQShare2(activity,OAuthID.QQkey);
67 | mQQShare2.setShareQQListener(this);
68 | mplatform=AuthPlatform.QQ;
69 | mAuthType=AuthType.SHARE;
70 | return mQQShare2;
71 | }
72 | public SinaShare shareSina(){
73 | mSinaShare=new SinaShare(activity);
74 | mSinaShare.setShareSinaListener(this);
75 | mplatform=AuthPlatform.SINA;
76 | mAuthType=AuthType.SHARE;
77 | return mSinaShare;
78 | }
79 |
80 | /**
81 | * 微信获取用户信息的时候,需要AppSecret,QQ可以传空
82 | */
83 | public void getUserInfo(AuthPlatform mplatform){
84 | String APPID="";
85 | String AppSecret="";
86 | switch (mplatform){
87 | case QQ:
88 | APPID=OAuthID.QQkey;
89 | break;
90 | case WX:
91 | APPID=OAuthID.WXkey;
92 | AppSecret=OAuthID.WX_secret;
93 | break;
94 | case SINA:
95 | APPID=OAuthID.SINAkey;
96 | break;
97 | }
98 | login(mplatform,APPID,true,AppSecret);
99 | mAuthType=AuthType.USERINFO;
100 | }
101 | private void login(AuthPlatform mplatform,String APPID,boolean isUserInfo,String AppSecret){
102 | this.mplatform=mplatform;
103 | mAuthType=AuthType.LOGIN;
104 | switch (mplatform){
105 | case QQ:
106 | mQQUtils=new QQUtils(activity,mplatform,APPID);
107 | mQQUtils.setOAuthQQListener(this);
108 | mQQUtils.login(isUserInfo);
109 | break;
110 | case WX:
111 | mWxUtils=new WeixinUtils(activity,mplatform,APPID);
112 | mWxUtils.setOAuthWXListener(this);
113 | if(isUserInfo){
114 | mWxUtils.getUserInfo(AppSecret);
115 | }else{
116 | mWxUtils.login(AppSecret,false);
117 | }
118 | break;
119 | case SINA:
120 | mSinaUtils=new SinaUtils(activity,mplatform,APPID,OAuthID.redirectUrl);
121 | mSinaUtils.setOAuthWXListener(this);
122 | mSinaUtils.login();
123 | break;
124 | }
125 | }
126 | OAuthListener mOAuthListener=null;
127 | public void setOAuthListener(OAuthListener l){mOAuthListener=l;}
128 |
129 |
130 | public void onNewIntent(Intent intent) {
131 | if(mplatform==null)return;
132 | switch (mplatform){
133 | case QQ:break;
134 | case WX:break;
135 | case SINA:
136 | if(mSinaShare!=null)mSinaShare.onNewIntent(intent);
137 | break;
138 | }
139 | }
140 | public void onActivityResult(int requestCode, int resultCode, Intent data){
141 | switch (mplatform){
142 | case QQ:
143 | if(mQQUtils!=null)
144 | mQQUtils.onActivityResult(requestCode,resultCode,data);
145 | if(mQQShare2!=null)
146 | mQQShare2.onActivityResult(requestCode,resultCode,data);
147 | break;
148 | case SINA:
149 | if(mSinaUtils!=null)
150 | mSinaUtils.onActivityResult(requestCode,resultCode,data);
151 | break;
152 | }
153 | }
154 |
155 |
156 | @Override
157 | public void onPlatformError(final AuthPlatform platform, final AuthType mAuthType) {
158 | activity.runOnUiThread(new Runnable() {
159 | @Override
160 | public void run() {
161 | if(mOAuthListener!=null)mOAuthListener.onAuthError(platform,mAuthType);
162 | }
163 | });
164 | }
165 |
166 | @Override
167 | public void onPlatformComplete(final AuthPlatform platform, final AuthType mAuthType, final Object object) {
168 | activity.runOnUiThread(new Runnable() {
169 | @Override
170 | public void run() {
171 | if(mOAuthListener!=null)mOAuthListener.onAuthComplete(platform,mAuthType,object);
172 | }
173 | });
174 | }
175 |
176 | @Override
177 | public void onPlatformCancel(final AuthPlatform platform, final AuthType mAuthType) {
178 | activity.runOnUiThread(new Runnable() {
179 | @Override
180 | public void run() {
181 | if(mOAuthListener!=null)mOAuthListener.onAuthCancel(platform,mAuthType);
182 | }
183 | });
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 前言
2 | 为什么需要再写一个第三方分享呢,现在友盟和sharesdk都封装的很好功能又很齐全,但是都需要微信的secret的值,但是有时候公司不提供secret的值,只提供微信的key的值,只需要微信返回code值然后后台去获取具体信息就可以,这时候你就不得不去微信官方重新写。
3 |
4 | 本文写法非常简单,代码又很清晰,目前只支持QQ,微信,新浪,基本APP也就这几种对接而已
5 |
6 | # 依赖: compile 'com.yanxuwen.OAuth:OAuth:1.0.0'
7 | # build.gradle 记得加入这句话不然会报错
8 | ~~~
9 | repositories {
10 | flatDir {
11 | dirs '../OAuth/libs';dirs 'libs'
12 | }
13 | }
14 | ~~~
15 | #实现:
16 | #### 1.首先初始化。
17 | ~~~
18 | //QQ,WX,SINA分别为对应的key值,第四个参数就是微信的secret值,
19 | //不传的话写null,授权的时候就只会返回code,如果有传的话就会返回openid跟access_token
20 | OAuthID.init(this, QQ, WX,null,SINA, "http://www.sina.com");
21 |
22 | //初始化Auth主操作对象
23 | mOAuthUtils=new OAuthUtils(this);
24 | mOAuthUtils.setOAuthListener(this);
25 | }
26 | ~~~
27 | #### 2.个重要的地方onNewIntent跟onActivityResult,复制进去就是了,记得这2个方法
28 | ~~~
29 | @Override
30 | protected void onNewIntent(Intent intent) {
31 | super.onNewIntent(intent);
32 | mOAuthUtils.onNewIntent(intent);
33 | }
34 | @Override
35 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
36 | mOAuthUtils.onActivityResult(requestCode, resultCode, data);
37 | super.onActivityResult(requestCode, resultCode, data);
38 | }
39 | ~~~
40 |
41 | #### 3.AndroidManifest.xml 也里就不说了大家都知道,也是复制进去,
42 | ~~~
43 |
44 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
61 |
62 |
63 | ~~~
64 | #### 4.WXEntryActivity这个大家也都知道,微信的路径必备的,别漏了
65 | ~~~
66 | public class WXEntryActivity extends MyWXEntryActivity {}
67 | ~~~
68 | #### 5. 这时候我们设置一个监听,因为我们授权成功的时候会回调
69 | ~~~
70 | public class MainActivity extends AppCompatActivity implements OAuthListener {
71 | }
72 | public void onAuthComplete(AuthPlatform platform, AuthType mAuthType, Object object) {}
73 | public void onAuthCancel(AuthPlatform platform, AuthType mAuthType) {}
74 | public void onAuthError(AuthPlatform platform, AuthType mAuthType) {}
75 | ~~~
76 | 这3个方法就是授权成功,授权取消,授权失败的回调,也是分享成功,分享失败的回调,
77 | 1.platform是用于判断是QQ还是微信还是新浪,
78 | 2.mAuthType是用于判断是登录还是分享
79 | 3.object是授权成功返回信息,可以强制转换为QQ的实体类或者微信的实体类,
80 | 如:
81 | QQ的 QQLogin mQQLogin=(QQLogin)object;
82 | 微信的WXLogin mWXLogin=(WXLogin)object;
83 | 新浪的SinaLogin mSinaLogin=(SinaLogin)object;
84 |
85 | 给一份代码跟清晰:
86 | ~~~
87 | @Override
88 | public void onAuthComplete(AuthPlatform platform, AuthType mAuthType, Object object) {
89 | switch (platform){
90 | case QQ:
91 | try {
92 | if(mAuthType==AuthType.LOGIN){
93 | QQLogin mQQLogin=(QQLogin)object;
94 | Toast.makeText(this,"授权成功"+mQQLogin.getAccess_token(),Toast.LENGTH_SHORT).show();
95 |
96 | }else if(mAuthType==AuthType.USERINFO){
97 | QQInfo mQQInfo=(QQInfo)object;
98 | Toast.makeText(this,"授权成功"+mQQInfo.getNickname(),Toast.LENGTH_SHORT).show();
99 | }else if(mAuthType==AuthType.SHARE){
100 | Toast.makeText(this,"分享成功",Toast.LENGTH_SHORT).show();
101 | }
102 |
103 | }catch (Exception e){}
104 | break;
105 | case WX:
106 | if(mAuthType==AuthType.LOGIN){
107 | WXLogin mWXLogin=(WXLogin)object;
108 | Toast.makeText(this,"授权成功"+mWXLogin.getCode(),Toast.LENGTH_SHORT).show();
109 |
110 | }else if(mAuthType==AuthType.SHARE){
111 | Toast.makeText(this,"分享成功",Toast.LENGTH_SHORT).show();
112 | }
113 | break;
114 | case SINA:
115 | if(mAuthType==AuthType.LOGIN){
116 | SinaLogin mSinaLogin=(SinaLogin)object;
117 | Toast.makeText(this,"授权成功"+mSinaLogin.getUid(),Toast.LENGTH_SHORT).show();
118 |
119 | }else if(mAuthType==AuthType.USERINFO){
120 |
121 | }
122 | break;
123 | }
124 | }
125 |
126 | @Override
127 | public void onAuthCancel(AuthPlatform platform, AuthType mAuthType) {
128 | switch (mAuthType){
129 | case LOGIN:
130 | Toast.makeText(this,"授权取消",Toast.LENGTH_SHORT).show();
131 | break;
132 | case SHARE:
133 | Toast.makeText(this,"分享取消",Toast.LENGTH_SHORT).show();
134 | break;
135 | case USERINFO:break;
136 | }
137 |
138 | }
139 |
140 | @Override
141 | public void onAuthError(AuthPlatform platform, AuthType mAuthType) {
142 | switch (mAuthType){
143 | case LOGIN:
144 | Toast.makeText(this,"授权失败",Toast.LENGTH_SHORT).show();
145 | break;
146 | case SHARE:
147 | Toast.makeText(this,"分享失败",Toast.LENGTH_SHORT).show();
148 | break;
149 | case USERINFO:break;
150 | }
151 | }
152 |
153 | ~~~
154 | #### 6.如何调用登录或者分享
155 | 首先登录:
156 | ~~~
157 | mOAuthUtils.login(AuthPlatform.QQ);
158 | //mOAuthUtils.login(AuthPlatform.WX);
159 | //mOAuthUtils.login(AuthPlatform.SINA);
160 |
161 | ~~~
162 | 分享QQ:
163 | ~~~
164 | QQShare2 mQQShare2=mOAuthUtils.shareQQ();
165 | String file_img= Environment.getExternalStorageDirectory()+ File.separator+"test.jpg";
166 | mQQShare2.shareMusic("标题","摘要","https://www.baidu.com/","http://imgcache.qq.com/music/photo/mid_album_300/V/E/000J1pJ50cDCVE.jpg","http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3","测试");
167 | ~~~
168 | 具体看demo比较清晰
169 | #### 7.如果你在demo上要测试你的项目话,只要更改下上面的key值还有在build.gradle的下面图两个箭头的地方更改成你的包名跟腾讯的key值,注意是“tencent+key”别搞错哦
170 | 
171 | # apk:https://www.pgyer.com/Share
172 | #### 喜欢就在github star下,非常感谢o(∩_∩)o~~~,您star下就是我的动力,
173 | #微信公众号:
174 | 
175 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/PlatformQQ/QQShare2.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.PlatformQQ;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.util.Patterns;
7 |
8 | import com.tencent.connect.share.QQShare;
9 | import com.tencent.connect.share.QzoneShare;
10 | import com.tencent.tauth.IUiListener;
11 | import com.tencent.tauth.Tencent;
12 | import com.tencent.tauth.UiError;
13 | import com.yanxuwen.OAuth.AuthPlatform;
14 | import com.yanxuwen.OAuth.AuthType;
15 | import com.yanxuwen.OAuth.OAuthPlatformListener;
16 |
17 | /**
18 | * Created by yanxuwen on 2017/9/28.
19 | */
20 |
21 | public class QQShare2 {
22 | private Tencent mTencent; //qq主操作对象
23 | Activity activity;
24 | OAuthPlatformListener mOAuthPlatformListener=null;
25 | public BaseUiListener mBaseUiListener;
26 | public void setShareQQListener(OAuthPlatformListener l){mOAuthPlatformListener=l;}
27 | public QQShare2(Activity activity, String appid){
28 | this.activity=activity;
29 | mTencent = Tencent.createInstance(appid,activity);
30 | mBaseUiListener=new BaseUiListener();
31 | }
32 |
33 | /**
34 | * 分享默认的,也就是图文消息
35 | * @param title 标题
36 | * @param summary 摘要
37 | * @param targetUrl 跳转URL
38 | * @param imageUrl 图片url 本地图片或者url
39 | * @param appname 手Q客户端顶部,替换“返回”按钮文字,如果为空,用返回代替
40 | */
41 | public void shareDefault(String title,String summary,String targetUrl,String imageUrl,String appname){
42 | final Bundle params = new Bundle();
43 | params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_DEFAULT);
44 | params.putString(QQShare.SHARE_TO_QQ_TITLE, title);
45 | params.putString(QQShare.SHARE_TO_QQ_SUMMARY, summary);
46 | params.putString(QQShare.SHARE_TO_QQ_TARGET_URL, targetUrl);
47 | //判断是否是地址,如果是则用网络图片url
48 | if (Patterns.WEB_URL.matcher(imageUrl).matches()) {
49 | params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL, imageUrl);
50 | } else{
51 | //不是的话则使用本地地址
52 | params.putString(QQShare.SHARE_TO_QQ_IMAGE_LOCAL_URL, imageUrl);
53 | }
54 | params.putString(QQShare.SHARE_TO_QQ_APP_NAME, appname);
55 | params.putInt(QQShare.SHARE_TO_QQ_EXT_INT, QQShare.SHARE_TO_QQ_FLAG_QZONE_ITEM_HIDE);
56 | mTencent.shareToQQ(activity, params, mBaseUiListener);
57 | }
58 | /**
59 | * 分享图片
60 | * @param url 本地图片
61 | * @param name 名字
62 | */
63 | public void shareImage(String url,String name){
64 | Bundle params = new Bundle();
65 | params.putString(QQShare.SHARE_TO_QQ_IMAGE_LOCAL_URL,url);
66 | params.putString(QQShare.SHARE_TO_QQ_APP_NAME, name);
67 | params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_IMAGE);
68 | params.putInt(QQShare.SHARE_TO_QQ_EXT_INT, QQShare.SHARE_TO_QQ_FLAG_QZONE_ITEM_HIDE);
69 | mTencent.shareToQQ(activity, params, mBaseUiListener);
70 | }
71 |
72 | /**
73 | * @param title 标题
74 | * @param summary 摘要
75 | * @param targetUrl 跳转URL
76 | * @param imageUrl 图片url 本地图片或者url
77 | * @param musicUrl 音乐url 不支持本地音乐
78 | * @param appname 手Q客户端顶部,替换“返回”按钮文字,如果为空,用返回代替
79 | */
80 | public void shareMusic(String title,String summary,String targetUrl,String imageUrl,String musicUrl,String appname){
81 | final Bundle params = new Bundle();
82 | params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_AUDIO);
83 | params.putString(QQShare.SHARE_TO_QQ_TITLE, title);
84 | params.putString(QQShare.SHARE_TO_QQ_SUMMARY, summary);
85 | params.putString(QQShare.SHARE_TO_QQ_TARGET_URL, targetUrl);
86 | //判断是否是地址,如果是则用网络图片url
87 | if (Patterns.WEB_URL.matcher(imageUrl).matches()) {
88 | params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL, imageUrl);
89 | } else{
90 | //不是的话则使用本地地址
91 | params.putString(QQShare.SHARE_TO_QQ_IMAGE_LOCAL_URL, imageUrl);
92 | }
93 | params.putString(QQShare.SHARE_TO_QQ_AUDIO_URL, musicUrl);
94 | params.putString(QQShare.SHARE_TO_QQ_APP_NAME, appname);
95 | params.putInt(QQShare.SHARE_TO_QQ_EXT_INT,QQShare.SHARE_TO_QQ_FLAG_QZONE_ITEM_HIDE);
96 | mTencent.shareToQQ(activity, params, mBaseUiListener);
97 | }
98 |
99 | /**
100 | * 分享APP
101 | * @param title 标题
102 | * @param summary 摘要
103 | * @param imageUrl 图片url 本地图片或者url
104 | * @param appname 手Q客户端顶部,替换“返回”按钮文字,如果为空,用返回代替
105 | */
106 | public void shareApp(String title,String summary,String imageUrl,String appname){
107 | final Bundle params = new Bundle();
108 | params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_APP);
109 | params.putString(QQShare.SHARE_TO_QQ_TITLE, title);
110 | params.putString(QQShare.SHARE_TO_QQ_SUMMARY, summary);
111 | //判断是否是地址,如果是则用网络图片url
112 | if (Patterns.WEB_URL.matcher(imageUrl).matches()) {
113 | params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL, imageUrl);
114 | } else{
115 | //不是的话则使用本地地址
116 | params.putString(QQShare.SHARE_TO_QQ_IMAGE_LOCAL_URL, imageUrl);
117 | }
118 | params.putString(QQShare.SHARE_TO_QQ_APP_NAME, appname);
119 | mTencent.shareToQQ(activity, params,mBaseUiListener);
120 | }
121 |
122 | /**
123 | * 分享QQ空间,目前只有图文
124 | * @param title 标题
125 | * @param summary 摘要
126 | * @param targetUrl 跳转url
127 | * @param imageUrl 图片url 本地图片或者url
128 | */
129 | public void shareToQzone (String title,String summary,String targetUrl,String imageUrl ) {
130 | final Bundle params = new Bundle();
131 | params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE,QQShare.SHARE_TO_QQ_TYPE_DEFAULT);
132 | params.putString(QQShare.SHARE_TO_QQ_TITLE, title);//必填
133 | params.putString(QQShare.SHARE_TO_QQ_SUMMARY, summary);//选填
134 | params.putString(QQShare.SHARE_TO_QQ_TARGET_URL, targetUrl);//必填
135 | //判断是否是地址,如果是则用网络图片url
136 | if (Patterns.WEB_URL.matcher(imageUrl).matches()) {
137 | params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL, imageUrl);
138 | } else{
139 | //不是的话则使用本地地址
140 | params.putString(QQShare.SHARE_TO_QQ_IMAGE_LOCAL_URL, imageUrl);
141 | }
142 | mTencent.shareToQzone(activity, params, new BaseUiListener());
143 | }
144 |
145 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
146 | if (null != mTencent)
147 | mTencent.handleLoginData(data, mBaseUiListener);
148 | }
149 |
150 | class BaseUiListener implements IUiListener {
151 |
152 | @Override
153 | public void onComplete(Object o) {
154 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformComplete(AuthPlatform.QQ, AuthType.SHARE,"");
155 | }
156 |
157 | @Override
158 | public void onError(UiError uiError) {
159 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformError(AuthPlatform.QQ, AuthType.SHARE);
160 |
161 | }
162 |
163 | @Override
164 | public void onCancel() {
165 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformCancel(AuthPlatform.QQ, AuthType.SHARE);
166 |
167 | }
168 | }
169 | }
170 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/PlatformWeixin/Util.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.PlatformWeixin;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.File;
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 | import java.io.RandomAccessFile;
8 | import java.net.HttpURLConnection;
9 | import java.net.MalformedURLException;
10 | import java.net.URL;
11 | import java.net.URLConnection;
12 | import java.security.MessageDigest;
13 |
14 | import junit.framework.Assert;
15 | import android.graphics.Bitmap;
16 | import android.graphics.BitmapFactory;
17 | import android.graphics.Bitmap.CompressFormat;
18 | import android.util.Log;
19 |
20 | class Util {
21 |
22 | private static final String TAG = "Share.Util";
23 |
24 | public static byte[] bmpToByteArray(final Bitmap bmp, final boolean needRecycle) {
25 | ByteArrayOutputStream output = new ByteArrayOutputStream();
26 | bmp.compress(CompressFormat.PNG, 100, output);
27 | if (needRecycle) {
28 | bmp.recycle();
29 | }
30 |
31 | byte[] result = output.toByteArray();
32 | try {
33 | output.close();
34 | } catch (Exception e) {
35 | e.printStackTrace();
36 | }
37 |
38 | return result;
39 | }
40 |
41 | public static byte[] getHtmlByteArray(final String url) {
42 | URL htmlUrl = null;
43 | InputStream inStream = null;
44 | try {
45 | htmlUrl = new URL(url);
46 | URLConnection connection = htmlUrl.openConnection();
47 | HttpURLConnection httpConnection = (HttpURLConnection)connection;
48 | int responseCode = httpConnection.getResponseCode();
49 | if(responseCode == HttpURLConnection.HTTP_OK){
50 | inStream = httpConnection.getInputStream();
51 | }
52 | } catch (MalformedURLException e) {
53 | e.printStackTrace();
54 | } catch (IOException e) {
55 | e.printStackTrace();
56 | }
57 | byte[] data = inputStreamToByte(inStream);
58 |
59 | return data;
60 | }
61 |
62 | public static byte[] inputStreamToByte(InputStream is) {
63 | try{
64 | ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
65 | int ch;
66 | while ((ch = is.read()) != -1) {
67 | bytestream.write(ch);
68 | }
69 | byte imgdata[] = bytestream.toByteArray();
70 | bytestream.close();
71 | return imgdata;
72 | }catch(Exception e){
73 | e.printStackTrace();
74 | }
75 |
76 | return null;
77 | }
78 |
79 | public static byte[] readFromFile(String fileName, int offset, int len) {
80 | if (fileName == null) {
81 | return null;
82 | }
83 |
84 | File file = new File(fileName);
85 | if (!file.exists()) {
86 | Log.i(TAG, "readFromFile: file not found");
87 | return null;
88 | }
89 |
90 | if (len == -1) {
91 | len = (int) file.length();
92 | }
93 |
94 | Log.d(TAG, "readFromFile : offset = " + offset + " len = " + len + " offset + len = " + (offset + len));
95 |
96 | if(offset <0){
97 | Log.e(TAG, "readFromFile invalid offset:" + offset);
98 | return null;
99 | }
100 | if(len <=0 ){
101 | Log.e(TAG, "readFromFile invalid len:" + len);
102 | return null;
103 | }
104 | if(offset + len > (int) file.length()){
105 | Log.e(TAG, "readFromFile invalid file len:" + file.length());
106 | return null;
107 | }
108 |
109 | byte[] b = null;
110 | try {
111 | RandomAccessFile in = new RandomAccessFile(fileName, "r");
112 | b = new byte[len]; // 创建合适文件大小的数组
113 | in.seek(offset);
114 | in.readFully(b);
115 | in.close();
116 |
117 | } catch (Exception e) {
118 | Log.e(TAG, "readFromFile : errMsg = " + e.getMessage());
119 | e.printStackTrace();
120 | }
121 | return b;
122 | }
123 |
124 | private static final int MAX_DECODE_PICTURE_SIZE = 1920 * 1440;
125 | public static Bitmap extractThumbNail(final String path, final int height, final int width, final boolean crop) {
126 | Assert.assertTrue(path != null && !path.equals("") && height > 0 && width > 0);
127 |
128 | BitmapFactory.Options options = new BitmapFactory.Options();
129 |
130 | try {
131 | options.inJustDecodeBounds = true;
132 | Bitmap tmp = BitmapFactory.decodeFile(path, options);
133 | if (tmp != null) {
134 | tmp.recycle();
135 | tmp = null;
136 | }
137 |
138 | Log.d(TAG, "extractThumbNail: round=" + width + "x" + height + ", crop=" + crop);
139 | final double beY = options.outHeight * 1.0 / height;
140 | final double beX = options.outWidth * 1.0 / width;
141 | Log.d(TAG, "extractThumbNail: extract beX = " + beX + ", beY = " + beY);
142 | options.inSampleSize = (int) (crop ? (beY > beX ? beX : beY) : (beY < beX ? beX : beY));
143 | if (options.inSampleSize <= 1) {
144 | options.inSampleSize = 1;
145 | }
146 |
147 | // NOTE: out of memory error
148 | while (options.outHeight * options.outWidth / options.inSampleSize > MAX_DECODE_PICTURE_SIZE) {
149 | options.inSampleSize++;
150 | }
151 |
152 | int newHeight = height;
153 | int newWidth = width;
154 | if (crop) {
155 | if (beY > beX) {
156 | newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth);
157 | } else {
158 | newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight);
159 | }
160 | } else {
161 | if (beY < beX) {
162 | newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth);
163 | } else {
164 | newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight);
165 | }
166 | }
167 |
168 | options.inJustDecodeBounds = false;
169 |
170 | Log.i(TAG, "bitmap required size=" + newWidth + "x" + newHeight + ", orig=" + options.outWidth + "x" + options.outHeight + ", sample=" + options.inSampleSize);
171 | Bitmap bm = BitmapFactory.decodeFile(path, options);
172 | if (bm == null) {
173 | Log.e(TAG, "bitmap decode failed");
174 | return null;
175 | }
176 |
177 | Log.i(TAG, "bitmap decoded size=" + bm.getWidth() + "x" + bm.getHeight());
178 | final Bitmap scale = Bitmap.createScaledBitmap(bm, newWidth, newHeight, true);
179 | if (scale != null) {
180 | bm.recycle();
181 | bm = scale;
182 | }
183 |
184 | if (crop) {
185 | final Bitmap cropped = Bitmap.createBitmap(bm, (bm.getWidth() - width) >> 1, (bm.getHeight() - height) >> 1, width, height);
186 | if (cropped == null) {
187 | return bm;
188 | }
189 |
190 | bm.recycle();
191 | bm = cropped;
192 | Log.i(TAG, "bitmap croped size=" + bm.getWidth() + "x" + bm.getHeight());
193 | }
194 | return bm;
195 |
196 | } catch (final OutOfMemoryError e) {
197 | Log.e(TAG, "decode bitmap failed: " + e.getMessage());
198 | options = null;
199 | }
200 |
201 | return null;
202 | }
203 | }
204 |
--------------------------------------------------------------------------------
/share/app/src/main/java/com/yanxuwen/share/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.share;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.os.AsyncTask;
7 | import android.os.Bundle;
8 | import android.os.Environment;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.view.View;
11 | import android.widget.Toast;
12 |
13 | import com.yanxuwen.OAuth.AuthPlatform;
14 | import com.yanxuwen.OAuth.AuthType;
15 | import com.yanxuwen.OAuth.OAuthID;
16 | import com.yanxuwen.OAuth.OAuthListener;
17 | import com.yanxuwen.OAuth.OAuthUtils;
18 | import com.yanxuwen.OAuth.PlatformQQ.QQInfo;
19 | import com.yanxuwen.OAuth.PlatformQQ.QQLogin;
20 | import com.yanxuwen.OAuth.PlatformQQ.QQShare2;
21 | import com.yanxuwen.OAuth.PlatformSina.SinaLogin;
22 | import com.yanxuwen.OAuth.PlatformSina.SinaShare;
23 | import com.yanxuwen.OAuth.PlatformWeixin.WXLogin;
24 | import com.yanxuwen.OAuth.PlatformWeixin.WXShare;
25 |
26 | import java.io.File;
27 | import java.net.URL;
28 |
29 | public class MainActivity extends AppCompatActivity implements OAuthListener {
30 | OAuthUtils mOAuthUtils;
31 | public final static String QQ="1105929954";
32 | public final static String WX="wxcd017f7b9a41b542";
33 | public final static String SINA="3416818377";
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_main);
38 | OAuthID.init(this, QQ, WX,null,SINA, "http://www.sina.com");
39 |
40 | //初始化Auth主操作对象
41 | mOAuthUtils=new OAuthUtils(this);
42 | mOAuthUtils.setOAuthListener(this);
43 | }
44 | public void onWeixin(View v){
45 | mOAuthUtils.login(AuthPlatform.WX);
46 |
47 | }
48 | public void onQQ(View v){
49 | mOAuthUtils.login(AuthPlatform.QQ);
50 |
51 | }
52 | public void onWeibo(View v){
53 | mOAuthUtils.login(AuthPlatform.SINA);
54 | }
55 |
56 | public void onWeixinShare(final View v){
57 |
58 | new AsyncTask() {
59 | @Override
60 | protected Bitmap doInBackground(String... params) {
61 | Bitmap bitmap = null;
62 | try {
63 | //网络图片
64 | URL url = new URL("http://imgcache.qq.com/music/photo/mid_album_300/V/E/000J1pJ50cDCVE.jpg");
65 | bitmap= BitmapFactory.decodeStream(url.openStream());
66 | //本地图片
67 | // String file_img= Environment.getExternalStorageDirectory()+ File.separator+"test.jpg";
68 | // bitmap = BitmapFactory.decodeFile(file_img);
69 | }catch (Exception e){}
70 |
71 | return bitmap;
72 | }
73 |
74 | @Override
75 | protected void onPostExecute(Bitmap bitmap) {
76 | WXShare mWXShare=mOAuthUtils.shareWX();
77 | mWXShare.shareMusic(WXShare.WX_SESSION,"http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3","标题","摘要",bitmap);
78 | }
79 | }.execute();
80 |
81 | }
82 | public void onQQShare(View v){
83 | QQShare2 mQQShare2=mOAuthUtils.shareQQ();
84 | String file_img= Environment.getExternalStorageDirectory()+ File.separator+"test.jpg";
85 | mQQShare2.shareMusic("标题","摘要","https://www.baidu.com/","http://imgcache.qq.com/music/photo/mid_album_300/V/E/000J1pJ50cDCVE.jpg","http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3","测试");
86 |
87 | }
88 | public void onWeiboShare(View v){
89 | new AsyncTask() {
90 | @Override
91 | protected Bitmap doInBackground(String... params) {
92 | Bitmap bitmap = null;
93 | try {
94 | //网络图片
95 | URL url = new URL("http://imgcache.qq.com/music/photo/mid_album_300/V/E/000J1pJ50cDCVE.jpg");
96 | bitmap= BitmapFactory.decodeStream(url.openStream());
97 | //本地图片
98 | // String file_img= Environment.getExternalStorageDirectory()+ File.separator+"test.jpg";
99 | // bitmap = BitmapFactory.decodeFile(file_img);
100 | }catch (Exception e){}
101 |
102 | return bitmap;
103 | }
104 |
105 | @Override
106 | protected void onPostExecute(Bitmap bitmap) {
107 | SinaShare mSinaShare=mOAuthUtils.shareSina();
108 | mSinaShare.shareDefault("标题","摘要","https://www.baidu.com/",bitmap);
109 | }
110 | }.execute();
111 |
112 | }
113 | @Override
114 | public void onAuthComplete(AuthPlatform platform, AuthType mAuthType, Object object) {
115 | switch (platform){
116 | case QQ:
117 | try {
118 | if(mAuthType==AuthType.LOGIN){
119 | QQLogin mQQLogin=(QQLogin)object;
120 | Toast.makeText(this,"授权成功"+mQQLogin.getAccess_token(),Toast.LENGTH_SHORT).show();
121 |
122 | }else if(mAuthType==AuthType.USERINFO){
123 | QQInfo mQQInfo=(QQInfo)object;
124 | Toast.makeText(this,"授权成功"+mQQInfo.getNickname(),Toast.LENGTH_SHORT).show();
125 | }else if(mAuthType==AuthType.SHARE){
126 | Toast.makeText(this,"分享成功",Toast.LENGTH_SHORT).show();
127 | }
128 |
129 | }catch (Exception e){}
130 | break;
131 | case WX:
132 | if(mAuthType==AuthType.LOGIN){
133 | WXLogin mWXLogin=(WXLogin)object;
134 | Toast.makeText(this,"授权成功"+mWXLogin.getCode(),Toast.LENGTH_SHORT).show();
135 |
136 | }else if(mAuthType==AuthType.SHARE){
137 | Toast.makeText(this,"分享成功",Toast.LENGTH_SHORT).show();
138 | }
139 | break;
140 | case SINA:
141 | if(mAuthType==AuthType.LOGIN){
142 | SinaLogin mSinaLogin=(SinaLogin)object;
143 | Toast.makeText(this,"授权成功"+mSinaLogin.getUid(),Toast.LENGTH_SHORT).show();
144 |
145 | }else if(mAuthType==AuthType.USERINFO){
146 |
147 | }
148 | break;
149 | }
150 | }
151 |
152 | @Override
153 | public void onAuthCancel(AuthPlatform platform, AuthType mAuthType) {
154 | switch (mAuthType){
155 | case LOGIN:
156 | Toast.makeText(this,"授权取消",Toast.LENGTH_SHORT).show();
157 | break;
158 | case SHARE:
159 | Toast.makeText(this,"分享取消",Toast.LENGTH_SHORT).show();
160 | break;
161 | case USERINFO:break;
162 | }
163 |
164 | }
165 |
166 | @Override
167 | public void onAuthError(AuthPlatform platform, AuthType mAuthType) {
168 | switch (mAuthType){
169 | case LOGIN:
170 | Toast.makeText(this,"授权失败",Toast.LENGTH_SHORT).show();
171 | break;
172 | case SHARE:
173 | Toast.makeText(this,"分享失败",Toast.LENGTH_SHORT).show();
174 | break;
175 | case USERINFO:break;
176 | }
177 | }
178 |
179 | @Override
180 | protected void onNewIntent(Intent intent) {
181 | super.onNewIntent(intent);
182 | mOAuthUtils.onNewIntent(intent);
183 | }
184 |
185 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
186 | mOAuthUtils.onActivityResult(requestCode, resultCode, data);
187 | super.onActivityResult(requestCode, resultCode, data);
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/PlatformWeixin/MyWXEntryActivity.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.PlatformWeixin;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 |
7 | import com.google.gson.Gson;
8 | import com.tencent.mm.opensdk.modelbase.BaseReq;
9 | import com.tencent.mm.opensdk.modelbase.BaseResp;
10 | import com.tencent.mm.opensdk.modelmsg.SendAuth;
11 | import com.tencent.mm.opensdk.openapi.IWXAPI;
12 | import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
13 | import com.yanxuwen.OAuth.AuthType;
14 | import com.yanxuwen.OAuth.Utils.JsonUtils;
15 |
16 | import org.json.JSONObject;
17 |
18 | public class MyWXEntryActivity extends Activity implements IWXAPIEventHandler {
19 | private static final int RETURN_MSG_TYPE_LOGIN = 1;
20 | private static final int RETURN_MSG_TYPE_SHARE = 2;
21 | public static IWXAPI api;
22 | public static boolean isUserInfo=false;
23 | public static String APP_ID="";
24 | public static String APP_SECRET="";
25 |
26 | public interface OnWXAuthListener{
27 | public void onWXAuthError(AuthType mAuthType);
28 | public void onWXAuthComplete(AuthType mAuthType, Object object);
29 | public void onWXAuthCancel(AuthType mAuthType);
30 | }
31 | static OnWXAuthListener mOnWXAuthListener=null;
32 | public static void setOnWXAuthListener(OnWXAuthListener l){
33 | mOnWXAuthListener=l;
34 | }
35 | public static void removeOnWXAuthListener(){
36 | mOnWXAuthListener=null;
37 | }
38 | @Override
39 | protected void onCreate(@Nullable Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 |
42 | //如果没回调onResp,八成是这句没有写
43 | if(api!=null){
44 | api.handleIntent(getIntent(), this);
45 | }
46 | }
47 |
48 | // 微信发送请求到第三方应用时,会回调到该方法
49 | @Override
50 | public void onReq(BaseReq req) {
51 |
52 | }
53 |
54 | // 第三方应用发送到微信的请求处理后的响应结果,会回调到该方法
55 | //app发送消息给微信,处理返回消息的回调
56 | @Override
57 | public void onResp(BaseResp resp) {
58 | switch (resp.errCode) {
59 | case BaseResp.ErrCode.ERR_OK:
60 | switch (resp.getType()) {
61 | case RETURN_MSG_TYPE_LOGIN:
62 | //拿到了微信返回的code,立马再去请求access_token
63 | String code = ((SendAuth.Resp) resp).code;
64 | WXLogin mWXLogin=new WXLogin();
65 | mWXLogin.setCode(code);
66 | //是否获取token
67 | if(APP_SECRET!=null&&!APP_SECRET.equals("")){
68 | getAccess_token(code,APP_ID,APP_SECRET);
69 | }else{
70 | if(mOnWXAuthListener!=null)mOnWXAuthListener.onWXAuthComplete( AuthType.LOGIN,mWXLogin);
71 | setNull();
72 | }
73 | break;
74 | case RETURN_MSG_TYPE_SHARE:
75 | if(mOnWXAuthListener!=null)mOnWXAuthListener.onWXAuthComplete( AuthType.SHARE,null);
76 | setNull();
77 | break;
78 | default:
79 | setNull();
80 | break;
81 | }
82 |
83 | break;
84 | case BaseResp.ErrCode.ERR_USER_CANCEL:
85 | switch (resp.getType()) {
86 | case RETURN_MSG_TYPE_LOGIN:
87 | if(mOnWXAuthListener!=null)mOnWXAuthListener.onWXAuthCancel(AuthType.LOGIN);
88 | break;
89 | case RETURN_MSG_TYPE_SHARE:
90 | if(mOnWXAuthListener!=null)mOnWXAuthListener.onWXAuthCancel(AuthType.SHARE);
91 | break;
92 | }
93 | setNull();
94 | break;
95 | case BaseResp.ErrCode.ERR_AUTH_DENIED:
96 | // result = "发送被拒绝";
97 | switch (resp.getType()) {
98 | case RETURN_MSG_TYPE_LOGIN:
99 | if(mOnWXAuthListener!=null)mOnWXAuthListener.onWXAuthError(AuthType.LOGIN);
100 | break;
101 | case RETURN_MSG_TYPE_SHARE:
102 | if(mOnWXAuthListener!=null)mOnWXAuthListener.onWXAuthError(AuthType.SHARE);
103 | break;
104 | }
105 | setNull();
106 | break;
107 | case BaseResp.ErrCode.ERR_UNSUPPORT:
108 | // result = "不支持错误";
109 | switch (resp.getType()) {
110 | case RETURN_MSG_TYPE_LOGIN:
111 | if(mOnWXAuthListener!=null)mOnWXAuthListener.onWXAuthError(AuthType.LOGIN);
112 | break;
113 | case RETURN_MSG_TYPE_SHARE:
114 | if(mOnWXAuthListener!=null)mOnWXAuthListener.onWXAuthError(AuthType.SHARE);
115 | break;
116 | }
117 | setNull();
118 | break;
119 | }
120 | }
121 | /**
122 | * 获取openid accessToken值用于后期操作
123 | *
124 | * @param code 请求码
125 | */
126 | private void getAccess_token(final String code, final String APP_ID, final String APP_SECRET) {
127 | new Thread(new Runnable() {
128 | @Override
129 | public void run() {
130 | String path = "https://api.weixin.qq.com/sns/oauth2/access_token?appid="
131 | + APP_ID
132 | + "&secret="
133 | + APP_SECRET
134 | + "&code="
135 | + code
136 | + "&grant_type=authorization_code";
137 | try {
138 | JSONObject jsonObject = JsonUtils.initSSLWithHttpClinet(path);// 请求https连接并得到json结果
139 | if (null != jsonObject) {
140 | String openid = jsonObject.getString("openid").toString().trim();
141 | String access_token = jsonObject.getString("access_token").toString().trim();
142 | //是否获取用户信息
143 | if(isUserInfo){
144 | getUserMesg(access_token, openid);
145 | }else{
146 | Gson gson =new Gson();
147 | WXLogin mWXLogin=gson.fromJson(jsonObject.toString(),WXLogin.class);
148 | mWXLogin.setCode(code);
149 | if(mOnWXAuthListener!=null)mOnWXAuthListener.onWXAuthComplete( AuthType.LOGIN,mWXLogin);
150 | setNull();
151 | }
152 | }else{
153 | if(mOnWXAuthListener!=null)mOnWXAuthListener.onWXAuthError(AuthType.LOGIN);
154 | setNull();
155 | }
156 |
157 | } catch (Exception e) {
158 | e.printStackTrace();
159 | if(mOnWXAuthListener!=null)mOnWXAuthListener.onWXAuthError(AuthType.LOGIN);
160 | setNull();
161 | }
162 | }
163 | }).start();
164 |
165 | }
166 |
167 | /**
168 | * 获取微信的个人信息
169 | *
170 | * @param access_token
171 | * @param openid
172 | */
173 | private void getUserMesg(final String access_token, final String openid) {
174 | String path = "https://api.weixin.qq.com/sns/userinfo?access_token="
175 | + access_token
176 | + "&openid="
177 | + openid;
178 | try {
179 | JSONObject jsonObject = JsonUtils.initSSLWithHttpClinet(path);// 请求https连接并得到json结果
180 | if (null != jsonObject) {
181 | String nickname = jsonObject.getString("nickname");
182 | int sex = Integer.parseInt(jsonObject.get("sex").toString());
183 | String headimgurl = jsonObject.getString("headimgurl");
184 | Gson gson =new Gson();
185 | WXInfo mWXInfo=gson.fromJson(jsonObject.toString(),WXInfo.class);
186 | if(mOnWXAuthListener!=null)mOnWXAuthListener.onWXAuthComplete( AuthType.USERINFO,mWXInfo);
187 | }else{
188 | if(mOnWXAuthListener!=null)mOnWXAuthListener.onWXAuthError(AuthType.USERINFO);
189 | }
190 | } catch (Exception e) {
191 | e.printStackTrace();
192 | if(mOnWXAuthListener!=null)mOnWXAuthListener.onWXAuthError(AuthType.USERINFO);
193 | }
194 | setNull();
195 | return;
196 | }
197 |
198 | public void setNull(){
199 | removeOnWXAuthListener();
200 | isUserInfo=false;
201 | MyWXEntryActivity.api=null;
202 | APP_ID="";
203 | APP_SECRET="";
204 | finish();
205 | }
206 | }
--------------------------------------------------------------------------------
/share/OAuth/src/main/java/com/yanxuwen/OAuth/PlatformWeixin/WXShare.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.OAuth.PlatformWeixin;
2 |
3 | import android.app.Activity;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.media.ThumbnailUtils;
7 | import android.widget.Toast;
8 |
9 | import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
10 | import com.tencent.mm.opensdk.modelmsg.WXImageObject;
11 | import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
12 | import com.tencent.mm.opensdk.modelmsg.WXMiniProgramObject;
13 | import com.tencent.mm.opensdk.modelmsg.WXMusicObject;
14 | import com.tencent.mm.opensdk.modelmsg.WXTextObject;
15 | import com.tencent.mm.opensdk.modelmsg.WXVideoObject;
16 | import com.tencent.mm.opensdk.modelmsg.WXWebpageObject;
17 | import com.tencent.mm.opensdk.openapi.IWXAPI;
18 | import com.tencent.mm.opensdk.openapi.WXAPIFactory;
19 | import com.yanxuwen.OAuth.AuthPlatform;
20 | import com.yanxuwen.OAuth.AuthType;
21 | import com.yanxuwen.OAuth.OAuthPlatformListener;
22 | import com.yanxuwen.OAuth.R;
23 |
24 | import java.io.File;
25 |
26 | /**
27 | * Created by yanxuwen on 2017/9/28.
28 | */
29 |
30 | public class WXShare implements MyWXEntryActivity.OnWXAuthListener{
31 | /**微信会话*/
32 | public final static int WX_SESSION=0;
33 | /**朋友圈*/
34 | public final static int WX_PYQ=1;
35 | /**收藏*/
36 | public final static int WX_FAVORITE=2;
37 | private static final int THUMB_SIZE = 100;
38 |
39 | private IWXAPI api;
40 | Activity activity;
41 | OAuthPlatformListener mOAuthPlatformListener=null;
42 | public void setShareWXListener(OAuthPlatformListener l){mOAuthPlatformListener=l;}
43 |
44 | /**
45 | * @param scene 返回微信(WX),朋友圈(WX_PYQ)或者收藏(WX_FAVORITE)
46 | * @return
47 | */
48 | public int getTargetScene(int scene){
49 | switch (scene){
50 | case WX_SESSION:
51 | return SendMessageToWX.Req.WXSceneSession;
52 | case WX_PYQ:
53 | return SendMessageToWX.Req.WXSceneTimeline;
54 | case WX_FAVORITE:
55 | return SendMessageToWX.Req.WXSceneFavorite;
56 | }
57 | return SendMessageToWX.Req.WXSceneSession;
58 | }
59 | public WXShare(Activity activity,String appid){
60 | api = WXAPIFactory.createWXAPI(activity,appid);
61 | // 将该app注册到微信
62 | api.registerApp(appid);
63 | MyWXEntryActivity.api=api;
64 | MyWXEntryActivity.setOnWXAuthListener(this);
65 | this.activity=activity;
66 | }
67 |
68 | /**
69 | * 发送文本
70 | * @param scene 发送微信(WX),朋友圈(WX_PYQ)或者收藏(WX_FAVORITE)
71 | * @param text
72 | */
73 | public void sendText(int scene,String text){
74 | WXTextObject textObj = new WXTextObject();
75 | textObj.text = text;
76 |
77 | WXMediaMessage msg = new WXMediaMessage();
78 | msg.mediaObject = textObj;
79 | msg.description = text;
80 | SendMessageToWX.Req req = new SendMessageToWX.Req();
81 | req.transaction = buildTransaction("text");
82 | req.message = msg;
83 | req.scene = getTargetScene(scene);
84 | api.sendReq(req);
85 | }
86 |
87 | /**
88 | * 发送资源图片
89 | * @param scene 发送微信(WX_SESSION),朋友圈(WX_PYQ)或者收藏(WX_FAVORITE)
90 | * @param drawable
91 | */
92 | public void shareImage(int scene,int drawable){
93 | Bitmap bmp = BitmapFactory.decodeResource(activity.getResources(), drawable);
94 | WXImageObject imgObj = new WXImageObject(bmp);
95 |
96 | WXMediaMessage msg = new WXMediaMessage();
97 | msg.mediaObject = imgObj;
98 |
99 | bmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true);
100 | msg.thumbData = Util.bmpToByteArray(bmp, true);
101 |
102 | SendMessageToWX.Req req = new SendMessageToWX.Req();
103 | req.transaction = buildTransaction("img");
104 | req.message = msg;
105 | req.scene = getTargetScene(scene);
106 | api.sendReq(req);
107 | }
108 |
109 | /**
110 | * 发送本地图片
111 | * @param scene 发送微信(WX_SESSION),朋友圈(WX_PYQ)或者收藏(WX_FAVORITE)
112 | * @param str_file
113 | */
114 | public void shareImage(int scene,String str_file){
115 | String path = str_file;
116 | File file = new File(path);
117 | if (!file.exists()) {
118 | String tip = activity.getString(R.string.send_img_file_not_exist);
119 | Toast.makeText(activity, tip + " path = " + path, Toast.LENGTH_LONG).show();
120 | return;
121 | }
122 |
123 | WXImageObject imgObj = new WXImageObject();
124 | imgObj.setImagePath(path);
125 |
126 | WXMediaMessage msg = new WXMediaMessage();
127 | msg.mediaObject = imgObj;
128 |
129 | Bitmap bmp = BitmapFactory.decodeFile(path);
130 | bmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true);
131 | msg.thumbData = Util.bmpToByteArray(bmp, true);
132 |
133 | SendMessageToWX.Req req = new SendMessageToWX.Req();
134 | req.transaction = buildTransaction("img");
135 | req.message = msg;
136 | req.scene = getTargetScene(scene);
137 | api.sendReq(req);
138 | }
139 |
140 | /**
141 | * 发送音乐
142 | * @param scene 发送微信(WX_SESSION),朋友圈(WX_PYQ)或者收藏(WX_FAVORITE)
143 | * @param musicUrl 音乐地址,建议是网页模式
144 | * @param title 标题
145 | * @param description 描述,建议是APP名字
146 | * @param bmp 图片
147 | */
148 | public void shareMusic(int scene,String musicUrl,String title,String description, Bitmap bmp){
149 | WXMusicObject music = new WXMusicObject();
150 | //music.musicUrl = "http://www.baidu.com";
151 | music.musicUrl=musicUrl;
152 |
153 | WXMediaMessage msg = new WXMediaMessage();
154 | msg.mediaObject = music;
155 | msg.title = title;
156 | msg.description =description;
157 | bmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true);
158 | msg.thumbData = Util.bmpToByteArray(bmp, true);
159 |
160 | SendMessageToWX.Req req = new SendMessageToWX.Req();
161 | req.transaction = buildTransaction("music");
162 | req.message = msg;
163 | req.scene = getTargetScene(scene);
164 | api.sendReq(req);
165 | }
166 |
167 | /**
168 | * 发送视频
169 | * @param scene 发送微信(WX_SESSION),朋友圈(WX_PYQ)或者收藏(WX_FAVORITE)
170 | * @param videoUrl 视频地址,建议是网页模式
171 | * @param title 标题
172 | * @param description 描述,建议是APP名字
173 | * @param bmp 图片
174 | */
175 | public void shareVideo(int scene,String videoUrl,String title,String description, Bitmap bmp) {
176 | WXVideoObject video = new WXVideoObject();
177 | video.videoUrl = videoUrl;
178 |
179 | WXMediaMessage msg = new WXMediaMessage(video);
180 | msg.title =title;
181 | msg.description =description;
182 | bmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true);
183 | msg.thumbData = Util.bmpToByteArray(bmp, true);
184 |
185 | SendMessageToWX.Req req = new SendMessageToWX.Req();
186 | req.transaction = buildTransaction("video");
187 | req.message = msg;
188 | req.scene = getTargetScene(scene);
189 | api.sendReq(req);
190 | }
191 |
192 | /**
193 | * 发送网页
194 | * @param scene 发送微信(WX_SESSION),朋友圈(WX_PYQ)或者收藏(WX_FAVORITE)
195 | * @param webpageUrl 网页地址
196 | * @param title 标题
197 | * @param description 描述,建议是APP名字
198 | * @param bmp 图片
199 | */
200 | public void shareWeb(int scene,String webpageUrl,String title,String description, Bitmap bmp) {
201 | WXWebpageObject webpage = new WXWebpageObject();
202 | webpage.webpageUrl =webpageUrl;
203 | WXMediaMessage msg = new WXMediaMessage(webpage);
204 | msg.title = title;
205 | msg.description = description;
206 | bmp= ThumbnailUtils.extractThumbnail(bmp, 100, 100);
207 | msg.thumbData = Util.bmpToByteArray(bmp, true);
208 | SendMessageToWX.Req req = new SendMessageToWX.Req();
209 | req.transaction = buildTransaction("webpage");
210 | req.message = msg;
211 | req.scene = getTargetScene(scene);
212 | api.sendReq(req);
213 | }
214 |
215 | /**
216 | * @param scene 发送微信(WX_SESSION),朋友圈(WX_PYQ)或者收藏(WX_FAVORITE)
217 | * @param webpageUrl 网页地址
218 | * @param userName 名字
219 | * @param path 小程序地址
220 | * @param title 标题
221 | * @param description 描述
222 | * @param bmp 图片
223 | */
224 | public void shareAppbrand(int scene,String webpageUrl,String userName,String path,String title,String description, Bitmap bmp) {
225 | WXMiniProgramObject miniProgram = new WXMiniProgramObject();
226 | miniProgram.webpageUrl = webpageUrl;
227 | miniProgram.userName = userName;
228 | miniProgram.path = path;
229 | WXMediaMessage msg = new WXMediaMessage(miniProgram);
230 | msg.title = title;
231 | msg.description =description;
232 | bmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true);
233 | msg.thumbData = Util.bmpToByteArray(bmp, true);
234 |
235 | SendMessageToWX.Req req = new SendMessageToWX.Req();
236 | req.transaction = buildTransaction("webpage");
237 | req.message = msg;
238 | req.scene =getTargetScene(scene);
239 | api.sendReq(req);
240 | }
241 | private String buildTransaction(final String type) {
242 | return (type == null) ? String.valueOf(System.currentTimeMillis()) : type + System.currentTimeMillis();
243 | }
244 |
245 | @Override
246 | public void onWXAuthError(AuthType mAuthType) {
247 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformError(AuthPlatform.WX,mAuthType);
248 | }
249 |
250 | @Override
251 | public void onWXAuthComplete(AuthType mAuthType, Object object) {
252 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformComplete(AuthPlatform.WX,mAuthType,object);
253 | }
254 |
255 | @Override
256 | public void onWXAuthCancel(AuthType mAuthType) {
257 | if(mOAuthPlatformListener!=null)mOAuthPlatformListener.onPlatformCancel(AuthPlatform.WX,mAuthType);
258 | }
259 | }
260 |
--------------------------------------------------------------------------------