├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── ThirdToolsLib
├── .gitignore
├── build.gradle
├── libs
│ ├── alipaySdk-20161222.jar
│ ├── libammsdk.jar
│ ├── mta-sdk-1.6.2.jar
│ └── open_sdk_r5778.jar
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── allure
│ │ └── thirdtools
│ │ ├── LoginManager.java
│ │ ├── PayManager.java
│ │ ├── PlatformManager.java
│ │ ├── bean
│ │ ├── LoginResult.java
│ │ ├── pay
│ │ │ └── WxPayBean.java
│ │ ├── token
│ │ │ ├── BaseTokenBean.java
│ │ │ ├── QQTokenBean.java
│ │ │ └── WeChatTokenBean.java
│ │ └── userinfo
│ │ │ ├── BaseUserInfoBean.java
│ │ │ └── QQUserInfoBean.java
│ │ ├── listener
│ │ └── AliPayListener.java
│ │ ├── login
│ │ ├── QQActivity.java
│ │ └── WXEntryActivity.java
│ │ ├── observer
│ │ ├── LoginEvent.java
│ │ ├── LoginObservable.java
│ │ ├── Observable.java
│ │ ├── Observer.java
│ │ └── SimpleObserver.java
│ │ ├── pay
│ │ ├── AliPayCallback.java
│ │ ├── AliPayResult.java
│ │ ├── AlipayRequest.java
│ │ └── WXPayEntryActivity.java
│ │ ├── platform
│ │ ├── LoginPlatform.java
│ │ ├── PayPlatform.java
│ │ ├── PlatformConfig.java
│ │ └── SharePlatform.java
│ │ └── share
│ │ ├── ShareUtils.java
│ │ └── WxUtil.java
│ └── res
│ └── values
│ ├── strings.xml
│ └── styles.xml
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── allure
│ │ └── third
│ │ ├── BaseApplication.java
│ │ └── MainActivity.java
│ └── res
│ ├── drawable-xxhdpi
│ └── ic_launcher.png
│ ├── layout
│ └── activity_main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── config.gradle
├── demo
└── guide_gif2.gif
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /.idea
9 | /captures
10 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | ThirdUtils
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
19 |
20 |
--------------------------------------------------------------------------------
/.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 | Android Lint
46 |
47 |
48 | Data flow issuesJava
49 |
50 |
51 | Groovy
52 |
53 |
54 | Initialization issuesJava
55 |
56 |
57 | Java
58 |
59 |
60 | Serialization issuesJava
61 |
62 |
63 | Threading issuesGroovy
64 |
65 |
66 | Threading issuesJava
67 |
68 |
69 |
70 |
71 | Android Lint
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | 1.8
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 此项目废弃,不再维护,有需要请使用另外2个开源项目
2 |
3 | [第三方登录(QQ/微信/新浪微博)](https://github.com/Allure0/ThirdLoginSDK)
4 |
5 |
6 | [第三方支付(支付宝/微信)](https://github.com/Allure0/ThirdPaySDK)
7 |
8 |
9 |
10 | 集成第三方登陆分享(微信/QQ),第三方支付(支付宝,微信,盛付通)
11 | 本Demo并不能直接使用,若要使用此项目,请将主项目的applicationId改为你的包名,signingConfigs配置签名配置
12 |
13 |
14 | # 使用方式
15 | gradle引入:
16 |
17 | ```
18 | compile 'com.allure0:ThirdToolsLib:1.0.2'
19 |
20 | ```
21 |
22 | ------
23 |
24 | 对于QQ需要在主项目build文件配置如下qq_id,将1105787445替换为你的QQ的APPKEY,参见主项目build.gradle
25 | ```
26 | manifestPlaceholders = [
27 | qq_id: "1105787445"
28 | ]
29 | ```
30 | ### 效果图
31 | 
32 |
33 | ### 初始化配置
34 | ```
35 | PlatformConfig platformConfig = PlatformConfig.getInstance()
36 | .setQqId("xxx")
37 | .setWeChatId("xxxx")
38 | .setWeChatSecret("");//如果是服务处理token和code不需要传此参数
39 |
40 | PlatformManager.getInstance()
41 | .setPlatformConfig(platformConfig)
42 | .initQQ(this)
43 | .initWx(this);
44 | ```
45 | ### QQ登陆
46 | ```
47 | LoginManager
48 | .with(MainActivity.this)
49 | .thirdLogin(LoginPlatform.PLATFORM_QQ);
50 | ```
51 |
52 | ### 微信登陆
53 | ```
54 | LoginManager.with(MainActivity.this)
55 | .thirdLogin(LoginPlatform.PLATFORM_WECHAT);
56 | ```
57 |
58 | ### 微信分享
59 | ```
60 | ShareUtils.initShareUtils(
61 | BaseApplication.getInstance(), text, text, imgUrl, url,
62 | BitmapFactory.decodeResource(BaseApplication.getInstance().getResources(),
63 | R.drawable.ic_launcher)
64 | ).shareToWX(MainActivity.this, ShareUtils.WECHAT_CIRCLE);
65 | ```
66 | ### QQ分享
67 | ```
68 | ShareUtils.initShareUtils(
69 | BaseApplication.getInstance(), text, text, imgUrl, url,
70 | BitmapFactory.decodeResource(BaseApplication.getInstance().getResources(),
71 | R.drawable.ic_launcher)
72 | ).shareToQQ(MainActivity.this, "测试啦");
73 | ```
74 | ### 微信支付
75 | ```
76 | PayManager.with(MainActivity.this)
77 | .wxPay( wxPayBean);
78 | ```
79 | ### 支付宝支付
80 | ```
81 | PayManager.with(MainActivity.this)
82 | .aliPay(ali_orderinfo, new AliPayListener() {
83 | @Override
84 | public void aliPayResult(String string, AliPayResult payResult) {
85 | Log.e("支付状态", string);
86 | Log.e("支付状态", payResult.getResultStatus());
87 | }
88 | });
89 | ```
90 |
91 |
92 | ### 观察者模式接受处理结果
93 | ```
94 | @Override
95 | public void thirdLoginSuccess(Object obj, LoginPlatform platform, LoginResult loginResult) {
96 |
97 | }
98 |
99 | @Override
100 | public void thirdLoginFailed(Object object, LoginPlatform loginPlatform) {
101 |
102 | }
103 |
104 | @Override
105 | public void thirdLoginCancel(LoginPlatform loginPlatform) {
106 |
107 | }
108 |
109 | @Override
110 | public void shareSuccess(SharePlatform sharePlatform) {
111 |
112 | }
113 |
114 | @Override
115 | public void shareFailed(SharePlatform sharePlatform) {
116 |
117 | }
118 |
119 | @Override
120 | public void paySuccess(PayPlatform payPlatform) {
121 |
122 | }
123 |
124 | @Override
125 | public void payFailed(PayPlatform payPlatform) {
126 |
127 | }
128 | ```
129 | ### 若有BUG或者疑问,请提交Issues。者QQ群:482906631
130 | #License
131 | Copyright 2017 Allure
132 |
133 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
134 |
135 | http://www.apache.org/licenses/LICENSE-2.0
136 |
137 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
138 |
--------------------------------------------------------------------------------
/ThirdToolsLib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ThirdToolsLib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion rootProject.ext.android.compileSdkVersion
5 | buildToolsVersion rootProject.ext.android.buildToolsVersion
6 |
7 | defaultConfig {
8 | minSdkVersion rootProject.ext.android.minSdkVersion
9 | targetSdkVersion rootProject.ext.android.targetSdkVersion
10 | versionCode rootProject.ext.android.versionCode
11 | versionName rootProject.ext.android.versionName
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 | dependencies {
21 | compile fileTree(dir: 'libs', include: ['*.jar'])
22 | compile rootProject.ext.dependencies.appcompatV7
23 | provided files('libs/mta-sdk-1.6.2.jar')//QQ
24 | provided files('libs/open_sdk_r5778.jar')//QQ
25 | provided files('libs/libammsdk.jar')//微信
26 | provided files('libs/alipaySdk-20161222.jar')//支付宝
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/ThirdToolsLib/libs/alipaySdk-20161222.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Allure0/ThirdUtils/020df7a5e70dfe4ebbd0b3b97284a0dc6f1494b3/ThirdToolsLib/libs/alipaySdk-20161222.jar
--------------------------------------------------------------------------------
/ThirdToolsLib/libs/libammsdk.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Allure0/ThirdUtils/020df7a5e70dfe4ebbd0b3b97284a0dc6f1494b3/ThirdToolsLib/libs/libammsdk.jar
--------------------------------------------------------------------------------
/ThirdToolsLib/libs/mta-sdk-1.6.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Allure0/ThirdUtils/020df7a5e70dfe4ebbd0b3b97284a0dc6f1494b3/ThirdToolsLib/libs/mta-sdk-1.6.2.jar
--------------------------------------------------------------------------------
/ThirdToolsLib/libs/open_sdk_r5778.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Allure0/ThirdUtils/020df7a5e70dfe4ebbd0b3b97284a0dc6f1494b3/ThirdToolsLib/libs/open_sdk_r5778.jar
--------------------------------------------------------------------------------
/ThirdToolsLib/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 /Users/luomin/Desktop/android-sdk-macosx/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 | -libraryjars libs/alipaySdk-20161222.jar
19 | -keep class com.alipay.android.app.IAlixPay{*;}
20 | -keep class com.alipay.android.app.IAlixPay$Stub{*;}
21 | -keep class com.alipay.android.app.IRemoteServiceCallback{*;}
22 | -keep class com.alipay.android.app.IRemoteServiceCallback$Stub{*;}
23 | -keep class com.alipay.sdk.app.PayTask{ public *;}
24 | -keep class com.alipay.sdk.app.AuthTask{ public *;}
25 | -keep class com.alipay.mobilesecuritysdk.*
26 | -keep class com.ut.*
27 | -keep class com.alipay.sdk.*
28 | -keep class com.alipay.*
29 |
30 |
31 | #-libraryjars libs/mta-sdk-1.6.2.jar
32 | #-libraryjars libs/open_sdk_r5778.jar
33 | #-keep class com.tencent.mm.sdk.*
34 |
35 |
36 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
22 |
23 |
28 |
29 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
46 |
47 |
48 |
49 |
50 |
51 |
55 |
56 |
60 |
61 |
62 |
63 |
67 |
68 |
72 |
73 |
74 |
75 |
76 |
77 |
83 |
84 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/LoginManager.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.support.v4.app.Fragment;
7 |
8 | import com.allure.thirdtools.login.QQActivity;
9 | import com.allure.thirdtools.platform.LoginPlatform;
10 | import com.allure.thirdtools.share.ShareUtils;
11 | import com.tencent.mm.sdk.modelmsg.SendAuth;
12 |
13 | /**
14 | * 作者:luomin
15 | * 邮箱:asddavid@163.com
16 | */
17 |
18 | public class LoginManager {
19 |
20 | private Object mContext;
21 |
22 |
23 | public LoginManager(Object object) {
24 | this.mContext = object;
25 | }
26 |
27 |
28 | public static LoginManager with(Context context) {
29 | return new LoginManager(context);
30 | }
31 |
32 | public static LoginManager with(Activity activity) {
33 | return new LoginManager(activity);
34 | }
35 |
36 | public static LoginManager with(Fragment fragmentV4) {
37 | return new LoginManager(fragmentV4);
38 | }
39 |
40 |
41 | public void thirdLogin(LoginPlatform platform) {
42 | switch (platform) {
43 | case PLATFORM_QQ:
44 | Intent intent = new Intent(ShareUtils.getActivtyContext(mContext), QQActivity.class);
45 | ShareUtils.getActivtyContext(mContext).startActivity(
46 | intent);
47 | break;
48 | case PLATFORM_WECHAT:
49 | SendAuth.Req req;
50 | req = new SendAuth.Req();
51 | req.scope = "snsapi_userinfo";
52 | req.state = "login_state";
53 | PlatformManager.getInstance().getIwxApi().sendReq(req);
54 | break;
55 | }
56 |
57 | }
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/PayManager.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.support.v4.app.Fragment;
6 |
7 | import com.allure.thirdtools.bean.pay.WxPayBean;
8 | import com.allure.thirdtools.listener.AliPayListener;
9 | import com.allure.thirdtools.pay.AliPayCallback;
10 | import com.allure.thirdtools.pay.AliPayResult;
11 | import com.allure.thirdtools.pay.AlipayRequest;
12 | import com.allure.thirdtools.share.ShareUtils;
13 | import com.tencent.mm.sdk.modelpay.PayReq;
14 |
15 | /**
16 | * 作者:luomin
17 | * 邮箱:asddavid@163.com
18 | */
19 |
20 | public class PayManager {
21 | private Object mContext;
22 |
23 | public PayManager(Object objcet) {
24 | this.mContext = objcet;
25 | }
26 |
27 | public static PayManager with(Context context) {
28 | return new PayManager(context);
29 | }
30 |
31 | public static PayManager with(Activity activity) {
32 | return new PayManager(activity);
33 | }
34 |
35 | public static PayManager with(Fragment fragmentV4) {
36 | return new PayManager(fragmentV4);
37 | }
38 |
39 | public void wxPay( WxPayBean wxPayBean) {
40 | PayReq payReq = new PayReq();
41 | payReq.appId = wxPayBean.getAppId();
42 | payReq.partnerId = wxPayBean.getPartnerId();
43 | payReq.prepayId = wxPayBean.getPrepayId();
44 | payReq.packageValue = wxPayBean.getPackageValue();
45 | payReq.nonceStr = wxPayBean.getNoncestr();
46 | payReq.timeStamp = wxPayBean.getTimestamp();
47 | payReq.sign = wxPayBean.getSign();
48 | PlatformManager.getInstance().getIwxApi().sendReq(payReq);
49 | }
50 |
51 |
52 | public void aliPay(String orderInfo, final AliPayListener aliPayListener) {
53 | AlipayRequest.StartAlipay(ShareUtils.getActivtyContext(mContext), orderInfo, new AliPayCallback() {
54 | @Override
55 | public void payResult(String result) {
56 | AliPayResult payResult = new AliPayResult(result);
57 | aliPayListener.aliPayResult(result, payResult);
58 | }
59 | });
60 |
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/PlatformManager.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools;
2 |
3 | import android.content.Context;
4 |
5 | import com.allure.thirdtools.platform.PlatformConfig;
6 | import com.tencent.mm.sdk.openapi.IWXAPI;
7 | import com.tencent.mm.sdk.openapi.WXAPIFactory;
8 | import com.tencent.tauth.Tencent;
9 |
10 | /**
11 | * 作者:luomin
12 | * 邮箱:asddavid@163.com
13 | */
14 |
15 | public class PlatformManager {
16 |
17 | private IWXAPI iwxapi;
18 | private Tencent tencent;
19 |
20 | public static PlatformConfig platformConfig;
21 |
22 | private static class SingletonHolder {
23 | private static final PlatformManager INSTANCE = new PlatformManager();
24 | }
25 |
26 | public static final PlatformManager getInstance() {
27 | return SingletonHolder.INSTANCE;
28 | }
29 |
30 | public PlatformManager setPlatformConfig(PlatformConfig config) {
31 | platformConfig = config;
32 | return this;
33 | }
34 |
35 |
36 | public IWXAPI getIwxApi() {
37 | return iwxapi;
38 | }
39 |
40 | public PlatformManager initWx(Context mContext) {
41 |
42 | if (null == iwxapi) {
43 | iwxapi = WXAPIFactory.createWXAPI(mContext.getApplicationContext(), platformConfig.getWeChatId(), true);
44 | iwxapi.registerApp(platformConfig.getWeChatId());
45 | }
46 | return this;
47 | }
48 |
49 | public Tencent getTencent() {
50 | return tencent;
51 | }
52 |
53 | public PlatformManager initQQ(Context mContext) {
54 | if (tencent == null) {
55 | tencent = Tencent.createInstance(platformConfig.getQqId(), mContext.getApplicationContext());
56 | }
57 | return this;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/bean/LoginResult.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.bean;
2 |
3 | import com.allure.thirdtools.bean.token.BaseTokenBean;
4 | import com.allure.thirdtools.bean.userinfo.BaseUserInfoBean;
5 |
6 | /**
7 | * 作者:luomin
8 | * 邮箱:asddavid@163.com
9 | */
10 |
11 | public class LoginResult {
12 |
13 | private BaseTokenBean baseTokenBean;
14 | private BaseUserInfoBean baseUserInfoBean;
15 |
16 | public LoginResult(BaseTokenBean baseTokenBean, BaseUserInfoBean baseUserInfoBean) {
17 | this.baseTokenBean = baseTokenBean;
18 | this.baseUserInfoBean = baseUserInfoBean;
19 | }
20 |
21 | public BaseTokenBean getBaseTokenBean() {
22 | return baseTokenBean;
23 | }
24 |
25 | public void setBaseTokenBean(BaseTokenBean baseTokenBean) {
26 | this.baseTokenBean = baseTokenBean;
27 | }
28 |
29 | public BaseUserInfoBean getBaseUserInfoBean() {
30 | return baseUserInfoBean;
31 | }
32 |
33 | public void setBaseUserInfoBean(BaseUserInfoBean baseUserInfoBean) {
34 | this.baseUserInfoBean = baseUserInfoBean;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/bean/pay/WxPayBean.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.bean.pay;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 作者:luomin
7 | * 邮箱:asddavid@163.com
8 | */
9 |
10 | public class WxPayBean implements Serializable {
11 | private String appId;
12 | private String partnerId;
13 | private String prepayId;
14 | private String packageValue;
15 | private String noncestr;
16 | private String timestamp;
17 | private String sign;
18 |
19 | public String getAppId() {
20 | return appId;
21 | }
22 |
23 | public void setAppId(String appId) {
24 | this.appId = appId;
25 | }
26 |
27 | public String getNoncestr() {
28 | return noncestr;
29 | }
30 |
31 | public void setNoncestr(String noncestr) {
32 | this.noncestr = noncestr;
33 | }
34 |
35 | public String getPackageValue() {
36 | return packageValue;
37 | }
38 |
39 | public void setPackageValue(String packageValue) {
40 | this.packageValue = packageValue;
41 | }
42 |
43 | public String getPartnerId() {
44 | return partnerId;
45 | }
46 |
47 | public void setPartnerId(String partnerId) {
48 | this.partnerId = partnerId;
49 | }
50 |
51 | public String getPrepayId() {
52 | return prepayId;
53 | }
54 |
55 | public void setPrepayId(String prepayId) {
56 | this.prepayId = prepayId;
57 | }
58 |
59 | public String getSign() {
60 | return sign;
61 | }
62 |
63 | public void setSign(String sign) {
64 | this.sign = sign;
65 | }
66 |
67 | public String getTimestamp() {
68 | return timestamp;
69 | }
70 |
71 | public void setTimestamp(String timestamp) {
72 | this.timestamp = timestamp;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/bean/token/BaseTokenBean.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.bean.token;
2 |
3 | /**
4 | * 作者:luomin
5 | * 邮箱:asddavid@163.com
6 | */
7 |
8 | public class BaseTokenBean {
9 | private String openId;
10 | private String accessToken;
11 |
12 |
13 |
14 | public String getAccessToken() {
15 | return accessToken;
16 | }
17 |
18 | public void setAccessToken(String accessToken) {
19 | this.accessToken = accessToken;
20 | }
21 |
22 | public String getOpenId() {
23 | return openId;
24 | }
25 |
26 | public void setOpenId(String openId) {
27 | this.openId = openId;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/bean/token/QQTokenBean.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.bean.token;
2 |
3 | import org.json.JSONException;
4 | import org.json.JSONObject;
5 |
6 | import java.io.Serializable;
7 |
8 | /**
9 | * 作者:luomin
10 | * 邮箱:asddavid@163.com
11 | */
12 |
13 | public class QQTokenBean extends BaseTokenBean implements Serializable {
14 |
15 | private String expires_in;
16 |
17 | public String getExpires_in() {
18 | return expires_in;
19 | }
20 |
21 | public void setExpires_in(String expires_in) {
22 | this.expires_in = expires_in;
23 | }
24 |
25 | public static QQTokenBean getToken(Object object) {
26 | QQTokenBean token = new QQTokenBean();
27 | JSONObject jsonObject = (JSONObject) object;
28 | try {
29 | token.setAccessToken(jsonObject.getString("access_token"));
30 | token.setOpenId(jsonObject.getString("openid"));
31 | token.setExpires_in(jsonObject.getString("expires_in"));
32 | } catch (JSONException e) {
33 | e.printStackTrace();
34 | }
35 | return token;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/bean/token/WeChatTokenBean.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.bean.token;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 作者:luomin
7 | * 邮箱:asddavid@163.com
8 | */
9 |
10 | public class WeChatTokenBean extends BaseTokenBean implements Serializable {
11 | }
12 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/bean/userinfo/BaseUserInfoBean.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.bean.userinfo;
2 |
3 | /**
4 | * 作者:luomin
5 | * 邮箱:asddavid@163.com
6 | */
7 |
8 | public class BaseUserInfoBean {
9 |
10 | private String openId;
11 |
12 | private String nickname;
13 |
14 | private int sex;
15 |
16 | private String headImageUrl;
17 |
18 | private String headImageUrlLarge;
19 |
20 | public String getHeadImageUrl() {
21 | return headImageUrl;
22 | }
23 |
24 | public void setHeadImageUrl(String headImageUrl) {
25 | this.headImageUrl = headImageUrl;
26 | }
27 |
28 | public String getHeadImageUrlLarge() {
29 | return headImageUrlLarge;
30 | }
31 |
32 | public void setHeadImageUrlLarge(String headImageUrlLarge) {
33 | this.headImageUrlLarge = headImageUrlLarge;
34 | }
35 |
36 | public String getNickname() {
37 | return nickname;
38 | }
39 |
40 | public void setNickname(String nickname) {
41 | this.nickname = nickname;
42 | }
43 |
44 | public String getOpenId() {
45 | return openId;
46 | }
47 |
48 | public void setOpenId(String openId) {
49 | this.openId = openId;
50 | }
51 |
52 | public int getSex() {
53 | return sex;
54 | }
55 |
56 | public void setSex(int sex) {
57 | this.sex = sex;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/bean/userinfo/QQUserInfoBean.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.bean.userinfo;
2 |
3 | import android.text.TextUtils;
4 |
5 | import org.json.JSONException;
6 | import org.json.JSONObject;
7 |
8 | import java.io.Serializable;
9 |
10 | /**
11 | * 作者:luomin
12 | * 邮箱:asddavid@163.com
13 | */
14 |
15 | public class QQUserInfoBean extends BaseUserInfoBean implements Serializable {
16 | private String qZoneHeadImage;
17 |
18 | private String qZoneHeadImageLarge;
19 |
20 | public String getqZoneHeadImage() {
21 | return qZoneHeadImage;
22 | }
23 |
24 | public void setqZoneHeadImage(String qZoneHeadImage) {
25 | this.qZoneHeadImage = qZoneHeadImage;
26 | }
27 |
28 | public String getqZoneHeadImageLarge() {
29 | return qZoneHeadImageLarge;
30 | }
31 |
32 | public void setqZoneHeadImageLarge(String qZoneHeadImageLarge) {
33 | this.qZoneHeadImageLarge = qZoneHeadImageLarge;
34 | }
35 |
36 | public static QQUserInfoBean getUserInfo(String openId, JSONObject jsonObject) {
37 | QQUserInfoBean user = new QQUserInfoBean();
38 |
39 | try {
40 | user.setNickname(jsonObject.getString("nickname"));
41 | user.setOpenId(openId);
42 | user.setSex(TextUtils.equals("男", jsonObject.getString("gender")) ? 1 : 2);
43 | user.setHeadImageUrl(jsonObject.getString("figureurl_qq_1"));
44 | user.setHeadImageUrlLarge(jsonObject.getString("figureurl_qq_2"));
45 | user.setqZoneHeadImage(jsonObject.getString("figureurl_1"));
46 | user.setqZoneHeadImageLarge(jsonObject.getString("figureurl_2"));
47 | } catch (JSONException e) {
48 | e.printStackTrace();
49 | }
50 |
51 | return user;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/listener/AliPayListener.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.listener;
2 |
3 | import com.allure.thirdtools.pay.AliPayResult;
4 |
5 | /**
6 | * 作者:luomin
7 | * 邮箱:asddavid@163.com
8 | */
9 |
10 | public interface AliPayListener {
11 | void aliPayResult(String string,AliPayResult payResult);
12 | }
13 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/login/QQActivity.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.login;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 |
8 | import com.allure.thirdtools.PlatformManager;
9 | import com.allure.thirdtools.bean.LoginResult;
10 | import com.allure.thirdtools.bean.token.QQTokenBean;
11 | import com.allure.thirdtools.bean.userinfo.QQUserInfoBean;
12 | import com.allure.thirdtools.observer.LoginEvent;
13 | import com.allure.thirdtools.platform.LoginPlatform;
14 | import com.tencent.connect.UserInfo;
15 | import com.tencent.tauth.IUiListener;
16 | import com.tencent.tauth.Tencent;
17 | import com.tencent.tauth.UiError;
18 |
19 | import org.json.JSONObject;
20 |
21 | /**
22 | * 作者:luomin
23 | * 邮箱:asddavid@163.com
24 | */
25 |
26 | public class QQActivity extends AppCompatActivity {
27 |
28 | private Tencent mTencent;
29 | private MyListener mListener;
30 |
31 | @Override
32 | protected void onCreate(@Nullable Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | mListener = new MyListener();
35 |
36 | mTencent= PlatformManager.getInstance().getTencent();
37 | QQLogin();
38 | }
39 |
40 |
41 | // 实现登录成功与否的接口
42 | private class MyListener implements IUiListener {
43 |
44 | @Override
45 | public void onComplete(final Object object) { //登录成功
46 |
47 | //获取token和openId
48 | final QQTokenBean qqTokenBean = QQTokenBean.getToken(object);
49 | mTencent.setOpenId(qqTokenBean.getOpenId());
50 | mTencent.setAccessToken(qqTokenBean.getAccessToken(), qqTokenBean.getExpires_in());
51 | //获取用户信息
52 | getUserInfo(object,qqTokenBean);
53 |
54 |
55 |
56 | }
57 |
58 | @Override
59 | public void onError(UiError uiError) { //登录失败
60 | LoginEvent.getDefault().postFailed(uiError, LoginPlatform.PLATFORM_QQ);
61 | QQActivity.this. finish();
62 | }
63 |
64 | @Override
65 | public void onCancel() { //取消登录
66 | LoginEvent.getDefault().postCancel(LoginPlatform.PLATFORM_QQ);
67 | QQActivity.this. finish();
68 |
69 | }
70 | }
71 |
72 | private void getUserInfo(final Object object, final QQTokenBean qqTokenBean) {
73 | if (mTencent != null && mTencent.isSessionValid()) {
74 | UserInfo userInfo = new UserInfo(QQActivity.this, mTencent.getQQToken());
75 | userInfo.getUserInfo(new IUiListener() {
76 | @Override
77 | public void onComplete(Object o) {
78 | JSONObject jb = (JSONObject) o;
79 | LoginResult loginResult = new LoginResult(QQTokenBean.getToken(object),
80 | QQUserInfoBean.getUserInfo(qqTokenBean.getOpenId(), jb));
81 |
82 | LoginEvent.getDefault().postSuccess(object.toString(),
83 | LoginPlatform.PLATFORM_QQ,
84 | loginResult);
85 | QQActivity.this. finish();
86 | finish();
87 | }
88 |
89 | @Override
90 | public void onError(UiError uiError) {
91 | finish();
92 | }
93 |
94 | @Override
95 | public void onCancel() {
96 | finish();
97 | }
98 | });
99 | }
100 | }
101 |
102 |
103 | private void QQLogin() {
104 | // if (!mTencent.isSessionValid()) {
105 | mTencent.login(this, "allure", mListener);
106 | // }
107 | }
108 |
109 | @Override
110 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
111 | super.onActivityResult(requestCode, resultCode, data);
112 | mTencent.onActivityResultData(requestCode, resultCode, data, mListener);
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/login/WXEntryActivity.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.login;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 |
8 | import com.allure.thirdtools.PlatformManager;
9 | import com.allure.thirdtools.observer.LoginEvent;
10 | import com.allure.thirdtools.platform.LoginPlatform;
11 | import com.allure.thirdtools.platform.SharePlatform;
12 | import com.tencent.mm.sdk.modelbase.BaseReq;
13 | import com.tencent.mm.sdk.modelbase.BaseResp;
14 | import com.tencent.mm.sdk.modelmsg.SendAuth;
15 | import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
16 |
17 | /**
18 | * 微信分享与登陆
19 | * 作者:luomin
20 | * 邮箱:asddavid@163.com
21 | */
22 |
23 | public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
24 | private static final String TAG = "WXEntryActivity";
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | try {
30 | PlatformManager.getInstance().getIwxApi().handleIntent(getIntent(),this);
31 | } catch (NullPointerException e) {
32 | e.printStackTrace();
33 | }
34 |
35 | }
36 |
37 | @Override
38 | protected void onNewIntent(Intent intent) {
39 | super.onNewIntent(intent);
40 | Log.i(TAG, "onNewIntent");
41 | setIntent(intent);
42 | PlatformManager.getInstance().getIwxApi().handleIntent(getIntent(),this);
43 | }
44 |
45 | /**
46 | * 请求回调接口
47 | */
48 | @Override
49 | public void onReq(BaseReq req) {
50 | Log.i(TAG, "req");
51 | }
52 |
53 | /**
54 | * 请求响应回调接口
55 | */
56 | @Override
57 | public void onResp(BaseResp resp) {
58 | Log.i(TAG, "onResp");
59 |
60 | if (resp.getType() == 1) {//登陆
61 | SendAuth.Resp sendAuthResp = (SendAuth.Resp) resp;
62 | String code = sendAuthResp.code;
63 | if (resp.errCode == BaseResp.ErrCode.ERR_OK) {
64 | LoginEvent.getDefault().postSuccess(code,
65 | LoginPlatform.PLATFORM_WECHAT,
66 | null);
67 | } else if (resp.errCode == BaseResp.ErrCode.ERR_USER_CANCEL) {
68 | LoginEvent.getDefault().postCancel(LoginPlatform.PLATFORM_WECHAT);
69 | } else {
70 | LoginEvent.getDefault().postFailed(resp, LoginPlatform.PLATFORM_WECHAT);
71 | }
72 | finish();
73 |
74 | } else if (resp.getType() == 2) {//分享
75 | if (resp.errCode == BaseResp.ErrCode.ERR_OK) {
76 | LoginEvent.getDefault().shareSuccess(SharePlatform.PLATFORM_WECHAT);
77 | } else {
78 | LoginEvent.getDefault().shareFailed(SharePlatform.PLATFORM_WECHAT);
79 | }
80 | finish();
81 | }
82 |
83 |
84 | }
85 |
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/observer/LoginEvent.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.observer;
2 |
3 | import com.allure.thirdtools.bean.LoginResult;
4 | import com.allure.thirdtools.platform.LoginPlatform;
5 | import com.allure.thirdtools.platform.PayPlatform;
6 | import com.allure.thirdtools.platform.SharePlatform;
7 |
8 | /**
9 | * 作者:luomin
10 | * 邮箱:asddavid@163.com
11 | */
12 |
13 | public class LoginEvent {
14 | private static LoginEvent instance;
15 | private LoginObservable loginObservableble;
16 |
17 | public static LoginEvent getDefault() {
18 | if (instance == null) {
19 | synchronized (LoginEvent.class) {
20 | if (instance == null) {
21 | instance = new LoginEvent();
22 | }
23 | }
24 | }
25 | return instance;
26 | }
27 |
28 | private LoginEvent() {
29 | loginObservableble = new LoginObservable();
30 | }
31 |
32 |
33 | public void register(Observer observer) {
34 | loginObservableble.addObserver(observer);
35 | }
36 |
37 |
38 | public void unregister(Observer observer) {
39 | loginObservableble.removeObserver(observer);
40 | }
41 |
42 |
43 | public void postSuccess(Object obj, LoginPlatform loginPlatform, LoginResult loginResult) {
44 | loginObservableble.successObservers(obj,loginPlatform,loginResult);
45 | }
46 |
47 | public void postFailed(Object obj, LoginPlatform loginPlatform) {
48 | loginObservableble.failedObservers(obj,loginPlatform);
49 | }
50 |
51 | public void postCancel(LoginPlatform loginPlatform) {
52 | loginObservableble.cancelObservers(loginPlatform);
53 | }
54 |
55 | public void shareSuccess(SharePlatform sharePlatform) {
56 | loginObservableble.shareSuccess(sharePlatform);
57 |
58 | }
59 | public void shareFailed(SharePlatform sharePlatform) {
60 | loginObservableble.shareFailed(sharePlatform);
61 |
62 | }
63 |
64 | public void paySuccess(PayPlatform payPlatform) {
65 | loginObservableble.paySuccess(payPlatform);
66 | }
67 | public void payFailed(PayPlatform payPlatform) {
68 | loginObservableble.payFailed(payPlatform);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/observer/LoginObservable.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.observer;
2 |
3 | import android.util.Log;
4 |
5 | import com.allure.thirdtools.bean.LoginResult;
6 | import com.allure.thirdtools.platform.LoginPlatform;
7 | import com.allure.thirdtools.platform.PayPlatform;
8 | import com.allure.thirdtools.platform.SharePlatform;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * 作者:luomin
14 | * 邮箱:asddavid@163.com
15 | */
16 |
17 | public class LoginObservable implements Observable {
18 | private ArrayList observers;
19 |
20 | public boolean checkNull(){
21 | if (observers == null || observers.size() <= 0) {
22 | Log.e("observers","observers为null或者size<=0,请先注册");
23 | return true;
24 | }
25 | return false;
26 | }
27 | @Override
28 | public void addObserver(Observer observer) {
29 | if (observers == null) {
30 | observers = new ArrayList<>();
31 | }
32 | observers.add(observer);
33 | }
34 |
35 | @Override
36 | public void removeObserver(Observer observer) {
37 | if(checkNull()){
38 | return;
39 | }
40 | observers.remove(observer);
41 | }
42 |
43 | @Override
44 | public void successObservers(Object obj, LoginPlatform loginPlatform, LoginResult loginResult) {
45 | if(checkNull()){
46 | return;
47 | }
48 | for (Observer observer : observers) {
49 | observer.thirdLoginSuccess(obj,loginPlatform,loginResult);
50 | }
51 | }
52 |
53 | @Override
54 | public void failedObservers(Object obj,LoginPlatform loginPlatform) {
55 | if(checkNull()){
56 | return;
57 | }
58 | for (Observer observer : observers) {
59 | observer.thirdLoginFailed(obj,loginPlatform);
60 | }
61 | }
62 |
63 | @Override
64 | public void cancelObservers(LoginPlatform loginPlatform) {
65 | if(checkNull()){
66 | return;
67 | }
68 | for (Observer observer : observers) {
69 | observer.thirdLoginCancel(loginPlatform);
70 | }
71 | }
72 |
73 | @Override
74 | public void shareSuccess(SharePlatform sharePlatform) {
75 | checkNull();
76 | for (Observer observer : observers) {
77 | observer.shareSuccess(sharePlatform);
78 | }
79 | }
80 | @Override
81 | public void shareFailed(SharePlatform sharePlatform) {
82 | if(checkNull()){
83 | return;
84 | }
85 | for (Observer observer : observers) {
86 | observer.shareFailed(sharePlatform);
87 | }
88 | }
89 |
90 | @Override
91 | public void paySuccess(PayPlatform payPlatform) {
92 | if(checkNull()){
93 | return;
94 | }
95 | for (Observer observer : observers) {
96 | observer.paySuccess(payPlatform);
97 | }
98 | }
99 |
100 | @Override
101 | public void payFailed(PayPlatform payPlatform) {
102 | if(checkNull()){
103 | return;
104 | }
105 | for (Observer observer : observers) {
106 | observer.payFailed(payPlatform);
107 | }
108 | }
109 |
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/observer/Observable.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.observer;
2 |
3 | import com.allure.thirdtools.bean.LoginResult;
4 | import com.allure.thirdtools.platform.LoginPlatform;
5 | import com.allure.thirdtools.platform.PayPlatform;
6 | import com.allure.thirdtools.platform.SharePlatform;
7 |
8 | /**
9 | * 作者:luomin
10 | * 邮箱:asddavid@163.com
11 | */
12 |
13 | public interface Observable {
14 |
15 | void addObserver(Observer observer);
16 |
17 |
18 | void removeObserver(Observer observer);
19 |
20 |
21 | public abstract void successObservers(Object obj, LoginPlatform loginPlatform, LoginResult loginResult);
22 |
23 | public abstract void failedObservers(Object obj,LoginPlatform loginPlatform);
24 |
25 | public abstract void cancelObservers(LoginPlatform loginPlatform);
26 |
27 | public abstract void shareSuccess(SharePlatform sharePlatform);
28 | public abstract void shareFailed(SharePlatform sharePlatform);
29 |
30 |
31 | public abstract void paySuccess(PayPlatform payPlatform);
32 |
33 | public abstract void payFailed(PayPlatform payPlatform);
34 |
35 | }
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/observer/Observer.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.observer;
2 |
3 | import com.allure.thirdtools.bean.LoginResult;
4 | import com.allure.thirdtools.platform.LoginPlatform;
5 | import com.allure.thirdtools.platform.PayPlatform;
6 | import com.allure.thirdtools.platform.SharePlatform;
7 |
8 | /**
9 | * 作者:luomin
10 | * 邮箱:asddavid@163.com
11 | */
12 |
13 | public interface Observer {
14 |
15 | public abstract void thirdLoginSuccess(Object obj, LoginPlatform platform, LoginResult loginResult);
16 |
17 | public abstract void thirdLoginFailed(Object object, LoginPlatform loginPlatform);
18 |
19 | public abstract void thirdLoginCancel(LoginPlatform loginPlatform);
20 |
21 | public abstract void shareSuccess(SharePlatform sharePlatform);
22 |
23 | public abstract void shareFailed(SharePlatform sharePlatform);
24 |
25 | public abstract void paySuccess(PayPlatform payPlatform);
26 |
27 | public abstract void payFailed(PayPlatform payPlatform);
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/observer/SimpleObserver.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.observer;
2 |
3 | import com.allure.thirdtools.bean.LoginResult;
4 | import com.allure.thirdtools.platform.LoginPlatform;
5 | import com.allure.thirdtools.platform.PayPlatform;
6 | import com.allure.thirdtools.platform.SharePlatform;
7 |
8 | /**
9 | * 作者:luomin
10 | * 邮箱:asddavid@163.com
11 | */
12 |
13 | public class SimpleObserver implements Observer {
14 | @Override
15 | public void thirdLoginSuccess(Object obj, LoginPlatform platform, LoginResult loginResult) {
16 |
17 | }
18 |
19 | @Override
20 | public void thirdLoginFailed(Object object, LoginPlatform loginPlatform) {
21 |
22 | }
23 |
24 | @Override
25 | public void thirdLoginCancel(LoginPlatform loginPlatform) {
26 |
27 | }
28 |
29 | @Override
30 | public void shareSuccess(SharePlatform sharePlatform) {
31 |
32 | }
33 |
34 | @Override
35 | public void shareFailed(SharePlatform sharePlatform) {
36 |
37 | }
38 |
39 | @Override
40 | public void paySuccess(PayPlatform payPlatform) {
41 |
42 | }
43 |
44 | @Override
45 | public void payFailed(PayPlatform payPlatform) {
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/pay/AliPayCallback.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.pay;
2 |
3 | /**
4 | * 作者:luomin
5 | * 邮箱:asddavid@163.com
6 | */
7 | public interface AliPayCallback {
8 |
9 | void payResult(String result);
10 | }
11 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/pay/AliPayResult.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.pay;
import android.text.TextUtils;
/**
* 作者:luomin
* 邮箱:asddavid@163.com
*/
public class AliPayResult {
private String resultStatus;
private String result;
private String memo;
public AliPayResult(String rawResult) {
if (TextUtils.isEmpty(rawResult))
return;
String[] resultParams = rawResult.split(";");
for (String resultParam : resultParams) {
if (resultParam.startsWith("resultStatus")) {
resultStatus = gatValue(resultParam, "resultStatus");
}
if (resultParam.startsWith("result")) {
result = gatValue(resultParam, "result");
}
if (resultParam.startsWith("memo")) {
memo = gatValue(resultParam, "memo");
}
}
}
@Override
public String toString() {
return "resultStatus={" + resultStatus + "};memo={" + memo
+ "};result={" + result + "}";
}
private String gatValue(String content, String key) {
String prefix = key + "={";
return content.substring(content.indexOf(prefix) + prefix.length(),
content.lastIndexOf("}"));
}
public String getResultStatus() {
return resultStatus;
}
public String getMemo() {
return memo;
}
public String getResult() {
return result;
}
}
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/pay/AlipayRequest.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.pay;
2 |
3 | import android.app.Activity;
4 |
5 | import com.alipay.sdk.app.PayTask;
6 |
7 | /**
8 | * 作者:luomin
9 | * 邮箱:asddavid@163.com
10 | */
11 | public class AlipayRequest {
12 |
13 | public static void StartAlipay(final Activity activity, final String payInfo, final AliPayCallback payCallback){
14 | // 必须异步调用
15 | new Thread(new Runnable() {
16 | @Override
17 | public void run() {
18 | // 构造PayTask 对象
19 | final PayTask alipay = new PayTask(activity);
20 | // 调用支付接口,获取支付结果
21 | payCallback.payResult(alipay.pay(payInfo,true));
22 | }
23 | }).start();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/pay/WXPayEntryActivity.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.pay;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 |
8 | import com.allure.thirdtools.PlatformManager;
9 | import com.allure.thirdtools.observer.LoginEvent;
10 | import com.allure.thirdtools.platform.PayPlatform;
11 | import com.tencent.mm.sdk.constants.ConstantsAPI;
12 | import com.tencent.mm.sdk.modelbase.BaseReq;
13 | import com.tencent.mm.sdk.modelbase.BaseResp;
14 | import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
15 |
16 | /**
17 | * 作者:luomin
18 | * 邮箱:asddavid@163.com
19 | */
20 |
21 | public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | try {
27 | PlatformManager.getInstance().getIwxApi().handleIntent(getIntent(),this);
28 | } catch (NullPointerException e) {
29 | e.printStackTrace();
30 | }
31 | }
32 |
33 | @Override
34 | protected void onNewIntent(Intent intent) {
35 | super.onNewIntent(intent);
36 | Log.e("WXPayEntryActivity", "onNewIntent");
37 | setIntent(intent);
38 | PlatformManager.getInstance().getIwxApi().handleIntent(getIntent(),this);
39 | }
40 |
41 | @Override
42 | public void onReq(BaseReq baseReq) {
43 |
44 | }
45 |
46 | @Override
47 | public void onResp(BaseResp baseResp) {
48 | Log.i("TAG", baseResp.getType() + "\n" + baseResp.errStr + "\n" + baseResp.errCode);
49 | if (baseResp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
50 | Log.e("resp",baseResp.errCode+"");
51 | if (baseResp.errCode == 0) {
52 | LoginEvent.getDefault().paySuccess(PayPlatform.PLATFORM_WECHAT);
53 | WXPayEntryActivity.this.finish();
54 | } else {
55 | LoginEvent.getDefault().payFailed(PayPlatform.PLATFORM_WECHAT);
56 | WXPayEntryActivity.this.finish();
57 |
58 | }
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/platform/LoginPlatform.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.platform;
2 |
3 | /**
4 | * 作者:luomin
5 | * 邮箱:asddavid@163.com
6 | */
7 |
8 | public enum LoginPlatform {
9 | PLATFORM_QQ,
10 | PLATFORM_WECHAT
11 | }
12 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/platform/PayPlatform.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.platform;
2 |
3 | /**
4 | * 作者:luomin
5 | * 邮箱:asddavid@163.com
6 | */
7 |
8 | public enum PayPlatform {
9 | PLATFORM_ALI,
10 | PLATFORM_WECHAT,
11 | }
12 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/platform/PlatformConfig.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.platform;
2 |
3 | /**
4 | * 作者:luomin
5 | * 邮箱:asddavid@163.com
6 | */
7 |
8 | public class PlatformConfig {
9 | private String qqId;
10 | private String weChatId;
11 | private String weChatSecret;
12 |
13 |
14 |
15 | public static PlatformConfig getInstance() {
16 | return new PlatformConfig();
17 | }
18 | public String getQqId() {
19 | return qqId;
20 | }
21 |
22 | public PlatformConfig setQqId(String qqId) {
23 | this.qqId = qqId;
24 | return this;
25 | }
26 |
27 | public String getWeChatId() {
28 | return weChatId;
29 | }
30 |
31 | public PlatformConfig setWeChatId(String weChatId) {
32 | this.weChatId = weChatId;
33 | return this;
34 | }
35 |
36 | public String getWeChatSecret() {
37 | return weChatSecret;
38 | }
39 |
40 | public PlatformConfig setWeChatSecret(String weChatSecret) {
41 | this.weChatSecret = weChatSecret;
42 | return this;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/platform/SharePlatform.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.platform;
2 |
3 | /**
4 | * 作者:luomin
5 | * 邮箱:asddavid@163.com
6 | */
7 | public enum SharePlatform {
8 | PLATFORM_QQ,
9 | PLATFORM_WECHAT
10 | }
11 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/share/ShareUtils.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.share;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.graphics.Bitmap;
6 | import android.os.Bundle;
7 | import android.support.v4.app.Fragment;
8 | import android.widget.Toast;
9 |
10 | import com.allure.thirdtools.PlatformManager;
11 | import com.tencent.mm.sdk.modelmsg.SendMessageToWX;
12 | import com.tencent.mm.sdk.modelmsg.WXImageObject;
13 | import com.tencent.mm.sdk.modelmsg.WXMediaMessage;
14 | import com.tencent.mm.sdk.modelmsg.WXTextObject;
15 | import com.tencent.mm.sdk.modelmsg.WXWebpageObject;
16 | import com.tencent.mm.sdk.openapi.IWXAPI;
17 | import com.tencent.tauth.Tencent;
18 |
19 | /**
20 | * 作者:luomin
21 | * 邮箱:asddavid@163.com
22 | */
23 | public class ShareUtils {
24 | private static ShareUtils shareUtils;
25 | private String shareContent, shareTitle, shareUrl, picUrl;
26 | private Context context;
27 | private Bitmap shareBitmap;
28 | public static final int WECHAT_FRIEND = SendMessageToWX.Req.WXSceneSession;
29 | public static final int WECHAT_CIRCLE = SendMessageToWX.Req.WXSceneTimeline;
30 |
31 | private ShareUtils(Context context) {
32 | this.context = context;
33 | }
34 |
35 | public static ShareUtils initShareUtils(Context context) {
36 | if (shareUtils == null)
37 | shareUtils = new ShareUtils(context);
38 | return shareUtils;
39 | }
40 |
41 | /**
42 | * @param context
43 | * @param shareTitle
44 | * @param shareContent
45 | * @param picUrl
46 | * @param shareUrl
47 | * @param shareBitmap
48 | * @return
49 | */
50 | public static ShareUtils initShareUtils(Context context, String shareTitle, String shareContent, String picUrl, String shareUrl, Bitmap shareBitmap) {
51 | if (shareUtils == null)
52 | shareUtils = new ShareUtils(context);
53 | shareUtils.shareUrl = shareUrl;
54 | shareUtils.shareTitle = shareTitle;
55 | shareUtils.shareContent = shareContent;
56 | shareUtils.shareBitmap = shareBitmap;
57 | shareUtils.picUrl = picUrl;
58 | return shareUtils;
59 | }
60 |
61 | /**
62 | * 分享到微信朋友圈或者好友
63 | *
64 | * @param context
65 | * @param flag 0是朋友圈,1是好友
66 | */
67 | public void shareToWX(Context context, final int flag) {
68 | IWXAPI api = PlatformManager.getInstance().getIwxApi();
69 | if (api.isWXAppSupportAPI()) {
70 | WXWebpageObject webpage = new WXWebpageObject();
71 | webpage.webpageUrl = shareUrl;
72 | WXMediaMessage msg = new WXMediaMessage(webpage);
73 |
74 | msg.title = shareTitle;
75 | msg.description = shareContent;
76 | msg.setThumbImage(shareBitmap);
77 |
78 | SendMessageToWX.Req req = new SendMessageToWX.Req();
79 | req.transaction = String.valueOf(System.currentTimeMillis());
80 | req.message = msg;
81 | req.scene = flag;
82 | api.sendReq(req);
83 | return;
84 | }
85 | }
86 |
87 |
88 | /**
89 | * 文字分享
90 | *
91 | * @param shareText
92 | * @param flag 0是朋友圈,1是好友
93 | */
94 | public void shareWxText(String shareText, int flag) {
95 | if (isWxInstall()) {
96 | WXTextObject textObj = new WXTextObject();
97 | textObj.text = shareText;
98 |
99 | WXMediaMessage msg = new WXMediaMessage();
100 | msg.mediaObject = textObj;
101 | // msg.title = "Will be ignored";
102 | msg.description = shareText;
103 |
104 | SendMessageToWX.Req req = new SendMessageToWX.Req();
105 | req.transaction = buildTransaction("text");
106 | req.message = msg;
107 | req.scene = flag;
108 |
109 | IWXAPI api = PlatformManager.getInstance().getIwxApi();
110 | api.sendReq(req);
111 | return;
112 | }
113 |
114 | }
115 |
116 | /**
117 | * 微信图片分享
118 | *
119 | * @param bmp
120 | * @param flag 0是朋友圈,1是好友
121 | */
122 | public void shareWxPic(Bitmap bmp, final int flag) {
123 |
124 | if (isWxInstall()) {
125 | WXImageObject imgObj = new WXImageObject(bmp);
126 | WXMediaMessage msg = new WXMediaMessage();
127 | msg.mediaObject = imgObj;
128 | Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, 120, 120, true);
129 | bmp.recycle();
130 | msg.thumbData = WxUtil.bmpToByteArray(thumbBmp, true);
131 |
132 | SendMessageToWX.Req req = new SendMessageToWX.Req();
133 | req.transaction = buildTransaction("img");
134 | req.message = msg;
135 | req.scene = flag;
136 | IWXAPI api = PlatformManager.getInstance().getIwxApi();
137 | api.sendReq(req);
138 | return;
139 | }
140 |
141 | }
142 |
143 |
144 | /**
145 | * 分享给QQ好友以及QQ空间
146 | *
147 | * @param context
148 | * @param appName
149 | */
150 | public void shareToQQ(Context context, String appName) {
151 | Tencent mTencent = null;
152 | mTencent = PlatformManager.getInstance().getTencent();
153 | Bundle bundle = new Bundle();
154 | bundle.putString("title", shareTitle);// 标题
155 | bundle.putString("imageUrl", picUrl);
156 | bundle.putString("targetUrl", shareUrl);
157 | bundle.putString("summary", shareContent);// 内容
158 | bundle.putString("appName", appName);
159 | mTencent.shareToQQ((Activity) context, bundle, null);
160 | }
161 |
162 | public static Activity getActivtyContext(Object object) {
163 | if (object instanceof Activity) {
164 | return (Activity) object;
165 | } else if (object instanceof Fragment) {
166 | return ((Fragment) object).getActivity();
167 | } else if (object instanceof android.app.Fragment) {
168 | return ((Fragment) object).getActivity();
169 | }
170 | return null;
171 | }
172 |
173 |
174 | public boolean isWxInstall() {
175 | if (PlatformManager.getInstance().getIwxApi().isWXAppSupportAPI()) {
176 | return true;
177 | } else {
178 | Toast.makeText(context, "请先安装微信客户端", Toast.LENGTH_SHORT).show();
179 | return false;
180 | }
181 | }
182 |
183 | private String buildTransaction(final String type) {
184 | return (type == null) ? String.valueOf(System.currentTimeMillis()) : type + System.currentTimeMillis();
185 | }
186 | }
187 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/java/com/allure/thirdtools/share/WxUtil.java:
--------------------------------------------------------------------------------
1 | package com.allure.thirdtools.share;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.Bitmap.CompressFormat;
5 | import android.graphics.BitmapFactory;
6 | import android.util.Log;
7 |
8 | import junit.framework.Assert;
9 |
10 | import java.io.ByteArrayOutputStream;
11 | import java.io.File;
12 | import java.io.IOException;
13 | import java.io.InputStream;
14 | import java.io.RandomAccessFile;
15 | import java.net.HttpURLConnection;
16 | import java.net.MalformedURLException;
17 | import java.net.URL;
18 | import java.net.URLConnection;
19 |
20 | /**
21 | *
22 | * @charset UTF-8
23 | * @version
24 | */
25 | public class WxUtil {
26 |
27 | private static final String TAG = "SDK_Sample.Util";
28 |
29 | public static byte[] bmpToByteArray(final Bitmap bmp, final boolean needRecycle) {
30 | ByteArrayOutputStream output = new ByteArrayOutputStream();
31 | bmp.compress(CompressFormat.PNG, 100, output);
32 | if (needRecycle) {
33 | bmp.recycle();
34 | }
35 |
36 | byte[] result = output.toByteArray();
37 | try {
38 | output.close();
39 | } catch (Exception e) {
40 | e.printStackTrace();
41 | }
42 |
43 | return result;
44 | }
45 |
46 | public static byte[] getHtmlByteArray(final String url) {
47 | URL htmlUrl = null;
48 | InputStream inStream = null;
49 | try {
50 | htmlUrl = new URL(url);
51 | URLConnection connection = htmlUrl.openConnection();
52 | HttpURLConnection httpConnection = (HttpURLConnection)connection;
53 | int responseCode = httpConnection.getResponseCode();
54 | if(responseCode == HttpURLConnection.HTTP_OK){
55 | inStream = httpConnection.getInputStream();
56 | }
57 | } catch (MalformedURLException e) {
58 | e.printStackTrace();
59 | } catch (IOException e) {
60 | e.printStackTrace();
61 | }
62 | byte[] data = inputStreamToByte(inStream);
63 |
64 | return data;
65 | }
66 |
67 | public static byte[] inputStreamToByte(InputStream is) {
68 | try{
69 | ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
70 | int ch;
71 | while ((ch = is.read()) != -1) {
72 | bytestream.write(ch);
73 | }
74 | byte imgdata[] = bytestream.toByteArray();
75 | bytestream.close();
76 | return imgdata;
77 | }catch(Exception e){
78 | e.printStackTrace();
79 | }
80 |
81 | return null;
82 | }
83 |
84 | public static byte[] readFromFile(String fileName, int offset, int len) {
85 | if (fileName == null) {
86 | return null;
87 | }
88 |
89 | File file = new File(fileName);
90 | if (!file.exists()) {
91 | Log.i(TAG, "readFromFile: file not found");
92 | return null;
93 | }
94 |
95 | if (len == -1) {
96 | len = (int) file.length();
97 | }
98 |
99 | Log.d(TAG, "readFromFile : offset = " + offset + " len = " + len + " offset + len = " + (offset + len));
100 |
101 | if(offset <0){
102 | Log.e(TAG, "readFromFile invalid offset:" + offset);
103 | return null;
104 | }
105 | if(len <=0 ){
106 | Log.e(TAG, "readFromFile invalid len:" + len);
107 | return null;
108 | }
109 | if(offset + len > (int) file.length()){
110 | Log.e(TAG, "readFromFile invalid file len:" + file.length());
111 | return null;
112 | }
113 |
114 | byte[] b = null;
115 | try {
116 | RandomAccessFile in = new RandomAccessFile(fileName, "r");
117 | b = new byte[len]; // ���������ļ���С������
118 | in.seek(offset);
119 | in.readFully(b);
120 | in.close();
121 |
122 | } catch (Exception e) {
123 | Log.e(TAG, "readFromFile : errMsg = " + e.getMessage());
124 | e.printStackTrace();
125 | }
126 | return b;
127 | }
128 |
129 | private static final int MAX_DECODE_PICTURE_SIZE = 1920 * 1440;
130 | public static Bitmap extractThumbNail(final String path, final int height, final int width, final boolean crop) {
131 | Assert.assertTrue(path != null && !path.equals("") && height > 0 && width > 0);
132 |
133 | BitmapFactory.Options options = new BitmapFactory.Options();
134 |
135 | try {
136 | options.inJustDecodeBounds = true;
137 | Bitmap tmp = BitmapFactory.decodeFile(path, options);
138 | if (tmp != null) {
139 | tmp.recycle();
140 | tmp = null;
141 | }
142 |
143 | Log.d(TAG, "extractThumbNail: round=" + width + "x" + height + ", crop=" + crop);
144 | final double beY = options.outHeight * 1.0 / height;
145 | final double beX = options.outWidth * 1.0 / width;
146 | Log.d(TAG, "extractThumbNail: extract beX = " + beX + ", beY = " + beY);
147 | options.inSampleSize = (int) (crop ? (beY > beX ? beX : beY) : (beY < beX ? beX : beY));
148 | if (options.inSampleSize <= 1) {
149 | options.inSampleSize = 1;
150 | }
151 |
152 | // NOTE: out of memory error
153 | while (options.outHeight * options.outWidth / options.inSampleSize > MAX_DECODE_PICTURE_SIZE) {
154 | options.inSampleSize++;
155 | }
156 |
157 | int newHeight = height;
158 | int newWidth = width;
159 | if (crop) {
160 | if (beY > beX) {
161 | newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth);
162 | } else {
163 | newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight);
164 | }
165 | } else {
166 | if (beY < beX) {
167 | newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth);
168 | } else {
169 | newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight);
170 | }
171 | }
172 |
173 | options.inJustDecodeBounds = false;
174 |
175 | Log.i(TAG, "bitmap required size=" + newWidth + "x" + newHeight + ", orig=" + options.outWidth + "x" + options.outHeight + ", sample=" + options.inSampleSize);
176 | Bitmap bm = BitmapFactory.decodeFile(path, options);
177 | if (bm == null) {
178 | Log.e(TAG, "bitmap decode failed");
179 | return null;
180 | }
181 |
182 | Log.i(TAG, "bitmap decoded size=" + bm.getWidth() + "x" + bm.getHeight());
183 | final Bitmap scale = Bitmap.createScaledBitmap(bm, newWidth, newHeight, true);
184 | if (scale != null) {
185 | bm.recycle();
186 | bm = scale;
187 | }
188 |
189 | if (crop) {
190 | final Bitmap cropped = Bitmap.createBitmap(bm, (bm.getWidth() - width) >> 1, (bm.getHeight() - height) >> 1, width, height);
191 | if (cropped == null) {
192 | return bm;
193 | }
194 |
195 | bm.recycle();
196 | bm = cropped;
197 | Log.i(TAG, "bitmap croped size=" + bm.getWidth() + "x" + bm.getHeight());
198 | }
199 | return bm;
200 |
201 | } catch (final OutOfMemoryError e) {
202 | Log.e(TAG, "decode bitmap failed: " + e.getMessage());
203 | options = null;
204 | }
205 |
206 | return null;
207 | }
208 | }
209 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ThirdToolsLib
3 |
4 |
--------------------------------------------------------------------------------
/ThirdToolsLib/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
16 |
17 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | /hiwan.jks
3 | /test
4 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion rootProject.ext.android.compileSdkVersion
5 | buildToolsVersion rootProject.ext.android.buildToolsVersion
6 | defaultConfig {
7 | applicationId "com.allure.third"
8 | minSdkVersion rootProject.ext.android.minSdkVersion
9 | targetSdkVersion rootProject.ext.android.targetSdkVersion
10 | versionCode rootProject.ext.android.versionCode
11 | versionName rootProject.ext.android.versionName
12 | manifestPlaceholders = [
13 | qq_id: "1105787445",
14 | ]
15 | }
16 |
17 |
18 | signingConfigs {
19 |
20 | release {
21 |
22 | storeFile file('hiwan.jks')
23 |
24 | storePassword RELEASE_STORE_PASSWORD
25 |
26 | keyAlias RELEASE_KEY_ALIAS
27 |
28 | keyPassword RELEASE_KEY_PASSWORD
29 |
30 | }
31 |
32 | }
33 | buildTypes {
34 | release {
35 | signingConfig signingConfigs.release
36 | minifyEnabled false
37 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
38 | }
39 | debug {
40 | minifyEnabled false
41 | signingConfig signingConfigs.release
42 | }
43 | }
44 | }
45 |
46 | dependencies {
47 | compile fileTree(dir: 'libs', include: ['*.jar'])
48 | compile rootProject.ext.dependencies.appcompatV7
49 | compile project(':ThirdToolsLib')
50 |
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/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 /Users/luomin/Desktop/android-sdk-macosx/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 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/allure/third/BaseApplication.java:
--------------------------------------------------------------------------------
1 | package com.allure.third;
2 |
3 | import android.app.Application;
4 |
5 | import com.allure.thirdtools.PlatformManager;
6 | import com.allure.thirdtools.platform.PlatformConfig;
7 |
8 | /**
9 | * 作者:luomin
10 | * 邮箱:asddavid@163.com
11 | */
12 |
13 | public class BaseApplication extends Application {
14 | private static BaseApplication instance;
15 |
16 | public static BaseApplication getInstance() {
17 | return instance;
18 | }
19 |
20 |
21 | @Override
22 | public void onCreate() {
23 | super.onCreate();
24 | instance = this;
25 |
26 | PlatformConfig platformConfig = PlatformConfig.getInstance()
27 | .setQqId("xxx")
28 | .setWeChatId("xxxx")
29 | .setWeChatSecret("");//如果是服务处理token和code不需要传此参数
30 |
31 | PlatformManager.getInstance()
32 | .setPlatformConfig(platformConfig)
33 | .initQQ(this)
34 | .initWx(this);
35 | }
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/allure/third/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.allure.third;
2 |
3 | import android.graphics.BitmapFactory;
4 | import android.os.Bundle;
5 | import android.os.Environment;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.util.Log;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.Toast;
11 |
12 | import com.allure.thirdtools.LoginManager;
13 | import com.allure.thirdtools.PayManager;
14 | import com.allure.thirdtools.bean.LoginResult;
15 | import com.allure.thirdtools.bean.pay.WxPayBean;
16 | import com.allure.thirdtools.listener.AliPayListener;
17 | import com.allure.thirdtools.observer.LoginEvent;
18 | import com.allure.thirdtools.observer.Observer;
19 | import com.allure.thirdtools.observer.SimpleObserver;
20 | import com.allure.thirdtools.pay.AliPayResult;
21 | import com.allure.thirdtools.platform.LoginPlatform;
22 | import com.allure.thirdtools.platform.PayPlatform;
23 | import com.allure.thirdtools.platform.SharePlatform;
24 | import com.allure.thirdtools.share.ShareUtils;
25 |
26 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, Observer {
27 | private Button btnLoginQQ;
28 | private Button btnLoginWeChat;
29 | private Button btnWechatShare;
30 | private Button btnQQShare;
31 | private Button btnWechatPay;
32 | private Button btnAliPay;
33 |
34 | //分享相关属性
35 | String text = "微信分享纯文本"; // 用于分享的文字
36 | String url = "https://www.baidu.com/";// 用于分享的链接
37 | String picPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + "test.jpg";// 用于分享的本地图片
38 | final String imgUrl = "http://segmentfault.com/img/bVkIvr";// 用于分享的在线图片
39 | String musicUrl = "http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3";// 用于分享在线音乐
40 | String videoUrl = "http://v.youku.com/v_show/id_XMjExOTcxNg==.html?f=1245977";// 用于分享的在线视频
41 |
42 |
43 | @Override
44 | protected void onCreate(Bundle savedInstanceState) {
45 | super.onCreate(savedInstanceState);
46 | setContentView(R.layout.activity_main);
47 | LoginEvent.getDefault().register(this);
48 | // LoginEvent.getDefault().register(simpleObserver);
49 | btnLoginQQ = (Button) findViewById(R.id.btn_qq);
50 | btnLoginWeChat = (Button) findViewById(R.id.btn_wechat);
51 | btnQQShare = (Button) findViewById(R.id.btn_qq_share);
52 | btnWechatShare = (Button) findViewById(R.id.btn_wechat_share);
53 | btnWechatPay = (Button) findViewById(R.id.btn_wechat_pay);
54 | btnAliPay = (Button) findViewById(R.id.btn_ali_pay);
55 |
56 | btnLoginQQ.setOnClickListener(this);
57 | btnLoginWeChat.setOnClickListener(this);
58 | btnWechatShare.setOnClickListener(this);
59 | btnQQShare.setOnClickListener(this);
60 | btnWechatPay.setOnClickListener(this);
61 | btnAliPay.setOnClickListener(this);
62 |
63 |
64 | }
65 |
66 | SimpleObserver simpleObserver = new SimpleObserver() {
67 | @Override
68 | public void shareFailed(SharePlatform sharePlatform) {
69 | super.shareFailed(sharePlatform);
70 | }
71 | };
72 |
73 |
74 | @Override
75 | protected void onDestroy() {
76 | super.onDestroy();
77 | LoginEvent.getDefault().unregister(this);
78 | // LoginEvent.getDefault().unregister(simpleObserver);
79 |
80 | }
81 |
82 |
83 | @Override
84 | public void thirdLoginSuccess(Object obj, LoginPlatform loginPlatform, LoginResult loginResult) {
85 | switch (loginPlatform) {
86 | case PLATFORM_QQ:
87 | Toast.makeText(this, "token:" + loginResult.getBaseTokenBean().getAccessToken()
88 | + "\n" + "昵称:" + loginResult.getBaseUserInfoBean().getNickname(), Toast.LENGTH_SHORT).show();
89 | Log.e("token", loginResult.getBaseTokenBean().getAccessToken());
90 | Log.e("用户信息", loginResult.getBaseUserInfoBean().getNickname());
91 | break;
92 |
93 | case PLATFORM_WECHAT:
94 | /**
95 | * 此处只返回了Code,loginResultw为null
96 | * 得到Code之后调用https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code
97 | * 获取到token和openID。之后再调用https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID 获取用户个人信息
98 | * 微信开发文档:https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419317853&token=&lang=zh_CN
99 | */
100 | Toast.makeText(MainActivity.this, "获取的Code:" + obj.toString(), Toast.LENGTH_SHORT).show();
101 |
102 | break;
103 | }
104 |
105 |
106 | }
107 |
108 | @Override
109 | public void thirdLoginFailed(Object object, LoginPlatform loginPlatform) {
110 | Toast.makeText(this, "登陆失败了", Toast.LENGTH_SHORT).show();
111 |
112 | }
113 |
114 | @Override
115 | public void thirdLoginCancel(LoginPlatform loginPlatform) {
116 | Toast.makeText(this, "登陆取消了", Toast.LENGTH_SHORT).show();
117 | }
118 |
119 | @Override
120 | public void shareSuccess(SharePlatform sharePlatform) {
121 | Toast.makeText(this, "分享成功", Toast.LENGTH_SHORT).show();
122 |
123 | }
124 |
125 | @Override
126 | public void shareFailed(SharePlatform sharePlatform) {
127 | Toast.makeText(this, "分享失败", Toast.LENGTH_SHORT).show();
128 |
129 | }
130 |
131 | //支付宝暂时未加入观察者模式观察,直接使用回调处理
132 | @Override
133 | public void paySuccess(PayPlatform payPlatform) {
134 | switch (payPlatform) {
135 | case PLATFORM_ALI:
136 | Toast.makeText(this, "支付宝成功", Toast.LENGTH_SHORT).show();
137 | break;
138 | case PLATFORM_WECHAT:
139 | Toast.makeText(this, "微信支付成功", Toast.LENGTH_SHORT).show();
140 | break;
141 | }
142 |
143 | }
144 |
145 | @Override
146 | public void payFailed(PayPlatform payPlatform) {
147 | switch (payPlatform) {
148 | case PLATFORM_ALI:
149 | Toast.makeText(this, "支付宝失败", Toast.LENGTH_SHORT).show();
150 | break;
151 | case PLATFORM_WECHAT:
152 | Toast.makeText(this, "微信支付失败", Toast.LENGTH_SHORT).show();
153 | break;
154 | }
155 | }
156 |
157 |
158 | @Override
159 | public void onClick(View view) {
160 | switch (view.getId()) {
161 | case R.id.btn_qq://QQ登陆
162 | LoginManager
163 | .with(MainActivity.this)
164 | .thirdLogin(LoginPlatform.PLATFORM_QQ);
165 | break;
166 | case R.id.btn_wechat://微信登陆
167 | LoginManager
168 | .with(MainActivity.this)
169 | .thirdLogin(LoginPlatform.PLATFORM_WECHAT);
170 | break;
171 |
172 | case R.id.btn_wechat_share:
173 | ShareUtils.initShareUtils(
174 | BaseApplication.getInstance(), text, text, imgUrl, url,
175 | BitmapFactory.decodeResource(BaseApplication.getInstance().getResources(),
176 | R.drawable.ic_launcher)
177 | ).shareToWX(MainActivity.this, ShareUtils.WECHAT_CIRCLE);
178 | break;
179 | case R.id.btn_qq_share://QQ分享
180 | ShareUtils.initShareUtils(
181 | BaseApplication.getInstance(), text, text, imgUrl, url,
182 | BitmapFactory.decodeResource(BaseApplication.getInstance().getResources(),
183 | R.drawable.ic_launcher)
184 | ).shareToQQ(MainActivity.this, "测试啦");
185 | break;
186 | case R.id.btn_wechat_pay://微信支付
187 | WxPayBean wxPayBean = new WxPayBean();
188 | // wxPayBean.setAppId(map.get("appid"));
189 | // wxPayBean.setPartnerId(map.get("partnerid"));
190 | // wxPayBean.setPrepayId(map.get("prepayid"));
191 | // wxPayBean.setPackageValue(map.get("package"));
192 | // wxPayBean.setNoncestr(map.get("noncestr"));
193 | // wxPayBean.setTimestamp(map.get("timestamp"));
194 | // wxPayBean.setSign(map.get("sign"));
195 | PayManager.with(MainActivity.this)
196 | .wxPay(wxPayBean);
197 |
198 | break;
199 | case R.id.btn_ali_pay://支付宝支付
200 | String ali_orderinfo = "xxxxxx";
201 | PayManager.with(MainActivity.this)
202 | .aliPay(ali_orderinfo, new AliPayListener() {
203 | @Override
204 | public void aliPayResult(String string, AliPayResult payResult) {
205 | Log.e("支付状态", string);
206 | Log.e("支付状态", payResult.getResultStatus());
207 | }
208 | });
209 |
210 |
211 | break;
212 |
213 | }
214 | }
215 | }
216 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Allure0/ThirdUtils/020df7a5e70dfe4ebbd0b3b97284a0dc6f1494b3/app/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
16 |
21 |
26 |
31 |
36 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Allure0/ThirdUtils/020df7a5e70dfe4ebbd0b3b97284a0dc6f1494b3/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Allure0/ThirdUtils/020df7a5e70dfe4ebbd0b3b97284a0dc6f1494b3/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Allure0/ThirdUtils/020df7a5e70dfe4ebbd0b3b97284a0dc6f1494b3/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Allure0/ThirdUtils/020df7a5e70dfe4ebbd0b3b97284a0dc6f1494b3/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Allure0/ThirdUtils/020df7a5e70dfe4ebbd0b3b97284a0dc6f1494b3/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ThirdUtils
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | apply from: "config.gradle"
4 | buildscript {
5 | repositories {
6 | jcenter()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.2.3'
10 |
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
25 |
--------------------------------------------------------------------------------
/config.gradle:
--------------------------------------------------------------------------------
1 | ext {
2 | android = [
3 | compileSdkVersion: 23,
4 | buildToolsVersion: "23.0.1",
5 | minSdkVersion : 16,
6 | targetSdkVersion : 23,
7 | versionCode :100,
8 | versionName : '1.0.0',
9 |
10 | ]
11 | isDebug=true;
12 |
13 | dependencies = [
14 | appcompatV7 : 'com.android.support:appcompat-v7:23.0.1',
15 |
16 | ]
17 | }
--------------------------------------------------------------------------------
/demo/guide_gif2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Allure0/ThirdUtils/020df7a5e70dfe4ebbd0b3b97284a0dc6f1494b3/demo/guide_gif2.gif
--------------------------------------------------------------------------------
/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | RELEASE_STORE_FILE= /Users/luomin/OpenGithub/ThirdUtils/app/hiwan.jks
21 |
22 | RELEASE_STORE_PASSWORD=123456
23 |
24 | RELEASE_KEY_ALIAS=hiwan
25 |
26 | RELEASE_KEY_PASSWORD=123456
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Allure0/ThirdUtils/020df7a5e70dfe4ebbd0b3b97284a0dc6f1494b3/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Jan 22 16:20:10 GMT+08:00 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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':ThirdToolsLib'
2 |
--------------------------------------------------------------------------------