diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/ExportEventsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/ExportEventsDialog.kt index 163eb5bba..5711a1f1a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/ExportEventsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/ExportEventsDialog.kt @@ -1,18 +1,36 @@ package com.simplemobiletools.calendar.dialogs -import android.app.Activity import android.support.v7.app.AlertDialog import android.view.ViewGroup +import android.widget.LinearLayout import com.simplemobiletools.calendar.R +import com.simplemobiletools.calendar.activities.SimpleActivity +import com.simplemobiletools.calendar.adapters.FilterEventTypeAdapter +import com.simplemobiletools.calendar.extensions.dbHelper import com.simplemobiletools.commons.extensions.* import kotlinx.android.synthetic.main.dialog_export_events.view.* import java.io.File -class ExportEventsDialog(val activity: Activity, val path: String, val callback: (exportPastEvents: Boolean, file: File) -> Unit) : AlertDialog.Builder(activity) { +class ExportEventsDialog(val activity: SimpleActivity, val path: String, val callback: (exportPastEvents: Boolean, file: File) -> Unit) : AlertDialog.Builder(activity) { init { val view = (activity.layoutInflater.inflate(R.layout.dialog_export_events, null) as ViewGroup).apply { export_events_folder.text = activity.humanizePath(path) export_events_filename.setText("events_${System.currentTimeMillis() / 1000}") + + activity.dbHelper.getEventTypes { + val eventTypes = HashSet() + it.mapTo(eventTypes, { it.id.toString() }) + + activity.runOnUiThread { + if (it.size > 1) { + export_events_pick_types.beVisible() + export_events_types_list.adapter = FilterEventTypeAdapter(activity, it, eventTypes) + + val margin = activity.resources.getDimension(R.dimen.normal_margin).toInt() + (export_events_checkbox.layoutParams as LinearLayout.LayoutParams).leftMargin = margin + } + } + } } AlertDialog.Builder(activity) diff --git a/app/src/main/res/layout/dialog_export_events.xml b/app/src/main/res/layout/dialog_export_events.xml index 3f9c8d0cc..268fec1fb 100644 --- a/app/src/main/res/layout/dialog_export_events.xml +++ b/app/src/main/res/layout/dialog_export_events.xml @@ -1,53 +1,92 @@ - + android:layout_height="wrap_content"> - - - + android:orientation="vertical" + android:paddingLeft="@dimen/activity_margin" + android:paddingRight="@dimen/activity_margin" + android:paddingTop="@dimen/activity_margin"> - + - + - + - + + + + + + + + + + + + + + +