-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Do not ship Mapeo for ICCAs assets with Mapeo (#447)
* feat: Create ICCAs build scripts & exclude ICCA screens from main build Use Metro build config to conditionally include ICCA screens so that ICCA resouces are not included in the main Mapeo build. This avoids the images used in the ICCAs intro screens increasing the file size of the main Mapeo APK. * feat: Ship apk variants with only the presets they need Choose the presets that are included in the apk at build time instead of runtime. This reduces the apk size and removes runtime code for conditionally running code based on app variant. * chore: Patch react-native so gradle tasks package ICCA variant Adds the app variant name as an environment variable in the gradle build script so that metro bundler can package JS files according to variant by using the `sourceExts` option.
- Loading branch information
1 parent
08fe2d6
commit c7df1fd
Showing
16 changed files
with
259 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">Mapeo for ICCAs</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">Mapeo ICCAs Dev</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
diff --git a/node_modules/nodejs-mobile-react-native/android/src/main/java/com/janeasystems/rn_nodejs_mobile/RNNodeJsMobileModule.java b/node_modules/nodejs-mobile-react-native/android/src/main/java/com/janeasystems/rn_nodejs_mobile/RNNodeJsMobileModule.java | ||
index e882a0c..02616d0 100644 | ||
--- a/node_modules/nodejs-mobile-react-native/android/src/main/java/com/janeasystems/rn_nodejs_mobile/RNNodeJsMobileModule.java | ||
+++ b/node_modules/nodejs-mobile-react-native/android/src/main/java/com/janeasystems/rn_nodejs_mobile/RNNodeJsMobileModule.java | ||
@@ -32,6 +32,7 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements | ||
private final ReactApplicationContext reactContext; | ||
private static final String TAG = "NODEJS-RN"; | ||
private static final String NODEJS_PROJECT_DIR = "nodejs-project"; | ||
+ private static final String NODEJS_ASSETS_DIR = "nodejs-assets"; | ||
private static final String NODEJS_BUILTIN_MODULES = "nodejs-builtin_modules"; | ||
private static final String TRASH_DIR = "nodejs-project-trash"; | ||
private static final String SHARED_PREFS = "NODEJS_MOBILE_PREFS"; | ||
@@ -42,6 +43,7 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements | ||
private static String trashDirPath; | ||
private static String filesDirPath; | ||
private static String nodeJsProjectPath; | ||
+ private static String nodeJsAssetsPath; | ||
private static String builtinModulesPath; | ||
private static String nativeAssetsPath; | ||
|
||
@@ -74,6 +76,7 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements | ||
|
||
// The paths where we expect the node project assets to be at runtime. | ||
nodeJsProjectPath = filesDirPath + "/" + NODEJS_PROJECT_DIR; | ||
+ nodeJsAssetsPath = filesDirPath + "/" + NODEJS_ASSETS_DIR; | ||
builtinModulesPath = filesDirPath + "/" + NODEJS_BUILTIN_MODULES; | ||
trashDirPath = filesDirPath + "/" + TRASH_DIR; | ||
nativeAssetsPath = BUILTIN_NATIVE_ASSETS_PREFIX + getCurrentABIName(); | ||
@@ -387,6 +390,9 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements | ||
// Copy the nodejs built-in modules to the application's data path. | ||
copyAssetFolder("builtin_modules", builtinModulesPath); | ||
|
||
+ // Copy nodejs assets (e.g. presets) which can vary between variants | ||
+ copyAssetFolder("nodejs-assets", nodeJsAssetsPath); | ||
+ | ||
saveLastUpdateTime(); | ||
Log.d(TAG, "Node assets copy completed successfully"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/node_modules/react-native/react.gradle b/node_modules/react-native/react.gradle | ||
index d886a9b..444c345 100644 | ||
--- a/node_modules/react-native/react.gradle | ||
+++ b/node_modules/react-native/react.gradle | ||
@@ -153,6 +153,8 @@ afterEvaluate { | ||
extraArgs.add(bundleConfig); | ||
} | ||
|
||
+ environment("APP_VARIANT", variant.name); | ||
+ | ||
commandLine(*execCommand, bundleCommand, "--platform", "android", "--dev", "${devEnabled}", | ||
"--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, | ||
"--sourcemap-output", enableHermes ? jsPackagerSourceMapFile : jsOutputSourceMapFile, *extraArgs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// @flow | ||
import AppStack from "./AppStack"; | ||
import IntroStack from "./screens/Intro"; | ||
import { createAppContainer, createSwitchNavigator } from "react-navigation"; | ||
|
||
const RootStack = createSwitchNavigator( | ||
{ | ||
Intro: IntroStack, | ||
App: AppStack, | ||
}, | ||
{ | ||
initialRouteName: "Intro", | ||
} | ||
); | ||
|
||
// $FlowFixMe | ||
export default createAppContainer(RootStack); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,119 +1,6 @@ | ||
// @flow | ||
import React from "react"; | ||
import { createAppContainer, createSwitchNavigator } from "react-navigation"; | ||
import { createBottomTabNavigator } from "react-navigation-tabs"; | ||
import { createStackNavigator } from "react-navigation-stack"; | ||
import MaterialIcons from "react-native-vector-icons/MaterialIcons"; | ||
import BuildConfig from "react-native-build-config"; | ||
|
||
import MapScreen from "./screens/MapScreen"; | ||
import CameraScreen from "./screens/CameraScreen"; | ||
import ObservationList from "./screens/ObservationsList"; | ||
import Observation from "./screens/Observation"; | ||
import ObservationEdit from "./screens/ObservationEdit"; | ||
import AddPhoto from "./screens/AddPhoto"; | ||
import ObservationDetails from "./screens/ObservationDetails"; | ||
import CategoryChooser from "./screens/CategoryChooser"; | ||
import GpsModal from "./screens/GpsModal"; | ||
import SyncModal from "./screens/SyncModal"; | ||
import Settings from "./screens/Settings"; | ||
import PhotosModal from "./screens/PhotosModal"; | ||
import ManualGpsScreen from "./screens/ManualGpsScreen"; | ||
import CustomHeaderLeft from "./sharedComponents/CustomHeaderLeft"; | ||
import ProjectConfig from "./screens/Settings/ProjectConfig"; | ||
import LanguageSettings from "./screens/Settings/LanguageSettings"; | ||
import IntroStack from "./screens/Intro"; | ||
import HomeHeader from "./sharedComponents/HomeHeader"; | ||
|
||
const HomeTabs = createBottomTabNavigator( | ||
{ | ||
Map: MapScreen, | ||
Camera: CameraScreen, | ||
}, | ||
// $FlowFixMe | ||
{ | ||
navigationOptions: () => ({ | ||
header: props => <HomeHeader {...props} />, | ||
headerTransparent: true, | ||
}), | ||
defaultNavigationOptions: ({ navigation }) => ({ | ||
initialRouteName: "Map", | ||
backBehavior: "initialRoute", | ||
tabBarOptions: { | ||
showLabel: false, | ||
}, | ||
tabBarIcon: ({ focused, horizontal, tintColor }) => { | ||
const { routeName } = navigation.state; | ||
let iconName; | ||
if (routeName === "Map") iconName = "map"; | ||
else iconName = "photo-camera"; | ||
return <MaterialIcons name={iconName} size={30} color={tintColor} />; | ||
}, | ||
}), | ||
} | ||
); | ||
|
||
const AppStack = createStackNavigator( | ||
// $FlowFixMe - flow definitions don't recognize static props on function components | ||
{ | ||
Home: HomeTabs, | ||
// $FlowFixMe | ||
GpsModal: GpsModal, | ||
// $FlowFixMe | ||
SyncModal: SyncModal, | ||
Settings: Settings, | ||
// $FlowFixMe | ||
ProjectConfig: ProjectConfig, | ||
// $FlowFixMe | ||
LanguageSettings, | ||
// $FlowFixMe | ||
PhotosModal: PhotosModal, | ||
// $FlowFixMe | ||
CategoryChooser: CategoryChooser, | ||
// $FlowFixMe | ||
AddPhoto: AddPhoto, | ||
// $FlowFixMe | ||
ObservationList: ObservationList, | ||
// $FlowFixMe | ||
Observation: Observation, | ||
// $FlowFixMe | ||
ObservationEdit: ObservationEdit, | ||
ManualGpsScreen: ManualGpsScreen, | ||
ObservationDetails: ObservationDetails, | ||
}, | ||
{ | ||
initialRouteName: "Home", | ||
// TODO iOS: Dynamically set transition mode to modal for modals | ||
mode: "card", | ||
headerMode: "screen", | ||
defaultNavigationOptions: { | ||
headerStyle: { | ||
height: 60, | ||
}, | ||
// We use a slightly larger back icon, to improve accessibility | ||
// TODO iOS: This should probably be a chevron not an arrow | ||
headerLeft: props => <CustomHeaderLeft {...props} />, | ||
headerTitleStyle: { | ||
marginHorizontal: 0, | ||
}, | ||
cardStyle: { | ||
backgroundColor: "#ffffff", | ||
}, | ||
}, | ||
} | ||
); | ||
|
||
const RootStack = createSwitchNavigator( | ||
{ | ||
Intro: IntroStack, | ||
App: AppStack, | ||
}, | ||
{ | ||
initialRouteName: "Intro", | ||
} | ||
); | ||
import AppStack from "./AppStack"; | ||
import { createAppContainer } from "react-navigation"; | ||
|
||
// $FlowFixMe | ||
export default createAppContainer( | ||
BuildConfig.FLAVOR === "icca" ? RootStack : AppStack | ||
); | ||
export default createAppContainer(AppStack); |
Oops, something went wrong.