Use proxy and/or specific server settings in account wizard
authorDa Risk <da_risk@beem-project.com>
Sat, 15 Dec 2012 18:23:34 +0100
changeset 1009 c76a6e4b37cf
parent 1008 9120606d6526
child 1010 d3be66f5cfa1
Use proxy and/or specific server settings in account wizard
res/layout/create_account.xml
res/layout/wizard_account_configure.xml
res/values-fr/strings.xml
res/values/strings.xml
src/com/beem/project/beem/ui/wizard/AccountConfigureFragment.java
src/com/beem/project/beem/ui/wizard/CreateAccountFragment.java
--- a/res/layout/create_account.xml	Sat Dec 15 18:15:42 2012 +0100
+++ b/res/layout/create_account.xml	Sat Dec 15 18:23:34 2012 +0100
@@ -59,6 +59,13 @@
 			android:inputType="textPassword" android:imeOptions="actionNext"
 			android:singleLine="true"
 			android:contentDescription="@string/create_account_confirm_password"/>
+		<TextView android:id="@+id/settings_warn_label" style="@style/Label"
+		    android:layout_width="fill_parent" android:layout_height="wrap_content"
+		    android:text="@string/account_wizard_settings_warn"
+		    android:inputType="textMultiLine|textNoSuggestions"
+		    android:textColor="@color/white"
+		    android:textStyle="normal"
+		    android:visibility="gone" />
 		<TextView android:id="@+id/error_label"
 				android:layout_width="fill_parent" android:layout_height="wrap_content"
 				android:textColor="@color/red" android:textStyle="bold"
--- a/res/layout/wizard_account_configure.xml	Sat Dec 15 18:15:42 2012 +0100
+++ b/res/layout/wizard_account_configure.xml	Sat Dec 15 18:23:34 2012 +0100
@@ -55,10 +55,17 @@
 		android:inputType="textPassword" android:imeOptions="actionNext"
 		android:password="true" android:singleLine="true"
 		android:contentDescription="@string/Password"/>
-	    <TextView android:id="@+id/error_label"
+	    <TextView android:id="@+id/settings_warn_label" style="@style/Label"
 		android:layout_width="fill_parent" android:layout_height="wrap_content"
-		android:text="@string/account_wizard_connection_failed" style="@style/Label"
-		android:inputType="textMultiLine"
+		android:text="@string/account_wizard_settings_warn"
+		android:inputType="textMultiLine|textNoSuggestions"
+		android:textColor="@color/white"
+		android:textStyle="normal"
+		android:visibility="gone" />
+	    <TextView android:id="@+id/error_label" style="@style/Label"
+		android:layout_width="fill_parent" android:layout_height="wrap_content"
+		android:text="@string/account_wizard_connection_failed"
+		android:inputType="textMultiLine|textNoSuggestions"
 		android:textColor="@color/red"
 		android:visibility="invisible" />
 	</LinearLayout>
--- a/res/values-fr/strings.xml	Sat Dec 15 18:15:42 2012 +0100
+++ b/res/values-fr/strings.xml	Sat Dec 15 18:23:34 2012 +0100
@@ -193,7 +193,9 @@
 	<string name="account_wizard_text1"><b>Bienvenue sur BEEM.</b>\n\nVous n\'avez pas encore configuré de compte XMPP (Jabber).\nChoisissez une des options suivantes :</string>
 	<string name="account_wizard_configure_text_1">Utilisez un compte du terminal</string>
 	<string name="account_wizard_configure_text_2"><b>ou</b></string>
-	<string name="account_wizard_configure_text_3">Remplissez les informations de votre compte</string>	<string name="account_wizard_configure_account">Je possède déjà un compte que je veux utiliser.</string>
+	<string name="account_wizard_configure_text_3">Remplissez les informations de votre compte</string>
+	<string name="account_wizard_settings_warn"><b>Attention : </b>Vos paramètres indique d\'utiliser un serveur proxy ou un serveur spécifique.</string>
+	<string name="account_wizard_configure_account">Je possède déjà un compte que je veux utiliser.</string>
 	<string name="account_wizard_create_account">Je veux créer un nouveau compte</string>
 
 	<!--
--- a/res/values/strings.xml	Sat Dec 15 18:15:42 2012 +0100
+++ b/res/values/strings.xml	Sat Dec 15 18:23:34 2012 +0100
@@ -191,6 +191,7 @@
 	<string name="account_wizard_configure_text_1">Use an account store on the device</string>
 	<string name="account_wizard_configure_text_2"><b>or</b></string>
 	<string name="account_wizard_configure_text_3">Fill in the data for your existing account</string>
+	<string name="account_wizard_settings_warn"><b>Warning: </b>Your settings are set to use a server proxy or a specific server hostname.</string>
 	<string name="account_wizard_connection_failed"><b>Unable to authenticate your account. Please verify your credentials</b></string>
 	<string name="account_wizard_select_account_btn">Choose an account</string>
 	
--- a/src/com/beem/project/beem/ui/wizard/AccountConfigureFragment.java	Sat Dec 15 18:15:42 2012 +0100
+++ b/src/com/beem/project/beem/ui/wizard/AccountConfigureFragment.java	Sat Dec 15 18:23:34 2012 +0100
@@ -99,6 +99,7 @@
     private Button mManualConfigButton;
     private Button mSelectAccountButton;
     private TextView mErrorLabel;
+    private TextView mSettingsWarningLabel;
     private EditText mAccountJID;
     private EditText mAccountPassword;
     private final JidTextWatcher mJidTextWatcher = new JidTextWatcher();
@@ -140,6 +141,7 @@
     	mSelectAccountButton = (Button) v.findViewById(R.id.select_account_btn);
     	mSelectAccountButton.setOnClickListener(this);
     	mErrorLabel = (TextView) v.findViewById(R.id.error_label);
+    	mSettingsWarningLabel = (TextView) v.findViewById(R.id.settings_warn_label);
     	mAccountJID = (EditText) v.findViewById(R.id.account_username);
     	mAccountPassword = (EditText) v.findViewById(R.id.account_password);
     	InputFilter[] orgFilters = mAccountJID.getFilters();
@@ -170,6 +172,12 @@
 	    mNextButton.setEnabled(true);
 	}
 	mAccountJID.addTextChangedListener(mJidTextWatcher);
+	if (settings.getBoolean(BeemApplication.ACCOUNT_SPECIFIC_SERVER_KEY, false)
+	    || settings.getBoolean(BeemApplication.PROXY_USE_KEY, false)) {
+	    mSettingsWarningLabel.setVisibility(View.VISIBLE);
+	} else
+	    mSettingsWarningLabel.setVisibility(View.GONE);
+
     }
 
     @TargetApi(14)
@@ -184,7 +192,12 @@
 		jid = StringUtils.parseBareAddress(jid);
 		String password = mAccountPassword.getText().toString();
 		task = new ConnectionTestTask();
-		task.execute(jid, password);
+		if (settings.getBoolean(BeemApplication.ACCOUNT_SPECIFIC_SERVER_KEY, false)) {
+		    String server = settings.getString(BeemApplication.ACCOUNT_SPECIFIC_SERVER_HOST_KEY, "");
+		    String port = settings.getString(BeemApplication.ACCOUNT_SPECIFIC_SERVER_PORT_KEY, "5222");
+		    task.execute(jid, password, server, port);
+		} else
+		    task.execute(jid, password);
 	    }
 	} else if (v == mManualConfigButton) {
 	    onManualConfigurationSelected();
@@ -414,7 +427,6 @@
 	    Log.d(TAG, "Xmpp login task");
 	    jid = params[0];
 	    password = params[1];
-	    Log.d(TAG, "jid " + jid + " server  " + server);
 
 	    int port = -1;
 	    if (params.length > 2) {
@@ -425,6 +437,7 @@
 		    port = Integer.parseInt(params[3]);
 		}
 	    }
+	    Log.d(TAG, "jid " + jid + " server  " + server + " port " + port);
 	    String login = StringUtils.parseName(jid);
 	    String serviceName = StringUtils.parseServer(jid);
 	    Connection connection = prepareConnection(jid, server, port);
--- a/src/com/beem/project/beem/ui/wizard/CreateAccountFragment.java	Sat Dec 15 18:15:42 2012 +0100
+++ b/src/com/beem/project/beem/ui/wizard/CreateAccountFragment.java	Sat Dec 15 18:23:34 2012 +0100
@@ -76,6 +76,7 @@
     private EditText password;
     private EditText confirmPassword;
     private TextView errorText;
+    private TextView mSettingsWarningLabel;
     private AutoCompleteTextView serverEdit;
     private Button createButton;
     private CreateAccountTask task;
@@ -115,6 +116,7 @@
 	confirmPassword = (EditText) v.findViewById(R.id.create_account_confirm_password);
 	confirmPassword.addTextChangedListener(mTextWatcher);
 	errorText = (TextView) v.findViewById(R.id.error_label);
+    	mSettingsWarningLabel = (TextView) v.findViewById(R.id.settings_warn_label);
 	createButton = (Button) v.findViewById(R.id.next);
 	createButton.setOnClickListener(this);
 	serverEdit = (AutoCompleteTextView) v.findViewById(R.id.xmpp_server);
@@ -135,6 +137,15 @@
     }
 
     @Override
+    public void onStart() {
+	super.onStart();
+	if (settings.getBoolean(BeemApplication.PROXY_USE_KEY, false)) {
+	    mSettingsWarningLabel.setVisibility(View.VISIBLE);
+	} else
+	    mSettingsWarningLabel.setVisibility(View.GONE);
+    }
+
+    @Override
     public void onClick(View v) {
 	if (v == createButton) {
 	    boolean create = true;