Skip to content

Commit

Permalink
qq分享增加发布说说
Browse files Browse the repository at this point in the history
更新微博sdk版本
  • Loading branch information
liujinwei committed Mar 5, 2019
1 parent afe3be0 commit adb8bc0
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 9 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

这个组件在demo中是没有包含相关调用的代码的只有一些配置和使用的东西,因为应用的申请实在麻烦,但是已经在项目中测试通过了,所以可以放心使用。

引用的sdk版本:**微博:v4.3.1 QQ:open\_sdk\_r6019\_lite WX:v5.1.6**
引用的sdk版本:**微博:v4.3.6 QQ:open\_sdk\_r6019\_lite WX:v5.1.6**

### 优点

Expand Down Expand Up @@ -37,7 +37,7 @@ dependencies {
...
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.github.arvinljw:SocialHelper:v1.2.0'
implementation 'com.github.arvinljw:SocialHelper:v1.2.1'
}
```

Expand Down Expand Up @@ -191,6 +191,9 @@ public interface SocialShareCallback extends SocialCallback{
* createMusicInfo 音乐信息
* createAppInfo 应用信息
* createImageTextInfoToQZone 图文信息到QQ空间
* createPublishTextToQZone 文字说说
* createPublishImageToQZone 图片说说
* createPublishVideoToQZone 视频说说

* WXShareEntity

Expand Down Expand Up @@ -253,6 +256,11 @@ protected void onDestroy() {

**最近重要版本更新内容:**

**v1.2.1**

* 增加qq分享到说说
* 更新微博sdk版本到4.3.6

**v1.2.0**

* 修正qq获取的unionId
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation project(':socialhelper')
// implementation 'com.github.arvinljw:SocialHelper:v1.1.6'
// implementation 'com.github.arvinljw:SocialHelper:v1.2.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
public class TestLoginShareActivity extends AppCompatActivity implements View.OnClickListener, SocialLoginCallback, SocialShareCallback {
private String imgUrl = "https://upload-images.jianshu.io/upload_images/3157525-afe6f0ba902eb523.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240";
private String localImgUrl = "/storage/emulated/0/DCIM/Camera/IMG_20180422_113944.jpg";
private String localVideoUrl = "/storage/emulated/0/893.mp4";
private String title = "个人博客";
private String summary = "好好学习";
private String targetUrl = "https://arvinljw.github.io";
Expand Down Expand Up @@ -97,6 +98,15 @@ private ShareEntity createQQShareEntity() {
imgUrls.add(imgUrl);
shareEntity = QQShareEntity.createImageTextInfoToQZone(title, targetUrl,
imgUrls, summary, "ni6");

//文字说说
// shareEntity = QQShareEntity.createPublishTextToQZone("好好学习");
//图片说说,本地文件
// imgUrls.clear();
// imgUrls.add(localImgUrl);
// shareEntity = QQShareEntity.createPublishImageToQZone(imgUrls);
//视频说说,本地视频,大小限制见方法注释
// shareEntity = QQShareEntity.createPublishVideoToQZone(localVideoUrl);
break;
}
return shareEntity;
Expand Down
2 changes: 1 addition & 1 deletion socialhelper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ dependencies {
compileOnly 'com.android.support:appcompat-v7:28.0.0'
compileOnly 'com.google.code.gson:gson:2.8.2'
api 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.1.6'
api 'com.sina.weibo.sdk:core:4.3.1:openDefaultRelease@aar'
api 'com.sina.weibo.sdk:core:4.3.6:openDefaultRelease@aar'
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ public void share(SocialShareCallback callback, ShareEntity shareInfo) {
initShareListener(shareInfo);
if (shareInfo.getType() == ShareEntity.TYPE_QQ) {
tencent.shareToQQ(activity, shareInfo.getParams(), shareListener);
} else if (shareInfo.getType() == ShareEntity.TYPE_PUBLISH) {
tencent.publishToQzone(activity, shareInfo.getParams(), shareListener);
} else {
tencent.shareToQzone(activity, shareInfo.getParams(), shareListener);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.arvin.socialhelper.entities;

import com.tencent.connect.share.QQShare;
import com.tencent.connect.share.QzonePublish;
import com.tencent.connect.share.QzoneShare;

import net.arvin.socialhelper.ParamsRequired;
Expand All @@ -25,7 +26,7 @@ private QQShareEntity(int type) {
* @param targetUrl 跳转地址
* @param imgUrl 图片地址,本地路径或者url
* @param summary 摘要,长度限制40个字
* @param appName 应用名
* @param appName 应用名;手Q客户端顶部,替换“返回”按钮文字,如果为空,用返回代替
*/
public static ShareEntity createImageTextInfo(@ParamsRequired String title, @ParamsRequired String targetUrl,
String imgUrl, String summary, String appName) {
Expand All @@ -43,7 +44,7 @@ public static ShareEntity createImageTextInfo(@ParamsRequired String title, @Par
* 创建分享纯图片到qq
*
* @param imgUrl 本地图片地址
* @param appName 应用名
* @param appName 应用名;手Q客户端顶部,替换“返回”按钮文字,如果为空,用返回代替
*/
public static ShareEntity createImageInfo(@ParamsRequired String imgUrl, String appName) {
ShareEntity entity = new ShareEntity(ShareEntity.TYPE_QQ);
Expand All @@ -61,7 +62,7 @@ public static ShareEntity createImageInfo(@ParamsRequired String imgUrl, String
* @param musicUrl 音乐地址,不支持本地音乐
* @param imgUrl 图片地址,本地路径或者url
* @param summary 摘要,长度限制40个字
* @param appName 应用名
* @param appName 应用名;手Q客户端顶部,替换“返回”按钮文字,如果为空,用返回代替
*/
public static ShareEntity createMusicInfo(@ParamsRequired String title, @ParamsRequired String targetUrl,
@ParamsRequired String musicUrl, String imgUrl, String summary, String appName) {
Expand All @@ -82,7 +83,7 @@ public static ShareEntity createMusicInfo(@ParamsRequired String title, @ParamsR
* @param title 标题,长度限制30个字符
* @param imgUrl 图片地址,本地路径或者url
* @param summary 摘要,长度限制40个字
* @param appName 应用名
* @param appName 应用名;手Q客户端顶部,替换“返回”按钮文字,如果为空,用返回代替
*/
public static ShareEntity createAppInfo(@ParamsRequired String title, String imgUrl, String summary, String appName) {
ShareEntity entity = new ShareEntity(ShareEntity.TYPE_QQ);
Expand All @@ -101,7 +102,7 @@ public static ShareEntity createAppInfo(@ParamsRequired String title, String img
* @param targetUrl 跳转地址
* @param imgUrl 图片地址,目前会第一张有效,待qq优化
* @param summary 摘要,长度限制600个字
* @param appName 应用名
* @param appName 应用名;手Q客户端顶部,替换“返回”按钮文字,如果为空,用返回代替
*/
public static ShareEntity createImageTextInfoToQZone(@ParamsRequired String title, @ParamsRequired String targetUrl,
@ParamsRequired ArrayList<String> imgUrl, String summary, String appName) {
Expand All @@ -114,4 +115,40 @@ public static ShareEntity createImageTextInfoToQZone(@ParamsRequired String titl
addParams(entity.params, QzoneShare.SHARE_TO_QQ_APP_NAME, appName);
return entity;
}

/**
* 创建分享图文说说到qq空间
*
* @param summary 摘要,长度限制600个字
*/
public static ShareEntity createPublishTextToQZone(@ParamsRequired String summary) {
ShareEntity entity = new ShareEntity(ShareEntity.TYPE_PUBLISH);
addParams(entity.params, QzoneShare.SHARE_TO_QZONE_KEY_TYPE, QzonePublish.PUBLISH_TO_QZONE_TYPE_PUBLISHMOOD);
addParams(entity.params, QzoneShare.SHARE_TO_QQ_SUMMARY, summary);
return entity;
}

/**
* 创建分享图文说说到qq空间
*
* @param imgUrl 图片地址,只支持本地图片;注:<=9张图片为发表说说,>9张为上传图片到相册
*/
public static ShareEntity createPublishImageToQZone(@ParamsRequired ArrayList<String> imgUrl) {
ShareEntity entity = new ShareEntity(ShareEntity.TYPE_PUBLISH);
addParams(entity.params, QzoneShare.SHARE_TO_QZONE_KEY_TYPE, QzonePublish.PUBLISH_TO_QZONE_TYPE_PUBLISHMOOD);
addParams(entity.params, QzonePublish.PUBLISH_TO_QZONE_IMAGE_URL, imgUrl);
return entity;
}

/**
* 创建分享视频说说到qq空间
*
* @param videoUrl 视频地址,只支持本地视频;上传视频的大小最好控制在100M以内(因为QQ普通用户上传视频必须在100M以内,黄钻用户可上传1G以内视频,大于1G会直接报错。)
*/
public static ShareEntity createPublishVideoToQZone(@ParamsRequired String videoUrl) {
ShareEntity entity = new ShareEntity(ShareEntity.TYPE_PUBLISH);
addParams(entity.params, QzoneShare.SHARE_TO_QZONE_KEY_TYPE, QzonePublish.PUBLISH_TO_QZONE_TYPE_PUBLISHVIDEO);
addParams(entity.params, QzonePublish.PUBLISH_TO_QZONE_VIDEO_PATH, videoUrl);
return entity;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ public class ShareEntity {
* 微信==2
* 朋友圈==3
* 微博==4
* 说说==5
*/
public static final int TYPE_QQ = 0;
public static final int TYPE_Q_ZONE = 1;
public static final int TYPE_WX = 2;
public static final int TYPE_PYQ = 3;
public static final int TYPE_WB = 4;
public static final int TYPE_PUBLISH = 5;

private int type;
Bundle params;
Expand Down

0 comments on commit adb8bc0

Please sign in to comment.