Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split service and client examples #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
3 changes: 0 additions & 3 deletions app/src/main/res/values/strings.xml

This file was deleted.

4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"

classpath 'com.vanniktech:gradle-maven-publish-plugin:0.15.1'
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.4.32'
Expand Down
File renamed without changes.
25 changes: 12 additions & 13 deletions app/build.gradle → client-app-example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ plugins {
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
compileSdkVersion 33
buildToolsVersion "33.0.0"

defaultConfig {
applicationId "com.softbankrobotics.planning"
applicationId "com.softbankrobotics.pddlplanning.example.client"
minSdkVersion 23
targetSdkVersion 30
targetSdkVersion 33
versionCode 1
versionName "1.0"

Expand All @@ -33,14 +33,13 @@ android {
}

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.0"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.7.10'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation project(path: ':pddl-planning')
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
File renamed without changes.
33 changes: 33 additions & 0 deletions client-app-example/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.softbankrobotics.pddlplanning.example.client">

<!-- To be allowed to bind the planner service -->
<uses-permission android:name="com.softbankrobotics.planning.SEARCH_PLANS" />

<!-- To see the planner service -->
<queries>
<package android:name="com.commonsware.android.r.embed.server" />
<intent>
<action android:name="com.softbankrobotics.planning.action.SEARCH_PLANS_FROM_PDDL" />
</intent>
<package android:name="com.softbankrobotics.pddlplanning.example.service" />
</queries>

<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Planning">
<activity
android:name=".ExampleClientActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.softbankrobotics.pddlplanning.example.client

import android.content.Intent
import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.softbankrobotics.pddlplanning.IPDDLPlannerService
import com.softbankrobotics.pddlplanning.PermissionCheckFunction
import com.softbankrobotics.pddlplanning.createPlanSearchFunctionFromService
import com.softbankrobotics.pddlplanning.createPlannerPermissionChecker
import com.softbankrobotics.pddlplanning.utils.createAsyncCoroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking

private const val plannerServicePackage = "com.softbankrobotics.pddlplanning.example.service"

class ExampleClientActivity : AppCompatActivity() {

private val coroutineScope = createAsyncCoroutineScope()
private lateinit var permissionCheckFunction: PermissionCheckFunction

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_example_main)
permissionCheckFunction = createPlannerPermissionChecker(this, plannerServicePackage)
}

override fun onResume() {
super.onResume()
val mainText = findViewById<TextView>(R.id.mainText)
mainText.text = "Searching plan..."
val checkingPermission = permissionCheckFunction()
coroutineScope.launch {
checkingPermission.await()
val plannerServiceIntent = Intent(IPDDLPlannerService.ACTION_SEARCH_PLANS_FROM_PDDL)
plannerServiceIntent.`package` = plannerServicePackage
val planSearchFunction =
createPlanSearchFunctionFromService(
this@ExampleClientActivity,
plannerServiceIntent
)
val domain = "(define (domain hello_domain)\n" +
" (:requirements :adl :negative-preconditions :universal-preconditions)\n" +
" (:types)\n" +
" (:constants)\n"
" (:predicates\n" +
" (was_greeted ?o)\n" +
" )\n" +
" (:action hello\n" +
" :parameters (?o)\n" +
" :precondition ()\n" +
" :effect (was_greeted ?o)\n" +
" )\n" +
")"

val problem = "(define (problem hello_problem)\n" +
" (:domain hello_domain)\n" +
" (:requirements :adl :negative-preconditions :universal-preconditions)\n" +
" (:objects\n" +
" world\n" +
" )\n" +
" (:init)\n"
" (:goal\n" +
" (forall (?o) (was_greeted ?o))\n" +
" )\n" +
")"

val plan = planSearchFunction(domain, problem, null)

runOnUiThread {
mainText.text = "Found plan:\n${plan.joinToString("\n")}"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ExampleMainActivity">
tools:context=".ExampleClientActivity">

<TextView
android:id="@+id/mainText"
Expand Down
3 changes: 3 additions & 0 deletions client-app-example/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">Planning Client Example</string>
</resources>
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official

android.disableAutomaticComponentCreation=true

GROUP=com.softbankrobotics.pddl
VERSION_NAME=1.4.1

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
19 changes: 9 additions & 10 deletions pddl-planning-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ plugins {
apply plugin: 'com.vanniktech.maven.publish'

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
compileSdkVersion 33
buildToolsVersion "33.0.0"

defaultConfig {
minSdkVersion 23
targetSdkVersion 30
versionName getProperty("VERSION_NAME")
targetSdkVersion 33

// Rename the output archives to identify them at a glance.
String artifactId = getProperty("POM_ARTIFACT_ID")
Expand Down Expand Up @@ -42,15 +41,15 @@ android {

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.20"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.10"
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'junit:junit:4.13.2' // We export test functions for planner implementations
implementation project(path: ':pddl-planning')
testImplementation 'junit:junit:4.13.2'
testImplementation "io.mockk:mockk:1.12.0"
testImplementation 'io.mockk:mockk:1.12.8'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "io.mockk:mockk-android:1.12.0"
androidTestImplementation 'io.mockk:mockk-android:1.12.8'
}
5 changes: 1 addition & 4 deletions pddl-planning-test/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.pddl_planning_test">

</manifest>
<manifest package="com.softbankrobotics.pddlplanning.test" />
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.softbankrobotics.pddlplanning.test

import android.content.Context
import android.util.Log
import com.example.pddl_planning_test.R
import com.softbankrobotics.pddlplanning.Expression
import com.softbankrobotics.pddlplanning.Task
import com.softbankrobotics.pddlplanning.Tasks
Expand Down
17 changes: 8 additions & 9 deletions pddl-planning/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ plugins {
apply plugin: 'com.vanniktech.maven.publish'

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
compileSdkVersion 33
buildToolsVersion "33.0.0"

defaultConfig {
minSdkVersion 23
targetSdkVersion 30
versionName getProperty("VERSION_NAME")
targetSdkVersion 33

// Rename the output archives to identify them at a glance.
String artifactId = getProperty("POM_ARTIFACT_ID")
Expand Down Expand Up @@ -43,11 +42,11 @@ android {

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.20"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.10"
api 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down
Loading