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 @@ -58,6 +59,8 @@
import java.util.ListIterator;
import java.util.Locale;

import android.graphics.RectF ;
newhinton marked this conversation as resolved.
Show resolved Hide resolved

import ws.xsoh.etar.R;

public class MonthWeekEventsView extends SimpleWeekView {
Expand Down Expand Up @@ -159,6 +162,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 = 5;
private static int EVENT_RECT_MARGIN_LEFT = 5;
private static int EVENT_RECT_MARGIN_RIGHT = 5;
private static int EVENT_RECT_MARGIN_TOP = 5;
private static int EVENT_RECT_MARGIN_BOTTOM = 5;

private static int EVENT_RECT_TEXT_MARGIN_LEFT = 5;
private static int EVENT_RECT_TEXT_MARGIN_RIGHT = 5;
private static int EVENT_RECT_TEXT_MARGIN_TOP= 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because if it has an greater offset, the text moves out of the drawingboundaries for the colored chip behind it. I put it in because of completeness, but it could be removed

private static int EVENT_RECT_TEXT_MARGIN_BOTTOM = 5;

/**
* Shows up as an error if we don't include this.
*/
Expand Down Expand Up @@ -318,7 +333,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 @@ -328,7 +343,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 @@ -582,6 +597,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 @@ -608,6 +627,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() );
newhinton marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -1525,11 +1548,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){
newhinton marked this conversation as resolved.
Show resolved Hide resolved
r.left+=EVENT_RECT_MARGIN_LEFT;
r.right+=EVENT_RECT_MARGIN_LEFT;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic here sounds unusual, you add marin_left whereas in line 1559 you substract margin right

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is a bit unusual. It seems that the background version behaves differently for those cases, they seem to be differently sized, that is why they have different margins (and why the right margin is added instead of substracted) should i add a comment there why that is in the code?

r.top+=EVENT_RECT_MARGIN_TOP;
newhinton marked this conversation as resolved.
Show resolved Hide resolved
canvas.drawRoundRect(new RectF(r), EVENT_RECT_ROUNDING, EVENT_RECT_ROUNDING, mEventSquarePaint);
}else{
newhinton marked this conversation as resolved.
Show resolved Hide resolved
r.left+=EVENT_RECT_MARGIN_LEFT;
r.right-=EVENT_RECT_MARGIN_RIGHT;
r.top+=EVENT_RECT_MARGIN_TOP;
r.bottom-=EVENT_RECT_MARGIN_BOTTOM;
newhinton marked this conversation as resolved.
Show resolved Hide resolved
//canvas.drawRect(r, mEventSquarePaint);
newhinton marked this conversation as resolved.
Show resolved Hide resolved
canvas.drawRoundRect(new RectF(r), EVENT_RECT_ALLDAY_ROUNDING, EVENT_RECT_ALLDAY_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 @@ -1625,7 +1661,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,
newhinton marked this conversation as resolved.
Show resolved Hide resolved
getTextPaint());
mBoundaries.moveLinesDown(1);
}
Expand Down