Commit 6401bcea authored by Lucas Braz Cunha's avatar Lucas Braz Cunha
Browse files

Issues AGILE#152 & AGILE#151: done request of dependets, adding dynamic list of sectors [WIP]


Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent 0a3d5a3e
...@@ -95,7 +95,6 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -95,7 +95,6 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
//TODO: DESIGNER - Define new color to "change photo button" or keep it gray?
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
......
...@@ -9,7 +9,6 @@ import android.content.Intent; ...@@ -9,7 +9,6 @@ import android.content.Intent;
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.v4.content.ContextCompat;
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,6 +20,7 @@ import android.view.Gravity; ...@@ -21,6 +20,7 @@ import android.view.Gravity;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
...@@ -33,14 +33,15 @@ import com.prolificinteractive.materialcalendarview.MaterialCalendarView; ...@@ -33,14 +33,15 @@ import com.prolificinteractive.materialcalendarview.MaterialCalendarView;
import com.prolificinteractive.materialcalendarview.OnDateSelectedListener; import com.prolificinteractive.materialcalendarview.OnDateSelectedListener;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import br.ufpr.c3sl.agendador.agendador.helpers.EventDecorator; import br.ufpr.c3sl.agendador.agendador.helpers.EventDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.HintAdapter; import br.ufpr.c3sl.agendador.agendador.helpers.HintAdapter;
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.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.presenters.SchedulingPresenter; import br.ufpr.c3sl.agendador.agendador.presenters.SchedulingPresenter;
import br.ufpr.c3sl.agendador.agendador.views.SchedulingView; import br.ufpr.c3sl.agendador.agendador.views.SchedulingView;
...@@ -79,18 +80,32 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -79,18 +80,32 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
private SchedulingPresenter schedulingPresenter; private SchedulingPresenter schedulingPresenter;
private List dependents;
private String[] dependents_name;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
schedulingPresenter = new SchedulingPresenter(this);
} else {
schedulingPresenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
}
setContentView(R.layout.activity_scheduling); setContentView(R.layout.activity_scheduling);
Toolbar toolbar = (Toolbar) findViewById(R.id.agendador_toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.agendador_toolbar);
toolbar.setTitle(null);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null); //getSupportActionBar().setTitle(null);
pb_scheduling = (ProgressBar) findViewById(R.id.pb_scheduling); pb_scheduling = (ProgressBar) findViewById(R.id.pb_scheduling);
Log.d("Aaaaaaa", pb_scheduling == null ? "Progress bar Vazio" : "Progress bar Não vazio");
actionMenuView = (ActionMenuView) toolbar.findViewById(R.id.agendador_toolbar_menu); actionMenuView = (ActionMenuView) toolbar.findViewById(R.id.agendador_toolbar_menu);
menuBuilder = (MenuBuilder) actionMenuView.getMenu(); menuBuilder = (MenuBuilder) actionMenuView.getMenu();
//noinspection RestrictedApi //noinspection RestrictedApi
...@@ -107,6 +122,8 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -107,6 +122,8 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
}); });
ll_fields = (LinearLayout) findViewById(R.id.ll_scheduling_fields); ll_fields = (LinearLayout) findViewById(R.id.ll_scheduling_fields);
//pb_scheduling.setVisibility(View.VISIBLE); //pb_scheduling.setVisibility(View.VISIBLE);
//ll_fields.setVisibility(View.INVISIBLE); //ll_fields.setVisibility(View.INVISIBLE);
...@@ -157,15 +174,9 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -157,15 +174,9 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
navigationView.setNavigationItemSelectedListener(this); navigationView.setNavigationItemSelectedListener(this);
schedulingPresenter = new SchedulingPresenter(this);
// TODO: 17/04/17 example on how to set hint to spinner // TODO: 17/04/17 example on how to set hint to spinner
String[] citizens = {"Lucas", "Selecione um cidadão"};
HintAdapter hintAdapterCitizen = new HintAdapter(this, android.R.layout.simple_list_item_1, citizens);
spnr_citizen.setAdapter(hintAdapterCitizen);
// show hint
spnr_citizen.setSelection(hintAdapterCitizen.getCount());
String[] sector = {"Saúde", "Selecione um setor"}; String[] sector = {"Saúde", "Selecione um setor"};
HintAdapter hintAdapterSector = new HintAdapter(this, android.R.layout.simple_list_item_1, sector); HintAdapter hintAdapterSector = new HintAdapter(this, android.R.layout.simple_list_item_1, sector);
...@@ -217,8 +228,46 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -217,8 +228,46 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
tv_day_month.setText(calendar.get(Calendar.DAY_OF_WEEK) + ", " + tv_day_month.setText(calendar.get(Calendar.DAY_OF_WEEK) + ", " +
months_short[calendar.get(Calendar.MONTH)] + " " + calendar.get(Calendar.DAY_OF_MONTH)); months_short[calendar.get(Calendar.MONTH)] + " " + calendar.get(Calendar.DAY_OF_MONTH));
ll_fields.setVisibility(View.INVISIBLE);
schedulingPresenter.bindView(this);
schedulingPresenter.getDependents();
} }
@Override
protected void onResume() {
super.onResume();
schedulingPresenter.bindView(this);
}
@Override
protected void onPause() {
super.onPause();
schedulingPresenter.unbindView();
}
@Override
protected void onStart(){
super.onStart();
spnr_citizen.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
// do nothing?
// or copy it to another variable?
//mcv.setSelectionMode(MaterialCalendarView.SELECTION_MODE_NONE);
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
// do nothing?
}
});
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
...@@ -238,7 +287,6 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -238,7 +287,6 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
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; return true;
case R.id.nav_schedule: case R.id.nav_schedule:
intent = new Intent(this, TermActivity.class); intent = new Intent(this, TermActivity.class);
...@@ -249,22 +297,31 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -249,22 +297,31 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
return false; return false;
} }
//todo: correct code
@Override @Override
public void setProgressBar(boolean enabled) { public void setProgressBar(boolean enabled) {
if (enabled) { if (enabled) {
pb_scheduling.setVisibility(View.VISIBLE); pb_scheduling.setVisibility(View.VISIBLE);
/*btn_update.setEnabled(false); spnr_citizen.setEnabled(false);
btn_cancel.setEnabled(false); spnr_location.setEnabled(false);
enableAllFields(false);*/ spnr_sector.setEnabled(false);
spnr_type.setEnabled(false);
mcv.setEnabled(false);
} else { } else {
pb_scheduling.setVisibility(View.INVISIBLE); pb_scheduling.setVisibility(View.INVISIBLE);
/*enableAllFields(true); spnr_citizen.setEnabled(true);
btn_update.setEnabled(true); spnr_location.setEnabled(true);
btn_cancel.setEnabled(true);*/ spnr_sector.setEnabled(true);
spnr_type.setEnabled(true);
mcv.setEnabled(true);
} }
} }
public void showLayout(boolean enabled){
if(enabled)
ll_fields.setVisibility(View.VISIBLE);
}
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu, menuBuilder); getMenuInflater().inflate(R.menu.main_menu, menuBuilder);
...@@ -281,6 +338,21 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -281,6 +338,21 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
} }
} }
public void successfulDependents(List<UserOutput> dependents){
this.dependents = dependents;
dependents_name = new String[dependents.size()+1];
int i = 0;
for (; i < dependents.size(); i++)
dependents_name[i] = dependents.get(i).getName();
dependents_name[i] = getResources().getString(R.string.scheduling_dependent_hint);
HintAdapter hintAdapterCitizen = new HintAdapter(this, android.R.layout.simple_list_item_1, dependents_name);
spnr_citizen.setAdapter(hintAdapterCitizen);
// show hint
spnr_citizen.setSelection(hintAdapterCitizen.getCount());
}
/** /**
* Called when a user clicks on a day. * Called when a user clicks on a day.
* There is no logic to prevent multiple calls for the same date and state. * There is no logic to prevent multiple calls for the same date and state.
...@@ -316,7 +388,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -316,7 +388,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
//SchedulingActivity activity = (SchedulingActivity) getActivity(); //SchedulingActivity activity = (SchedulingActivity) getActivity();
//activity.presenter.onSignOutClicked(); //activity.schedulingPresenter.onSignOutClicked();
} }
}) })
.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() { .setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
......
package br.ufpr.c3sl.agendador.agendador; package br.ufpr.c3sl.agendador.agendador;
import android.content.Intent; import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.ListView;
import java.util.List;
import br.ufpr.c3sl.agendador.agendador.models.SectorInput;
import br.ufpr.c3sl.agendador.agendador.presenters.TermPresenter;
import br.ufpr.c3sl.agendador.agendador.views.TermView;
public class TermActivity extends AppCompatActivity implements TermView {
private TermPresenter termPresenter;
private List<SectorInput> sectors;
public class TermActivity extends AppCompatActivity { private ListView lv_sectors;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
termPresenter = new TermPresenter(this);
} else {
termPresenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
}
setContentView(R.layout.activity_term); setContentView(R.layout.activity_term);
Button refusal = (Button) findViewById(R.id.btn_term_refusal); Button refusal = (Button) findViewById(R.id.btn_term_refusal);
...@@ -34,5 +52,40 @@ public class TermActivity extends AppCompatActivity { ...@@ -34,5 +52,40 @@ public class TermActivity extends AppCompatActivity {
finish(); finish();
} }
}); });
lv_sectors = (ListView) findViewById(R.id.lv_term_sectors);
termPresenter.bindView(this);
termPresenter.requestSectors();
}
@Override
protected void onResume() {
super.onResume();
termPresenter.bindView(this);
}
@Override
protected void onPause() {
super.onPause();
termPresenter.unbindView();
}
// TODO: 02/06/17 to implement!!!
//implement handler of listView
//after sectors request, dependents request receives 401 - unauthorized
@Override
public void showLayout(boolean enabled) {
}
@Override
public void setProgressBar(boolean enabled) {
}
public void successfulSectors(List<SectorInput> sectors){
this.sectors = sectors;
} }
} }
package br.ufpr.c3sl.agendador.agendador.helpers;
/**
* Created by Lucas B. Cunha on 02/06/17.
*/
public class SectorArrayAdapter {
}
...@@ -8,10 +8,10 @@ import com.google.gson.annotations.SerializedName; ...@@ -8,10 +8,10 @@ import com.google.gson.annotations.SerializedName;
public class Account { public class Account {
@SerializedName("cpf") @SerializedName("cpf")
String mCpf; private String mCpf;
@SerializedName("password") @SerializedName("password")
String mPassword; private String mPassword;
public Account(String cpf, String password) { public Account(String cpf, String password) {
this.mCpf = cpf; this.mCpf = cpf;
......
package br.ufpr.c3sl.agendador.agendador.models; package br.ufpr.c3sl.agendador.agendador.models;
import android.util.Log;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
/** /**
...@@ -11,7 +9,7 @@ import com.google.gson.annotations.SerializedName; ...@@ -11,7 +9,7 @@ import com.google.gson.annotations.SerializedName;
public class AccountOutput { public class AccountOutput {
@SerializedName("data") @SerializedName("data")
DataOutput mData; private DataOutput mData;
public AccountOutput(DataOutput data) { public AccountOutput(DataOutput data) {
this.mData = data; this.mData = data;
...@@ -21,7 +19,7 @@ public class AccountOutput { ...@@ -21,7 +19,7 @@ public class AccountOutput {
return mData.getmCitizen(); return mData.getmCitizen();
} }
public class DataOutput { private class DataOutput {
@SerializedName("id") @SerializedName("id")
int mId; int mId;
...@@ -45,5 +43,6 @@ public class AccountOutput { ...@@ -45,5 +43,6 @@ public class AccountOutput {
public UserOutput getmCitizen() { public UserOutput getmCitizen() {
return mCitizen; return mCitizen;
} }
} }
} }
...@@ -9,16 +9,16 @@ import com.google.gson.annotations.SerializedName; ...@@ -9,16 +9,16 @@ import com.google.gson.annotations.SerializedName;
public class AccountUpdate { public class AccountUpdate {
@SerializedName("citizen") @SerializedName("citizen")
UserUpdate mUser; private UserUpdate mUser;
@SerializedName("current_password") @SerializedName("current_password")
String mcurrentPassword; private String mcurrentPassword;
@SerializedName("password") @SerializedName("password")
String mPassword; private String mPassword;
@SerializedName("password_confirmation") @SerializedName("password_confirmation")
String mPasswordConfirmation; private String mPasswordConfirmation;
public AccountUpdate(UserUpdate user, String currentPassword, String password, String passwordConfirmation) { public AccountUpdate(UserUpdate user, String currentPassword, String password, String passwordConfirmation) {
......
...@@ -8,7 +8,7 @@ import com.google.gson.annotations.SerializedName; ...@@ -8,7 +8,7 @@ import com.google.gson.annotations.SerializedName;
public class Cep { public class Cep {
@SerializedName("number") @SerializedName("number")
String mNumber; private String mNumber;
public Cep(String number) { public Cep(String number) {
this.mNumber = number; this.mNumber = number;
......
...@@ -8,7 +8,7 @@ import com.google.gson.annotations.SerializedName; ...@@ -8,7 +8,7 @@ import com.google.gson.annotations.SerializedName;
public class CepInput { public class CepInput {
@SerializedName("cep") @SerializedName("cep")
Cep mCep; private Cep mCep;
public CepInput(String number) { public CepInput(String number) {
this.mCep = new Cep(number); this.mCep = new Cep(number);
......
...@@ -7,6 +7,7 @@ import com.google.gson.annotations.SerializedName; ...@@ -7,6 +7,7 @@ import com.google.gson.annotations.SerializedName;
*/ */
public class City { public class City {
//package private because they're used on UserOutput.
@SerializedName("id") @SerializedName("id")
int mId; int mId;
......
package br.ufpr.c3sl.agendador.agendador.models;
import com.google.gson.annotations.SerializedName;
/**
* Created by Lucas B. Cunha on 02/06/17.
*/
public class SectorInput {
@SerializedName("id")
private int mId;
@SerializedName("name")
private String mName;
@SerializedName("absence_max")
private int mAbsenceMax;
@SerializedName("active")
private boolean isActive;
@SerializedName("blocking_days")
private int mBlockingDays;
@SerializedName("cancel_limit")
private int mCancelLimit;
@SerializedName("description")
private String description;<