Commit dc2558ef authored by Philipp Auersperg's avatar Philipp Auersperg

...

parent dfd6aef3
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeSettings">
<configurations>
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
......
......@@ -37,5 +37,6 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:design:28.0.0'
}
......@@ -29,5 +29,10 @@ class MainActivity : AppCompatActivity() {
}
}
}
btnSubmit.setOnClickListener {
val res=ProcbridgeClient.request(editCommand.text.toString(), editParams.text.toString())
txtMessage.text=res.toString()
}
}
}
......@@ -4,6 +4,7 @@ import co.gongzh.procbridge.MessageHandler
import co.gongzh.procbridge.ProcBridge
import co.gongzh.procbridge.ProcBridgeException
import com.google.gson.JsonObject
import kotlinx.coroutines.*
object ProcbridgeClient {
lateinit var pb:ProcBridge
......@@ -24,5 +25,16 @@ object ProcbridgeClient {
fun connect(host:String, port:Int=8077, timeout:Int =1000) {
pb = ProcBridge(host, port, timeout, messageHandlerImpl)
}
fun request(api:String, params:String): JsonObject {
println("request before:$api")
val res = runBlocking (Dispatchers.IO){
pb.sendMessage(api, "{$params}")
}
println("request after:$res")
val rres=res.get()!!
println("res.get()=$rres")
return rres
}
}
......@@ -5,7 +5,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
tools:context=".MainActivity" android:background="@color/colorBackground">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -15,7 +15,7 @@
android:id="@+id/editHost" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"
android:hint="Host" android:layout_marginTop="60dp" app:layout_constraintTop_toBottomOf="@+id/txtStatus"/>
android:hint="Host" android:layout_marginTop="16dp" app:layout_constraintTop_toBottomOf="@+id/txtStatus"/>
<Button
android:text="connect"
android:layout_width="wrap_content"
......@@ -24,7 +24,7 @@
android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
app:layout_constraintHorizontal_bias="0.498" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/editPort"/>
app:layout_constraintTop_toBottomOf="@+id/editPort" android:background="@color/colorPrimary"/>
<TextView
android:text="disconnected"
android:layout_width="wrap_content"
......@@ -43,9 +43,56 @@
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"/>
<TextView
android:layout_width="232dp"
android:layout_height="158dp"
android:layout_height="0dp"
android:id="@+id/txtMessage" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/btnConnect"/>
app:layout_constraintTop_toBottomOf="@+id/btnConnect" android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/textView" android:background="#ffffff"/>
<TextView
android:text="command"
android:layout_width="wrap_content"
android:layout_height="19dp"
android:id="@+id/textView"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/constraintLayout"/>
<android.support.constraint.ConstraintLayout
android:layout_width="0dp"
android:layout_height="47dp" android:layout_marginEnd="32dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="32dp" android:id="@+id/constraintLayout" android:layout_marginBottom="16dp"
app:layout_constraintBottom_toTopOf="@+id/btnSubmit">
<EditText
android:layout_width="85dp"
android:layout_height="0dp"
android:inputType="textPersonName"
android:text="echo"
android:ems="10"
android:id="@+id/editCommand"
android:textSize="14sp" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent"/>
<EditText
android:layout_width="0dp"
android:layout_height="0dp"
android:inputType="textPersonName"
android:text="echo:hi"
android:ems="10"
android:id="@+id/editParams"
app:layout_constraintStart_toEndOf="@+id/editCommand" android:layout_marginStart="16dp"
app:layout_constraintEnd_toEndOf="parent" android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
<Button
android:text="submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnSubmit" android:background="@color/colorPrimary"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:layout_marginBottom="56dp" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.498"/>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
......@@ -3,4 +3,5 @@
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="colorBackground">#C0DBC1</color>
</resources>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment