diff --git a/Adapters/AndroidUnityNativeSharingAdapter.cs b/Adapters/AndroidUnityNativeSharingAdapter.cs index 038ef86..f4e4cbd 100644 --- a/Adapters/AndroidUnityNativeSharingAdapter.cs +++ b/Adapters/AndroidUnityNativeSharingAdapter.cs @@ -33,11 +33,11 @@ public AndroidUnityNativeSharingAdapter() sharingJavaClass = new AndroidJavaClass(AndroidClass); } - public void ShareScreenshotAndText(string shareText, string filePath, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With") + public void ShareScreenshotAndText(string shareText, string filePath, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With", string mimeType = "image/*") { AndroidJNI.AttachCurrentThread(); - sharingJavaClass.CallStatic(ShareScreenshotWithTextMethodName, shareText, filePath, showShareDialogBox, shareDialogBoxText); + sharingJavaClass.CallStatic(ShareScreenshotWithTextMethodName, shareText, filePath, showShareDialogBox, shareDialogBoxText, mimeType); } public void ShareText(string shareText, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With") diff --git a/Adapters/IUnityNativeSharingAdapter.cs b/Adapters/IUnityNativeSharingAdapter.cs index 3a20c87..4065cc4 100644 --- a/Adapters/IUnityNativeSharingAdapter.cs +++ b/Adapters/IUnityNativeSharingAdapter.cs @@ -2,7 +2,7 @@ namespace UnityNative.Sharing { public interface IUnityNativeSharingAdapter { - void ShareScreenshotAndText(string shareText, string filePath, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With"); + void ShareScreenshotAndText(string shareText, string filePath, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With", string mimeType = "image/*"); void ShareText(string shareText, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With"); } } diff --git a/Adapters/IosUnityNativeSharingAdapter.cs b/Adapters/IosUnityNativeSharingAdapter.cs index e709708..bd74aeb 100644 --- a/Adapters/IosUnityNativeSharingAdapter.cs +++ b/Adapters/IosUnityNativeSharingAdapter.cs @@ -10,7 +10,7 @@ public class IosUnityNativeSharingAdapter : IUnityNativeSharingAdapter [System.Runtime.InteropServices.DllImport("__Internal")] private static extern void UnityNative_Sharing_ShareText(string shareText); - public void ShareScreenshotAndText(string shareText, string filePath, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With") + public void ShareScreenshotAndText(string shareText, string filePath, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With", string mimeType = "image/*") { UnityNative_Sharing_ShareTextAndScreenshot(shareText, filePath); } diff --git a/Adapters/NullUnityNativeSharingAdapter.cs b/Adapters/NullUnityNativeSharingAdapter.cs index 74085b6..bb9751e 100644 --- a/Adapters/NullUnityNativeSharingAdapter.cs +++ b/Adapters/NullUnityNativeSharingAdapter.cs @@ -2,7 +2,7 @@ namespace UnityNative.Sharing { public class NullUnityNativeSharingAdapter : IUnityNativeSharingAdapter { - public void ShareScreenshotAndText(string shareText, string filePath, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With") + public void ShareScreenshotAndText(string shareText, string filePath, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With", string mimeType = "image/*") { } diff --git a/CHANGELOG.md b/CHANGELOG.md index f118c23..ddbd62c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,9 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [1.0.6] - 2021-03-09 +### Added +- Added optional mime type parameter for Android to use in the intent rather than it being hardcoded to `image/*` ## [1.0.5] - 2021-01-07 ### Fixed diff --git a/Plugins/Android/com.UnityNative.Sharing-v1.0.5.aar b/Plugins/Android/com.UnityNative.Sharing-v1.0.6.aar similarity index 83% rename from Plugins/Android/com.UnityNative.Sharing-v1.0.5.aar rename to Plugins/Android/com.UnityNative.Sharing-v1.0.6.aar index 02334f3..1137f7d 100644 Binary files a/Plugins/Android/com.UnityNative.Sharing-v1.0.5.aar and b/Plugins/Android/com.UnityNative.Sharing-v1.0.6.aar differ diff --git a/Plugins/Android/com.UnityNative.Sharing-v1.0.5.aar.meta b/Plugins/Android/com.UnityNative.Sharing-v1.0.6.aar.meta similarity index 100% rename from Plugins/Android/com.UnityNative.Sharing-v1.0.5.aar.meta rename to Plugins/Android/com.UnityNative.Sharing-v1.0.6.aar.meta diff --git a/Plugins/Android/src~/Unity-Native-Sharing/build.gradle b/Plugins/Android/src~/Unity-Native-Sharing/build.gradle index fda7f5b..9935a8b 100644 --- a/Plugins/Android/src~/Unity-Native-Sharing/build.gradle +++ b/Plugins/Android/src~/Unity-Native-Sharing/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'com.android.library' ext.outputDir = "..\\.." -ext.outputName = "com.UnityNative.Sharing-v1.0.5" +ext.outputName = "com.UnityNative.Sharing-v1.0.6" android { compileSdkVersion 28 diff --git a/Plugins/Android/src~/Unity-Native-Sharing/src/main/java/com/UnityNative/Sharing/UnityNativeSharingAdapter.java b/Plugins/Android/src~/Unity-Native-Sharing/src/main/java/com/UnityNative/Sharing/UnityNativeSharingAdapter.java index e0265ca..e42616a 100644 --- a/Plugins/Android/src~/Unity-Native-Sharing/src/main/java/com/UnityNative/Sharing/UnityNativeSharingAdapter.java +++ b/Plugins/Android/src~/Unity-Native-Sharing/src/main/java/com/UnityNative/Sharing/UnityNativeSharingAdapter.java @@ -24,14 +24,15 @@ public class UnityNativeSharingAdapter { * @param imagePath - Path to the file to share * @param showShareDialog - Should the share dialog be opened * @param shareDialogBoxText - Title of the share dialog + * @param mimeType - Mime type of the file being shared */ @Keep - public static void ShareScreenshotAndText(String shareText, String imagePath, boolean showShareDialog, String shareDialogBoxText) { + public static void ShareScreenshotAndText(String shareText, String imagePath, boolean showShareDialog, String shareDialogBoxText, String mimeType) { //Generate the intent Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); - intent.setType("image/*"); + intent.setType(mimeType); intent.putExtra(Intent.EXTRA_TEXT, shareText); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); diff --git a/README.md b/README.md index bafd3cd..18a1514 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Examples can be found at [Unity-Native-Example-Project](https://github.com/Nicho ![AddPackageFromGitURL](Images~/AddPackageFromGitURL.PNG) -`https://github.com/NicholasSheehan/Unity-Native-Sharing.git#v1.0.5` +`https://github.com/NicholasSheehan/Unity-Native-Sharing.git#v1.0.6`

Unity 2018.3 or later (Using Unity Package Manager)

@@ -50,7 +50,7 @@ Add this to the projects `manifest.json` To update the package, change suffix `#{version}` to the target version. -* e.g. `"com.unitynative.sharing" : "https://github.com/NicholasSheehan/Unity-Native-Sharing.git#v1.0.5"` +* e.g. `"com.unitynative.sharing" : "https://github.com/NicholasSheehan/Unity-Native-Sharing.git#v1.0.6"`

Unity 2018.3 or later (Using OpenUPM)

diff --git a/UnityNativeSharing.cs b/UnityNativeSharing.cs index 29fda6f..ef7660c 100644 --- a/UnityNativeSharing.cs +++ b/UnityNativeSharing.cs @@ -2,7 +2,7 @@ { public interface IUnityNativeSharing { - void ShareScreenshotAndText(string shareText, string filePath, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With"); + void ShareScreenshotAndText(string shareText, string filePath, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With", string mimeType = "image/*"); void ShareText(string shareText, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With"); } @@ -38,9 +38,10 @@ public UnityNativeSharing(IUnityNativeSharingAdapter adapter) /// The path to the attached file /// Should the share dialog be opened (Android only) /// The text to show on the share dialog (Android only) - public void ShareScreenshotAndText(string shareText, string filePath, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With") + /// Mime type of the file being shared (Android only) + public void ShareScreenshotAndText(string shareText, string filePath, bool showShareDialogBox = true, string shareDialogBoxText = "Select App To Share With", string mimeType = "image/*") { - adapter.ShareScreenshotAndText(shareText, filePath, showShareDialogBox, shareDialogBoxText); + adapter.ShareScreenshotAndText(shareText, filePath, showShareDialogBox, shareDialogBoxText, mimeType); } /// diff --git a/package.json b/package.json index 8e45521..5b407e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.unitynative.sharing", - "version": "1.0.5", + "version": "1.0.6", "displayName": "Unity-Native-Sharing", "description": "A Unity plugin to open native sharing dialogs on iOS and Android", "unity": "2018.3",