Commit a0943d82 authored by Lucas Braz Cunha's avatar Lucas Braz Cunha

Issue AGILE#198 Confirmation done

Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent 3b03eaec
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application <application
android:allowBackup="true" android:allowBackup="false"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true" android:supportsRtl="true"
......
...@@ -255,7 +255,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -255,7 +255,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
} }
else{ else{
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_cep_connection_error)); bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_cep_connection_error));
if(connectionErrorDialog == null){ if(connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog(); connectionErrorDialog = new ConnectionErrorDialog();
} }
...@@ -285,7 +285,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -285,7 +285,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
connectionErrorDialog = new ConnectionErrorDialog(); connectionErrorDialog = new ConnectionErrorDialog();
} }
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_no_connection_message)); bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_no_connection_message));
connectionErrorDialog.setArguments(bundle); connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR); connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
scrollUp(); scrollUp();
...@@ -394,11 +394,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -394,11 +394,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
else else
imv_profile.setImageBitmap(null); imv_profile.setImageBitmap(null);
} else { } else {
/*Intent intent = new Intent(AccountActivity.this, HomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);*/
super.onBackPressed(); super.onBackPressed();
finish();
} }
} }
...@@ -436,10 +432,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -436,10 +432,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
else else
imv_profile.setImageBitmap(null); imv_profile.setImageBitmap(null);
} else { } else {
Intent intent = new Intent(AccountActivity.this, HomeActivity.class); onBackPressed();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
} }
return true; return true;
case R.id.btn_edit_account: case R.id.btn_edit_account:
...@@ -779,7 +772,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -779,7 +772,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.signup_warningDialog_message) + "\n" + builder.setMessage(getString(R.string.signup_warningDialog_message) + "\n" +
getString(R.string.signup_warningDialog_message2)) getString(R.string.signup_warningDialog_message2))
.setTitle(getString(R.string.signup_warningDialog_title)) .setTitle(getString(R.string.warningDialog_title))
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
dismiss(); dismiss();
...@@ -798,7 +791,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -798,7 +791,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.dialog_cep_warning_message) + builder.setMessage(getString(R.string.dialog_cep_warning_message) +
getString(R.string.signup_warningDialog_message2)) getString(R.string.signup_warningDialog_message2))
.setTitle(getString(R.string.signup_warningDialog_title)) .setTitle(getString(R.string.warningDialog_title))
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
} }
...@@ -898,7 +891,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -898,7 +891,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
connectionErrorDialog = new ConnectionErrorDialog(); connectionErrorDialog = new ConnectionErrorDialog();
} }
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_connection_error_message)); bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_connection_error_message));
connectionErrorDialog.setArguments(bundle); connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR); connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
} }
...@@ -912,7 +905,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -912,7 +905,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
connectionErrorDialog = new ConnectionErrorDialog(); connectionErrorDialog = new ConnectionErrorDialog();
} }
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_cep_connection_error)); bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_cep_connection_error));
connectionErrorDialog.setArguments(bundle); connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR); connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
...@@ -926,7 +919,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -926,7 +919,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
connectionErrorDialog = new ConnectionErrorDialog(); connectionErrorDialog = new ConnectionErrorDialog();
} }
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_no_connection_message)); bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_no_connection_message));
connectionErrorDialog.setArguments(bundle); connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR); connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
} }
......
...@@ -68,12 +68,12 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{ ...@@ -68,12 +68,12 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
rv_citizens.addOnItemTouchListener(new CitizensItemListener(getApplicationContext(), rv_citizens, rv_citizens.addOnItemTouchListener(new CitizensItemListener(getApplicationContext(), rv_citizens,
new CitizensItemListener.RecyclerTouchListener() { new CitizensItemListener.RecyclerTouchListener() {
public void onClickItem(View v, int position) { public void onClickItem(View v, int position) {
Intent intent = new Intent(CitizenActivity.this, SchedulingActivity.class); Intent intent = new Intent(CitizenActivity.this, TermActivity.class);
Bundle bundle = getIntent().getBundleExtra(Utils.SECTORS_BUNDLE); Bundle bundle = new Bundle();
bundle.putParcelable(Utils.CITIZEN, citizens.get(position)); bundle.putParcelable(Utils.CITIZEN, citizens.get(position));
intent.putExtra(Utils.SECTORS_CITIZENS_BUNDLE, bundle); intent.putExtra(Utils.CITIZEN_BUNDLE, bundle);
startActivity(intent); startActivity(intent);
finish();
} }
public void onLongClickItem(View v, int position) { public void onLongClickItem(View v, int position) {
...@@ -81,8 +81,6 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{ ...@@ -81,8 +81,6 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
} }
})); }));
citizensPresenter.bindView(this);
citizensPresenter.requestCitizens();
} }
...@@ -91,7 +89,7 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{ ...@@ -91,7 +89,7 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
citizensPresenter.bindView(this); citizensPresenter.bindView(this);
citizensPresenter.requestCitizens();
} }
@Override @Override
...@@ -100,6 +98,13 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{ ...@@ -100,6 +98,13 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
citizensPresenter.unbindView(); citizensPresenter.unbindView();
} }
@Override
protected void onStart() {
super.onStart();
}
public void showLayout(boolean enabled) { public void showLayout(boolean enabled) {
rv_citizens.setAdapter(new CitizensArrayAdapter(this, citizens)); rv_citizens.setAdapter(new CitizensArrayAdapter(this, citizens));
...@@ -115,7 +120,7 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{ ...@@ -115,7 +120,7 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
if(dg_connection_failure == null){ if(dg_connection_failure == null){
dg_connection_failure = new ConnectionFailureDialog(); dg_connection_failure = new ConnectionFailureDialog();
} }
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_term_error)); bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_term_error));
dg_connection_failure.setArguments(bundle); dg_connection_failure.setArguments(bundle);
dg_connection_failure.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR); dg_connection_failure.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
......
package br.ufpr.c3sl.agendador.agendador; package br.ufpr.c3sl.agendador.agendador;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.DialogFragment; import android.app.DialogFragment;
...@@ -12,6 +11,7 @@ import android.os.Build; ...@@ -12,6 +11,7 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView; import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.view.GravityCompat; import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
...@@ -21,7 +21,6 @@ import android.support.v7.widget.ActionMenuView; ...@@ -21,7 +21,6 @@ import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.style.ForegroundColorSpan; import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
...@@ -29,16 +28,11 @@ import android.view.View; ...@@ -29,16 +28,11 @@ import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.firebase.jobdispatcher.FirebaseJobDispatcher;
import com.firebase.jobdispatcher.GooglePlayDriver;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences; import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.UserPhotoHelper; import br.ufpr.c3sl.agendador.agendador.helpers.UserPhotoHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.presenters.HomePresenter; import br.ufpr.c3sl.agendador.agendador.presenters.HomePresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.ScheduleConfirmationPresenter;
import br.ufpr.c3sl.agendador.agendador.services.ImageUpdateService;
import br.ufpr.c3sl.agendador.agendador.views.HomeView; import br.ufpr.c3sl.agendador.agendador.views.HomeView;
/** /**
...@@ -46,10 +40,6 @@ import br.ufpr.c3sl.agendador.agendador.views.HomeView; ...@@ -46,10 +40,6 @@ import br.ufpr.c3sl.agendador.agendador.views.HomeView;
*/ */
// TODO: 03/07/17 Sugestão: após agendamento perguntar se usuário quer visualizar sua lista de agendamentos.
public class HomeActivity extends AppCompatActivity implements HomeView, public class HomeActivity extends AppCompatActivity implements HomeView,
NavigationView.OnNavigationItemSelectedListener { NavigationView.OnNavigationItemSelectedListener {
private HomePresenter presenter; private HomePresenter presenter;
...@@ -60,6 +50,10 @@ public class HomeActivity extends AppCompatActivity implements HomeView, ...@@ -60,6 +50,10 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
private ConfirmationDialog confirmationDialog; private ConfirmationDialog confirmationDialog;
private Snackbar snackbar;
public static String SHOW_SCHEDULE_SNACKBAR = "snack_bar";
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -138,12 +132,20 @@ public class HomeActivity extends AppCompatActivity implements HomeView, ...@@ -138,12 +132,20 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
btn_schedule.setOnClickListener(new View.OnClickListener() { btn_schedule.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(HomeActivity.this, TermActivity.class); Intent intent = new Intent(HomeActivity.this, CitizenActivity.class);
startActivity(intent); startActivity(intent);
} }
}); });
snackbar = Snackbar.make(findViewById(R.id.coordinator_home), R.string.snackbar_home_description,Snackbar.LENGTH_LONG)
.setAction(R.string.snackbar_home_action, new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getBaseContext(), "Abrir a tela de agendamentos", Toast.LENGTH_SHORT).show();
}
});
changeTextColor(); changeTextColor();
showSnackBar(getIntent());
} }
@TargetApi(23) @TargetApi(23)
...@@ -217,15 +219,35 @@ public class HomeActivity extends AppCompatActivity implements HomeView, ...@@ -217,15 +219,35 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
case R.id.nav_my_info: case R.id.nav_my_info:
intent = new Intent(this, AccountActivity.class); intent = new Intent(this, AccountActivity.class);
startActivity(intent); startActivity(intent);
break;
return true;
case R.id.nav_schedule: case R.id.nav_schedule:
intent = new Intent(this, TermActivity.class); intent = new Intent(this, CitizenActivity.class);
item.setChecked(false);
startActivity(intent); startActivity(intent);
break;
default: default:
break;
}
return true;
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
showSnackBar(intent);
}
private void showSnackBar(Intent intent){
if(intent != null){
Bundle extras = intent.getBundleExtra(SHOW_SCHEDULE_SNACKBAR);
if (extras != null) {
int b = extras.getInt(SHOW_SCHEDULE_SNACKBAR, 0);
if(b != 0){
snackbar.show();
}
}
} }
return false;
} }
......
...@@ -102,7 +102,7 @@ public class LoginActivity extends AppCompatActivity implements LoginView { ...@@ -102,7 +102,7 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
if (dg_connection_error == null) if (dg_connection_error == null)
dg_connection_error = new ConnectionErrorDialog(); dg_connection_error = new ConnectionErrorDialog();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_no_connection_message)); bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_no_connection_message));
dg_connection_error.setArguments(bundle); dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR); dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
setWrongPassword(false); setWrongPassword(false);
...@@ -189,7 +189,7 @@ public class LoginActivity extends AppCompatActivity implements LoginView { ...@@ -189,7 +189,7 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
if(dg_connection_error == null){ if(dg_connection_error == null){
dg_connection_error = new ConnectionErrorDialog(); dg_connection_error = new ConnectionErrorDialog();
} }
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_connection_error_message)); bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_connection_error_message));
dg_connection_error.setArguments(bundle); dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR); dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
} }
......
...@@ -15,6 +15,7 @@ import android.support.v7.app.AppCompatActivity; ...@@ -15,6 +15,7 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.view.menu.MenuBuilder; import android.support.v7.view.menu.MenuBuilder;
import android.support.v7.widget.ActionMenuView; import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
...@@ -24,8 +25,6 @@ import android.widget.ImageView; ...@@ -24,8 +25,6 @@ import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import org.w3c.dom.Text;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Locale; import java.util.Locale;
...@@ -34,10 +33,7 @@ import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog; ...@@ -34,10 +33,7 @@ import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences; import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.UserPhotoHelper; import br.ufpr.c3sl.agendador.agendador.helpers.UserPhotoHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils; import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.SectorInput; import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation;
import br.ufpr.c3sl.agendador.agendador.models.ServiceLocation;
import br.ufpr.c3sl.agendador.agendador.models.ServiceSchedule;
import br.ufpr.c3sl.agendador.agendador.models.ServiceType;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput; import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.presenters.ScheduleConfirmationPresenter; import br.ufpr.c3sl.agendador.agendador.presenters.ScheduleConfirmationPresenter;
import br.ufpr.c3sl.agendador.agendador.views.ScheduleConfirmationView; import br.ufpr.c3sl.agendador.agendador.views.ScheduleConfirmationView;
...@@ -46,6 +42,7 @@ import br.ufpr.c3sl.agendador.agendador.views.ScheduleConfirmationView; ...@@ -46,6 +42,7 @@ import br.ufpr.c3sl.agendador.agendador.views.ScheduleConfirmationView;
* Created by Lucas B. Cunha on 25/07/17. * Created by Lucas B. Cunha on 25/07/17.
*/ */
public class ScheduleConfirmationActivity extends AppCompatActivity implements ScheduleConfirmationView, NavigationView.OnNavigationItemSelectedListener{ public class ScheduleConfirmationActivity extends AppCompatActivity implements ScheduleConfirmationView, NavigationView.OnNavigationItemSelectedListener{
private ScheduleConfirmationPresenter scheduleConfirmationPresenter; private ScheduleConfirmationPresenter scheduleConfirmationPresenter;
...@@ -75,12 +72,12 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S ...@@ -75,12 +72,12 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
setContentView(R.layout.activity_schedule_confirmation); setContentView(R.layout.activity_schedule_confirmation);
Bundle bundle = getIntent().getBundleExtra(Utils.SCHEDULE_BUNDLE); Bundle bundle = getIntent().getBundleExtra(Utils.SCHEDULE_BUNDLE);
SectorInput sector = bundle.getParcelable(Utils.SECTOR);
final UserOutput citizen = bundle.getParcelable(Utils.CITIZEN); final UserOutput citizen = bundle.getParcelable(Utils.CITIZEN);
ServiceLocation location = bundle.getParcelable(Utils.LOCATION); final ScheduleConfirmation scheduleConfirmation = bundle.getParcelable(Utils.SCHEDULE_CONFIRMATION);
ServiceType type = bundle.getParcelable(Utils.TYPE); String sectorName = scheduleConfirmation.getSectorName();
final ServiceSchedule schedule = bundle.getParcelable(Utils.SCHEDULE); String locationName = scheduleConfirmation.getLocationName();
String typeName = scheduleConfirmation.getServiceTypeName();
String address = scheduleConfirmation.getAddressStreet() + ", " + scheduleConfirmation.getAddressNumber();
Toolbar toolbar = (Toolbar) findViewById(R.id.agendador_toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.agendador_toolbar);
toolbar.setTitle(null); toolbar.setTitle(null);
...@@ -113,6 +110,8 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S ...@@ -113,6 +110,8 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
NavigationView navigationView = (NavigationView) findViewById(R.id.schedule_confirmation_navigation_view); NavigationView navigationView = (NavigationView) findViewById(R.id.schedule_confirmation_navigation_view);
navigationView.getMenu().findItem(R.id.nav_schedule).setChecked(true);
View headerView = navigationView.getHeaderView(0); View headerView = navigationView.getHeaderView(0);
...@@ -148,14 +147,16 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S ...@@ -148,14 +147,16 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
TextView tv_location = (TextView) findViewById(R.id.tv_schedule_location_content); TextView tv_location = (TextView) findViewById(R.id.tv_schedule_location_content);
TextView tv_type = (TextView) findViewById(R.id.tv_schedule_type_content); TextView tv_type = (TextView) findViewById(R.id.tv_schedule_type_content);
TextView tv_schedule = (TextView) findViewById(R.id.tv_schedule_date_content); TextView tv_schedule = (TextView) findViewById(R.id.tv_schedule_date_content);
TextView tv_street = (TextView) findViewById(R.id.tv_schedule_street_content);
tv_sector.setText(sector.getName()); tv_sector.setText(sectorName);
tv_citizen.setText(citizen.getName()); tv_citizen.setText(citizen.getName());
tv_location.setText(location.getmName()); tv_location.setText(locationName);
tv_type.setText(type.getmDescription()); tv_type.setText(typeName);
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy - HH:mm", Locale.getDefault()); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy - HH:mm", Locale.getDefault());
tv_schedule.setText(dateFormat.format(schedule.getStart())); tv_schedule.setText(dateFormat.format(scheduleConfirmation.getStartTime()));
tv_street.setText(address);
bt_schedule = (Button) findViewById(R.id.btn_schedule_confirm); bt_schedule = (Button) findViewById(R.id.btn_schedule_confirm);
...@@ -165,7 +166,7 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S ...@@ -165,7 +166,7 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
bt_schedule.setOnClickListener(new View.OnClickListener() { bt_schedule.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
scheduleConfirmationPresenter.onScheduleClicked(schedule, citizen); scheduleConfirmationPresenter.onScheduleClicked(scheduleConfirmation, citizen);
bt_schedule.setEnabled(false); bt_schedule.setEnabled(false);
bt_back.setEnabled(false); bt_back.setEnabled(false);
} }
...@@ -199,14 +200,14 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S ...@@ -199,14 +200,14 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
case R.id.nav_my_info: case R.id.nav_my_info:
intent = new Intent(this, AccountActivity.class); intent = new Intent(this, AccountActivity.class);
startActivity(intent); startActivity(intent);
return true; break;
case R.id.nav_schedule: case R.id.nav_schedule:
intent = new Intent(this, TermActivity.class); //do nothing.
item.setChecked(false); break;
startActivity(intent);
default: default:
break;
} }
return false; return true;
} }
@Override @Override
...@@ -243,12 +244,21 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S ...@@ -243,12 +244,21 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
connectionErrorDialog = new ConnectionErrorDialog(); connectionErrorDialog = new ConnectionErrorDialog();
} }
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_connection_error_message)); bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_connection_error_message));
connectionErrorDialog.setArguments(bundle); connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR); connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
} }
} }
public void onSuccess(){
Intent intent = new Intent(ScheduleConfirmationActivity.this, HomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle bundle = new Bundle();
bundle.putInt(HomeActivity.SHOW_SCHEDULE_SNACKBAR, 1);
intent.putExtra(HomeActivity.SHOW_SCHEDULE_SNACKBAR,bundle);
startActivity(intent);
}
@Override @Override
public void setProgressBar(boolean enabled) { public void setProgressBar(boolean enabled) {
if (enabled) { if (enabled) {
...@@ -262,6 +272,18 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S ...@@ -262,6 +272,18 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
} }
@Override
public void setConnectionError(boolean enabled){
if(enabled){
if(connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_connection_error_message));
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
}
public static class ConfirmationDialog extends DialogFragment { public static class ConfirmationDialog extends DialogFragment {
......
...@@ -105,7 +105,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView { ...@@ -105,7 +105,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
if(dg_connection_error == null) if(dg_connection_error == null)
dg_connection_error = new ConnectionErrorDialog(); dg_connection_error = new ConnectionErrorDialog();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_no_connection_message)); bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_no_connection_message));
dg_connection_error.setArguments(bundle); dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR); dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
} }
...@@ -363,7 +363,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView { ...@@ -363,7 +363,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
dg_connection_error = new ConnectionErrorDialog(); dg_connection_error = new ConnectionErrorDialog();
} }
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_connection_error_message)); bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_connection_error_message));
dg_connection_error.setArguments(bundle); dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), "noConnectionDialog"); dg_connection_error.show(getFragmentManager(), "noConnectionDialog");
} }