allow selecting which event type events should be exported
This commit is contained in:
parent
537afc2f05
commit
25e22a67e6
|
@ -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<String>()
|
||||
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)
|
||||
|
|
|
@ -1,53 +1,92 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/export_events_holder"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/export_events_scrollview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/export_events_folder_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/folder"
|
||||
android:textSize="@dimen/smaller_text_size"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/export_events_folder"
|
||||
<LinearLayout
|
||||
android:id="@+id/export_events_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
android:layout_marginLeft="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/small_margin"
|
||||
android:paddingRight="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/small_margin"/>
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/export_events_filename_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/filename_without_ics"
|
||||
android:textSize="@dimen/smaller_text_size"/>
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/export_events_folder_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/folder"
|
||||
android:textSize="@dimen/smaller_text_size"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyEditText
|
||||
android:id="@+id/export_events_filename"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
android:layout_marginLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/normal_margin"/>
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/export_events_folder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
android:layout_marginLeft="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/small_margin"
|
||||
android:paddingRight="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/small_margin"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/export_events_checkbox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/small_margin"
|
||||
android:text="@string/export_past_events_too"/>
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/export_events_filename_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/filename_without_ics"
|
||||
android:textSize="@dimen/smaller_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
<com.simplemobiletools.commons.views.MyEditText
|
||||
android:id="@+id/export_events_filename"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
android:layout_marginLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/normal_margin"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/export_events_checkbox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/small_margin"
|
||||
android:text="@string/export_past_events_too"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/export_events_pick_types"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/export_events_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:layout_marginBottom="@dimen/medium_margin"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="@color/darker_divider"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/export_events_pick_types_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/include_event_types"
|
||||
android:textSize="@dimen/smaller_text_size"/>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/export_events_types_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:overScrollMode="never"
|
||||
android:paddingTop="@dimen/medium_margin"
|
||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
Loading…
Reference in New Issue