diff --git a/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeShareBroadcastListener.java b/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeShareBroadcastListener.java index 8e5fe0b..0b7e38c 100644 --- a/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeShareBroadcastListener.java +++ b/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeShareBroadcastListener.java @@ -26,10 +26,7 @@ public static IntentSender Initialize( Context context ) // Maybe FLAG_IMMUTABLE is sufficient but the pre-31 default value was implicitly mutable and I don't trust // all social apps to work correctly on Android 12+ (API 31+) if I set it to FLAG_IMMUTABLE //pendingIntentFlags |= PendingIntent.FLAG_MUTABLE; - - // Only temporarily set the IMMUTABLE flag to avoid crashes until Android 12 SDK is officially released - // https://github.com/yasirkula/UnityNativeShare/issues/130 - pendingIntentFlags |= PendingIntent.FLAG_IMMUTABLE; + pendingIntentFlags |= 1 << 25; // Hardcoded value of PendingIntent.FLAG_MUTABLE (when compiling with an older SDK version) } return PendingIntent.getBroadcast( context, 0, receiverIntent, pendingIntentFlags ).getIntentSender(); diff --git a/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeShareContentProvider.java b/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeShareContentProvider.java index ddea4fd..00d9421 100644 --- a/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeShareContentProvider.java +++ b/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeShareContentProvider.java @@ -12,6 +12,7 @@ import android.os.ParcelFileDescriptor; import android.provider.OpenableColumns; import android.text.TextUtils; +import android.util.Log; import android.webkit.MimeTypeMap; import org.xmlpull.v1.XmlPullParserException; @@ -254,12 +255,19 @@ private static PathStrategy parsePathStrategy(Context context, String authority) final SimplePathStrategy strat = new SimplePathStrategy(authority); final ProviderInfo info = context.getPackageManager() .resolveContentProvider(authority, PackageManager.GET_META_DATA); - final XmlResourceParser in = info.loadXmlMetaData( - context.getPackageManager(), META_DATA_FILE_PROVIDER_PATHS); - //if (in == null) { - // throw new IllegalArgumentException( - // "Missing " + META_DATA_FILE_PROVIDER_PATHS + " meta-data"); - //} + if (info == null) + { + Log.w("Unity", "NativeShareContentProvider.resolveContentProvider is null!"); + } + else + { + final XmlResourceParser in = info.loadXmlMetaData( + context.getPackageManager(), META_DATA_FILE_PROVIDER_PATHS ); + //if (in == null) { + // throw new IllegalArgumentException( + // "Missing " + META_DATA_FILE_PROVIDER_PATHS + " meta-data"); + //} + } File target = null; target = buildPath(DEVICE_ROOT, "."); diff --git a/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeShareFragment.java b/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeShareFragment.java index e5090dc..e4b433f 100644 --- a/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeShareFragment.java +++ b/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeShareFragment.java @@ -39,7 +39,7 @@ public void onCreate( Bundle savedInstanceState ) super.onCreate( savedInstanceState ); if( NativeShare.shareResultReceiver == null ) - getFragmentManager().beginTransaction().remove( this ).commit(); + onActivityResult( SHARE_RESULT_CODE, Activity.RESULT_CANCELED, null ); else { final ArrayList fileUris = new ArrayList(); diff --git a/.github/README.md b/.github/README.md index 90b9cd3..3c18c02 100644 --- a/.github/README.md +++ b/.github/README.md @@ -39,6 +39,7 @@ There are two ways to set up the plugin on iOS: Simply create a new **NativeShare** object and customize it by chaining the following functions as you like (see example code): +- `Clear()`: clears the previously set share content (if any). Only useful if the same NativeShare instance will be reused for memory efficiency - `SetSubject( string subject )`: sets the subject (primarily used in e-mail applications) - `SetText( string text )`: sets the shared text. Note that the Facebook app will omit text, if exists (see [this topic](https://stackoverflow.com/a/35102802/2373034)) - `SetUrl( string url )`: sets the shared url. On supported iOS apps, this url is used to generate a preview of the target webpage. Other iOS apps may append the url to the text or omit it. While sharing a file on iOS or while sharing anything on Android, the url is appended to the text (unless the text already contains the url) diff --git a/Plugins/NativeShare/Android/NativeShare.aar b/Plugins/NativeShare/Android/NativeShare.aar index 84f2dc9..17b3707 100644 Binary files a/Plugins/NativeShare/Android/NativeShare.aar and b/Plugins/NativeShare/Android/NativeShare.aar differ diff --git a/Plugins/NativeShare/NativeShare.cs b/Plugins/NativeShare/NativeShare.cs index f27e814..4544ef0 100644 --- a/Plugins/NativeShare/NativeShare.cs +++ b/Plugins/NativeShare/NativeShare.cs @@ -53,9 +53,7 @@ private static AndroidJavaObject Context #if UNITY_EDITOR || UNITY_ANDROID private readonly List emailRecipients = new List( 0 ); -#endif -#if UNITY_EDITOR || UNITY_ANDROID private readonly List targetPackages = new List( 0 ); private readonly List targetClasses = new List( 0 ); #endif @@ -65,6 +63,23 @@ private static AndroidJavaObject Context private ShareResultCallback callback; + public NativeShare Clear() + { + subject = text = title = url = string.Empty; + +#if UNITY_EDITOR || UNITY_ANDROID + emailRecipients.Clear(); + targetPackages.Clear(); + targetClasses.Clear(); +#endif + files.Clear(); + mimes.Clear(); + + callback = null; + + return this; + } + public NativeShare SetSubject( string subject ) { this.subject = subject ?? string.Empty; diff --git a/Plugins/NativeShare/README.txt b/Plugins/NativeShare/README.txt index 76afe8d..b3c76ef 100644 --- a/Plugins/NativeShare/README.txt +++ b/Plugins/NativeShare/README.txt @@ -1,4 +1,4 @@ -= Native Share for Android & iOS = += Native Share for Android & iOS (v1.4.8) = Online documentation & example code available at: https://github.com/yasirkula/UnityNativeShare E-mail: yasirkula@gmail.com @@ -44,6 +44,7 @@ If you are sure that your plugin is up-to-date, then enable "Custom Proguard Fil 4. SCRIPTING API Simply create a new NativeShare object and customize it by chaining the following functions as you like: +- Clear(): clears the previously set share content (if any). Only useful if the same NativeShare instance will be reused for memory efficiency - SetSubject( string subject ): sets the subject (primarily used in e-mail applications) - SetText( string text ): sets the shared text. Note that the Facebook app will omit text, if exists - SetUrl( string url ): sets the shared url. On supported iOS apps, this url is used to generate a preview of the target webpage. Other iOS apps may append the url to the text or omit it. While sharing a file on iOS or while sharing anything on Android, the url is appended to the text (unless the text already contains the url) diff --git a/package.json b/package.json index 92ec363..6b9eddf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.yasirkula.nativeshare", "displayName": "Native Share", - "version": "1.4.7", + "version": "1.4.8", "documentationUrl": "https://github.com/yasirkula/UnityNativeShare", "changelogUrl": "https://github.com/yasirkula/UnityNativeShare/releases", "licensesUrl": "https://github.com/yasirkula/UnityNativeShare/blob/master/LICENSE.txt",