// Returns the julian day of the day in the upper right corner private int getUpperRightJulianDay() { SimpleWeekView child = (SimpleWeekView) getChildAt(0); if (child == null) { return -1; } return child.getFirstJulianDay() + SimpleDayPickerFragment.DAYS_PER_WEEK - 1; }
@Override public void setWeekParams(HashMap<String, Integer> params, String tz) { super.setWeekParams(params, tz); if (params.containsKey(VIEW_PARAMS_ORIENTATION)) { mOrientation = params.get(VIEW_PARAMS_ORIENTATION); } updateToday(tz); mNumCells = mNumDays + 1; if (params.containsKey(VIEW_PARAMS_ANIMATE_TODAY) && mHasToday) { synchronized (mAnimatorListener) { if (mTodayAnimator != null) { mTodayAnimator.removeAllListeners(); mTodayAnimator.cancel(); } mTodayAnimator = ObjectAnimator.ofInt(this, "animateTodayAlpha", Math.max(mAnimateTodayAlpha, 80), 255); mTodayAnimator.setDuration(150); mAnimatorListener.setAnimator(mTodayAnimator); mAnimatorListener.setFadingIn(true); mTodayAnimator.addListener(mAnimatorListener); mAnimateToday = true; mTodayAnimator.start(); } } }
/** * Sets up the text and style properties for painting. Override this if you want to use a * different paint. */ @Override protected void initView() { super.initView(); if (!mInitialized) { Resources resources = getContext().getResources(); mShowDetailsInMonth = Utils.getConfigBool(getContext(), R.bool.show_details_in_month); TEXT_SIZE_EVENT_TITLE = resources.getInteger(R.integer.text_size_event_title); TEXT_SIZE_MONTH_NUMBER = resources.getInteger(R.integer.text_size_month_number); SIDE_PADDING_MONTH_NUMBER = resources.getInteger(R.integer.month_day_number_margin); CONFLICT_COLOR = resources.getColor(R.color.month_dna_conflict_time_color); EVENT_TEXT_COLOR = resources.getColor(R.color.calendar_event_text_color); if (mScale != 1) { TOP_PADDING_MONTH_NUMBER *= mScale; TOP_PADDING_WEEK_NUMBER *= mScale; SIDE_PADDING_MONTH_NUMBER *= mScale; SIDE_PADDING_WEEK_NUMBER *= mScale; SPACING_WEEK_NUMBER *= mScale; TEXT_SIZE_MONTH_NUMBER *= mScale; TEXT_SIZE_EVENT *= mScale; TEXT_SIZE_EVENT_TITLE *= mScale; TEXT_SIZE_MORE_EVENTS *= mScale; TEXT_SIZE_MONTH_NAME *= mScale; TEXT_SIZE_WEEK_NUM *= mScale; DAY_SEPARATOR_OUTER_WIDTH *= mScale; DAY_SEPARATOR_INNER_WIDTH *= mScale; DAY_SEPARATOR_VERTICAL_LENGTH *= mScale; DAY_SEPARATOR_VERTICAL_LENGHT_PORTRAIT *= mScale; EVENT_X_OFFSET_LANDSCAPE *= mScale; EVENT_Y_OFFSET_LANDSCAPE *= mScale; EVENT_Y_OFFSET_PORTRAIT *= mScale; EVENT_SQUARE_WIDTH *= mScale; EVENT_SQUARE_BORDER *= mScale; EVENT_LINE_PADDING *= mScale; EVENT_BOTTOM_PADDING *= mScale; EVENT_RIGHT_PADDING *= mScale; DNA_MARGIN *= mScale; DNA_WIDTH *= mScale; DNA_ALL_DAY_HEIGHT *= mScale; DNA_MIN_SEGMENT_HEIGHT *= mScale; DNA_SIDE_PADDING *= mScale; DEFAULT_EDGE_SPACING *= mScale; DNA_ALL_DAY_WIDTH *= mScale; TODAY_HIGHLIGHT_WIDTH *= mScale; } if (!mShowDetailsInMonth) { TOP_PADDING_MONTH_NUMBER += DNA_ALL_DAY_HEIGHT + DNA_MARGIN; } mInitialized = true; } mPadding = DEFAULT_EDGE_SPACING; loadColors(getContext()); // TODO modify paint properties depending on isMini mMonthNumPaint = new Paint(); mMonthNumPaint.setFakeBoldText(false); mMonthNumPaint.setAntiAlias(true); mMonthNumPaint.setTextSize(TEXT_SIZE_MONTH_NUMBER); mMonthNumPaint.setColor(mMonthNumColor); mMonthNumPaint.setStyle(Style.FILL); mMonthNumPaint.setTextAlign(Align.RIGHT); mMonthNumPaint.setTypeface(Typeface.DEFAULT); mMonthNumAscentHeight = (int) (-mMonthNumPaint.ascent() + 0.5f); mMonthNumHeight = (int) (mMonthNumPaint.descent() - mMonthNumPaint.ascent() + 0.5f); mEventPaint = new TextPaint(); mEventPaint.setFakeBoldText(true); mEventPaint.setAntiAlias(true); mEventPaint.setTextSize(TEXT_SIZE_EVENT_TITLE); mEventPaint.setColor(mMonthEventColor); mSolidBackgroundEventPaint = new TextPaint(mEventPaint); mSolidBackgroundEventPaint.setColor(EVENT_TEXT_COLOR); mFramedEventPaint = new TextPaint(mSolidBackgroundEventPaint); mDeclinedEventPaint = new TextPaint(); mDeclinedEventPaint.setFakeBoldText(true); mDeclinedEventPaint.setAntiAlias(true); mDeclinedEventPaint.setTextSize(TEXT_SIZE_EVENT_TITLE); mDeclinedEventPaint.setColor(mMonthDeclinedEventColor); mEventAscentHeight = (int) (-mEventPaint.ascent() + 0.5f); mEventHeight = (int) (mEventPaint.descent() - mEventPaint.ascent() + 0.5f); mEventExtrasPaint = new TextPaint(); mEventExtrasPaint.setFakeBoldText(false); mEventExtrasPaint.setAntiAlias(true); mEventExtrasPaint.setStrokeWidth(EVENT_SQUARE_BORDER); mEventExtrasPaint.setTextSize(TEXT_SIZE_EVENT); mEventExtrasPaint.setColor(mMonthEventExtraColor); mEventExtrasPaint.setStyle(Style.FILL); mEventExtrasPaint.setTextAlign(Align.LEFT); mExtrasHeight = (int) (mEventExtrasPaint.descent() - mEventExtrasPaint.ascent() + 0.5f); mExtrasAscentHeight = (int) (-mEventExtrasPaint.ascent() + 0.5f); mExtrasDescent = (int) (mEventExtrasPaint.descent() + 0.5f); mEventDeclinedExtrasPaint = new TextPaint(); mEventDeclinedExtrasPaint.setFakeBoldText(false); mEventDeclinedExtrasPaint.setAntiAlias(true); mEventDeclinedExtrasPaint.setStrokeWidth(EVENT_SQUARE_BORDER); mEventDeclinedExtrasPaint.setTextSize(TEXT_SIZE_EVENT); mEventDeclinedExtrasPaint.setColor(mMonthDeclinedExtrasColor); mEventDeclinedExtrasPaint.setStyle(Style.FILL); mEventDeclinedExtrasPaint.setTextAlign(Align.LEFT); mWeekNumPaint = new Paint(); mWeekNumPaint.setFakeBoldText(false); mWeekNumPaint.setAntiAlias(true); mWeekNumPaint.setTextSize(TEXT_SIZE_WEEK_NUM); mWeekNumPaint.setColor(mWeekNumColor); mWeekNumPaint.setStyle(Style.FILL); mWeekNumPaint.setTextAlign(Align.RIGHT); mWeekNumAscentHeight = (int) (-mWeekNumPaint.ascent() + 0.5f); mDNAAllDayPaint = new Paint(); mDNATimePaint = new Paint(); mDNATimePaint.setColor(mMonthBusyBitsBusyTimeColor); mDNATimePaint.setStyle(Style.FILL_AND_STROKE); mDNATimePaint.setStrokeWidth(DNA_WIDTH); mDNATimePaint.setAntiAlias(false); mDNAAllDayPaint.setColor(mMonthBusyBitsConflictTimeColor); mDNAAllDayPaint.setStyle(Style.FILL_AND_STROKE); mDNAAllDayPaint.setStrokeWidth(DNA_ALL_DAY_WIDTH); mDNAAllDayPaint.setAntiAlias(false); mEventSquarePaint = new Paint(); mEventSquarePaint.setStrokeWidth(EVENT_SQUARE_BORDER); mEventSquarePaint.setAntiAlias(false); if (DEBUG_LAYOUT) { Log.d("EXTRA", "mScale=" + mScale); Log.d( "EXTRA", "mMonthNumPaint ascent=" + mMonthNumPaint.ascent() + " descent=" + mMonthNumPaint.descent() + " int height=" + mMonthNumHeight); Log.d( "EXTRA", "mEventPaint ascent=" + mEventPaint.ascent() + " descent=" + mEventPaint.descent() + " int height=" + mEventHeight + " int ascent=" + mEventAscentHeight); Log.d( "EXTRA", "mEventExtrasPaint ascent=" + mEventExtrasPaint.ascent() + " descent=" + mEventExtrasPaint.descent() + " int height=" + mExtrasHeight); Log.d( "EXTRA", "mWeekNumPaint ascent=" + mWeekNumPaint.ascent() + " descent=" + mWeekNumPaint.descent()); } }