-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #793 from dariuszseweryn/develop
RxJava 3 modules with source generation
- Loading branch information
Showing
37 changed files
with
580 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
# Recommended pre-commit hook for people releasing RxAndroidBle | ||
# This script updates all README.md files with the current value of VERSION_NAME specified in | ||
# $root/gradle.properties when following conditions are met: | ||
# - this script is run on the release branch | ||
# - the VERSION_NAME has changed | ||
# - the VERSION_NAME is not a "SNAPSHOT" release | ||
|
||
# Check if on release branch | ||
current_branch="$(git branch --show-current)" | ||
release_branch='master' | ||
echo current_branch: "$current_branch", release_branch: "$release_branch" | ||
if [[ $current_branch != "$release_branch" ]]; then | ||
exit 0 | ||
fi | ||
echo not equal | ||
|
||
# Check if VERSION_NAME changed | ||
this_script_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
root_project_path="${this_script_path%/*}" | ||
git stash -m "PRE-COMMIT-VERSIONS-CHANGE-CHECK-PREPARE" --keep-index --include-untracked | ||
git stash -m "PRE-COMMIT-VERSIONS-CHANGE-CHECK" | ||
version_name_line=$(grep ^VERSION_NAME= "$root_project_path"/gradle.properties) | ||
version_name_old=${version_name_line##*=} | ||
git stash pop | ||
git add . | ||
git stash pop | ||
version_name_line=$(grep ^VERSION_NAME= "$root_project_path"/gradle.properties) | ||
version_name_new=${version_name_line##*=} | ||
if [[ $version_name_old -eq $version_name_new ]]; then | ||
exit 0 | ||
fi | ||
|
||
# Check if VERSION_NAME is not SNAPSHOT | ||
if [[ $version_name_new == *"SNAPSHOT"* ]]; then | ||
exit 0 | ||
fi | ||
|
||
# Update version for gradle and maven in all README.md files | ||
git stash -m "PRE-COMMIT-HOOK-STASH" --keep-index | ||
find "$root_project_path" -name README.md \ | ||
-exec sed -i '' \ | ||
-e "s~\(.*implementation .*:\)\(.*\)\(\\\"\)~\1$version_name_new\3~g" \ | ||
-e "s~\(.*<version>\)\(.*\)\(<\/version>\)~\1$version_name_new\3~g" {} ";" \ | ||
-exec git add {} ";" | ||
git stash pop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// generates sources compatible with RxJava 2 to RxJava 3 | ||
|
||
copy { | ||
from "../${project.name.substring(0, project.name.length() - 1)}/src" | ||
into 'src' | ||
includeEmptyDirs = false | ||
eachFile { | ||
name = name.replace('rxandroidble2', 'rxandroidble3') | ||
path = path.replace('rxandroidble2', 'rxandroidble3') | ||
filter { | ||
it.replace('rxandroidble2', 'rxandroidble3') | ||
.replaceAll('io\\.reactivex\\.([a-z]+)', 'io.reactivex.rxjava3.$1') | ||
.replaceAll('io\\.reactivex\\.([A-Z][a-z]+)', 'io.reactivex.rxjava3.core.$1') | ||
.replace('import io.reactivex.rxjava3.disposables.Disposables', 'import io.reactivex.rxjava3.disposables.Disposable') | ||
.replace('Disposables.fromAction', 'Disposable.fromAction') | ||
.replace('Disposables.empty()', 'Disposable.empty()') | ||
.replace('com.jakewharton.rxrelay2.BehaviorRelay', 'com.jakewharton.rxrelay3.BehaviorRelay') | ||
.replace('.startWith(', '.startWithItem(') | ||
.replace('import com.jakewharton.rxrelay2', 'import com.jakewharton.rxrelay3') | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
'src' is generated from 'mockrxandroidble' by script in 'gradle/src-gen-rxjava3-from-rxjava2.gradle' | ||
|
||
MockRxAndroidBle | ||
============= | ||
|
||
This project allows to mock a Bluetooth LE device. It's supposed to be used with RxAndroidBle library. | ||
|
||
|
||
### Example | ||
|
||
Using MockRxAndroidBle you can start writing and testing your Bluetooth code having just the device's specification. | ||
|
||
Here's an example: | ||
|
||
```java | ||
RxBleClient rxBleClientMock = new RxBleClientMock.Builder() | ||
.addDevice(new RxBleDeviceMock.Builder() // <-- creating device mock, there can me multiple of them | ||
.deviceMacAddress(macAddress) | ||
.deviceName(deviceName) | ||
.scanRecord(new RxBleScanRecordMock.Builder() | ||
.setAdvertiseFlags(1) | ||
.addServiceUuid(new ParcelUuid(serviceUUID)) | ||
.addServiceUuid(new ParcelUuid(serviceUUID2)) | ||
.addManufacturerSpecificData(0x2211, [0x33, 0x44] as byte[]) | ||
.addServiceData(new ParcelUuid(serviceUUID), [0x11, 0x22] as byte[]) | ||
.setTxPowerLevel(12) | ||
.setDeviceName("TestDeviceAdv") | ||
.build() | ||
) | ||
.connection(new RxBleConnectionMock.Builder() // <-- creating connection mock | ||
.rssi(rssi) | ||
.notificationSource(characteristicNotifiedUUID, characteristicNotificationSubject) | ||
.addService( // <-- adding service mocks to the device, there can be multiple of them | ||
serviceUUID, | ||
new RxBleClientMock.CharacteristicsBuilder() | ||
.addCharacteristic( // <-- adding characteristic mocks to the service, there can be multiple of them | ||
characteristicUUID, | ||
characteristicData, | ||
new RxBleClientMock.DescriptorsBuilder() | ||
.addDescriptor(descriptorUUID, descriptorData) // <-- adding descriptor mocks | ||
.build() // to the characteristic, there can be multiple of them | ||
).build() | ||
).characteristicReadCallback(characteristicUUID, (device, characteristic, result) -> { | ||
result.success(characteristicValue); | ||
}) | ||
.characteristicWriteCallback(characteristicUUID, (device, characteristic, bytes, result) -> { | ||
if(writeData(characteristic, bytes)) { | ||
result.success(); | ||
} else { | ||
result.failure(0x80); | ||
// can also use result.disconnect(0x80); | ||
} | ||
}).build() | ||
).build() | ||
).build(); | ||
|
||
// Now mocked client can be used the same way as RxAndroidBle client | ||
``` | ||
|
||
### Download | ||
|
||
Get MockRxAndroidBle via Maven: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.polidea.rxandroidble3</groupId> | ||
<artifactId>mockclient</artifactId> | ||
<version>1.14.1</version> | ||
<type>aar</type> | ||
</dependency> | ||
``` | ||
|
||
or via Gradle | ||
|
||
```groovy | ||
implementation "com.polidea.rxandroidble3:mockclient:1.14.1" | ||
``` | ||
|
||
### License | ||
|
||
Copyright 2016 Polidea Sp. z o.o | ||
Copyright 2021 Dariusz Seweryn | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
Oops, something went wrong.