diff --git a/sdk-webview/src/main/java/com/xuqm/sdk/webview/XWebViewView.kt b/sdk-webview/src/main/java/com/xuqm/sdk/webview/XWebViewView.kt index 9ff1676..e63d677 100644 --- a/sdk-webview/src/main/java/com/xuqm/sdk/webview/XWebViewView.kt +++ b/sdk-webview/src/main/java/com/xuqm/sdk/webview/XWebViewView.kt @@ -45,6 +45,7 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver import androidx.core.content.ContextCompat import androidx.core.content.FileProvider +import android.provider.MediaStore import com.xuqm.sdk.file.FileDownloadDestination import com.xuqm.sdk.file.FileSDK import kotlinx.coroutines.Dispatchers @@ -89,6 +90,10 @@ internal fun resolvePickerMimeTypes(acceptTypes: Array): Array { // ACTION_GET_CONTENT contract supporting multiple MIME types via EXTRA_MIME_TYPES. internal class GetContentWithMimeTypes : ActivityResultContract, Uri?>() { override fun createIntent(context: Context, input: Array): Intent = + // Use ACTION_GET_CONTENT to preserve the familiar system file picker UI (bottom sheet + // with Documents/Images/Recent shortcuts). URI permission issues on vivo/OPPO are + // handled downstream by copyUriToWebViewCache(), which copies the file to a local + // cache path before passing it to WebView — so the intent type does not matter. Intent(Intent.ACTION_GET_CONTENT).apply { addCategory(Intent.CATEGORY_OPENABLE) if (input.size == 1) { @@ -272,14 +277,14 @@ internal fun storagePermissionsGranted(context: Context, acceptMimes: Array if (cursor.moveToFirst()) cursor.getString(0) else null } ?: runCatching { context.contentResolver.query( - uri, arrayOf(android.provider.MediaStore.MediaColumns.DATA), null, null, null + uri, arrayOf(MediaStore.MediaColumns.DATA), null, null, null )?.use { cursor -> if (cursor.moveToFirst()) cursor.getString(0)?.substringAfterLast('/') else null } @@ -298,7 +303,7 @@ internal fun copyUriToWebViewCache(context: Context, uri: Uri, mimeType: String? val bytesRead = context.contentResolver.openInputStream(uri)?.use { input -> dest.outputStream().use { out -> input.copyTo(out) } - } ?: return null // openInputStream returned null — URI unreadable + } ?: return null android.util.Log.d("XWV", "copyUriToWebViewCache: $uri → ${dest.name} ($bytesRead bytes)") Uri.fromFile(dest)