提交 f73fb952 authored 作者: JarvanMo's avatar JarvanMo

*…

* 使用了多端统一API,详情请点击[这里](https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Share_and_Favorites/Android.html) * 分享时所有的缩略图请使用`thumbData`字段 * Fluwx不会再对任何图片进行压缩处理
上级 31327261
...@@ -6,7 +6,6 @@ import com.jarvan.fluwx.handlers.FluwxAuthHandler ...@@ -6,7 +6,6 @@ import com.jarvan.fluwx.handlers.FluwxAuthHandler
import com.jarvan.fluwx.handlers.FluwxRequestHandler import com.jarvan.fluwx.handlers.FluwxRequestHandler
import com.jarvan.fluwx.handlers.FluwxShareHandler import com.jarvan.fluwx.handlers.FluwxShareHandler
import com.jarvan.fluwx.handlers.FluwxShareHandlerEmbedding import com.jarvan.fluwx.handlers.FluwxShareHandlerEmbedding
import com.jarvan.fluwx.handlers.PermissionHandler
import com.jarvan.fluwx.handlers.WXAPiHandler import com.jarvan.fluwx.handlers.WXAPiHandler
import com.jarvan.fluwx.utils.WXApiUtils import com.jarvan.fluwx.utils.WXApiUtils
import com.jarvan.fluwx.utils.readWeChatCallbackIntent import com.jarvan.fluwx.utils.readWeChatCallbackIntent
......
package com.jarvan.fluwx.handlers package com.jarvan.fluwx.handlers
import android.Manifest
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.AssetFileDescriptor import android.content.res.AssetFileDescriptor
import android.net.Uri import android.net.Uri
import androidx.core.content.ContextCompat
import androidx.core.content.FileProvider import androidx.core.content.FileProvider
import com.jarvan.fluwx.io.* import com.jarvan.fluwx.io.*
import com.tencent.mm.opensdk.modelbase.BaseReq import com.tencent.mm.opensdk.modelbase.BaseReq
...@@ -93,8 +90,6 @@ internal interface FluwxShareHandler : CoroutineScope { ...@@ -93,8 +90,6 @@ internal interface FluwxShareHandler : CoroutineScope {
msg.description = call.argument(keyDescription) // 小程序消息desc msg.description = call.argument(keyDescription) // 小程序消息desc
launch { launch {
msg.thumbData = readThumbnailByteArray(call, length = SHARE_MINI_PROGRAM_THUMB_LENGTH)
val req = SendMessageToWX.Req() val req = SendMessageToWX.Req()
setCommonArguments(call, req, msg) setCommonArguments(call, req, msg)
req.message = msg req.message = msg
...@@ -105,27 +100,24 @@ internal interface FluwxShareHandler : CoroutineScope { ...@@ -105,27 +100,24 @@ internal interface FluwxShareHandler : CoroutineScope {
private fun shareImage(call: MethodCall, result: MethodChannel.Result) { private fun shareImage(call: MethodCall, result: MethodChannel.Result) {
launch { launch {
val map: Map<String, Any> = call.argument("source") ?: mapOf() val map: Map<String, Any> = call.argument("source") ?: mapOf()
val sourceImage = WeChatFile.createWeChatFile(map, assetFileDescriptor)
val thumbData = readThumbnailByteArray(call)
val sourceByteArray = sourceImage.readByteArray() val imgHash = call.argument<String?>("imgDataHash")
val imageObject = when { val uint8List = map["uint8List"] as? ByteArray
sourceByteArray.isEmpty() -> { val imageObject = uint8List?.let {
WXImageObject() WXImageObject().apply {
imageData = it
imgDataHash = imgHash
} }
else -> { }?:run {
WXImageObject().apply { WXImageObject().apply {
if (supportFileProvider && targetHigherThanN) { imagePath = call.argument<String?>("localImagePath")
setImagePath(getFileContentUri(sourceByteArray.toCacheFile(context, sourceImage.suffix))) imgDataHash = imgHash
} else {
setImagePath(sourceByteArray.toExternalCacheFile(context, sourceImage.suffix)?.absolutePath)
}
}
} }
} }
val msg = WXMediaMessage() val msg = WXMediaMessage()
msg.mediaObject = imageObject msg.mediaObject = imageObject
msg.thumbData = thumbData
msg.description = call.argument(keyDescription) msg.description = call.argument(keyDescription)
...@@ -154,8 +146,6 @@ internal interface FluwxShareHandler : CoroutineScope { ...@@ -154,8 +146,6 @@ internal interface FluwxShareHandler : CoroutineScope {
msg.description = call.argument(keyDescription) msg.description = call.argument(keyDescription)
launch { launch {
msg.thumbData = readThumbnailByteArray(call)
val req = SendMessageToWX.Req() val req = SendMessageToWX.Req()
setCommonArguments(call, req, msg) setCommonArguments(call, req, msg)
req.message = msg req.message = msg
...@@ -177,7 +167,6 @@ internal interface FluwxShareHandler : CoroutineScope { ...@@ -177,7 +167,6 @@ internal interface FluwxShareHandler : CoroutineScope {
msg.description = call.argument(keyDescription) msg.description = call.argument(keyDescription)
launch { launch {
msg.thumbData = readThumbnailByteArray(call)
val req = SendMessageToWX.Req() val req = SendMessageToWX.Req()
setCommonArguments(call, req, msg) setCommonArguments(call, req, msg)
req.message = msg req.message = msg
...@@ -195,7 +184,6 @@ internal interface FluwxShareHandler : CoroutineScope { ...@@ -195,7 +184,6 @@ internal interface FluwxShareHandler : CoroutineScope {
msg.description = call.argument(keyDescription) msg.description = call.argument(keyDescription)
launch { launch {
msg.thumbData = readThumbnailByteArray(call)
val req = SendMessageToWX.Req() val req = SendMessageToWX.Req()
setCommonArguments(call, req, msg) setCommonArguments(call, req, msg)
req.message = msg req.message = msg
...@@ -227,7 +215,6 @@ internal interface FluwxShareHandler : CoroutineScope { ...@@ -227,7 +215,6 @@ internal interface FluwxShareHandler : CoroutineScope {
} }
} }
msg.thumbData = readThumbnailByteArray(call)
val req = SendMessageToWX.Req() val req = SendMessageToWX.Req()
setCommonArguments(call, req, msg) setCommonArguments(call, req, msg)
req.message = msg req.message = msg
...@@ -239,20 +226,6 @@ internal interface FluwxShareHandler : CoroutineScope { ...@@ -239,20 +226,6 @@ internal interface FluwxShareHandler : CoroutineScope {
result.success(WXAPiHandler.wxApi?.sendReq(request)) result.success(WXAPiHandler.wxApi?.sendReq(request))
} }
private suspend fun readThumbnailByteArray(call: MethodCall, length: Int = SHARE_IMAGE_THUMB_LENGTH): ByteArray? {
val thumbnailMap: Map<String, Any>? = call.argument(keyThumbnail)
val compress:Boolean = call.argument("compressThumbnail")?:true
return thumbnailMap?.run {
val thumbnailImage = WeChatFile.createWeChatFile(thumbnailMap, assetFileDescriptor)
val thumbnailImageIO = ImagesIOIml(thumbnailImage)
if(compress){
compressThumbnail(thumbnailImageIO, length)
}else{
thumbnailImageIO.readByteArray()
}
}
}
private suspend fun compressThumbnail(ioIml: ImagesIO, length: Int) = ioIml.compressedByteArray(context, length) private suspend fun compressThumbnail(ioIml: ImagesIO, length: Int) = ioIml.compressedByteArray(context, length)
// SESSION, TIMELINE, FAVORITE // SESSION, TIMELINE, FAVORITE
......
...@@ -21,6 +21,6 @@ ...@@ -21,6 +21,6 @@
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.0</string> <string>1.0</string>
<key>MinimumOSVersion</key> <key>MinimumOSVersion</key>
<string>11.0</string> <string>12.0</string>
</dict> </dict>
</plist> </plist>
# Uncomment this line to define a global platform for your project # Uncomment this line to define a global platform for your project
# platform :ios, '11.0' # platform :ios, '12.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency. # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true' ENV['COCOAPODS_DISABLE_STATS'] = 'true'
......
...@@ -29,10 +29,10 @@ EXTERNAL SOURCES: ...@@ -29,10 +29,10 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
fluwx: c37e78d6ad04b852e39f785e660c65d4906e3f4f fluwx: c18fd6c16b03a2187cd07d6e48e32a7801962849
integration_test: 13825b8a9334a850581300559b8839134b124670 integration_test: 13825b8a9334a850581300559b8839134b124670
WechatOpenSDK-XCFramework: 36fb2bea0754266c17184adf4963d7e6ff98b69f WechatOpenSDK-XCFramework: 36fb2bea0754266c17184adf4963d7e6ff98b69f
PODFILE CHECKSUM: 02caaa843f6501172c0d470d80e72f61175c8b93 PODFILE CHECKSUM: 6e700dec67e6deac9b1c69bb14c49a2217a12d15
COCOAPODS: 1.12.1 COCOAPODS: 1.15.2
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
KnownAssetTags = ( KnownAssetTags = (
New, New,
); );
LastUpgradeCheck = 1430; LastUpgradeCheck = 1510;
ORGANIZATIONNAME = ""; ORGANIZATIONNAME = "";
TargetAttributes = { TargetAttributes = {
331C80F0294D02FB00263BE5 = { 331C80F0294D02FB00263BE5 = {
...@@ -467,7 +467,7 @@ ...@@ -467,7 +467,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0; IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos; SUPPORTED_PLATFORMS = iphoneos;
...@@ -585,7 +585,7 @@ ...@@ -585,7 +585,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0; IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES; MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
...@@ -634,7 +634,7 @@ ...@@ -634,7 +634,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0; IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos; SUPPORTED_PLATFORMS = iphoneos;
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "1430" LastUpgradeVersion = "1510"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
......
...@@ -12,8 +12,6 @@ class _ShareImagePageState extends State<ShareImagePage> { ...@@ -12,8 +12,6 @@ class _ShareImagePageState extends State<ShareImagePage> {
WeChatScene scene = WeChatScene.session; WeChatScene scene = WeChatScene.session;
String _response = ''; String _response = '';
WeChatImage? source;
WeChatImage? thumbnail;
Fluwx fluwx = Fluwx(); Fluwx fluwx = Fluwx();
@override @override
...@@ -57,7 +55,6 @@ class _ShareImagePageState extends State<ShareImagePage> { ...@@ -57,7 +55,6 @@ class _ShareImagePageState extends State<ShareImagePage> {
'&src=http%3A%2F%2Fimg.mp.sohu.com%2Fupload%2F20170516%2F51296b2673704ae2992d0a28c244274c_th.png', '&src=http%3A%2F%2Fimg.mp.sohu.com%2Fupload%2F20170516%2F51296b2673704ae2992d0a28c244274c_th.png',
), ),
onChanged: (value) { onChanged: (value) {
source = WeChatImage.network(value);
}, },
keyboardType: TextInputType.multiline, keyboardType: TextInputType.multiline,
), ),
...@@ -65,7 +62,6 @@ class _ShareImagePageState extends State<ShareImagePage> { ...@@ -65,7 +62,6 @@ class _ShareImagePageState extends State<ShareImagePage> {
decoration: InputDecoration(labelText: '缩略地址'), decoration: InputDecoration(labelText: '缩略地址'),
controller: TextEditingController(text: '//images/logo.png'), controller: TextEditingController(text: '//images/logo.png'),
onChanged: (value) { onChanged: (value) {
thumbnail = WeChatImage.asset(value);
}, },
), ),
Row( Row(
...@@ -117,7 +113,6 @@ class _ShareImagePageState extends State<ShareImagePage> { ...@@ -117,7 +113,6 @@ class _ShareImagePageState extends State<ShareImagePage> {
} }
void _shareImage() { void _shareImage() {
fluwx.share(WeChatShareImageModel(source!, thumbnail: thumbnail));
} }
void handleRadioValueChanged(WeChatScene scene) { void handleRadioValueChanged(WeChatScene scene) {
......
...@@ -97,7 +97,6 @@ class _ShareMiniProgramPageState extends State<ShareMiniProgramPage> { ...@@ -97,7 +97,6 @@ class _ShareMiniProgramPageState extends State<ShareMiniProgramPage> {
title: _title, title: _title,
path: _path, path: _path,
description: _description, description: _description,
thumbnail: WeChatImage.network(_thumbnail),
); );
fluwx.share(model); fluwx.share(model);
} }
......
...@@ -129,7 +129,6 @@ class _ShareMusicPageState extends State<ShareMusicPage> { ...@@ -129,7 +129,6 @@ class _ShareMusicPageState extends State<ShareMusicPage> {
musicUrl: _musicUrl, musicUrl: _musicUrl,
scene: scene, scene: scene,
musicLowBandUrl: _musicLowBandUrl, musicLowBandUrl: _musicLowBandUrl,
thumbnail: WeChatImage.network(_thumnail),
); );
_fluwx.share(model); _fluwx.share(model);
......
...@@ -125,7 +125,6 @@ class _ShareVideoPageState extends State<ShareVideoPage> { ...@@ -125,7 +125,6 @@ class _ShareVideoPageState extends State<ShareVideoPage> {
var model = WeChatShareVideoModel( var model = WeChatShareVideoModel(
videoUrl: _videoUrl, videoUrl: _videoUrl,
videoLowBandUrl: _videoLowBandUrl, videoLowBandUrl: _videoLowBandUrl,
thumbnail: WeChatImage.network(_thumnail),
description: _description, description: _description,
scene: scene, scene: scene,
title: _title, title: _title,
......
...@@ -106,7 +106,6 @@ class ShareWebPagePageState extends State<ShareWebPagePage> { ...@@ -106,7 +106,6 @@ class ShareWebPagePageState extends State<ShareWebPagePage> {
var model = WeChatShareWebPageModel( var model = WeChatShareWebPageModel(
_url, _url,
title: _title, title: _title,
thumbnail: WeChatImage.network(_thumnail),
scene: scene, scene: scene,
); );
fluwx.share(model); fluwx.share(model);
......
...@@ -525,20 +525,18 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -525,20 +525,18 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
dispatch_async(globalQueue, ^{ dispatch_async(globalQueue, ^{
NSDictionary *sourceImage = call.arguments[keySource]; NSDictionary *sourceImage = call.arguments[keySource];
NSData *sourceImageData = [self getNsDataFromWeChatFile:sourceImage];
UIImage *thumbnailImage = [self getCommonThumbnail:call]; FlutterStandardTypedData *flutterImageData = sourceImage[@"uint8List"];
UIImage *realThumbnailImage; NSData *imageData = nil;
if (thumbnailImage == nil) {
NSString *suffix = sourceImage[@"suffix"];
BOOL isPNG = [self isPNG:suffix]; if (flutterImageData != nil){
BOOL compress = [call.arguments[fluwxKeyCompressThumbnail] boolValue]; imageData = flutterImageData.data;
realThumbnailImage = [self getThumbnailFromNSData:sourceImageData size:defaultThumbnailSize isPNG:isPNG compress:compress];
} else {
realThumbnailImage = thumbnailImage;
} }
NSString * imageDataHash = sourceImage[@"imgDataHash"];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
FlutterStandardTypedData *flutterThumbData = call.arguments[fluwxKeyThumbData]; FlutterStandardTypedData *flutterThumbData = call.arguments[fluwxKeyThumbData];
NSData *thumbData = nil; NSData *thumbData = nil;
...@@ -547,12 +545,13 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -547,12 +545,13 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
thumbData = flutterThumbData.data; thumbData = flutterThumbData.data;
} }
NSNumber *scene = call.arguments[fluwxKeyScene]; NSNumber *scene = call.arguments[fluwxKeyScene];
[self sendImageData:sourceImageData [self sendImageData:imageData
ImgDataHash:imageDataHash
TagName:call.arguments[fluwxKeyMediaTagName] TagName:call.arguments[fluwxKeyMediaTagName]
MessageExt:call.arguments[fluwxKeyMessageExt] MessageExt:call.arguments[fluwxKeyMessageExt]
Action:call.arguments[fluwxKeyMessageAction] Action:call.arguments[fluwxKeyMessageAction]
ThumbImage:realThumbnailImage
InScene:[self intToWeChatScene:scene] InScene:[self intToWeChatScene:scene]
title:call.arguments[fluwxKeyTitle] title:call.arguments[fluwxKeyTitle]
description:call.arguments[fluwxKeyDescription] description:call.arguments[fluwxKeyDescription]
...@@ -723,23 +722,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -723,23 +722,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0); dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0);
dispatch_async(globalQueue, ^{ dispatch_async(globalQueue, ^{
UIImage *thumbnailImage = [self getCommonThumbnail:call];
NSData *hdImageData = nil;
NSDictionary *hdImagePath = call.arguments[@"hdImagePath"];
if (hdImagePath != (id) [NSNull null]) {
NSData *imageData = [self getNsDataFromWeChatFile:hdImagePath];
BOOL compress = [call.arguments[fluwxKeyCompressThumbnail] boolValue];
hdImageData = [self getThumbnailDataFromNSData:imageData size:120 * 1024 compress:compress];
// UIImage *uiImage = [self getThumbnailFromNSData:imageData size:120 * 1024 isPNG:isPNG compress:compress];
// if (isPNG) {
// hdImageData = UIImagePNGRepresentation(uiImage);
// } else {
// hdImageData = UIImageJPEGRepresentation(uiImage, 1);
// }
}
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
...@@ -765,8 +747,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -765,8 +747,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
path:call.arguments[@"path"] path:call.arguments[@"path"]
title:call.arguments[fluwxKeyTitle] title:call.arguments[fluwxKeyTitle]
Description:call.arguments[fluwxKeyDescription] Description:call.arguments[fluwxKeyDescription]
ThumbImage:thumbnailImage
hdImageData:hdImageData
withShareTicket:[call.arguments[@"withShareTicket"] boolValue] withShareTicket:[call.arguments[@"withShareTicket"] boolValue]
miniProgramType:miniProgramType miniProgramType:miniProgramType
MessageExt:call.arguments[fluwxKeyMessageExt] MessageExt:call.arguments[fluwxKeyMessageExt]
...@@ -1189,10 +1169,10 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -1189,10 +1169,10 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
} }
- (void)sendImageData:(NSData *)imageData - (void)sendImageData:(NSData *)imageData
ImgDataHash:(NSString *) imgDataHash
TagName:(NSString *)tagName TagName:(NSString *)tagName
MessageExt:(NSString *)messageExt MessageExt:(NSString *)messageExt
Action:(NSString *)action Action:(NSString *)action
ThumbImage:(UIImage *)thumbImage
InScene:(enum WXScene)scene InScene:(enum WXScene)scene
title:(NSString *)title title:(NSString *)title
description:(NSString *)description description:(NSString *)description
...@@ -1202,13 +1182,13 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -1202,13 +1182,13 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
completion:(void (^ __nullable)(BOOL success))completion { completion:(void (^ __nullable)(BOOL success))completion {
WXImageObject *ext = [WXImageObject object]; WXImageObject *ext = [WXImageObject object];
ext.imageData = imageData; ext.imageData = imageData;
ext.imgDataHash = (imgDataHash == (id) [NSNull null]) ? nil : imgDataHash;
WXMediaMessage *message = [self messageWithTitle:(title == (id) [NSNull null]) ? nil : title WXMediaMessage *message = [self messageWithTitle:(title == (id) [NSNull null]) ? nil : title
Description:(description == (id) [NSNull null]) ? nil : description Description:(description == (id) [NSNull null]) ? nil : description
Object:ext Object:ext
MessageExt:(messageExt == (id) [NSNull null]) ? nil : messageExt MessageExt:(messageExt == (id) [NSNull null]) ? nil : messageExt
MessageAction:(action == (id) [NSNull null]) ? nil : action MessageAction:(action == (id) [NSNull null]) ? nil : action
ThumbImage:thumbImage
MediaTag:(tagName == (id) [NSNull null]) ? nil : tagName MediaTag:(tagName == (id) [NSNull null]) ? nil : tagName
MsgSignature:(msgSignature == (id) [NSNull null]) ? nil : msgSignature MsgSignature:(msgSignature == (id) [NSNull null]) ? nil : msgSignature
ThumbData: thumbData ThumbData: thumbData
...@@ -1244,7 +1224,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -1244,7 +1224,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
Object:ext Object:ext
MessageExt:(messageExt == (id) [NSNull null]) ? nil : messageExt MessageExt:(messageExt == (id) [NSNull null]) ? nil : messageExt
MessageAction:(messageAction == (id) [NSNull null]) ? nil : messageAction MessageAction:(messageAction == (id) [NSNull null]) ? nil : messageAction
ThumbImage:thumbImage
MediaTag:(tagName == (id) [NSNull null]) ? nil : tagName MediaTag:(tagName == (id) [NSNull null]) ? nil : tagName
MsgSignature:(msgSignature == (id) [NSNull null]) ? nil : msgSignature MsgSignature:(msgSignature == (id) [NSNull null]) ? nil : msgSignature
ThumbData: thumbData ThumbData: thumbData
...@@ -1289,7 +1268,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -1289,7 +1268,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
Object:ext Object:ext
MessageExt:(messageExt == (id) [NSNull null]) ? nil : messageExt MessageExt:(messageExt == (id) [NSNull null]) ? nil : messageExt
MessageAction:(messageAction == (id) [NSNull null]) ? nil : messageAction MessageAction:(messageAction == (id) [NSNull null]) ? nil : messageAction
ThumbImage:thumbImage
MediaTag:(tagName == (id) [NSNull null]) ? nil : tagName MediaTag:(tagName == (id) [NSNull null]) ? nil : tagName
MsgSignature:(msgSignature == (id) [NSNull null]) ? nil : msgSignature MsgSignature:(msgSignature == (id) [NSNull null]) ? nil : msgSignature
ThumbData: thumbData ThumbData: thumbData
...@@ -1405,8 +1383,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -1405,8 +1383,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
path:(NSString *)path path:(NSString *)path
title:(NSString *)title title:(NSString *)title
Description:(NSString *)description Description:(NSString *)description
ThumbImage:(UIImage *)thumbImage
hdImageData:(NSData *)hdImageData
withShareTicket:(BOOL)withShareTicket withShareTicket:(BOOL)withShareTicket
miniProgramType:(WXMiniProgramType)programType miniProgramType:(WXMiniProgramType)programType
MessageExt:(NSString *)messageExt MessageExt:(NSString *)messageExt
...@@ -1421,7 +1397,7 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -1421,7 +1397,7 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
ext.webpageUrl = (webpageUrl == (id) [NSNull null]) ? nil : webpageUrl; ext.webpageUrl = (webpageUrl == (id) [NSNull null]) ? nil : webpageUrl;
ext.userName = (userName == (id) [NSNull null]) ? nil : userName; ext.userName = (userName == (id) [NSNull null]) ? nil : userName;
ext.path = (path == (id) [NSNull null]) ? nil : path; ext.path = (path == (id) [NSNull null]) ? nil : path;
ext.hdImageData = (hdImageData == (id) [NSNull null]) ? nil : hdImageData;
ext.withShareTicket = withShareTicket; ext.withShareTicket = withShareTicket;
ext.miniProgramType = programType; ext.miniProgramType = programType;
...@@ -1431,7 +1407,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -1431,7 +1407,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
Object:ext Object:ext
MessageExt:(messageExt == (id) [NSNull null]) ? nil : messageExt MessageExt:(messageExt == (id) [NSNull null]) ? nil : messageExt
MessageAction:(messageAction == (id) [NSNull null]) ? nil : messageAction MessageAction:(messageAction == (id) [NSNull null]) ? nil : messageAction
ThumbImage:thumbImage
MediaTag:(tagName == (id) [NSNull null]) ? nil : tagName MediaTag:(tagName == (id) [NSNull null]) ? nil : tagName
MsgSignature:(msgSignature == (id) [NSNull null]) ? nil : msgSignature MsgSignature:(msgSignature == (id) [NSNull null]) ? nil : msgSignature
ThumbData: thumbData ThumbData: thumbData
...@@ -1470,7 +1445,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -1470,7 +1445,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
Object:ext Object:ext
MessageExt:messageExt MessageExt:messageExt
MessageAction:action MessageAction:action
ThumbImage:thumbImage
MediaTag:nil MediaTag:nil
MsgSignature:(msgSignature == (id) [NSNull null]) ? nil : msgSignature MsgSignature:(msgSignature == (id) [NSNull null]) ? nil : msgSignature
ThumbData: thumbData ThumbData: thumbData
...@@ -1660,7 +1634,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -1660,7 +1634,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
Object:(id)mediaObject Object:(id)mediaObject
MessageExt:(NSString *)messageExt MessageExt:(NSString *)messageExt
MessageAction:(NSString *)action MessageAction:(NSString *)action
ThumbImage:(UIImage *)thumbImage
MediaTag:(NSString *)tagName MediaTag:(NSString *)tagName
MsgSignature:(NSString *)msgSignature MsgSignature:(NSString *)msgSignature
ThumbData:(NSData *)thumbData ThumbData:(NSData *)thumbData
...@@ -1678,7 +1651,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -1678,7 +1651,6 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
if(msgSignature != nil ){ if(msgSignature != nil ){
message.msgSignature = msgSignature; message.msgSignature = msgSignature;
} }
[message setThumbImage:thumbImage];
return message; return message;
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* the License. * the License.
*/ */
import 'dart:io';
import 'dart:typed_data'; import 'dart:typed_data';
import '../wechat_enums.dart'; import '../wechat_enums.dart';
......
...@@ -21,13 +21,11 @@ part of 'arguments.dart'; ...@@ -21,13 +21,11 @@ part of 'arguments.dart';
const String _scene = "scene"; const String _scene = "scene";
const String _source = "source"; const String _source = "source";
const String _thumbnail = "thumbnail";
const String _title = "title"; const String _title = "title";
const String _description = "description"; const String _description = "description";
const String _messageExt = "messageExt"; const String _messageExt = "messageExt";
const String _mediaTagName = "mediaTagName"; const String _mediaTagName = "mediaTagName";
const String _messageAction = "messageAction"; const String _messageAction = "messageAction";
const String _compressThumbnail = "compressThumbnail";
const String _msgSignature = "msgSignature"; const String _msgSignature = "msgSignature";
const String _thumbData = "thumbData"; const String _thumbData = "thumbData";
const String _thumbDataHash = "thumbDataHash"; const String _thumbDataHash = "thumbDataHash";
...@@ -88,8 +86,6 @@ class WeChatShareTextModel extends WeChatShareModel { ...@@ -88,8 +86,6 @@ class WeChatShareTextModel extends WeChatShareModel {
} }
/// the default value is [MINI_PROGRAM_TYPE_RELEASE] /// the default value is [MINI_PROGRAM_TYPE_RELEASE]
/// [hdImagePath] only works on iOS, not sure the relationship
/// between [thumbnail] and [hdImagePath].
class WeChatShareMiniProgramModel extends WeChatShareModel { class WeChatShareMiniProgramModel extends WeChatShareModel {
WeChatShareMiniProgramModel({ WeChatShareMiniProgramModel({
required this.webPageUrl, required this.webPageUrl,
...@@ -99,12 +95,9 @@ class WeChatShareMiniProgramModel extends WeChatShareModel { ...@@ -99,12 +95,9 @@ class WeChatShareMiniProgramModel extends WeChatShareModel {
super.title, super.title,
super.description, super.description,
this.withShareTicket = false, this.withShareTicket = false,
required this.thumbnail,
this.hdImagePath,
this.mediaTagName, this.mediaTagName,
this.messageAction, this.messageAction,
this.messageExt, this.messageExt,
this.compressThumbnail = true,
super.msgSignature, super.msgSignature,
super.thumbData, super.thumbData,
super.thumbDataHash, super.thumbDataHash,
...@@ -116,13 +109,10 @@ class WeChatShareMiniProgramModel extends WeChatShareModel { ...@@ -116,13 +109,10 @@ class WeChatShareMiniProgramModel extends WeChatShareModel {
final WXMiniProgramType miniProgramType; final WXMiniProgramType miniProgramType;
final String userName; final String userName;
final String path; final String path;
final WeChatImage? hdImagePath;
final WeChatImage thumbnail;
final bool withShareTicket; final bool withShareTicket;
final String? messageExt; final String? messageExt;
final String? messageAction; final String? messageAction;
final String? mediaTagName; final String? mediaTagName;
final bool compressThumbnail;
@override @override
Map<String, dynamic> get arguments => { Map<String, dynamic> get arguments => {
...@@ -133,11 +123,8 @@ class WeChatShareMiniProgramModel extends WeChatShareModel { ...@@ -133,11 +123,8 @@ class WeChatShareMiniProgramModel extends WeChatShareModel {
"title": title, "title": title,
_description: description, _description: description,
"withShareTicket": withShareTicket, "withShareTicket": withShareTicket,
_thumbnail: thumbnail.toMap(),
"hdImagePath": hdImagePath?.toMap(),
_messageAction: messageAction, _messageAction: messageAction,
_mediaTagName: mediaTagName, _mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature, _msgSignature: msgSignature,
_thumbData: thumbData, _thumbData: thumbData,
_thumbDataHash: thumbDataHash, _thumbDataHash: thumbDataHash,
...@@ -146,44 +133,43 @@ class WeChatShareMiniProgramModel extends WeChatShareModel { ...@@ -146,44 +133,43 @@ class WeChatShareMiniProgramModel extends WeChatShareModel {
/// [source] the image you want to send to WeChat /// [source] the image you want to send to WeChat
/// [scene] the target you want to send /// [scene] the target you want to send
/// [thumbnail] the preview of your image, will be created from [scene] if null.
class WeChatShareImageModel extends WeChatShareModel { class WeChatShareImageModel extends WeChatShareModel {
WeChatShareImageModel( WeChatShareImageModel(
this.source, { this.source, {
WeChatImage? thumbnail, this.entranceMiniProgramPath,
this.entranceMiniProgramUsername,
super.title, super.title,
this.scene = WeChatScene.session, this.scene = WeChatScene.session,
super.description, super.description,
this.mediaTagName, this.mediaTagName,
this.messageAction, this.messageAction,
this.messageExt, this.messageExt,
this.compressThumbnail = true,
super.msgSignature, super.msgSignature,
super.thumbData, super.thumbData,
super.thumbDataHash, super.thumbDataHash,
}) : thumbnail = thumbnail ?? source; });
final WeChatImage source; final WeChatImageToShare source;
final WeChatImage thumbnail;
final WeChatScene scene; final WeChatScene scene;
final String? messageExt; final String? messageExt;
final String? messageAction; final String? messageAction;
final String? mediaTagName; final String? mediaTagName;
final bool compressThumbnail; final String? entranceMiniProgramUsername;
final String? entranceMiniProgramPath;
@override @override
Map<String, dynamic> get arguments => { Map<String, dynamic> get arguments => {
_scene: scene.index, _scene: scene.index,
_source: source.toMap(), _source: source.arguments,
_thumbnail: thumbnail.toMap(),
_title: title, _title: title,
_description: description, _description: description,
_messageAction: messageAction, _messageAction: messageAction,
_mediaTagName: mediaTagName, _mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature, _msgSignature: msgSignature,
_thumbData: thumbData, _thumbData: thumbData,
_thumbDataHash: thumbDataHash, _thumbDataHash: thumbDataHash,
"entranceMiniProgramUsername": entranceMiniProgramUsername,
"entranceMiniProgramPath": entranceMiniProgramPath,
}; };
} }
...@@ -197,12 +183,10 @@ class WeChatShareMusicModel extends WeChatShareModel { ...@@ -197,12 +183,10 @@ class WeChatShareMusicModel extends WeChatShareModel {
super.description = "", super.description = "",
this.musicDataUrl, this.musicDataUrl,
this.musicLowBandDataUrl, this.musicLowBandDataUrl,
this.thumbnail,
this.mediaTagName, this.mediaTagName,
this.messageAction, this.messageAction,
this.messageExt, this.messageExt,
this.scene = WeChatScene.session, this.scene = WeChatScene.session,
this.compressThumbnail = true,
super.msgSignature, super.msgSignature,
super.thumbData, super.thumbData,
super.thumbDataHash}) super.thumbDataHash})
...@@ -212,12 +196,10 @@ class WeChatShareMusicModel extends WeChatShareModel { ...@@ -212,12 +196,10 @@ class WeChatShareMusicModel extends WeChatShareModel {
final String? musicDataUrl; final String? musicDataUrl;
final String? musicLowBandUrl; final String? musicLowBandUrl;
final String? musicLowBandDataUrl; final String? musicLowBandDataUrl;
final WeChatImage? thumbnail;
final WeChatScene scene; final WeChatScene scene;
final String? messageExt; final String? messageExt;
final String? messageAction; final String? messageAction;
final String? mediaTagName; final String? mediaTagName;
final bool compressThumbnail;
@override @override
Map<String, dynamic> get arguments => { Map<String, dynamic> get arguments => {
...@@ -226,12 +208,10 @@ class WeChatShareMusicModel extends WeChatShareModel { ...@@ -226,12 +208,10 @@ class WeChatShareMusicModel extends WeChatShareModel {
"musicDataUrl": musicDataUrl, "musicDataUrl": musicDataUrl,
"musicLowBandUrl": musicLowBandUrl, "musicLowBandUrl": musicLowBandUrl,
"musicLowBandDataUrl": musicLowBandDataUrl, "musicLowBandDataUrl": musicLowBandDataUrl,
_thumbnail: thumbnail?.toMap(),
_title: title, _title: title,
_description: description, _description: description,
_messageAction: messageAction, _messageAction: messageAction,
_mediaTagName: mediaTagName, _mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature, _msgSignature: msgSignature,
_thumbData: thumbData, _thumbData: thumbData,
_thumbDataHash: thumbDataHash, _thumbDataHash: thumbDataHash,
...@@ -247,37 +227,30 @@ class WeChatShareVideoModel extends WeChatShareModel { ...@@ -247,37 +227,30 @@ class WeChatShareVideoModel extends WeChatShareModel {
this.videoLowBandUrl, this.videoLowBandUrl,
super.title = "", super.title = "",
super.description = "", super.description = "",
this.thumbnail,
this.mediaTagName, this.mediaTagName,
this.messageAction, this.messageAction,
this.messageExt, this.messageExt,
this.compressThumbnail = true,
super.msgSignature, super.msgSignature,
super.thumbData, super.thumbData,
super.thumbDataHash, super.thumbDataHash,
}) : assert(videoUrl != null || videoLowBandUrl != null), }) : assert(videoUrl != null || videoLowBandUrl != null);
assert(thumbnail != null);
final String? videoUrl; final String? videoUrl;
final String? videoLowBandUrl; final String? videoLowBandUrl;
final WeChatImage? thumbnail;
final WeChatScene scene; final WeChatScene scene;
final String? messageExt; final String? messageExt;
final String? messageAction; final String? messageAction;
final String? mediaTagName; final String? mediaTagName;
final bool compressThumbnail;
@override @override
Map<String, dynamic> get arguments => { Map<String, dynamic> get arguments => {
_scene: scene.index, _scene: scene.index,
"videoUrl": videoUrl, "videoUrl": videoUrl,
"videoLowBandUrl": videoLowBandUrl, "videoLowBandUrl": videoLowBandUrl,
_thumbnail: thumbnail?.toMap(),
_title: title, _title: title,
_description: description, _description: description,
_messageAction: messageAction, _messageAction: messageAction,
_mediaTagName: mediaTagName, _mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature, _msgSignature: msgSignature,
_thumbData: thumbData, _thumbData: thumbData,
_thumbDataHash: thumbDataHash, _thumbDataHash: thumbDataHash,
...@@ -291,35 +264,29 @@ class WeChatShareWebPageModel extends WeChatShareModel { ...@@ -291,35 +264,29 @@ class WeChatShareWebPageModel extends WeChatShareModel {
this.webPage, { this.webPage, {
super.title = "", super.title = "",
super.description, super.description,
this.thumbnail,
this.scene = WeChatScene.session, this.scene = WeChatScene.session,
this.mediaTagName, this.mediaTagName,
this.messageAction, this.messageAction,
this.messageExt, this.messageExt,
this.compressThumbnail = true,
super.msgSignature, super.msgSignature,
super.thumbData, super.thumbData,
super.thumbDataHash, super.thumbDataHash,
}) : assert(webPage.isNotEmpty); }) : assert(webPage.isNotEmpty);
final String webPage; final String webPage;
final WeChatImage? thumbnail;
final WeChatScene scene; final WeChatScene scene;
final String? messageExt; final String? messageExt;
final String? messageAction; final String? messageAction;
final String? mediaTagName; final String? mediaTagName;
final bool compressThumbnail;
@override @override
Map<String, dynamic> get arguments => { Map<String, dynamic> get arguments => {
_scene: scene.index, _scene: scene.index,
"webPage": webPage, "webPage": webPage,
_thumbnail: thumbnail?.toMap(),
_title: title, _title: title,
_messageAction: messageAction, _messageAction: messageAction,
_mediaTagName: mediaTagName, _mediaTagName: mediaTagName,
_description: description, _description: description,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature, _msgSignature: msgSignature,
_thumbData: thumbData, _thumbData: thumbData,
_thumbDataHash: thumbDataHash, _thumbDataHash: thumbDataHash,
...@@ -334,37 +301,52 @@ class WeChatShareFileModel extends WeChatShareModel { ...@@ -334,37 +301,52 @@ class WeChatShareFileModel extends WeChatShareModel {
this.source, { this.source, {
super.title = "", super.title = "",
super.description = "", super.description = "",
this.thumbnail,
this.scene = WeChatScene.session, this.scene = WeChatScene.session,
this.mediaTagName, this.mediaTagName,
this.messageAction, this.messageAction,
this.messageExt, this.messageExt,
this.compressThumbnail = true,
super.msgSignature, super.msgSignature,
super.thumbData, super.thumbData,
super.thumbDataHash, super.thumbDataHash,
}); });
final WeChatFile source; final WeChatFile source;
final WeChatImage? thumbnail;
final WeChatScene scene; final WeChatScene scene;
final String? messageExt; final String? messageExt;
final String? messageAction; final String? messageAction;
final String? mediaTagName; final String? mediaTagName;
final bool compressThumbnail;
@override @override
Map<String, dynamic> get arguments => { Map<String, dynamic> get arguments => {
_scene: scene.index, _scene: scene.index,
_source: source.toMap(), _source: source.toMap(),
_thumbnail: thumbnail?.toMap(),
_title: title, _title: title,
_description: description, _description: description,
_messageAction: messageAction, _messageAction: messageAction,
_mediaTagName: mediaTagName, _mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature, _msgSignature: msgSignature,
_thumbData: thumbData, _thumbData: thumbData,
_thumbDataHash: thumbDataHash, _thumbDataHash: thumbDataHash,
}; };
} }
class WeChatImageToShare with _Argument {
final Uint8List? uint8List;
final String? localImagePath;
final String? imgDataHash;
/// [uint8List] is available on both iOS and Android
/// [localImagePath] only available on Android, if [uint8List] is null, [localImagePath] must not be null;
/// if [uint8List] and [localImagePath] are both provided on android, [uint8List] will be used.
WeChatImageToShare(this.uint8List, this.localImagePath, this.imgDataHash)
: assert(Platform.isIOS && uint8List != null),
assert(Platform.isAndroid &&
(uint8List != null || localImagePath != null));
@override
Map<String, dynamic> get arguments => {
'uint8List': uint8List,
'localImagePath': localImagePath,
'imgDataHash': imgDataHash,
};
}
...@@ -22,28 +22,6 @@ import 'dart:typed_data'; ...@@ -22,28 +22,6 @@ import 'dart:typed_data';
const String defaultSuffixJpeg = '.jpeg'; const String defaultSuffixJpeg = '.jpeg';
const String defaultSuffixTxt = '.txt'; const String defaultSuffixTxt = '.txt';
class WeChatImage extends WeChatFile {
WeChatImage.network(
String source, {
String suffix = defaultSuffixJpeg,
}) : super.network(source, suffix: suffix);
WeChatImage.asset(
String source, {
String suffix = defaultSuffixJpeg,
}) : super.asset(source, suffix: suffix);
WeChatImage.file(
File source, {
String suffix = defaultSuffixJpeg,
}) : super.file(source, suffix: suffix);
WeChatImage.binary(
Uint8List source, {
String suffix = defaultSuffixJpeg,
}) : super.binary(source, suffix: suffix);
}
class WeChatFile { class WeChatFile {
/// [source] must begin with http or https /// [source] must begin with http or https
WeChatFile.network( WeChatFile.network(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论