diff options
Diffstat (limited to 'android/app/build.gradle')
| -rw-r--r-- | android/app/build.gradle | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/android/app/build.gradle b/android/app/build.gradle index 0119e93..8dcfc04 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -22,6 +22,24 @@ tasks.register('copyWeb', Copy) { into layout.buildDirectory.dir('www') } +// Firebase settings for the fcm build, read from app/google-services.json +// (downloaded from the Firebase console; gitignored). Without it the fcm +// build still builds, and pushes through UnifiedPush like the webview one. +def firebase = [appId: '', apiKey: '', projectId: '', senderId: ''] +def gsFile = file('google-services.json') +if (gsFile.exists()) { + def gs = new groovy.json.JsonSlurper().parse(gsFile) + def client = gs.client.find { it.client_info?.android_client_info?.package_name == 'io.coinos.beta' } + if (client) { + firebase = [ + appId: client.client_info.mobilesdk_app_id, + apiKey: client.api_key[0].current_key, + projectId: gs.project_info.project_id, + senderId: gs.project_info.project_number, + ] + } +} + android { namespace 'io.coinos.app' compileSdk 35 @@ -66,6 +84,21 @@ android { resValue 'string', 'app_name', 'Coinos (UnifiedPush)' buildConfigField 'boolean', 'BUNDLED', 'false' } + // fcm — the webview shell plus Firebase Cloud Messaging: push without a + // distributor app on phones with Google Play Services (see + // src/fcm/java/io/coinos/app/Fcm.java). Its own app id, so it + // installs beside the TWA for a side-by-side trial. + fcm { + dimension 'shell' + applicationId 'io.coinos.beta' + versionNameSuffix '-beta' + resValue 'string', 'app_name', 'Coinos Beta' + buildConfigField 'boolean', 'BUNDLED', 'false' + buildConfigField 'String', 'FCM_APP_ID', "\"${firebase.appId}\"" + buildConfigField 'String', 'FCM_API_KEY', "\"${firebase.apiKey}\"" + buildConfigField 'String', 'FCM_PROJECT_ID', "\"${firebase.projectId}\"" + buildConfigField 'String', 'FCM_SENDER_ID', "\"${firebase.senderId}\"" + } fdroid { dimension 'shell' applicationId 'io.coinos.fdroid' @@ -74,9 +107,19 @@ android { } } sourceSets { + // the webview shell has no Firebase: its Fcm is a stub + webview { + java.srcDirs += 'src/nofcm/java' + } + // the webview shell with Firebase (the manifest is webview's plus FCM) + fcm { + java.srcDirs = ['src/webview/java', 'src/fcm/java'] + res.srcDirs = ['src/webview/res'] + manifest.srcFile 'src/fcm/AndroidManifest.xml' + } // the same shell as webview, plus the bundled web app fdroid { - java.srcDirs = ['src/webview/java'] + java.srcDirs = ['src/webview/java', 'src/nofcm/java'] res.srcDirs = ['src/webview/res'] manifest.srcFile 'src/webview/AndroidManifest.xml' assets.srcDirs += layout.buildDirectory.dir('www').get().asFile @@ -102,6 +145,12 @@ android { dependencies { // only the TWA shell needs Chrome's helper; the WebView build carries none twaImplementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.5.0' + // WebAuthn (passkeys) inside the WebView builds — androidx, no Google services + webviewImplementation 'androidx.webkit:webkit:1.14.0' + fcmImplementation 'androidx.webkit:webkit:1.14.0' + fdroidImplementation 'androidx.webkit:webkit:1.14.0' + // only the fcm build carries Google's push client + fcmImplementation 'com.google.firebase:firebase-messaging:24.1.0' } preBuild.dependsOn copyWeb |
