update commons to 3.18.18

This commit is contained in:
tibbi 2018-04-11 12:24:24 +02:00
parent adebfb60f6
commit ce92fa8f63
18 changed files with 65 additions and 61 deletions

View file

@ -46,7 +46,7 @@ ext {
} }
dependencies { dependencies {
implementation 'com.simplemobiletools:commons:3.17.14' implementation 'com.simplemobiletools:commons:3.18.18'
implementation 'joda-time:joda-time:2.9.9' implementation 'joda-time:joda-time:2.9.9'
implementation 'com.facebook.stetho:stetho:1.5.0' implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.android.support:multidex:1.0.3' implementation 'com.android.support:multidex:1.0.3'

View file

@ -63,7 +63,6 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private var mStoredDayCode = "" private var mStoredDayCode = ""
private var mStoredIsSundayFirst = false private var mStoredIsSundayFirst = false
private var mStoredUse24HourFormat = false private var mStoredUse24HourFormat = false
private var mStoredUseEnglish = false
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -123,11 +122,6 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
if (mStoredUseEnglish != config.useEnglish) {
restartActivity()
return
}
if (mStoredTextColor != config.textColor || mStoredBackgroundColor != config.backgroundColor || mStoredPrimaryColor != config.primaryColor if (mStoredTextColor != config.textColor || mStoredBackgroundColor != config.backgroundColor || mStoredPrimaryColor != config.primaryColor
|| mStoredDayCode != Formatter.getTodayCode(applicationContext)) { || mStoredDayCode != Formatter.getTodayCode(applicationContext)) {
updateViewPager() updateViewPager()
@ -213,7 +207,6 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private fun storeStateVariables() { private fun storeStateVariables() {
config.apply { config.apply {
mStoredUseEnglish = useEnglish
mStoredIsSundayFirst = isSundayFirst mStoredIsSundayFirst = isSundayFirst
mStoredTextColor = textColor mStoredTextColor = textColor
mStoredPrimaryColor = primaryColor mStoredPrimaryColor = primaryColor

View file

@ -35,7 +35,6 @@ class ManageEventTypesActivity : SimpleActivity(), DeleteEventTypesListener {
val adapter = ManageEventTypesAdapter(this, it, this, manage_event_types_list) { val adapter = ManageEventTypesAdapter(this, it, this, manage_event_types_list) {
showEventTypeDialog(it as EventType) showEventTypeDialog(it as EventType)
} }
adapter.setupDragListener(true)
manage_event_types_list.adapter = adapter manage_event_types_list.adapter = adapter
} }
} }

View file

@ -101,7 +101,7 @@ class SettingsActivity : SimpleActivity() {
settings_use_english_holder.setOnClickListener { settings_use_english_holder.setOnClickListener {
settings_use_english.toggle() settings_use_english.toggle()
config.useEnglish = settings_use_english.isChecked config.useEnglish = settings_use_english.isChecked
useEnglishToggled() System.exit(0)
} }
} }

View file

@ -106,15 +106,15 @@ class WidgetListConfigureActivity : SimpleActivity() {
} }
private fun pickBackgroundColor() { private fun pickBackgroundColor() {
ColorPickerDialog(this, mBgColorWithoutTransparency) { ColorPickerDialog(this, mBgColorWithoutTransparency) { wasPositivePressed, color ->
mBgColorWithoutTransparency = it mBgColorWithoutTransparency = color
updateBgColor() updateBgColor()
} }
} }
private fun pickTextColor() { private fun pickTextColor() {
ColorPickerDialog(this, mTextColor) { ColorPickerDialog(this, mTextColor) { wasPositivePressed, color ->
mTextColorWithoutTransparency = it mTextColorWithoutTransparency = color
updateColors() updateColors()
} }
} }

View file

@ -110,15 +110,15 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
} }
private fun pickBackgroundColor() { private fun pickBackgroundColor() {
ColorPickerDialog(this, mBgColorWithoutTransparency) { ColorPickerDialog(this, mBgColorWithoutTransparency) { wasPositivePressed, color ->
mBgColorWithoutTransparency = it mBgColorWithoutTransparency = color
updateBgColor() updateBgColor()
} }
} }
private fun pickTextColor() { private fun pickTextColor() {
ColorPickerDialog(this, mTextColor) { ColorPickerDialog(this, mTextColor) { wasPositivePressed, color ->
mTextColorWithoutTransparency = it mTextColorWithoutTransparency = color
updateColors() updateColors()
updateDays() updateDays()
} }

View file

@ -24,6 +24,10 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
private var allDayString = resources.getString(R.string.all_day) private var allDayString = resources.getString(R.string.all_day)
private var replaceDescriptionWithLocation = activity.config.replaceDescription private var replaceDescriptionWithLocation = activity.config.replaceDescription
init {
setupDragListener(true)
}
override fun getActionMenuId() = R.menu.cab_day override fun getActionMenuId() = R.menu.cab_day
override fun prepareActionMode(menu: Menu) {} override fun prepareActionMode(menu: Menu) {}

View file

@ -23,6 +23,10 @@ import java.util.*
class ManageEventTypesAdapter(activity: SimpleActivity, val eventTypes: ArrayList<EventType>, val listener: DeleteEventTypesListener?, recyclerView: MyRecyclerView, class ManageEventTypesAdapter(activity: SimpleActivity, val eventTypes: ArrayList<EventType>, val listener: DeleteEventTypesListener?, recyclerView: MyRecyclerView,
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) { itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
init {
setupDragListener(true)
}
override fun getActionMenuId() = R.menu.cab_event_type override fun getActionMenuId() = R.menu.cab_event_type
override fun prepareActionMode(menu: Menu) {} override fun prepareActionMode(menu: Menu) {}

View file

@ -29,8 +29,8 @@ class DeleteEventDialog(val activity: Activity, eventIds: List<Int>, val callbac
.setPositiveButton(R.string.yes, { dialog, which -> dialogConfirmed(view as ViewGroup, hasRepeatableEvent) }) .setPositiveButton(R.string.yes, { dialog, which -> dialogConfirmed(view as ViewGroup, hasRepeatableEvent) })
.setNegativeButton(R.string.no, null) .setNegativeButton(R.string.no, null)
.create().apply { .create().apply {
activity.setupDialogStuff(view, this) activity.setupDialogStuff(view, this)
} }
} }
private fun dialogConfirmed(view: ViewGroup, hasRepeatableEvent: Boolean) { private fun dialogConfirmed(view: ViewGroup, hasRepeatableEvent: Boolean) {

View file

@ -39,26 +39,26 @@ class ExportEventsDialog(val activity: SimpleActivity, val path: String, val cal
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .create().apply {
activity.setupDialogStuff(view, this, R.string.export_events) { activity.setupDialogStuff(view, this, R.string.export_events) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val filename = view.export_events_filename.value val filename = view.export_events_filename.value
when { when {
filename.isEmpty() -> activity.toast(R.string.empty_name) filename.isEmpty() -> activity.toast(R.string.empty_name)
filename.isAValidFilename() -> { filename.isAValidFilename() -> {
val file = File(path, "$filename.ics") val file = File(path, "$filename.ics")
if (file.exists()) { if (file.exists()) {
activity.toast(R.string.name_taken) activity.toast(R.string.name_taken)
return@setOnClickListener return@setOnClickListener
} }
val eventTypes = (view.export_events_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsSet() val eventTypes = (view.export_events_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsSet()
callback(view.export_events_checkbox.isChecked, file, eventTypes) callback(view.export_events_checkbox.isChecked, file, eventTypes)
dismiss() dismiss()
}
else -> activity.toast(R.string.invalid_name)
}
} }
else -> activity.toast(R.string.invalid_name)
} }
} }
}
}
} }
} }

View file

@ -22,8 +22,8 @@ class FilterEventTypesDialog(val activity: SimpleActivity, val callback: () -> U
.setPositiveButton(R.string.ok, { dialogInterface, i -> confirmEventTypes() }) .setPositiveButton(R.string.ok, { dialogInterface, i -> confirmEventTypes() })
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .create().apply {
activity.setupDialogStuff(view, this, R.string.filter_events_by_type) activity.setupDialogStuff(view, this, R.string.filter_events_by_type)
} }
} }
private fun confirmEventTypes() { private fun confirmEventTypes() {

View file

@ -34,17 +34,17 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .create().apply {
activity.setupDialogStuff(view, this, R.string.import_events) { activity.setupDialogStuff(view, this, R.string.import_events) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
activity.toast(R.string.importing) activity.toast(R.string.importing)
Thread { Thread {
val result = IcsImporter(activity).importEvents(path, currEventTypeId, currEventTypeCalDAVCalendarId) val result = IcsImporter(activity).importEvents(path, currEventTypeId, currEventTypeCalDAVCalendarId)
handleParseResult(result) handleParseResult(result)
dismiss() dismiss()
}.start() }.start()
}
}
} }
}
}
} }
private fun updateEventType(view: ViewGroup) { private fun updateEventType(view: ViewGroup) {

View file

@ -36,8 +36,8 @@ class SelectCalendarsDialog(val activity: SimpleActivity, val callback: () -> Un
.setPositiveButton(R.string.ok, { dialogInterface, i -> confirmSelection() }) .setPositiveButton(R.string.ok, { dialogInterface, i -> confirmSelection() })
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .create().apply {
activity.setupDialogStuff(view, this, R.string.select_caldav_calendars) activity.setupDialogStuff(view, this, R.string.select_caldav_calendars)
} }
} }
private fun addCalendarItem(isEvent: Boolean, text: String, tag: Int = 0, shouldCheck: Boolean = false) { private fun addCalendarItem(isEvent: Boolean, text: String, tag: Int = 0, shouldCheck: Boolean = false) {

View file

@ -39,8 +39,8 @@ class SelectEventCalendarDialog(val activity: Activity, val calendars: List<CalD
dialog = AlertDialog.Builder(activity) dialog = AlertDialog.Builder(activity)
.create().apply { .create().apply {
activity.setupDialogStuff(view, this) activity.setupDialogStuff(view, this)
} }
} }
private fun addRadioButton(title: String, typeId: Int, color: Int) { private fun addRadioButton(title: String, typeId: Int, color: Int) {

View file

@ -32,8 +32,8 @@ class SelectEventTypeColorDialog(val activity: Activity, val eventType: EventTyp
wasInit = true wasInit = true
dialog = AlertDialog.Builder(activity) dialog = AlertDialog.Builder(activity)
.create().apply { .create().apply {
activity.setupDialogStuff(view, this) activity.setupDialogStuff(view, this)
} }
} }
private fun addRadioButton(colorKey: Int, color: Int) { private fun addRadioButton(colorKey: Int, color: Int) {

View file

@ -23,8 +23,8 @@ class UpdateEventTypeDialog(val activity: Activity, var eventType: EventType? =
type_title.setText(eventType!!.title) type_title.setText(eventType!!.title)
type_color.setOnClickListener { type_color.setOnClickListener {
if (eventType?.caldavCalendarId == 0) { if (eventType?.caldavCalendarId == 0) {
ColorPickerDialog(activity, eventType!!.color) { ColorPickerDialog(activity, eventType!!.color) { wasPositivePressed, color ->
eventType!!.color = it eventType!!.color = color
setupColor(type_color) setupColor(type_color)
} }
} else { } else {

View file

@ -32,6 +32,7 @@ import com.simplemobiletools.calendar.receivers.CalDAVSyncReceiver
import com.simplemobiletools.calendar.receivers.NotificationReceiver import com.simplemobiletools.calendar.receivers.NotificationReceiver
import com.simplemobiletools.calendar.services.SnoozeService import com.simplemobiletools.calendar.services.SnoozeService
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.SILENT
import com.simplemobiletools.commons.helpers.isOreoPlus import com.simplemobiletools.commons.helpers.isOreoPlus
import org.joda.time.DateTime import org.joda.time.DateTime
import org.joda.time.DateTimeZone import org.joda.time.DateTimeZone
@ -178,8 +179,12 @@ fun Context.getNotification(pendingIntent: PendingIntent, event: Event, content:
} }
} }
val soundUri = Uri.parse(config.reminderSoundUri) var soundUri = config.reminderSoundUri
grantReadUriPermission(config.reminderSoundUri) if (soundUri == SILENT) {
soundUri = ""
} else {
grantReadUriPermission(soundUri)
}
val contentTitle = if (publicVersion) resources.getString(R.string.app_name) else event.title val contentTitle = if (publicVersion) resources.getString(R.string.app_name) else event.title
val contentText = if (publicVersion) resources.getString(R.string.public_event_notification_text) else content val contentText = if (publicVersion) resources.getString(R.string.public_event_notification_text) else content
@ -192,7 +197,7 @@ fun Context.getNotification(pendingIntent: PendingIntent, event: Event, content:
.setPriority(Notification.PRIORITY_HIGH) .setPriority(Notification.PRIORITY_HIGH)
.setDefaults(Notification.DEFAULT_LIGHTS) .setDefaults(Notification.DEFAULT_LIGHTS)
.setAutoCancel(true) .setAutoCancel(true)
.setSound(soundUri, AudioManager.STREAM_NOTIFICATION) .setSound(Uri.parse(soundUri), AudioManager.STREAM_NOTIFICATION)
.setChannelId(channelId) .setChannelId(channelId)
.addAction(R.drawable.ic_snooze, getString(R.string.snooze), getSnoozePendingIntent(this, event)) .addAction(R.drawable.ic_snooze, getString(R.string.snooze), getSnoozePendingIntent(this, event))

View file

@ -139,7 +139,6 @@ class DayFragment : Fragment() {
DayEventsAdapter(activity as SimpleActivity, events, mHolder.day_events) { DayEventsAdapter(activity as SimpleActivity, events, mHolder.day_events) {
editEvent(it as Event) editEvent(it as Event)
}.apply { }.apply {
setupDragListener(true)
addVerticalDividers(true) addVerticalDividers(true)
mHolder.day_events.adapter = this mHolder.day_events.adapter = this
} }