From 251f4d6d7f93da6d23c3422cf8eeece780789f45 Mon Sep 17 00:00:00 2001 From: Sam Whited Date: Sat, 15 Nov 2014 11:29:58 -0500 Subject: [PATCH] Add incompatible server status --- .../siacs/conversations/entities/Account.java | 5 +- .../ui/adapter/AccountAdapter.java | 78 ++++--------------- .../conversations/xmpp/XmppConnection.java | 1 + src/main/res/values/strings.xml | 1 + 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 d5a316ab8..85f967eca 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 7404e161d..139f36575 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 { 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 42a89610d..3c911fc98 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 4a1ec6759..db9f95d45 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -142,6 +142,7 @@ Registration completed Server does not support registration Security error + Incompatible server Plain text OTR OpenPGP