Skip to content

Commit

Permalink
appinio_social_share - version 0.3.1
Browse files Browse the repository at this point in the history
* update method to get correct default SMS package

* refactor

* layer: flutter_android

* nit

* fix: android

* layer: android

* general code

* fix: insta multifiles

* adding types

* Update README.md

* Update README.md

* fix: typecasting

* fix: twitter

* Update README.md

* fix:

* changelog

* iOS improvements

* appinio_social_share - version 0.3.1

---------

Co-authored-by: samuel.peirson.knowunity <[email protected]>
Co-authored-by: Bilal <[email protected]>
  • Loading branch information
3 people authored Apr 15, 2024
1 parent e7c5db3 commit 3e2a11a
Show file tree
Hide file tree
Showing 13 changed files with 610 additions and 207 deletions.
6 changes: 6 additions & 0 deletions packages/appinio_social_share/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [0.3.1] - 2024.04.15
* Many bug fixes and improvements.
* Refactoring:
- Now you will have to choose platform while sharing.
- For example: AppinioSocialShare().android.shareToWhatsapp(message, file)

## [0.3.0] - 2023.12.21
* Enhancement:
- Facebook Android Sdk updated to 16.0.0.
Expand Down
33 changes: 21 additions & 12 deletions packages/appinio_social_share/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ Add these permissions and queries to your AndroidManifest.xml
</manifest>
```

## NOTE:

MANAGE_EXTERNAL_STORAGE requires additional permissions from google. So do not add it if you are not planning to access external storage.
Check this for more info. https://support.google.com/googleplay/android-developer/answer/10467955?hl=en


Create xml folder and add a provider path file to it (for example: provider_paths_app.xml) in android/app/src/main/res and
add the lines below to the created xml file

Expand Down Expand Up @@ -403,36 +409,39 @@ class MyApp extends StatefulWidget {
}
class _MyAppState extends State<MyApp> {
AppinioSocialShare appinioSocialShare = AppinioSocialShare();
AppinioSocialShare appinioSocialShare = AppinioSocialShare();
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Share Feature",
home: Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
child: Text("ShareToWhatsapp"),
onPressed: () {
shareToWhatsApp("Message Text!!", filePaths: [file.getAbsolutePath()]);
},
child: const Text("ShareToWhatsapp"),
onPressed: () async {
FilePickerResult? result = await FilePicker.platform
.pickFiles(type: FileType.image, allowMultiple: false);
if (result != null && result.paths.isNotEmpty) {
shareToWhatsApp(
"message", result.paths[0]!);
}
},
),
],
),
)
);
));
}
Future<void> shareToWhatsApp(String message, {List<String>? filePaths) async{
String response = await appinioSocialShare.shareToWhatsapp(message,filePath: filePath);
print(response);
shareToWhatsApp(String message, String filePath) async {
await appinioSocialShare.android.shareToSMS(message, filePath);
}
}
```

<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,23 @@ public class AppinioSocialSharePlugin implements FlutterPlugin, MethodCallHandle
private final String INSTALLED_APPS = "installed_apps";
private final String INSTAGRAM_DIRECT = "instagram_direct";
private final String INSTAGRAM_FEED = "instagram_post";
private final String INSTAGRAM_FEED_FILES = "instagram_post_files";
private final String INSTAGRAM_STORIES = "instagram_stories";
private final String FACEBOOK = "facebook";
private final String MESSENGER = "messenger";
private final String FACEBOOK_STORIES = "facebook_stories";
private final String WHATSAPP = "whatsapp";
private final String TWITTER = "twitter";
private final String SMS = "sms";
private final String WHATSAPP_ANDROID = "whatsapp_android";
private final String WHATSAPP_ANDROID_MULTIFILES = "whatsapp_android_multifiles";
private final String TWITTER_ANDROID = "twitter_android";
private final String TWITTER_ANDROID_MULTIFILES = "twitter_android_multifiles";
private final String SMS_ANDROID = "sms_android";
private final String SMS_ANDROID_MULTIFILES = "sms_android_multifiles";
private final String TIKTOK = "tiktok_status";
private final String SYSTEM_SHARE = "system_share";
private final String SYSTEM_SHARE_ANDROID = "system_share_android";
private final String SYSTEM_SHARE_ANDROID_MULTIFILES = "system_share_android_multifiles";
private final String COPY_TO_CLIPBOARD = "copy_to_clipboard";
private final String TELEGRAM = "telegram";
private final String TELEGRAM_ANDROID = "telegram_android";
private final String TELEGRAM_ANDROID_MULTIFILES = "telegram_android_multifiles";


private SocialShareUtil socialShareUtil;
Expand All @@ -56,13 +62,13 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin

@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
try{
try {
String response = decideApp(call, result);
if (response != null) {
result.success(response);
}
}catch (Exception e){
Log.d("error",e.getLocalizedMessage());
} catch (Exception e) {
Log.d("error", e.getLocalizedMessage());
result.success(e.getLocalizedMessage());
}

Expand All @@ -75,43 +81,56 @@ public String decideApp(@NonNull MethodCall call, @NonNull Result result) {
String appId = call.argument("appId");
ArrayList<String> imagePaths = call.argument("imagePaths");
String stickerImage = call.argument("stickerImage");
String imagePath = call.argument("imagePath");
String attributionURL = call.argument("attributionURL");
String backgroundImage = call.argument("backgroundImage");
String backgroundTopColor = call.argument("backgroundTopColor");
String backgroundBottomColor = call.argument("backgroundBottomColor");
switch (call.method) {
case INSTALLED_APPS:
Map<String, Boolean> response = socialShareUtil.getInstalledApps(activeContext);
Map<String, Boolean> response = socialShareUtil.getInstalledApps(activeContext);
result.success(response);
return null;
case INSTAGRAM_DIRECT:
return socialShareUtil.shareToInstagramDirect(message,activeContext);
return socialShareUtil.shareToInstagramDirect(message, activeContext);
case INSTAGRAM_FEED:
return socialShareUtil.shareToInstagramFeed(imagePaths, activeContext, message);
return socialShareUtil.shareToInstagramFeed(imagePath, message, activeContext, message);
case INSTAGRAM_FEED_FILES:
return socialShareUtil.shareToInstagramFeedFiles(imagePaths, activeContext,message);
case INSTAGRAM_STORIES:
return socialShareUtil.shareToInstagramStory(appId, stickerImage, backgroundImage, backgroundTopColor, backgroundBottomColor, attributionURL, activeContext);
case FACEBOOK_STORIES:
return socialShareUtil.shareToFaceBookStory(appId, stickerImage, backgroundImage, backgroundTopColor, backgroundBottomColor, attributionURL, activeContext);
case MESSENGER:
case MESSENGER:
return socialShareUtil.shareToMessenger(message, activeContext);
case FACEBOOK:
if (activity == null) return SocialShareUtil.UNKNOWN_ERROR;
socialShareUtil.shareToFacebook(imagePaths, message, activity, result);
return null;
case WHATSAPP:
return socialShareUtil.shareToWhatsApp(imagePaths, message, activeContext);
case TELEGRAM:
return socialShareUtil.shareToTelegram(imagePaths, activeContext, message);
case TWITTER:
return socialShareUtil.shareToTwitter(imagePaths, activeContext, message);
case WHATSAPP_ANDROID:
return socialShareUtil.shareToWhatsApp(imagePath, message, activeContext);
case WHATSAPP_ANDROID_MULTIFILES:
return socialShareUtil.shareToWhatsAppFiles(imagePaths, activeContext);
case TELEGRAM_ANDROID:
return socialShareUtil.shareToTelegram(imagePath, activeContext, message);
case TELEGRAM_ANDROID_MULTIFILES:
return socialShareUtil.shareToTelegramFiles(imagePaths, activeContext);
case TWITTER_ANDROID:
return socialShareUtil.shareToTwitter(imagePath, activeContext, message);
case TWITTER_ANDROID_MULTIFILES:
return socialShareUtil.shareToTwitterFiles(imagePaths, activeContext);
case COPY_TO_CLIPBOARD:
return socialShareUtil.copyToClipBoard(message, activeContext);
case SYSTEM_SHARE:
return socialShareUtil.shareToSystem(title, message, imagePaths, "image/*", title, context);
case SYSTEM_SHARE_ANDROID:
return socialShareUtil.shareToSystem(title, message, imagePath, title, context);
case SYSTEM_SHARE_ANDROID_MULTIFILES:
return socialShareUtil.shareToSystemFiles(title, imagePaths, title, context);
case TIKTOK:
return socialShareUtil.shareToTikTok(imagePaths, activeContext, message);
case SMS:
return socialShareUtil.shareToSMS(message, activeContext,imagePaths);
return socialShareUtil.shareToTikTok(imagePaths, activeContext);
case SMS_ANDROID:
return socialShareUtil.shareToSMS(message, activeContext, imagePath);
case SMS_ANDROID_MULTIFILES:
return socialShareUtil.shareToSMSFiles(activeContext, imagePaths);
default:
return null;
}
Expand Down
Loading

0 comments on commit 3e2a11a

Please sign in to comment.