mirror of
				https://github.com/SimpleMobileTools/Simple-Calendar.git
				synced 2025-06-05 21:59:17 +02:00 
			
		
		
		
	allow selecting which event type events should be exported
This commit is contained in:
		| @@ -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,9 +1,15 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <LinearLayout | ||||
| <ScrollView | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     android:id="@+id/export_events_scrollview" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="wrap_content"> | ||||
|  | ||||
|     <LinearLayout | ||||
|         android:id="@+id/export_events_holder" | ||||
|         android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:orientation="vertical" | ||||
|         android:paddingLeft="@dimen/activity_margin" | ||||
|         android:paddingRight="@dimen/activity_margin" | ||||
| @@ -50,4 +56,37 @@ | ||||
|             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> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user