show only username when registering account with magic create
This commit is contained in:
parent
98ecac0ffa
commit
d23178acb9
|
@ -38,7 +38,7 @@ public final class Config {
|
||||||
|
|
||||||
|
|
||||||
public static final String DOMAIN_LOCK = null; //only allow account creation for this domain
|
public static final String DOMAIN_LOCK = null; //only allow account creation for this domain
|
||||||
public static final String MAGIC_CREATE_DOMAIN = null;
|
public static final String MAGIC_CREATE_DOMAIN = "conversations.im";
|
||||||
public static final boolean DISALLOW_REGISTRATION_IN_UI = false; //hide the register checkbox
|
public static final boolean DISALLOW_REGISTRATION_IN_UI = false; //hide the register checkbox
|
||||||
|
|
||||||
public static final boolean ALLOW_NON_TLS_CONNECTIONS = false; //very dangerous. you should have a good reason to set this to true
|
public static final boolean ALLOW_NON_TLS_CONNECTIONS = false; //very dangerous. you should have a good reason to set this to true
|
||||||
|
|
|
@ -102,6 +102,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
||||||
|
|
||||||
private Jid jidToEdit;
|
private Jid jidToEdit;
|
||||||
private boolean mInitMode = false;
|
private boolean mInitMode = false;
|
||||||
|
private boolean mUsernameMode = Config.DOMAIN_LOCK != null;
|
||||||
private boolean mShowOptions = false;
|
private boolean mShowOptions = false;
|
||||||
private Account mAccount;
|
private Account mAccount;
|
||||||
private String messageFingerprint;
|
private String messageFingerprint;
|
||||||
|
@ -128,20 +129,20 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final boolean registerNewAccount = mRegisterNew.isChecked() && !Config.DISALLOW_REGISTRATION_IN_UI;
|
final boolean registerNewAccount = mRegisterNew.isChecked() && !Config.DISALLOW_REGISTRATION_IN_UI;
|
||||||
if (Config.DOMAIN_LOCK != null && mAccountJid.getText().toString().contains("@")) {
|
if (mUsernameMode && mAccountJid.getText().toString().contains("@")) {
|
||||||
mAccountJid.setError(getString(R.string.invalid_username));
|
mAccountJid.setError(getString(R.string.invalid_username));
|
||||||
mAccountJid.requestFocus();
|
mAccountJid.requestFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Jid jid;
|
final Jid jid;
|
||||||
try {
|
try {
|
||||||
if (Config.DOMAIN_LOCK != null) {
|
if (mUsernameMode) {
|
||||||
jid = Jid.fromParts(mAccountJid.getText().toString(), Config.DOMAIN_LOCK, null);
|
jid = Jid.fromParts(mAccountJid.getText().toString(), getUserModeDomain(), null);
|
||||||
} else {
|
} else {
|
||||||
jid = Jid.fromString(mAccountJid.getText().toString());
|
jid = Jid.fromString(mAccountJid.getText().toString());
|
||||||
}
|
}
|
||||||
} catch (final InvalidJidException e) {
|
} catch (final InvalidJidException e) {
|
||||||
if (Config.DOMAIN_LOCK != null) {
|
if (mUsernameMode) {
|
||||||
mAccountJid.setError(getString(R.string.invalid_username));
|
mAccountJid.setError(getString(R.string.invalid_username));
|
||||||
} else {
|
} else {
|
||||||
mAccountJid.setError(getString(R.string.invalid_jid));
|
mAccountJid.setError(getString(R.string.invalid_jid));
|
||||||
|
@ -175,7 +176,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jid.isDomainJid()) {
|
if (jid.isDomainJid()) {
|
||||||
if (Config.DOMAIN_LOCK != null) {
|
if (mUsernameMode) {
|
||||||
mAccountJid.setError(getString(R.string.invalid_username));
|
mAccountJid.setError(getString(R.string.invalid_username));
|
||||||
} else {
|
} else {
|
||||||
mAccountJid.setError(getString(R.string.invalid_jid));
|
mAccountJid.setError(getString(R.string.invalid_jid));
|
||||||
|
@ -395,7 +396,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
||||||
|
|
||||||
protected boolean jidEdited() {
|
protected boolean jidEdited() {
|
||||||
final String unmodified;
|
final String unmodified;
|
||||||
if (Config.DOMAIN_LOCK != null) {
|
if (mUsernameMode) {
|
||||||
unmodified = this.mAccount.getJid().getLocalpart();
|
unmodified = this.mAccount.getJid().getLocalpart();
|
||||||
} else {
|
} else {
|
||||||
unmodified = this.mAccount.getJid().toBareJid().toString();
|
unmodified = this.mAccount.getJid().toBareJid().toString();
|
||||||
|
@ -427,10 +428,6 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
||||||
this.mAccountJid = (AutoCompleteTextView) findViewById(R.id.account_jid);
|
this.mAccountJid = (AutoCompleteTextView) findViewById(R.id.account_jid);
|
||||||
this.mAccountJid.addTextChangedListener(this.mTextWatcher);
|
this.mAccountJid.addTextChangedListener(this.mTextWatcher);
|
||||||
this.mAccountJidLabel = (TextView) findViewById(R.id.account_jid_label);
|
this.mAccountJidLabel = (TextView) findViewById(R.id.account_jid_label);
|
||||||
if (Config.DOMAIN_LOCK != null) {
|
|
||||||
this.mAccountJidLabel.setText(R.string.username);
|
|
||||||
this.mAccountJid.setHint(R.string.username_hint);
|
|
||||||
}
|
|
||||||
this.mPassword = (EditText) findViewById(R.id.account_password);
|
this.mPassword = (EditText) findViewById(R.id.account_password);
|
||||||
this.mPassword.addTextChangedListener(this.mTextWatcher);
|
this.mPassword.addTextChangedListener(this.mTextWatcher);
|
||||||
this.mPasswordConfirm = (EditText) findViewById(R.id.account_password_confirm);
|
this.mPasswordConfirm = (EditText) findViewById(R.id.account_password_confirm);
|
||||||
|
@ -577,6 +574,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
||||||
this.mAccount = xmppConnectionService.findAccountByJid(jidToEdit);
|
this.mAccount = xmppConnectionService.findAccountByJid(jidToEdit);
|
||||||
if (this.mAccount != null) {
|
if (this.mAccount != null) {
|
||||||
this.mInitMode |= this.mAccount.isOptionSet(Account.OPTION_REGISTER);
|
this.mInitMode |= this.mAccount.isOptionSet(Account.OPTION_REGISTER);
|
||||||
|
this.mUsernameMode |= mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) && mAccount.isOptionSet(Account.OPTION_REGISTER);
|
||||||
if (this.mAccount.getPrivateKeyAlias() != null) {
|
if (this.mAccount.getPrivateKeyAlias() != null) {
|
||||||
this.mPassword.setHint(R.string.authenticate_with_certificate);
|
this.mPassword.setHint(R.string.authenticate_with_certificate);
|
||||||
if (this.mInitMode) {
|
if (this.mInitMode) {
|
||||||
|
@ -596,7 +594,10 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
||||||
this.mCancelButton.setEnabled(false);
|
this.mCancelButton.setEnabled(false);
|
||||||
this.mCancelButton.setTextColor(getSecondaryTextColor());
|
this.mCancelButton.setTextColor(getSecondaryTextColor());
|
||||||
}
|
}
|
||||||
if (Config.DOMAIN_LOCK == null) {
|
if (mUsernameMode) {
|
||||||
|
this.mAccountJidLabel.setText(R.string.username);
|
||||||
|
this.mAccountJid.setHint(R.string.username_hint);
|
||||||
|
} else {
|
||||||
final KnownHostsAdapter mKnownHostsAdapter = new KnownHostsAdapter(this,
|
final KnownHostsAdapter mKnownHostsAdapter = new KnownHostsAdapter(this,
|
||||||
R.layout.simple_list_item,
|
R.layout.simple_list_item,
|
||||||
xmppConnectionService.getKnownHosts());
|
xmppConnectionService.getKnownHosts());
|
||||||
|
@ -606,6 +607,14 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getUserModeDomain() {
|
||||||
|
if (mAccount != null) {
|
||||||
|
return mAccount.getJid().getDomainpart();
|
||||||
|
} else {
|
||||||
|
return Config.DOMAIN_LOCK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
|
@ -666,7 +675,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
||||||
private void updateAccountInformation(boolean init) {
|
private void updateAccountInformation(boolean init) {
|
||||||
if (init) {
|
if (init) {
|
||||||
this.mAccountJid.getEditableText().clear();
|
this.mAccountJid.getEditableText().clear();
|
||||||
if (Config.DOMAIN_LOCK != null) {
|
if (mUsernameMode) {
|
||||||
this.mAccountJid.getEditableText().append(this.mAccount.getJid().getLocalpart());
|
this.mAccountJid.getEditableText().append(this.mAccount.getJid().getLocalpart());
|
||||||
} else {
|
} else {
|
||||||
this.mAccountJid.getEditableText().append(this.mAccount.getJid().toBareJid().toString());
|
this.mAccountJid.getEditableText().append(this.mAccount.getJid().toBareJid().toString());
|
||||||
|
|
Loading…
Reference in a new issue