adding a couple monthly widget improvements
This commit is contained in:
parent
659af8ae83
commit
0adbc34dcc
4 changed files with 30 additions and 15 deletions
|
@ -268,7 +268,7 @@ fun Context.addDayNumber(rawTextColor: Int, day: DayMonthly, linearLayout: Linea
|
|||
if (!day.isThisMonth)
|
||||
textColor = textColor.adjustAlpha(LOW_ALPHA)
|
||||
|
||||
(View.inflate(this, R.layout.day_monthly_item_view, null) as TextView).apply {
|
||||
(View.inflate(this, R.layout.day_monthly_number_view, null) as TextView).apply {
|
||||
setTextColor(textColor)
|
||||
text = day.value.toString()
|
||||
gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
|
||||
|
@ -310,7 +310,7 @@ fun Context.addDayEvents(day: DayMonthly, linearLayout: LinearLayout, res: Resou
|
|||
textColor = textColor.adjustAlpha(0.25f)
|
||||
}
|
||||
|
||||
(View.inflate(this, R.layout.day_monthly_item_view, null) as TextView).apply {
|
||||
(View.inflate(this, R.layout.day_monthly_event_view, null) as TextView).apply {
|
||||
setTextColor(textColor)
|
||||
text = it.title.replace(" ", "\u00A0") // allow word break by char
|
||||
background = backgroundDrawable
|
||||
|
|
|
@ -29,7 +29,6 @@ class MyWidgetMonthlyProvider : AppWidgetProvider(), MonthlyCalendar {
|
|||
|
||||
private var mTextColor = 0
|
||||
private var mCalendar: MonthlyCalendarImpl? = null
|
||||
private var mRemoteViews: RemoteViews? = null
|
||||
|
||||
private var mSmallerFontSize = 0f
|
||||
private var mMediumFontSize = 0f
|
||||
|
@ -42,6 +41,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider(), MonthlyCalendar {
|
|||
|
||||
companion object {
|
||||
private var mTargetDate = DateTime()
|
||||
private var mRemoteViews: RemoteViews? = null
|
||||
}
|
||||
|
||||
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
||||
|
@ -112,7 +112,6 @@ class MyWidgetMonthlyProvider : AppWidgetProvider(), MonthlyCalendar {
|
|||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (mCalendar == null || mRemoteViews == null) {
|
||||
initVariables(context)
|
||||
return
|
||||
}
|
||||
|
||||
val action = intent.action
|
||||
|
@ -178,10 +177,10 @@ class MyWidgetMonthlyProvider : AppWidgetProvider(), MonthlyCalendar {
|
|||
backgroundColor = backgroundColor.adjustAlpha(0.25f)
|
||||
}
|
||||
|
||||
val newRemoteView = RemoteViews(packageName, R.layout.day_monthly_item_view).apply {
|
||||
setTextViewText(R.id.day_monthly_id, it.title.replace(" ", "\u00A0"))
|
||||
setTextColor(R.id.day_monthly_id, eventTextColor)
|
||||
setBackgroundColor(R.id.day_monthly_id, backgroundColor)
|
||||
val newRemoteView = RemoteViews(packageName, R.layout.day_monthly_event_view).apply {
|
||||
setTextViewText(R.id.day_monthly_event_id, it.title.replace(" ", "\u00A0"))
|
||||
setTextColor(R.id.day_monthly_event_id, eventTextColor)
|
||||
setBackgroundColor(R.id.day_monthly_event_id, backgroundColor)
|
||||
}
|
||||
mRemoteViews!!.addView(id, newRemoteView)
|
||||
}
|
||||
|
@ -189,13 +188,13 @@ class MyWidgetMonthlyProvider : AppWidgetProvider(), MonthlyCalendar {
|
|||
}
|
||||
|
||||
private fun addDayNumber(day: DayMonthly, packageName: String, textColor: Int, id: Int, primaryColor: Int) {
|
||||
val newRemoteView = RemoteViews(packageName, R.layout.day_monthly_item_view).apply {
|
||||
setTextViewText(R.id.day_monthly_id, day.value.toString())
|
||||
setTextColor(R.id.day_monthly_id, textColor)
|
||||
val newRemoteView = RemoteViews(packageName, R.layout.day_monthly_number_view).apply {
|
||||
setTextViewText(R.id.day_monthly_number_id, day.value.toString())
|
||||
setTextColor(R.id.day_monthly_number_id, textColor)
|
||||
|
||||
if (day.isToday) {
|
||||
setViewPadding(R.id.day_monthly_id, 10, 0, 10, 0)
|
||||
setBackgroundColor(R.id.day_monthly_id, primaryColor)
|
||||
setViewPadding(R.id.day_monthly_number_id, 10, 0, 10, 0)
|
||||
setBackgroundColor(R.id.day_monthly_number_id, primaryColor)
|
||||
}
|
||||
}
|
||||
mRemoteViews!!.addView(id, newRemoteView)
|
||||
|
|
16
app/src/main/res/layout/day_monthly_event_view.xml
Normal file
16
app/src/main/res/layout/day_monthly_event_view.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/day_monthly_event_id"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/tiny_margin"
|
||||
android:layout_marginRight="@dimen/tiny_margin"
|
||||
android:ellipsize="none"
|
||||
android:gravity="start"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/tiny_margin"
|
||||
android:paddingRight="@dimen/tiny_margin"
|
||||
android:textSize="@dimen/day_monthly_text_size"
|
||||
tools:text="1"/>
|
|
@ -2,13 +2,13 @@
|
|||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/day_monthly_id"
|
||||
android:id="@+id/day_monthly_number_id"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/tiny_margin"
|
||||
android:layout_marginRight="@dimen/tiny_margin"
|
||||
android:ellipsize="none"
|
||||
android:gravity="start"
|
||||
android:gravity="center_horizontal"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/tiny_margin"
|
||||
android:paddingRight="@dimen/tiny_margin"
|
Loading…
Reference in a new issue