create standalone list items for widget

This commit is contained in:
tibbi 2016-11-29 21:14:07 +01:00
parent d33b5e8f2d
commit f96c7a875c
5 changed files with 114 additions and 41 deletions

View File

@ -40,7 +40,7 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV
val remoteView: RemoteViews
if (type == ITEM_EVENT) {
val item = events[position] as ListEvent
remoteView = RemoteViews(context.packageName, R.layout.event_list_item)
remoteView = RemoteViews(context.packageName, R.layout.event_list_item_widget)
remoteView.apply {
setTextViewText(R.id.event_item_title, item.title)
setTextViewText(R.id.event_item_description, item.description)
@ -54,7 +54,7 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV
}
} else {
val item = events[position] as ListSection
remoteView = RemoteViews(context.packageName, R.layout.event_list_section)
remoteView = RemoteViews(context.packageName, R.layout.event_list_section_widget)
remoteView.apply {
setTextViewText(R.id.event_item_title, item.title)
setInt(R.id.event_item_title, "setTextColor", textColor)

View File

@ -1,48 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/event_item_holder"
android:id="@+id/event_item_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/event_item_background">
android:background="?attr/selectableItemBackground"
android:foreground="@drawable/selector">
<TextView
android:id="@+id/event_item_start"
android:layout_width="wrap_content"
<RelativeLayout
android:id="@+id/event_item_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin"
android:text="13:00"
android:textSize="@dimen/day_text_size"/>
android:background="@drawable/event_item_background"
android:paddingBottom="@dimen/event_padding"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/small_padding">
<TextView
android:id="@+id/event_item_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/event_item_start"
android:layout_marginLeft="@dimen/activity_margin"
android:text="15:00"
android:textSize="@dimen/day_text_size"/>
<TextView
android:id="@+id/event_item_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="13:00"
android:textSize="@dimen/day_text_size"/>
<TextView
android:id="@+id/event_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin"
android:layout_toRightOf="@+id/event_item_start"
android:maxLines="1"
android:text="Event title"
android:textSize="@dimen/day_text_size"/>
<TextView
android:id="@+id/event_item_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/event_item_start"
android:text="15:00"
android:textSize="@dimen/day_text_size"/>
<TextView
android:id="@+id/event_item_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/event_item_title"
android:layout_marginLeft="@dimen/activity_margin"
android:layout_toRightOf="@+id/event_item_end"
android:alpha=".4"
android:maxLines="1"
android:text="Event description"
android:textSize="@dimen/day_text_size"/>
<TextView
android:id="@+id/event_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin"
android:layout_toRightOf="@+id/event_item_start"
android:maxLines="1"
android:text="Event title"
android:textSize="@dimen/day_text_size"/>
</RelativeLayout>
<TextView
android:id="@+id/event_item_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/event_item_title"
android:layout_marginLeft="@dimen/activity_margin"
android:layout_toRightOf="@+id/event_item_end"
android:alpha=".4"
android:maxLines="1"
android:text="Event description"
android:textSize="@dimen/day_text_size"/>
</RelativeLayout>
</FrameLayout>

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/event_item_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/event_item_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin"
android:text="13:00"
android:textSize="@dimen/day_text_size"/>
<TextView
android:id="@+id/event_item_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/event_item_start"
android:layout_marginLeft="@dimen/activity_margin"
android:text="15:00"
android:textSize="@dimen/day_text_size"/>
<TextView
android:id="@+id/event_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin"
android:layout_toRightOf="@+id/event_item_start"
android:maxLines="1"
android:paddingRight="@dimen/activity_margin"
android:text="Event title"
android:textSize="@dimen/day_text_size"/>
<TextView
android:id="@+id/event_item_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/event_item_title"
android:layout_marginLeft="@dimen/activity_margin"
android:layout_toRightOf="@+id/event_item_end"
android:alpha=".4"
android:maxLines="1"
android:paddingRight="@dimen/activity_margin"
android:text="Event description"
android:textSize="@dimen/day_text_size"/>
</RelativeLayout>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/event_item_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="1dp"
android:drawableTop="@drawable/divider"
android:paddingTop="@dimen/small_padding"
android:textSize="@dimen/normal_text_size"
android:textStyle="bold"/>

View File

@ -4,6 +4,9 @@
android:id="@+id/widget_event_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:divider="@null"
android:dividerHeight="@dimen/medium_padding"
android:paddingBottom="@dimen/activity_margin"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"/>
android:paddingTop="@dimen/medium_padding"/>