chore: 将所有剩余修改文件提交到Git仓库
This commit is contained in:
18
app/release/output-metadata.json
Normal file
18
app/release/output-metadata.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"artifactType": {
|
||||||
|
"type": "APK",
|
||||||
|
"kind": "Directory"
|
||||||
|
},
|
||||||
|
"applicationId": "com.jx.jyhd",
|
||||||
|
"variantName": "processReleaseResources",
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"type": "SINGLE",
|
||||||
|
"filters": [],
|
||||||
|
"versionCode": 3,
|
||||||
|
"versionName": "3.6.3",
|
||||||
|
"outputFile": "app-release.apk"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -2280,8 +2280,22 @@ public class NewwebviewActivity extends AppCompatActivity implements
|
|||||||
String scene = currentShareData.getSharefriend();
|
String scene = currentShareData.getSharefriend();
|
||||||
if (scene.equals("2")){
|
if (scene.equals("2")){
|
||||||
//朋友圈分享
|
//朋友圈分享
|
||||||
//直接调用微信分享
|
|
||||||
WeChatShareHelper.doWeChatShare(NewwebviewActivity.this, data);
|
//第一步:必须注册回调 handler 给 WXEntryActivity
|
||||||
|
apputil.wxtype = 1;
|
||||||
|
Wxistrue.sharetype = 2;
|
||||||
|
WXEntryActivity.setshareHandler(handler);
|
||||||
|
|
||||||
|
//第二步:调用隔离好的原生SDK方法发请求
|
||||||
|
String type = currentShareData.getType() == null ? "" : currentShareData.getType();
|
||||||
|
final int sceneType = com.tencent.mm.opensdk.modelmsg.SendMessageToWX.Req.WXSceneTimeline;
|
||||||
|
|
||||||
|
// 网页分享
|
||||||
|
com.tsgame.tsgame_niuniu.util.WeChatOfficialShareUtil.getInstance(NewwebviewActivity.this)
|
||||||
|
.shareWebPage(NewwebviewActivity.this, currentShareData.getWebpageUrl(), currentShareData.getTitle(), currentShareData.getDescription(), sceneType);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}else if (scene.equals("1")){
|
}else if (scene.equals("1")){
|
||||||
//好友分享
|
//好友分享
|
||||||
SharePanelHelper.showSharePanel(NewwebviewActivity.this, data);
|
SharePanelHelper.showSharePanel(NewwebviewActivity.this, data);
|
||||||
@@ -3474,7 +3488,7 @@ public class NewwebviewActivity extends AppCompatActivity implements
|
|||||||
|
|
||||||
if (bean.getType().equals("1")) {
|
if (bean.getType().equals("1")) {
|
||||||
|
|
||||||
com.tsgame.tsgame_niuniu.util.WeChatIntentShareUtil.getInstance(this).shareWebPage(
|
com.jx.jyhd.simcpux.util.WeChatShareUtil.getInstance(this).shareWebPage(
|
||||||
this,
|
this,
|
||||||
bean.getWebpageUrl(),
|
bean.getWebpageUrl(),
|
||||||
bean.getTitle(),
|
bean.getTitle(),
|
||||||
@@ -3669,7 +3683,7 @@ public class NewwebviewActivity extends AppCompatActivity implements
|
|||||||
|
|
||||||
if (bean.getType().equals("1")) {
|
if (bean.getType().equals("1")) {
|
||||||
System.out.println("hhhhhhh");
|
System.out.println("hhhhhhh");
|
||||||
com.tsgame.tsgame_niuniu.util.WeChatIntentShareUtil.getInstance(this).shareWebPage(
|
com.jx.jyhd.simcpux.util.WeChatShareUtil.getInstance(this).shareWebPage(
|
||||||
this,
|
this,
|
||||||
bean.getWebpageUrl(),
|
bean.getWebpageUrl(),
|
||||||
bean.getTitle(),
|
bean.getTitle(),
|
||||||
|
|||||||
@@ -3347,7 +3347,7 @@ public class webviewActivity extends AppCompatActivity implements
|
|||||||
|
|
||||||
if (bean.getType().equals("1")) {
|
if (bean.getType().equals("1")) {
|
||||||
|
|
||||||
com.tsgame.tsgame_niuniu.util.WeChatIntentShareUtil.getInstance(this).shareWebPage(
|
com.jx.jyhd.simcpux.util.WeChatShareUtil.getInstance(this).shareWebPage(
|
||||||
this,
|
this,
|
||||||
bean.getWebpageUrl(),
|
bean.getWebpageUrl(),
|
||||||
bean.getTitle(),
|
bean.getTitle(),
|
||||||
@@ -3500,7 +3500,7 @@ public class webviewActivity extends AppCompatActivity implements
|
|||||||
Wxistrue.sharetype = 2;
|
Wxistrue.sharetype = 2;
|
||||||
|
|
||||||
if (bean.getType().equals("1")) {
|
if (bean.getType().equals("1")) {
|
||||||
com.tsgame.tsgame_niuniu.util.WeChatIntentShareUtil.getInstance(this).shareWebPage(
|
com.jx.jyhd.simcpux.util.WeChatShareUtil.getInstance(this).shareWebPage(
|
||||||
this,
|
this,
|
||||||
bean.getWebpageUrl(),
|
bean.getWebpageUrl(),
|
||||||
bean.getTitle(),
|
bean.getTitle(),
|
||||||
|
|||||||
@@ -0,0 +1,132 @@
|
|||||||
|
package com.tsgame.tsgame_niuniu.util;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.jx.jyhd.R;
|
||||||
|
import com.jx.jyhd.simcpux.Constants;
|
||||||
|
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
|
||||||
|
import com.tencent.mm.opensdk.modelmsg.WXImageObject;
|
||||||
|
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
|
||||||
|
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject;
|
||||||
|
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||||
|
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信官方 SDK 分享工具类
|
||||||
|
* 用来发送请求给微信,并且可以接通 WXEntryActivity 的回调
|
||||||
|
*/
|
||||||
|
public class WeChatOfficialShareUtil {
|
||||||
|
|
||||||
|
private static WeChatOfficialShareUtil instance;
|
||||||
|
private IWXAPI api;
|
||||||
|
|
||||||
|
private WeChatOfficialShareUtil(Context context) {
|
||||||
|
api = WXAPIFactory.createWXAPI(context, Constants.APP_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WeChatOfficialShareUtil getInstance(Context context) {
|
||||||
|
if (instance == null) {
|
||||||
|
synchronized (WeChatOfficialShareUtil.class) {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new WeChatOfficialShareUtil(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWeChatInstalled() {
|
||||||
|
return api != null && api.isWXAppInstalled();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分享网页到微信
|
||||||
|
*/
|
||||||
|
public void shareWebPage(Context context, String webpageUrl, String title, String description, int sceneType) {
|
||||||
|
if (!isWeChatInstalled()) {
|
||||||
|
Toast.makeText(context, "您还未安装微信客户端", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WXWebpageObject webpage = new WXWebpageObject();
|
||||||
|
// 追加随机时间戳参数,强制跳过微信的缩略图缓存
|
||||||
|
String finalUrl = webpageUrl;
|
||||||
|
if (finalUrl != null && !finalUrl.isEmpty()) {
|
||||||
|
String separator = finalUrl.contains("?") ? "&" : "?";
|
||||||
|
finalUrl = finalUrl + separator + "t=" + System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
webpage.webpageUrl = webpageUrl;
|
||||||
|
|
||||||
|
WXMediaMessage msg = new WXMediaMessage(webpage);
|
||||||
|
msg.title = title;
|
||||||
|
msg.description = description;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Bitmap thumbBmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.logo6);
|
||||||
|
if (thumbBmp != null) {
|
||||||
|
Bitmap scaled = Bitmap.createScaledBitmap(thumbBmp, 120, 120, true);
|
||||||
|
msg.setThumbImage(scaled);
|
||||||
|
thumbBmp.recycle();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
SendMessageToWX.Req req = new SendMessageToWX.Req();
|
||||||
|
req.transaction = "webpage" + System.currentTimeMillis();
|
||||||
|
req.message = msg;
|
||||||
|
req.scene = sceneType;
|
||||||
|
api.sendReq(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分享图片到微信
|
||||||
|
*/
|
||||||
|
public void shareImage(Context context, String imagePath, int sceneType) {
|
||||||
|
if (!isWeChatInstalled()) {
|
||||||
|
Toast.makeText(context, "您还未安装微信客户端", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WXImageObject imgObj = new WXImageObject();
|
||||||
|
try {
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { // Android 7.0及以上即可使用FileProvider
|
||||||
|
android.net.Uri contentUri = com.tsgame.tsgame_niuniu.util.FileProviderUtil.getUriForFile(context, new java.io.File(imagePath));
|
||||||
|
if (contentUri != null && "content".equals(contentUri.getScheme())) {
|
||||||
|
context.grantUriPermission("com.tencent.mm", contentUri, android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
imgObj.imagePath = contentUri.toString();
|
||||||
|
} else {
|
||||||
|
imgObj.imagePath = imagePath;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
imgObj.imagePath = imagePath;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
imgObj.imagePath = imagePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
WXMediaMessage msg = new WXMediaMessage();
|
||||||
|
msg.mediaObject = imgObj;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Bitmap bmp = BitmapFactory.decodeFile(imagePath);
|
||||||
|
if (bmp != null) {
|
||||||
|
Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, 120, 120, true);
|
||||||
|
msg.setThumbImage(thumbBmp);
|
||||||
|
bmp.recycle();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
SendMessageToWX.Req req = new SendMessageToWX.Req();
|
||||||
|
req.transaction = "img" + System.currentTimeMillis();
|
||||||
|
req.message = msg;
|
||||||
|
req.scene = sceneType;
|
||||||
|
api.sendReq(req);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user