Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[config] android plugins #2849

Merged
merged 21 commits into from
Nov 10, 2020
Merged

[config] android plugins #2849

merged 21 commits into from
Nov 10, 2020

Conversation

EvanBacon
Copy link
Contributor

@EvanBacon EvanBacon commented Nov 3, 2020

Wrap all existing config methods in plugins and unify the file writing for common operations. A lot of complex functionality is wrapped in dangerous mods pending more investigation on how to make them safer. mods like "android.strings" currently don't account for any kind of localization but this could possibly be provided to the mod as a modRequest property.

Test Plan

  • Extended the iOS tests to account for Android.
    • added checks to ensure files are written in a valid format.

@EvanBacon EvanBacon added the Expo config Related to the app.json config for Expo projects label Nov 3, 2020
@EvanBacon EvanBacon marked this pull request as ready for review November 4, 2020 18:16
@EvanBacon EvanBacon mentioned this pull request Nov 9, 2020
packages/config/src/android/Orientation.ts Outdated Show resolved Hide resolved
packages/config/src/android/UserInterfaceStyle.ts Outdated Show resolved Hide resolved
packages/config/src/android/UserInterfaceStyle.ts Outdated Show resolved Hide resolved
packages/config/src/plugins/__tests__/expo-plugins-test.ts Outdated Show resolved Hide resolved
packages/config/src/plugins/__tests__/expo-plugins-test.ts Outdated Show resolved Hide resolved
@brentvatne
Copy link
Member

i took a stab at clarifying wording in a few places in 44a9391 - feel free to revert / correct anything that is factually incorrect or that you think i made worse

Copy link
Contributor

@bbarthec bbarthec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the direction it is going! 👍
So, my understanding is that we have built-in suport for modified limited set of files (AndroidManifest, two .gradle files and a bunch of files in res directory), but we also can modify arbitrary xml/java/kt file by using some dangerous technique? 🤔

Comment on lines +62 to +106
// project build.gradle
AndroidConfig.GoogleServices.withClassPath,

// app/build.gradle
AndroidConfig.GoogleServices.withApplyPlugin,
AndroidConfig.Package.withPackageGradle,
AndroidConfig.Version.withVersion,

// AndroidManifest.xml
AndroidConfig.Package.withPackageManifest,
AndroidConfig.AllowBackup.withAllowBackup,
AndroidConfig.Scheme.withScheme,
AndroidConfig.Orientation.withOrientation,
AndroidConfig.Permissions.withPermissions,
AndroidConfig.Branch.withBranch,
AndroidConfig.Facebook.withFacebookManifest,

AndroidConfig.UserInterfaceStyle.withUiModeManifest,
AndroidConfig.GoogleMobileAds.withGoogleMobileAdsConfig,
AndroidConfig.GoogleMapsApiKey.withGoogleMapsApiKey,
AndroidConfig.IntentFilters.withAndroidIntentFilters,
[AndroidConfig.Updates.withUpdates, { expoUsername }],

// MainActivity.*
AndroidConfig.UserInterfaceStyle.withUiModeMainActivity,

// strings.xml
AndroidConfig.Name.withName,
AndroidConfig.Facebook.withFacebookAppIdString,

// Dangerous -- these plugins run in reverse order.
AndroidConfig.GoogleServices.withGoogleServicesFile,

// Modify colors.xml and styles.xml
AndroidConfig.RootViewBackgroundColor.withRootViewBackgroundColor,
AndroidConfig.NavigationBar.withNavigationBar,
AndroidConfig.StatusBar.withStatusBar,
AndroidConfig.PrimaryColor.withPrimaryColor,

AndroidConfig.Icon.withIcons,
AndroidConfig.SplashScreen.withSplashScreen,

// If we renamed the package, we should also move it around and rename it in source files
// Added last to ensure this plugin runs first. Out of tree solutions will mistakenly resolve the package incorrectly otherwise.
AndroidConfig.Package.withPackageRefactor,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome 🤩

@EvanBacon EvanBacon merged commit a86d698 into master Nov 10, 2020
@EvanBacon EvanBacon deleted the @evanbacon/config/android-plugins branch November 10, 2020 14:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Expo config Related to the app.json config for Expo projects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants