diff --git a/app/src/main/java/im/conversations/android/ui/model/SetupViewModel.java b/app/src/main/java/im/conversations/android/ui/model/SetupViewModel.java
index e71bf321b..9d1f550b6 100644
--- a/app/src/main/java/im/conversations/android/ui/model/SetupViewModel.java
+++ b/app/src/main/java/im/conversations/android/ui/model/SetupViewModel.java
@@ -1,6 +1,9 @@
package im.conversations.android.ui.model;
import android.app.Application;
+import android.net.ConnectivityManager;
+import android.net.Network;
+import android.net.NetworkCapabilities;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
@@ -340,7 +343,14 @@ public class SetupViewModel extends AndroidViewModel {
private void decideNextStep(
final Target current, final ConnectionException connectionException) {
final var state = connectionException.getConnectionState();
- LOGGER.info("Deciding next step for {}", state);
+ final var isNetworkDown = isNetworkDown();
+ LOGGER.info("Deciding next step for {} isNetworkDown {}", state, isNetworkDown);
+ if (state == ConnectionState.SERVER_NOT_FOUND && isNetworkDown) {
+ this.genericErrorEvent.postValue(
+ new Event<>(
+ getApplication().getString(R.string.check_your_internet_connection)));
+ return;
+ }
if (Arrays.asList(ConnectionState.UNAUTHORIZED, ConnectionState.TEMPORARY_AUTH_FAILURE)
.contains(state)) {
if (this.redirectIfNecessary(current, Target.ENTER_PASSWORD)) {
@@ -473,6 +483,15 @@ public class SetupViewModel extends AndroidViewModel {
super.onCleared();
}
+ private boolean isNetworkDown() {
+ final ConnectivityManager cm = getApplication().getSystemService(ConnectivityManager.class);
+ final Network activeNetwork = cm == null ? null : cm.getActiveNetwork();
+ final NetworkCapabilities capabilities =
+ activeNetwork == null ? null : cm.getNetworkCapabilities(activeNetwork);
+ return capabilities == null
+ || !capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
+ }
+
public enum Target {
ENTER_ADDRESS,
ENTER_PASSWORD,
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 51a544018..1c4dcc172 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1047,5 +1047,6 @@
The server certificate is not trustworthy. If you don’t know what this means it’s best to go back!
Trust certificate
You
+ Check your Internet connection