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.

4.5 KB
Raw Blame
apply plugin: 'com.android.application'

android {
    namespace = "ch.duartesantos.opengym"
    compileSdk = rootProject.ext.compileSdkVersion
    buildFeatures {
        buildConfig = true
    }
    defaultConfig {
        applicationId "ch.duartesantos.opengym"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 28
        versionName "1.4.3"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        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:!*~'
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            // The barcode scanner's ML Kit library ships a native build for four CPU families.
            // Phones are ARM; the two x86 builds only serve emulators and a few Chromebooks, which
            // run ARM code through translation anyway. Leaving them out takes about 12 MB off
            // the APK. Release only: the debug build keeps x86_64 for the emulator test rig.
            ndk {
                abiFilters 'arm64-v8a', 'armeabi-v7a'
            }
        }
        debug {
            // Test build installs side-by-side with the real app: its own applicationId, so both
            // can live on one device. The name/icon label is overridden by the debug resource
            // overlay in src/debug/res. The release build (the "real" app) is untouched.
            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 {
    flatDir{
        dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
    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.
    implementation "androidx.health.connect:connect-client:$healthConnectVersion"
    // The sharper animations as Play asset packs (AnimationPacksPlugin in src/play): the Play
    // build only. The sideloaded APK has no Play Store behind it and keeps its built-in ones.
    playImplementation "com.google.android.play:asset-delivery:$assetDeliveryVersion"
    implementation project(':capacitor-android')
    testImplementation "junit:junit:$junitVersion"
    androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
    androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
    implementation project(':capacitor-cordova-android-plugins')
}

apply from: 'capacitor.build.gradle'

// The asset packs themselves, generated on the release machine only (settings.gradle).
if (rootProject.file('asset-packs.app.gradle').exists()) {
    apply from: rootProject.file('asset-packs.app.gradle')
}

try {
    def servicesJSON = file('google-services.json')
    if (servicesJSON.text) {
        apply plugin: 'com.google.gms.google-services'
    }
} catch(Exception e) {
    logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}