diff --git a/app/src/main/java/com/android/calendar/month/MonthWeekEventsView.java b/app/src/main/java/com/android/calendar/month/MonthWeekEventsView.java index 42a9da93f04fbda328f88dad9a7ceab9612105b1..e7345585c2382ee34e282ba29fbe49d05a6edb0e 100644 --- a/app/src/main/java/com/android/calendar/month/MonthWeekEventsView.java +++ b/app/src/main/java/com/android/calendar/month/MonthWeekEventsView.java @@ -44,8 +44,6 @@ import android.view.MotionEvent; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; -import androidx.core.content.ContextCompat; - import com.android.calendar.DynamicTheme; import com.android.calendar.Event; import com.android.calendar.LunarUtils; @@ -626,12 +624,14 @@ public class MonthWeekEventsView extends SimpleWeekView { Time time = new Time(mTimeZone); time.setJulianDay(julianMonday); - int current_date_text_x=getResources().getDimensionPixelSize(R.dimen.current_date_text_x); - int current_date_text_y=getResources().getDimensionPixelSize(R.dimen.current_date_text_y); - int current_date_event_margin=getResources().getDimensionPixelSize(R.dimen.current_date_text_event_margin); + int todayTextY = getResources().getDimensionPixelSize(R.dimen.current_date_text_y); + int todayEventMargin = getResources().getDimensionPixelSize(R.dimen.current_date_text_event_margin); for (; i < numCount; i++) { x = computeDayLeftPosition(i - offset) - (mSidePaddingMonthNumber); + + final float monthNumberTextX = getMonthNumberTextX(x); + if (mHasToday && todayIndex == i) { mMonthNumPaint.setFakeBoldText(isBold = false); if (i + 1 < numCount) { @@ -640,28 +640,30 @@ public class MonthWeekEventsView extends SimpleWeekView { isFocusMonth = !mFocusDay[i + 1]; } mMonthNumPaint.setColor(getContext().getResources().getColor(R.color.colorAccent)); - int current_date_bg_size=getResources().getDimensionPixelSize(R.dimen.current_date_bg_size); + final int todayCircleRadius = getResources().getDimensionPixelSize(R.dimen.current_date_bg_size); //check text width & height to calculate circle cx and cy values Rect bounds = new Rect(); mMonthNumPaint.getTextBounds(mDayNumbers[i], 0, mDayNumbers[i].length(), bounds); - int text_height = bounds.height(); - int text_width = bounds.width(); + int textHeight = bounds.height(); + final int todayCircleCenterY = y + todayTextY - (textHeight / 2) - todayEventMargin; - canvas.drawCircle(x - current_date_text_x - (text_width / 2), - y + current_date_text_y - (text_height / 2) - current_date_event_margin, - current_date_bg_size, mMonthNumPaint); + canvas.drawCircle(monthNumberTextX, + todayCircleCenterY, + todayCircleRadius, mMonthNumPaint); mMonthNumPaint.setColor(mMonthNumTodayColor); } else if (mFocusDay[i] != isFocusMonth) { isFocusMonth = mFocusDay[i]; mMonthNumPaint.setColor(isFocusMonth ? mMonthNumColor : mMonthNumOtherColor); } - double relation = Math.sqrt(canvas.getWidth() * canvas.getHeight()); - mMonthNumPaint.setTextSize((int)relation / 12); - canvas.drawText(mDayNumbers[i], x-current_date_text_x, - y+current_date_text_y - current_date_event_margin, mMonthNumPaint); + mMonthNumPaint.setTextSize(getResources().getDimensionPixelSize(R.dimen.day_number_text_size)); + + mMonthNumPaint.setTextAlign(Align.CENTER); + + canvas.drawText(mDayNumbers[i], monthNumberTextX, + y + todayTextY - todayEventMargin, mMonthNumPaint); if (isBold) { mMonthNumPaint.setFakeBoldText(isBold = false); } @@ -724,6 +726,21 @@ public class MonthWeekEventsView extends SimpleWeekView { } } + private float getMonthNumberTextX(int x) { + final float monthNumberMarginEnd; + if (mShowWeekNum) { + monthNumberMarginEnd = getMonthNumberMarginEnd(); + } else { + monthNumberMarginEnd = 0; + } + + return x - (((float) mWidth / mNumDays) / 2f) + mSidePaddingMonthNumber + monthNumberMarginEnd; + } + + private float getMonthNumberMarginEnd() { + return getResources().getDimensionPixelSize(R.dimen.day_number_margin_end); + } + protected void drawEvents(Canvas canvas) { if (mEvents == null || mEvents.isEmpty()) { return; diff --git a/app/src/main/res/layout-sw600dp/full_month_header.xml b/app/src/main/res/layout-sw600dp/full_month_header.xml index fb6cee51ff8fc9b3127762d9ac229135c770fc68..31985a34e6202e2918a33c22f9f01e5fdcd4de88 100644 --- a/app/src/main/res/layout-sw600dp/full_month_header.xml +++ b/app/src/main/res/layout-sw600dp/full_month_header.xml @@ -15,6 +15,7 @@ --> - - - - - - - diff --git a/app/src/main/res/layout/full_month_header.xml b/app/src/main/res/layout/full_month_header.xml index 1c47db98530927c799611676a2817f047942ff8a..ceae216290362529c4b878f2f859ab5f3cb90f12 100644 --- a/app/src/main/res/layout/full_month_header.xml +++ b/app/src/main/res/layout/full_month_header.xml @@ -15,70 +15,80 @@ --> - - - - - - - - diff --git a/app/src/main/res/layout/mini_month_header.xml b/app/src/main/res/layout/mini_month_header.xml index 9c30995506c1b2b9f63183a7f8e8202d05d7b6df..2f9c74f9d127f364f047a0e86a0a692efe137ed8 100644 --- a/app/src/main/res/layout/mini_month_header.xml +++ b/app/src/main/res/layout/mini_month_header.xml @@ -15,6 +15,7 @@ --> diff --git a/app/src/main/res/values-w600dp-h879dp/dimens.xml b/app/src/main/res/values-w600dp-h879dp/dimens.xml index d84c8075f8ef56762171bceba83b11b1e18263eb..60d8985c84a7f6ea7077a89c6ed0c999fdcb5ee7 100644 --- a/app/src/main/res/values-w600dp-h879dp/dimens.xml +++ b/app/src/main/res/values-w600dp-h879dp/dimens.xml @@ -15,7 +15,8 @@ --> - 14sp + 16sp + 16sp 10dip 0dip 6dip diff --git a/app/src/main/res/values-w960dp-h527dp/dimens.xml b/app/src/main/res/values-w960dp-h527dp/dimens.xml index e2774773bdc768792645b70b8a027d69f959e34a..94f73f8d3624718a97d391cd9f4418f477d8769a 100644 --- a/app/src/main/res/values-w960dp-h527dp/dimens.xml +++ b/app/src/main/res/values-w960dp-h527dp/dimens.xml @@ -15,7 +15,8 @@ --> - 14sp + 16sp + 16sp 10dip 0dip 6dip diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 68e8f61953dee0ba56ea5291207ff876b4fc7cbf..7d8f93edbaadd9bd85f5aaf8c47f2028e158d4d6 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -14,7 +14,9 @@ limitations under the License. --> - 11sp + 16sp + 16sp + 8dp 8dip 0dip 4dip @@ -56,7 +58,7 @@ 300dp 16dp - 14dp + 15dp 15dp 12dp 5dp diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index e0469620ed677a8c4a46cd368b07daf0abf3246f..7ec02b0df61903cbe99049d1485377d176585430 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -78,8 +78,8 @@