diff --git a/app.json b/app.json index 8a0f4f54..d0023760 100644 --- a/app.json +++ b/app.json @@ -111,7 +111,8 @@ { "android": { "parentTheme": "Material3" } } ], ["react-native-bottom-tabs"], - ["./plugins/withChangeNativeAndroidTextToWhite.js"] + ["./plugins/withChangeNativeAndroidTextToWhite.js"], + ["./plugins/withGoogleCastActivity.js"] ], "experiments": { "typedRoutes": true diff --git a/plugins/withGoogleCastActivity.js b/plugins/withGoogleCastActivity.js new file mode 100644 index 00000000..1a8c0a30 --- /dev/null +++ b/plugins/withGoogleCastActivity.js @@ -0,0 +1,34 @@ +const { withAndroidManifest } = require("@expo/config-plugins"); + +const withGoogleCastActivity = (config) => + withAndroidManifest(config, async (config) => { + const mainApplication = config.modResults.manifest.application[0]; + + // Initialize activity array if it doesn't exist + if (!mainApplication.activity) { + mainApplication.activity = []; + } + + // Check if the activity already exists + const activityExists = mainApplication.activity.some( + (activity) => + activity.$?.["android:name"] === + "com.reactnative.googlecast.RNGCExpandedControllerActivity" + ); + + // Only add the activity if it doesn't already exist + if (!activityExists) { + mainApplication.activity.push({ + $: { + "android:name": + "com.reactnative.googlecast.RNGCExpandedControllerActivity", + "android:theme": "@style/Theme.MaterialComponents.NoActionBar", + "android:launchMode": "singleTask", + }, + }); + } + + return config; + }); + +module.exports = withGoogleCastActivity;