fix #285, rework the event list widgets top
This commit is contained in:
parent
9614997324
commit
136e5e2fcf
|
@ -31,7 +31,6 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
|||
private val textColor = context.config.widgetTextColor
|
||||
private val replaceDescription = context.config.replaceDescription
|
||||
private var mediumFontSize = context.config.getFontSize()
|
||||
private var todayDate = ""
|
||||
|
||||
override fun getViewAt(position: Int): RemoteViews? {
|
||||
val type = getItemViewType(position)
|
||||
|
@ -99,11 +98,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
|||
|
||||
override fun getViewTypeCount() = 2
|
||||
|
||||
override fun onCreate() {
|
||||
val now = (System.currentTimeMillis() / 1000).toInt()
|
||||
val todayCode = Formatter.getDayCodeFromTS(now)
|
||||
todayDate = Formatter.getDayTitle(context, todayCode)
|
||||
}
|
||||
override fun onCreate() {}
|
||||
|
||||
override fun getItemId(position: Int) = position.toLong()
|
||||
|
||||
|
@ -121,7 +116,6 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
|||
val code = Formatter.getDayCodeFromTS(it.startTS)
|
||||
if (code != prevCode) {
|
||||
val day = Formatter.getDayTitle(context, code)
|
||||
if (day != todayDate)
|
||||
listItems.add(ListSection(day))
|
||||
prevCode = code
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ object Formatter {
|
|||
val TIME_PATTERN = "HHmmss"
|
||||
private val DAY_PATTERN = "d"
|
||||
private val DAY_OF_WEEK_PATTERN = "EEE"
|
||||
private val LONGEST_PATTERN = "MMMM dd YYYY (EEEE)"
|
||||
private val PATTERN_TIME_12 = "hh:mm a"
|
||||
private val PATTERN_TIME_24 = "HH:mm"
|
||||
|
||||
|
@ -44,6 +45,8 @@ object Formatter {
|
|||
date
|
||||
}
|
||||
|
||||
fun getLongestDate(ts: Int) = getDateTimeFromTS(ts).toString(LONGEST_PATTERN)
|
||||
|
||||
fun getDate(context: Context, dateTime: DateTime, addDayOfWeek: Boolean = true) = getDayTitle(context, getDayCodeFromDateTime(dateTime), addDayOfWeek)
|
||||
|
||||
fun getFullDate(context: Context, dateTime: DateTime): String {
|
||||
|
|
|
@ -40,12 +40,11 @@ class MyWidgetListProvider : AppWidgetProvider() {
|
|||
setTextSize(R.id.widget_event_list_empty, fontSize)
|
||||
|
||||
setTextColor(R.id.widget_event_list_today, textColor)
|
||||
setTextSize(R.id.widget_event_list_today, fontSize + 3)
|
||||
setTextSize(R.id.widget_event_list_today, fontSize)
|
||||
}
|
||||
|
||||
val now = (System.currentTimeMillis() / 1000).toInt()
|
||||
val todayCode = Formatter.getDayCodeFromTS(now)
|
||||
val todayText = Formatter.getDayTitle(context, todayCode)
|
||||
val todayText = Formatter.getLongestDate(now)
|
||||
views.setText(R.id.widget_event_list_today, todayText)
|
||||
|
||||
views.setImageViewBitmap(R.id.widget_event_new_event, context.resources.getColoredBitmap(R.drawable.ic_plus, textColor))
|
||||
|
|
|
@ -7,22 +7,29 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/widget_event_list_today"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/activity_margin"
|
||||
android:textSize="@dimen/actionbar_text_size"/>
|
||||
android:layout_alignBottom="@+id/widget_event_new_event"
|
||||
android:layout_alignTop="@+id/widget_event_new_event"
|
||||
android:layout_toLeftOf="@+id/widget_event_new_event"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:textSize="@dimen/normal_text_size"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/widget_event_new_event"
|
||||
style="@style/ArrowStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/widget_event_list"
|
||||
android:layout_alignBottom="@+id/widget_event_list_today"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@+id/widget_event_list_today"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:layout_alignParentTop="true"
|
||||
android:paddingBottom="@dimen/medium_margin"
|
||||
android:paddingLeft="@dimen/normal_margin"
|
||||
android:paddingRight="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/normal_margin"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_plus"/>
|
||||
|
||||
|
@ -30,11 +37,11 @@
|
|||
android:id="@+id/widget_event_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/widget_event_list_today"
|
||||
android:layout_below="@+id/widget_event_new_event"
|
||||
android:clipToPadding="false"
|
||||
android:divider="@null"
|
||||
android:dividerHeight="@dimen/medium_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/medium_margin"
|
||||
android:paddingLeft="@dimen/activity_margin"/>
|
||||
|
||||
<TextView
|
||||
|
|
Loading…
Reference in New Issue