Add incompatible server status

This commit is contained in:
Sam Whited 2014-11-15 11:29:58 -05:00
parent c09d450db8
commit 251f4d6d7f
4 changed files with 19 additions and 66 deletions

View File

@ -53,7 +53,8 @@ public class Account extends AbstractEntity {
REGISTRATION_CONFLICT(true), REGISTRATION_CONFLICT(true),
REGISTRATION_SUCCESSFUL, REGISTRATION_SUCCESSFUL,
REGISTRATION_NOT_SUPPORTED(true), REGISTRATION_NOT_SUPPORTED(true),
SECURITY_ERROR(true); SECURITY_ERROR(true),
INCOMPATIBLE_SERVER(true);
private boolean isError; private boolean isError;
@ -95,6 +96,8 @@ public class Account extends AbstractEntity {
return R.string.account_status_regis_not_sup; return R.string.account_status_regis_not_sup;
case SECURITY_ERROR: case SECURITY_ERROR:
return R.string.account_status_security_error; return R.string.account_status_security_error;
case INCOMPATIBLE_SERVER:
return R.string.account_status_incompatible_server;
default: default:
return R.string.account_status_unknown; return R.string.account_status_unknown;
} }

View File

@ -36,71 +36,19 @@ public class AccountAdapter extends ArrayAdapter<Account> {
ImageView imageView = (ImageView) view.findViewById(R.id.account_image); ImageView imageView = (ImageView) view.findViewById(R.id.account_image);
imageView.setImageBitmap(activity.avatarService().get(account, imageView.setImageBitmap(activity.avatarService().get(account,
activity.getPixel(48))); activity.getPixel(48)));
switch (account.getStatus()) { statusView.setText(getContext().getString(account.getStatus().getReadableId()));
case DISABLED: switch (account.getStatus()) {
statusView.setText(getContext().getString( case ONLINE:
R.string.account_status_disabled)); statusView.setTextColor(activity.getPrimaryColor());
statusView.setTextColor(activity.getSecondaryTextColor()); break;
break; case DISABLED:
case ONLINE: case CONNECTING:
statusView.setText(getContext().getString( statusView.setTextColor(activity.getSecondaryTextColor());
R.string.account_status_online)); break;
statusView.setTextColor(activity.getPrimaryColor()); default:
break; statusView.setTextColor(activity.getWarningTextColor());
case CONNECTING: break;
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;
}
return view; return view;
} }
} }

View File

@ -669,6 +669,7 @@ public class XmppConnection implements Runnable {
} else if (this.streamFeatures.hasChild("bind") && shouldBind) { } else if (this.streamFeatures.hasChild("bind") && shouldBind) {
sendBindRequest(); sendBindRequest();
} else { } else {
account.setStatus(Account.State.INCOMPATIBLE_SERVER);
Log.d(Config.LOGTAG, account.getJid().toBareJid() Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": incompatible server. disconnecting"); + ": incompatible server. disconnecting");
disconnect(true); disconnect(true);

View File

@ -142,6 +142,7 @@
<string name="account_status_regis_success">Registration completed</string> <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_regis_not_sup">Server does not support registration</string>
<string name="account_status_security_error">Security error</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_none">Plain text</string>
<string name="encryption_choice_otr">OTR</string> <string name="encryption_choice_otr">OTR</string>
<string name="encryption_choice_pgp">OpenPGP</string> <string name="encryption_choice_pgp">OpenPGP</string>