Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/731/slim monthview #733

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<color name="mini_month_bg_color">#FFFFFFFF</color>
<color name="mini_month_today_outline_color">#FF000000</color>

<color name="month_day_number">#FF555555</color>
<color name="month_day_number">#FFBFBFBF</color>
<color name="month_mini_day_number">#FF000000</color>
<color name="month_day_number_other">#FF999999</color>
<color name="month_week_num_color">#41c3b1</color>
Expand Down
46 changes: 41 additions & 5 deletions src/com/android/calendar/month/MonthWeekEventsView.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import android.text.format.DateUtils;
import android.text.format.Time;
import android.util.Log;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
Expand All @@ -59,6 +60,8 @@
import java.util.ListIterator;
import java.util.Locale;

import android.graphics.RectF;

import ws.xsoh.etar.R;

public class MonthWeekEventsView extends SimpleWeekView {
Expand Down Expand Up @@ -161,6 +164,18 @@ public class MonthWeekEventsView extends SimpleWeekView {
private ObjectAnimator mTodayAnimator = null;
private int[] mDayXs;

private static int EVENT_RECT_ROUNDING = 5;
private static int EVENT_RECT_ALLDAY_ROUNDING = 2;
private static int EVENT_RECT_MARGIN_LEFT = 5;
private static int EVENT_RECT_MARGIN_RIGHT = 2;
private static int EVENT_RECT_MARGIN_TOP = 5;
private static int EVENT_RECT_MARGIN_BOTTOM = 5;

private static int EVENT_RECT_TEXT_MARGIN_LEFT = 15;
private static int EVENT_RECT_TEXT_MARGIN_RIGHT = 5;
private static int EVENT_RECT_TEXT_MARGIN_TOP= 10;
private static int EVENT_RECT_TEXT_MARGIN_BOTTOM = 10;

/**
* Shows up as an error if we don't include this.
*/
Expand Down Expand Up @@ -321,7 +336,7 @@ protected void initView() {
mMonthNumHeight = (int) (mMonthNumPaint.descent() - mMonthNumPaint.ascent() + 0.5f);

mEventPaint = new TextPaint();
mEventPaint.setFakeBoldText(true);
mEventPaint.setFakeBoldText(false);
mEventPaint.setAntiAlias(true);
mEventPaint.setTextSize(mTextSizeEventTitle);
mEventPaint.setColor(mMonthEventColor);
Expand All @@ -331,7 +346,7 @@ protected void initView() {
mFramedEventPaint = new TextPaint(mSolidBackgroundEventPaint);

mDeclinedEventPaint = new TextPaint();
mDeclinedEventPaint.setFakeBoldText(true);
mDeclinedEventPaint.setFakeBoldText(false);
mDeclinedEventPaint.setAntiAlias(true);
mDeclinedEventPaint.setTextSize(mTextSizeEventTitle);
mDeclinedEventPaint.setColor(mMonthDeclinedEventColor);
Expand Down Expand Up @@ -592,6 +607,10 @@ private void drawClick(Canvas canvas) {
}
}

/**
* This draws the weeknumber or the daynumber, depending on the view.
* @param canvas The canvas to draw on
*/
@Override
protected void drawWeekNums(Canvas canvas) {
int y;
Expand All @@ -618,6 +637,10 @@ protected void drawWeekNums(Canvas canvas) {
boolean isBold = false;
mMonthNumPaint.setColor(isFocusMonth ? mMonthNumColor : mMonthNumOtherColor);

float twelveDp = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16,
getResources().getDisplayMetrics());
mMonthNumPaint.setTextSize(twelveDp);

// Get the julian monday used to show the lunar info.
int julianMonday = Utils.getJulianMondayFromWeeksSinceEpoch(mWeek);
Time time = new Time(mTimeZone);
Expand Down Expand Up @@ -1535,11 +1558,24 @@ protected void drawEventRectangle(Canvas canvas, int day) {
mBoundaries.setRectangle(mFormat.getDaySpan(day), mFormat.getEventLines());
mEventSquarePaint.setStyle(getRectanglePaintStyle());
mEventSquarePaint.setColor(getRectangleColor());
canvas.drawRect(r, mEventSquarePaint);

if(mEvent.allDay){
r.left += EVENT_RECT_MARGIN_LEFT;
r.right -= EVENT_RECT_MARGIN_RIGHT;
r.top += EVENT_RECT_MARGIN_TOP;
r.bottom += EVENT_RECT_MARGIN_BOTTOM+EVENT_RECT_TEXT_MARGIN_BOTTOM;
canvas.drawRoundRect(new RectF(r), EVENT_RECT_ALLDAY_ROUNDING, EVENT_RECT_ALLDAY_ROUNDING, mEventSquarePaint);
} else {
r.left += EVENT_RECT_MARGIN_LEFT;
r.right += EVENT_RECT_MARGIN_RIGHT;
r.top += EVENT_RECT_MARGIN_TOP+EVENT_RECT_TEXT_MARGIN_TOP; //both so that the bar aligns with the text
r.bottom += EVENT_RECT_TEXT_MARGIN_BOTTOM;
canvas.drawRoundRect(new RectF(r), EVENT_RECT_ROUNDING, EVENT_RECT_ROUNDING, mEventSquarePaint);
}
}

protected int getAvailableSpaceForText(int spanningDays) {
return mBoundaries.getTextRightEdge(spanningDays) - mBoundaries.getTextX();
return mBoundaries.getTextRightEdge(spanningDays) - mBoundaries.getTextX() - EVENT_RECT_TEXT_MARGIN_RIGHT;
}

@Override
Expand Down Expand Up @@ -1635,7 +1671,7 @@ protected void drawText(Canvas canvas, ViewDetailsPreferences.Preferences prefer
lineText = baseText.subSequence(mTextLayout.getLineStart(i),
mTextLayout.getLineEnd(i));
}
canvas.drawText(lineText.toString(), mBoundaries.getTextX(), mBoundaries.getTextY(),
canvas.drawText(lineText.toString(), mBoundaries.getTextX() + EVENT_RECT_TEXT_MARGIN_LEFT, mBoundaries.getTextY() + EVENT_RECT_TEXT_MARGIN_TOP,
getTextPaint());
mBoundaries.moveLinesDown(1);
}
Expand Down