mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-24 18:57:37 +00:00
Added a flag for connection status
Reactively updated flag which only checks whether the "data" / "wifi" / "ethernet" is plugged in or enabled. If the user connects to the wifi but has no actual connection, the app will never know. Please refrain from using other access methods (like pinging a host), it can get picked up by a VPN or other methods and possibly expose MM.
This commit is contained in:
parent
223913c30a
commit
4ef19d17da
@ -62,6 +62,7 @@ dependencies {
|
||||
implementation 'com.jakewharton.timber:timber:4.7.1'
|
||||
implementation 'com.github.skoumalcz:teanity:0.3.3'
|
||||
implementation 'com.ncapdevi:frag-nav:3.2.0'
|
||||
implementation 'com.github.pwittchen:reactivenetwork-rx2:3.0.3'
|
||||
|
||||
def vMarkwon = '3.1.0'
|
||||
implementation "ru.noties.markwon:core:${vMarkwon}"
|
||||
|
@ -1,7 +1,10 @@
|
||||
package com.topjohnwu.magisk.ui.base
|
||||
|
||||
import android.app.Activity
|
||||
import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork
|
||||
import com.skoumal.teanity.extensions.doOnSubscribeUi
|
||||
import com.skoumal.teanity.extensions.subscribeK
|
||||
import com.skoumal.teanity.util.KObservableField
|
||||
import com.skoumal.teanity.viewmodel.LoadingViewModel
|
||||
import com.topjohnwu.magisk.model.events.BackPressEvent
|
||||
import com.topjohnwu.magisk.model.events.PermissionEvent
|
||||
@ -12,6 +15,14 @@ import io.reactivex.subjects.PublishSubject
|
||||
|
||||
abstract class MagiskViewModel : LoadingViewModel() {
|
||||
|
||||
val isConnected = KObservableField(true)
|
||||
|
||||
init {
|
||||
ReactiveNetwork.observeInternetConnectivity()
|
||||
.subscribeK { isConnected.value = it }
|
||||
.add()
|
||||
}
|
||||
|
||||
fun withView(action: Activity.() -> Unit) {
|
||||
ViewActionEvent(action).publish()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user