Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.composeMultiplatform)
alias(libs.plugins.composeCompiler)
alias(libs.plugins.ksp)
}

val keystorePropertiesFile = rootProject.file("keystore.properties")
Expand Down Expand Up @@ -59,13 +60,33 @@ kotlin {
jvmTarget = JvmTarget.JVM_17
}
}
ksp {
arg("appfunctions:aggregateAppFunctions", "true")
}

dependencies {
implementation(projects.shared)

implementation(libs.androidx.activity.compose)

// Ask GalwayBus: AppFunctions (also exposed to the system's assistants) and the on-device
// ML Kit agent that uses them as its tools.
implementation(libs.androidx.appfunctions)
ksp(libs.androidx.appfunctions.compiler)
implementation(libs.mlkit.genai.agent)
implementation(libs.markdown.renderer.m3)
implementation(libs.compose.runtime)
implementation(libs.compose.foundation)
implementation(libs.compose.material3)
implementation(libs.compose.material.icons.extended)
implementation(libs.compose.ui)
implementation(libs.androidx.lifecycle.viewmodelCompose)
implementation(libs.androidx.lifecycle.runtimeCompose)

implementation(libs.compose.uiToolingPreview)
debugImplementation(libs.compose.uiTooling)

testImplementation(libs.junit)
}

android {
Expand All @@ -92,7 +113,8 @@ android {

defaultConfig {
applicationId = "dev.johnoreilly.galwaybus"
minSdk = libs.versions.android.minSdk.get().toInt()
// 26 rather than the shared minSdk: ML Kit genai-agent requires it
minSdk = 26
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = versionCode()
versionName = versionName()
Expand Down
9 changes: 9 additions & 0 deletions androidApp/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,12 @@
-dontwarn org.conscrypt.**
-dontwarn org.bouncycastle.**
-dontwarn org.openjsse.**

# ML Kit (its bundled firebase-components) creates component registrars by reflection from
# manifest metadata, so R8 sees their no-arg constructors as unused and removes them. ML Kit then
# starts with no components and Generation.getClient() throws (BikeShare 1.0.17 crashed at launch
# this way: "Could not instantiate com.google.mlkit.common.internal.CommonComponentRegistrar").
-keep class * implements com.google.firebase.components.ComponentRegistrar { <init>(); }

# AppFunctions: the system and the agent reach these by name, through KSP-generated code.
-keep class dev.johnoreilly.galwaybus.functions.** { *; }
23 changes: 22 additions & 1 deletion androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
Expand Down Expand Up @@ -32,6 +33,26 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

<!-- AppFunctions (Android 16+): generated by KSP from BaseGalwayBusAppFunctionService -->
<service
android:name="dev.johnoreilly.galwaybus.functions.GalwayBusAppFunctionService"
android:permission="android.permission.BIND_APP_FUNCTION_SERVICE"
android:exported="true"
tools:targetApi="36">
<property
android:name="android.app.appfunctions.schema"
android:value="app_functions_schema.xsd"/>
<property
android:name="android.app.appfunctions.v2"
android:value="galwaybus_app_function_service.xml"/>
<intent-filter>
<action android:name="android.app.appfunctions.AppFunctionService"/>
</intent-filter>
</service>
<property
android:name="android.app.appfunctions.app_metadata"
android:resource="@xml/app_metadata"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import dev.johnoreilly.galwaybus.agent.AskGalwayBusAction
import dev.johnoreilly.galwaybus.agent.GalwayBusAgentViewModel
import dev.johnoreilly.galwaybus.location.LocationController
import dev.johnoreilly.galwaybus.scan.CameraController
import kotlinx.coroutines.CompletableDeferred

class MainActivity : ComponentActivity() {

private val agentViewModel: GalwayBusAgentViewModel by viewModels()

// Bridges the one-shot permission dialog (an Activity concern) to the shared LocationProvider's
// suspend request. Only one request is ever in flight at a time.
private var pendingPermission: CompletableDeferred<Boolean>? = null
Expand Down Expand Up @@ -56,7 +61,7 @@ class MainActivity : ComponentActivity() {
deferred.await()
}

setContent { App() }
setContent { App(extraActions = { AskGalwayBusAction(agentViewModel) }) }
}
}

Expand Down
Loading
Loading