expert setting to trigger extended connection options
This commit is contained in:
parent
31fd425c9a
commit
7c0eae8059
|
@ -1969,7 +1969,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
|||
}
|
||||
}
|
||||
}
|
||||
Element form = query.findChild("x","jabber:x:data");
|
||||
Element form = query.findChild("x", "jabber:x:data");
|
||||
if (form != null) {
|
||||
conversation.getMucOptions().updateFormData(Data.parse(form));
|
||||
}
|
||||
|
@ -2378,7 +2378,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
|||
updateConversationUi();
|
||||
updateRosterUi();
|
||||
} else {
|
||||
Conversation conversation = find(account,avatar.owner.toBareJid());
|
||||
Conversation conversation = find(account, avatar.owner.toBareJid());
|
||||
if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) {
|
||||
MucOptions.User user = conversation.getMucOptions().findUser(avatar.owner.getResourcepart());
|
||||
if (user != null) {
|
||||
|
@ -2586,6 +2586,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
|||
return Config.FORCE_ORBOT || getPreferences().getBoolean("use_tor", false);
|
||||
}
|
||||
|
||||
public boolean showExtendedConnectionOptions() {
|
||||
return getPreferences().getBoolean("show_connection_options", false);
|
||||
}
|
||||
|
||||
public int unreadCount() {
|
||||
int count = 0;
|
||||
for (Conversation conversation : getConversations()) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.app.AlertDialog.Builder;
|
|||
import android.app.PendingIntent;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
@ -91,7 +92,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
|||
|
||||
private Jid jidToEdit;
|
||||
private boolean mInitMode = false;
|
||||
private boolean mUseTor = false;
|
||||
private boolean mShowOptions = false;
|
||||
private Account mAccount;
|
||||
private String messageFingerprint;
|
||||
|
||||
|
@ -133,7 +134,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
|||
}
|
||||
String hostname = null;
|
||||
int numericPort = 5222;
|
||||
if (mUseTor) {
|
||||
if (mShowOptions) {
|
||||
hostname = mHostname.getText().toString();
|
||||
final String port = mPort.getText().toString();
|
||||
if (hostname.contains(" ")) {
|
||||
|
@ -511,8 +512,11 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
|||
}
|
||||
}
|
||||
}
|
||||
this.mUseTor = Config.FORCE_ORBOT || getPreferences().getBoolean("use_tor", false);
|
||||
this.mNamePort.setVisibility(mUseTor ? View.VISIBLE : View.GONE);
|
||||
SharedPreferences preferences = getPreferences();
|
||||
boolean useTor = Config.FORCE_ORBOT || preferences.getBoolean("use_tor", false);
|
||||
this.mShowOptions = useTor || preferences.getBoolean("show_connection_options", false);
|
||||
mHostname.setHint(useTor ? R.string.hostname_or_onion : R.string.hostname_example);
|
||||
this.mNamePort.setVisibility(mShowOptions ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -598,7 +602,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
|||
this.mHostname.getEditableText().append(this.mAccount.getHostname());
|
||||
this.mPort.setText("");
|
||||
this.mPort.getEditableText().append(String.valueOf(this.mAccount.getPort()));
|
||||
this.mNamePort.setVisibility(mUseTor ? View.VISIBLE : View.GONE);
|
||||
this.mNamePort.setVisibility(mShowOptions ? View.VISIBLE : View.GONE);
|
||||
|
||||
}
|
||||
if (!mInitMode) {
|
||||
|
@ -740,12 +744,24 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
|||
}
|
||||
} else {
|
||||
if (this.mAccount.errorStatus()) {
|
||||
this.mAccountJid.setError(getString(this.mAccount.getStatus().getReadableId()));
|
||||
final EditText errorTextField;
|
||||
if (this.mAccount.getStatus() == Account.State.UNAUTHORIZED) {
|
||||
errorTextField = this.mPassword;
|
||||
} else if (mShowOptions
|
||||
&& this.mAccount.getStatus() == Account.State.SERVER_NOT_FOUND
|
||||
&& this.mHostname.getText().length() > 0) {
|
||||
errorTextField = this.mHostname;
|
||||
} else {
|
||||
errorTextField = this.mAccountJid;
|
||||
}
|
||||
errorTextField.setError(getString(this.mAccount.getStatus().getReadableId()));
|
||||
if (init || !accountInfoEdited()) {
|
||||
this.mAccountJid.requestFocus();
|
||||
errorTextField.requestFocus();
|
||||
}
|
||||
} else {
|
||||
this.mAccountJid.setError(null);
|
||||
this.mPassword.setError(null);
|
||||
this.mHostname.setError(null);
|
||||
}
|
||||
this.mStats.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -243,6 +243,7 @@ public class XmppConnection implements Runnable {
|
|||
tagWriter = new TagWriter();
|
||||
this.changeStatus(Account.State.CONNECTING);
|
||||
final boolean useTor = mXmppConnectionService.useTorToConnect() || account.isOnion();
|
||||
final boolean extended = mXmppConnectionService.showExtendedConnectionOptions();
|
||||
if (useTor) {
|
||||
String destination;
|
||||
if (account.getHostname() == null || account.getHostname().isEmpty()) {
|
||||
|
@ -250,8 +251,16 @@ public class XmppConnection implements Runnable {
|
|||
} else {
|
||||
destination = account.getHostname();
|
||||
}
|
||||
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": connect to "+destination+" via TOR");
|
||||
socket = SocksSocketFactory.createSocketOverTor(destination,account.getPort());
|
||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": connect to " + destination + " via TOR");
|
||||
socket = SocksSocketFactory.createSocketOverTor(destination, account.getPort());
|
||||
startXmpp();
|
||||
} else if (extended && account.getHostname() != null && !account.getHostname().isEmpty()) {
|
||||
socket = new Socket();
|
||||
try {
|
||||
socket.connect(new InetSocketAddress(account.getHostname(), account.getPort()), Config.SOCKET_TIMEOUT * 1000);
|
||||
} catch (IOException e) {
|
||||
throw new UnknownHostException();
|
||||
}
|
||||
startXmpp();
|
||||
} else if (DNSHelper.isIp(account.getServer().toString())) {
|
||||
socket = new Socket();
|
||||
|
|
|
@ -529,6 +529,9 @@
|
|||
<string name="pref_away_when_screen_off_summary">Marks your resource as away when the screen is turned off</string>
|
||||
<string name="pref_xa_on_silent_mode">Not available in silent mode</string>
|
||||
<string name="pref_xa_on_silent_mode_summary">Marks your resource as not available when device is in silent mode</string>
|
||||
<string name="pref_show_connection_options">Extended connection options</string>
|
||||
<string name="pref_show_connection_options_summary">Show hostname and port options when setting up an account</string>
|
||||
<string name="hostname_example">xmpp.example.com</string>
|
||||
<string name="action_add_account_with_certificate">Add account with certificate</string>
|
||||
<string name="unable_to_parse_certificate">Unable to parse certificate</string>
|
||||
<string name="authenticate_with_certificate">Leave empty to authenticate w/ certificate</string>
|
||||
|
|
|
@ -155,6 +155,11 @@
|
|||
android:key="use_tor"
|
||||
android:summary="@string/pref_use_tor_summary"
|
||||
android:title="@string/pref_use_tor"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="show_connection_options"
|
||||
android:summary="@string/pref_show_connection_options_summary"
|
||||
android:title="@string/pref_show_connection_options"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_input_options">
|
||||
<CheckBoxPreference
|
||||
|
|
Loading…
Reference in a new issue