mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 21:31:26 +00:00
feat: add Google Assistant App Actions entrypoint
This commit is contained in:
@@ -49,6 +49,9 @@
|
||||
android:supportsRtl="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:theme="@style/Theme.OpenClawNode">
|
||||
<meta-data
|
||||
android:name="android.app.shortcuts"
|
||||
android:resource="@xml/shortcuts" />
|
||||
<service
|
||||
android:name=".NodeForegroundService"
|
||||
android:exported="false"
|
||||
|
||||
7
apps/android/app/src/main/res/values/assistant.xml
Normal file
7
apps/android/app/src/main/res/values/assistant.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<resources>
|
||||
<string-array name="ask_openclaw_query_patterns">
|
||||
<item>ask OpenClaw $prompt</item>
|
||||
<item>tell OpenClaw to $prompt</item>
|
||||
<item>open OpenClaw and ask $prompt</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
17
apps/android/app/src/main/res/xml/shortcuts.xml
Normal file
17
apps/android/app/src/main/res/xml/shortcuts.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<capability
|
||||
android:name="custom.actions.intent.ASK_OPENCLAW"
|
||||
app:queryPatterns="@array/ask_openclaw_query_patterns">
|
||||
<intent
|
||||
android:action="ai.openclaw.app.action.ASK_OPENCLAW"
|
||||
android:targetPackage="ai.openclaw.app"
|
||||
android:targetClass="ai.openclaw.app.MainActivity">
|
||||
<parameter
|
||||
android:name="prompt"
|
||||
android:key="prompt"
|
||||
android:mimeType="text/*"
|
||||
android:required="true" />
|
||||
</intent>
|
||||
</capability>
|
||||
</shortcuts>
|
||||
@@ -0,0 +1,39 @@
|
||||
package ai.openclaw.app
|
||||
|
||||
import android.content.Intent
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [34])
|
||||
class AssistantLaunchTest {
|
||||
@Test
|
||||
fun parsesAssistGestureIntent() {
|
||||
val parsed = parseAssistantLaunchIntent(Intent(Intent.ACTION_ASSIST))
|
||||
|
||||
requireNotNull(parsed)
|
||||
assertEquals("assist", parsed.source)
|
||||
assertNull(parsed.prompt)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parsesAppActionPrompt() {
|
||||
val parsed =
|
||||
parseAssistantLaunchIntent(
|
||||
Intent(actionAskOpenClaw).putExtra(extraAssistantPrompt, " summarize my unread texts "),
|
||||
)
|
||||
|
||||
requireNotNull(parsed)
|
||||
assertEquals("app_action", parsed.source)
|
||||
assertEquals("summarize my unread texts", parsed.prompt)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun ignoresUnrelatedIntents() {
|
||||
assertNull(parseAssistantLaunchIntent(Intent(Intent.ACTION_VIEW)))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user