fix #178, improve the tablet layout

This commit is contained in:
tibbi 2017-08-24 15:21:09 +02:00
parent 2c422d716d
commit 6b1f871a43
6 changed files with 106 additions and 76 deletions

View File

@ -21,6 +21,7 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
var mDays = 31
var mFirstDay = 0
var mTodaysId = 0
var mIsLandscape = false
var mEvents: ArrayList<Int>? = null
@ -68,14 +69,17 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
mColoredPaint = Paint(mPaint)
mColoredPaint.color = mColoredTextColor
mIsLandscape = resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
}
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
if (mDayWidth == 0f) {
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
mDayWidth = (canvas.width / 9.2).toFloat()
} else mDayWidth = (canvas.width / 8).toFloat()
mDayWidth = if (mIsLandscape) {
(canvas.width / 9).toFloat()
} else {
(canvas.width / 7).toFloat()
}
}
var curId = 1 - mFirstDay
@ -85,7 +89,8 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
canvas.drawText(curId.toString(), x * mDayWidth, y * mDayWidth, getPaint(curId))
if (curId == mTodaysId) {
canvas.drawCircle(x * mDayWidth - mDayWidth / 7, y * mDayWidth - mDayWidth / 6, mDayWidth * 0.41f, mColoredPaint)
val dividerConstant = if (mIsLandscape) 6 else 4
canvas.drawCircle(x * mDayWidth - mDayWidth / dividerConstant, y * mDayWidth - mDayWidth / dividerConstant, mDayWidth * 0.41f, mColoredPaint)
}
}
curId++

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/calendar_holder"
android:layout_width="match_parent"
@ -23,15 +24,15 @@
android:gravity="center_horizontal"
android:text="@string/january"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/month_1_label"
android:layout_marginLeft="@dimen/yearly_month_left_padding"
android:layout_marginStart="@dimen/yearly_month_left_padding" />
android:layout_marginLeft="@dimen/yearly_month_padding"
android:layout_marginStart="@dimen/yearly_month_padding"/>
</RelativeLayout>
@ -50,15 +51,15 @@
android:gravity="center_horizontal"
android:text="@string/february"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/month_2_label"
android:layout_marginLeft="@dimen/yearly_month_left_padding"
android:layout_marginStart="@dimen/yearly_month_left_padding" />
android:layout_marginLeft="@dimen/yearly_month_padding"
android:layout_marginStart="@dimen/yearly_month_padding"/>
</RelativeLayout>
@ -67,6 +68,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/yearly_padding_full"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<com.simplemobiletools.commons.views.MyTextView
@ -76,21 +78,22 @@
android:gravity="center_horizontal"
android:text="@string/march"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/month_3_label"
android:layout_marginLeft="@dimen/yearly_month_left_padding"
android:layout_marginStart="@dimen/yearly_month_left_padding" />
android:layout_marginLeft="@dimen/yearly_month_padding"
android:layout_marginStart="@dimen/yearly_month_padding"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_4_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_marginRight="@dimen/yearly_padding_full"
android:layout_weight="1">
@ -101,16 +104,16 @@
android:gravity="center_horizontal"
android:text="@string/april"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_4_label"
android:layout_marginLeft="@dimen/yearly_month_left_padding"
android:layout_marginStart="@dimen/yearly_month_left_padding"
app:days="30" />
android:layout_marginLeft="@dimen/yearly_month_padding"
android:layout_marginStart="@dimen/yearly_month_padding"
app:days="30"/>
</RelativeLayout>
</TableRow>
@ -131,15 +134,15 @@
android:gravity="center_horizontal"
android:text="@string/may"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_5_label"
android:layout_marginLeft="@dimen/yearly_month_left_padding"
android:layout_marginStart="@dimen/yearly_month_left_padding" />
android:layout_marginLeft="@dimen/yearly_month_padding"
android:layout_marginStart="@dimen/yearly_month_padding"/>
</RelativeLayout>
@ -148,6 +151,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/yearly_padding_full"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<com.simplemobiletools.commons.views.MyTextView
@ -157,22 +161,23 @@
android:gravity="center_horizontal"
android:text="@string/june"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_6_label"
android:layout_marginLeft="@dimen/yearly_month_left_padding"
android:layout_marginStart="@dimen/yearly_month_left_padding"
app:days="30" />
android:layout_marginLeft="@dimen/yearly_month_padding"
android:layout_marginStart="@dimen/yearly_month_padding"
app:days="30"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_7_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_marginRight="@dimen/yearly_padding_full"
android:layout_weight="1">
@ -183,15 +188,15 @@
android:gravity="center_horizontal"
android:text="@string/july"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_7_label"
android:layout_marginLeft="@dimen/yearly_month_left_padding"
android:layout_marginStart="@dimen/yearly_month_left_padding" />
android:layout_marginLeft="@dimen/yearly_month_padding"
android:layout_marginStart="@dimen/yearly_month_padding"/>
</RelativeLayout>
<RelativeLayout
@ -209,15 +214,15 @@
android:gravity="center_horizontal"
android:text="@string/august"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_8_label"
android:layout_marginLeft="@dimen/yearly_month_left_padding"
android:layout_marginStart="@dimen/yearly_month_left_padding" />
android:layout_marginLeft="@dimen/yearly_month_padding"
android:layout_marginStart="@dimen/yearly_month_padding"/>
</RelativeLayout>
</TableRow>
@ -229,6 +234,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/yearly_padding_full"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<com.simplemobiletools.commons.views.MyTextView
@ -238,22 +244,23 @@
android:gravity="center_horizontal"
android:text="@string/september"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_9"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_9_label"
android:layout_marginLeft="@dimen/yearly_month_left_padding"
android:layout_marginStart="@dimen/yearly_month_left_padding"
app:days="30" />
android:layout_marginLeft="@dimen/yearly_month_padding"
android:layout_marginStart="@dimen/yearly_month_padding"
app:days="30"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_10_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_marginRight="@dimen/yearly_padding_full"
android:layout_weight="1">
@ -264,15 +271,15 @@
android:gravity="center_horizontal"
android:text="@string/october"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_10_label"
android:layout_marginLeft="@dimen/yearly_month_left_padding"
android:layout_marginStart="@dimen/yearly_month_left_padding" />
android:layout_marginLeft="@dimen/yearly_month_padding"
android:layout_marginStart="@dimen/yearly_month_padding"/>
</RelativeLayout>
<RelativeLayout
@ -290,16 +297,16 @@
android:gravity="center_horizontal"
android:text="@string/november"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_11"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_11_label"
android:layout_marginLeft="@dimen/yearly_month_left_padding"
android:layout_marginStart="@dimen/yearly_month_left_padding"
app:days="30" />
android:layout_marginLeft="@dimen/yearly_month_padding"
android:layout_marginStart="@dimen/yearly_month_padding"
app:days="30"/>
</RelativeLayout>
<RelativeLayout
@ -307,6 +314,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/yearly_padding_full"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<com.simplemobiletools.commons.views.MyTextView
@ -316,16 +324,16 @@
android:gravity="center_horizontal"
android:text="@string/december"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_12"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_12_label"
android:layout_marginLeft="@dimen/yearly_month_left_padding"
android:layout_marginStart="@dimen/yearly_month_left_padding" />
android:layout_marginLeft="@dimen/yearly_month_padding"
android:layout_marginStart="@dimen/yearly_month_padding"/>
</RelativeLayout>
</TableRow>
</TableLayout>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/calendar_holder"
android:layout_width="match_parent"
@ -12,6 +13,7 @@
android:id="@+id/month_1_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_marginRight="@dimen/yearly_padding_full"
android:layout_weight="1">
@ -22,13 +24,14 @@
android:gravity="center_horizontal"
android:text="@string/january"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/month_1_label" />
android:layout_below="@+id/month_1_label"
android:layout_centerInParent="true"/>
</RelativeLayout>
@ -47,13 +50,13 @@
android:gravity="center_horizontal"
android:text="@string/february"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/month_2_label" />
android:layout_below="@+id/month_2_label"/>
</RelativeLayout>
@ -62,6 +65,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/yearly_padding_full"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<com.simplemobiletools.commons.views.MyTextView
@ -71,13 +75,14 @@
android:gravity="center_horizontal"
android:text="@string/march"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/month_3_label" />
android:layout_below="@+id/month_3_label"/>
</RelativeLayout>
</TableRow>
@ -87,6 +92,7 @@
android:id="@+id/month_4_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_marginRight="@dimen/yearly_padding_full"
android:layout_weight="1">
@ -97,14 +103,15 @@
android:gravity="center_horizontal"
android:text="@string/april"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_4_label"
app:days="30" />
app:days="30"/>
</RelativeLayout>
<RelativeLayout
@ -122,13 +129,13 @@
android:gravity="center_horizontal"
android:text="@string/may"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_5_label" />
android:layout_below="@+id/month_5_label"/>
</RelativeLayout>
@ -137,6 +144,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/yearly_padding_full"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<com.simplemobiletools.commons.views.MyTextView
@ -146,14 +154,14 @@
android:gravity="center_horizontal"
android:text="@string/june"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_6_label"
app:days="30" />
app:days="30"/>
</RelativeLayout>
</TableRow>
@ -163,6 +171,7 @@
android:id="@+id/month_7_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_marginRight="@dimen/yearly_padding_full"
android:layout_weight="1">
@ -173,13 +182,13 @@
android:gravity="center_horizontal"
android:text="@string/july"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_7_label" />
android:layout_below="@+id/month_7_label"/>
</RelativeLayout>
<RelativeLayout
@ -197,13 +206,14 @@
android:gravity="center_horizontal"
android:text="@string/august"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_8_label" />
android:layout_below="@+id/month_8_label"/>
</RelativeLayout>
<RelativeLayout
@ -211,6 +221,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/yearly_padding_full"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<com.simplemobiletools.commons.views.MyTextView
@ -220,14 +231,15 @@
android:gravity="center_horizontal"
android:text="@string/september"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_9"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_9_label"
app:days="30" />
app:days="30"/>
</RelativeLayout>
</TableRow>
@ -237,6 +249,7 @@
android:id="@+id/month_10_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_marginRight="@dimen/yearly_padding_full"
android:layout_weight="1">
@ -247,13 +260,14 @@
android:gravity="center_horizontal"
android:text="@string/october"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_10_label" />
android:layout_below="@+id/month_10_label"/>
</RelativeLayout>
<RelativeLayout
@ -271,14 +285,16 @@
android:gravity="center_horizontal"
android:text="@string/november"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_11"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_11_label"
app:days="30" />
android:layout_marginLeft="@dimen/yearly_month_padding"
android:layout_marginStart="@dimen/yearly_month_padding"
app:days="30"/>
</RelativeLayout>
<RelativeLayout
@ -286,6 +302,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/yearly_padding_full"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<com.simplemobiletools.commons.views.MyTextView
@ -295,13 +312,14 @@
android:gravity="center_horizontal"
android:text="@string/december"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.calendar.views.SmallMonthView
android:id="@+id/month_12"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_12_label" />
android:layout_below="@+id/month_12_label"/>
</RelativeLayout>
</TableRow>
</TableLayout>

View File

@ -0,0 +1,3 @@
<resources>
<dimen name="yearly_month_padding">40dp</dimen>
</resources>

View File

@ -9,9 +9,6 @@
<dimen name="weekly_view_events_height">2160dp</dimen> <!-- weekly_view_row_height * 24 hours -->
<dimen name="weekly_view_minimal_event_height">15dp</dimen>
<dimen name="yearly_month_left_padding">40dp</dimen>
<dimen name="yearly_month_right_padding">40dp</dimen>
<dimen name="meta_text_size">20sp</dimen>
<dimen name="day_text_size">22sp</dimen>
<dimen name="month_text_size">26sp</dimen>

View File

@ -15,8 +15,7 @@
<dimen name="repeat_type_margin_start">40dp</dimen>
<dimen name="yearly_month_left_padding">40dp</dimen>
<dimen name="yearly_month_right_padding">40dp</dimen>
<dimen name="yearly_month_padding">0dp</dimen>
<dimen name="meta_text_size">14sp</dimen>
<dimen name="day_text_size">17sp</dimen>