diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt index 18ac3e88f..5ca1a5151 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt @@ -55,6 +55,7 @@ import java.util.* import kotlin.collections.ArrayList class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { + private val PICK_IMPORT_SOURCE_INTENT = 1 private val PICK_EXPORT_FILE_INTENT = 2 private var showCalDAVRefreshToast = false @@ -234,7 +235,9 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { super.onActivityResult(requestCode, resultCode, resultData) - if (requestCode == PICK_EXPORT_FILE_INTENT && resultCode == Activity.RESULT_OK && resultData != null && resultData.data != null) { + if (requestCode == PICK_IMPORT_SOURCE_INTENT && resultCode == Activity.RESULT_OK && resultData != null && resultData.data != null) { + tryImportEventsFromFile(resultData.data!!) + } else if (requestCode == PICK_EXPORT_FILE_INTENT && resultCode == Activity.RESULT_OK && resultData != null && resultData.data != null) { val outputStream = contentResolver.openOutputStream(resultData.data!!) exportEventsTo(eventTypesToExport, outputStream) } @@ -751,9 +754,17 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { } private fun tryImportEvents() { - handlePermission(PERMISSION_READ_STORAGE) { - if (it) { - importEvents() + if (isQPlus()) { + Intent(Intent.ACTION_GET_CONTENT).apply { + addCategory(Intent.CATEGORY_OPENABLE) + type = "text/calendar" + startActivityForResult(this, PICK_IMPORT_SOURCE_INTENT) + } + } else { + handlePermission(PERMISSION_READ_STORAGE) { + if (it) { + importEvents() + } } } }