add handling for importing .ics files in Scoped Storage
This commit is contained in:
parent
97197435ae
commit
c03a05eeae
|
@ -55,6 +55,7 @@ import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
|
private val PICK_IMPORT_SOURCE_INTENT = 1
|
||||||
private val PICK_EXPORT_FILE_INTENT = 2
|
private val PICK_EXPORT_FILE_INTENT = 2
|
||||||
|
|
||||||
private var showCalDAVRefreshToast = false
|
private var showCalDAVRefreshToast = false
|
||||||
|
@ -234,7 +235,9 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, resultData)
|
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!!)
|
val outputStream = contentResolver.openOutputStream(resultData.data!!)
|
||||||
exportEventsTo(eventTypesToExport, outputStream)
|
exportEventsTo(eventTypesToExport, outputStream)
|
||||||
}
|
}
|
||||||
|
@ -751,9 +754,17 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryImportEvents() {
|
private fun tryImportEvents() {
|
||||||
handlePermission(PERMISSION_READ_STORAGE) {
|
if (isQPlus()) {
|
||||||
if (it) {
|
Intent(Intent.ACTION_GET_CONTENT).apply {
|
||||||
importEvents()
|
addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
|
type = "text/calendar"
|
||||||
|
startActivityForResult(this, PICK_IMPORT_SOURCE_INTENT)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
handlePermission(PERMISSION_READ_STORAGE) {
|
||||||
|
if (it) {
|
||||||
|
importEvents()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue