added calendar widget - still needs work though days of week are not internationalized and Set button should be removed (date should be set on pressing the date

pull/14/head
Jon Paris 14 years ago
parent bebd8db682
commit dd6aebe111

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<com.company.view.CalendarView
android:id="@+id/CalendarView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="7">
<Button android:layout_width="wrap_content"
android:layout_height="fill_parent" android:text="Set" android:id="@+id/SetButton"
android:layout_weight="1" />
<Button android:layout_width="wrap_content"
android:layout_height="fill_parent" android:text="Cancel" android:id="@+id/CancelButton"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>

@ -27,16 +27,15 @@ import java.util.LinkedList;
import java.util.List;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.TabActivity;
import android.app.DatePickerDialog.OnDateSetListener;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.DialogInterface.OnCancelListener;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
@ -49,11 +48,11 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
@ -64,7 +63,6 @@ import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import android.widget.ToggleButton;
import android.widget.AdapterView.OnItemSelectedListener;
import com.timsu.astrid.R;
import com.todoroo.andlib.data.Property.StringProperty;
@ -89,6 +87,7 @@ import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.tags.TagsControlSet;
import com.todoroo.astrid.timers.TimerControlSet;
import com.todoroo.astrid.ui.CalendarDialog;
import com.todoroo.astrid.ui.DeadlineTimePickerDialog;
import com.todoroo.astrid.ui.DeadlineTimePickerDialog.OnDeadlineTimeSetListener;
import com.todoroo.astrid.voice.VoiceInputAssistant;
@ -183,6 +182,8 @@ public final class TaskEditActivity extends TabActivity {
private EditText notesEditText;
private boolean cancelled = false;
/* ======================================================================
* ======================================================= initialization
* ====================================================================== */
@ -796,7 +797,7 @@ public final class TaskEditActivity extends TabActivity {
// --- UrgencyControlSet
private class UrgencyControlSet implements TaskEditControlSet,
OnItemSelectedListener, OnDeadlineTimeSetListener, OnDateSetListener,
OnItemSelectedListener, OnDeadlineTimeSetListener,
OnCancelListener {
private static final int SPECIFIC_DATE = -1;
@ -918,10 +919,30 @@ public final class TaskEditActivity extends TabActivity {
customSetting = item.setting;
customDate = new Date(existingDate == EXISTING_TIME_UNSET ? DateUtilities.now() : existingDate);
customDate.setSeconds(0);
DatePickerDialog datePicker = new DatePickerDialog(TaskEditActivity.this,
this, 1900 + customDate.getYear(), customDate.getMonth(), customDate.getDate());
datePicker.setOnCancelListener(this);
datePicker.show();
/***** Calendar Dialog Changes -- Start *****/
final CalendarDialog calendarDialog = new CalendarDialog(TaskEditActivity.this, customDate);
calendarDialog.show();
calendarDialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface arg0) {
if (!cancelled) {
setDate(calendarDialog);
}
cancelled = false;
}
});
calendarDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface arg0) {
cancelled = true;
}
});
/***** Calendar Dialog Changes -- End *****/
// DatePickerDialog datePicker = new DatePickerDialog(TaskEditActivity.this,
// this, 1900 + customDate.getYear(), customDate.getMonth(), customDate.getDate());
// datePicker.setOnCancelListener(this);
// datePicker.show();
spinner.setSelection(previousSetting);
} else {
@ -938,7 +959,31 @@ public final class TaskEditActivity extends TabActivity {
Date customDate;
int customSetting;
public void onDateSet(DatePicker view, int year, int month, int monthDay) {
private void setDate(CalendarDialog calendarDialog) {
customDate = calendarDialog.getCalendarDate();
customDate.setMinutes(0);
if(customSetting != Task.URGENCY_SPECIFIC_DAY_TIME) {
customDateFinished();
return;
}
boolean specificTime = existingDateHour != SPECIFIC_DATE;
if(existingDateHour < 0) {
existingDateHour = customDate.getHours();
existingDateMinutes= customDate.getMinutes();
}
DeadlineTimePickerDialog timePicker = new DeadlineTimePickerDialog(TaskEditActivity.this, this,
existingDateHour, existingDateMinutes,
DateUtilities.is24HourFormat(TaskEditActivity.this),
specificTime);
timePicker.setOnCancelListener(this);
timePicker.show();
}
/*public void onDateSet(DatePicker view, int year, int month, int monthDay) {
customDate.setYear(year - 1900);
customDate.setMonth(month);
customDate.setDate(monthDay);
@ -962,7 +1007,7 @@ public final class TaskEditActivity extends TabActivity {
timePicker.setOnCancelListener(this);
timePicker.show();
}
}*/
public void onTimeSet(TimePicker view, boolean hasTime, int hourOfDay, int minute) {
if(!hasTime)
@ -1013,7 +1058,7 @@ public final class TaskEditActivity extends TabActivity {
*
*/
private class HideUntilControlSet implements TaskEditControlSet,
OnItemSelectedListener, OnDateSetListener, OnCancelListener,
OnItemSelectedListener, OnCancelListener,
OnDeadlineTimeSetListener {
private static final int SPECIFIC_DATE = -1;
@ -1103,10 +1148,31 @@ public final class TaskEditActivity extends TabActivity {
if(item.date == SPECIFIC_DATE) {
customDate = new Date(existingDate == EXISTING_TIME_UNSET ? DateUtilities.now() : existingDate);
customDate.setSeconds(0);
DatePickerDialog datePicker = new DatePickerDialog(TaskEditActivity.this,
/***** Calendar Dialog Changes -- Start *****/
final CalendarDialog calendarDialog = new CalendarDialog(TaskEditActivity.this, customDate);
calendarDialog.show();
calendarDialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface arg0) {
if (!cancelled) {
setDate(calendarDialog);
}
cancelled = false;
}
});
calendarDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface arg0) {
cancelled = true;
}
});
/***** Calendar Dialog Changes -- End *****/
/*DatePickerDialog datePicker = new DatePickerDialog(TaskEditActivity.this,
this, 1900 + customDate.getYear(), customDate.getMonth(), customDate.getDate());
datePicker.setOnCancelListener(this);
datePicker.show();
datePicker.show();*/
spinner.setSelection(previousSetting);
} else {
@ -1122,7 +1188,25 @@ public final class TaskEditActivity extends TabActivity {
Date customDate;
public void onDateSet(DatePicker view, int year, int month, int monthDay) {
private void setDate(CalendarDialog calendarDialog) {
customDate = calendarDialog.getCalendarDate();
boolean specificTime = existingDateHour != SPECIFIC_DATE;
if(existingDateHour < 0) {
existingDateHour = customDate.getHours();
existingDateMinutes= customDate.getMinutes();
}
DeadlineTimePickerDialog timePicker = new DeadlineTimePickerDialog(TaskEditActivity.this, this,
existingDateHour, existingDateMinutes,
DateUtilities.is24HourFormat(TaskEditActivity.this),
specificTime);
timePicker.setOnCancelListener(this);
timePicker.show();
}
/*public void onDateSet(DatePicker view, int year, int month, int monthDay) {
customDate.setYear(year - 1900);
customDate.setMonth(month);
customDate.setDate(monthDay);
@ -1140,7 +1224,7 @@ public final class TaskEditActivity extends TabActivity {
timePicker.setOnCancelListener(this);
timePicker.show();
}
}*/
public void onTimeSet(TimePicker view, boolean hasTime, int hourOfDay, int minute) {
if(!hasTime) {

@ -0,0 +1,63 @@
package com.todoroo.astrid.ui;
import java.util.Date;
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.Button;
import com.timsu.astrid.R;
public class CalendarDialog extends Dialog implements OnClickListener {
private final Button setButton;
private final Button cancelButton;
private Date calendarDate;
private final CalendarView calendarView;
public CalendarDialog(Context context, Date calendarDate) {
super(context);
this.calendarDate = calendarDate;
/** 'Window.FEATURE_NO_TITLE' - Used to hide the title */
requestWindowFeature(Window.FEATURE_NO_TITLE);
/** Design the dialog in main.xml file */
setContentView(R.layout.calendar);
LayoutParams params = getWindow().getAttributes();
params.height = LayoutParams.FILL_PARENT;
params.width = LayoutParams.FILL_PARENT;
getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
setButton = (Button) findViewById(R.id.SetButton);
cancelButton = (Button) findViewById(R.id.CancelButton);
calendarView = (CalendarView) findViewById(R.id.CalendarView);
calendarView.setCalendarDate(calendarDate);
setButton.setOnClickListener(this);
cancelButton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == setButton) {
calendarDate = calendarView.getCalendarDate();
dismiss();
} else if (v == cancelButton) {
cancel();
}
}
public Date getCalendarDate() {
return calendarDate;
}
public void setCalendarDate(Date calendarDate) {
this.calendarDate = calendarDate;
}
}

@ -0,0 +1,386 @@
package com.todoroo.astrid.ui;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.text.format.DateFormat;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import com.timsu.astrid.R;
public class CalendarView extends View {
private static final int PADDING = 3;
private final static int CURVE_RADIUS = 5;
private final static int TEXT_SIZE = 16;
private final static String[] DAYS = {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"};
private Paint borderPaint;
private Paint borderRightAlignPaint;
private Paint backColorPaint;
private Paint whiteCenterAlignPaint;
private Paint whiteRightAlignPaint;
private Paint dayPaint;
private Paint calendarPaint;
private int leftArrowHeight;
private int leftArrowWidth;
private int rightArrowHeight;
private int rightArrowWidth;
private int leftArrowX = 0;
private int leftArrowY = 0;
private int rightArrowX = 0;
private int rightArrowY = 0;
private int[] dayLeftArr;
private int[] dayTopArr;
private int boxWidth;
private int boxHeight;
private Date calendarDate = new Date();
private int currentHighlightDay = -1;
/**
* Constructor. This version is only needed if you will be instantiating
* the object manually (not from a layout XML file).
* @param context
*/
public CalendarView(Context context) {
super(context);
initCalendarView();
}
public CalendarView(Context context, AttributeSet attrs) {
super(context, attrs);
initCalendarView();
}
private final void initCalendarView() {
borderPaint = new Paint();
borderPaint.setAntiAlias(true);
borderPaint.setColor(Color.BLACK);
borderRightAlignPaint = new Paint();
borderRightAlignPaint.setAntiAlias(true);
borderRightAlignPaint.setColor(Color.BLACK);
borderRightAlignPaint.setTextSize(TEXT_SIZE);
borderRightAlignPaint.setTextAlign(Paint.Align.RIGHT);
dayPaint = new Paint();
dayPaint.setAntiAlias(true);
dayPaint.setColor(Color.rgb(137, 135, 132));
calendarPaint = new Paint();
calendarPaint.setAntiAlias(true);
calendarPaint.setColor(Color.rgb(202, 201, 194));
whiteCenterAlignPaint = new Paint();
whiteCenterAlignPaint.setAntiAlias(true);
whiteCenterAlignPaint.setColor(Color.WHITE);
whiteCenterAlignPaint.setTextAlign(Paint.Align.CENTER);
whiteCenterAlignPaint.setTextSize(TEXT_SIZE);
whiteRightAlignPaint = new Paint();
whiteRightAlignPaint.setAntiAlias(true);
whiteRightAlignPaint.setColor(Color.WHITE);
whiteRightAlignPaint.setTextAlign(Paint.Align.RIGHT);
whiteRightAlignPaint.setTextSize(TEXT_SIZE);
backColorPaint = new Paint();
backColorPaint.setAntiAlias(true);
backColorPaint.setColor(Color.rgb(68, 68, 68));
setPadding(PADDING, PADDING, PADDING, PADDING);
}
/**
* @see android.view.View#measure(int, int)
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(measureWidth(widthMeasureSpec),
measureHeight(heightMeasureSpec));
}
/**
* Determines the width of this view
* @param measureSpec A measureSpec packed into an int
* @return The width of the view, honoring constraints from measureSpec
*/
private int measureWidth(int measureSpec) {
int result = 0;
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec);
if (specMode == MeasureSpec.EXACTLY) {
// We were told how big to be
result = specSize;
}
return result;
}
/**
* Determines the height of this view
* @param measureSpec A measureSpec packed into an int
* @return The height of the view, honoring constraints from measureSpec
*/
private int measureHeight(int measureSpec) {
int result = 0;
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec);
if (specMode == MeasureSpec.EXACTLY) {
// We were told how big to be
result = specSize;
}
return result;
}
/**
* @see android.view.View#onDraw(android.graphics.Canvas)
*/
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// Background
canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), backColorPaint);
// Outermost border -- Start
RectF outerMostBorder = new RectF();
outerMostBorder.set(5, 5, getMeasuredWidth() - 5, getMeasuredHeight() - 5);
canvas.drawRoundRect(outerMostBorder, CURVE_RADIUS, CURVE_RADIUS, borderPaint);
outerMostBorder.set(6, 6, getMeasuredWidth() - 6, getMeasuredHeight() - 6);
canvas.drawRoundRect(outerMostBorder, CURVE_RADIUS, CURVE_RADIUS, backColorPaint);
// Outermost border -- end
// Month border -- Start
RectF rectF = new RectF();
rectF.set(15, 15, getMeasuredWidth() - 15, (int)(getMeasuredHeight() * 0.2)); // 20% height is given to month border
canvas.drawRoundRect(rectF, CURVE_RADIUS, CURVE_RADIUS, borderPaint);
rectF.set(16, 16, getMeasuredWidth() - 16, (int)(getMeasuredHeight() * 0.2) - 1);
canvas.drawRoundRect(rectF, CURVE_RADIUS, CURVE_RADIUS, backColorPaint);
// Month border -- end
// Month left arrow -- Start
InputStream is = getResources().openRawResource(R.drawable.leftarrow);
Bitmap leftArrow = BitmapFactory.decodeStream(is);
leftArrowHeight = leftArrow.getHeight();
leftArrowWidth = leftArrow.getWidth();
leftArrowX = 24;
leftArrowY = 8 + (int)((getMeasuredHeight() * 0.2 / 2) - (leftArrowHeight/2));
System.out.println("Left arrow x, y, height, width : " + leftArrowX + ", " + leftArrowY + ", " + leftArrowHeight + ", " + leftArrowWidth);
canvas.drawBitmap(leftArrow, leftArrowX, leftArrowY, null);
// Month left arrow -- End
// Month right arrow -- Start
is = getResources().openRawResource(R.drawable.rightarrow);
Bitmap rightArrow = BitmapFactory.decodeStream(is);
rightArrowHeight = rightArrow.getHeight();
rightArrowWidth = rightArrow.getWidth();
rightArrowX = getMeasuredWidth() - 16 - (PADDING*3) - rightArrow.getWidth();
rightArrowY = 8 + (int)((getMeasuredHeight() * 0.2 / 2) - (rightArrowHeight/2));
// System.out.println("Right arrow x, y, height, width : " + rightArrowX + ", " + rightArrowY + ", " + rightArrowHeight + ", " + rightArrowWidth);
canvas.drawBitmap(rightArrow, rightArrowX, rightArrowY, null);
// Month right arrow -- End
// Month text -- Start
int monthX = getMeasuredWidth() / 2;
int monthY = (int) (getMeasuredHeight() * 0.2 / 2) + 14;
String monthYear = (String) DateFormat.format("MMMM yyyy", calendarDate);
canvas.drawText(monthYear, monthX, monthY, whiteCenterAlignPaint);
// Month text -- End
// Day heading -- Start
int dayLeft = 15;
int dayTop = (int)(getMeasuredHeight() * 0.2) + (PADDING * 2);
boxWidth = (getMeasuredWidth() - 38 - (PADDING*2)) / 7;
boxHeight = (int) (((getMeasuredHeight() - (getMeasuredHeight() * 0.2) - 16) - (PADDING * 8)) / 7);
// int boxHeight = boxWidth;
int textX = 0;
int textY = 0;
for (String day : DAYS) {
rectF.set(dayLeft, dayTop, dayLeft + boxWidth, dayTop + boxHeight);
canvas.drawRoundRect(rectF, CURVE_RADIUS, CURVE_RADIUS, borderPaint);
rectF.set(dayLeft+1, dayTop+1, dayLeft + boxWidth - 1, dayTop + boxHeight - 1);
canvas.drawRoundRect(rectF, CURVE_RADIUS, CURVE_RADIUS, dayPaint);
String strDateFormat = "E";
SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
textX = dayLeft + boxWidth - PADDING * 2;
textY = dayTop + (boxHeight - boxHeight/8) - PADDING * 2;
canvas.drawText(day, textX, textY, whiteRightAlignPaint);
dayLeft += boxWidth + PADDING;
}
// Day heading -- End
// Calendar -- Start
Calendar calendar = Calendar.getInstance();
calendar.setTime(calendarDate);
if (currentHighlightDay == -1) {
currentHighlightDay = calendar.get(Calendar.DATE);
}
int lastDateOfThisMonth = calendar.getActualMaximum(Calendar.DATE);
calendar.set(Calendar.DATE, 1);
// SUNDAY is 1 in java.util.Calendar
int firstDay = calendar.get(Calendar.DAY_OF_WEEK);
// Setting as per our calendar, as it starts from monday and not sunday
if (firstDay == Calendar.SUNDAY) {
firstDay = 7;
} else {
firstDay--;
}
boolean firstTime = true;
int dayOfMonth = 1;
Paint colorPaint, textPaint;
dayLeftArr = new int[lastDateOfThisMonth];
dayTopArr = new int[lastDateOfThisMonth];
for (int i = 1; i <= 6; i++) {
dayLeft = 15;
dayTop += boxHeight + PADDING;
for (int j = 1; j <= 7; j++) {
if (firstTime && j != firstDay) {
dayLeft += boxWidth + PADDING;
continue;
}
firstTime = false;
if (dayOfMonth <= lastDateOfThisMonth) {
if (currentHighlightDay == dayOfMonth) {
colorPaint = whiteRightAlignPaint;
textPaint = borderRightAlignPaint;
} else {
colorPaint = calendarPaint;
textPaint = whiteRightAlignPaint;
}
dayLeftArr[dayOfMonth-1] = dayLeft;
dayTopArr[dayOfMonth-1] = dayTop;
rectF.set(dayLeft, dayTop, dayLeft + boxWidth, dayTop + boxHeight);
canvas.drawRoundRect(rectF, CURVE_RADIUS, CURVE_RADIUS, borderPaint);
rectF.set(dayLeft+1, dayTop+1, dayLeft + boxWidth - 1, dayTop + boxHeight - 1);
canvas.drawRoundRect(rectF, CURVE_RADIUS, CURVE_RADIUS, colorPaint);
textX = dayLeft + boxWidth - PADDING * 2;
textY = dayTop + (boxHeight - boxHeight/8) - PADDING * 2;
canvas.drawText(String.valueOf(dayOfMonth), textX, textY, textPaint);
dayLeft += boxWidth + PADDING;
dayOfMonth++;
}
}
}
// Calendar -- End
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_UP:
int x = (int) event.getX();
int y = (int) event.getY();
performClick(x, y);
break;
}
return true;
}
private void performClick(int x, int y) {
// System.out.println("---------------------Current x, y : " + x + ", " + y);
// Handle left-right arrow click -- start
if ((x > leftArrowX && x < (leftArrowX + leftArrowWidth))
&& (y > leftArrowY && y < (leftArrowY + leftArrowHeight))) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(calendarDate);
int prevMonth = calendar.get(Calendar.MONTH);
int currentMonth = calendar.get(Calendar.MONTH);
if (currentMonth == Calendar.JANUARY) {
calendar.set(Calendar.MONTH, Calendar.DECEMBER);
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 1);
} else {
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1);
}
calendarDate = calendar.getTime();
calendar.setTime(calendarDate);
if (prevMonth == calendar.get(Calendar.MONTH)) {
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1);
calendar.set(Calendar.DATE, 1);
calendarDate = calendar.getTime();
}
currentHighlightDay = calendar.get(Calendar.DATE);
this.invalidate();
} else if ((x > rightArrowX && x < (rightArrowX + rightArrowWidth))
&& (y > rightArrowY && y < (rightArrowY + rightArrowHeight))) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(calendarDate);
int prevMonth = calendar.get(Calendar.MONTH);
int currentMonth = calendar.get(Calendar.MONTH);
if (currentMonth == Calendar.DECEMBER) {
calendar.set(Calendar.MONTH, Calendar.JANUARY);
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) + 1);
} else {
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) + 1);
}
calendarDate = calendar.getTime();
if (prevMonth == calendar.get(Calendar.MONTH)) {
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1);
calendar.set(Calendar.DATE, 1);
calendarDate = calendar.getTime();
}
currentHighlightDay = calendar.get(Calendar.DATE);
this.invalidate();
// Handle left-right arrow click -- end
} else {
// Check if clicked on date
for (int i=0; i<dayLeftArr.length; i++) {
if ((x > dayLeftArr[i] && x < dayLeftArr[i]+boxWidth) && (y > dayTopArr[i] && y < dayTopArr[i] + boxHeight)) {
currentHighlightDay = i+1;
Calendar calendar = Calendar.getInstance();
calendar.setTime(calendarDate);
calendar.set(Calendar.DATE, currentHighlightDay);
calendarDate = calendar.getTime();
this.invalidate();
}
}
}
}
public Date getCalendarDate() {
return calendarDate;
}
public void setCalendarDate(Date calendarDate) {
this.calendarDate = calendarDate;
}
}
Loading…
Cancel
Save