update Commons to 3.0.17

This commit is contained in:
tibbi 2017-12-01 11:57:41 +01:00
parent 9c6592bcae
commit 749c2e5326
13 changed files with 94 additions and 88 deletions

View File

@ -47,7 +47,7 @@ ext {
} }
dependencies { dependencies {
implementation 'com.simplemobiletools:commons:3.0.12' implementation 'com.simplemobiletools:commons:3.0.17'
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.2' implementation 'com.android.support:multidex:1.0.2'

View File

@ -294,7 +294,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
val items = getHolidayRadioItems() val items = getHolidayRadioItems()
RadioGroupDialog(this, items, -1) { RadioGroupDialog(this, items, -1) {
toast(R.string.importing) toast(R.string.importing)
Thread({ Thread {
val holidays = getString(R.string.holidays) val holidays = getString(R.string.holidays)
var eventTypeId = dbHelper.getEventTypeIdWithTitle(holidays) var eventTypeId = dbHelper.getEventTypeIdWithTitle(holidays)
if (eventTypeId == -1) { if (eventTypeId == -1) {
@ -308,14 +308,14 @@ class MainActivity : SimpleActivity(), NavigationListener {
updateViewPager() updateViewPager()
} }
} }
}).start() }.start()
} }
} }
private fun tryAddBirthdays() { private fun tryAddBirthdays() {
handlePermission(PERMISSION_READ_CONTACTS) { handlePermission(PERMISSION_READ_CONTACTS) {
if (it) { if (it) {
Thread({ Thread {
addContactEvents(true) { addContactEvents(true) {
if (it > 0) { if (it > 0) {
toast(R.string.birthdays_added) toast(R.string.birthdays_added)
@ -324,7 +324,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
toast(R.string.no_birthdays) toast(R.string.no_birthdays)
} }
} }
}).start() }.start()
} else { } else {
toast(R.string.no_contacts_permission) toast(R.string.no_contacts_permission)
} }
@ -334,7 +334,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
private fun tryAddAnniversaries() { private fun tryAddAnniversaries() {
handlePermission(PERMISSION_READ_CONTACTS) { handlePermission(PERMISSION_READ_CONTACTS) {
if (it) { if (it) {
Thread({ Thread {
addContactEvents(false) { addContactEvents(false) {
if (it > 0) { if (it > 0) {
toast(R.string.anniversaries_added) toast(R.string.anniversaries_added)
@ -343,7 +343,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
toast(R.string.no_anniversaries) toast(R.string.no_anniversaries)
} }
} }
}).start() }.start()
} else { } else {
toast(R.string.no_contacts_permission) toast(R.string.no_contacts_permission)
} }
@ -541,7 +541,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
FilePickerDialog(this, pickFile = false) { FilePickerDialog(this, pickFile = false) {
val path = it val path = it
ExportEventsDialog(this, path) { exportPastEvents, file, eventTypes -> ExportEventsDialog(this, path) { exportPastEvents, file, eventTypes ->
Thread({ Thread {
val events = dbHelper.getEventsToExport(exportPastEvents).filter { eventTypes.contains(it.eventType.toString()) } val events = dbHelper.getEventsToExport(exportPastEvents).filter { eventTypes.contains(it.eventType.toString()) }
if (events.isEmpty()) { if (events.isEmpty()) {
toast(R.string.no_events_for_exporting) toast(R.string.no_events_for_exporting)
@ -555,7 +555,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
}) })
} }
} }
}).start() }.start()
} }
} }
} }
@ -665,7 +665,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
weeklyAdapter.updateScrollY(week_view_view_pager.currentItem, y) weeklyAdapter.updateScrollY(week_view_view_pager.currentItem, y)
} }
}) })
week_view_hours_scrollview.setOnTouchListener({ view, motionEvent -> true }) week_view_hours_scrollview.setOnTouchListener{ view, motionEvent -> true }
} }
fun updateHoursTopMargin(margin: Int) { fun updateHoursTopMargin(margin: Int) {

View File

@ -156,7 +156,7 @@ class SettingsActivity : SimpleActivity() {
config.caldavSync = newCalendarIds.isNotEmpty() config.caldavSync = newCalendarIds.isNotEmpty()
toast(R.string.syncing) toast(R.string.syncing)
Thread({ Thread {
if (newCalendarIds.isNotEmpty()) { if (newCalendarIds.isNotEmpty()) {
val existingEventTypeNames = dbHelper.fetchEventTypes().map { it.getDisplayTitle().toLowerCase() } as ArrayList<String> val existingEventTypeNames = dbHelper.fetchEventTypes().map { it.getDisplayTitle().toLowerCase() } as ArrayList<String>
getSyncedCalDAVCalendars().forEach { getSyncedCalDAVCalendars().forEach {
@ -179,7 +179,7 @@ class SettingsActivity : SimpleActivity() {
} }
dbHelper.deleteEventTypesWithCalendarId(TextUtils.join(",", removedCalendarIds)) dbHelper.deleteEventTypesWithCalendarId(TextUtils.join(",", removedCalendarIds))
toast(R.string.synchronization_completed) toast(R.string.synchronization_completed)
}).start() }.start()
} }
} }

View File

@ -19,8 +19,9 @@ class EditRepeatingEventDialog(val activity: SimpleActivity, val callback: (allO
dialog = AlertDialog.Builder(activity) dialog = AlertDialog.Builder(activity)
.create().apply { .create().apply {
activity.setupDialogStuff(view, this) activity.setupDialogStuff(view, this) {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
}
} }
} }

View File

@ -38,25 +38,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

@ -32,15 +32,16 @@ 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().importEvents(activity, path, currEventTypeId) val result = IcsImporter().importEvents(activity, path, currEventTypeId)
handleParseResult(result) handleParseResult(result)
dismiss() dismiss()
}).start() }.start()
}) }
}
} }
} }

View File

@ -39,8 +39,9 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Int,
.setPositiveButton(R.string.ok, { dialogInterface, i -> confirmRepetition() }) .setPositiveButton(R.string.ok, { dialogInterface, i -> confirmRepetition() })
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .create().apply {
activity.setupDialogStuff(view, this) activity.setupDialogStuff(view, this) {
activity.currentFocus?.clearFocus() activity.currentFocus?.clearFocus()
}
} }
} }

View File

@ -20,14 +20,15 @@ class SnoozePickerDialog(val activity: SimpleActivity, val minutes: Int, 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) activity.setupDialogStuff(view, this) {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val value = view.snooze_picker.value val value = view.snooze_picker.value
val minutes = Integer.valueOf(if (value.isEmpty() || value == "0") "1" else value) val minutes = Integer.valueOf(if (value.isEmpty() || value == "0") "1" else value)
callback(minutes) callback(minutes)
dismiss() dismiss()
}) }
}
} }
} }
} }

View File

@ -45,39 +45,40 @@ class UpdateEventTypeDialog(val activity: Activity, var eventType: EventType? =
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
activity.setupDialogStuff(view, this, if (isNewEvent) R.string.add_new_type else R.string.edit_type) activity.setupDialogStuff(view, this, if (isNewEvent) R.string.add_new_type else R.string.edit_type) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val title = view.type_title.value val title = view.type_title.value
val eventIdWithTitle = activity.dbHelper.getEventTypeIdWithTitle(title) val eventIdWithTitle = activity.dbHelper.getEventTypeIdWithTitle(title)
var isEventTypeTitleTaken = isNewEvent && eventIdWithTitle != -1 var isEventTypeTitleTaken = isNewEvent && eventIdWithTitle != -1
if (!isEventTypeTitleTaken) if (!isEventTypeTitleTaken)
isEventTypeTitleTaken = !isNewEvent && eventType!!.id != eventIdWithTitle && eventIdWithTitle != -1 isEventTypeTitleTaken = !isNewEvent && eventType!!.id != eventIdWithTitle && eventIdWithTitle != -1
if (title.isEmpty()) { if (title.isEmpty()) {
activity.toast(R.string.title_empty) activity.toast(R.string.title_empty)
return@setOnClickListener return@setOnClickListener
} else if (isEventTypeTitleTaken) { } else if (isEventTypeTitleTaken) {
activity.toast(R.string.type_already_exists) activity.toast(R.string.type_already_exists)
return@setOnClickListener return@setOnClickListener
}
eventType!!.title = title
if (eventType!!.caldavCalendarId != 0)
eventType!!.caldavDisplayName = title
val eventTypeId = if (isNewEvent) {
activity.dbHelper.insertEventType(eventType!!)
} else {
activity.dbHelper.updateEventType(eventType!!)
}
if (eventTypeId != -1) {
dismiss()
callback(eventTypeId)
} else {
activity.toast(R.string.editing_calendar_failed)
}
} }
}
eventType!!.title = title
if (eventType!!.caldavCalendarId != 0)
eventType!!.caldavDisplayName = title
val eventTypeId = if (isNewEvent) {
activity.dbHelper.insertEventType(eventType!!)
} else {
activity.dbHelper.updateEventType(eventType!!)
}
if (eventTypeId != -1) {
dismiss()
callback(eventTypeId)
} else {
activity.toast(R.string.editing_calendar_failed)
}
})
} }
} }

View File

@ -237,10 +237,10 @@ fun Context.getSyncedCalDAVCalendars() = CalDAVHandler(applicationContext).getCa
fun Context.recheckCalDAVCalendars(callback: () -> Unit) { fun Context.recheckCalDAVCalendars(callback: () -> Unit) {
if (config.caldavSync) { if (config.caldavSync) {
Thread({ Thread {
CalDAVHandler(applicationContext).refreshCalendars(null, callback) CalDAVHandler(applicationContext).refreshCalendars(null, callback)
updateWidgets() updateWidgets()
}).start() }.start()
} }
} }

View File

@ -95,7 +95,7 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEventsListen
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> positivePressed(dateTime, datePicker) } .setPositiveButton(R.string.ok) { dialog, which -> positivePressed(dateTime, datePicker) }
.create().apply { .create().apply {
context.setupDialogStuff(view, this) activity?.setupDialogStuff(view, this)
} }
} }

View File

@ -137,7 +137,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> positivePressed(dateTime, datePicker) } .setPositiveButton(R.string.ok) { dialog, which -> positivePressed(dateTime, datePicker) }
.create().apply { .create().apply {
context.setupDialogStuff(view, this) activity?.setupDialogStuff(view, this)
} }
} }

View File

@ -573,9 +573,9 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
} }
fun getEvents(fromTS: Int, toTS: Int, eventId: Int = -1, callback: (events: MutableList<Event>) -> Unit) { fun getEvents(fromTS: Int, toTS: Int, eventId: Int = -1, callback: (events: MutableList<Event>) -> Unit) {
Thread({ Thread {
getEventsInBackground(fromTS, toTS, eventId, callback) getEventsInBackground(fromTS, toTS, eventId, callback)
}).start() }.start()
} }
fun getEventsInBackground(fromTS: Int, toTS: Int, eventId: Int = -1, callback: (events: MutableList<Event>) -> Unit) { fun getEventsInBackground(fromTS: Int, toTS: Int, eventId: Int = -1, callback: (events: MutableList<Event>) -> Unit) {
@ -847,9 +847,9 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
} }
fun getEventTypes(callback: (types: ArrayList<EventType>) -> Unit) { fun getEventTypes(callback: (types: ArrayList<EventType>) -> Unit) {
Thread({ Thread {
callback(fetchEventTypes()) callback(fetchEventTypes())
}).start() }.start()
} }
fun fetchEventTypes(): ArrayList<EventType> { fun fetchEventTypes(): ArrayList<EventType> {