Skip to content

Commit 73da821

Browse files
committed
add ci
remove rx add livedata
1 parent 83d1f62 commit 73da821

File tree

13 files changed

+228
-268
lines changed

13 files changed

+228
-268
lines changed

.github/workflows/code-style.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
- develop
6+
pull_request:
7+
8+
name: Code Style
9+
10+
jobs:
11+
spotless-check:
12+
name: Spotless Style Check
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- uses: actions/setup-java@v1
19+
with:
20+
java-version: 1.8
21+
22+
- uses: actions/cache@v1
23+
with:
24+
path: ~/.gradle/caches
25+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
26+
restore-keys: |
27+
${{ runner.os }}-gradle-
28+
29+
- run: ./gradlew spotlessCheck
30+
31+
32+
lint:
33+
name: Android Lint
34+
runs-on: ubuntu-latest
35+
36+
steps:
37+
- uses: actions/checkout@v2
38+
39+
- uses: actions/setup-java@v1
40+
with:
41+
java-version: 1.8
42+
43+
- uses: actions/cache@v1
44+
with:
45+
path: ~/.gradle/caches
46+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
47+
restore-keys: |
48+
${{ runner.os }}-gradle-
49+
50+
- run: ./gradlew lint

.github/workflows/tests.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
- develop
6+
pull_request:
7+
8+
name: Tests
9+
10+
jobs:
11+
gradle-test:
12+
name: Gradle Test
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 15
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- uses: actions/setup-java@v1
20+
with:
21+
java-version: 1.8
22+
23+
- uses: actions/cache@v1
24+
with:
25+
path: ~/.gradle/caches
26+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
27+
restore-keys: |
28+
${{ runner.os }}-gradle-
29+
30+
- run: ./gradlew :cleanTest :test

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Unreleased
2+
3+
# Version 1.1.0
4+
> 2021-06-09
5+
- Expose `WifiLiveData`
6+
- Remove RxJava dependency

README.md

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,50 @@
11
# WiFiMonitor
2+
[![](https://jitpack.io/v/Kuama-IT/android-kotlin-wifi-watcher.svg)](https://jitpack.io/#Kuama-IT/android-kotlin-wifi-watcher)
3+
24
Allows you to watch for wi-fi changes on an Android device.
35

46
```kotlin
5-
val monitor = WifiMonitor.Builder().context(aContext).build()
6-
7-
subscribe = monitor.info.subscribe {
8-
println("${it.state.name} - ${it.ssid} - ${it.bssid} - ${it.rssi}")
7+
class WiFiViewModel(context: Context) : ViewModel() {
8+
val values = WifiLiveData(WifiMonitor(context))
99
}
1010

11-
```
12-
don't forget to unsubscribe when you don't need it anymore
13-
```kotlin
14-
override fun onPause() {
15-
super.onPause()
16-
if (subscribe?.isDisposed == false) {
17-
subscribe?.dispose()
11+
class MainActivity : AppCompatActivity() {
12+
override fun onCreate(savedInstanceState: Bundle?) {
13+
super.onCreate(savedInstanceState)
14+
setContentView(R.layout.activity_main)
15+
16+
val viewModel = WiFiViewModel(this)
17+
18+
viewModel.values.observe(this) {
19+
println(it.band)
20+
println(it.bssid)
21+
println(it.state.name)
22+
}
1823
}
1924
}
25+
2026
```
2127

2228
### Do I need a context?
23-
Sadly yes, to bootstrap the library you will need a valid context:
29+
Sadly yes, to bootstrap the library you will need a valid context.
2430

25-
```kotlin
26-
WifiMonitor.Builder().context(this).build() // this is a context (eg. activity)
31+
### Installation
32+
Add the JitPack repository to your build file
2733
```
34+
allprojects {
35+
repositories {
36+
...
37+
maven { url 'https://jitpack.io' }
38+
}
39+
}
40+
```
41+
Add the dependency
2842

29-
### Can I subscribe multiple times?
30-
Yes, the `info` object is a `ConnectableObservable`
31-
43+
```
44+
dependencies {
45+
implementation 'com.github.Kuama-IT:android-kotlin-wifi-watcher:Tag'
46+
}
47+
```
3248
### Which states could I get?
3349

3450
#### `CONNECTED`

build.gradle

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,75 @@
11

22
buildscript {
3-
ext.kotlin_version = '1.3.72'
3+
ext.kotlin_version = "1.5.10"
44
repositories {
55
google()
6-
jcenter()
7-
}
6+
mavenCentral()
87
dependencies {
9-
classpath "com.android.tools.build:gradle:4.0.0"
8+
classpath "com.android.tools.build:gradle:4.2.1"
109
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
classpath "com.diffplug.spotless:spotless-plugin-gradle:4.4.0"
10+
classpath "com.diffplug.spotless:spotless-plugin-gradle:5.12.5"
1211
}
1312
}
1413

1514
allprojects {
1615
repositories {
1716
google()
18-
jcenter()
19-
maven { url 'https://jitpack.io' }
17+
mavenCentral()
18+
maven { url "https://jitpack.io" }
19+
}
20+
}
21+
22+
ext {
23+
artifactId = 'wifi-watcher'
24+
groupId = 'net.kuama.android'
25+
compile_sdk_version = 30
26+
min_sdk_version = 21
27+
target_sdk_version = 30
28+
version_code = project.property("version_code").toInteger()
29+
version_name = project.property("version_name") as String
2030
}
2131
}
2232

2333
apply plugin: "com.android.library"
2434
apply plugin: "kotlin-android"
25-
apply plugin: "kotlin-android-extensions"
2635
apply plugin: "maven-publish"
27-
apply plugin: "com.diffplug.gradle.spotless"
36+
apply plugin: "com.diffplug.spotless"
2837

2938
android {
30-
compileSdkVersion 29
31-
buildToolsVersion "29.0.3"
39+
compileSdkVersion 30
40+
buildToolsVersion "30.0.3"
3241

3342

3443
defaultConfig {
35-
minSdkVersion 19
36-
targetSdkVersion 29
37-
versionCode project.property('version_code').toInteger()
38-
versionName project.property('version_name') as String
44+
minSdkVersion rootProject.ext.min_sdk_version
45+
targetSdkVersion rootProject.ext.target_sdk_version
46+
versionCode rootProject.ext.version_code
47+
versionName rootProject.ext.version_name
3948

4049
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
41-
consumerProguardFiles 'consumer-rules.pro'
50+
consumerProguardFiles "consumer-rules.pro"
4251
}
4352

4453
buildTypes {
4554
release {
4655
minifyEnabled false
47-
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
56+
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
4857
}
4958
}
5059

5160
}
5261

5362
dependencies {
54-
implementation fileTree(dir: 'libs', include: ['*.jar'])
55-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
56-
implementation 'androidx.appcompat:appcompat:1.1.0'
57-
implementation 'androidx.core:core-ktx:1.3.0'
58-
implementation "io.reactivex.rxjava2:rxjava:2.2.19"
59-
implementation "io.reactivex.rxjava2:rxkotlin:2.4.0"
60-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7"
61-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7"
62-
implementation 'com.github.jitpack:gradle-simple:1.0'
63-
testImplementation 'junit:junit:4.13'
64-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
65-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
63+
implementation fileTree(dir: "libs", include: ["*.jar"])
64+
implementation "androidx.core:core-ktx:1.5.0"
65+
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
66+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3"
67+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3"
68+
69+
testImplementation "junit:junit:4.13.2"
70+
testImplementation "io.mockk:mockk:1.11.0"
71+
androidTestImplementation "androidx.test.ext:junit:1.1.2"
72+
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0"
6673
}
6774

6875

@@ -81,19 +88,26 @@ task sourceJar(type: Jar) {
8188
classifier "sources"
8289
}
8390

84-
publishing {
85-
publications {
86-
bar(MavenPublication) {
87-
groupId 'net.kuama.android'
88-
artifactId 'wifi-monitor'
89-
version project.property('version_name')
90-
artifact(sourceJar)
91-
artifact("$buildDir/outputs/aar/wifi-monitor-release.aar")
92-
}
93-
}
94-
repositories {
95-
maven {
96-
url "$buildDir/repo"
91+
task androidSourcesJar(type: Jar) {
92+
archiveClassifier.set('sources')
93+
from android.sourceSets.main.java.srcDirs
94+
}
95+
96+
afterEvaluate {
97+
publishing {
98+
publications {
99+
release(MavenPublication) {
100+
from components.release
101+
102+
// Adds javadocs and sources as separate jars.
103+
// artifact androidJavadocsJar
104+
artifact androidSourcesJar
105+
106+
groupId rootProject.ext.groupId
107+
artifactId rootProject.ext.artifactId
108+
version project.property("version_name") as String
109+
110+
}
97111
}
98112
}
99113
}

gradle.properties

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
1-
# Project-wide Gradle settings.
2-
# IDE (e.g. Android Studio) users:
3-
# Gradle settings configured through the IDE *will override*
4-
# any settings specified in this file.
5-
# For more details on how to configure your build environment visit
6-
# http://www.gradle.org/docs/current/userguide/build_environment.html
7-
# Specifies the JVM arguments used for the daemon process.
8-
# The setting is particularly useful for tweaking memory settings.
91
org.gradle.jvmargs=-Xmx1536m
10-
# When configured, Gradle will run in incubating parallel mode.
11-
# This option should only be used with decoupled projects. More details, visit
12-
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13-
# org.gradle.parallel=true
14-
# AndroidX package structure to make it clearer which packages are bundled with the
15-
# Android operating system, and which are packaged with your app's APK
16-
# https://developer.android.com/topic/libraries/support-library/androidx-rn
172
android.useAndroidX=true
18-
# Automatically convert third-party libraries to use AndroidX
193
android.enableJetifier=true
20-
# Kotlin code style for this project: "official" or "obsolete":
214
kotlin.code.style=official
22-
version_code=6
23-
version_name=1.0
5+
version_code=7
6+
version_name=1.1.0
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Wed Jun 09 08:08:14 CEST 2021
12
distributionBase=GRADLE_USER_HOME
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
24
distributionPath=wrapper/dists
3-
zipStoreBase=GRADLE_USER_HOME
45
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
6+
zipStoreBase=GRADLE_USER_HOME

publish.gradle

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/main/java/net/kuama/wifiMonitor/WifiListener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.kuama.wifiMonitor
22

3-
internal interface WifiListener {
3+
interface WifiListener {
44
fun stop()
55

66
fun start(onChange: () -> Unit)

0 commit comments

Comments
 (0)