Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b788f14 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

Merge branch '7012-t-fix-calendar-ui-regression' into 'v1-t'

fix: Improve Calendar's monthly view UI

See merge request !49
parents b3f64891 db1ecbb1
Loading
Loading
Loading
Loading
+32 −15
Original line number Diff line number Diff line
@@ -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;
+29 −21
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
@@ -26,59 +27,66 @@
        android:gravity="left"
        android:visibility="gone" />

    <TextView android:id="@+id/d0_label"
    <TextView
        android:id="@+id/d0_label"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="6dip"
        android:gravity="right"
        android:gravity="center_horizontal"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_DayLabel" />

    <TextView android:id="@+id/d1_label"
    <TextView
        android:id="@+id/d1_label"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="6dip"
        android:gravity="right"
        android:gravity="center_horizontal"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_DayLabel" />

    <TextView android:id="@+id/d2_label"
    <TextView
        android:id="@+id/d2_label"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="6dip"
        android:gravity="right"
        android:gravity="center_horizontal"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_DayLabel" />

    <TextView android:id="@+id/d3_label"
    <TextView
        android:id="@+id/d3_label"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="6dip"
        android:gravity="right"
        android:gravity="center_horizontal"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_DayLabel" />

    <TextView android:id="@+id/d4_label"
    <TextView
        android:id="@+id/d4_label"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="6dip"
        android:gravity="right"
        android:gravity="center_horizontal"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_DayLabel" />

    <TextView android:id="@+id/d5_label"
    <TextView
        android:id="@+id/d5_label"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="6dip"
        android:gravity="right"
        android:gravity="center_horizontal"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_DayLabel" />

    <TextView android:id="@+id/d6_label"
    <TextView
        android:id="@+id/d6_label"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="6dip"
        android:gravity="right"
        android:gravity="center_horizontal"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_DayLabel" />
</LinearLayout>
+34 −24
Original line number Diff line number Diff line
@@ -15,70 +15,80 @@
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="16dip"
    android:layout_height="wrap_content"
    android:paddingVertical="3dp"
    android:background="@color/date_strip_bg">

    <TextView android:id="@+id/wk_label"
    <TextView
        android:id="@+id/wk_label"
        android:layout_width="24dip"
        android:layout_height="wrap_content"
        android:gravity="right"
        android:gravity="center_horizontal"
        android:visibility="gone" />

    <TextView android:id="@+id/d0_label"
    <TextView
        android:id="@+id/d0_label"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="6dip"
        android:gravity="right"
        android:gravity="center_horizontal"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_DayLabel" />

    <TextView android:id="@+id/d1_label"
    <TextView
        android:id="@+id/d1_label"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="6dip"
        android:gravity="right"
        android:gravity="center_horizontal"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_DayLabel" />

    <TextView android:id="@+id/d2_label"
    <TextView
        android:id="@+id/d2_label"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="6dip"
        android:gravity="right"
        android:gravity="center_horizontal"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_DayLabel" />

    <TextView android:id="@+id/d3_label"
    <TextView
        android:id="@+id/d3_label"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="6dip"
        android:gravity="right"
        android:gravity="center_horizontal"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_DayLabel" />

    <TextView android:id="@+id/d4_label"
    <TextView
        android:id="@+id/d4_label"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="6dip"
        android:gravity="right"
        android:gravity="center_horizontal"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_DayLabel" />

    <TextView android:id="@+id/d5_label"
    <TextView
        android:id="@+id/d5_label"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="6dip"
        android:gravity="right"
        android:gravity="center_horizontal"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_DayLabel" />

    <TextView android:id="@+id/d6_label"
    <TextView
        android:id="@+id/d6_label"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="6dip"
        android:gravity="right"
        android:gravity="center_horizontal"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_DayLabel" />
</LinearLayout>
+8 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
@@ -32,6 +33,7 @@
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_MiniDayLabel" />

    <TextView android:id="@+id/d1_label"
@@ -39,6 +41,7 @@
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_MiniDayLabel" />

    <TextView android:id="@+id/d2_label"
@@ -46,6 +49,7 @@
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_MiniDayLabel" />

    <TextView android:id="@+id/d3_label"
@@ -53,6 +57,7 @@
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_MiniDayLabel" />

    <TextView android:id="@+id/d4_label"
@@ -60,6 +65,7 @@
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_MiniDayLabel" />

    <TextView android:id="@+id/d5_label"
@@ -67,6 +73,7 @@
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_MiniDayLabel" />

    <TextView android:id="@+id/d6_label"
@@ -74,5 +81,6 @@
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center"
        tools:text="@tools:sample/date/day_of_week"
        style="@style/TextAppearance.MonthView_MiniDayLabel" />
</LinearLayout>
+2 −1
Original line number Diff line number Diff line
@@ -15,7 +15,8 @@
-->
<resources>

    <dimen name="day_label_text_size">14sp</dimen>
    <dimen name="day_label_text_size">16sp</dimen>
    <dimen name="day_number_text_size">16sp</dimen>
    <dimen name="all_day_bottom_margin">10dip</dimen>
    <dimen name="one_day_header_height">0dip</dimen>
    <dimen name="day_header_bottom_margin">6dip</dimen>
Loading