updating commons to 5.22.5

This commit is contained in:
tibbi 2020-02-06 20:41:36 +01:00
parent 6030857fea
commit 53c88f1ab2
8 changed files with 22 additions and 35 deletions

View File

@ -64,7 +64,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.simplemobiletools:commons:5.21.9' implementation 'com.simplemobiletools:commons:5.22.5'
implementation 'joda-time:joda-time:2.10.1' implementation 'joda-time:joda-time:2.10.1'
implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'

View File

@ -515,12 +515,6 @@ class SettingsActivity : SimpleActivity() {
} }
} }
private fun getFontSizeText() = getString(when (config.fontSize) {
FONT_SIZE_SMALL -> R.string.small
FONT_SIZE_MEDIUM -> R.string.medium
else -> R.string.large
})
private fun setupCustomizeWidgetColors() { private fun setupCustomizeWidgetColors() {
settings_customize_widget_colors_holder.setOnClickListener { settings_customize_widget_colors_holder.setOnClickListener {
Intent(this, WidgetListConfigureActivity::class.java).apply { Intent(this, WidgetListConfigureActivity::class.java).apply {

View File

@ -10,6 +10,7 @@ import com.simplemobiletools.calendar.pro.R.id.event_item_holder
import com.simplemobiletools.calendar.pro.R.id.event_section_title import com.simplemobiletools.calendar.pro.R.id.event_section_title
import com.simplemobiletools.calendar.pro.extensions.config import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.eventsHelper import com.simplemobiletools.calendar.pro.extensions.eventsHelper
import com.simplemobiletools.calendar.pro.extensions.getWidgetFontSize
import com.simplemobiletools.calendar.pro.extensions.seconds import com.simplemobiletools.calendar.pro.extensions.seconds
import com.simplemobiletools.calendar.pro.helpers.* import com.simplemobiletools.calendar.pro.helpers.*
import com.simplemobiletools.calendar.pro.helpers.Formatter import com.simplemobiletools.calendar.pro.helpers.Formatter
@ -34,7 +35,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
private var weakTextColor = textColor.adjustAlpha(LOW_ALPHA) private var weakTextColor = textColor.adjustAlpha(LOW_ALPHA)
private val replaceDescription = context.config.replaceDescription private val replaceDescription = context.config.replaceDescription
private val dimPastEvents = context.config.dimPastEvents private val dimPastEvents = context.config.dimPastEvents
private var mediumFontSize = context.config.getFontSize() private var mediumFontSize = context.getWidgetFontSize()
override fun getViewAt(position: Int): RemoteViews? { override fun getViewAt(position: Int): RemoteViews? {
val type = getItemViewType(position) val type = getItemViewType(position)
@ -154,7 +155,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
override fun onDataSetChanged() { override fun onDataSetChanged() {
textColor = context.config.widgetTextColor textColor = context.config.widgetTextColor
weakTextColor = textColor.adjustAlpha(LOW_ALPHA) weakTextColor = textColor.adjustAlpha(LOW_ALPHA)
mediumFontSize = context.config.getFontSize() 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) {

View File

@ -512,3 +512,14 @@ fun Context.refreshCalDAVCalendars(ids: String, showToasts: Boolean) {
} }
} }
} }
fun Context.getWidgetFontSize() = when (config.fontSize) {
FONT_SIZE_SMALL -> getWidgetSmallFontSize()
FONT_SIZE_MEDIUM -> getWidgetMediumFontSize()
else -> getWidgetLargeFontSize()
}
fun Context.getWidgetSmallFontSize() = getWidgetMediumFontSize() - 3f
fun Context.getWidgetMediumFontSize() = resources.getDimension(R.dimen.day_text_size) / resources.displayMetrics.density
fun Context.getWidgetLargeFontSize() = getWidgetMediumFontSize() + 3f

View File

@ -2,7 +2,6 @@ package com.simplemobiletools.calendar.pro.helpers
import android.content.Context import android.content.Context
import android.media.AudioManager import android.media.AudioManager
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.extensions.config import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.scheduleCalDAVSync import com.simplemobiletools.calendar.pro.extensions.scheduleCalDAVSync
import com.simplemobiletools.commons.extensions.getDefaultAlarmTitle import com.simplemobiletools.commons.extensions.getDefaultAlarmTitle
@ -73,10 +72,6 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getStringSet(DISPLAY_EVENT_TYPES, HashSet<String>()) get() = prefs.getStringSet(DISPLAY_EVENT_TYPES, HashSet<String>())
set(displayEventTypes) = prefs.edit().remove(DISPLAY_EVENT_TYPES).putStringSet(DISPLAY_EVENT_TYPES, displayEventTypes).apply() set(displayEventTypes) = prefs.edit().remove(DISPLAY_EVENT_TYPES).putStringSet(DISPLAY_EVENT_TYPES, displayEventTypes).apply()
var fontSize: Int
get() = prefs.getInt(FONT_SIZE, FONT_SIZE_MEDIUM)
set(size) = prefs.edit().putInt(FONT_SIZE, size).apply()
var listWidgetViewToOpen: Int var listWidgetViewToOpen: Int
get() = prefs.getInt(LIST_WIDGET_VIEW_TO_OPEN, DAILY_VIEW) get() = prefs.getInt(LIST_WIDGET_VIEW_TO_OPEN, DAILY_VIEW)
set(viewToOpenFromListWidget) = prefs.edit().putInt(LIST_WIDGET_VIEW_TO_OPEN, viewToOpenFromListWidget).apply() set(viewToOpenFromListWidget) = prefs.edit().putInt(LIST_WIDGET_VIEW_TO_OPEN, viewToOpenFromListWidget).apply()
@ -140,16 +135,6 @@ class Config(context: Context) : BaseConfig(context) {
displayEventTypes = currDisplayEventTypes displayEventTypes = currDisplayEventTypes
} }
fun getFontSize() = when (fontSize) {
FONT_SIZE_SMALL -> getSmallFontSize()
FONT_SIZE_MEDIUM -> getMediumFontSize()
else -> getLargeFontSize()
}
private fun getSmallFontSize() = getMediumFontSize() - 3f
private fun getMediumFontSize() = context.resources.getDimension(R.dimen.day_text_size) / context.resources.displayMetrics.density
private fun getLargeFontSize() = getMediumFontSize() + 3f
var usePreviousEventReminders: Boolean var usePreviousEventReminders: Boolean
get() = prefs.getBoolean(USE_PREVIOUS_EVENT_REMINDERS, true) get() = prefs.getBoolean(USE_PREVIOUS_EVENT_REMINDERS, true)
set(usePreviousEventReminders) = prefs.edit().putBoolean(USE_PREVIOUS_EVENT_REMINDERS, usePreviousEventReminders).apply() set(usePreviousEventReminders) = prefs.edit().putBoolean(USE_PREVIOUS_EVENT_REMINDERS, usePreviousEventReminders).apply()

View File

@ -50,7 +50,6 @@ const val LAST_EVENT_REMINDER_MINUTES = "reminder_minutes"
const val LAST_EVENT_REMINDER_MINUTES_2 = "reminder_minutes_2" const val LAST_EVENT_REMINDER_MINUTES_2 = "reminder_minutes_2"
const val LAST_EVENT_REMINDER_MINUTES_3 = "reminder_minutes_3" const val LAST_EVENT_REMINDER_MINUTES_3 = "reminder_minutes_3"
const val DISPLAY_EVENT_TYPES = "display_event_types" const val DISPLAY_EVENT_TYPES = "display_event_types"
const val FONT_SIZE = "font_size"
const val LIST_WIDGET_VIEW_TO_OPEN = "list_widget_view_to_open" const val LIST_WIDGET_VIEW_TO_OPEN = "list_widget_view_to_open"
const val CALDAV_SYNC = "caldav_sync" const val CALDAV_SYNC = "caldav_sync"
const val CALDAV_SYNCED_CALENDAR_IDS = "caldav_synced_calendar_ids" const val CALDAV_SYNCED_CALENDAR_IDS = "caldav_synced_calendar_ids"
@ -142,11 +141,6 @@ const val FR = "FR"
const val SA = "SA" const val SA = "SA"
const val SU = "SU" const val SU = "SU"
// font sizes
const val FONT_SIZE_SMALL = 0
const val FONT_SIZE_MEDIUM = 1
const val FONT_SIZE_LARGE = 2
const val SOURCE_SIMPLE_CALENDAR = "simple-calendar" const val SOURCE_SIMPLE_CALENDAR = "simple-calendar"
const val SOURCE_IMPORTED_ICS = "imported-ics" const val SOURCE_IMPORTED_ICS = "imported-ics"
const val SOURCE_CONTACT_BIRTHDAY = "contact-birthday" const val SOURCE_CONTACT_BIRTHDAY = "contact-birthday"

View File

@ -11,6 +11,7 @@ import android.widget.RemoteViews
import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SplashActivity import com.simplemobiletools.calendar.pro.activities.SplashActivity
import com.simplemobiletools.calendar.pro.extensions.config import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.getWidgetFontSize
import com.simplemobiletools.calendar.pro.extensions.launchNewEventIntent import com.simplemobiletools.calendar.pro.extensions.launchNewEventIntent
import com.simplemobiletools.calendar.pro.services.WidgetService import com.simplemobiletools.calendar.pro.services.WidgetService
import com.simplemobiletools.calendar.pro.services.WidgetServiceEmpty import com.simplemobiletools.calendar.pro.services.WidgetServiceEmpty
@ -27,7 +28,7 @@ class MyWidgetListProvider : AppWidgetProvider() {
} }
private fun performUpdate(context: Context) { private fun performUpdate(context: Context) {
val fontSize = context.config.getFontSize() val fontSize = context.getWidgetFontSize()
val textColor = context.config.widgetTextColor val textColor = context.config.widgetTextColor
val appWidgetManager = AppWidgetManager.getInstance(context) val appWidgetManager = AppWidgetManager.getInstance(context)

View File

@ -12,6 +12,7 @@ import android.widget.RemoteViews
import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SplashActivity import com.simplemobiletools.calendar.pro.activities.SplashActivity
import com.simplemobiletools.calendar.pro.extensions.config import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.getWidgetFontSize
import com.simplemobiletools.calendar.pro.extensions.launchNewEventIntent import com.simplemobiletools.calendar.pro.extensions.launchNewEventIntent
import com.simplemobiletools.calendar.pro.interfaces.MonthlyCalendar import com.simplemobiletools.calendar.pro.interfaces.MonthlyCalendar
import com.simplemobiletools.calendar.pro.models.DayMonthly import com.simplemobiletools.calendar.pro.models.DayMonthly
@ -93,7 +94,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() {
val displayWeekNumbers = context.config.showWeekNumbers val displayWeekNumbers = context.config.showWeekNumbers
val textColor = context.config.widgetTextColor val textColor = context.config.widgetTextColor
val dimPastEvents = context.config.dimPastEvents val dimPastEvents = context.config.dimPastEvents
val smallerFontSize = context.config.getFontSize() - 3f val smallerFontSize = context.getWidgetFontSize() - 3f
val res = context.resources val res = context.resources
val len = days.size val len = days.size
val packageName = context.packageName val packageName = context.packageName
@ -148,7 +149,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() {
private fun addDayNumber(context: Context, views: RemoteViews, day: DayMonthly, textColor: Int, id: Int) { private fun addDayNumber(context: Context, views: RemoteViews, day: DayMonthly, textColor: Int, id: Int) {
val newRemoteView = RemoteViews(context.packageName, R.layout.day_monthly_number_view).apply { val newRemoteView = RemoteViews(context.packageName, R.layout.day_monthly_number_view).apply {
setText(R.id.day_monthly_number_id, day.value.toString()) setText(R.id.day_monthly_number_id, day.value.toString())
setTextSize(R.id.day_monthly_number_id, context.config.getFontSize() - 3f) setTextSize(R.id.day_monthly_number_id, context.getWidgetFontSize() - 3f)
if (day.isToday) { if (day.isToday) {
setBackgroundColor(R.id.day_monthly_number_id, textColor) setBackgroundColor(R.id.day_monthly_number_id, textColor)
@ -162,7 +163,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() {
private val monthlyCalendar = object : MonthlyCalendar { private val monthlyCalendar = object : MonthlyCalendar {
override fun updateMonthlyCalendar(context: Context, month: String, days: ArrayList<DayMonthly>, checkedEvents: Boolean, currTargetDate: DateTime) { override fun updateMonthlyCalendar(context: Context, month: String, days: ArrayList<DayMonthly>, checkedEvents: Boolean, currTargetDate: DateTime) {
val largerFontSize = context.config.getFontSize() + 3f val largerFontSize = context.getWidgetFontSize() + 3f
val textColor = context.config.widgetTextColor val textColor = context.config.widgetTextColor
val resources = context.resources val resources = context.resources
@ -212,7 +213,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() {
private fun updateDayLabels(context: Context, views: RemoteViews, resources: Resources, textColor: Int) { private fun updateDayLabels(context: Context, views: RemoteViews, resources: Resources, textColor: Int) {
val sundayFirst = context.config.isSundayFirst val sundayFirst = context.config.isSundayFirst
val smallerFontSize = context.config.getFontSize() val smallerFontSize = context.getWidgetFontSize()
val packageName = context.packageName val packageName = context.packageName
val letters = context.resources.getStringArray(R.array.week_day_letters) val letters = context.resources.getStringArray(R.array.week_day_letters)
for (i in 0..6) { for (i in 0..6) {