diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5b3a148..0ea7f5e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,7 @@ + { var message = event.details if (!event.serverDetails.isNullOrEmpty()) - message += "\n\n" + "Server details: ${event.serverDetails}" + message += "\n\nServer details: ${event.serverDetails}" + if (!isConnectedToNetwork(this)) + message += "\n\nInternet may be inaccessible…" alert(message, title = event.short) updateState(PageViewModel.State.IDLE) } diff --git a/app/src/main/java/dev/lowrespalmtree/comet/NetUtils.kt b/app/src/main/java/dev/lowrespalmtree/comet/NetUtils.kt new file mode 100644 index 0000000..5dd12fa --- /dev/null +++ b/app/src/main/java/dev/lowrespalmtree/comet/NetUtils.kt @@ -0,0 +1,11 @@ +package dev.lowrespalmtree.comet + +import android.content.Context +import android.net.ConnectivityManager +import android.net.NetworkCapabilities + +fun isConnectedToNetwork(context: Context): Boolean { + val connManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + val caps = connManager.getNetworkCapabilities(connManager.activeNetwork) ?: return false + return caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED) +}