mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
couple fixes related to event list widget
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
package com.simplemobiletools.calendar.adapters
|
package com.simplemobiletools.calendar.adapters
|
||||||
|
|
||||||
import android.appwidget.AppWidgetManager
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.view.View
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
import android.widget.RemoteViewsService
|
import android.widget.RemoteViewsService
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
@@ -23,15 +23,8 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV
|
|||||||
val ITEM_EVENT = 0
|
val ITEM_EVENT = 0
|
||||||
val ITEM_HEADER = 1
|
val ITEM_HEADER = 1
|
||||||
|
|
||||||
val appWidgetId: Int
|
var events: List<ListItem> = ArrayList()
|
||||||
var events: List<ListItem>
|
val textColor: Int = Config.newInstance(context).widgetTextColor
|
||||||
val textColor: Int
|
|
||||||
|
|
||||||
init {
|
|
||||||
textColor = Config.newInstance(context).widgetTextColor
|
|
||||||
appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID)
|
|
||||||
events = ArrayList<ListItem>()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getViewAt(position: Int): RemoteViews {
|
override fun getViewAt(position: Int): RemoteViews {
|
||||||
val type = getItemViewType(position)
|
val type = getItemViewType(position)
|
||||||
@@ -39,26 +32,37 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV
|
|||||||
|
|
||||||
if (type == ITEM_EVENT) {
|
if (type == ITEM_EVENT) {
|
||||||
val item = events[position] as ListEvent
|
val item = events[position] as ListEvent
|
||||||
remoteView = RemoteViews(context.packageName, R.layout.event_list_item_widget)
|
remoteView = RemoteViews(context.packageName, R.layout.event_list_item_widget).apply {
|
||||||
remoteView.apply {
|
|
||||||
setTextViewText(R.id.event_item_title, item.title)
|
setTextViewText(R.id.event_item_title, item.title)
|
||||||
setTextViewText(R.id.event_item_description, item.description)
|
setTextViewText(R.id.event_item_description, item.description)
|
||||||
setTextViewText(R.id.event_item_start, Formatter.getTimeFromTS(context, item.startTS))
|
setTextViewText(R.id.event_item_start, Formatter.getTimeFromTS(context, item.startTS))
|
||||||
setTextViewText(R.id.event_item_end, Formatter.getTimeFromTS(context, item.endTS))
|
|
||||||
|
if (item.startTS == item.endTS) {
|
||||||
|
setViewVisibility(R.id.event_item_end, View.INVISIBLE)
|
||||||
|
} else {
|
||||||
|
setViewVisibility(R.id.event_item_end, View.VISIBLE)
|
||||||
|
var endString = Formatter.getTimeFromTS(context, item.endTS)
|
||||||
|
val startCode = Formatter.getDayCodeFromTS(item.startTS)
|
||||||
|
val endCode = Formatter.getDayCodeFromTS(item.endTS)
|
||||||
|
if (startCode != endCode) {
|
||||||
|
endString += " (${Formatter.getDate(context, endCode)})"
|
||||||
|
}
|
||||||
|
setTextViewText(R.id.event_item_end, endString)
|
||||||
|
}
|
||||||
|
|
||||||
setInt(R.id.event_item_title, "setTextColor", textColor)
|
setInt(R.id.event_item_title, "setTextColor", textColor)
|
||||||
setInt(R.id.event_item_description, "setTextColor", textColor)
|
setInt(R.id.event_item_description, "setTextColor", textColor)
|
||||||
setInt(R.id.event_item_start, "setTextColor", textColor)
|
setInt(R.id.event_item_start, "setTextColor", textColor)
|
||||||
setInt(R.id.event_item_end, "setTextColor", textColor)
|
setInt(R.id.event_item_end, "setTextColor", textColor)
|
||||||
|
|
||||||
val intent = Intent()
|
Intent().apply {
|
||||||
intent.putExtra(EVENT_ID, item.id)
|
putExtra(EVENT_ID, item.id)
|
||||||
setOnClickFillInIntent(event_item_holder, intent)
|
setOnClickFillInIntent(event_item_holder, this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val item = events[position] as ListSection
|
val item = events[position] as ListSection
|
||||||
remoteView = RemoteViews(context.packageName, R.layout.event_list_section_widget)
|
remoteView = RemoteViews(context.packageName, R.layout.event_list_section_widget).apply {
|
||||||
remoteView.apply {
|
|
||||||
setTextViewText(R.id.event_item_title, item.title)
|
setTextViewText(R.id.event_item_title, item.title)
|
||||||
setInt(R.id.event_item_title, "setTextColor", textColor)
|
setInt(R.id.event_item_title, "setTextColor", textColor)
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<TextView
|
||||||
android:id="@+id/event_item_start"
|
android:id="@+id/event_item_start"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
android:text="13:00"
|
android:text="13:00"
|
||||||
android:textSize="@dimen/day_text_size"/>
|
android:textSize="@dimen/day_text_size"/>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<TextView
|
||||||
android:id="@+id/event_item_end"
|
android:id="@+id/event_item_end"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
android:text="15:00"
|
android:text="15:00"
|
||||||
android:textSize="@dimen/day_text_size"/>
|
android:textSize="@dimen/day_text_size"/>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<TextView
|
||||||
android:id="@+id/event_item_title"
|
android:id="@+id/event_item_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
android:text="Event title"
|
android:text="Event title"
|
||||||
android:textSize="@dimen/day_text_size"/>
|
android:textSize="@dimen/day_text_size"/>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<TextView
|
||||||
android:id="@+id/event_item_description"
|
android:id="@+id/event_item_description"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<TextView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/event_item_title"
|
android:id="@+id/event_item_title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Reference in New Issue
Block a user