aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Whited <sam@samwhited.com>2014-11-15 11:29:58 -0500
committerSam Whited <sam@samwhited.com>2014-11-15 11:29:58 -0500
commit251f4d6d7f93da6d23c3422cf8eeece780789f45 (patch)
tree56f918a32397f4e15817816692ff2bb4613e415d
parentc09d450db815f51802caf0ea761ee01617a4ad19 (diff)
Add incompatible server status
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Account.java5
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java78
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java1
-rw-r--r--src/main/res/values/strings.xml1
4 files changed, 19 insertions, 66 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java
index d5a316ab..85f967ec 100644
--- a/src/main/java/eu/siacs/conversations/entities/Account.java
+++ b/src/main/java/eu/siacs/conversations/entities/Account.java
@@ -53,7 +53,8 @@ public class Account extends AbstractEntity {
REGISTRATION_CONFLICT(true),
REGISTRATION_SUCCESSFUL,
REGISTRATION_NOT_SUPPORTED(true),
- SECURITY_ERROR(true);
+ SECURITY_ERROR(true),
+ INCOMPATIBLE_SERVER(true);
private boolean isError;
@@ -95,6 +96,8 @@ public class Account extends AbstractEntity {
return R.string.account_status_regis_not_sup;
case SECURITY_ERROR:
return R.string.account_status_security_error;
+ case INCOMPATIBLE_SERVER:
+ return R.string.account_status_incompatible_server;
default:
return R.string.account_status_unknown;
}
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java
index 7404e161..139f3657 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java
@@ -36,71 +36,19 @@ public class AccountAdapter extends ArrayAdapter<Account> {
ImageView imageView = (ImageView) view.findViewById(R.id.account_image);
imageView.setImageBitmap(activity.avatarService().get(account,
activity.getPixel(48)));
- switch (account.getStatus()) {
- case DISABLED:
- statusView.setText(getContext().getString(
- R.string.account_status_disabled));
- statusView.setTextColor(activity.getSecondaryTextColor());
- break;
- case ONLINE:
- statusView.setText(getContext().getString(
- R.string.account_status_online));
- statusView.setTextColor(activity.getPrimaryColor());
- break;
- case CONNECTING:
- statusView.setText(getContext().getString(
- R.string.account_status_connecting));
- statusView.setTextColor(activity.getSecondaryTextColor());
- break;
- case OFFLINE:
- statusView.setText(getContext().getString(
- R.string.account_status_offline));
- statusView.setTextColor(activity.getWarningTextColor());
- break;
- case UNAUTHORIZED:
- statusView.setText(getContext().getString(
- R.string.account_status_unauthorized));
- statusView.setTextColor(activity.getWarningTextColor());
- break;
- case SERVER_NOT_FOUND:
- statusView.setText(getContext().getString(
- R.string.account_status_not_found));
- statusView.setTextColor(activity.getWarningTextColor());
- break;
- case NO_INTERNET:
- statusView.setText(getContext().getString(
- R.string.account_status_no_internet));
- statusView.setTextColor(activity.getWarningTextColor());
- break;
- case REGISTRATION_FAILED:
- statusView.setText(getContext().getString(
- R.string.account_status_regis_fail));
- statusView.setTextColor(activity.getWarningTextColor());
- break;
- case REGISTRATION_CONFLICT:
- statusView.setText(getContext().getString(
- R.string.account_status_regis_conflict));
- statusView.setTextColor(activity.getWarningTextColor());
- break;
- case REGISTRATION_SUCCESSFUL:
- statusView.setText(getContext().getString(
- R.string.account_status_regis_success));
- statusView.setTextColor(activity.getSecondaryTextColor());
- break;
- case REGISTRATION_NOT_SUPPORTED:
- statusView.setText(getContext().getString(
- R.string.account_status_regis_not_sup));
- statusView.setTextColor(activity.getWarningTextColor());
- break;
- case SECURITY_ERROR:
- statusView.setText(getContext().getString
- (R.string.account_status_security_error));
- statusView.setTextColor(activity.getWarningTextColor());
- default:
- statusView.setText("");
- break;
- }
-
+ statusView.setText(getContext().getString(account.getStatus().getReadableId()));
+ switch (account.getStatus()) {
+ case ONLINE:
+ statusView.setTextColor(activity.getPrimaryColor());
+ break;
+ case DISABLED:
+ case CONNECTING:
+ statusView.setTextColor(activity.getSecondaryTextColor());
+ break;
+ default:
+ statusView.setTextColor(activity.getWarningTextColor());
+ break;
+ }
return view;
}
}
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index 42a89610..3c911fc9 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -669,6 +669,7 @@ public class XmppConnection implements Runnable {
} else if (this.streamFeatures.hasChild("bind") && shouldBind) {
sendBindRequest();
} else {
+ account.setStatus(Account.State.INCOMPATIBLE_SERVER);
Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": incompatible server. disconnecting");
disconnect(true);
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 4a1ec675..db9f95d4 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -142,6 +142,7 @@
<string name="account_status_regis_success">Registration completed</string>
<string name="account_status_regis_not_sup">Server does not support registration</string>
<string name="account_status_security_error">Security error</string>
+ <string name="account_status_incompatible_server">Incompatible server</string>
<string name="encryption_choice_none">Plain text</string>
<string name="encryption_choice_otr">OTR</string>
<string name="encryption_choice_pgp">OpenPGP</string>