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.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
|
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
|
||||||
import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
|
import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
|
||||||
|
import com.simplemobiletools.commons.helpers.mydebug
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -26,11 +27,24 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
|||||||
private var events = ArrayList<ListItem>()
|
private var events = ArrayList<ListItem>()
|
||||||
private var textColor = context.config.widgetTextColor
|
private var textColor = context.config.widgetTextColor
|
||||||
private var weakTextColor = textColor.adjustAlpha(MEDIUM_ALPHA)
|
private var weakTextColor = textColor.adjustAlpha(MEDIUM_ALPHA)
|
||||||
private val displayDescription = context.config.displayDescription
|
private var displayDescription = context.config.displayDescription
|
||||||
private val replaceDescription = context.config.replaceDescription
|
private var replaceDescription = context.config.replaceDescription
|
||||||
private val dimPastEvents = context.config.dimPastEvents
|
private var dimPastEvents = context.config.dimPastEvents
|
||||||
private var mediumFontSize = context.getWidgetFontSize()
|
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 {
|
override fun getViewAt(position: Int): RemoteViews {
|
||||||
val type = getItemViewType(position)
|
val type = getItemViewType(position)
|
||||||
val remoteView: RemoteViews
|
val remoteView: RemoteViews
|
||||||
@@ -108,7 +122,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
|||||||
|
|
||||||
remoteView.apply {
|
remoteView.apply {
|
||||||
setTextColor(event_section_title, curTextColor)
|
setTextColor(event_section_title, curTextColor)
|
||||||
setTextSize(event_section_title, mediumFontSize)
|
setTextSize(event_section_title, mediumFontSize - 3f)
|
||||||
setText(event_section_title, item.title)
|
setText(event_section_title, item.title)
|
||||||
|
|
||||||
Intent().apply {
|
Intent().apply {
|
||||||
@@ -123,6 +137,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
|||||||
val curTextColor = textColor
|
val curTextColor = textColor
|
||||||
remoteView.apply {
|
remoteView.apply {
|
||||||
setTextColor(event_section_title, curTextColor)
|
setTextColor(event_section_title, curTextColor)
|
||||||
|
setTextSize(event_section_title, mediumFontSize)
|
||||||
setText(event_section_title, item.title)
|
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 getItemId(position: Int) = position.toLong()
|
||||||
|
|
||||||
override fun onDataSetChanged() {
|
override fun onDataSetChanged() {
|
||||||
textColor = context.config.widgetTextColor
|
initConfigValues()
|
||||||
weakTextColor = textColor.adjustAlpha(LOWER_ALPHA)
|
|
||||||
mediumFontSize = context.getWidgetFontSize()
|
|
||||||
val fromTS = DateTime().seconds() - context.config.displayPastEvents * 60
|
val fromTS = DateTime().seconds() - context.config.displayPastEvents * 60
|
||||||
val toTS = DateTime().plusYears(1).seconds()
|
val toTS = DateTime().plusYears(1).seconds()
|
||||||
context.eventsHelper.getEventsSync(fromTS, toTS, applyTypeFilter = true) {
|
context.eventsHelper.getEventsSync(fromTS, toTS, applyTypeFilter = true) {
|
||||||
|
@@ -5,12 +5,9 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/small_margin"
|
android:layout_marginStart="@dimen/small_margin"
|
||||||
android:layout_marginTop="@dimen/small_margin"
|
|
||||||
android:layout_marginEnd="@dimen/small_margin"
|
android:layout_marginEnd="@dimen/small_margin"
|
||||||
android:layout_marginBottom="@dimen/medium_margin"
|
android:paddingTop="@dimen/small_margin"
|
||||||
android:background="@drawable/section_holder_stroke"
|
android:paddingBottom="@dimen/small_margin">
|
||||||
android:paddingTop="@dimen/medium_margin"
|
|
||||||
android:paddingBottom="@dimen/medium_margin">
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/event_item_color_bar"
|
android:id="@+id/event_item_color_bar"
|
||||||
@@ -29,6 +26,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/normal_margin"
|
android:layout_marginStart="@dimen/normal_margin"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
android:includeFontPadding="false"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingEnd="@dimen/small_margin"
|
android:paddingEnd="@dimen/small_margin"
|
||||||
android:textSize="@dimen/day_text_size"
|
android:textSize="@dimen/day_text_size"
|
||||||
@@ -42,7 +40,7 @@
|
|||||||
android:layout_alignStart="@+id/event_item_title"
|
android:layout_alignStart="@+id/event_item_title"
|
||||||
android:alpha="0.8"
|
android:alpha="0.8"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:lineSpacingExtra="2dp"
|
android:includeFontPadding="false"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:paddingEnd="@dimen/small_margin"
|
android:paddingEnd="@dimen/small_margin"
|
||||||
android:textSize="@dimen/normal_text_size"
|
android:textSize="@dimen/normal_text_size"
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
android:id="@+id/event_section_title"
|
android:id="@+id/event_section_title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:includeFontPadding="false"
|
||||||
android:paddingStart="@dimen/bigger_margin"
|
android:paddingStart="@dimen/bigger_margin"
|
||||||
android:paddingBottom="@dimen/small_margin"
|
|
||||||
android:textSize="@dimen/normal_text_size"
|
android:textSize="@dimen/normal_text_size"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
@@ -3,8 +3,9 @@
|
|||||||
android:id="@+id/event_section_title"
|
android:id="@+id/event_section_title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:includeFontPadding="false"
|
||||||
android:paddingStart="@dimen/medium_margin"
|
android:paddingStart="@dimen/medium_margin"
|
||||||
android:paddingBottom="@dimen/small_margin"
|
android:paddingBottom="@dimen/small_margin"
|
||||||
android:textAllCaps="true"
|
android:textAllCaps="true"
|
||||||
android:textFontWeight="300"
|
android:textFontWeight="300"
|
||||||
android:textSize="20sp" />
|
android:textSize="16sp" />
|
||||||
|
Reference in New Issue
Block a user