From 48b75344d89d6af5ce84a1ce09520d6902d28089 Mon Sep 17 00:00:00 2001 From: Gregor MacLennan Date: Wed, 28 Feb 2024 14:48:13 +0000 Subject: [PATCH 1/4] fix: location of observation should not change from GPS when editing (#1145) Fixes #1144 --- src/frontend/sharedComponents/LocationField.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/frontend/sharedComponents/LocationField.js b/src/frontend/sharedComponents/LocationField.js index c1df35c3b..27967ddad 100644 --- a/src/frontend/sharedComponents/LocationField.js +++ b/src/frontend/sharedComponents/LocationField.js @@ -22,12 +22,12 @@ type Props = { * It needs a function as children, which will be called with the current * longitude, latitude and accuracy of the location on the observation */ -const LocationField = ({ children }: Props) => { +const LocationField = ({ children, locked }: Props) => { const [{ value }, { updateDraft }] = useDraftObservation(); const location = React.useContext(LocationContext); React.useEffect(() => { - if (!location.position || !value) return; + if (locked || !location.position || !value) return; const draftHasManualLocation = value.metadata && value.metadata.manualLocation; const draftHasLocation = @@ -48,7 +48,7 @@ const LocationField = ({ children }: Props) => { location: omit(location, "savedPosition"), }, }); - }, [location, updateDraft, value]); + }, [location, updateDraft, value, locked]); if (!value) return null; From eb7c5314ffe3c94a151bef919abecf063dd227ef Mon Sep 17 00:00:00 2001 From: Andrew Chou Date: Wed, 13 Mar 2024 16:22:22 -0400 Subject: [PATCH 2/4] fix: adjust mapbox access token usage (#1150) Co-authored-by: ErikSin <67773827+ErikSin@users.noreply.github.com> --- .cirrus.yml | 2 ++ .env.example | 2 ++ CONTRIBUTING.md | 25 +++++++++----------- __mocks__/react-native-config.js | 3 +++ android/app/build.gradle | 7 ++++++ bitrise.yml | 6 +++++ package-lock.json | 5 ++++ package.json | 1 + src/config.json | 3 --- src/frontend/hooks/useMapAvailability.ts | 4 ++-- src/frontend/lib/config.ts | 5 ++++ src/frontend/sharedComponents/Map/MapView.js | 5 ++-- 12 files changed, 46 insertions(+), 22 deletions(-) create mode 100644 .env.example create mode 100644 __mocks__/react-native-config.js delete mode 100644 src/config.json create mode 100644 src/frontend/lib/config.ts diff --git a/.cirrus.yml b/.cirrus.yml index 08f254798..4721346ff 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -14,6 +14,7 @@ task: -Dkotlin.compiler.execution.strategy=in-process NODEJS_MOBILE_BUILD_NATIVE_MODULES: "0" MAPBOX_DOWNLOAD_TOKEN: ENCRYPTED[6c72ef68629d29a9a0d9aa396d1f55badda203ce2d2ce0e21c6f79d6714dc2966db4326efb73d0f6e2082cdf27943d34] + MAPBOX_ACCESS_TOKEN: ENCRYPTED[820fc045f961fadebee5d3b9ed6350b26e32ed296f4c0d595b7fc2b92a42f393612af52d07c14abf178f34e428e0cbb4] container: image: digidem/docker-android:2 cpu: 8 @@ -30,6 +31,7 @@ task: - npm ci build_backend_script: npm run build:backend build_translations_script: npm run build:translations + build_env_script: echo "MAPBOX_ACCESS_TOKEN=${MAPBOX_ACCESS_TOKEN}" >> .env nodejs_mobile_cache: folder: android/build/nodejs-native-assets fingerprint_script: diff --git a/.env.example b/.env.example new file mode 100644 index 000000000..4aad9b6db --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +MAPBOX_DOWNLOAD_TOKEN=sk.abc123 # Replace this with a Mapbox secret access token +MAPBOX_ACCESS_TOKEN=pk.abc123 # Replace this with a Mapbox public access token diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3abc7dcf9..3817ccbab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing -Thank you so much for taking the time to contribute to Mapeo development! Mapeo Mobile is a mobile app written in react-native that currently runs on Android. +Thank you so much for taking the time to contribute to Mapeo development! Mapeo Mobile is a mobile app written in react-native that currently runs on Android. After doing the [Initial Install](#initial-install), for most development you will need Android Studio and the Android SDK installed on your computer as outlined in the [Full App Development](#full-app-development) section. @@ -23,28 +23,23 @@ npm install ### Pre-requisites -In order to develop the full app you will need the Android Studio, Android SDK, React Native CLI, and other dependencies installed, as per [this guide](https://reactnative.dev/docs/0.66/environment-setup) following the instructions up to *Creating a new application*. +In order to develop the full app you will need the Android Studio, Android SDK, React Native CLI, and other dependencies installed, as per [this guide](https://reactnative.dev/docs/0.66/environment-setup) following the instructions up to _Creating a new application_. Once you have done so and have Android Studio open, you may need to open your app's `/android` folder in Android Studio, so that it detects, downloads and configures requirements that might be missing, such as the NDK and CMake to build the native code part of the project. However, the version of NDK to use with Mapeo Mobile needs to be specifically [21.4.7075529](https://developer.android.com/ndk/guides/). You can download this version (as well as CMake if necessary) in Android Studio by navigating to Tools -> SDK Manager -> SDK Tools. +You will also need to have a `.env` file at the project root that defines a couple of necessary environment variables related to Mapbox: `MAPBOX_DOWNLOAD_TOKEN` and `MAPBOX_ACCESS_TOKEN`. You can make a copy of the existing [`.env.example`](./.env.example) file (make sure it is called `.env`) and then replace the existing variables with your tokens. This requires creating a [Mapbox](https://mapbox.com) account. -Due to an [issue](https://github.com/rnmapbox/maps/issues/1572) with installing some Mapbox SDK Android deps, you will also have to complete additional steps before getting the app to build: +The `MAPBOX_DOWNLOAD_TOKEN` variable is necessary for installing components of Mapbox's native SDK for building the app (see this [issue](https://github.com/rnmapbox/maps/issues/1572) for more context). To set it up: 1. Refer to the [`Configure Credentials`](https://docs.mapbox.com/android/maps/guides/install/#configure-credentials) section and follow the instructions for creating a **secret access token**. This requires creating a [Mapbox](https://mapbox.com) account. -2. With the secret token, you'll need to define the `MAPBOX_DOWNLOAD_TOKEN` environment variable. Although not ideal, there are a couple of options to choose from: +2. With the secret token, update your `.env` file so that it has line similar to the following: `MAPBOX_DOWNLOAD_TOKEN=` -- Specify the environment variable when running the `react-native run-android` command (or any command that runs it). For example: +The `MAPBOX_ACCESS_TOKEN` variable is necessary for using the Mapbox client library to render maps in the app. To set it up: - ```sh - MAPBOX_DOWNLOAD_TOKEN=your_token_here npm run android - ``` +1. Follow the instructions listed [here](https://docs.mapbox.com/help/getting-started/access-tokens/) to create a public access token. -- Create a `.env` file in your Mapeo Mobile directory and paste the following in there with your Mapbox access token. This will be utilized when building Mapeo Mobile. - - ```sh - MAPBOX_DOWNLOAD_TOKEN=your_token_here - ``` +2. With the public access token, update your `.env` file so that it has a line similar to the following: `MAPBOX_ACCESS_TOKEN=` We recognize that this extra configuration is not ideal and we intend for this to be temporary. @@ -81,7 +76,8 @@ dev version of the app on your device: npm run android ``` -This process may take a while when you are first building the app. Additionally, to bypass unneeded latency when installing certain dependencies like TypeScript, you can add the following to your `.gitconfig` file in your home directory (`~`): +This process may take a while when you are first building the app. Additionally, to bypass unneeded latency when installing certain dependencies like TypeScript, you can add the following to your `.gitconfig` file in your home directory (`~`): + ```sh [url "https://"] insteadOf = git:// @@ -172,6 +168,7 @@ npm run storybook-native You will probably need to reload the storybook mobile app for the web app to be able to control the mobile app. + ## Release Variants We generate different variants of the app, each with a different Application ID, diff --git a/__mocks__/react-native-config.js b/__mocks__/react-native-config.js new file mode 100644 index 000000000..e6f6300c5 --- /dev/null +++ b/__mocks__/react-native-config.js @@ -0,0 +1,3 @@ +export default { + MAPBOX_ACCESS_TOKEN: "pk.abc123", +}; diff --git a/android/app/build.gradle b/android/app/build.gradle index 35464de38..124912195 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -108,6 +108,9 @@ apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" // Add bugsnag plugin for source map and symbol uploads apply plugin: 'com.bugsnag.android.gradle' +// React Native Config +apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" + /** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices @@ -227,7 +230,11 @@ android { // Bugsnag integration manifestPlaceholders = [bugsnagReleaseStage: getDefaultBugsnagReleaseStage(myVersionName)] + + // React Native Config + resValue "string", "build_config_package", "com.mapeo" } + splits { abi { reset() diff --git a/bitrise.yml b/bitrise.yml index 28ac9966e..262eb4e53 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -281,6 +281,12 @@ workflows: inputs: - destination: $PROJECT_LOCATION/app/mapeo-release-key.keystore - source: $BITRISEIO_ANDROID_KEYSTORE_URL + - script@1.2.0: + title: Create .env file + inputs: + - content: | + #!/bin/bash + echo "MAPBOX_ACCESS_TOKEN=$MAPBOX_ACCESS_TOKEN" >> .env - script@1.2.0: title: Update SDK components inputs: diff --git a/package-lock.json b/package-lock.json index 92247a0d8..d9373f3fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39181,6 +39181,11 @@ "nullthrows": "^1.1.1" } }, + "react-native-config": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/react-native-config/-/react-native-config-1.5.1.tgz", + "integrity": "sha512-g1xNgt1tV95FCX+iWz6YJonxXkQX0GdD3fB8xQtR1GUBEqweB9zMROW77gi2TygmYmUkBI7LU4pES+zcTyK4HA==" + }, "react-native-confirmation-code-field": { "version": "7.3.0", "resolved": "https://registry.npmjs.org/react-native-confirmation-code-field/-/react-native-confirmation-code-field-7.3.0.tgz", diff --git a/package.json b/package.json index 36ec3b4c1..9d2032f8b 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,7 @@ "react-intl": "^5.4.5", "react-native": "^0.66.5", "react-native-android-open-settings": "^1.3.0", + "react-native-config": "^1.5.1", "react-native-confirmation-code-field": "^7.3.0", "react-native-device-info": "^8.4.8", "react-native-fetch-api": "^3.0.0", diff --git a/src/config.json b/src/config.json deleted file mode 100644 index 7afaaf204..000000000 --- a/src/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "mapboxAccessToken": "pk.eyJ1IjoiZ21hY2xlbm5hbiIsImEiOiJSaWVtd2lRIn0.ASYMZE2HhwkAw4Vt7SavEg" -} diff --git a/src/frontend/hooks/useMapAvailability.ts b/src/frontend/hooks/useMapAvailability.ts index 5d33cafb2..7ada67f0a 100644 --- a/src/frontend/hooks/useMapAvailability.ts +++ b/src/frontend/hooks/useMapAvailability.ts @@ -4,12 +4,12 @@ import MapboxGL from "@react-native-mapbox-gl/maps"; import api from "../api"; import { normalizeStyleURL } from "../lib/mapbox"; -import config from "../../config.json"; +import { config } from "../lib/config"; /** URL used for map style when no custom map and user is online */ export const onlineStyleURL = normalizeStyleURL( MapboxGL.StyleURL.Outdoors + "?" + Date.now(), - config.mapboxAccessToken + config.MAPBOX_ACCESS_TOKEN ); export type MapAvailability = "unknown" | "available" | "unavailable"; diff --git a/src/frontend/lib/config.ts b/src/frontend/lib/config.ts new file mode 100644 index 000000000..7dbf800fd --- /dev/null +++ b/src/frontend/lib/config.ts @@ -0,0 +1,5 @@ +import Config from "react-native-config"; + +export const config = { + MAPBOX_ACCESS_TOKEN: Config.MAPBOX_ACCESS_TOKEN, +}; diff --git a/src/frontend/sharedComponents/Map/MapView.js b/src/frontend/sharedComponents/Map/MapView.js index b89818aaa..f636231b5 100644 --- a/src/frontend/sharedComponents/Map/MapView.js +++ b/src/frontend/sharedComponents/Map/MapView.js @@ -5,7 +5,6 @@ import MapboxGL, { Logger } from "@react-native-mapbox-gl/maps"; import ScaleBar from "react-native-scale-bar"; import CheapRuler from "cheap-ruler"; import validateColor from "validate-color"; - import ConfigContext from "../../context/ConfigContext"; import { LocationFollowingIcon, LocationNoFollowIcon } from "../icons"; import IconButton from "../IconButton"; @@ -13,7 +12,7 @@ import type { LocationContextType } from "../../context/LocationContext"; import type { ObservationsMap } from "../../context/ObservationsContext"; import { useIsFullyFocused } from "../../hooks/useIsFullyFocused"; import bugsnag from "../../lib/logger"; -import config from "../../../config.json"; +import { config } from "../../lib/config"; import { OfflineMapLayers } from "../OfflineMapLayers"; import { UserLocation } from "./UserLocation"; @@ -38,7 +37,7 @@ Logger.setLogCallback(log => { ); }); -MapboxGL.setAccessToken(config.mapboxAccessToken); +MapboxGL.setAccessToken(config.MAPBOX_ACCESS_TOKEN); // Forces Mapbox to always be in connected state, rather than reading system // connectivity state MapboxGL.setConnected(true); From 6bab3a1f4db9030f6504ffabac40c618705899e4 Mon Sep 17 00:00:00 2001 From: Digidem Bot <68966934+digidem-bot@users.noreply.github.com> Date: Mon, 11 Mar 2024 19:32:50 +0900 Subject: [PATCH 3/4] New translations en.json (Are are) --- messages/alu.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 messages/alu.json diff --git a/messages/alu.json b/messages/alu.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/messages/alu.json @@ -0,0 +1 @@ +{} From 3462c0baa1ea8ab175c0836a3052a3a7b2276644 Mon Sep 17 00:00:00 2001 From: ErikSin <67773827+ErikSin@users.noreply.github.com> Date: Wed, 13 Mar 2024 15:15:34 -0700 Subject: [PATCH 4/4] chore(release): Prepare release 5.6.8 --- CHANGELOG.md | 7 +++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 778e347a5..b888a47d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [5.6.8](https://github.com/digidem/mapeo-mobile/compare/v5.6.7...v5.6.8) (2024-03-13) + +### Bug Fixes + +- adjust mapbox access token usage ([#1150](https://github.com/digidem/mapeo-mobile/issues/1150)) ([eb7c531](https://github.com/digidem/mapeo-mobile/commit/eb7c5314ffe3c94a151bef919abecf063dd227ef)) +- location of observation should not change from GPS when editing ([#1145](https://github.com/digidem/mapeo-mobile/issues/1145)) ([48b7534](https://github.com/digidem/mapeo-mobile/commit/48b75344d89d6af5ce84a1ce09520d6902d28089)), closes [#1144](https://github.com/digidem/mapeo-mobile/issues/1144) + ### [5.6.7](https://github.com/digidem/mapeo-mobile/compare/v5.6.8...v5.6.7) (2023-10-30) ### [5.6.6](https://github.com/digidem/mapeo-mobile/compare/v5.6.5...v5.6.6) (2023-10-24) diff --git a/package-lock.json b/package-lock.json index d9373f3fa..13c5f0cd7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mapeo-mobile", - "version": "5.6.7", + "version": "5.6.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9d2032f8b..632ae7fd3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mapeo-mobile", - "version": "5.6.7", + "version": "5.6.8", "private": true, "engines": { "node": "12.16.3"