IGNF / cartes-ign-app

Application mobile officielle de l'IGN, utilisant MapLibre GL JS et Capacitor
https://www.ign.fr/telechargez-application-cartographique-cartes-ign
GNU General Public License v3.0
55 stars 2 forks source link

feat(android): foss compliant build for F-Droid #87

Closed azarz closed 4 months ago

azarz commented 4 months ago

Add a fdroid flavor for builds that does not depend on Google services.

licaon-kter commented 4 months ago

...but it should not depend at build time either

this recipe metadata/fr.ign.geoportail.yml

License: GPLv3
SourceCode: https://github.com/IGNF/cartes-ign-app
IssueTracker: https://github.com/IGNF/cartes-ign-app/issues

AutoName: geoportail-app
Description: Application Géoportail

RepoType: git
Repo: https://github.com/IGNF/cartes-ign-app

Builds:
  - versionName: 3.1.0
    versionCode: 30100
    commit: 5a3ebbf4bea3aa7e678a2917e241919d0042a3e4
    subdir: android/app
    sudo:
      - sysctl fs.inotify.max_user_watches=524288 || true
      - apt-get update
      - apt-get install -y make npm
    gradle:
      - fdroid
    rm:
      - android/app/build_google.gradle
    prebuild:
      - sed -i -e '/gms/d' ../build.gradle
      - cd ../..
      - npm install --build-from-source
      - npm run build
      - npx cap sync
      - sed -i -e '/gms/d' node_modules/@capacitor/geolocation/android/build.gradle
    scandelete:
      - node_modules

AutoUpdateMode: None
UpdateCheckMode: Tags

will fail... kinda as expected, right? As I'm removing all the proprietary bits before building...

> Task :capacitor-geolocation:compileReleaseJavaWithJavac FAILED
/home/vagrant/build/fr.ign.geoportail/node_modules/@capacitor/geolocation/android/src/main/java/com/capacitorjs/plugins/geolocation/Geolocation.java:8: error: package com.google.android.gms.common does not exist
import com.google.android.gms.common.ConnectionResult;
,,,

...yet @capacitor/geolocation still depends on them

azarz commented 4 months ago

Is it possible in the prebuild section of the recipe to remove the line

 "@capacitor/geolocation": "^6.0.0",

from the package.json file, before the npm install command? The app will still work, the only featur that will be lacking will be the user prompt to activate GPS when activating Geolocation in the App.

I would like to test the resulting app from such a recipe, how can I manage to do that? This way I could tweak it and propose a final result to you. As the app name and description are outdated, I could also change them.

licaon-kter commented 4 months ago

@azarz that's like a hardcoded dep https://github.com/IGNF/cartes-ign-app/blob/5a3ebbf4bea3aa7e678a2917e241919d0042a3e4/src/js/services/location.js#L13 so will fail to build

azarz commented 4 months ago

I have made the import conditional: https://github.com/IGNF/cartes-ign-app/blob/7a4bf9b445048af952f30a36a2ec0401c6423568/src/js/services/location.js#L14-L42

Now if the dependency is not in the package.json, the build does not fail.

On another note, the app name has changed, here is a suggestion for the display name and description:

License: GPLv3
SourceCode: https://github.com/IGNF/cartes-ign-app
IssueTracker: https://github.com/IGNF/cartes-ign-app/issues

# if AutoName is a display name
AutoName: Cartes IGN
Description: Découvrez la France autrement et observez l’évolution du territoire
licaon-kter commented 4 months ago

autoname comes from your code: https://github.com/IGNF/cartes-ign-app/blob/develop/android/app/src/main/res/values/strings.xml#L3

description/changelogs/icon/screenshots you'll add in a Fastlane folder structure: https://gitlab.com/-/snippets/1895688

here's a test APK: fr.ign.geoportail_30100.apk.ZIP (remove the .ZIP from name)

built from this recipe:

  - versionName: 3.1.0+foss
    versionCode: 30100
    commit: 847580597dcba31d50a17eecfbfe9c815d517a14
    subdir: android/app
    sudo:
      - sysctl fs.inotify.max_user_watches=524288 || true
      - apt-get update
      - apt-get install -y make npm
    gradle:
      - fdroid
    rm:
      - android/app/build_google.gradle
    prebuild:
      - sed -i -e '/gms/d' ../build.gradle
      - sed -i -e '/geolocation/d' ../../package.json
      - cd ../..
      - npm install --build-from-source
      - npm run build
      - npx cap sync
    scandelete:
      - node_modules
azarz commented 4 months ago

I have added the fastlane directory, and tested the app you provided: it seems to work!

What is the next step?

licaon-kter commented 4 months ago

I have added the fastlane directory

right, but why add the French texts and pics in the en-US folder?

Move them to fr-FR :smile:

Is the app in French only? Even so, you should add at least summary and some info in full description .txt in English in en-US that explains this, so users that don't have French locale don't end up with a blank details screen.

licaon-kter commented 4 months ago

What is the next step?

merge this PR, tag a new release

azarz commented 4 months ago

I have added the fastlane directory

right, but why add the French texts and pics in the en-US folder?

Move them to fr-FR 😄

Is the app in French only? Even so, you should add at least summary and some info in full description .txt in English in en-US that explains this, so users that don't have French locale don't end up with a blank details screen.

I did it because as you guessed, the app is french only, and apparently FDroid requires the en-US folder. I will do as you advised and merge the PR. I'll let you know when I have tagged a release.

licaon-kter commented 4 months ago

Regarding the pics, keep en-US/images/icon.png but the rest can go away from en-US, as they live in fr-FR