suggest the Calendar at opening .ics files from a file manager

This commit is contained in:
tibbi
2017-04-06 22:51:03 +02:00
parent 9285a17ccb
commit 44e773ffdd
2 changed files with 26 additions and 8 deletions

View File

@ -27,7 +27,17 @@
</intent-filter>
</activity>
<activity android:name=".activities.MainActivity"/>
<activity android:name=".activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="content"/>
<data android:scheme="file"/>
<data android:mimeType="text/x-vcalendar"/>
<data android:mimeType="text/calendar"/>
</intent-filter>
</activity>
<activity
android:name=".activities.WidgetMonthlyConfigureActivity"

View File

@ -72,6 +72,10 @@ class MainActivity : SimpleActivity(), NavigationListener {
storeStoragePaths()
if (resources.getBoolean(R.bool.portrait_only))
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
if (intent?.action == Intent.ACTION_VIEW && intent.data != null) {
importEventsFromFile(intent.data!!.path)
}
}
override fun onResume() {
@ -238,8 +242,13 @@ class MainActivity : SimpleActivity(), NavigationListener {
private fun importEvents() {
FilePickerDialog(this) {
if (it.toLowerCase().endsWith(".ics")) {
ImportEventsDialog(this, it) {
importEventsFromFile(it)
}
}
private fun importEventsFromFile(path: String) {
if (path.toLowerCase().endsWith(".ics")) {
ImportEventsDialog(this, path) {
if (it) {
updateViewPager()
}
@ -248,7 +257,6 @@ class MainActivity : SimpleActivity(), NavigationListener {
toast(R.string.invalid_file_format)
}
}
}
private fun tryExportEvents() {
if (hasReadStoragePermission()) {