[288126d] | 1 | package ve.gob.cenditel.tibisaymovil; |
---|
| 2 | |
---|
| 3 | import android.app.Activity; |
---|
| 4 | import android.app.Dialog; |
---|
| 5 | import android.text.Editable; |
---|
| 6 | import android.text.TextWatcher; |
---|
| 7 | import android.view.Window; |
---|
| 8 | import android.widget.Button; |
---|
| 9 | import android.widget.EditText; |
---|
| 10 | import android.widget.TextView; |
---|
| 11 | |
---|
| 12 | public class PasswordConfirmationDialog extends Dialog implements TextWatcher { |
---|
| 13 | private PasswordConfirmationView viewHolder; |
---|
| 14 | |
---|
| 15 | public PasswordConfirmationDialog(Activity activity, int titleId) { |
---|
| 16 | |
---|
| 17 | super(activity); |
---|
| 18 | |
---|
| 19 | this.viewHolder = new PasswordConfirmationView(activity, titleId); |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | public void setAcceptListener(android.view.View.OnClickListener listener) { |
---|
| 23 | |
---|
| 24 | this.viewHolder.accept.setOnClickListener(listener); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | public String getPassword() { |
---|
| 28 | |
---|
| 29 | return this.viewHolder.password.getText().toString(); |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | @Override |
---|
| 33 | public void afterTextChanged(Editable s) { |
---|
| 34 | |
---|
| 35 | if (this.viewHolder.password.length() > 0 && this.viewHolder.password.getText().toString().equals( |
---|
| 36 | this.viewHolder.confirmation.getText().toString())) { |
---|
| 37 | this.viewHolder.accept.setEnabled(true); |
---|
| 38 | } else { |
---|
| 39 | this.viewHolder.accept.setEnabled(false); |
---|
| 40 | } |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | @Override |
---|
| 44 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {} |
---|
| 45 | |
---|
| 46 | @Override |
---|
| 47 | public void onTextChanged(CharSequence s, int start, int before, int count) {} |
---|
| 48 | |
---|
| 49 | private class PasswordConfirmationView { |
---|
| 50 | |
---|
| 51 | public EditText password; |
---|
| 52 | public EditText confirmation; |
---|
| 53 | public Button accept; |
---|
| 54 | public TextView title; |
---|
| 55 | |
---|
| 56 | public PasswordConfirmationView(Activity activity, int titleId) { |
---|
| 57 | |
---|
| 58 | setOwnerActivity(activity); |
---|
| 59 | requestWindowFeature(Window.FEATURE_NO_TITLE); |
---|
| 60 | setContentView(R.layout.password_confirmation); |
---|
| 61 | |
---|
| 62 | this.title = (TextView) findViewById(R.id.title); |
---|
| 63 | this.title.setText(titleId); |
---|
| 64 | |
---|
| 65 | this.password = (EditText) findViewById(R.id.password); |
---|
| 66 | this.confirmation = (EditText) findViewById(R.id.confirmation); |
---|
| 67 | this.accept = (Button) findViewById(R.id.button_accept); |
---|
| 68 | |
---|
| 69 | this.password.addTextChangedListener(PasswordConfirmationDialog.this); |
---|
| 70 | this.confirmation.addTextChangedListener(PasswordConfirmationDialog.this); |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | } |
---|