mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
fix #1553, make the List View widget more compact
This commit is contained in:
@@ -14,6 +14,7 @@ import com.simplemobiletools.calendar.pro.models.*
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
|
||||
import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
|
||||
import com.simplemobiletools.commons.helpers.mydebug
|
||||
import org.joda.time.DateTime
|
||||
import java.util.*
|
||||
|
||||
@@ -26,11 +27,24 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
||||
private var events = ArrayList<ListItem>()
|
||||
private var textColor = context.config.widgetTextColor
|
||||
private var weakTextColor = textColor.adjustAlpha(MEDIUM_ALPHA)
|
||||
private val displayDescription = context.config.displayDescription
|
||||
private val replaceDescription = context.config.replaceDescription
|
||||
private val dimPastEvents = context.config.dimPastEvents
|
||||
private var displayDescription = context.config.displayDescription
|
||||
private var replaceDescription = context.config.replaceDescription
|
||||
private var dimPastEvents = context.config.dimPastEvents
|
||||
private var mediumFontSize = context.getWidgetFontSize()
|
||||
|
||||
init {
|
||||
initConfigValues()
|
||||
}
|
||||
|
||||
private fun initConfigValues() {
|
||||
textColor = context.config.widgetTextColor
|
||||
weakTextColor = textColor.adjustAlpha(MEDIUM_ALPHA)
|
||||
displayDescription = context.config.displayDescription
|
||||
replaceDescription = context.config.replaceDescription
|
||||
dimPastEvents = context.config.dimPastEvents
|
||||
mediumFontSize = context.getWidgetFontSize()
|
||||
}
|
||||
|
||||
override fun getViewAt(position: Int): RemoteViews {
|
||||
val type = getItemViewType(position)
|
||||
val remoteView: RemoteViews
|
||||
@@ -108,7 +122,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
||||
|
||||
remoteView.apply {
|
||||
setTextColor(event_section_title, curTextColor)
|
||||
setTextSize(event_section_title, mediumFontSize)
|
||||
setTextSize(event_section_title, mediumFontSize - 3f)
|
||||
setText(event_section_title, item.title)
|
||||
|
||||
Intent().apply {
|
||||
@@ -123,6 +137,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
||||
val curTextColor = textColor
|
||||
remoteView.apply {
|
||||
setTextColor(event_section_title, curTextColor)
|
||||
setTextSize(event_section_title, mediumFontSize)
|
||||
setText(event_section_title, item.title)
|
||||
}
|
||||
}
|
||||
@@ -142,9 +157,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
||||
override fun getItemId(position: Int) = position.toLong()
|
||||
|
||||
override fun onDataSetChanged() {
|
||||
textColor = context.config.widgetTextColor
|
||||
weakTextColor = textColor.adjustAlpha(LOWER_ALPHA)
|
||||
mediumFontSize = context.getWidgetFontSize()
|
||||
initConfigValues()
|
||||
val fromTS = DateTime().seconds() - context.config.displayPastEvents * 60
|
||||
val toTS = DateTime().plusYears(1).seconds()
|
||||
context.eventsHelper.getEventsSync(fromTS, toTS, applyTypeFilter = true) {
|
||||
|
@@ -5,12 +5,9 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/small_margin"
|
||||
android:layout_marginTop="@dimen/small_margin"
|
||||
android:layout_marginEnd="@dimen/small_margin"
|
||||
android:layout_marginBottom="@dimen/medium_margin"
|
||||
android:background="@drawable/section_holder_stroke"
|
||||
android:paddingTop="@dimen/medium_margin"
|
||||
android:paddingBottom="@dimen/medium_margin">
|
||||
android:paddingTop="@dimen/small_margin"
|
||||
android:paddingBottom="@dimen/small_margin">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/event_item_color_bar"
|
||||
@@ -29,6 +26,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/normal_margin"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:paddingEnd="@dimen/small_margin"
|
||||
android:textSize="@dimen/day_text_size"
|
||||
@@ -42,7 +40,7 @@
|
||||
android:layout_alignStart="@+id/event_item_title"
|
||||
android:alpha="0.8"
|
||||
android:ellipsize="end"
|
||||
android:lineSpacingExtra="2dp"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="2"
|
||||
android:paddingEnd="@dimen/small_margin"
|
||||
android:textSize="@dimen/normal_text_size"
|
||||
|
@@ -3,7 +3,7 @@
|
||||
android:id="@+id/event_section_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:paddingStart="@dimen/bigger_margin"
|
||||
android:paddingBottom="@dimen/small_margin"
|
||||
android:textSize="@dimen/normal_text_size"
|
||||
android:textStyle="bold" />
|
||||
|
@@ -3,8 +3,9 @@
|
||||
android:id="@+id/event_section_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:paddingBottom="@dimen/small_margin"
|
||||
android:textAllCaps="true"
|
||||
android:textFontWeight="300"
|
||||
android:textSize="20sp" />
|
||||
android:textSize="16sp" />
|
||||
|
Reference in New Issue
Block a user