@@ -63,6 +63,9 @@ public class SimpleMonthView extends View {
63
63
protected int mWeekStart = 1 ;
64
64
protected int mWidth ;
65
65
protected int mYear ;
66
+ protected int mDayDisabledTextColor ;
67
+ protected int mStartDay ;
68
+ protected int mEndDay ;
66
69
private DateFormatSymbols mDateFormatSymbols = new DateFormatSymbols ();
67
70
68
71
public SimpleMonthView (Context context ) {
@@ -73,6 +76,7 @@ public SimpleMonthView(Context context) {
73
76
this .mDayOfWeekTypeface = resources .getString (R .string .day_of_week_label_typeface );
74
77
this .mMonthTitleTypeface = resources .getString (R .string .sans_serif );
75
78
this .mDayTextColor = resources .getColor (R .color .date_picker_text_normal );
79
+ this .mDayDisabledTextColor = resources .getColor (R .color .date_picker_text_disabled );
76
80
this .mTodayNumberColor = resources .getColor (R .color .blue );
77
81
this .mMonthTitleColor = resources .getColor (R .color .white );
78
82
this .mMonthTitleBGColor = resources .getColor (R .color .circle_background );
@@ -149,8 +153,11 @@ protected void drawMonthNums(Canvas canvas) {
149
153
int x = paddingDay * (1 + dayOffset * 2 ) + this .mPadding ;
150
154
if (this .mSelectedDay == day )
151
155
canvas .drawCircle (x , y - MINI_DAY_NUMBER_TEXT_SIZE / 3 , DAY_SELECTED_CIRCLE_SIZE , this .mSelectedCirclePaint );
156
+
152
157
if ((this .mHasToday ) && (this .mToday == day ))
153
158
this .mMonthNumPaint .setColor (this .mTodayNumberColor );
159
+ else if (day < this .mStartDay || day > this .mEndDay )
160
+ this .mMonthNumPaint .setColor (this .mDayDisabledTextColor );
154
161
else
155
162
this .mMonthNumPaint .setColor (this .mDayTextColor );
156
163
canvas .drawText (String .format ("%d" , day ), x , y , this .mMonthNumPaint );
@@ -171,7 +178,9 @@ public SimpleMonthAdapter.CalendarDay getDayFromLocation(float x, float y) {
171
178
172
179
int yDay = (int ) (y - MONTH_HEADER_SIZE ) / this .mRowHeight ;
173
180
int day = 1 + ((int ) ((x - padding ) * this .mNumDays / (this .mWidth - padding - this .mPadding )) - findDayOffset ()) + yDay * this .mNumDays ;
174
-
181
+ // If day out of range
182
+ if (day < this .mStartDay || day > this .mEndDay )
183
+ return null ;
175
184
return new SimpleMonthAdapter .CalendarDay (this .mYear , this .mMonth , day );
176
185
}
177
186
@@ -254,6 +263,8 @@ public void setMonthParams(HashMap<String, Integer> monthParams) {
254
263
this .mSelectedDay = ((Integer ) monthParams .get ("selected_day" )).intValue ();
255
264
this .mMonth = ((Integer ) monthParams .get ("month" )).intValue ();
256
265
this .mYear = ((Integer ) monthParams .get ("year" )).intValue ();
266
+ this .mStartDay = ((Integer ) monthParams .get ("start_day" )).intValue ();
267
+ this .mEndDay = ((Integer ) monthParams .get ("end_day" )).intValue ();
257
268
Time time = new Time (Time .getCurrentTimezone ());
258
269
time .setToNow ();
259
270
this .mHasToday = false ;
0 commit comments