Skip to content

Commit

Permalink
#6: Added Rx module and unimplemented interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
mihakrajnc committed Apr 22, 2017
1 parent 20f898c commit a0cbd73
Show file tree
Hide file tree
Showing 8 changed files with 298 additions and 1 deletion.
1 change: 1 addition & 0 deletions neatle-rx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
87 changes: 87 additions & 0 deletions neatle-rx/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* MIT License
*
* Copyright (c) 2017 Inova IT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

apply plugin: 'com.android.library'
apply from: '../jacoco.gradle'

ext {
artifactId = 'neatle-rx'
buildNumber = (System.getenv("TRAVIS_BUILD_NUMBER") ?: "1").toInteger()
getVersionName = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--long'
standardOutput = stdout
}
return stdout.toString().trim().find("(.+)(?=-\\d+-[a-z0-9]+)") ?: "0.0.1"
}
}

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
minSdkVersion 19
targetSdkVersion 25
versionCode buildNumber
versionName getVersionName()
}

lintOptions {
abortOnError false
ignoreWarnings true
}

testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
}

libraryVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(output.outputFile.parent, output.outputFile.name.replace("${artifactId}", "${artifactId}-${getVersionName()}"))
}
}
}

configurations {
javadocDeps
}

dependencies {
compile project(":neatle")
compile 'io.reactivex.rxjava2:rxjava:2.0.8'
compile 'com.android.support:support-annotations:25.3.1'
javadocDeps 'com.android.support:support-annotations:25.3.1'

testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.3.2'
testCompile "org.mockito:mockito-core:2.7.22"
}

//apply from: '../deploy.gradle'
25 changes: 25 additions & 0 deletions neatle-rx/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
~ MIT License
~
~ Copyright (c) 2017 Inova IT
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->

<manifest package="si.inova.neatle.rx" />
46 changes: 46 additions & 0 deletions neatle-rx/src/main/java/si/inova/neatle/rx/MonitorResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* MIT License
*
* Copyright (c) 2017 Inova IT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package si.inova.neatle.rx;

import si.inova.neatle.monitor.Connection;

public class MonitorResult {

private Connection connection;
private int newState;

public MonitorResult(Connection connection, int newState) {
this.connection = connection;
this.newState = newState;
}

public Connection getConnection() {
return connection;
}

public int getNewState() {
return newState;
}
}
53 changes: 53 additions & 0 deletions neatle-rx/src/main/java/si/inova/neatle/rx/NeatleRx.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* MIT License
*
* Copyright (c) 2017 Inova IT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package si.inova.neatle.rx;

import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.support.annotation.NonNull;

import java.util.HashMap;

import io.reactivex.Observable;
import si.inova.neatle.operation.CommandResult;

public class NeatleRx {

private static HashMap<String, Observable<MonitorResult>> connectionMonitors = new HashMap<>();

public static Observable<MonitorResult> getConnectionMonitor(@NonNull Context context, @NonNull BluetoothDevice device) {
// TODO: Add implementation
return null;
}

public static Observable<CommandResult> getSubscription(@NonNull Context context, @NonNull BluetoothDevice device) {
// TODO: Add implementation
return null;
}

public static RxOperationBuilder createOperationBuilder(@NonNull Context context) {
return new RxOperationBuilder(context);
}
}
44 changes: 44 additions & 0 deletions neatle-rx/src/main/java/si/inova/neatle/rx/RxOperationBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* MIT License
*
* Copyright (c) 2017 Inova IT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package si.inova.neatle.rx;

import android.bluetooth.BluetoothDevice;
import android.content.Context;

import io.reactivex.Observable;
import si.inova.neatle.operation.CommandResult;
import si.inova.neatle.operation.OperationBuilder;

public class RxOperationBuilder extends OperationBuilder {

RxOperationBuilder(Context context) {
super(context);
}

public Observable<CommandResult> buildReactive(BluetoothDevice device) {
//TODO: Add implementation
return null;
}
}
41 changes: 41 additions & 0 deletions neatle-rx/src/test/java/si/inova/neatle/rx/ExampleUnitTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* MIT License
*
* Copyright (c) 2017 Inova IT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package si.inova.neatle.rx;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
* SOFTWARE.
*/

include ':neatle', ':sample'
include ':neatle', ':sample', ':neatle-rx'

0 comments on commit a0cbd73

Please sign in to comment.