Confirm password when registering new XMPP account

parent d47bdcdd
...@@ -27,6 +27,8 @@ import android.widget.CheckBox; ...@@ -27,6 +27,8 @@ import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException; import com.xabber.android.data.NetworkException;
...@@ -89,6 +91,7 @@ public class AccountAdd extends ManagedActivity implements ...@@ -89,6 +91,7 @@ public class AccountAdd extends ManagedActivity implements
} }
((Button) findViewById(R.id.ok)).setOnClickListener(this); ((Button) findViewById(R.id.ok)).setOnClickListener(this);
createAccount.setOnClickListener(this);
InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(findViewById(R.id.ok) inputManager.hideSoftInputFromWindow(findViewById(R.id.ok)
.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
...@@ -155,6 +158,13 @@ public class AccountAdd extends ManagedActivity implements ...@@ -155,6 +158,13 @@ public class AccountAdd extends ManagedActivity implements
} else { } else {
EditText userView = (EditText) findViewById(R.id.account_user_name); EditText userView = (EditText) findViewById(R.id.account_user_name);
EditText passwordView = (EditText) findViewById(R.id.account_password); EditText passwordView = (EditText) findViewById(R.id.account_password);
EditText passwordConfirmView = (EditText) findViewById(R.id.confirm_password);
if(createAccount.isChecked() &&
!passwordView.getText().toString().contentEquals(passwordConfirmView.getText().toString())) {
Toast.makeText(this, getString(R.string.CONFIRM_PASSWORD),
Toast.LENGTH_LONG).show();
return;
}
String account; String account;
try { try {
account = AccountManager.getInstance().addAccount( account = AccountManager.getInstance().addAccount(
...@@ -172,6 +182,14 @@ public class AccountAdd extends ManagedActivity implements ...@@ -172,6 +182,14 @@ public class AccountAdd extends ManagedActivity implements
finish(); finish();
} }
break; break;
case R.id.register_account:
LinearLayout passwordConfirmView = (LinearLayout) findViewById(R.id.confirm_password_layout);
if(createAccount.isChecked()) {
passwordConfirmView.setVisibility(View.VISIBLE);
}
else {
passwordConfirmView.setVisibility(View.GONE);
}
default: default:
break; break;
} }
......
...@@ -90,6 +90,23 @@ ...@@ -90,6 +90,23 @@
android:checked="false" android:checked="false"
android:text="@string/account_register" /> android:text="@string/account_register" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/confirm_password_layout"
android:visibility="gone">
<TextView android:text="@string/confirm_password" android:layout_width="match_parent" android:layout_height="wrap_content" />
<EditText
android:id="@+id/confirm_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:password="true"
android:singleLine="true"
android:text=""
/>
</LinearLayout>
<LinearLayout <LinearLayout
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<string name="account_host">Host</string> <string name="account_host">Host</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_01.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_01.png -->
<string name="account_password">Password</string> <string name="account_password">Password</string>
<string name="confirm_password">Confirm password</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_02.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_02.png -->
<string name="account_port">Port</string> <string name="account_port">Port</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_02.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_02.png -->
...@@ -68,6 +69,7 @@ ...@@ -68,6 +69,7 @@
<string name="EMPTY_SERVER_NAME">Server name is not specified</string> <string name="EMPTY_SERVER_NAME">Server name is not specified</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_add_error.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_add_error.png -->
<string name="EMPTY_USER_NAME">Username is not specified</string> <string name="EMPTY_USER_NAME">Username is not specified</string>
<string name="CONFIRM_PASSWORD">Passwords do not match</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_03.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_03.png -->
<string name="account_archive_mode">Store message history</string> <string name="account_archive_mode">Store message history</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_history.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_history.png -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment