move the week day letters in MonthView too
This commit is contained in:
parent
223d711f60
commit
503d941d65
4 changed files with 23 additions and 19 deletions
|
@ -203,10 +203,10 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
|
|||
}
|
||||
|
||||
private fun updateLabels() {
|
||||
for (i in 0..6) {
|
||||
/*for (i in 0..6) {
|
||||
findViewById<TextView>(mRes.getIdentifier("label_$i", "id", mPackageName)).apply {
|
||||
setTextColor(mTextColor)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.DatePicker
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.extensions.config
|
||||
import com.simplemobiletools.calendar.helpers.Config
|
||||
|
@ -152,7 +151,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
|
|||
}
|
||||
|
||||
private fun setupLabels() {
|
||||
val letters = context!!.resources.getStringArray(R.array.week_day_letters)
|
||||
/*val letters = context!!.resources.getStringArray(R.array.week_day_letters)
|
||||
for (i in 0..6) {
|
||||
var index = i
|
||||
if (mSundayFirst) {
|
||||
|
@ -163,7 +162,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
|
|||
setTextColor(mTextColor)
|
||||
text = letters[index]
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private fun updateDays(days: ArrayList<DayMonthly>) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.simplemobiletools.calendar.models.DayMonthly
|
|||
import com.simplemobiletools.commons.extensions.adjustAlpha
|
||||
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
||||
import com.simplemobiletools.commons.extensions.getContrastColor
|
||||
import com.simplemobiletools.commons.extensions.moveLastItemToFront
|
||||
|
||||
// used in the Monthly view fragment, 1 view per screen
|
||||
class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(context, attrs, defStyle) {
|
||||
|
@ -21,6 +22,8 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||
private var primaryColor = 0
|
||||
private var textColor = 0
|
||||
private var weakTextColor = 0
|
||||
private var weekDaysLetterHeight = 0
|
||||
private var dayLetters = ArrayList<String>()
|
||||
private var days = ArrayList<DayMonthly>()
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0)
|
||||
|
@ -30,11 +33,18 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||
textColor = context.config.textColor
|
||||
weakTextColor = textColor.adjustAlpha(LOW_ALPHA)
|
||||
|
||||
val normalTextSize = resources.getDimensionPixelSize(R.dimen.normal_text_size).toFloat()
|
||||
paint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||
color = textColor
|
||||
textSize = resources.getDimensionPixelSize(R.dimen.normal_text_size).toFloat()
|
||||
textSize = normalTextSize
|
||||
textAlign = Paint.Align.CENTER
|
||||
}
|
||||
|
||||
weekDaysLetterHeight = 2 * normalTextSize.toInt()
|
||||
dayLetters = context.resources.getStringArray(R.array.week_day_letters).toList() as ArrayList<String>
|
||||
if (context.config.isSundayFirst) {
|
||||
dayLetters.moveLastItemToFront()
|
||||
}
|
||||
}
|
||||
|
||||
fun updateDays(newDays: ArrayList<DayMonthly>) {
|
||||
|
@ -49,7 +59,12 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||
}
|
||||
|
||||
if (dayHeight == 0f) {
|
||||
dayHeight = (canvas.height / 6).toFloat()
|
||||
dayHeight = ((canvas.height - weekDaysLetterHeight) / 6).toFloat()
|
||||
}
|
||||
|
||||
for (i in 0..6) {
|
||||
val xPos = (i + 1) * dayWidth - dayWidth / 2
|
||||
canvas.drawText(dayLetters[i], xPos, weekDaysLetterHeight / 2f, paint)
|
||||
}
|
||||
|
||||
var curId = 0
|
||||
|
@ -58,7 +73,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||
val day = days.getOrNull(curId)
|
||||
if (day != null) {
|
||||
val xPos = x * dayWidth - dayWidth / 2
|
||||
val yPos = y * dayHeight
|
||||
val yPos = y * dayHeight + weekDaysLetterHeight
|
||||
if (day.isToday) {
|
||||
canvas.drawCircle(xPos, yPos + paint.textSize * 0.7f, paint.textSize * 0.75f, getCirclePaint(day))
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/month_calendar_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -9,19 +8,10 @@
|
|||
|
||||
<include layout="@layout/top_navigation"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/first_row"
|
||||
layout="@layout/first_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/top_value"
|
||||
tools:ignore="UnknownIdInLayout"/>
|
||||
|
||||
<com.simplemobiletools.calendar.views.MonthView
|
||||
android:id="@+id/month_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/first_row"
|
||||
android:layout_centerInParent="true"/>
|
||||
android:layout_below="@+id/top_left_arrow"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in a new issue