diff --git a/packages/react-native-blob-util/CHANGELOG.md b/packages/react-native-blob-util/CHANGELOG.md index ed4a39d8..7c082acb 100644 --- a/packages/react-native-blob-util/CHANGELOG.md +++ b/packages/react-native-blob-util/CHANGELOG.md @@ -1,3 +1,10 @@ +### @config-plugins/react-native-blob-util [1.0.3](https://github.com/expo/config-plugins/compare/@config-plugins/react-native-blob-util@1.0.2...@config-plugins/react-native-blob-util@1.0.3) (2022-03-22) + + +### Other chores + +* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904)) + ### @config-plugins/react-native-blob-util [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/react-native-blob-util@1.0.1...@config-plugins/react-native-blob-util@1.0.2) (2022-03-16) diff --git a/packages/react-native-blob-util/build/withReactNativeBlobUtil.d.ts b/packages/react-native-blob-util/build/withReactNativeBlobUtil.d.ts new file mode 100644 index 00000000..4275331a --- /dev/null +++ b/packages/react-native-blob-util/build/withReactNativeBlobUtil.d.ts @@ -0,0 +1,4 @@ +import { AndroidConfig, ConfigPlugin } from "@expo/config-plugins"; +export declare function appendDownloadCompleteAction(androidManifest: AndroidConfig.Manifest.AndroidManifest): AndroidConfig.Manifest.AndroidManifest; +declare const _default: ConfigPlugin; +export default _default; diff --git a/packages/react-native-blob-util/build/withReactNativeBlobUtil.js b/packages/react-native-blob-util/build/withReactNativeBlobUtil.js new file mode 100644 index 00000000..0add60ca --- /dev/null +++ b/packages/react-native-blob-util/build/withReactNativeBlobUtil.js @@ -0,0 +1,59 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.appendDownloadCompleteAction = void 0; +const config_plugins_1 = require("@expo/config-plugins"); +let pkg = { + name: "react-native-blob-util", +}; +try { + pkg = require("react-native-blob-util/package.json"); +} +catch (_a) { + // empty catch block +} +function appendDownloadCompleteAction(androidManifest) { + var _a, _b; + if (!Array.isArray(androidManifest.manifest.application)) { + return androidManifest; + } + for (const application of androidManifest.manifest.application) { + for (const activity of application.activity || []) { + if (((_a = activity === null || activity === void 0 ? void 0 : activity.$) === null || _a === void 0 ? void 0 : _a["android:launchMode"]) === "singleTask") { + for (const intentFilter of activity["intent-filter"] || []) { + const isLauncher = (_b = intentFilter.category) === null || _b === void 0 ? void 0 : _b.some((action) => action.$["android:name"] === "android.intent.category.LAUNCHER"); + if (!isLauncher) + continue; + intentFilter.action = intentFilter.action || []; + const hasDownloadCompleteAction = intentFilter.action.some((action) => action.$["android:name"] === + "android.intent.action.DOWNLOAD_COMPLETE"); + if (!hasDownloadCompleteAction) { + intentFilter.action.push({ + $: { + "android:name": "android.intent.action.DOWNLOAD_COMPLETE", + }, + }); + return androidManifest; + } + } + break; + } + } + } + return androidManifest; +} +exports.appendDownloadCompleteAction = appendDownloadCompleteAction; +const withReactNativeBlobUtil = (config) => { + config = config_plugins_1.AndroidConfig.Permissions.withPermissions(config, [ + "android.permission.READ_EXTERNAL_STORAGE", + "android.permission.WRITE_EXTERNAL_STORAGE", + "android.permission.DOWNLOAD_WITHOUT_NOTIFICATION", + // Wifi-only mode. + "android.permission.ACCESS_NETWORK_STATE", + ]); + config = config_plugins_1.withAndroidManifest(config, (config) => { + config.modResults = appendDownloadCompleteAction(config.modResults); + return config; + }); + return config; +}; +exports.default = config_plugins_1.createRunOncePlugin(withReactNativeBlobUtil, pkg.name, pkg.version); diff --git a/packages/react-native-blob-util/package.json b/packages/react-native-blob-util/package.json index 78a763df..847cb261 100644 --- a/packages/react-native-blob-util/package.json +++ b/packages/react-native-blob-util/package.json @@ -1,6 +1,6 @@ { "name": "@config-plugins/react-native-blob-util", - "version": "1.0.2", + "version": "1.0.3", "description": "Config plugin to auto configure react-native-blob-util on prebuild", "main": "build/withReactNativeBlobUtil.js", "types": "build/withReactNativeBlobUtil.d.ts",