diff --git a/lib_social/README.md b/lib_social/README.md
index 9d75756..2864e6d 100644
--- a/lib_social/README.md
+++ b/lib_social/README.md
@@ -55,4 +55,30 @@ manifest 配置参考
## 支付宝支付
-- sdk 版本:alipaySdk-15.6.2-20190416165100-noUtdid
\ No newline at end of file
+- sdk 版本:alipaySdk-15.6.2-20190416165100-noUtdid
+
+## QQ
+
+manifest 配置参考
+
+```xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+```
\ No newline at end of file
diff --git a/lib_social/build.gradle b/lib_social/build.gradle
index 58c391f..75e895b 100644
--- a/lib_social/build.gradle
+++ b/lib_social/build.gradle
@@ -19,12 +19,6 @@ android {
}
}
- sourceSets {
- main {
- jniLibs.srcDirs = ['libs']
- }
- }
-
lintOptions {
abortOnError false
}
diff --git a/lib_social/libs/open_sdk_r6137_lite.jar b/lib_social/libs/open_sdk_r6137_lite.jar
new file mode 100644
index 0000000..574c2bb
Binary files /dev/null and b/lib_social/libs/open_sdk_r6137_lite.jar differ
diff --git a/lib_social/src/main/java/com/android/sdk/social/qq/QQManager.java b/lib_social/src/main/java/com/android/sdk/social/qq/QQManager.java
new file mode 100644
index 0000000..3b53a52
--- /dev/null
+++ b/lib_social/src/main/java/com/android/sdk/social/qq/QQManager.java
@@ -0,0 +1,67 @@
+package com.android.sdk.social.qq;
+
+import android.app.Activity;
+import android.content.Context;
+import android.support.annotation.Nullable;
+
+import com.android.sdk.social.common.Utils;
+import com.tencent.tauth.IUiListener;
+import com.tencent.tauth.Tencent;
+import com.tencent.tauth.UiError;
+
+import timber.log.Timber;
+
+/**
+ * @author Ztiany
+ * Email: ztiany3@gmail.com
+ * Date : 2019-08-27 18:16
+ */
+public class QQManager {
+
+ private final Tencent mTencent;
+
+ private static String sAppId;
+
+ public static void initQQSDK(String appId) {
+ sAppId = appId;
+ }
+
+ private static String getAppId() {
+ Utils.requestNotNull(sAppId, "weChat app id");
+ return sAppId;
+ }
+
+ public QQManager(Context context) {
+ mTencent = Tencent.createInstance(getAppId(), context);
+ }
+
+ public void shareToQQ(Activity activity, QQShareInfo shareInfo, @Nullable ShareResultCallback shareResultCallback) {
+ mTencent.shareToQQ(activity, shareInfo.getBundle(), newDefaultListener(shareResultCallback));
+ }
+
+ private static IUiListener newDefaultListener(ShareResultCallback shareResultCallback) {
+ if (shareResultCallback == null) {
+ return null;
+ }
+ return new IUiListener() {
+ @Override
+ public void onComplete(Object o) {
+ Timber.d("shareToQQ onComplete: " + o);
+ shareResultCallback.onSuccess();
+ }
+
+ @Override
+ public void onError(UiError uiError) {
+ Timber.d("shareToQQ onError: " + uiError);
+ shareResultCallback.onError();
+ }
+
+ @Override
+ public void onCancel() {
+ Timber.d("shareToQQ onCancel");
+ shareResultCallback.onCancel();
+ }
+ };
+ }
+
+}
diff --git a/lib_social/src/main/java/com/android/sdk/social/qq/QQShareInfo.java b/lib_social/src/main/java/com/android/sdk/social/qq/QQShareInfo.java
new file mode 100644
index 0000000..28105da
--- /dev/null
+++ b/lib_social/src/main/java/com/android/sdk/social/qq/QQShareInfo.java
@@ -0,0 +1,54 @@
+package com.android.sdk.social.qq;
+
+import android.os.Bundle;
+
+import com.tencent.connect.share.QQShare;
+
+/**
+ * @author Ztiany
+ * Email: ztiany3@gmail.com
+ * Date : 2019-08-27 19:00
+ */
+public class QQShareInfo {
+
+ private final Bundle mBundle = new Bundle();
+
+ public QQShareInfo() {
+ shareToFriend();
+ }
+
+ public QQShareInfo setTitle(String title) {
+ mBundle.putString(QQShare.SHARE_TO_QQ_TITLE, title);
+ return this;
+ }
+
+ public QQShareInfo setTargetUrl(String targetUrl) {
+ mBundle.putString(QQShare.SHARE_TO_QQ_TARGET_URL, targetUrl);
+ return this;
+ }
+
+ public QQShareInfo setSummary(String summary) {
+ mBundle.putString(QQShare.SHARE_TO_QQ_SUMMARY, summary);
+ return this;
+ }
+
+ public QQShareInfo setImage(String imageUrl) {
+ mBundle.putString(QQShare.SHARE_TO_QQ_IMAGE_URL, imageUrl);
+ return this;
+ }
+
+ public QQShareInfo setLocalImage(String imageUrl) {
+ mBundle.putString(QQShare.SHARE_TO_QQ_IMAGE_LOCAL_URL, imageUrl);
+ return this;
+ }
+
+ public QQShareInfo shareToFriend() {
+ mBundle.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_DEFAULT);
+ return this;
+ }
+
+ Bundle getBundle() {
+ return mBundle;
+ }
+
+}
diff --git a/lib_social/src/main/java/com/android/sdk/social/qq/ShareResultCallback.java b/lib_social/src/main/java/com/android/sdk/social/qq/ShareResultCallback.java
new file mode 100644
index 0000000..d90195d
--- /dev/null
+++ b/lib_social/src/main/java/com/android/sdk/social/qq/ShareResultCallback.java
@@ -0,0 +1,16 @@
+package com.android.sdk.social.qq;
+
+/**
+ * @author Ztiany
+ * Email: ztiany3@gmail.com
+ * Date : 2019-08-27 19:35
+ */
+public interface ShareResultCallback {
+
+ void onSuccess();
+
+ void onError();
+
+ void onCancel();
+
+}
diff --git a/lib_social/src/main/java/com/android/sdk/social/wechat/WeChatManager.java b/lib_social/src/main/java/com/android/sdk/social/wechat/WeChatManager.java
index 598ce14..9fb06ba 100644
--- a/lib_social/src/main/java/com/android/sdk/social/wechat/WeChatManager.java
+++ b/lib_social/src/main/java/com/android/sdk/social/wechat/WeChatManager.java
@@ -14,6 +14,7 @@ import com.tencent.mm.opensdk.constants.ConstantsAPI;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
+import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
import com.tencent.mm.opensdk.modelpay.PayReq;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
@@ -31,6 +32,11 @@ public class WeChatManager {
private static String sAppId;
private static String sAppSecret;
+ /**
+ * @param context 上下文
+ * @param appId app id
+ * @param appSecret 密钥,如果要进行微信登录,则需要提供。
+ */
public static synchronized void initWeChatSDK(Context context, String appId, String appSecret) {
if (sWeChatManager != null) {
throw new UnsupportedOperationException("WeChatManager has already been initialized");
@@ -90,13 +96,15 @@ public class WeChatManager {
}
static void handleOnWxEntryResp(BaseResp baseResp) {
- Timber.d("baseResp.type = " + baseResp.getType());
+ Timber.d("handleOnWxEntryResp type = " + baseResp.getType() + "errStr = " + baseResp.errStr);
if (ConstantsAPI.COMMAND_SENDAUTH == baseResp.getType()) {
handAuthResp(baseResp);
} else if (ConstantsAPI.COMMAND_PAY_BY_WX == baseResp.getType()) {
handleOnWxEntryPayResp(baseResp);
} else if (ConstantsAPI.COMMAND_LAUNCH_WX_MINIPROGRAM == baseResp.getType()) {
handleMiniProgramResp(baseResp);
+ } else if (ConstantsAPI.COMMAND_SENDMESSAGE_TO_WX == baseResp.getType()) {
+ handleSendMessageResp(baseResp);
}
}
@@ -110,20 +118,22 @@ public class WeChatManager {
* @param userName 小程序原始id
* @param path 拉起小程序页面的可带参路径,不填默认拉起小程序首页
*/
- public void navToMinProgram(String userName, String path) {
+ public void navToMinProgram(String userName, String path, boolean isRelease) {
WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
req.userName = userName;
req.path = path;
// 可选打开开发版,体验版和正式版
- req.miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE;
+ req.miniprogramType = isRelease ? WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE : WXLaunchMiniProgram.Req.MINIPROGRAM_TYPE_PREVIEW;
mWxApi.sendReq(req);
}
private static void handleMiniProgramResp(BaseResp baseResp) {
- WXLaunchMiniProgram.Resp launchMiniProResp = (WXLaunchMiniProgram.Resp) baseResp;
- //对应小程序组件