Skip to content

Commit

Permalink
V 2.0.0 -- Kotlin support with suspendable remote functions
Browse files Browse the repository at this point in the history
  • Loading branch information
josesamuel committed Feb 14, 2020
1 parent ad6fd53 commit f2d91cf
Show file tree
Hide file tree
Showing 118 changed files with 8,746 additions and 240 deletions.
1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change Log
==========

Version 2.0.0 *(2020-02-13)*
----------------------------
Kotlin suspend function support!


Version 1.2.6 *(2020-01-25)*
----------------------------
Proxy equals now match with the id of the stub process it wraps
Expand Down
78 changes: 74 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ public interface ISampleService {
* No messy **.aidl**, just plain simple **interface**
* Implement the interface directly using intuitive normal java way, instead of extending Stub
* **Fully interoperable with AIDL**. Remoter creates the same serialized data as created by AIDL, so it is fully interoperable with AIDL
* Supports more data types than AIDL, everything supported by Parcel
* Supports more data types than AIDL, everything supported by [Parceler](https://github.com/johncarl81/parceler)
* Make an interface that extends other interfaces as @Remoter
* Interface methods can throw any exceptions. Clients will get the same exception that is thrown.
* Remoter interface can be templated
* Remoter is an **annotation processor** that generates two helper classes during build time -- a client side Proxy and a service side Stub that allows you to wrap your interface and implementation
* **Support kotlin coroutines!**


**At the client side**
Expand Down Expand Up @@ -72,6 +73,69 @@ That's it!
* **@ParamIn** Mark an array or Parcelable parameter as an **input only** parameter(**in** of aidl). By **default** they are **input and output** (inout of aidl)
* **@ParamOut** Mark an array or Parcelable parameter as an **output only** parameter(**out** of aidl).
* **@Oneway** Annotate on a method (in the @Remoter interface) with void return to make it an asynchronous method.
* **@NullableType** Used to annotate a type parameter or suspend function return as nullable. See below for more details



##Kotlin Support with suspend functions

Remoter supports Kotlin interfaces with suspend functions. If your interface (marked with @Remoter) has any suspend functions, then the generated Proxy and Stub will be in Kotlin, enabling to call your remoter service method from coroutines.

* The suspend functions will be dispatched using the Dispatcher.IO context
* Kotlin Proxy can be created using the optional constructor that accepts IServiceConnector which moves service connection to a suspendable coroutine

##### Kotlin Example

* Define interface in kotlin as suspend

```kotlin
@Remoter
interface ISampleService {

/**
* A suspend function which will be implemented by a service
*/
suspend fun authenticate(userName:String, password:String) : Boolean
}

```

* Include the depednecy for RemoterBuilder to take advantage of suspended service connection

```kotlin
implementation 'com.josesamuel:remoter-builder:<VERSION>'
```

* From your coroutine, call the remote service call as follows

```kotlin

//From your coroutine context -

//create service using serviceintent
val service = ISampleService_Proxy(context, SERVICE_INTENT)

//call the suspend function
val authenticated = service.authenticate(userName, password)

//The above call will
- suspend the current context
- connect to service,
- make the remote call,

all sequentially without blocking the calling thread!

```

* No need to take care of service connection!
* No need to move to background thread for service call and then to main thred to update UI!



##### Notes on Kotlin support
* vararg is not supported. Either use array or non suspend
* If any return is nullable type on a suspend function, explicitly mark the method with @NullableType
* If any types in a generic parameter is nullable, explicitly mnark those parameter with @NullableType optionally specifying which indexex of that type parameter are nullable



Expand All @@ -82,10 +146,16 @@ Gradle dependency

```groovy
dependencies {
implementation 'com.josesamuel:remoter-annotations:1.2.7'
annotationProcessor 'com.josesamuel:remoter:1.2.7'
implementation 'com.josesamuel:remoter-annotations:2.0.0'
kapt 'com.josesamuel:remoter:2.0.0'
//If using kotlin coroutines, include following
//to make even the service connection simpler -
implementation 'com.josesamuel:remoter-builder:2.0.0'
//If any of the parameters are @Parcel, include depedencies for @Parcel
}
```

Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@


buildscript {
ext.kotlin_version = '1.3.61'
ext.versions = [
'minSdk' : 9,
'compileSdk': 26,
Expand Down Expand Up @@ -40,6 +41,7 @@ buildscript {
}
dependencies {
classpath deps.android.gradlePlugin
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GROUP=com.josesamuel
VERSION_NAME=1.2.7
VERSION_CODE=17
VERSION_NAME=2.0.0
VERSION_CODE=20

POM_DESCRIPTION=Remoter makes developing android remote services intuitive without messing with aidl.

Expand Down
15 changes: 11 additions & 4 deletions gradle/gradle-mvn-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,21 @@ afterEvaluate { project ->
}
}

task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.source
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
// task androidJavadocs(type: Javadoc) {
// source = android.sourceSets.main.java.source
// classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
// }

task androidJavadocs(dependsOn: dokka) {
// source = android.sourceSets.main.java.source
// classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}


task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
//from androidJavadocs.destinationDir
from dokka.outputDirectory
}

task androidSourcesJar(type: Jar) {
Expand Down
2 changes: 0 additions & 2 deletions javadoc/META-INF/MANIFEST.MF

This file was deleted.

8 changes: 5 additions & 3 deletions javadoc/allclasses-frame.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_152) on Fri Feb 02 21:39:38 CST 2018 -->
<title>All Classes (remoter-annotations 1.1.5 API)</title>
<meta name="date" content="2018-02-02">
<!-- Generated by javadoc (1.8.0_191) on Thu Feb 13 21:59:59 CST 2020 -->
<title>All Classes (remoter-annotations 2.0.0 API)</title>
<meta name="date" content="2020-02-13">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<h1 class="bar">All&nbsp;Classes</h1>
<div class="indexContainer">
<ul>
<li><a href="remoter/annotations/NullableType.html" title="annotation in remoter.annotations" target="classFrame">NullableType</a></li>
<li><a href="remoter/annotations/Oneway.html" title="annotation in remoter.annotations" target="classFrame">Oneway</a></li>
<li><a href="remoter/annotations/ParamIn.html" title="annotation in remoter.annotations" target="classFrame">ParamIn</a></li>
<li><a href="remoter/annotations/ParamOut.html" title="annotation in remoter.annotations" target="classFrame">ParamOut</a></li>
<li><a href="remoter/annotations/Remoter.html" title="annotation in remoter.annotations" target="classFrame">Remoter</a></li>
<li><a href="remoter/RemoterProxy.html" title="interface in remoter" target="classFrame"><span class="interfaceName">RemoterProxy</span></a></li>
<li><a href="remoter/RemoterProxyListener.html" title="interface in remoter" target="classFrame"><span class="interfaceName">RemoterProxyListener</span></a></li>
<li><a href="remoter/RemoterStub.html" title="interface in remoter" target="classFrame"><span class="interfaceName">RemoterStub</span></a></li>
</ul>
</div>
</body>
Expand Down
8 changes: 5 additions & 3 deletions javadoc/allclasses-noframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_152) on Fri Feb 02 21:39:38 CST 2018 -->
<title>All Classes (remoter-annotations 1.1.5 API)</title>
<meta name="date" content="2018-02-02">
<!-- Generated by javadoc (1.8.0_191) on Thu Feb 13 21:59:59 CST 2020 -->
<title>All Classes (remoter-annotations 2.0.0 API)</title>
<meta name="date" content="2020-02-13">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<h1 class="bar">All&nbsp;Classes</h1>
<div class="indexContainer">
<ul>
<li><a href="remoter/annotations/NullableType.html" title="annotation in remoter.annotations">NullableType</a></li>
<li><a href="remoter/annotations/Oneway.html" title="annotation in remoter.annotations">Oneway</a></li>
<li><a href="remoter/annotations/ParamIn.html" title="annotation in remoter.annotations">ParamIn</a></li>
<li><a href="remoter/annotations/ParamOut.html" title="annotation in remoter.annotations">ParamOut</a></li>
<li><a href="remoter/annotations/Remoter.html" title="annotation in remoter.annotations">Remoter</a></li>
<li><a href="remoter/RemoterProxy.html" title="interface in remoter"><span class="interfaceName">RemoterProxy</span></a></li>
<li><a href="remoter/RemoterProxyListener.html" title="interface in remoter"><span class="interfaceName">RemoterProxyListener</span></a></li>
<li><a href="remoter/RemoterStub.html" title="interface in remoter"><span class="interfaceName">RemoterStub</span></a></li>
</ul>
</div>
</body>
Expand Down
8 changes: 4 additions & 4 deletions javadoc/constant-values.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_152) on Fri Feb 02 21:39:38 CST 2018 -->
<title>Constant Field Values (remoter-annotations 1.1.5 API)</title>
<meta name="date" content="2018-02-02">
<!-- Generated by javadoc (1.8.0_191) on Thu Feb 13 21:59:59 CST 2020 -->
<title>Constant Field Values (remoter-annotations 2.0.0 API)</title>
<meta name="date" content="2020-02-13">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Constant Field Values (remoter-annotations 1.1.5 API)";
parent.document.title="Constant Field Values (remoter-annotations 2.0.0 API)";
}
}
catch(err) {
Expand Down
8 changes: 4 additions & 4 deletions javadoc/deprecated-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_152) on Fri Feb 02 21:39:38 CST 2018 -->
<title>Deprecated List (remoter-annotations 1.1.5 API)</title>
<meta name="date" content="2018-02-02">
<!-- Generated by javadoc (1.8.0_191) on Thu Feb 13 21:59:59 CST 2020 -->
<title>Deprecated List (remoter-annotations 2.0.0 API)</title>
<meta name="date" content="2020-02-13">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Deprecated List (remoter-annotations 1.1.5 API)";
parent.document.title="Deprecated List (remoter-annotations 2.0.0 API)";
}
}
catch(err) {
Expand Down
8 changes: 4 additions & 4 deletions javadoc/help-doc.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_152) on Fri Feb 02 21:39:38 CST 2018 -->
<title>API Help (remoter-annotations 1.1.5 API)</title>
<meta name="date" content="2018-02-02">
<!-- Generated by javadoc (1.8.0_191) on Thu Feb 13 21:59:59 CST 2020 -->
<title>API Help (remoter-annotations 2.0.0 API)</title>
<meta name="date" content="2020-02-13">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="API Help (remoter-annotations 1.1.5 API)";
parent.document.title="API Help (remoter-annotations 2.0.0 API)";
}
}
catch(err) {
Expand Down
44 changes: 38 additions & 6 deletions javadoc/index-all.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_152) on Fri Feb 02 21:39:38 CST 2018 -->
<title>Index (remoter-annotations 1.1.5 API)</title>
<meta name="date" content="2018-02-02">
<!-- Generated by javadoc (1.8.0_191) on Thu Feb 13 21:59:59 CST 2020 -->
<title>Index (remoter-annotations 2.0.0 API)</title>
<meta name="date" content="2020-02-13">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Index (remoter-annotations 1.1.5 API)";
parent.document.title="Index (remoter-annotations 2.0.0 API)";
}
}
catch(err) {
Expand Down Expand Up @@ -68,7 +68,25 @@
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="contentContainer"><a href="#I:I">I</a>&nbsp;<a href="#I:O">O</a>&nbsp;<a href="#I:P">P</a>&nbsp;<a href="#I:R">R</a>&nbsp;<a href="#I:U">U</a>&nbsp;<a name="I:I">
<div class="contentContainer"><a href="#I:D">D</a>&nbsp;<a href="#I:I">I</a>&nbsp;<a href="#I:N">N</a>&nbsp;<a href="#I:O">O</a>&nbsp;<a href="#I:P">P</a>&nbsp;<a href="#I:R">R</a>&nbsp;<a href="#I:U">U</a>&nbsp;<a name="I:D">
<!-- -->
</a>
<h2 class="title">D</h2>
<dl>
<dt><span class="memberNameLink"><a href="remoter/RemoterProxy.html#destroyProxy--">destroyProxy()</a></span> - Method in interface remoter.<a href="remoter/RemoterProxy.html" title="interface in remoter">RemoterProxy</a></dt>
<dd>
<div class="block">Call to destroy the proxy.</div>
</dd>
<dt><span class="memberNameLink"><a href="remoter/RemoterProxy.html#destroyStub-java.lang.Object-">destroyStub(Object)</a></span> - Method in interface remoter.<a href="remoter/RemoterProxy.html" title="interface in remoter">RemoterProxy</a></dt>
<dd>
<div class="block">Destroys any stub created while sending the given object through this proxy.</div>
</dd>
<dt><span class="memberNameLink"><a href="remoter/RemoterStub.html#destroyStub--">destroyStub()</a></span> - Method in interface remoter.<a href="remoter/RemoterStub.html" title="interface in remoter">RemoterStub</a></dt>
<dd>
<div class="block">Destroys this stub.</div>
</dd>
</dl>
<a name="I:I">
<!-- -->
</a>
<h2 class="title">I</h2>
Expand All @@ -78,6 +96,16 @@ <h2 class="title">I</h2>
<div class="block">Checks whether the remote side is still alive</div>
</dd>
</dl>
<a name="I:N">
<!-- -->
</a>
<h2 class="title">N</h2>
<dl>
<dt><a href="remoter/annotations/NullableType.html" title="annotation in remoter.annotations"><span class="typeNameLink">NullableType</span></a> - Annotation Type in <a href="remoter/annotations/package-summary.html">remoter.annotations</a></dt>
<dd>
<div class="block">Marks which of the types in a type parameter are nullable</div>
</dd>
</dl>
<a name="I:O">
<!-- -->
</a>
Expand Down Expand Up @@ -134,6 +162,10 @@ <h2 class="title">R</h2>
<dd>
<div class="block">Listener to get notified about changes in a <a href="remoter/RemoterProxy.html" title="interface in remoter"><code>RemoterProxy</code></a></div>
</dd>
<dt><a href="remoter/RemoterStub.html" title="interface in remoter"><span class="typeNameLink">RemoterStub</span></a> - Interface in <a href="remoter/package-summary.html">remoter</a></dt>
<dd>
<div class="block">Represents a remote stub.</div>
</dd>
</dl>
<a name="I:U">
<!-- -->
Expand All @@ -145,7 +177,7 @@ <h2 class="title">U</h2>
<div class="block">Un register a <a href="remoter/RemoterProxyListener.html" title="interface in remoter"><code>RemoterProxyListener</code></a></div>
</dd>
</dl>
<a href="#I:I">I</a>&nbsp;<a href="#I:O">O</a>&nbsp;<a href="#I:P">P</a>&nbsp;<a href="#I:R">R</a>&nbsp;<a href="#I:U">U</a>&nbsp;</div>
<a href="#I:D">D</a>&nbsp;<a href="#I:I">I</a>&nbsp;<a href="#I:N">N</a>&nbsp;<a href="#I:O">O</a>&nbsp;<a href="#I:P">P</a>&nbsp;<a href="#I:R">R</a>&nbsp;<a href="#I:U">U</a>&nbsp;</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
Expand Down
4 changes: 2 additions & 2 deletions javadoc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_152) on Fri Feb 02 21:39:38 CST 2018 -->
<title>remoter-annotations 1.1.5 API</title>
<!-- Generated by javadoc (1.8.0_191) on Thu Feb 13 21:59:59 CST 2020 -->
<title>remoter-annotations 2.0.0 API</title>
<script type="text/javascript">
tmpTargetPage = "" + window.location.search;
if (tmpTargetPage != "" && tmpTargetPage != "undefined")
Expand Down
Loading

0 comments on commit f2d91cf

Please sign in to comment.