Skip to content

Commit 79725e2

Browse files
InfantLabclaude
andcommitted
feat(android): Phase 3 — Capacitor Android shell scaffolded
Phase 3 of v0.7.0. Installs @capacitor/* (v8), runs cap init + cap add android, configures the WebView origin / cookie behaviour / icon set / deep links, and stops short of the steps that need Java/Android Studio (which aren't available in the devcontainer). What's in this commit: - Capacitor 8.3.3 + @capacitor/{android,cli,core,preferences,app, splash-screen,local-notifications,assets} as devDeps. - `capacitor.config.ts` — appId living.tada.app, webDir .output/public, WebView origin https://app.tada.living (chosen so SameSite=Lax cookies set by tada.living/api/* are eligible to be sent on cross- subdomain fetches). - `android/` Gradle project scaffolded via `npx cap add android`. - AndroidManifest tuned: App Links intent filter for tada.living with autoVerify=true, a SEND text/plain intent for Web Share Target, and permissions for INTERNET, ACCESS_NETWORK_STATE, POST_NOTIFICATIONS, WAKE_LOCK, FOREGROUND_SERVICE (+ media playback + special use). - 92 Android icon + splash assets generated from public/icons/tada-fullicon.png via @capacitor/assets. Brand green background, darker green for splash dark mode. - CORS middleware default allow-list now includes https://app.tada.living so the WebView's cross-origin fetch hits Access-Control-Allow-Credentials: true. Production should still pin CORS_ALLOWED_ORIGINS explicitly. - plugins/api-client.client.ts switched to credentials:"include" when apiBaseUrl is set, so the session cookie actually rides along on cross-origin API calls. - npm scripts: android:sync (build:capacitor + cap sync), android:open (cap open android), android:run, android:assets. - docs/dev/android-build-handover.md — the local-machine checklist: Android Studio setup, first emulator build, signing key generation warning, Play Console identity-verification timeline (2-7 days for new individual accounts + 12 testers / 14 days closed-testing rule for the production track), F-Droid metadata flow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a319d88 commit 79725e2

86 files changed

Lines changed: 2263 additions & 73 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/android/.gitignore

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore
2+
3+
# Built application files
4+
*.apk
5+
*.aar
6+
*.ap_
7+
*.aab
8+
9+
# Files for the ART/Dalvik VM
10+
*.dex
11+
12+
# Java class files
13+
*.class
14+
15+
# Generated files
16+
bin/
17+
gen/
18+
out/
19+
# Uncomment the following line in case you need and you don't have the release build type files in your app
20+
# release/
21+
22+
# Gradle files
23+
.gradle/
24+
build/
25+
26+
# Local configuration file (sdk path, etc)
27+
local.properties
28+
29+
# Proguard folder generated by Eclipse
30+
proguard/
31+
32+
# Log Files
33+
*.log
34+
35+
# Android Studio Navigation editor temp files
36+
.navigation/
37+
38+
# Android Studio captures folder
39+
captures/
40+
41+
# IntelliJ
42+
*.iml
43+
.idea/workspace.xml
44+
.idea/tasks.xml
45+
.idea/gradle.xml
46+
.idea/assetWizardSettings.xml
47+
.idea/dictionaries
48+
.idea/libraries
49+
# Android Studio 3 in .gitignore file.
50+
.idea/caches
51+
.idea/modules.xml
52+
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
53+
.idea/navEditor.xml
54+
55+
# Keystore files
56+
# Uncomment the following lines if you do not want to check your keystore files in.
57+
#*.jks
58+
#*.keystore
59+
60+
# External native build folder generated in Android Studio 2.2 and later
61+
.externalNativeBuild
62+
.cxx/
63+
64+
# Google Services (e.g. APIs or Firebase)
65+
# google-services.json
66+
67+
# Freeline
68+
freeline.py
69+
freeline/
70+
freeline_project_description.json
71+
72+
# fastlane
73+
fastlane/report.xml
74+
fastlane/Preview.html
75+
fastlane/screenshots
76+
fastlane/test_output
77+
fastlane/readme.md
78+
79+
# Version control
80+
vcs.xml
81+
82+
# lint
83+
lint/intermediates/
84+
lint/generated/
85+
lint/outputs/
86+
lint/tmp/
87+
# lint/reports/
88+
89+
# Android Profiling
90+
*.hprof
91+
92+
# Cordova plugins for Capacitor
93+
capacitor-cordova-android-plugins
94+
95+
# Copied web assets
96+
app/src/main/assets/public
97+
98+
# Generated Config files
99+
app/src/main/assets/capacitor.config.json
100+
app/src/main/assets/capacitor.plugins.json
101+
app/src/main/res/xml/config.xml

app/android/app/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/build/*
2+
!/build/.npmkeep

app/android/app/build.gradle

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
namespace = "living.tada.app"
5+
compileSdk = rootProject.ext.compileSdkVersion
6+
defaultConfig {
7+
applicationId "living.tada.app"
8+
minSdkVersion rootProject.ext.minSdkVersion
9+
targetSdkVersion rootProject.ext.targetSdkVersion
10+
versionCode 1
11+
versionName "1.0"
12+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13+
aaptOptions {
14+
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
15+
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
16+
ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
17+
}
18+
}
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
}
26+
27+
repositories {
28+
flatDir{
29+
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
30+
}
31+
}
32+
33+
dependencies {
34+
implementation fileTree(include: ['*.jar'], dir: 'libs')
35+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
36+
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
37+
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
38+
implementation project(':capacitor-android')
39+
testImplementation "junit:junit:$junitVersion"
40+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
41+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
42+
implementation project(':capacitor-cordova-android-plugins')
43+
}
44+
45+
apply from: 'capacitor.build.gradle'
46+
47+
try {
48+
def servicesJSON = file('google-services.json')
49+
if (servicesJSON.text) {
50+
apply plugin: 'com.google.gms.google-services'
51+
}
52+
} catch(Exception e) {
53+
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
54+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
2+
3+
android {
4+
compileOptions {
5+
sourceCompatibility JavaVersion.VERSION_21
6+
targetCompatibility JavaVersion.VERSION_21
7+
}
8+
}
9+
10+
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
11+
dependencies {
12+
implementation project(':capacitor-app')
13+
implementation project(':capacitor-local-notifications')
14+
implementation project(':capacitor-preferences')
15+
implementation project(':capacitor-splash-screen')
16+
17+
}
18+
19+
20+
if (hasProperty('postBuildExtras')) {
21+
postBuildExtras()
22+
}

app/android/app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.getcapacitor.myapp;
2+
3+
import static org.junit.Assert.*;
4+
5+
import android.content.Context;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
import androidx.test.platform.app.InstrumentationRegistry;
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
15+
*/
16+
@RunWith(AndroidJUnit4.class)
17+
public class ExampleInstrumentedTest {
18+
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
23+
24+
assertEquals("com.getcapacitor.app", appContext.getPackageName());
25+
}
26+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<application
4+
android:allowBackup="true"
5+
android:icon="@mipmap/ic_launcher"
6+
android:label="@string/app_name"
7+
android:roundIcon="@mipmap/ic_launcher_round"
8+
android:supportsRtl="true"
9+
android:theme="@style/AppTheme">
10+
<activity
11+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation|density"
12+
android:name=".MainActivity"
13+
android:label="@string/title_activity_main"
14+
android:theme="@style/AppTheme.NoActionBarLaunch"
15+
android:launchMode="singleTask"
16+
android:exported="true">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
<category android:name="android.intent.category.LAUNCHER" />
20+
</intent-filter>
21+
22+
<!-- App Links: tada.living/* opens in the app when verified (Phase 3.4) -->
23+
<intent-filter android:autoVerify="true">
24+
<action android:name="android.intent.action.VIEW" />
25+
<category android:name="android.intent.category.DEFAULT" />
26+
<category android:name="android.intent.category.BROWSABLE" />
27+
<data android:scheme="https" />
28+
<data android:host="tada.living" />
29+
</intent-filter>
30+
31+
<!-- Web Share Target — receive shared text/url from other apps -->
32+
<intent-filter>
33+
<action android:name="android.intent.action.SEND" />
34+
<category android:name="android.intent.category.DEFAULT" />
35+
<data android:mimeType="text/plain" />
36+
</intent-filter>
37+
</activity>
38+
39+
<provider
40+
android:name="androidx.core.content.FileProvider"
41+
android:authorities="${applicationId}.fileprovider"
42+
android:exported="false"
43+
android:grantUriPermissions="true">
44+
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
45+
</provider>
46+
</application>
47+
48+
<!-- Permissions -->
49+
50+
<uses-permission android:name="android.permission.INTERNET" />
51+
<!-- Allow checking connectivity for offline detection (Phase 2.5 cache layer) -->
52+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
53+
<!-- Notifications for session bells (Phase 4.1) — Android 13+ requires runtime grant -->
54+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
55+
<!-- Wake the screen for session timing (Phase 4.3) -->
56+
<uses-permission android:name="android.permission.WAKE_LOCK" />
57+
<!-- Active-session foreground service (Phase 4.2). FGS_SPECIAL_USE is the
58+
Android 14+ category for "ongoing user-initiated activity" like a
59+
meditation timer; we declare the more specific FGS_MEDIA_PLAYBACK
60+
too because session bells are media playback. -->
61+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
62+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
63+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
64+
</manifest>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package living.tada.app;
2+
3+
import com.getcapacitor.BridgeActivity;
4+
5+
public class MainActivity extends BridgeActivity {}
91 KB
Loading
15.7 KB
Loading

0 commit comments

Comments
 (0)