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

Issue AGILE#175: [WIP] Highlight available dates

Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent baf6a00d
......@@ -9,6 +9,7 @@ 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;
......@@ -26,8 +27,15 @@ import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import com.prolificinteractive.materialcalendarview.CalendarDay;
import com.prolificinteractive.materialcalendarview.MaterialCalendarView;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
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;
......@@ -57,6 +65,8 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
private TextView tv_year, tv_day_month;
private MaterialCalendarView mcv;
//TODO: create class "ConfirmationDialog"
private ConfirmationDialog confirmationDialog;
......@@ -171,6 +181,25 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
tv_day_month = (TextView) v.findViewById(R.id.tv_calendar_day_month_scheduling);
mcv = (MaterialCalendarView) ll_fields.findViewById(R.id.ll_scheduling_calendar).findViewById(R.id.mcv_scheduling_date);
if(mcv == null){
Log.d("AAAAa", "aaaaaaaaaa");
}
else
mcv.state().edit().setMinimumDate(CalendarDay.today()).commit();
HashSet<CalendarDay> hash = new HashSet<>();
Calendar.getInstance().setTime(new Date());
EventDecorator decorator;
hash.add(CalendarDay.today());
decorator = new EventDecorator(ContextCompat.getColor(this, R.color.colorGreen), hash, this);
mcv.addDecorator(decorator);
Calendar calendar = Calendar.getInstance();
// TODO: 24/05/17 Arrumar a apresentação da data
String s = calendar.get(Calendar.YEAR) + "";
......
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 com.prolificinteractive.materialcalendarview.spans.DotSpan;
import java.util.Collection;
import java.util.HashSet;
import br.ufpr.c3sl.agendador.agendador.R;
/**
* Created by lbc16 on 25/05/17.
*/
public class EventDecorator implements DayViewDecorator {
private final int color;
private final HashSet<CalendarDay> dates;
private Context context;
public EventDecorator(int color, Collection<CalendarDay> dates, Context context) {
this.color = color;
this.dates = new HashSet<>(dates);
this.context = context;
}
/**
* 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 dates.contains(day);
}
/**
* 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.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.green_button_shape));
}
}
......@@ -159,8 +159,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:mcv_selectionColor="@color/colorGreen"
app:mcv_selectionColor="@color/colorGray"
app:mcv_showOtherDates="all"
app:mcv_calendarMode="month"
app:mcv_monthLabels="@array/months_pt"
app:mcv_weekDayLabels="@array/days_pt"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment