Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Mobile: Capacitor 8 (Android 16, API 36) and a Google Play build

Duarte Santos469209753b1a
diff --git a/frontend/android/app/build.gradle b/frontend/android/app/build.gradle
index c1e8ceb01..e0551beed 100644
--- a/frontend/android/app/build.gradle
+++ b/frontend/android/app/build.gradle
@@ -1,8 +1,11 @@
apply plugin: 'com.android.application'
android {
- namespace "ch.duartesantos.opengym"
- compileSdk rootProject.ext.compileSdkVersion
+ namespace = "ch.duartesantos.opengym"
+ compileSdk = rootProject.ext.compileSdkVersion
+ buildFeatures {
+ buildConfig = true
+ }
defaultConfig {
applicationId "ch.duartesantos.opengym"
minSdkVersion rootProject.ext.minSdkVersion
@@ -13,7 +16,7 @@ android {
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
- ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
+ ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}
buildTypes {
@@ -35,6 +38,24 @@ android {
applicationIdSuffix ".test"
}
}
+ // Where the app is installed from. "sideload" is the APK on GitHub and opengym.ch: it checks
+ // GitHub for a newer release and installs it itself (InstallPlugin, REQUEST_INSTALL_PACKAGES).
+ // "play" is the Google Play build: Play installs the updates, so the updater, its permission
+ // and its plugin are left out (Play does not allow an app to update itself). Same
+ // applicationId and the same signing key, so a phone can move from one to the other without
+ // losing its data. The page asks which one it runs in (ChannelPlugin, lib/channel.js).
+ flavorDimensions = ["channel"]
+ productFlavors {
+ sideload {
+ dimension = "channel"
+ isDefault = true
+ buildConfigField "String", "CHANNEL", '"sideload"'
+ }
+ play {
+ dimension = "channel"
+ buildConfigField "String", "CHANNEL", '"play"'
+ }
+ }
}
repositories {
@@ -49,8 +70,7 @@ dependencies {
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
// Writing workouts and weigh-ins to Health Connect (#200, HealthConnectPlugin). Off until the
- // user turns it on. 1.1.0-alpha12 is the last release that builds with compileSdk 35 and AGP
- // 8.7; 1.1.0 stable asks for compileSdk 36 and AGP 8.9.1.
+ // user turns it on.
implementation "androidx.health.connect:connect-client:$healthConnectVersion"
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
diff --git a/frontend/android/app/src/main/AndroidManifest.xml b/frontend/android/app/src/main/AndroidManifest.xml
index ccee08949..aea946284 100644
--- a/frontend/android/app/src/main/AndroidManifest.xml
+++ b/frontend/android/app/src/main/AndroidManifest.xml
@@ -17,7 +17,7 @@
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/AppTheme">
<activity
- android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation"
+ android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation|density"
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
@@ -86,7 +86,6 @@
<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<!-- Workout-day reminder: lets the local-notifications plugin fire at the exact minute
on Android 12+. Where it isn't granted, scheduling silently falls back to inexact
alarms — the reminder still arrives, just not to the minute. -->
diff --git a/frontend/android/app/src/main/java/ch/duartesantos/opengym/SystemBarsPlugin.java b/frontend/android/app/src/main/java/ch/duartesantos/opengym/BarIconsPlugin.java
similarity index 91%
rename from frontend/android/app/src/main/java/ch/duartesantos/opengym/SystemBarsPlugin.java
rename to frontend/android/app/src/main/java/ch/duartesantos/opengym/BarIconsPlugin.java
index b42f71722..9c421220a 100644
--- a/frontend/android/app/src/main/java/ch/duartesantos/opengym/SystemBarsPlugin.java
+++ b/frontend/android/app/src/main/java/ch/duartesantos/opengym/BarIconsPlugin.java
@@ -19,10 +19,10 @@ import com.getcapacitor.annotation.CapacitorPlugin;
* own background and there is nothing to change.
*
* Usage from JS:
- * registerPlugin('SystemBars').setStyle({ light: true })
+ * registerPlugin('BarIcons').setStyle({ light: true })
*/
-@CapacitorPlugin(name = "SystemBars")
-public class SystemBarsPlugin extends Plugin {
+@CapacitorPlugin(name = "BarIcons")
+public class BarIconsPlugin extends Plugin {
@PluginMethod
public void setStyle(PluginCall call) {
diff --git a/frontend/android/app/src/main/java/ch/duartesantos/opengym/ChannelPlugin.java b/frontend/android/app/src/main/java/ch/duartesantos/opengym/ChannelPlugin.java
new file mode 100644
index 000000000..1ce16b19e
--- /dev/null
+++ b/frontend/android/app/src/main/java/ch/duartesantos/opengym/ChannelPlugin.java
@@ -0,0 +1,23 @@
+package ch.duartesantos.opengym;
+
+import com.getcapacitor.JSObject;
+import com.getcapacitor.Plugin;
+import com.getcapacitor.PluginCall;
+import com.getcapacitor.PluginMethod;
+import com.getcapacitor.annotation.CapacitorPlugin;
+
+/**
+ * Which build this is: "sideload" (the APK from GitHub and opengym.ch, which updates itself) or
+ * "play" (Google Play, which updates it). The page asks once (lib/channel.js) and shows the
+ * updater only in the first.
+ */
+@CapacitorPlugin(name = "Channel")
+public class ChannelPlugin extends Plugin {
+
+ @PluginMethod
+ public void get(PluginCall call) {
+ JSObject ret = new JSObject();
+ ret.put("channel", BuildConfig.CHANNEL);
+ call.resolve(ret);
+ }
+}
diff --git a/frontend/android/app/src/main/java/ch/duartesantos/opengym/MainActivity.java b/frontend/android/app/src/main/java/ch/duartesantos/opengym/MainActivity.java
index 8325be72c..babd6403a 100644
--- a/frontend/android/app/src/main/java/ch/duartesantos/opengym/MainActivity.java
+++ b/frontend/android/app/src/main/java/ch/duartesantos/opengym/MainActivity.java
@@ -21,15 +21,21 @@ public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
registerPlugin(HealthConnectPlugin.class);
- registerPlugin(InstallPlugin.class);
+ registerPlugin(ChannelPlugin.class);
+ FlavorPlugins.register(this);
registerPlugin(PrintPlugin.class);
registerPlugin(RestAlertPlugin.class);
registerPlugin(BackupFolderPlugin.class);
- registerPlugin(SystemBarsPlugin.class);
+ registerPlugin(BarIconsPlugin.class);
super.onCreate(savedInstanceState);
passSystemBarsToPage();
}
+ /** For FlavorPlugins: registerPlugin is protected in BridgeActivity. */
+ void registerFlavorPlugin(Class<? extends com.getcapacitor.Plugin> plugin) {
+ registerPlugin(plugin);
+ }
+
/**
* Android 15 draws an app that targets it edge to edge: the page runs under the status bar and
* under the navigation bar. The WebView reports only the camera cutout as
diff --git a/frontend/android/app/src/play/java/ch/duartesantos/opengym/FlavorPlugins.java b/frontend/android/app/src/play/java/ch/duartesantos/opengym/FlavorPlugins.java
new file mode 100644
index 000000000..80cc3acb8
--- /dev/null
+++ b/frontend/android/app/src/play/java/ch/duartesantos/opengym/FlavorPlugins.java
@@ -0,0 +1,8 @@
+package ch.duartesantos.opengym;
+
+/** Google Play installs the updates itself: no updater in this build. */
+final class FlavorPlugins {
+ private FlavorPlugins() {}
+
+ static void register(MainActivity activity) {}
+}
diff --git a/frontend/android/app/src/sideload/AndroidManifest.xml b/frontend/android/app/src/sideload/AndroidManifest.xml
new file mode 100644
index 000000000..3c8216bf3
--- /dev/null
+++ b/frontend/android/app/src/sideload/AndroidManifest.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- The in-app updater (InstallPlugin) hands the downloaded APK to the system installer.
+ Only in this build: Google Play updates the Play build itself. -->
+ <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
+</manifest>
diff --git a/frontend/android/app/src/sideload/java/ch/duartesantos/opengym/FlavorPlugins.java b/frontend/android/app/src/sideload/java/ch/duartesantos/opengym/FlavorPlugins.java
new file mode 100644
index 000000000..057b23330
--- /dev/null
+++ b/frontend/android/app/src/sideload/java/ch/duartesantos/opengym/FlavorPlugins.java
@@ -0,0 +1,11 @@
+package ch.duartesantos.opengym;
+
+
+/** The APK from GitHub and opengym.ch installs its own updates (InstallPlugin). */
+final class FlavorPlugins {
+ private FlavorPlugins() {}
+
+ static void register(MainActivity activity) {
+ activity.registerFlavorPlugin(InstallPlugin.class);
+ }
+}
diff --git a/frontend/android/app/src/main/java/ch/duartesantos/opengym/InstallPlugin.java b/frontend/android/app/src/sideload/java/ch/duartesantos/opengym/InstallPlugin.java
similarity index 100%
rename from frontend/android/app/src/main/java/ch/duartesantos/opengym/InstallPlugin.java
rename to frontend/android/app/src/sideload/java/ch/duartesantos/opengym/InstallPlugin.java
diff --git a/frontend/android/build.gradle b/frontend/android/build.gradle
index f1b3b0e51..eb191da81 100644
--- a/frontend/android/build.gradle
+++ b/frontend/android/build.gradle
@@ -7,8 +7,8 @@ buildscript {
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:8.7.2'
- classpath 'com.google.gms:google-services:4.4.2'
+ classpath 'com.android.tools.build:gradle:8.13.0'
+ classpath 'com.google.gms:google-services:4.4.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -25,5 +25,5 @@ allprojects {
}
task clean(type: Delete) {
- delete rootProject.buildDir
+ delete rootProject.layout.buildDirectory
}
diff --git a/frontend/android/gradle/wrapper/gradle-wrapper.properties b/frontend/android/gradle/wrapper/gradle-wrapper.properties
index c1d5e0185..7705927e9 100644
--- a/frontend/android/gradle/wrapper/gradle-wrapper.properties
+++ b/frontend/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
diff --git a/frontend/android/variables.gradle b/frontend/android/variables.gradle
index efaa2a2b0..a9983adeb 100644
--- a/frontend/android/variables.gradle
+++ b/frontend/android/variables.gradle
@@ -1,17 +1,17 @@
ext {
- minSdkVersion = 23
- compileSdkVersion = 35
- targetSdkVersion = 35
- androidxActivityVersion = '1.9.2'
- androidxAppCompatVersion = '1.7.0'
- androidxCoordinatorLayoutVersion = '1.2.0'
- androidxCoreVersion = '1.15.0'
- androidxFragmentVersion = '1.8.4'
- coreSplashScreenVersion = '1.0.1'
- androidxWebkitVersion = '1.12.1'
+ minSdkVersion = 24
+ compileSdkVersion = 36
+ targetSdkVersion = 36
+ androidxActivityVersion = '1.11.0'
+ androidxAppCompatVersion = '1.7.1'
+ androidxCoordinatorLayoutVersion = '1.3.0'
+ androidxCoreVersion = '1.17.0'
+ androidxFragmentVersion = '1.8.9'
+ coreSplashScreenVersion = '1.2.0'
+ androidxWebkitVersion = '1.14.0'
junitVersion = '4.13.2'
- androidxJunitVersion = '1.2.1'
- androidxEspressoCoreVersion = '3.6.1'
- cordovaAndroidVersion = '10.1.1'
- healthConnectVersion = '1.1.0-alpha12'
+ androidxJunitVersion = '1.3.0'
+ androidxEspressoCoreVersion = '3.7.0'
+ cordovaAndroidVersion = '14.0.1'
+ healthConnectVersion = '1.1.0'
}
\ No newline at end of file
diff --git a/frontend/capacitor.config.json b/frontend/capacitor.config.json
index b635dfa5f..f49280772 100644
--- a/frontend/capacitor.config.json
+++ b/frontend/capacitor.config.json
@@ -5,5 +5,10 @@
"backgroundColor": "#0c0e12",
"android": {
"allowMixedContent": true
+ },
+ "plugins": {
+ "SystemBars": {
+ "insetsHandling": "disable"
+ }
}
}
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index f7e570cda..9ccb186b6 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -9,13 +9,13 @@
"version": "1.4.1",
"license": "AGPL-3.0-or-later",
"dependencies": {
- "@aparajita/capacitor-secure-storage": "^7.1.6",
- "@capacitor-mlkit/barcode-scanning": "^7.5.0",
- "@capacitor/app": "^7.1.2",
- "@capacitor/core": "^7.6.8",
- "@capacitor/filesystem": "^7.1.8",
- "@capacitor/local-notifications": "^7.0.7",
- "@capacitor/share": "^7.0.4",
+ "@aparajita/capacitor-secure-storage": "^8.0.1",
+ "@capacitor-mlkit/barcode-scanning": "^8.2.1",
+ "@capacitor/app": "^8.0.0",
+ "@capacitor/core": "^8.5.3",
+ "@capacitor/filesystem": "^8.1.4",
+ "@capacitor/local-notifications": "^8.0.0",
+ "@capacitor/share": "^8.0.0",
"jsqr": "^1.4.0",
"lean-qr": "^2.7.3",
"react": "^19.2.7",
@@ -24,10 +24,10 @@
"zustand": "^5.0.14"
},
"devDependencies": {
- "@capacitor/android": "^7.6.8",
+ "@capacitor/android": "^8.5.3",
"@capacitor/assets": "^3.0.5",
- "@capacitor/cli": "^7.6.8",
- "@capacitor/ios": "^7.6.8",
+ "@capacitor/cli": "^8.5.3",
+ "@capacitor/ios": "^8.5.3",
"@vitejs/plugin-react": "^6.0.3",
"@vitest/coverage-v8": "^4.1.11",
"happy-dom": "^20.11.2",
@@ -37,14 +37,16 @@
}
},
"node_modules/@aparajita/capacitor-secure-storage": {
- "version": "7.1.6",
- "resolved": "https://registry.npmjs.org/@aparajita/capacitor-secure-storage/-/capacitor-secure-storage-7.1.6.tgz",
- "integrity": "sha512-KIfLOm/oSciUiWsOMtMv2nzlnwW3LERid0DvZ3djt7UORBQvFqpvSefiLG5kkc8D34pGkb2ZqAz0ZprrI9LiTQ==",
+ "version": "8.0.1",
+ "resolved": "https://registry.npmjs.org/@aparajita/capacitor-secure-storage/-/capacitor-secure-storage-8.0.1.tgz",
+ "integrity": "sha512-NSYIQtH6TyBgL3myumQGcCE3iecq2PtGNFlGxl1fJKEU37Dv5DudzDlwg42cgbVxCm1ay72g4X7rTSAvKULsVg==",
+ "license": "MIT",
"dependencies": {
- "@capacitor/android": "^7.4.4",
- "@capacitor/app": "^7.1.0",
- "@capacitor/core": "^7.4.4",
- "@capacitor/ios": "^7.4.4"
+ "@capacitor/android": "^8.0.2",
+ "@capacitor/app": "^8.0.0",
+ "@capacitor/core": "^8.0.2",
+ "@capacitor/ios": "^8.0.2",
+ "@capacitor/keyboard": "^8.0.0"
},
"engines": {
"node": ">=20.0.0"
@@ -110,9 +112,9 @@
}
},
"node_modules/@capacitor-mlkit/barcode-scanning": {
- "version": "7.5.0",
- "resolved": "https://registry.npmjs.org/@capacitor-mlkit/barcode-scanning/-/barcode-scanning-7.5.0.tgz",
- "integrity": "sha512-DBWRykYYLW0YMj/UzlQ0sVGn83mwGAJsbZVxFsd44pppEEy88OO04lxy9Esv5QpnNBIKPjSIqLWmSLuhoFGPaQ==",
+ "version": "8.2.1",
+ "resolved": "https://registry.npmjs.org/@capacitor-mlkit/barcode-scanning/-/barcode-scanning-8.2.1.tgz",
+ "integrity": "sha512-UdjIOK2dJwJ7c3Y+lRuRqIaP0VfHJeLvPNyE5kHrFU20MY++4uoAVm7JTWSklVVrjN4siIK/xmXL3QsYbthWSQ==",
"funding": [
{
"type": "github",
@@ -123,24 +125,27 @@
"url": "https://opencollective.com/capawesome"
}
],
+ "license": "Apache-2.0",
"peerDependencies": {
- "@capacitor/core": ">=7.0.0"
+ "@capacitor/core": ">=8.0.0"
}
},
"node_modules/@capacitor/android": {
- "version": "7.6.9",
- "resolved": "https://registry.npmjs.org/@capacitor/android/-/android-7.6.9.tgz",
- "integrity": "sha512-jvfU42aOuj92/KJqRscfDm+5612WzJainFL09xjJgD9oI3OMXN4PBfccn8Ig9i8x7bkVqZv/XNwFshiIRqmggg==",
+ "version": "8.5.3",
+ "resolved": "https://registry.npmjs.org/@capacitor/android/-/android-8.5.3.tgz",
+ "integrity": "sha512-ilH4gSSz3DrketMkzDVAvY9JsWJ//rCQnECLTdcFRO7xXDogwAbUvQAnIAbiqefwV/D1xfjEL4Gw1MJXEcaA9g==",
+ "license": "MIT",
"peerDependencies": {
- "@capacitor/core": "^7.6.0"
+ "@capacitor/core": "^8.5.0"
}
},
"node_modules/@capacitor/app": {
- "version": "7.1.2",
- "resolved": "https://registry.npmjs.org/@capacitor/app/-/app-7.1.2.tgz",
- "integrity": "sha512-d4I/oF/PRu4megL7/IGKYfe5j7yzSON1FRFgq6kH+m5kH6g7V+wyjHRLauCzGNjdRx4S+nWOumINds0qcRBtKg==",
+ "version": "8.1.2",
+ "resolved": "https://registry.npmjs.org/@capacitor/app/-/app-8.1.2.tgz",
+ "integrity": "sha512-uKBlsrXH0IdvUn69e/KKYbZ32A06pcrUdG8LWuZ/6y33YMXZXLEEdNSwl+jKS/SrsTWqnePs8EqSWaiQM3mUGA==",
+ "license": "MIT",
"peerDependencies": {
- "@capacitor/core": ">=7.0.0"
+ "@capacitor/core": ">=8.0.0"
}
},
"node_modules/@capacitor/assets": {
@@ -528,10 +533,11 @@
"dev": true
},
"node_modules/@capacitor/cli": {
- "version": "7.6.8",
- "resolved": "https://registry.npmjs.org/@capacitor/cli/-/cli-7.6.8.tgz",
- "integrity": "sha512-sJYLoSS1wVHjDPwRc0grtNZcQZnkQc7TJKoVZdHL2HI5TPCq+27WBrMAo0mXvQQSH2axPYCz5cyRrcqqakOvxQ==",
+ "version": "8.5.3",
+ "resolved": "https://registry.npmjs.org/@capacitor/cli/-/cli-8.5.3.tgz",
+ "integrity": "sha512-/G6xwna+p4GS3lthSdWN3OThCH2F85O0Ukdy8rv3oAXvgEMeyFgPEIA3PMAS++IkHwUuBYBAKOQJnZfcrh1n0w==",
"dev": true,
+ "license": "MIT",
"dependencies": {
"@ionic/cli-framework-output": "^2.2.8",
"@ionic/utils-subprocess": "^3.0.1",
@@ -549,6 +555,7 @@
"semver": "^7.6.3",
"tar": "^7.5.3",
"tslib": "^2.8.1",
+ "xcode": "^3.0.1",
"xml2js": "^0.6.2"
},
"bin": {
@@ -556,50 +563,64 @@
"capacitor": "bin/capacitor"
},
"engines": {
- "node": ">=20.0.0"
+ "node": ">=22.0.0"
}
},
"node_modules/@capacitor/core": {
- "version": "7.6.8",
- "resolved": "https://registry.npmjs.org/@capacitor/core/-/core-7.6.8.tgz",
- "integrity": "sha512-x1xfxvNcTSnj6OoYaAB0n0a0HRvi5f2YjcVnMLxpMhbHDgGDAzzN9z8cnPCYV+SKTvqGF1hezHm82Op32XaAGg==",
+ "version": "8.5.3",
+ "resolved": "https://registry.npmjs.org/@capacitor/core/-/core-8.5.3.tgz",
+ "integrity": "sha512-oBE1oGuYE4ZzYYrulC75OuHdSsD6zLUy7d5o1tFwDLG4govGoubY15cxpiI5l0+q87Lm5p0bhbehMdzJg4aFag==",
+ "license": "MIT",
"dependencies": {
"tslib": "^2.1.0"
}
},
"node_modules/@capacitor/filesystem": {
- "version": "7.1.8",
- "resolved": "https://registry.npmjs.org/@capacitor/filesystem/-/filesystem-7.1.8.tgz",
- "integrity": "sha512-Qpw/2SE4/CzqAUvGgSM9hw/uXQ5qoOaF4wxbToXwpAaKPS+tzletS1h5ti3jjLmGcqizTs2sEXMtcsARW/Ceew==",
+ "version": "8.1.4",
+ "resolved": "https://registry.npmjs.org/@capacitor/filesystem/-/filesystem-8.1.4.tgz",
+ "integrity": "sha512-8MXmt10cb+dGWoh8jUeO8on0U6iETQCX5k+fmdB278PZ3MYDEVGQo08+hroaOtUbK3+5stiRk4/K6QBHKepv0A==",
+ "license": "MIT",
"dependencies": {
- "@capacitor/synapse": "^1.0.3"
+ "@capacitor/synapse": "^1.0.4"
},
"peerDependencies": {
- "@capacitor/core": ">=7.0.0"
+ "@capacitor/core": ">=8.0.0"
}
},
"node_modules/@capacitor/ios": {
- "version": "7.6.9",
- "resolved": "https://registry.npmjs.org/@capacitor/ios/-/ios-7.6.9.tgz",
- "integrity": "sha512-LANP81TfwuJk1zq9EuF+J5AJK71rKDgXB5XD+VFJQHC7BxSH4Dsma6DSMyrjFT03jtqc/0JTMEfSMBE7go3ZjA==",
+ "version": "8.5.3",
+ "resolved": "https://registry.npmjs.org/@capacitor/ios/-/ios-8.5.3.tgz",
+ "integrity": "sha512-HnnV92Jl8+3x0JUloXUMjFcUsQI8wHFVsKwkLn72DfRZXYGZW11tQbmNOWOnRTljaU18FdI1b9ipT09SzzPDNw==",
+ "license": "MIT",
+ "peerDependencies": {
+ "@capacitor/core": "^8.5.0"
+ }
+ },
+ "node_modules/@capacitor/keyboard": {
+ "version": "8.0.6",
+ "resolved": "https://registry.npmjs.org/@capacitor/keyboard/-/keyboard-8.0.6.tgz",
+ "integrity": "sha512-Bbe+9V0qaT6dzEFJEK7BUWR01l2+vZE8FM5ITF/WgKtx+G6eGZ6d5+YiSMRJBAK0VGjdO59v8yiQ10Doa5KyvQ==",
+ "license": "MIT",
"peerDependencies": {
- "@capacitor/core": "^7.6.0"
+ "@capacitor/core": ">=8.0.0"
}
},
"node_modules/@capacitor/local-notifications": {
- "version": "7.0.7",
- "resolved": "https://registry.npmjs.org/@capacitor/local-notifications/-/local-notifications-7.0.7.tgz",
- "integrity": "sha512-3qSpa8PpVMONHqBOaJ4RbA/lB5vOdEngtep0myGmP3S56gShPScDCotbw7dwmQy3NCdY4Up9nH3ySrGvUh2jZg==",
+ "version": "8.3.1",
+ "resolved": "https://registry.npmjs.org/@capacitor/local-notifications/-/local-notifications-8.3.1.tgz",
+ "integrity": "sha512-F7zu/+p/mIR958YP4axOkeI5hBKRaXDyYjbNPrAil2wWfd7OxScPSTvP9t85NpQ0eULVRu0/sntoxOg6ck477A==",
+ "license": "MIT",
"peerDependencies": {
- "@capacitor/core": ">=7.0.0"
+ "@capacitor/core": ">=8.0.0"
}
},
"node_modules/@capacitor/share": {
- "version": "7.0.4",
- "resolved": "https://registry.npmjs.org/@capacitor/share/-/share-7.0.4.tgz",
- "integrity": "sha512-wNXxmXUcChrtbZ5jQv8scFIbIGKo3rk6B7qpWySxfUhYJP5NANgAqQ9Z69m0k/zYsucdh66SBU7XW1ykd9aUug==",
+ "version": "8.0.3",
+ "resolved": "https://registry.npmjs.org/@capacitor/share/-/share-8.0.3.tgz",
+ "integrity": "sha512-gnvZBV1NPu2B8vd1UKncR56G15ueHd0aZLqgDov++t3SmTBG9Q0VrAZ1VnHn5stxlmglVaTb4RwopMgbpLzroA==",
+ "license": "MIT",
"peerDependencies": {
- "@capacitor/core": ">=7.0.0"
+ "@capacitor/core": ">=8.0.0"
}
},
"node_modules/@capacitor/synapse": {
diff --git a/frontend/package.json b/frontend/package.json
index 42ca79781..3f0ee4fb5 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -14,13 +14,13 @@
},
"license": "AGPL-3.0-or-later",
"dependencies": {
- "@aparajita/capacitor-secure-storage": "^7.1.6",
- "@capacitor-mlkit/barcode-scanning": "^7.5.0",
- "@capacitor/app": "^7.1.2",
- "@capacitor/core": "^7.6.8",
- "@capacitor/filesystem": "^7.1.8",
- "@capacitor/local-notifications": "^7.0.7",
- "@capacitor/share": "^7.0.4",
+ "@aparajita/capacitor-secure-storage": "^8.0.1",
+ "@capacitor-mlkit/barcode-scanning": "^8.2.1",
+ "@capacitor/app": "^8.0.0",
+ "@capacitor/core": "^8.5.3",
+ "@capacitor/filesystem": "^8.1.4",
+ "@capacitor/local-notifications": "^8.0.0",
+ "@capacitor/share": "^8.0.0",
"jsqr": "^1.4.0",
"lean-qr": "^2.7.3",
"react": "^19.2.7",
@@ -29,10 +29,10 @@
"zustand": "^5.0.14"
},
"devDependencies": {
- "@capacitor/android": "^7.6.8",
+ "@capacitor/android": "^8.5.3",
"@capacitor/assets": "^3.0.5",
- "@capacitor/cli": "^7.6.8",
- "@capacitor/ios": "^7.6.8",
+ "@capacitor/cli": "^8.5.3",
+ "@capacitor/ios": "^8.5.3",
"@vitejs/plugin-react": "^6.0.3",
"@vitest/coverage-v8": "^4.1.11",
"happy-dom": "^20.11.2",
diff --git a/frontend/src/lib/channel.js b/frontend/src/lib/channel.js
new file mode 100644
index 000000000..ed1e3f8da
--- /dev/null
+++ b/frontend/src/lib/channel.js
@@ -0,0 +1,32 @@
+// Where this copy of the app came from, which decides who installs its updates:
+// 'sideload' the APK from GitHub or opengym.ch: it checks GitHub and installs updates itself
+// 'play' Google Play, which updates it (and does not allow an app to update itself)
+// 'appstore' the iPhone app, updated by the App Store
+// 'web' the browser, updated with its server
+// Android says which build it is (ChannelPlugin.java, the build flavour). An APK from before the
+// plugin existed is a sideloaded one: the Play build never shipped without it.
+import { MOBILE } from './mobile.js'
+
+let channelP = null
+export function getChannel() {
+ return channelP || (channelP = (async () => {
+ if (!MOBILE) return 'web'
+ const { Capacitor, registerPlugin } = await import('@capacitor/core')
+ const platform = Capacitor.getPlatform()
+ if (platform === 'ios') return 'appstore'
+ if (platform !== 'android') return 'web'
+ try {
+ const { channel } = await registerPlugin('Channel').get()
+ return channel === 'play' ? 'play' : 'sideload'
+ } catch {
+ return 'sideload'
+ }
+ })().catch(() => 'web'))
+}
+
+// The in-app updater is for the sideloaded APK only.
+export async function selfUpdates() {
+ return (await getChannel()) === 'sideload'
+}
+
+export function resetChannel() { channelP = null }
diff --git a/frontend/src/lib/channel.test.js b/frontend/src/lib/channel.test.js
new file mode 100644
index 000000000..de54d49f5
--- /dev/null
+++ b/frontend/src/lib/channel.test.js
@@ -0,0 +1,65 @@
+// Who installs the updates: the sideloaded APK updates itself, Google Play and the App Store do it
+// for their builds. The updater must never show in a store build (Play does not allow it).
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+
+const h = vi.hoisted(() => {
+ vi.stubEnv('VITE_MOBILE', '1')
+ return { platform: 'android', answer: { channel: 'sideload' }, fail: false }
+})
+
+vi.mock('@capacitor/core', () => ({
+ Capacitor: { getPlatform: () => h.platform },
+ registerPlugin: () => new Proxy({}, {
+ get: (_, prop) => prop === 'then' ? undefined : async () => {
+ if (h.fail) throw new Error('"Channel" plugin is not implemented on android')
+ return h.answer
+ },
+ }),
+}))
+
+beforeEach(() => {
+ vi.resetModules()
+ h.platform = 'android'
+ h.answer = { channel: 'sideload' }
+ h.fail = false
+})
+
+describe('install channel', () => {
+ it('the APK from GitHub updates itself', async () => {
+ const { getChannel, selfUpdates } = await import('./channel.js')
+ expect(await getChannel()).toBe('sideload')
+ expect(await selfUpdates()).toBe(true)
+ })
+
+ it('the Google Play build does not', async () => {
+ h.answer = { channel: 'play' }
+ const { getChannel, selfUpdates } = await import('./channel.js')
+ expect(await getChannel()).toBe('play')
+ expect(await selfUpdates()).toBe(false)
+ })
+
+ it('an older APK without the plugin is a sideloaded one', async () => {
+ h.fail = true
+ const { getChannel } = await import('./channel.js')
+ expect(await getChannel()).toBe('sideload')
+ })
+
+ it('the iPhone app is the App Store\'s', async () => {
+ h.platform = 'ios'
+ const { getChannel, selfUpdates } = await import('./channel.js')
+ expect(await getChannel()).toBe('appstore')
+ expect(await selfUpdates()).toBe(false)
+ })
+
+ it('the Play flavour says "play" and leaves the updater out', async () => {
+ const { readFileSync, existsSync } = await import('node:fs')
+ const app = new URL('../../android/app/', import.meta.url)
+ const gradle = readFileSync(new URL('build.gradle', app), 'utf8')
+ expect(gradle).toMatch(/play \{[\s\S]*?buildConfigField "String", "CHANNEL", '"play"'/)
+ const main = readFileSync(new URL('src/main/AndroidManifest.xml', app), 'utf8')
+ expect(main).not.toContain('REQUEST_INSTALL_PACKAGES')
+ expect(existsSync(new URL('src/main/java/ch/duartesantos/opengym/InstallPlugin.java', app))).toBe(false)
+ const play = readFileSync(new URL('src/play/java/ch/duartesantos/opengym/FlavorPlugins.java', app), 'utf8')
+ expect(play).not.toContain('InstallPlugin')
+ })
+})
diff --git a/frontend/src/lib/system-bars.js b/frontend/src/lib/system-bars.js
index fdd24681a..69b8613a4 100644
--- a/frontend/src/lib/system-bars.js
+++ b/frontend/src/lib/system-bars.js
@@ -1,16 +1,26 @@
-// Android app: the status bar and the navigation bar draw on top of the page (Android 15, edge to
-// edge), white unless the native side is told the page is light. On the light theme the clock and
-// the battery all but vanished on #f2f2f7. App.jsx calls this with every theme it resolves to; the
-// SystemBars plugin (SystemBarsPlugin.java) flips the icons dark on light and back.
-import { isAndroid } from './mobile.js'
+// The status bar (and on Android the navigation bar) draws on top of the page: Android 15 runs the
+// page edge to edge, iOS always does. The icons are white unless the native side is told the page
+// is light, and on the light theme the clock and the battery all but vanished on #f2f2f7. App.jsx
+// calls this with every theme it resolves to. Android: BarIconsPlugin.java flips the icons dark on
+// light and back (from Android 15, where the page is under the bars). iOS: Capacitor's own
+// SystemBars plugin does the same for the status bar.
+import { MOBILE } from './mobile.js'
// Registered once, and kept inside an object: a Capacitor plugin proxy answers `then` with a native
// call that never settles, so a promise resolved with the bare proxy would hang (the Coach hang, #42).
let pluginP = null
const barsPlugin = () => pluginP || (pluginP = (async () => {
- if (!(await isAndroid())) return null
- const { registerPlugin } = await import('@capacitor/core')
- return { SystemBars: registerPlugin('SystemBars') }
+ if (!MOBILE) return null
+ const { Capacitor, registerPlugin, SystemBars } = await import('@capacitor/core')
+ const platform = Capacitor.getPlatform()
+ if (platform === 'android') {
+ const icons = registerPlugin('BarIcons')
+ return { setLight: light => icons.setStyle({ light }) }
+ }
+ if (platform === 'ios' && SystemBars) {
+ return { setLight: light => SystemBars.setStyle({ style: light ? 'LIGHT' : 'DARK' }) }
+ }
+ return null
})().catch(() => null))
let last = null
@@ -20,7 +30,7 @@ export async function setSystemBarsLight(light) {
last = light
try {
const p = await barsPlugin()
- if (p) await p.SystemBars.setStyle({ light })
+ if (p) await p.setLight(light)
} catch {
// An older APK without the plugin: the bars stay as they were.
}
diff --git a/frontend/src/lib/system-bars.test.js b/frontend/src/lib/system-bars.test.js
index 05c310437..029630e66 100644
--- a/frontend/src/lib/system-bars.test.js
+++ b/frontend/src/lib/system-bars.test.js
@@ -13,7 +13,7 @@ const pluginProxy = () => new Proxy({}, {
get: (_, prop) => {
if (prop === 'then') return () => new Promise(() => {})
return async arg => {
- if (h.fail) throw new Error('"SystemBars" plugin is not implemented on android')
+ if (h.fail) throw new Error('"BarIcons" plugin is not implemented on android')
h.calls.push([String(prop), arg])
}
},
@@ -22,6 +22,7 @@ const pluginProxy = () => new Proxy({}, {
vi.mock('@capacitor/core', () => ({
Capacitor: { getPlatform: () => h.platform },
registerPlugin: () => pluginProxy(),
+ SystemBars: { setStyle: async arg => { h.calls.push(['ios.setStyle', arg]) } },
}))
beforeEach(() => {
@@ -40,10 +41,18 @@ describe('system bars follow the theme on Android', () => {
expect(h.calls).toEqual([['setStyle', { light: true }], ['setStyle', { light: false }]])
})
- it('stays quiet off Android', async () => {
+ it('on iOS, Capacitor\'s SystemBars sets the status bar style', async () => {
h.platform = 'ios'
const { setSystemBarsLight } = await import('./system-bars.js')
await setSystemBarsLight(true)
+ await setSystemBarsLight(false)
+ expect(h.calls).toEqual([['ios.setStyle', { style: 'LIGHT' }], ['ios.setStyle', { style: 'DARK' }]])
+ })
+
+ it('stays quiet in a browser shell', async () => {
+ h.platform = 'web'
+ const { setSystemBarsLight } = await import('./system-bars.js')
+ await setSystemBarsLight(true)
expect(h.calls).toEqual([])
})
@@ -58,9 +67,9 @@ describe('system bars follow the theme on Android', () => {
expect(app).toMatch(/function applyPrefs[\s\S]*?setSystemBarsLight\(de\.dataset\.theme === 'light'\)/)
const dir = '../../android/app/src/main/java/ch/duartesantos/opengym/'
const activity = readFileSync(new URL(dir + 'MainActivity.java', import.meta.url), 'utf8')
- const plugin = readFileSync(new URL(dir + 'SystemBarsPlugin.java', import.meta.url), 'utf8')
- expect(activity).toMatch(/registerPlugin\(SystemBarsPlugin\.class\);[\s\S]*super\.onCreate/)
- expect(plugin).toContain('@CapacitorPlugin(name = "SystemBars")')
+ const plugin = readFileSync(new URL(dir + 'BarIconsPlugin.java', import.meta.url), 'utf8')
+ expect(activity).toMatch(/registerPlugin\(BarIconsPlugin\.class\);[\s\S]*super\.onCreate/)
+ expect(plugin).toContain('@CapacitorPlugin(name = "BarIcons")')
expect(plugin).toMatch(/setAppearanceLightStatusBars\(light\)/)
})
})
diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx
index 9a651c58f..490c22675 100644
--- a/frontend/src/views/Settings.jsx
+++ b/frontend/src/views/Settings.jsx
@@ -32,6 +32,7 @@ import { limitsFrom, fmtMB, MB } from '../lib/media-limits.js'
import { setRestAccent } from '../lib/rest-alert.js'
import { CUSTOM, accentKey, adjustedIn, applyAccent, cleanHex, inkOn, isGrey } from '../lib/accent.js'
import { checkForUpdate, downloadAndInstall, fetchChecksum, RELEASES_PAGE } from '../lib/update.js'
+import { selfUpdates } from '../lib/channel.js'
import { forgetCoach } from '../lib/coach-api.js'
import { REST_MAX, REST_PAUSE_MIN, REST_PAUSE_MAX, fmtRest, fmtDuration } from '../lib/duration.js'
import { starterPlanSheet, confirmSheet, importFromApp, importFromHevy, equipmentProfileSheet, plateInventorySheet, dumbbellInventorySheet, menuSheet } from '../sheets.jsx'
@@ -151,6 +152,7 @@ export default function Settings({ page = null, find = null, via = null }) {
// --- update check state ---
const [updateInfo, setUpdateInfo] = useState(null) // { hasUpdate, latestVersion, apkUrl, hashUrl } | null
const [android, setAndroid] = useState(false)
+ const [selfUpdate, setSelfUpdate] = useState(false) // the sideloaded APK, which updates itself
const [checking, setChecking] = useState(false)
// Where auto-backup writes on this Android phone, for the Auto-backup row's own subtitle.
const [backupDir] = useBackupFolder(MOBILE && android && !!S.autoBackup)
@@ -161,8 +163,14 @@ export default function Settings({ page = null, find = null, via = null }) {
// already answers false off the mobile build; the MOBILE check on top keeps the web bundle
// from even asking (and from calling GitHub on every Settings visit). Only the pages
// that show it ask: the root (for nothing but `android`) skips the release check.
+ // The Google Play build is updated by Play (lib/channel.js): no update row there either.
if (!MOBILE) return
- isAndroid().then(ok => { setAndroid(ok); if (ok && page === 'about') checkForUpdate().then(setUpdateInfo).catch(() => {}) })
+ isAndroid().then(async ok => {
+ setAndroid(ok)
+ const own = ok && await selfUpdates()
+ setSelfUpdate(own)
+ if (own && page === 'about') checkForUpdate().then(setUpdateInfo).catch(() => {})
+ })
}, [page])
// A search hit: scroll its row (or button) into view and flash it once. A row that shows only
@@ -807,11 +815,12 @@ export default function Settings({ page = null, find = null, via = null }) {
about: () => <>
{/* Updates. On Android the row is always there: it checks on demand and installs when a
release is newer (checksum verified, see onUpdateRowClick). On the web the app updates
- with its server, so the row points at the APK for the phone instead. iOS has no APK. */}
- <Section footer={MOBILE ? (android ? t('Releases are checked on GitHub. The download is verified against its checksum before the installer opens.') : null) : t('The web app updates together with your server. The Android app installs its own updates from here.')}>
+ with its server, so the row points at the APK for the phone instead. iOS and the Google
+ Play build are updated by their store. */}
+ <Section footer={MOBILE ? (selfUpdate ? t('Releases are checked on GitHub. The download is verified against its checksum before the installer opens.') : null) : t('The web app updates together with your server. The Android app installs its own updates from here.')}>
<Row icon="info" iconTint="var(--grey)" title={t('Version')} value={'v' + __APP_VERSION__} />
{MOBILE
- ? android && <Row icon="download" iconTint="var(--green)"
+ ? selfUpdate && <Row icon="download" iconTint="var(--green)"
title={updateInfo?.hasUpdate ? t('Update to openGym v{0}', updateInfo.latestVersion) : t('Check for updates')}
subtitle={checking ? t('Checking…') : t('You have v{0}', __APP_VERSION__)}
accessory="chevron"
diff --git a/frontend/src/views/Settings.update.test.jsx b/frontend/src/views/Settings.update.test.jsx
index bb4846cc8..3aad9b73c 100644
--- a/frontend/src/views/Settings.update.test.jsx
+++ b/frontend/src/views/Settings.update.test.jsx
@@ -11,7 +11,7 @@ globalThis.IS_REACT_ACT_ENVIRONMENT = true
// flips the two gates (MOBILE flag, Capacitor platform) and watches whether Settings even
// asks gitlab.com for the latest release.
const mocks = vi.hoisted(() => {
- const state = { S: null, MOBILE: false, android: false }
+ const state = { S: null, MOBILE: false, android: false, channel: 'sideload' }
state.snapshot = () => ({
S: state.S,
user: null,
@@ -54,6 +54,7 @@ vi.mock('../lib/update.js', () => ({
checkForUpdate: (...a) => mocks.checkForUpdate(...a),
downloadAndInstall: vi.fn(),
}))
+vi.mock('../lib/channel.js', () => ({ selfUpdates: () => Promise.resolve(mocks.channel === 'sideload') }))
vi.mock('./MobileOnboarding.jsx', () => ({ ConnectSheet: () => null }))
vi.mock('../sheets.jsx', () => ({
starterPlanSheet: vi.fn(), confirmSheet: (...a) => mocks.confirmSheet(...a), importFromApp: vi.fn(),
@@ -70,6 +71,7 @@ beforeEach(() => {
}
mocks.MOBILE = false
mocks.android = false
+ mocks.channel = 'sideload'
mocks.checkForUpdate.mockClear()
mocks.confirmSheet.mockClear()
host = document.createElement('div')
@@ -84,7 +86,7 @@ afterEach(() => {
// The effect resolves two promises (isAndroid, then checkForUpdate) before the row can render.
const mount = async () => {
await act(async () => { root.render(<Settings page="about" />) })
- await act(async () => { await Promise.resolve(); await Promise.resolve() })
+ await act(async () => { for (let i = 0; i < 4; i++) await Promise.resolve() })
}
const updateRow = () => [...host.querySelectorAll('.lrow')].find(r => r.textContent.includes('Update to openGym v9.9.9'))
const checkRow = () => [...host.querySelectorAll('.lrow')].find(r => r.textContent.includes('Check for updates'))
@@ -108,6 +110,16 @@ describe('Settings — in-app update check', () => {
expect(webRow()).toBeUndefined()
})
+ it('Google Play build: Play installs the updates, so no check and no row', async () => {
+ mocks.MOBILE = true
+ mocks.android = true
+ mocks.channel = 'play'
+ await mount()
+ expect(mocks.checkForUpdate).not.toHaveBeenCalled()
+ expect(updateRow()).toBeUndefined()
+ expect(checkRow()).toBeUndefined()
+ })
+
it('mobile build on Android: checks once and shows the row, tapping it asks before downloading', async () => {
mocks.MOBILE = true
mocks.android = true