[8379cd8] | 1 | /* |
---|
| 2 | Tibisay Movil |
---|
| 3 | |
---|
| 4 | Copyright (C) 2013 Antonio Araujo (aaraujo@cenditel.gob.ve), Jose Ruiz |
---|
| 5 | (jruiz@cenditel.gob.ve), Fundacion Centro Nacional de Desarrollo e |
---|
| 6 | Investigacion en Tecnologias Libres - CENDITEL. |
---|
| 7 | |
---|
| 8 | La Fundación CENDITEL concede permiso para usar, copiar, distribuir y/o |
---|
| 9 | modificar este programa, reconociendo el derecho que la humanidad posee al |
---|
| 10 | libre acceso al conocimiento, bajo los términos de la licencia de software |
---|
| 11 | GPL versión 2.0 de la Free Software Foundation. |
---|
| 12 | |
---|
| 13 | Este programa se distribuye con la esperanza de que sea util, pero SIN |
---|
| 14 | NINGUNA GARANTIA; tampoco las implicitas garantias de MERCANTILIDAD o |
---|
| 15 | ADECUACION A UN PROPOSITO PARTICULAR. |
---|
| 16 | |
---|
| 17 | Para mayor información sobre los términos de la licencia ver el archivo |
---|
| 18 | llamado "gpl-2.0.txt" en ingles. |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | |
---|
[288126d] | 22 | package ve.gob.cenditel.tibisaymovil; |
---|
| 23 | |
---|
| 24 | import android.app.Activity; |
---|
| 25 | import android.app.Dialog; |
---|
| 26 | import android.text.Editable; |
---|
| 27 | import android.text.TextWatcher; |
---|
| 28 | import android.view.Window; |
---|
| 29 | import android.widget.Button; |
---|
| 30 | import android.widget.EditText; |
---|
| 31 | import android.widget.TextView; |
---|
| 32 | |
---|
| 33 | public class PasswordConfirmationDialog extends Dialog implements TextWatcher { |
---|
| 34 | private PasswordConfirmationView viewHolder; |
---|
| 35 | |
---|
| 36 | public PasswordConfirmationDialog(Activity activity, int titleId) { |
---|
| 37 | |
---|
| 38 | super(activity); |
---|
| 39 | |
---|
| 40 | this.viewHolder = new PasswordConfirmationView(activity, titleId); |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | public void setAcceptListener(android.view.View.OnClickListener listener) { |
---|
| 44 | |
---|
| 45 | this.viewHolder.accept.setOnClickListener(listener); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | public String getPassword() { |
---|
| 49 | |
---|
| 50 | return this.viewHolder.password.getText().toString(); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | @Override |
---|
| 54 | public void afterTextChanged(Editable s) { |
---|
| 55 | |
---|
| 56 | if (this.viewHolder.password.length() > 0 && this.viewHolder.password.getText().toString().equals( |
---|
| 57 | this.viewHolder.confirmation.getText().toString())) { |
---|
| 58 | this.viewHolder.accept.setEnabled(true); |
---|
| 59 | } else { |
---|
| 60 | this.viewHolder.accept.setEnabled(false); |
---|
| 61 | } |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | @Override |
---|
| 65 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {} |
---|
| 66 | |
---|
| 67 | @Override |
---|
| 68 | public void onTextChanged(CharSequence s, int start, int before, int count) {} |
---|
| 69 | |
---|
| 70 | private class PasswordConfirmationView { |
---|
| 71 | |
---|
| 72 | public EditText password; |
---|
| 73 | public EditText confirmation; |
---|
| 74 | public Button accept; |
---|
| 75 | public TextView title; |
---|
| 76 | |
---|
| 77 | public PasswordConfirmationView(Activity activity, int titleId) { |
---|
| 78 | |
---|
| 79 | setOwnerActivity(activity); |
---|
| 80 | requestWindowFeature(Window.FEATURE_NO_TITLE); |
---|
| 81 | setContentView(R.layout.password_confirmation); |
---|
| 82 | |
---|
| 83 | this.title = (TextView) findViewById(R.id.title); |
---|
| 84 | this.title.setText(titleId); |
---|
| 85 | |
---|
| 86 | this.password = (EditText) findViewById(R.id.password); |
---|
| 87 | this.confirmation = (EditText) findViewById(R.id.confirmation); |
---|
| 88 | this.accept = (Button) findViewById(R.id.button_accept); |
---|
| 89 | |
---|
| 90 | this.password.addTextChangedListener(PasswordConfirmationDialog.this); |
---|
| 91 | this.confirmation.addTextChangedListener(PasswordConfirmationDialog.this); |
---|
| 92 | } |
---|
| 93 | } |
---|
| 94 | } |
---|