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

Issue AGILE#182 [WIP] showing dates on calendar

Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent 011330b3
...@@ -31,7 +31,11 @@ ...@@ -31,7 +31,11 @@
<activity android:name=".AccountActivity" /> <activity android:name=".AccountActivity" />
<activity android:name=".ForgotPasswordActivity" /> <activity android:name=".ForgotPasswordActivity" />
<activity android:name=".TermActivity" /> <activity android:name=".TermActivity" />
<activity android:name=".SchedulingActivity" /> <activity android:name=".SchedulingActivity"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name=".CitizenActivity"></activity> <activity android:name=".CitizenActivity"></activity>
</application> </application>
......
...@@ -45,10 +45,10 @@ import java.util.List; ...@@ -45,10 +45,10 @@ import java.util.List;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionChecker; import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionChecker;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog; import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.PhotoSelectionAdapter; import br.ufpr.c3sl.agendador.agendador.helpers.DateValidator;
import br.ufpr.c3sl.agendador.agendador.helpers.DataValidador;
import br.ufpr.c3sl.agendador.agendador.helpers.Mask; import br.ufpr.c3sl.agendador.agendador.helpers.Mask;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences; import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.PhotoSelectionAdapter;
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.presenters.AccountPresenter; import br.ufpr.c3sl.agendador.agendador.presenters.AccountPresenter;
...@@ -569,7 +569,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -569,7 +569,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
et_sus_number.setText(osb.getString("sus", null)); et_sus_number.setText(osb.getString("sus", null));
et_cep.setText(osb.getString("address.zipcode", null)); et_cep.setText(osb.getString("address.zipcode", null));
et_number.setText(osb.getString("address_number", null)); et_number.setText(osb.getString("address_number", null));
et_birthdate.setText(DataValidador.stringToDate(osb.getString("birth_date", null), true)); et_birthdate.setText(DateValidator.stringToDate(osb.getString("birth_date", null), true));
et_disability.setText(pcd); et_disability.setText(pcd);
et_address.setText(osb.getString("address.address", null)); et_address.setText(osb.getString("address.address", null));
et_neighborhood.setText(osb.getString("address.neighborhood", null)); et_neighborhood.setText(osb.getString("address.neighborhood", null));
...@@ -593,7 +593,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -593,7 +593,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
private boolean validateData() { private boolean validateData() {
clearWarnings(); clearWarnings();
boolean openDialog = false; boolean openDialog = false;
String bDate = DataValidador.stringToDate(et_birthdate.getText().toString(), false); String bDate = DateValidator.stringToDate(et_birthdate.getText().toString(), false);
if (et_name.getText().toString().replaceAll("\\s+", "").isEmpty()) { if (et_name.getText().toString().replaceAll("\\s+", "").isEmpty()) {
tv_name_warning.setText(R.string.null_name); tv_name_warning.setText(R.string.null_name);
...@@ -603,7 +603,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -603,7 +603,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
tv_name_warning.setVisibility(View.INVISIBLE); tv_name_warning.setVisibility(View.INVISIBLE);
} }
if (bDate.isEmpty() || !DataValidador.isValidBirthDate(bDate)) { if (bDate.isEmpty() || !DateValidator.isValidBirthDate(bDate)) {
tv_birthdate_warning.setText(R.string.invalid_birthdate); tv_birthdate_warning.setText(R.string.invalid_birthdate);
tv_birthdate_warning.setVisibility(View.VISIBLE); tv_birthdate_warning.setVisibility(View.VISIBLE);
openDialog = true; openDialog = true;
...@@ -616,7 +616,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -616,7 +616,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
tv_email_warning.setVisibility(View.VISIBLE); tv_email_warning.setVisibility(View.VISIBLE);
openDialog = true; openDialog = true;
} else { } else {
if (DataValidador.isValidEmail(et_email.getText().toString())) { if (DateValidator.isValidEmail(et_email.getText().toString())) {
tv_email_warning.setVisibility(View.INVISIBLE); tv_email_warning.setVisibility(View.INVISIBLE);
} else { } else {
tv_email_warning.setText(R.string.invalid_email); tv_email_warning.setText(R.string.invalid_email);
...@@ -815,7 +815,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView { ...@@ -815,7 +815,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
values.put("name", et_name.getText().toString()); values.put("name", et_name.getText().toString());
values.put("rg", et_rg.getText().toString()); values.put("rg", et_rg.getText().toString());
values.put("birth_date", DataValidador.stringToDate(et_birthdate.getText().toString(), false)); values.put("birth_date", DateValidator.stringToDate(et_birthdate.getText().toString(), false));
if (rb_no.isChecked()) { if (rb_no.isChecked()) {
values.put("pcd", null); values.put("pcd", null);
......
...@@ -6,10 +6,7 @@ import android.app.Dialog; ...@@ -6,10 +6,7 @@ import android.app.Dialog;
import android.app.DialogFragment; import android.app.DialogFragment;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
...@@ -80,13 +77,12 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{ ...@@ -80,13 +77,12 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
} }
public void onLongClickItem(View v, int position) { public void onLongClickItem(View v, int position) {
//Log.d("AAAAAAaaaaa", "On long Click Item interface");
//do nothing. //do nothing.
} }
})); }));
citizensPresenter.bindView(this); citizensPresenter.bindView(this);
citizensPresenter.requestCitizens(); citizensPresenter.requestCitizens();
} }
......
...@@ -24,6 +24,7 @@ import android.view.Gravity; ...@@ -24,6 +24,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.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
...@@ -36,6 +37,11 @@ import br.ufpr.c3sl.agendador.agendador.views.HomeView; ...@@ -36,6 +37,11 @@ import br.ufpr.c3sl.agendador.agendador.views.HomeView;
* Created by Bruno Freitas Tissei on 2/7/17. * Created by Bruno Freitas Tissei on 2/7/17.
*/ */
// 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;
...@@ -52,6 +58,8 @@ public class HomeActivity extends AppCompatActivity implements HomeView, ...@@ -52,6 +58,8 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
private ConfirmationDialog confirmationDialog; private ConfirmationDialog confirmationDialog;
private Button btn_schedule;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -64,8 +72,8 @@ public class HomeActivity extends AppCompatActivity implements HomeView, ...@@ -64,8 +72,8 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
setContentView(R.layout.activity_home); setContentView(R.layout.activity_home);
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);
osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE); osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
String citizenName = osb.getString("name", null); String citizenName = osb.getString("name", null);
...@@ -125,6 +133,16 @@ public class HomeActivity extends AppCompatActivity implements HomeView, ...@@ -125,6 +133,16 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
navigationView.setNavigationItemSelectedListener(this); navigationView.setNavigationItemSelectedListener(this);
btn_schedule = (Button) findViewById(R.id.btn_homeact_schedule);
btn_schedule.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(HomeActivity.this, TermActivity.class);
startActivity(intent);
}
});
changeTextColor(); changeTextColor();
} }
......
...@@ -18,7 +18,7 @@ import java.util.HashMap; ...@@ -18,7 +18,7 @@ import java.util.HashMap;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionChecker; import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionChecker;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog; import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.DataValidador; import br.ufpr.c3sl.agendador.agendador.helpers.DateValidator;
import br.ufpr.c3sl.agendador.agendador.helpers.Mask; import br.ufpr.c3sl.agendador.agendador.helpers.Mask;
import br.ufpr.c3sl.agendador.agendador.presenters.SignupPresenter; import br.ufpr.c3sl.agendador.agendador.presenters.SignupPresenter;
import br.ufpr.c3sl.agendador.agendador.views.SignupView; import br.ufpr.c3sl.agendador.agendador.views.SignupView;
...@@ -144,7 +144,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView { ...@@ -144,7 +144,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
public boolean validateData() { public boolean validateData() {
boolean openDialog = false; boolean openDialog = false;
String bDate = DataValidador.stringToDate(et_birthday.getText().toString(), false); String bDate = DateValidator.stringToDate(et_birthday.getText().toString(), false);
if (et_name.getText().toString().replaceAll("\\s+", "").isEmpty()) { if (et_name.getText().toString().replaceAll("\\s+", "").isEmpty()) {
openDialog = true; openDialog = true;
...@@ -157,7 +157,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView { ...@@ -157,7 +157,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
tv_cpf_warning.setText(R.string.cpf_empty); tv_cpf_warning.setText(R.string.cpf_empty);
tv_cpf_warning.setVisibility(View.VISIBLE); tv_cpf_warning.setVisibility(View.VISIBLE);
} else { } else {
if (DataValidador.isValidCPF(Mask.unmask(et_cpf.getText().toString()))) { if (DateValidator.isValidCPF(Mask.unmask(et_cpf.getText().toString()))) {
tv_cpf_warning.setVisibility(View.INVISIBLE); tv_cpf_warning.setVisibility(View.INVISIBLE);
} else { } else {
...@@ -166,7 +166,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView { ...@@ -166,7 +166,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
openDialog = true; openDialog = true;
} }
} }
if (bDate.isEmpty() || !DataValidador.isValidBirthDate(bDate)) { if (bDate.isEmpty() || !DateValidator.isValidBirthDate(bDate)) {
openDialog = true; openDialog = true;
tv_birthday_warning.setVisibility(View.VISIBLE); tv_birthday_warning.setVisibility(View.VISIBLE);
} else { } else {
...@@ -177,7 +177,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView { ...@@ -177,7 +177,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
tv_email_warning.setVisibility(View.VISIBLE); tv_email_warning.setVisibility(View.VISIBLE);
openDialog = true; openDialog = true;
} else { } else {
if (DataValidador.isValidEmail(et_email.getText().toString())) { if (DateValidator.isValidEmail(et_email.getText().toString())) {
tv_email_warning.setVisibility(View.INVISIBLE); tv_email_warning.setVisibility(View.INVISIBLE);
} else { } else {
tv_email_warning.setText(R.string.invalid_email); tv_email_warning.setText(R.string.invalid_email);
...@@ -295,7 +295,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView { ...@@ -295,7 +295,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
HashMap<String,String> values = new HashMap<String,String>(); HashMap<String,String> values = new HashMap<String,String>();
values.put("cpf",Mask.unmask(et_cpf.getText().toString())); values.put("cpf",Mask.unmask(et_cpf.getText().toString()));
values.put("birth_date",DataValidador.stringToDate(et_birthday.getText().toString(),false)); values.put("birth_date", DateValidator.stringToDate(et_birthday.getText().toString(),false));
values.put("name",et_name.getText().toString()); values.put("name",et_name.getText().toString());
values.put("cep",Mask.unmask(et_cep.getText().toString())); values.put("cep",Mask.unmask(et_cep.getText().toString()));
values.put("password_confirmation",et_password_confirm.getText().toString()); values.put("password_confirmation",et_password_confirm.getText().toString());
......
...@@ -170,6 +170,12 @@ public class TermActivity extends AppCompatActivity implements TermView { ...@@ -170,6 +170,12 @@ public class TermActivity extends AppCompatActivity implements TermView {
return builder.create(); return builder.create();
} }
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
getActivity().onBackPressed();
}
} }
/** /**
......
...@@ -6,12 +6,13 @@ import java.text.ParseException; ...@@ -6,12 +6,13 @@ import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.InputMismatchException; import java.util.InputMismatchException;
import java.util.Locale;
/** /**
* Created by horstmann on 18/02/17. * Created by horstmann on 18/02/17.
*/ */
public class DataValidador { public class DateValidator {
public static boolean isValidEmail(String email) { public static boolean isValidEmail(String email) {
return !(email.isEmpty()) && android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches(); return !(email.isEmpty()) && android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches();
...@@ -37,7 +38,7 @@ public class DataValidador { ...@@ -37,7 +38,7 @@ public class DataValidador {
sm = 0; sm = 0;
peso = 10; peso = 10;
for (i = 0; i < 9; i++) { for (i = 0; i < 9; i++) {
num = (int) (cpf.charAt(i) - 48); num = cpf.charAt(i) - 48;
sm = sm + (num * peso); sm = sm + (num * peso);
peso = peso - 1; peso = peso - 1;
} }
...@@ -52,7 +53,7 @@ public class DataValidador { ...@@ -52,7 +53,7 @@ public class DataValidador {
sm = 0; sm = 0;
peso = 11; peso = 11;
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
num = (int) (cpf.charAt(i) - 48); num = cpf.charAt(i) - 48;
sm = sm + (num * peso); sm = sm + (num * peso);
peso = peso - 1; peso = peso - 1;
} }
...@@ -76,11 +77,11 @@ public class DataValidador { ...@@ -76,11 +77,11 @@ public class DataValidador {
public static String stringToDate(String birth_date, boolean invert) { public static String stringToDate(String birth_date, boolean invert) {
SimpleDateFormat formatter, formatter2; SimpleDateFormat formatter, formatter2;
if (invert) { if (invert) {
formatter = new SimpleDateFormat("yyyy-MM-dd"); formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
formatter2 = new SimpleDateFormat("dd/MM/yyyy"); formatter2 = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
}else { }else {
formatter = new SimpleDateFormat("dd/MM/yyyy"); formatter = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
formatter2 = new SimpleDateFormat("MMM dd yyyy"); formatter2 = new SimpleDateFormat("MMM dd yyyy", Locale.getDefault());
} }
formatter.setLenient(false); formatter.setLenient(false);
formatter2.setLenient(false); formatter2.setLenient(false);
...@@ -97,7 +98,7 @@ public class DataValidador { ...@@ -97,7 +98,7 @@ public class DataValidador {
public static boolean isValidBirthDate(String birth_date){ public static boolean isValidBirthDate(String birth_date){
Date today = new Date(); Date today = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("MMM dd yyyy"); SimpleDateFormat formatter = new SimpleDateFormat("MMM dd yyyy", Locale.getDefault());
try { try {
Date birth = formatter.parse(birth_date); Date birth = formatter.parse(birth_date);
Log.d("DataV:is_valid_birth", birth.toString()); Log.d("DataV:is_valid_birth", birth.toString());
......
...@@ -7,24 +7,36 @@ import com.prolificinteractive.materialcalendarview.CalendarDay; ...@@ -7,24 +7,36 @@ import com.prolificinteractive.materialcalendarview.CalendarDay;
import com.prolificinteractive.materialcalendarview.DayViewDecorator; import com.prolificinteractive.materialcalendarview.DayViewDecorator;
import com.prolificinteractive.materialcalendarview.DayViewFacade; import com.prolificinteractive.materialcalendarview.DayViewFacade;
import java.util.Collection; import java.text.DateFormat;
import java.util.HashSet; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import br.ufpr.c3sl.agendador.agendador.R; import br.ufpr.c3sl.agendador.agendador.R;
import br.ufpr.c3sl.agendador.agendador.models.ServiceSchedule;
/** /**
* Created by lbc16 on 25/05/17. * Created by Lucas B. Cunha on 25/05/17.
*/ */
public class EventDecorator implements DayViewDecorator { public class EventDecorator implements DayViewDecorator {
private final HashSet<CalendarDay> dates; public static int INVALID_STATE = -1;
private List<HashMap<String,ArrayList<ServiceSchedule>>> listOfScheduleDays;
private Context context; private Context context;
public EventDecorator(Collection<CalendarDay> dates, Context context) { private int scheduleType;
this.dates = new HashSet<>(dates);
private DateFormat dateFormat;
public EventDecorator(List<HashMap<String,ArrayList<ServiceSchedule>>> listOfScheduleDays, Context context) {
this.listOfScheduleDays = listOfScheduleDays;
this.context = context; this.context = context;
dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
} }
/** /**
...@@ -35,7 +47,7 @@ public class EventDecorator implements DayViewDecorator { ...@@ -35,7 +47,7 @@ public class EventDecorator implements DayViewDecorator {
*/ */
@Override @Override
public boolean shouldDecorate(CalendarDay day) { public boolean shouldDecorate(CalendarDay day) {
return dates.contains(day); return scheduleType != INVALID_STATE && listOfScheduleDays.get(scheduleType).containsKey(dateFormat.format(day.getDate()));
} }
/** /**
...@@ -46,5 +58,16 @@ public class EventDecorator implements DayViewDecorator { ...@@ -46,5 +58,16 @@ public class EventDecorator implements DayViewDecorator {
@Override @Override
public void decorate(DayViewFacade view) { public void decorate(DayViewFacade view) {
view.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.date_highlight)); view.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.date_highlight));
}
public void setScheduleType(int scheduleType){
this.scheduleType = scheduleType;
} }
public void setListOfScheduleDays(List<HashMap<String, ArrayList<ServiceSchedule>>> listOfScheduleDays) {
this.listOfScheduleDays = listOfScheduleDays;
}
} }
...@@ -38,7 +38,6 @@ public abstract class Mask { ...@@ -38,7 +38,6 @@ public abstract class Mask {
for (char m : mask.toCharArray()) { for (char m : mask.toCharArray()) {
if (m != '#') { if (m != '#') {
mask2 += m; mask2 += m;
continue;
}else{ }else{
try { try {
mask2 += str.charAt(i); mask2 += str.charAt(i);
......
package br.ufpr.c3sl.agendador.agendador.helpers;
import android.content.Context;
import android.support.v4.content.ContextCompat;
import com.prolificinteractive.materialcalendarview.CalendarDay;
import com.prolificinteractive.materialcalendarview.DayViewDecorator;
import com.prolificinteractive.materialcalendarview.DayViewFacade;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import br.ufpr.c3sl.agendador.agendador.R;
import br.ufpr.c3sl.agendador.agendador.models.ServiceSchedule;
/**
* Created by Lucas B. Cunha on 13/07/17.
*/
public class SchedulingDecorator implements DayViewDecorator {
public static int INVALID_STATE = -1;
private List<HashMap<String,ArrayList<ServiceSchedule>>> listOfScheduleDays;
private Context context;
private int scheduleType;
private DateFormat dateFormat;
public SchedulingDecorator(List<HashMap<String,ArrayList<ServiceSchedule>>> listOfScheduleDays, Context context) {
this.listOfScheduleDays = listOfScheduleDays;
this.context = context;
dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
}
/**
* Determine if a specific day should be decorated
*
* @param day {@linkplain CalendarDay} to possibly decorate
* @return true if this decorator should be applied to the provided day
*/
@Override
public boolean shouldDecorate(CalendarDay day) {
return scheduleType != INVALID_STATE && !listOfScheduleDays.get(scheduleType).containsKey(dateFormat.format(day.getDate()));
}
/**
* Set decoration options onto a facade to be applied to all relevant days
*
* @param view View to decorate
*/
@Override
public void decorate(DayViewFacade view) {
view.setSelectionDrawable(ContextCompat.getDrawable(context, R.drawable.date_transparent));
}
public void setScheduleType(int scheduleType){
this.scheduleType = scheduleType;
}
public void setListOfScheduleDays(List<HashMap<String, ArrayList<ServiceSchedule>>> listOfScheduleDays) {
this.listOfScheduleDays = listOfScheduleDays;
}
}
...@@ -4,15 +4,22 @@ import android.content.Context; ...@@ -4,15 +4,22 @@ import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Base64; import android.util.Base64;
import android.util.Base64OutputStream; import android.util.Base64OutputStream;
import android.util.TypedValue; import android.util.TypedValue;
import android.widget.TextView;
import com.prolificinteractive.materialcalendarview.CalendarDay;
import com.prolificinteractive.materialcalendarview.MaterialCalendarView;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Calendar;
/** /**
* Created by Lucas B. Cunha on 31/03/17. * Created by Lucas B. Cunha on 31/03/17.
...@@ -28,10 +35,11 @@ public class Utils { ...@@ -28,10 +35,11 @@ public class Utils {
public static final String SECTORS_CITIZENS_BUNDLE = "br.ufpr.c3sl.agendador.agendador.sectors_citizens_bundle"; public static final String SECTORS_CITIZENS_BUNDLE = "br.ufpr.c3sl.agendador.agendador.sectors_citizens_bundle";
public final static String DIR_PICTRS = "pictures"; public static final String DIR_PICTRS = "pictures";
public final static String USR_PICT_FILE_NAME = "usr_prof_pic";
static final String USR_PICT_FILE_NAME = "usr_prof_pic";
public final static String CITIZEN = "citizen_object"; public static final String CITIZEN = "citizen_object";
public static int getPixelValue(int dp, Context context) { public static int getPixelValue(int dp, Context context) {
Resources resources = context.getResources(); Resources resources = context.getResources();
...@@ -39,7 +47,7 @@ public class Utils { ...@@ -39,7 +47,7 @@ public class Utils {
dp, resources.getDisplayMetrics()); dp, resources.getDisplayMetrics());
} }
public static boolean isImage(File file) { static boolean isImage(File file) {
if (file == null || !file.exists()) { if (file == null || !file.exists()) {
return false; return false;
} }
...@@ -53,9 +61,7 @@ public class Utils { ...@@ -53,9 +61,7 @@ public class Utils {
byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT); byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); return BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
return decodedByte;
} }
// Converting File to Base64.encode String type using Method