Commit 9ed45842 authored by Lucas Braz Cunha's avatar Lucas Braz Cunha
Browse files

Issue AGILE#164: New dialog to inform user of connection failure


Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent cc952995
......@@ -33,6 +33,7 @@ import java.util.HashMap;
import br.ufpr.c3sl.agendador.agendador.helpers.DataValidador;
import br.ufpr.c3sl.agendador.agendador.helpers.Mask;
import br.ufpr.c3sl.agendador.agendador.helpers.NoConnectionDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.presenters.AccountPresenter;
import br.ufpr.c3sl.agendador.agendador.views.AccountView;
......@@ -60,6 +61,8 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
private boolean editable, changingPassword;
private NoConnectionDialog dg_connection;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -543,7 +546,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
return;
}
//TODO: show password Warning Dialog on error
public void showPasswordWarning(){
FragmentManager manager = getFragmentManager();
PasswWarningDialog passwWarningDialog = new PasswWarningDialog();
......@@ -612,7 +615,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.signup_warningDialog_message) +
"\n" +
getString(R.string.signup_warningDialog_message2)).setTitle(getString(R.string.signup_warningDialog_title))
getString(R.string.signup_warningDialog_message2)).setTitle(getString(R.string.warningDialog_title))
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
......@@ -628,7 +631,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.account_cepWarningDialog_message) +
getString(R.string.signup_warningDialog_message2)).setTitle(getString(R.string.signup_warningDialog_title))
getString(R.string.signup_warningDialog_message2)).setTitle(getString(R.string.warningDialog_title))
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
......@@ -644,7 +647,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.account_passwWarningDialog_message) + "\n" +
getString(R.string.signup_warningDialog_message2)).setTitle(getString(R.string.signup_warningDialog_title))
getString(R.string.signup_warningDialog_message2)).setTitle(getString(R.string.warningDialog_title))
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
......@@ -712,5 +715,14 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
return values;
}
@Override
public void setNoConnection(boolean enabled){
if(enabled){
if(dg_connection == null){
dg_connection = new NoConnectionDialog();
}
dg_connection.show(getFragmentManager(), "noConnectionDialog");
}
}
}
......@@ -11,6 +11,7 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import br.ufpr.c3sl.agendador.agendador.helpers.Mask;
import br.ufpr.c3sl.agendador.agendador.helpers.NoConnectionDialog;
import br.ufpr.c3sl.agendador.agendador.presenters.CepPresenter;
import br.ufpr.c3sl.agendador.agendador.views.CepView;
......@@ -24,6 +25,7 @@ public class CepActivity extends AppCompatActivity implements CepView {
private EditText et_cep;
private TextView tv_invalid_cep;
private ProgressBar pb_waiting;
private NoConnectionDialog dg_connection;
@Override
public void onCreate(Bundle savedInstanceState) {
......@@ -87,8 +89,13 @@ public class CepActivity extends AppCompatActivity implements CepView {
}
@Override
public void setNoConnection(boolean enable) {
public void setNoConnection(boolean enabled) {
if(enabled){
if(dg_connection == null){
dg_connection = new NoConnectionDialog();
}
dg_connection.show(getFragmentManager(), "noConnectionDialog");
}
}
@Override
......
......@@ -2,7 +2,6 @@ package br.ufpr.c3sl.agendador.agendador;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.AppCompatActivity;
......@@ -10,7 +9,6 @@ import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextWatcher;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.view.View;
import android.widget.Button;
......@@ -19,6 +17,7 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import br.ufpr.c3sl.agendador.agendador.helpers.Mask;
import br.ufpr.c3sl.agendador.agendador.helpers.NoConnectionDialog;
import br.ufpr.c3sl.agendador.agendador.presenters.LoginPresenter;
import br.ufpr.c3sl.agendador.agendador.views.LoginView;
......@@ -33,6 +32,7 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
private EditText et_cpf, et_password;
private TextView tv_signup, tv_forgot_password, tv_description;
private ProgressBar pb_waiting;
private NoConnectionDialog dg_connection;
@Override
public void onCreate(Bundle savedInstanceState) {
......@@ -153,7 +153,12 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
@Override
public void setNoConnection(boolean enabled) {
// TODO: show an error (no connection)
if(enabled){
if(dg_connection == null){
dg_connection = new NoConnectionDialog();
}
dg_connection.show(getFragmentManager(), "noConnectionDialog");
}
}
@Override
......
......@@ -18,6 +18,7 @@ import java.util.HashMap;
import br.ufpr.c3sl.agendador.agendador.helpers.DataValidador;
import br.ufpr.c3sl.agendador.agendador.helpers.Mask;
import br.ufpr.c3sl.agendador.agendador.helpers.NoConnectionDialog;
import br.ufpr.c3sl.agendador.agendador.presenters.SignupPresenter;
import br.ufpr.c3sl.agendador.agendador.views.SignupView;
......@@ -35,6 +36,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
private TextView tv_cpf_warning,tv_name_warning,tv_rg_warning,tv_birthday_warning,
tv_phone_warning,tv_password_warning,tv_password_confirm_warning, tv_email_warning ;
private Intent intent;
private NoConnectionDialog dg_connection;
@Override
public void onCreate(Bundle savedInstanceState) {
......@@ -253,7 +255,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.signup_warningDialog_message) +
"\n" +
getString(R.string.signup_warningDialog_message2)).setTitle(getString(R.string.signup_warningDialog_title))
getString(R.string.signup_warningDialog_message2)).setTitle(getString(R.string.warningDialog_title))
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
......@@ -343,6 +345,16 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
btn_signup.setEnabled(true);
}
}
@Override
public void setNoConnection(boolean enabled){
if(enabled){
if(dg_connection == null){
dg_connection = new NoConnectionDialog();
}
dg_connection.show(getFragmentManager(), "noConnectionDialog");
}
}
}
......
package br.ufpr.c3sl.agendador.agendador.helpers;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import br.ufpr.c3sl.agendador.agendador.R;
/**
* Created by Lucas Braz Cunha on 20/03/17.
*/
public class NoConnectionDialog extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.noConnectionDialog_message))
.setTitle(getString(R.string.warningDialog_title))
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
return builder.create();
}
}
package br.ufpr.c3sl.agendador.agendador.presenters;
import android.content.Context;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
......@@ -68,7 +69,7 @@ public class AccountPresenter extends BasePresenter<AccountView> {
Map<String, String> body;
body = accountPresenter.view().getValues();
UserUpdate user= new UserUpdate(body);
AccountUpdate account;
final AccountUpdate account;
if (body.get("password")==null || body.get("password_confirmation")==null){
account = new AccountUpdate(user);
......@@ -88,11 +89,10 @@ public class AccountPresenter extends BasePresenter<AccountView> {
switch (status) {
case 404:
// accountPresenter.view().cpfExists();
accountPresenter.view().setProgressBar(false);
break;
case 422:
// accountPresenter.view().cpfExists();
accountPresenter.view().showPasswordWarning();
accountPresenter.view().setProgressBar(false);
updateToken(headers);
......@@ -109,15 +109,13 @@ public class AccountPresenter extends BasePresenter<AccountView> {
@Override
public void onFailure(Call<AccountOutput> call, Throwable t) {
accountPresenter.view().setProgressBar(true);
accountPresenter.view().setProgressBar(false);
accountPresenter.view().setNoConnection(true);
}
});
}
//TODO:implementar a confirmção
//public void onConfirmClicked(String cpf, String oldPassword, String newPassword) {}
public void onCepNotFocused(String cep) {
Map<String, String> header = new HashMap<>();
......
......@@ -87,8 +87,8 @@ public class SignupPresenter extends BasePresenter<SignupView> {
@Override
public void onFailure(Call<AccountOutput> call, Throwable t) {
signupPresenter.view().setProgressBar(true);
signupPresenter.view().setProgressBar(false);
signupPresenter.view().setNoConnection(true);
}
});
......
......@@ -16,4 +16,9 @@ public interface AccountView {
void successfulUpdate();
void scrollUp();
void showPasswordWarning();
void setNoConnection(boolean enabled);
}
......@@ -15,6 +15,7 @@ public interface SignupView {
void cpfExists();
void setNoConnection(boolean enabled);
}
......@@ -57,7 +57,7 @@
<string name="account_rg">RG*</string>
<string name="invalid_rg">RG inválido</string>
<string name="signup_warningDialog_message">Algumas informações não foram preenchidas ou estão incorretas no cadastro.</string>
<string name="signup_warningDialog_title">OPS</string>
<string name="warningDialog_title">OPS</string>
<string name="ok">OK</string>
<string name="signup_warningDialog_message2">"Por favor retorne e preencha novamente. "</string>
<string name="null_name">Nome vázio</string>
......@@ -92,4 +92,5 @@
<string name="optional">(Opcional)</string>
<string name="account_cepWarningDialog_message">A sua cidade não está no Agendador ou seu CEP não foi encontrado.</string>
<string name="account_passwWarningDialog_message">Senha incorreta!</string>
<string name="noConnectionDialog_message">Ocorreu um erro na conexão, tente novamente mais tarde.</string>
</resources>
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
#Mon Dec 28 10:00:20 PST 2015
#Thu Mar 16 09:36:43 BRT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
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