use a more compact widget list layout if there is no end time and description
This commit is contained in:
parent
785a2e0ae5
commit
ed0d974e00
|
@ -40,8 +40,11 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
||||||
val remoteView: RemoteViews
|
val remoteView: RemoteViews
|
||||||
|
|
||||||
if (type == ITEM_EVENT) {
|
if (type == ITEM_EVENT) {
|
||||||
remoteView = RemoteViews(context.packageName, R.layout.event_list_item_widget)
|
val event = events[position] as ListEvent
|
||||||
setupListEvent(remoteView, events[position] as ListEvent)
|
val detailField = if (replaceDescription) event.location else event.description
|
||||||
|
val layout = if (event.startTS == event.endTS && detailField.isEmpty()) R.layout.event_list_item_widget_simple else R.layout.event_list_item_widget
|
||||||
|
remoteView = RemoteViews(context.packageName, layout)
|
||||||
|
setupListEvent(remoteView, event)
|
||||||
} else {
|
} else {
|
||||||
remoteView = RemoteViews(context.packageName, R.layout.event_list_section_widget)
|
remoteView = RemoteViews(context.packageName, R.layout.event_list_section_widget)
|
||||||
setupListSection(remoteView, events[position] as ListSection)
|
setupListSection(remoteView, events[position] as ListSection)
|
||||||
|
@ -122,7 +125,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
||||||
|
|
||||||
override fun getLoadingView() = null
|
override fun getLoadingView() = null
|
||||||
|
|
||||||
override fun getViewTypeCount() = 2
|
override fun getViewTypeCount() = 3
|
||||||
|
|
||||||
override fun onCreate() {}
|
override fun onCreate() {}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/event_item_holder"
|
android:id="@+id/event_item_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/medium_margin">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/event_item_start"
|
android:id="@+id/event_item_start"
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/event_item_start"
|
android:layout_below="@+id/event_item_start"
|
||||||
android:layout_marginLeft="@dimen/medium_margin"
|
android:layout_marginLeft="@dimen/medium_margin"
|
||||||
|
android:includeFontPadding="false"
|
||||||
android:text="15:00"
|
android:text="15:00"
|
||||||
android:textSize="@dimen/day_text_size"/>
|
android:textSize="@dimen/day_text_size"/>
|
||||||
|
|
||||||
|
@ -45,6 +47,7 @@
|
||||||
android:layout_toLeftOf="@+id/event_item_color"
|
android:layout_toLeftOf="@+id/event_item_color"
|
||||||
android:layout_toRightOf="@+id/event_item_end"
|
android:layout_toRightOf="@+id/event_item_end"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
android:includeFontPadding="false"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingRight="@dimen/small_margin"
|
android:paddingRight="@dimen/small_margin"
|
||||||
android:textSize="@dimen/day_text_size"
|
android:textSize="@dimen/day_text_size"
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?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/event_item_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/medium_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/event_item_start"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/medium_margin"
|
||||||
|
android:textSize="@dimen/day_text_size"
|
||||||
|
tools:text="13:00"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/event_section_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/normal_margin"
|
||||||
|
android:layout_toLeftOf="@+id/event_item_color"
|
||||||
|
android:layout_toRightOf="@+id/event_item_start"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingRight="@dimen/small_margin"
|
||||||
|
android:textSize="@dimen/day_text_size"
|
||||||
|
tools:text="Event title"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/event_item_color"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_alignBottom="@+id/event_section_title"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignTop="@+id/event_section_title"
|
||||||
|
android:paddingRight="@dimen/medium_margin"
|
||||||
|
android:src="@drawable/monthly_event_dot"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
|
@ -6,6 +6,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:drawablePadding="1dp"
|
android:drawablePadding="1dp"
|
||||||
android:drawableTop="@drawable/divider_width"
|
android:drawableTop="@drawable/divider_width"
|
||||||
|
android:paddingBottom="@dimen/small_margin"
|
||||||
android:paddingTop="@dimen/small_margin"
|
android:paddingTop="@dimen/small_margin"
|
||||||
android:textSize="@dimen/normal_text_size"
|
android:textSize="@dimen/normal_text_size"
|
||||||
android:textStyle="bold"/>
|
android:textStyle="bold"/>
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
android:layout_below="@+id/widget_event_new_event"
|
android:layout_below="@+id/widget_event_new_event"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:divider="@null"
|
android:divider="@null"
|
||||||
android:dividerHeight="@dimen/small_margin"
|
|
||||||
android:paddingBottom="@dimen/small_margin"
|
android:paddingBottom="@dimen/small_margin"
|
||||||
android:paddingLeft="@dimen/medium_margin"/>
|
android:paddingLeft="@dimen/medium_margin"/>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue