From aae5e81164579db50046faaaa9a4d5bf489dc91b Mon Sep 17 00:00:00 2001 From: Nicholas Sheehan Date: Sat, 8 May 2021 02:47:21 +0100 Subject: [PATCH] v1.0.6 Added optional mime type for Android sharing intents --- Adapters/AndroidUnityNativeSharingAdapter.cs | 4 ++-- Adapters/IUnityNativeSharingAdapter.cs | 2 +- Adapters/IosUnityNativeSharingAdapter.cs | 2 +- Adapters/NullUnityNativeSharingAdapter.cs | 2 +- CHANGELOG.md | 4 +++- ...aar => com.UnityNative.Sharing-v1.0.6.aar} | Bin 18913 -> 18926 bytes ...> com.UnityNative.Sharing-v1.0.6.aar.meta} | 0 .../src~/Unity-Native-Sharing/build.gradle | 2 +- .../Sharing/UnityNativeSharingAdapter.java | 5 +++-- README.md | 4 ++-- UnityNativeSharing.cs | 7 ++++--- package.json | 2 +- 12 files changed, 19 insertions(+), 15 deletions(-) rename Plugins/Android/{com.UnityNative.Sharing-v1.0.5.aar => com.UnityNative.Sharing-v1.0.6.aar} (83%) rename Plugins/Android/{com.UnityNative.Sharing-v1.0.5.aar.meta => com.UnityNative.Sharing-v1.0.6.aar.meta} (100%) 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 02334f338e3b4df1bdc5b97ee64fb3c2f431906a..1137f7daef798bc61727e8c30089c9fec4764476 100644 GIT binary patch delta 2518 zcmZXWXHXO97KRf7ArNvY(lpWq1XM1IG-&}suc3oMq)U}vLdh-?5R@XJSAmTpJ#

A;V3m-sP-Z!LI405z6uD(LawQu#yaxPM;G(!K!gLWH=@%L1H~KxkBT&CSZM{X zD=(w@ZzL)m(p|Hi}xGX5>sS)AC#`Ib#Mx-OH;yQAC_8*z@>Ou*uh?%&tv` zH+n-f-b~$!rkp;tK3L60AFD>Kl0h7k_SCCWG2wbZ1(W{U8viB@OhxF#J1&*;pj)o# zLaM7jDqM4AgYR_rvO)2QUq*#9a1^mHJ4ao@7f5-T9PUF4jjj4-AH7nHsT!M`WBpz= z;w##lVuyU?+z~kGW2?(;DDn>Vz^W-L?L1bu)~P(V@k7P$^4QIl3C+YRl6}GC_y|D~ z>P3(HpP_121P(FfAjgP~=-5I_={yB-LP+L;=sJt~?4qmD{4yfr zNamP5&T^;vG%4`3rGaRz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(4Mv0t7iZoN&PsL4Xi%NkSpFRN zz{Rq9tz`2@synYLys$^i09K>$hq@v;t&53T3EH=s*qvG>kU?(>9K+zQ(bJ@Je_(x- zWL2@6{t$T2TzVn5&_nNUUJSqyt^}QR;x1bsRviFHu-R{7<^3CC<=R|SGF^TIF}>Rh z%MrKq=)bjAR)X65J;ymmC`tNEkexxR`(S|(4{zO9>nH4pNU2@+JeTVyd2*IzG}Cf+ zp4n}RGJoan03%elUzD97OyLEtk=I(aur*BnosvJ-KbG|UYlCHspHq`AWy@yP;|dpp@ewka0k?Fl7PjWmVXeu|Xe{M&otCNQ*J zrhd1zlyOTocF6hrc9|Y{jD+2iB5#IY$ZMgGu2$7)U@(zw0y$n(O9&W=%r~m?IOoq$ z4>2$Kb8~muvv(Y38YJ=L>0JK@!$SE>&O>EB=?(&ay~wK0RVpi8UKzF 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",