Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/ci-gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ org.gradle.parallel=true
org.gradle.workers.max=2
org.gradle.configuration-cache=true
org.gradle.configuration-cache.parallel=true
org.gradle.jvmargs="-Xmx2g"

kotlin.incremental=false

Expand Down
133 changes: 133 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Build

on:
push:
branches:
- main
pull_request:
paths:
- 'agent/**'
- 'ChatApp/**'
- '.github/workflows/**'
workflow_dispatch:

concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

jobs:
agent-build:
name: "Agent build & test"
runs-on: macos-latest
timeout-minutes: 45

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
build-root-directory: agent

- name: Run spotless
run: ./gradlew spotlessCheck
working-directory: agent

- name: Run unit tests
run: ./gradlew test -PGEMINI_API_KEY=dummy_key
working-directory: agent

- name: Build Debug and Release APKs
run: ./gradlew assembleDebug assembleRelease -PGEMINI_API_KEY=dummy_key
working-directory: agent

- name: Upload Agent APKs
uses: actions/upload-artifact@v4
with:
name: agent-apks
path: agent/app/build/outputs/apk/**/*.apk

- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
env:
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL: 180
with:
api-level: 37.1
target: google_apis_ps16k
arch: arm64-v8a
emulator-boot-timeout: 900
force-avd-creation: true
emulator-options: -no-snapshot-load -no-snapshot-save -no-window -gpu host -noaudio -no-boot-anim -camera-back none -partition-size 4096
heap-size: 600M
disable-animations: true
working-directory: agent
script: adb shell wm dismiss-keyguard && ./gradlew :app:connectedAndroidTest -PGEMINI_API_KEY=dummy_key

chatapp-build:
name: "ChatApp build & test"
runs-on: macos-latest
timeout-minutes: 45

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
build-root-directory: ChatApp

- name: Run spotless
run: ./gradlew spotlessCheck
working-directory: ChatApp

- name: Run unit tests
run: ./gradlew test
working-directory: ChatApp

- name: Build Debug and Release APKs
run: ./gradlew assembleDebug assembleRelease
working-directory: ChatApp

- name: Upload ChatApp APKs
uses: actions/upload-artifact@v4
with:
name: chatapp-apks
path: |
ChatApp/app/build/outputs/apk/**/*.apk
ChatApp/wear/build/outputs/apk/**/*.apk

- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
env:
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL: 180
with:
api-level: 37.1
target: google_apis_ps16k
arch: arm64-v8a
emulator-boot-timeout: 900
force-avd-creation: true
emulator-options: -no-snapshot-load -no-snapshot-save -no-window -gpu host -noaudio -no-boot-anim -camera-back none -partition-size 4096
heap-size: 600M
disable-animations: true
working-directory: ChatApp
script: adb shell wm dismiss-keyguard && ./gradlew :app:connectedAndroidTest
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ build/
app/build
gradle/gradle-daemon-jvm.properties
local.properties
!.editorconfig

5 changes: 5 additions & 0 deletions ChatApp/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root = true

[*.{kt,kts}]
ktlint_code_style = ktlint_official
ktlint_function_naming_ignore_when_annotated_with = Composable
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.appfunctions.ExecuteAppFunctionRequest
import androidx.appfunctions.ExecuteAppFunctionResponse
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.example.chatapp.appfunctions.ChatAppFunctionService
import com.example.chatapp.data.MessageRepository
import com.example.chatapp.data.RecipientsRepository
import com.google.common.truth.Truth.assertThat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,16 @@ fun MessageBubble(
}
}
if (message.content.isNotEmpty()) {
val linkColor = if (message.isInbound) {
MaterialTheme.colorScheme.primary
} else {
MaterialTheme.colorScheme.inversePrimary
}
val annotatedText = remember(message.content, linkColor) {
linkifyString(message.content, linkColor = linkColor)
}
val linkColor =
if (message.isInbound) {
MaterialTheme.colorScheme.primary
} else {
MaterialTheme.colorScheme.inversePrimary
}
val annotatedText =
remember(message.content, linkColor) {
linkifyString(message.content, linkColor = linkColor)
}
Text(
modifier = Modifier.padding(16.dp),
text = annotatedText,
Expand Down
2 changes: 1 addition & 1 deletion ChatApp/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ composeMaterialIconsAndroid = "1.11.1"
composeMaterialIconsCore = "1.7.8"
hilt = "2.59.2"
androidxHiltNavigationCompose = "1.3.0"
ksp = "2.3.6"
ksp = "2.3.9"
spotless = "8.5.0"
truth = "1.4.5"
coil = "2.7.0"
Expand Down
1 change: 0 additions & 1 deletion ChatApp/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ dependencies {
// App functions
implementation(libs.androidx.appfunctions)
ksp(libs.androidx.appfunctions.compiler)

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
package com.example.chatapp

import android.app.Application

abstract class BaseChatApplication : Application()
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ import android.app.PendingIntent
import android.content.Intent
import android.net.Uri
import androidx.annotation.RequiresApi
import androidx.appfunctions.AppFunction
import androidx.appfunctions.AppFunctionAppUnknownException
import androidx.appfunctions.AppFunctionElementNotFoundException
import androidx.appfunctions.AppFunctionInvalidArgumentException
import androidx.appfunctions.AppFunctionService
import androidx.appfunctions.AppFunctionServiceEntryPoint
import androidx.appfunctions.AppFunctionStringValueConstraint
import androidx.appfunctions.AppFunction
import com.example.chatapp.data.CallManager
import com.example.chatapp.data.MessageRepository
import com.example.chatapp.data.RecipientsRepository
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import kotlinx.coroutines.CancellationException
import javax.inject.Inject

/**
* Service entry point for chat-related AppFunctions such as searching contacts, sending messages, and making calls.
Expand All @@ -44,7 +44,9 @@ import kotlinx.coroutines.CancellationException
)
abstract class BaseChatAppFunctionService : AppFunctionService() {
@Inject lateinit var messageRepository: MessageRepository

@Inject lateinit var recipientsRepository: RecipientsRepository

@Inject lateinit var callManager: CallManager

/**
Expand Down Expand Up @@ -153,9 +155,7 @@ abstract class BaseChatAppFunctionService : AppFunctionService() {
* @throws AppFunctionElementNotFoundException If no recipient exists for endpointValue. If thrown, call "searchContacts" to find the correct ID.
*/
@AppFunction(isDescribedByKDoc = true)
suspend fun makeCall(
endpointValue: String,
): PendingIntent {
suspend fun makeCall(endpointValue: String): PendingIntent {
val recipient =
recipientsRepository.getRecipientById(endpointValue)
?: throw AppFunctionElementNotFoundException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.chatapp.appfunctions

import androidx.appfunctions.AppFunctionSerializable


/**
* Represents a result from a contact or group search.
*/
Expand Down Expand Up @@ -67,4 +65,4 @@ data class ChatGroup(
val name: String,
/** List of members belonging to the group. */
val recipients: List<Recipient>,
)
)
31 changes: 18 additions & 13 deletions ChatApp/shared/src/main/kotlin/com/example/chatapp/util/Linkify.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import androidx.compose.ui.text.TextLinkStyles
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.style.TextDecoration

fun linkifyString(text: String, linkColor: Color? = null): AnnotatedString {
fun linkifyString(
text: String,
linkColor: Color? = null,
): AnnotatedString {
val matcher = Patterns.WEB_URL.matcher(text)
var lastIndex = 0
return buildAnnotatedString {
Expand All @@ -35,22 +38,24 @@ fun linkifyString(text: String, linkColor: Color? = null): AnnotatedString {

append(text.substring(lastIndex, start))

val uriStr = if (url.startsWith("http://", ignoreCase = true) || url.startsWith("https://", ignoreCase = true)) {
url
} else {
"https://$url"
}

val linkStyle = SpanStyle(
color = linkColor ?: Color.Unspecified,
textDecoration = TextDecoration.Underline
)
val uriStr =
if (url.startsWith("http://", ignoreCase = true) || url.startsWith("https://", ignoreCase = true)) {
url
} else {
"https://$url"
}

val linkStyle =
SpanStyle(
color = linkColor ?: Color.Unspecified,
textDecoration = TextDecoration.Underline,
)

pushLink(
LinkAnnotation.Url(
url = uriStr,
styles = TextLinkStyles(style = linkStyle)
)
styles = TextLinkStyles(style = linkStyle),
),
)
append(url)
pop()
Expand Down
1 change: 0 additions & 1 deletion ChatApp/wear/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ dependencies {
// App functions
implementation(libs.androidx.appfunctions)
ksp(libs.androidx.appfunctions.compiler)

}

// AppFunctions ksp option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ fun WearChatScreen(
title = { Text(text = if (message.isInbound) message.senderName ?: "Sender" else "Me") },
) {
val linkColor = MaterialTheme.colorScheme.primary
val annotatedText = remember(message.content, linkColor) {
linkifyString(text = message.content, linkColor = linkColor)
}
val annotatedText =
remember(message.content, linkColor) {
linkifyString(text = message.content, linkColor = linkColor)
}
Text(text = annotatedText)
}
}
Expand Down
5 changes: 5 additions & 0 deletions agent/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root = true

[*.{kt,kts}]
ktlint_code_style = ktlint_official
ktlint_function_naming_ignore_when_annotated_with = Composable
2 changes: 1 addition & 1 deletion agent/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {

defaultConfig {
applicationId = "com.example.appfunctions.agent"
minSdk = 35
minSdk = 36
targetSdk = 37
versionCode = 1
versionName = "0.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import kotlinx.serialization.json.Json
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Assume.assumeTrue
import org.junit.Before
import org.junit.Test

Expand All @@ -58,7 +59,7 @@ abstract class LlmProviderIntegrationTestBase {
fun setUp() {
val arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments()
apiKey = arguments.getString(apiKeyArgumentKey) ?: ""
assertTrue(
assumeTrue(
"API key is required. Please provide it via instrumentation arguments.",
apiKey.isNotEmpty() && apiKey != "PLACEHOLDER",
)
Expand Down
Loading
Loading