Show different error if failed to connect to instance domain.

This commit is contained in:
O01eg 2019-07-10 21:26:47 +03:00
parent 8543f24bc7
commit a9fc78581c
No known key found for this signature in database
GPG Key ID: 321DEF6CF5F0D7D2
4 changed files with 12 additions and 0 deletions

View File

@ -337,6 +337,8 @@ public class LoginActivity extends BaseActivity {
instance_chosen.setText(instance);
}
}
}else if(instanceNodeInfo != null && instanceNodeInfo.isConnectionError()){
Toasty.error(LoginActivity.this,getString(R.string.connect_error), Toast.LENGTH_LONG).show();
}else{
Toasty.error(LoginActivity.this,getString(R.string.client_error), Toast.LENGTH_LONG).show();
}

View File

@ -650,6 +650,7 @@ public class API {
setDefaultError(e);
}
} catch (IOException e) {
instanceNodeInfo.setConnectionError(true);
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
@ -663,6 +664,7 @@ public class API {
instanceNodeInfo.setVersion(jsonObject.getString("version"));
instanceNodeInfo.setOpenRegistrations(true);
} catch (IOException e1) {
instanceNodeInfo.setConnectionError(true);
e1.printStackTrace();
} catch (NoSuchAlgorithmException e1) {
e1.printStackTrace();

View File

@ -19,6 +19,7 @@ public class InstanceNodeInfo {
private String name;
private String version;
private boolean openRegistrations;
private boolean connectionError;
public String getName() {
return name;
@ -43,4 +44,10 @@ public class InstanceNodeInfo {
public void setOpenRegistrations(boolean openRegistrations) {
this.openRegistrations = openRegistrations;
}
public boolean isConnectionError() { return connectionError; }
public void setConnectionError(boolean connectionError) {
this.connectionError = connectionError;
}
}

View File

@ -268,6 +268,7 @@
<string name="pinned_toots">Pinned</string>
<!-- TOAST -->
<string name="client_error">Unable to get client id!</string>
<string name="connect_error">Unable to connect to instance domain!</string>
<string name="no_internet">No Internet connection!</string>
<string name="toast_block">The account was blocked!</string>
<string name="toast_unblock">The account is no longer blocked!</string>