Commit 8e7761f8 authored by Lucas Braz Cunha's avatar Lucas Braz Cunha

Merge branch 'recuperar_senha' into 'develop'

Password retrieval layout

See merge request !15
parents b9c53b3d ee6baa5c
......@@ -35,7 +35,7 @@
<activity android:name=".CepNotFoundActivity" />
<activity android:name=".SignUpActivity" />
<activity android:name=".AccountActivity" />
<activity android:name=".ForgotPasswordActivity" />
<activity android:name=".PasswordRetrievalActivity" />
<activity android:name=".DependentsListActivity" />
<service
......@@ -52,10 +52,12 @@
android:name=".SchedulingActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" />
<activity android:name=".CitizenActivity" />
<activity android:name=".CitizenListActivity" />
<activity android:name=".ScheduleConfirmationActivity" />
<activity android:name=".DependentUpdateActivity" />
<activity android:name=".NewDependentActivity"/>
<activity android:name=".NewDependentActivity" />
<activity android:name=".RetrievalFailureActivity" />
<activity android:name=".RetrievalSuccessActivity"></activity>
</application>
</manifest>
\ No newline at end of file
......@@ -24,11 +24,13 @@ import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.text.method.PasswordTransformationMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
......@@ -181,11 +183,20 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
userImgHelper = new UserImgHelper(getBaseContext());
et_cep.addTextChangedListener(Mask.insert("#####-###", et_cep));
et_phone.addTextChangedListener(Mask.insert("(##)####-####", et_phone));
et_phone2.addTextChangedListener(Mask.insert("(##)####-####", et_phone2));
et_cpf.addTextChangedListener(Mask.insert("###.###.###-##", et_cpf));
et_birthdate.addTextChangedListener(Mask.insert("##/##/####", et_birthdate));
et_cep.addTextChangedListener(Mask.insert(Utils.CEP_MASK, et_cep));
et_cep.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.CEP_MASK.length())});
et_phone.addTextChangedListener(Mask.insert(Utils.PHONE_MASK, et_phone));
et_phone.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.PHONE_MASK.length())});
et_phone2.addTextChangedListener(Mask.insert(Utils.PHONE_MASK, et_phone2));
et_phone2.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.PHONE_MASK.length())});
et_cpf.addTextChangedListener(Mask.insert(Utils.CPF_MASK, et_cpf));
et_cpf.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.CPF_MASK.length())});
et_birthdate.addTextChangedListener(Mask.insert(Utils.BIRTH_DAY_MASK, et_birthdate));
et_birthdate.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.BIRTH_DAY_MASK.length())});
loadData();
......@@ -408,15 +419,25 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
public void scrollUp() {
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appbar_account);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
NestedScrollView nestedScrollView = (NestedScrollView) findViewById(R.id.nestedscrollview_account);
nestedScrollView.fullScroll(View.FOCUS_UP);
//close keyboard if open
View view = this.getCurrentFocus();
// Check if no view has focus:
if (view != null) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
view.clearFocus();
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior();
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorlayout_account);
if (behavior != null) {
behavior.setTopAndBottomOffset(0);
behavior.onNestedPreScroll(coordinatorLayout, appBarLayout, null, 0, 1, new int[2]);
}
nestedScrollView.fullScroll(View.FOCUS_UP);
......@@ -848,7 +869,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
values.put(Utils.NAME, et_name.getText().toString());
values.put(Utils.RG, et_rg.getText().toString());
values.put(Utils.BIRTH_DATE, DateValidator.stringToDate(et_birthdate.getText().toString(), false));
values.put(Utils.BIRTH_DAY, DateValidator.stringToDate(et_birthdate.getText().toString(), false));
if (rb_no.isChecked()) {
values.put(Utils.PCD, null);
......
......@@ -3,6 +3,7 @@ package br.ufpr.c3sl.agendador.agendador;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
......@@ -12,6 +13,7 @@ import android.widget.TextView;
import br.ufpr.c3sl.agendador.agendador.helpers.Mask;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.presenters.CepPresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.views.CepView;
......@@ -46,7 +48,9 @@ public class CepActivity extends AppCompatActivity implements CepView {
pb_waiting = (ProgressBar) findViewById(R.id.pb_cepact);
et_cep = (EditText) findViewById(R.id.et_cepact_cep);
et_cep.addTextChangedListener(Mask.insert("#####-###", et_cep));
et_cep.addTextChangedListener(Mask.insert(Utils.CEP_MASK, et_cep));
et_cep.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.CPF_MASK.length())});
et_cep.addTextChangedListener(new CepChangeListener());
tv_invalid_cep = (TextView) findViewById(R.id.tv_cepact_invalid_cep);
......
......@@ -47,7 +47,7 @@ public class CepNotFoundActivity extends AppCompatActivity implements CepNotFoun
String state_name = intent.getStringExtra("statename_su");
if (city_name.equals("null")) {
error_message.setText("Cep inválido");
error_message.setText(getResources().getString(R.string.invalid_cep));
} else {
error_message.setText(String.format(getString(R.string.cep_not_found_message),
city_name, state_name));
......
......@@ -20,7 +20,6 @@ import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.helpers.adapters.CitizensArrayAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.listeners.RecyclerViewItemListener;
import br.ufpr.c3sl.agendador.agendador.models.CitizenCompact;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.presenters.CitizensPresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.views.CitizenView;
......@@ -31,7 +30,7 @@ import br.ufpr.c3sl.agendador.agendador.views.CitizenView;
*/
public class CitizenActivity extends AppCompatActivity implements CitizenView{
public class CitizenListActivity extends AppCompatActivity implements CitizenView{
private RecyclerView rv_citizens;
......@@ -73,7 +72,7 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
rv_citizens.addOnItemTouchListener(new RecyclerViewItemListener(getApplicationContext(), rv_citizens,
new RecyclerViewItemListener.RecyclerTouchListener() {
public void onClickItem(View v, int position) {
Intent intent = new Intent(CitizenActivity.this, TermActivity.class);
Intent intent = new Intent(CitizenListActivity.this, TermActivity.class);
Bundle bundle = new Bundle();
bundle.putParcelable(Utils.CITIZEN, citizens.get(position));
intent.putExtra(Utils.CITIZEN_BUNDLE, bundle);
......
......@@ -4,6 +4,7 @@ import android.Manifest;
import android.annotation.TargetApi;
import android.app.FragmentManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
......@@ -19,11 +20,12 @@ import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
......@@ -86,12 +88,6 @@ public class DependentUpdateActivity extends AppCompatActivity implements Depend
private final int LOAD_IMAGE_INTENT = 1;
// TODO: 18/09/17 Cep error dialog shows twice on error
//problema da atualização da foto está na dependent activity.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -160,11 +156,21 @@ public class DependentUpdateActivity extends AppCompatActivity implements Depend
isChangingPhoto = false;
userImgHelper = new UserImgHelper(getBaseContext());
et_disability.setEnabled(false);
et_cep.addTextChangedListener(Mask.insert("#####-###", et_cep));
et_phone.addTextChangedListener(Mask.insert("(##)####-####", et_phone));
et_phone2.addTextChangedListener(Mask.insert("(##)####-####", et_phone2));
et_cpf.addTextChangedListener(Mask.insert("###.###.###-##", et_cpf));
et_birthdate.addTextChangedListener(Mask.insert("##/##/####", et_birthdate));
et_cep.addTextChangedListener(Mask.insert(Utils.CEP_MASK, et_cep));
et_cep.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.CEP_MASK.length())});
et_phone.addTextChangedListener(Mask.insert(Utils.PHONE_MASK, et_phone));
et_phone.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.PHONE_MASK.length())});
et_phone2.addTextChangedListener(Mask.insert(Utils.PHONE_MASK, et_phone2));
et_phone2.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.PHONE_MASK.length())});
et_cpf.addTextChangedListener(Mask.insert(Utils.CPF_MASK, et_cpf));
et_cpf.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.CPF_MASK.length())});
et_birthdate.addTextChangedListener(Mask.insert(Utils.BIRTH_DAY_MASK, et_birthdate));
et_birthdate.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.BIRTH_DAY_MASK.length())});
try{
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
......@@ -385,6 +391,14 @@ public class DependentUpdateActivity extends AppCompatActivity implements Depend
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
NestedScrollView nestedScrollView = (NestedScrollView) findViewById(R.id.nestedscrollview_dependents);
//close keyboard if open
View view = this.getCurrentFocus();
// Check if no view has focus:
if (view != null) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
view.clearFocus();
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior();
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorlayout_dependents);
......@@ -528,7 +542,7 @@ public class DependentUpdateActivity extends AppCompatActivity implements Depend
values.put(Utils.RG, et_rg.getText().toString().trim());
values.put(Utils.BIRTH_DATE, DateValidator.stringToDate(et_birthdate.getText().toString(), false));
values.put(Utils.BIRTH_DAY, DateValidator.stringToDate(et_birthdate.getText().toString(), false));
values.put(Utils.CEP, Mask.unmask(et_cep.getText().toString()));
......
package br.ufpr.c3sl.agendador.agendador;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import br.ufpr.c3sl.agendador.agendador.presenters.ForgotPasswordPresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.views.ForgotPasswordView;
/**
* Created by Horstmann on 23/02/17.
*/
public class ForgotPasswordActivity extends AppCompatActivity implements ForgotPasswordView {
private ForgotPasswordPresenter presenter;
private Button btn_send;
private EditText et_cpf;
private TextView tv_cpf, tv_cpf_warning;
private ProgressBar pb_waiting;
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
presenter = new ForgotPasswordPresenter(this);
} else {
presenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
if(presenter == null)
presenter = new ForgotPasswordPresenter(this);
}
setContentView(R.layout.activity_login);
tv_cpf = (TextView) findViewById(R.id.tv_forgot_password_cpf);
tv_cpf_warning = (TextView) findViewById(R.id.tv_forgot_password_invalid_cpf);
}
@Override
public void setProgressBar(boolean enabled) {
}
}
......@@ -7,11 +7,11 @@ import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
......@@ -137,7 +137,7 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
btn_schedule.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(HomeActivity.this, CitizenActivity.class);
Intent intent = new Intent(HomeActivity.this, CitizenListActivity.class);
startActivity(intent);
}
});
......@@ -157,15 +157,10 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
private void changeTextColor(){
//Changing text style
SpannableString text = new SpannableString(getString(R.string.schedules_more_information));
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
text.setSpan(new ForegroundColorSpan(getColor(R.color.colorGreen)), 123, 143, 0);
text.setSpan(new ForegroundColorSpan(getColor(R.color.colorGreen)), 88, 108, 0);
} else{
text.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.colorGreen)), 123, 143, 0);
text.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.colorGreen, null)), 123, 143, 0);
text.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.colorGreen)), 88, 108, 0);
}
text.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.colorGreen, null)), 88, 108, 0);
tv_presentation.setText(text, TextView.BufferType.SPANNABLE);
}
......@@ -234,7 +229,7 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
startActivity(intent);
break;
case R.id.nav_schedule:
intent = new Intent(this, CitizenActivity.class);
intent = new Intent(this, CitizenListActivity.class);
startActivity(intent);
break;
case R.id.nav_dependants:
......
......@@ -7,11 +7,11 @@ import android.os.Bundle;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.InputFilter;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextWatcher;
import android.text.style.StyleSpan;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
......@@ -66,7 +66,10 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
pb_waiting = (ProgressBar) findViewById(R.id.pb_loginact);
et_cpf = (EditText) findViewById(R.id.et_loginact_cpf);
et_cpf.addTextChangedListener(Mask.insert("###.###.###-##", et_cpf));
et_cpf.addTextChangedListener(Mask.insert(Utils.CPF_MASK, et_cpf));
et_cpf.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.CPF_MASK.length())});
et_cpf.addTextChangedListener(new LoginChangeListener());
et_password = (EditText) findViewById(R.id.et_loginact_password);
......@@ -78,7 +81,8 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
tv_forgot_password.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
presenter.onForgotPasswordClicked();
Intent intent = new Intent(getBaseContext(), PasswordRetrievalActivity.class);
startActivity(intent);
}
});
......@@ -151,16 +155,15 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
@Override
public void setProgressBar(boolean enabled) {
ProgressBar pb_login = (ProgressBar) findViewById(R.id.pb_loginact);
EditText et_cpf = (EditText) findViewById(R.id.et_loginact_cpf);
EditText et_password = (EditText) findViewById(R.id.et_loginact_password);
if (enabled) {
pb_login.setVisibility(View.VISIBLE);
pb_waiting.setVisibility(View.VISIBLE);
et_cpf.setEnabled(false);
et_password.setEnabled(false);
} else {
pb_login.setVisibility(View.INVISIBLE);
pb_waiting.setVisibility(View.INVISIBLE);
et_cpf.setEnabled(true);
et_password.setEnabled(true);
}
......
......@@ -5,6 +5,7 @@ import android.annotation.TargetApi;
import android.app.Activity;
import android.app.FragmentManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
......@@ -20,10 +21,11 @@ import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
......@@ -46,7 +48,6 @@ import br.ufpr.c3sl.agendador.agendador.helpers.UserImgHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.helpers.adapters.PhotoSelectionAdapter;
import br.ufpr.c3sl.agendador.agendador.models.FullDependent;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.presenters.NewDependentPresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.views.NewDependentsView;
......@@ -144,11 +145,23 @@ public class NewDependentActivity extends AppCompatActivity implements NewDepen
isChangingPhoto = false;
userImgHelper = new UserImgHelper(getBaseContext());
et_disability.setEnabled(false);
et_cep.addTextChangedListener(Mask.insert("#####-###", et_cep));
et_phone.addTextChangedListener(Mask.insert("(##)####-####", et_phone));
et_phone2.addTextChangedListener(Mask.insert("(##)####-####", et_phone2));
et_cpf.addTextChangedListener(Mask.insert("###.###.###-##", et_cpf));
et_birthdate.addTextChangedListener(Mask.insert("##/##/####", et_birthdate));
et_cep.addTextChangedListener(Mask.insert(Utils.CEP_MASK, et_cep));
et_cep.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.CEP_MASK.length())});
et_phone.addTextChangedListener(Mask.insert(Utils.PHONE_MASK, et_phone));
et_phone.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.PHONE_MASK.length())});
et_phone2.addTextChangedListener(Mask.insert(Utils.PHONE_MASK, et_phone2));
et_phone2.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.PHONE_MASK.length())});
et_cpf.addTextChangedListener(Mask.insert(Utils.CPF_MASK, et_cpf));
et_cpf.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.CPF_MASK.length())});
et_birthdate.addTextChangedListener(Mask.insert(Utils.BIRTH_DAY_MASK, et_birthdate));
et_birthdate.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.BIRTH_DAY_MASK.length())});
try{
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
......@@ -441,7 +454,7 @@ public class NewDependentActivity extends AppCompatActivity implements NewDepen
if(!et_rg.getText().toString().isEmpty())
values.put(Utils.RG, et_rg.getText().toString().trim());
values.put(Utils.BIRTH_DATE, DateValidator.stringToDate(et_birthdate.getText().toString(), false));
values.put(Utils.BIRTH_DAY, DateValidator.stringToDate(et_birthdate.getText().toString(), false));
if (rb_no.isChecked()) {
values.put(Utils.PCD, null);
......@@ -490,7 +503,16 @@ public class NewDependentActivity extends AppCompatActivity implements NewDepen
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
NestedScrollView nestedScrollView = (NestedScrollView) findViewById(R.id.nestedscrollview_dependents);
nestedScrollView.fullScroll(View.FOCUS_UP);
//close keyboard if open
View view = this.getCurrentFocus();
// Check if no view has focus:
if (view != null) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
view.clearFocus();
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior();
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorlayout_dependents);
......
package br.ufpr.c3sl.agendador.agendador;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.AppCompatActivity;
import android.text.InputFilter;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import br.ufpr.c3sl.agendador.agendador.helpers.Mask;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.presenters.ForgotPasswordPresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.views.ForgotPasswordView;
/**
* Created by Horstmann on 23/02/17.
*/
public class PasswordRetrievalActivity extends AppCompatActivity implements ForgotPasswordView {
private ForgotPasswordPresenter presenter;
private Button bt_send;
private EditText et_cpf;
private TextView tv_cpf_warning;
private ProgressBar pb_waiting;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
presenter = new ForgotPasswordPresenter(this);
} else {
presenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
if(presenter == null)
presenter = new ForgotPasswordPresenter(this);
}
setContentView(R.layout.activity_password_retrieval);
tv_cpf_warning = (TextView) findViewById(R.id.tv_passwd_retriev_invalid_cpf);
et_cpf = (EditText) findViewById(R.id.et_passwd_retriev_cpf);
et_cpf.addTextChangedListener(Mask.insert(Utils.CPF_MASK, et_cpf));
et_cpf.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.CPF_MASK.length())});
pb_waiting = (ProgressBar) findViewById(R.id.pb_passwd_retriev_act);
bt_send = (Button) findViewById(R.id.bt_passwd_retriev_send);
Button bt_back = (Button) findViewById(R.id.bt_passwd_retriev_back);
bt_send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_cpf_warning.setVisibility(View.INVISIBLE);
onRequestSuccess();
onRequestFailure();
/*if(!et_cpf.getText().toString().replaceAll("\\s+", "").isEmpty() && !DateValidator.isValidCPF(et_cpf.getText().toString().replaceAll("\\.", "").replace("-",""))) {
setProgressBar(true);
presenter.requestNewPassword();
}
else{
tv_cpf_warning.setVisibility(View.VISIBLE);
}*/
}
});
bt_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
@Override
public void onBackPressed() {
//-> if request is on the way, cancel
//-> back to prior activity. finish();
super.onBackPressed();
}
@Override
public void setProgressBar(boolean enabled) {
if(enabled){
pb_waiting.setVisibility(View.VISIBLE);
bt_send.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.disabled_container_shape, null));
}else{
pb_waiting.setVisibility(View.INVISIBLE);
bt_send.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.green_button_shape, null));
}
et_cpf.setEnabled(!enabled);
bt_send.setEnabled(!enabled);
}
public void onRequestFailure(){
Intent intent = new Intent(PasswordRetrievalActivity.this, RetrievalFailureActivity.class);
startActivity(intent);
}
public void onRequestSuccess(){
Intent intent = new Intent(PasswordRetrievalActivity.this, RetrievalSuccessActivity.class);
startActivity(intent);
}
@Override
public String getCpf() {
return et_cpf.getText().toString().replaceAll("\\.", "").replace("-","");
}
}
package br.ufpr.c3sl.agendador.agendador;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
public class RetrievalFailureActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_retrieval_failure);
ImageView back = (ImageView) findViewById(R.id.bt_retriev_fail_back);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}
package br.ufpr.c3sl.agendador.agendador;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
public class RetrievalSuccessActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_retrieval_success);
ImageView back = (ImageView) findViewById(R.id.bt_retrieval_succ_back);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}