From e73b6c8814e317d0ac79c0f8e15b8b4f7fd57c5e Mon Sep 17 00:00:00 2001 From: vadym Date: Sat, 8 Aug 2020 01:08:01 -0700 Subject: [PATCH] 1. added notification --- .../java/io/github/chronosx88/yggdrasil/MainActivity.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt b/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt index b96e71d..1cc7adf 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt +++ b/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt @@ -148,10 +148,16 @@ class MainActivity : AppCompatActivity() { connectivityManager?.let { it.registerDefaultNetworkCallback(object : ConnectivityManager.NetworkCallback() { override fun onAvailable(network: Network) { + showToast("network on") + stopVpn() + Thread.sleep(1000) startVpn() } override fun onLost(network: Network?) { + showToast("network off") stopVpn() + Thread.sleep(1000) + startVpn() } }) } @@ -162,8 +168,10 @@ class MainActivity : AppCompatActivity() { Log.i(TAG, "Network state has been changed") if ("android.net.conn.CONNECTIVITY_CHANGE" == intent.action) { if (status == NetworkUtils.NETWORK_STATUS_NOT_CONNECTED) { + showToast("network on") stopVpn() } else { + showToast("network of") startVpn() } }