@capgo/capacitor-share-target 8.0.46 → 8.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,6 +3,7 @@ package app.capgo.sharetarget;
|
|
|
3
3
|
import android.content.Intent;
|
|
4
4
|
import android.database.Cursor;
|
|
5
5
|
import android.net.Uri;
|
|
6
|
+
import android.os.Build;
|
|
6
7
|
import android.provider.OpenableColumns;
|
|
7
8
|
import android.util.Log;
|
|
8
9
|
import android.webkit.MimeTypeMap;
|
|
@@ -59,7 +60,12 @@ public class CapacitorShareTargetPlugin extends Plugin {
|
|
|
59
60
|
// Get files
|
|
60
61
|
JSArray files = new JSArray();
|
|
61
62
|
if (Intent.ACTION_SEND.equals(action)) {
|
|
62
|
-
Uri fileUri
|
|
63
|
+
Uri fileUri;
|
|
64
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
65
|
+
fileUri = intent.getParcelableExtra(Intent.EXTRA_STREAM, Uri.class);
|
|
66
|
+
} else {
|
|
67
|
+
fileUri = getParcelableExtraLegacy(intent, Intent.EXTRA_STREAM);
|
|
68
|
+
}
|
|
63
69
|
if (fileUri != null) {
|
|
64
70
|
JSObject fileData = getFileData(fileUri);
|
|
65
71
|
if (fileData != null) {
|
|
@@ -67,7 +73,12 @@ public class CapacitorShareTargetPlugin extends Plugin {
|
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action)) {
|
|
70
|
-
ArrayList<Uri> fileUris
|
|
76
|
+
ArrayList<Uri> fileUris;
|
|
77
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
78
|
+
fileUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM, Uri.class);
|
|
79
|
+
} else {
|
|
80
|
+
fileUris = getParcelableArrayListExtraLegacy(intent, Intent.EXTRA_STREAM);
|
|
81
|
+
}
|
|
71
82
|
if (fileUris != null) {
|
|
72
83
|
for (Uri fileUri : fileUris) {
|
|
73
84
|
JSObject fileData = getFileData(fileUri);
|
|
@@ -88,6 +99,16 @@ public class CapacitorShareTargetPlugin extends Plugin {
|
|
|
88
99
|
}
|
|
89
100
|
}
|
|
90
101
|
|
|
102
|
+
@SuppressWarnings("deprecation")
|
|
103
|
+
private Uri getParcelableExtraLegacy(Intent intent, String key) {
|
|
104
|
+
return intent.getParcelableExtra(key);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@SuppressWarnings("deprecation")
|
|
108
|
+
private ArrayList<Uri> getParcelableArrayListExtraLegacy(Intent intent, String key) {
|
|
109
|
+
return intent.getParcelableArrayListExtra(key);
|
|
110
|
+
}
|
|
111
|
+
|
|
91
112
|
private JSObject getFileData(Uri uri) {
|
|
92
113
|
try {
|
|
93
114
|
JSObject fileData = new JSObject();
|
|
@@ -8,7 +8,7 @@ import UIKit
|
|
|
8
8
|
*/
|
|
9
9
|
@objc(CapacitorShareTargetPlugin)
|
|
10
10
|
public class CapacitorShareTargetPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
11
|
-
private let pluginVersion: String = "8.0.
|
|
11
|
+
private let pluginVersion: String = "8.0.48"
|
|
12
12
|
public let identifier = "CapacitorShareTargetPlugin"
|
|
13
13
|
public let jsName = "CapacitorShareTarget"
|
|
14
14
|
public let pluginMethods: [CAPPluginMethod] = [
|