react-native-kookit 0.4.4 → 0.4.5
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.
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withContentUriCopy.d.ts","sourceRoot":"","sources":["../src/withContentUriCopy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAGb,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;;;GAUG;AACH,QAAA,MAAM,kBAAkB,EAAE,YAKzB,CAAC;
|
|
1
|
+
{"version":3,"file":"withContentUriCopy.d.ts","sourceRoot":"","sources":["../src/withContentUriCopy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAGb,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;;;GAUG;AACH,QAAA,MAAM,kBAAkB,EAAE,YAKzB,CAAC;AA4QF,eAAe,kBAAkB,CAAC"}
|
|
@@ -37,7 +37,6 @@ function addContentUriCopyKotlin(contents) {
|
|
|
37
37
|
const imports = [
|
|
38
38
|
"import android.content.Intent",
|
|
39
39
|
"import android.net.Uri",
|
|
40
|
-
"import android.os.Build",
|
|
41
40
|
"import android.util.Log",
|
|
42
41
|
"import java.io.File",
|
|
43
42
|
"import java.io.FileOutputStream",
|
|
@@ -62,14 +61,22 @@ function addContentUriCopyKotlin(contents) {
|
|
|
62
61
|
const methods = `
|
|
63
62
|
// content:// URI cold-start copy - Added by react-native-kookit
|
|
64
63
|
override fun onNewIntent(intent: Intent) {
|
|
65
|
-
|
|
64
|
+
// Call super first so other modules (e.g. expo-share-intent) can process
|
|
65
|
+
// the original intent before we potentially rewrite it.
|
|
66
66
|
super.onNewIntent(intent)
|
|
67
|
+
copyContentUriOnColdStart(intent)
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
|
-
* If [intent] carries a content:// URI
|
|
71
|
-
* the
|
|
72
|
-
*
|
|
71
|
+
* If [intent] carries a content:// URI via ACTION_VIEW, copy the file to
|
|
72
|
+
* the app's cache directory synchronously and rewrite the intent so that
|
|
73
|
+
* downstream code receives a plain file:// URI instead.
|
|
74
|
+
*
|
|
75
|
+
* ACTION_SEND intents are intentionally left untouched so that other modules
|
|
76
|
+
* (e.g. expo-share-intent) can query the ContentResolver with the original
|
|
77
|
+
* content:// URI. Rewriting the URI before those modules run causes a
|
|
78
|
+
* NullPointerException in ContentResolver.query() because file:// URIs are
|
|
79
|
+
* not supported by the ContentProvider.
|
|
73
80
|
*
|
|
74
81
|
* This consumes the one-shot URI permission while it is still valid,
|
|
75
82
|
* preventing "permission denied" errors in the JS layer.
|
|
@@ -77,14 +84,10 @@ function addContentUriCopyKotlin(contents) {
|
|
|
77
84
|
private fun copyContentUriOnColdStart(intent: Intent) {
|
|
78
85
|
try {
|
|
79
86
|
val action = intent.action
|
|
87
|
+
// Only handle ACTION_VIEW here. ACTION_SEND is handled by
|
|
88
|
+
// expo-share-intent (or similar) which needs the original content:// URI.
|
|
80
89
|
val uri: Uri? = when (action) {
|
|
81
90
|
Intent.ACTION_VIEW -> intent.data
|
|
82
|
-
Intent.ACTION_SEND -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
83
|
-
intent.getParcelableExtra(Intent.EXTRA_STREAM, Uri::class.java)
|
|
84
|
-
} else {
|
|
85
|
-
@Suppress("DEPRECATION")
|
|
86
|
-
intent.getParcelableExtra(Intent.EXTRA_STREAM)
|
|
87
|
-
}
|
|
88
91
|
else -> null
|
|
89
92
|
}
|
|
90
93
|
|
|
@@ -117,9 +120,9 @@ function addContentUriCopyKotlin(contents) {
|
|
|
117
120
|
Log.i("MainActivity", "Copied content URI to: \${destFile.absolutePath}")
|
|
118
121
|
|
|
119
122
|
val fileUri = Uri.fromFile(destFile)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
// Only ACTION_VIEW is rewritten; ACTION_SEND is left for other modules.
|
|
124
|
+
if (action == Intent.ACTION_VIEW) {
|
|
125
|
+
intent.data = fileUri
|
|
123
126
|
}
|
|
124
127
|
} catch (e: Exception) {
|
|
125
128
|
Log.w("MainActivity", "Failed to copy content URI: \${e.message}")
|
|
@@ -143,7 +146,6 @@ function addContentUriCopyJava(contents) {
|
|
|
143
146
|
const imports = [
|
|
144
147
|
"import android.content.Intent;",
|
|
145
148
|
"import android.net.Uri;",
|
|
146
|
-
"import android.os.Build;",
|
|
147
149
|
"import android.util.Log;",
|
|
148
150
|
"import java.io.File;",
|
|
149
151
|
"import java.io.FileOutputStream;",
|
|
@@ -170,14 +172,22 @@ function addContentUriCopyJava(contents) {
|
|
|
170
172
|
// content:// URI cold-start copy - Added by react-native-kookit
|
|
171
173
|
@Override
|
|
172
174
|
public void onNewIntent(Intent intent) {
|
|
173
|
-
|
|
175
|
+
// Call super first so other modules (e.g. expo-share-intent) can process
|
|
176
|
+
// the original intent before we potentially rewrite it.
|
|
174
177
|
super.onNewIntent(intent);
|
|
178
|
+
copyContentUriOnColdStart(intent);
|
|
175
179
|
}
|
|
176
180
|
|
|
177
181
|
/**
|
|
178
|
-
* If intent carries a content:// URI
|
|
179
|
-
*
|
|
180
|
-
*
|
|
182
|
+
* If intent carries a content:// URI via ACTION_VIEW, copy the file to the
|
|
183
|
+
* app's cache directory synchronously and rewrite the intent so that
|
|
184
|
+
* downstream code receives a plain file:// URI instead.
|
|
185
|
+
*
|
|
186
|
+
* ACTION_SEND intents are intentionally left untouched so that other modules
|
|
187
|
+
* (e.g. expo-share-intent) can query the ContentResolver with the original
|
|
188
|
+
* content:// URI. Rewriting the URI before those modules run causes a
|
|
189
|
+
* NullPointerException in ContentResolver.query() because file:// URIs are
|
|
190
|
+
* not supported by the ContentProvider.
|
|
181
191
|
*
|
|
182
192
|
* This consumes the one-shot URI permission while it is still valid,
|
|
183
193
|
* preventing "permission denied" errors in the JS layer.
|
|
@@ -186,15 +196,11 @@ function addContentUriCopyJava(contents) {
|
|
|
186
196
|
if (intent == null) return;
|
|
187
197
|
try {
|
|
188
198
|
String action = intent.getAction();
|
|
199
|
+
// Only handle ACTION_VIEW here. ACTION_SEND is handled by
|
|
200
|
+
// expo-share-intent (or similar) which needs the original content:// URI.
|
|
189
201
|
Uri uri = null;
|
|
190
202
|
if (Intent.ACTION_VIEW.equals(action)) {
|
|
191
203
|
uri = intent.getData();
|
|
192
|
-
} else if (Intent.ACTION_SEND.equals(action)) {
|
|
193
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
194
|
-
uri = intent.getParcelableExtra(Intent.EXTRA_STREAM, Uri.class);
|
|
195
|
-
} else {
|
|
196
|
-
uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
|
197
|
-
}
|
|
198
204
|
}
|
|
199
205
|
|
|
200
206
|
if (uri == null || !"content".equals(uri.getScheme())) return;
|
|
@@ -231,10 +237,9 @@ function addContentUriCopyJava(contents) {
|
|
|
231
237
|
Log.i("MainActivity", "Copied content URI to: " + destFile.getAbsolutePath());
|
|
232
238
|
|
|
233
239
|
Uri fileUri = Uri.fromFile(destFile);
|
|
240
|
+
// Only ACTION_VIEW is rewritten; ACTION_SEND is left for other modules.
|
|
234
241
|
if (Intent.ACTION_VIEW.equals(action)) {
|
|
235
242
|
intent.setData(fileUri);
|
|
236
|
-
} else if (Intent.ACTION_SEND.equals(action)) {
|
|
237
|
-
intent.putExtra(Intent.EXTRA_STREAM, fileUri);
|
|
238
243
|
}
|
|
239
244
|
} catch (Exception e) {
|
|
240
245
|
Log.w("MainActivity", "Failed to copy content URI: " + e.getMessage());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withContentUriCopy.js","sourceRoot":"","sources":["../src/withContentUriCopy.ts"],"names":[],"mappings":";;AAAA,yDAI8B;AAE9B;;;;;;;;;;GAUG;AACH,MAAM,kBAAkB,GAAiB,CAAC,MAAM,EAAE,EAAE;IAClD,OAAO,IAAA,iCAAgB,EAAC,MAAM,EAAE,CAAC,MAAM,EAA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