From 8069d99a5daeb0b0587ac89dd41cad963ff219d7 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Tue, 12 Sep 2023 18:33:01 +0800 Subject: [PATCH] chore: try build for f-droid https://github.com/Alovoa/alovoa-expo/issues/14 --- .github/workflows/build-apk.yml | 11 +++++++---- .gitmodules | 6 ++++++ libs/expo-application | 1 + libs/expo-location | 1 + scripts/fit-f-droid.mjs | 4 ++++ src/services/NativeService/index.ts | 4 +--- 6 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 .gitmodules create mode 160000 libs/expo-application create mode 160000 libs/expo-location create mode 100644 scripts/fit-f-droid.mjs diff --git a/.github/workflows/build-apk.yml b/.github/workflows/build-apk.yml index 1771a3f..f022fba 100644 --- a/.github/workflows/build-apk.yml +++ b/.github/workflows/build-apk.yml @@ -42,26 +42,29 @@ jobs: with: distribution: 'zulu' # See 'Supported distributions' for available options java-version: '11' - - name: Setup Gradle + - name: Setup Gradle # fix `incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.` uses: gradle/gradle-build-action@v2 with: - gradle-version: 8.0.1 + gradle-version: 8.0.1 # use the gradle version I saw on eas build's console, which might match the kotlin version? - name: Install dependencies run: pnpm install + - name: remove prorietary bits (for f-droid) + run: npx zx scripts/fit-f-droid.mjs + ## configure cash for gradle : will help to reduce build time - name: Cache Gradle Wrapper uses: actions/cache@v2 with: path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} + key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('android/gradle/wrapper/gradle-wrapper.properties') }} - name: Cache Gradle Dependencies uses: actions/cache@v2 with: path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-caches-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} + key: ${{ runner.os }}-gradle-caches-${{ hashFiles('android/gradle/wrapper/gradle-wrapper.properties') }} restore-keys: | ${{ runner.os }}-gradle-caches- diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5016947 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "libs/expo-location"] + path = libs/expo-location + url = https://github.com/Nonononoki/expo-location +[submodule "libs/expo-application"] + path = libs/expo-application + url = https://github.com/Nonononoki/expo-application diff --git a/libs/expo-application b/libs/expo-application new file mode 160000 index 0000000..9388d3e --- /dev/null +++ b/libs/expo-application @@ -0,0 +1 @@ +Subproject commit 9388d3e0ef639741f6f4555a1ef8d7955788d74b diff --git a/libs/expo-location b/libs/expo-location new file mode 160000 index 0000000..18ddc37 --- /dev/null +++ b/libs/expo-location @@ -0,0 +1 @@ +Subproject commit 18ddc374f738e16b90e6412b903c331b93538e5d diff --git a/scripts/fit-f-droid.mjs b/scripts/fit-f-droid.mjs new file mode 100644 index 0000000..b23e1f1 --- /dev/null +++ b/scripts/fit-f-droid.mjs @@ -0,0 +1,4 @@ +import fs from 'fs-extra'; + +await Promise.all([fs.unlink('node_modules/expo-location'), fs.unlink('node_modules/expo-application')]); +await Promise.all([fs.copy('libs/expo-location', 'node_modules/expo-location'), fs.copy('libs/expo-application', 'node_modules/expo-application')]); diff --git a/src/services/NativeService/index.ts b/src/services/NativeService/index.ts index 49a7c48..ba4d467 100644 --- a/src/services/NativeService/index.ts +++ b/src/services/NativeService/index.ts @@ -26,9 +26,7 @@ export class NativeService { // this usually last for a very long time. So we use a timeout to prevent it from blocking the app const locationPromise = (async () => { - const location = (await Location.getLastKnownPositionAsync()) ?? await Location.getCurrentPositionAsync({ - accuracy: Location.Accuracy.Lowest, - }); + const location = await Location.getCurrentPositionAsync({ accuracy: Location.Accuracy.Lowest }); return location.coords; })();