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 {
implementation 'com.simplemobiletools:commons:3.0.12'
implementation 'com.simplemobiletools:commons:3.0.17'
implementation 'joda-time:joda-time:2.9.9'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.android.support:multidex:1.0.2'

View File

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

View File

@ -156,7 +156,7 @@ class SettingsActivity : SimpleActivity() {
config.caldavSync = newCalendarIds.isNotEmpty()
toast(R.string.syncing)
Thread({
Thread {
if (newCalendarIds.isNotEmpty()) {
val existingEventTypeNames = dbHelper.fetchEventTypes().map { it.getDisplayTitle().toLowerCase() } as ArrayList<String>
getSyncedCalDAVCalendars().forEach {
@ -179,7 +179,7 @@ class SettingsActivity : SimpleActivity() {
}
dbHelper.deleteEventTypesWithCalendarId(TextUtils.join(",", removedCalendarIds))
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)
.create().apply {
activity.setupDialogStuff(view, this)
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
activity.setupDialogStuff(view, this) {
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)
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this, R.string.export_events)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
val filename = view.export_events_filename.value
when {
filename.isEmpty() -> activity.toast(R.string.empty_name)
filename.isAValidFilename() -> {
val file = File(path, "$filename.ics")
if (file.exists()) {
activity.toast(R.string.name_taken)
return@setOnClickListener
}
activity.setupDialogStuff(view, this, R.string.export_events) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val filename = view.export_events_filename.value
when {
filename.isEmpty() -> activity.toast(R.string.empty_name)
filename.isAValidFilename() -> {
val file = File(path, "$filename.ics")
if (file.exists()) {
activity.toast(R.string.name_taken)
return@setOnClickListener
}
val eventTypes = (view.export_events_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsSet()
callback(view.export_events_checkbox.isChecked, file, eventTypes)
dismiss()
val eventTypes = (view.export_events_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsSet()
callback(view.export_events_checkbox.isChecked, file, eventTypes)
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)
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this, R.string.import_events)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
activity.toast(R.string.importing)
Thread({
val result = IcsImporter().importEvents(activity, path, currEventTypeId)
handleParseResult(result)
dismiss()
}).start()
})
activity.setupDialogStuff(view, this, R.string.import_events) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
activity.toast(R.string.importing)
Thread {
val result = IcsImporter().importEvents(activity, path, currEventTypeId)
handleParseResult(result)
dismiss()
}.start()
}
}
}
}

View File

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

View File

@ -20,14 +20,15 @@ class SnoozePickerDialog(val activity: SimpleActivity, val minutes: Int, val cal
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this)
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
val value = view.snooze_picker.value
val minutes = Integer.valueOf(if (value.isEmpty() || value == "0") "1" else value)
callback(minutes)
dismiss()
})
activity.setupDialogStuff(view, this) {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val value = view.snooze_picker.value
val minutes = Integer.valueOf(if (value.isEmpty() || value == "0") "1" else value)
callback(minutes)
dismiss()
}
}
}
}
}

View File

@ -45,39 +45,40 @@ class UpdateEventTypeDialog(val activity: Activity, var eventType: EventType? =
.setNegativeButton(R.string.cancel, null)
.create().apply {
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)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
val title = view.type_title.value
val eventIdWithTitle = activity.dbHelper.getEventTypeIdWithTitle(title)
var isEventTypeTitleTaken = isNewEvent && eventIdWithTitle != -1
if (!isEventTypeTitleTaken)
isEventTypeTitleTaken = !isNewEvent && eventType!!.id != eventIdWithTitle && eventIdWithTitle != -1
activity.setupDialogStuff(view, this, if (isNewEvent) R.string.add_new_type else R.string.edit_type) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val title = view.type_title.value
val eventIdWithTitle = activity.dbHelper.getEventTypeIdWithTitle(title)
var isEventTypeTitleTaken = isNewEvent && eventIdWithTitle != -1
if (!isEventTypeTitleTaken)
isEventTypeTitleTaken = !isNewEvent && eventType!!.id != eventIdWithTitle && eventIdWithTitle != -1
if (title.isEmpty()) {
activity.toast(R.string.title_empty)
return@setOnClickListener
} else if (isEventTypeTitleTaken) {
activity.toast(R.string.type_already_exists)
return@setOnClickListener
if (title.isEmpty()) {
activity.toast(R.string.title_empty)
return@setOnClickListener
} else if (isEventTypeTitleTaken) {
activity.toast(R.string.type_already_exists)
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) {
if (config.caldavSync) {
Thread({
Thread {
CalDAVHandler(applicationContext).refreshCalendars(null, callback)
updateWidgets()
}).start()
}.start()
}
}

View File

@ -95,7 +95,7 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEventsListen
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> positivePressed(dateTime, datePicker) }
.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)
.setPositiveButton(R.string.ok) { dialog, which -> positivePressed(dateTime, datePicker) }
.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) {
Thread({
Thread {
getEventsInBackground(fromTS, toTS, eventId, callback)
}).start()
}.start()
}
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) {
Thread({
Thread {
callback(fetchEventTypes())
}).start()
}.start()
}
fun fetchEventTypes(): ArrayList<EventType> {