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

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 {
//TODO: DESIGNER - Define new color to "change photo button" or keep it gray?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......
......@@ -9,7 +9,6 @@ import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
......@@ -21,6 +20,7 @@ import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
......@@ -33,14 +33,15 @@ import com.prolificinteractive.materialcalendarview.MaterialCalendarView;
import com.prolificinteractive.materialcalendarview.OnDateSelectedListener;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import br.ufpr.c3sl.agendador.agendador.helpers.EventDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.HintAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
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.views.SchedulingView;
......@@ -79,18 +80,32 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
private SchedulingPresenter schedulingPresenter;
private List dependents;
private String[] dependents_name;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
schedulingPresenter = new SchedulingPresenter(this);
} else {
schedulingPresenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
}
setContentView(R.layout.activity_scheduling);
Toolbar toolbar = (Toolbar) findViewById(R.id.agendador_toolbar);
toolbar.setTitle(null);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);
//getSupportActionBar().setTitle(null);
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);
menuBuilder = (MenuBuilder) actionMenuView.getMenu();
//noinspection RestrictedApi
......@@ -107,6 +122,8 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
});
ll_fields = (LinearLayout) findViewById(R.id.ll_scheduling_fields);
//pb_scheduling.setVisibility(View.VISIBLE);
//ll_fields.setVisibility(View.INVISIBLE);
......@@ -157,15 +174,9 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
navigationView.setNavigationItemSelectedListener(this);
schedulingPresenter = new SchedulingPresenter(this);
// 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"};
HintAdapter hintAdapterSector = new HintAdapter(this, android.R.layout.simple_list_item_1, sector);
......@@ -217,8 +228,46 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
tv_day_month.setText(calendar.get(Calendar.DAY_OF_WEEK) + ", " +
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
public boolean onOptionsItemSelected(MenuItem item) {
......@@ -238,7 +287,6 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
case R.id.nav_my_info:
intent = new Intent(this, AccountActivity.class);
startActivity(intent);
return true;
case R.id.nav_schedule:
intent = new Intent(this, TermActivity.class);
......@@ -249,22 +297,31 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
return false;
}
//todo: correct code
@Override
public void setProgressBar(boolean enabled) {
if (enabled) {
pb_scheduling.setVisibility(View.VISIBLE);
/*btn_update.setEnabled(false);
btn_cancel.setEnabled(false);
enableAllFields(false);*/
spnr_citizen.setEnabled(false);
spnr_location.setEnabled(false);
spnr_sector.setEnabled(false);
spnr_type.setEnabled(false);
mcv.setEnabled(false);
} else {
pb_scheduling.setVisibility(View.INVISIBLE);
/*enableAllFields(true);
btn_update.setEnabled(true);
btn_cancel.setEnabled(true);*/
spnr_citizen.setEnabled(true);
spnr_location.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
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu, menuBuilder);
......@@ -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.
* 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
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//SchedulingActivity activity = (SchedulingActivity) getActivity();
//activity.presenter.onSignOutClicked();
//activity.schedulingPresenter.onSignOutClicked();
}
})
.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
......
package br.ufpr.c3sl.agendador.agendador;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
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
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
termPresenter = new TermPresenter(this);
} else {
termPresenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
}
setContentView(R.layout.activity_term);
Button refusal = (Button) findViewById(R.id.btn_term_refusal);
......@@ -34,5 +52,40 @@ public class TermActivity extends AppCompatActivity {
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;
public class Account {
@SerializedName("cpf")
String mCpf;
private String mCpf;
@SerializedName("password")
String mPassword;
private String mPassword;
public Account(String cpf, String password) {
this.mCpf = cpf;
......
package br.ufpr.c3sl.agendador.agendador.models;
import android.util.Log;
import com.google.gson.annotations.SerializedName;
/**
......@@ -11,7 +9,7 @@ import com.google.gson.annotations.SerializedName;
public class AccountOutput {
@SerializedName("data")
DataOutput mData;
private DataOutput mData;
public AccountOutput(DataOutput data) {
this.mData = data;
......@@ -21,7 +19,7 @@ public class AccountOutput {
return mData.getmCitizen();
}
public class DataOutput {
private class DataOutput {
@SerializedName("id")
int mId;
......@@ -45,5 +43,6 @@ public class AccountOutput {
public UserOutput getmCitizen() {
return mCitizen;
}
}
}
......@@ -9,16 +9,16 @@ import com.google.gson.annotations.SerializedName;
public class AccountUpdate {
@SerializedName("citizen")
UserUpdate mUser;
private UserUpdate mUser;
@SerializedName("current_password")
String mcurrentPassword;
private String mcurrentPassword;
@SerializedName("password")
String mPassword;
private String mPassword;
@SerializedName("password_confirmation")
String mPasswordConfirmation;
private String mPasswordConfirmation;
public AccountUpdate(UserUpdate user, String currentPassword, String password, String passwordConfirmation) {
......
......@@ -8,7 +8,7 @@ import com.google.gson.annotations.SerializedName;
public class Cep {
@SerializedName("number")
String mNumber;
private String mNumber;
public Cep(String number) {
this.mNumber = number;
......
......@@ -8,7 +8,7 @@ import com.google.gson.annotations.SerializedName;
public class CepInput {
@SerializedName("cep")
Cep mCep;
private Cep mCep;
public CepInput(String number) {
this.mCep = new Cep(number);
......
......@@ -7,6 +7,7 @@ import com.google.gson.annotations.SerializedName;
*/
public class City {
//package private because they're used on UserOutput.
@SerializedName("id")
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;
@SerializedName("schedules_by_sector")
private int mSchedules;
public SectorInput(int mId, String mName, int mAbsenceMax, boolean isActive, int mBlockingDays,
int mCancelLimit, String description, int mSchedules){
this.mId = mId;
this.mName = mName;
this.mAbsenceMax = mAbsenceMax;
this.isActive = isActive;
this.mBlockingDays = mBlockingDays;
this.mCancelLimit = mCancelLimit;
this.description = description;
this.mSchedules = mSchedules;
}
public String getmName(){
return this.mName;
}
}
......@@ -6,7 +6,9 @@ import com.google.gson.annotations.SerializedName;
* Created by Bruno Freitas Tissei on 2/10/17.
*/
public class State {
public class State{
//package private because they're used on UserOutput.
@SerializedName("id")
int mId;
......
......@@ -8,31 +8,31 @@ import com.google.gson.annotations.SerializedName;
public class User {
@SerializedName("cpf")
String mCpf;
private String mCpf;
@SerializedName("birth_date")
String mBirth_date;
private String mBirth_date;
@SerializedName("password")
String mPassword;
private String mPassword;
@SerializedName("password_confirmation")
String mPassword_confirmation;
private String mPassword_confirmation;
@SerializedName("email")
String mEmail;
private String mEmail;
@SerializedName("name")
String mName;
private String mName;
@SerializedName("phone1")
String mPhone1;
private String mPhone1;
@SerializedName("rg")
String mRg;
private String mRg;
@SerializedName("cep")
String mCep;
private String mCep;
......
......@@ -15,79 +15,79 @@ import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
public class UserOutput {
@SerializedName("address_number")
String mAddress_Number;
private String mAddress_Number;
@SerializedName("updated_at")
String mUpdated_At;
private String mUpdated_At;
@SerializedName("id")
int mId;
private int mId;
@SerializedName("photo_update_at")
String mPhoto_Update_At;
private String mPhoto_Update_At;
@SerializedName("photo_content_type")
String mPhoto_Content_Type;
private String mPhoto_Content_Type;
@SerializedName("photo_file_name")
String mPhoto_File_Name;
private String mPhoto_File_Name;
@SerializedName("photo_file_size")
String mPhoto_File_Size;
private String mPhoto_File_Size;
@SerializedName("note")
String mNote;
private String mNote;
@SerializedName("rg")
String mRg;
private String mRg;
@SerializedName("email")
String mEmail;
private String mEmail;
@SerializedName("pcd")
String mPcd;
private String mPcd;
@SerializedName("account_id")
int mAccount_Id;
private int mAccount_Id;
@SerializedName("phone2")
String mPhone2;
private String mPhone2;
@SerializedName("phone1")
String mPhone1;
private String mPhone1;
@SerializedName("responsible_id")
int mResponsible_Id;
private int mResponsible_Id;
@SerializedName("active")
boolean mActive;
private boolean mActive;
@SerializedName("name")
String mName;
private String mName;
@SerializedName("created_at")
String mCreated_At;
private String mCreated_At;
@SerializedName("cpf")
String mCpf;
private String mCpf;
@SerializedName("birth_date")
String mBirth_Date;
private String mBirth_Date;
@SerializedName("city")
City mCity;
private City mCity;
@SerializedName("state")
State mState;
private State mState;
@SerializedName("address")
Address mAddress;
private Address mAddress;
@SerializedName("cep")
String mCep;
private String mCep;
@SerializedName("address_complement")
String mAddressComplement;
private String mAddressComplement;
public UserOutput(Map<String,String> values){
this.mAddress_Number = values.get("address_number");
......@@ -167,4 +167,8 @@ public class UserOutput {
osb.edit().putString("state.name", this.mState.mName).apply();
osb.edit().putString("state.abbreviation", this.mState.mAbbreviation).apply();
}
public String getName(){
return this.mName;
}
}
......@@ -15,41 +15,40 @@ import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
public class UserUpdate {
@SerializedName("address_number")
String mAddress_Number;
private String mAddress_Number;
@SerializedName("note")
String mNote;
private String mNote;
@SerializedName("rg")
String mRg;
private String mRg;
@SerializedName("email")
String mEmail;
private String mEmail;
@SerializedName("pcd")
String mPcd;
private String mPcd;
@SerializedName("phone2")
String mPhone2;
private String mPhone2;
@SerializedName("phone1")
String mPhone1;
private String mPhone1;
@SerializedName("name")
String mName;
private String mName;
@SerializedName("birth_date")
String mBirth_Date;
private String mBirth_Date;
@SerializedName("cep")
String mCep;
private String mCep;
@SerializedName("address_complement")
String mAddressComplement;
private String mAddressComplement;
@SerializedName("image")
Image mImage;
private Image mImage;
public UserUpdate(Map<String, String> values) {
this.mAddress_Number = values.get("address_number");
......@@ -70,7 +69,7 @@ public class UserUpdate {
this.mImage = new Image(contentType, fileName, content);
}
public class Image {
private class Image {
@SerializedName("content")
String mContent;
......@@ -82,7 +81,7 @@ public class UserUpdate {
String mContentType;
public Image(String contentType, String fileName, String content) {
private Image(String contentType, String fileName, String content) {
this.mContent = content;