@@ -147,6 +147,7 @@ class MainActivity : SimpleActivity() {
147147
148148 fun refreshMenuItems () {
149149 val currentFragment = getCurrentFragment() ? : return
150+ val isCreateDocumentIntent = intent.action == Intent .ACTION_CREATE_DOCUMENT
150151 val currentViewType = config.getFolderViewType(currentFragment.currentPath)
151152 val favorites = config.favorites
152153
@@ -169,6 +170,9 @@ class MainActivity : SimpleActivity() {
169170 findItem(R .id.increase_column_count).isVisible =
170171 currentViewType == VIEW_TYPE_GRID && config.fileColumnCnt < MAX_COLUMN_COUNT && currentFragment !is StorageFragment
171172 findItem(R .id.reduce_column_count).isVisible = currentViewType == VIEW_TYPE_GRID && config.fileColumnCnt > 1 && currentFragment !is StorageFragment
173+
174+ findItem(R .id.settings).isVisible = ! isCreateDocumentIntent
175+ findItem(R .id.about).isVisible = ! isCreateDocumentIntent
172176 }
173177 }
174178
@@ -373,6 +377,7 @@ class MainActivity : SimpleActivity() {
373377
374378 val isPickRingtoneIntent = intent.action == RingtoneManager .ACTION_RINGTONE_PICKER
375379 val isGetContentIntent = intent.action == Intent .ACTION_GET_CONTENT || intent.action == Intent .ACTION_PICK
380+ val isCreateDocumentIntent = intent.action == Intent .ACTION_CREATE_DOCUMENT
376381 val allowPickingMultipleIntent = intent.getBooleanExtra(Intent .EXTRA_ALLOW_MULTIPLE , false )
377382 val getContentMimeType = if (isGetContentIntent) {
378383 intent.type ? : " "
@@ -385,6 +390,7 @@ class MainActivity : SimpleActivity() {
385390 it?.isPickMultipleIntent = allowPickingMultipleIntent
386391 it?.isGetContentIntent = isGetContentIntent
387392 it?.wantedMimeType = getContentMimeType
393+ it?.updateIsCreateDocumentIntent(isCreateDocumentIntent)
388394 }
389395
390396 if (refreshRecents) {
@@ -418,15 +424,20 @@ class MainActivity : SimpleActivity() {
418424
419425 private fun setupTabs () {
420426 main_tabs_holder.removeAllTabs()
421- val isPickFileIntent =
422- intent.action == RingtoneManager .ACTION_RINGTONE_PICKER || intent.action == Intent .ACTION_GET_CONTENT || intent.action == Intent .ACTION_PICK
427+ val action = intent.action
428+ val isPickFileIntent = action == RingtoneManager .ACTION_RINGTONE_PICKER || action == Intent .ACTION_GET_CONTENT || action == Intent .ACTION_PICK
429+ val isCreateDocumentIntent = action == Intent .ACTION_CREATE_DOCUMENT
430+
423431 if (isPickFileIntent) {
424432 mTabsToShow.remove(TAB_STORAGE_ANALYSIS )
425433 if (mTabsToShow.none { it and config.showTabs != 0 }) {
426434 config.showTabs = TAB_FILES
427435 mStoredShowTabs = TAB_FILES
428436 mTabsToShow = arrayListOf (TAB_FILES )
429437 }
438+ } else if (isCreateDocumentIntent) {
439+ mTabsToShow.clear()
440+ mTabsToShow = arrayListOf (TAB_FILES )
430441 }
431442
432443 mTabsToShow.forEachIndexed { index, value ->
@@ -698,6 +709,17 @@ class MainActivity : SimpleActivity() {
698709 finish()
699710 }
700711
712+ fun createDocumentConfirmed (path : String ) {
713+ val resultIntent = Intent ()
714+ val filename = intent.getStringExtra(Intent .EXTRA_TITLE ) ? : " "
715+ val uri = getFilePublicUri(File (path, filename), BuildConfig .APPLICATION_ID )
716+ val type = path.getMimeType()
717+ resultIntent.setDataAndType(uri, type)
718+ resultIntent.flags = Intent .FLAG_GRANT_READ_URI_PERMISSION or Intent .FLAG_GRANT_WRITE_URI_PERMISSION or Intent .FLAG_GRANT_PERSISTABLE_URI_PERMISSION
719+ setResult(Activity .RESULT_OK , resultIntent)
720+ finish()
721+ }
722+
701723 fun pickedRingtone (path : String ) {
702724 val uri = getFilePublicUri(File (path), BuildConfig .APPLICATION_ID )
703725 val type = path.getMimeType()
0 commit comments