fix #178, improve the tablet layout
This commit is contained in:
parent
2c422d716d
commit
6b1f871a43
|
@ -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++
|
||||
|
|
|
@ -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"
|
||||
|
@ -30,8 +31,8 @@
|
|||
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>
|
||||
|
||||
|
@ -57,8 +58,8 @@
|
|||
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
|
||||
|
@ -83,14 +85,15 @@
|
|||
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">
|
||||
|
||||
|
@ -108,8 +111,8 @@
|
|||
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"
|
||||
android:layout_marginLeft="@dimen/yearly_month_padding"
|
||||
android:layout_marginStart="@dimen/yearly_month_padding"
|
||||
app:days="30"/>
|
||||
</RelativeLayout>
|
||||
</TableRow>
|
||||
|
@ -138,8 +141,8 @@
|
|||
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
|
||||
|
@ -164,8 +168,8 @@
|
|||
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"
|
||||
android:layout_marginLeft="@dimen/yearly_month_padding"
|
||||
android:layout_marginStart="@dimen/yearly_month_padding"
|
||||
app:days="30"/>
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -173,6 +177,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">
|
||||
|
||||
|
@ -190,8 +195,8 @@
|
|||
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
|
||||
|
@ -216,8 +221,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
|
||||
|
@ -245,8 +251,8 @@
|
|||
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"
|
||||
android:layout_marginLeft="@dimen/yearly_month_padding"
|
||||
android:layout_marginStart="@dimen/yearly_month_padding"
|
||||
app:days="30"/>
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -254,6 +260,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">
|
||||
|
||||
|
@ -271,8 +278,8 @@
|
|||
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
|
||||
|
@ -297,8 +304,8 @@
|
|||
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"
|
||||
android:layout_marginLeft="@dimen/yearly_month_padding"
|
||||
android:layout_marginStart="@dimen/yearly_month_padding"
|
||||
app:days="30"/>
|
||||
</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
|
||||
|
@ -323,9 +331,9 @@
|
|||
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>
|
||||
|
|
|
@ -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">
|
||||
|
||||
|
@ -28,7 +30,8 @@
|
|||
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>
|
||||
|
||||
|
@ -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
|
||||
|
@ -78,6 +82,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
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">
|
||||
|
||||
|
@ -105,6 +111,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/month_4_label"
|
||||
app:days="30"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<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
|
||||
|
@ -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">
|
||||
|
||||
|
@ -204,6 +213,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
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
|
||||
|
@ -228,6 +239,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/month_9_label"
|
||||
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">
|
||||
|
||||
|
@ -254,6 +267,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/month_10_label"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
@ -278,6 +292,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/month_11_label"
|
||||
android:layout_marginLeft="@dimen/yearly_month_padding"
|
||||
android:layout_marginStart="@dimen/yearly_month_padding"
|
||||
app:days="30"/>
|
||||
</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
|
||||
|
@ -302,6 +319,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/month_12_label"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<resources>
|
||||
<dimen name="yearly_month_padding">40dp</dimen>
|
||||
</resources>
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue