Skip to content

Commit 65960f7

Browse files
committed
feat: launch SAF intent for selected image mime types when editing space image
1 parent d8deb7c commit 65960f7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/SpacesListFragment.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package com.owncloud.android.presentation.spaces
2424

2525
import android.content.DialogInterface
26+
import android.content.Intent
2627
import android.content.res.Configuration
2728
import android.os.Bundle
2829
import android.view.LayoutInflater
@@ -61,6 +62,7 @@ import com.owncloud.android.presentation.common.BottomSheetFragmentItemView
6162
import com.owncloud.android.utils.DisplayUtils
6263
import com.owncloud.android.presentation.common.UIResult
6364
import com.owncloud.android.presentation.spaces.createspace.CreateSpaceDialogFragment
65+
import com.owncloud.android.ui.activity.FileDisplayActivity.Companion.REQUEST_CODE__SELECT_CONTENT_FROM_APPS
6466
import kotlinx.coroutines.flow.SharedFlow
6567
import org.koin.androidx.viewmodel.ext.android.viewModel
6668
import org.koin.core.parameter.parametersOf
@@ -382,7 +384,17 @@ class SpacesListFragment :
382384
negativeButtonText = getString(R.string.common_no)
383385
)
384386
}
385-
SpaceMenuOption.EDIT_IMAGE -> { }
387+
SpaceMenuOption.EDIT_IMAGE -> {
388+
val action = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
389+
addCategory(Intent.CATEGORY_OPENABLE)
390+
type = IMAGE_FILES_SAF_REGEX
391+
putExtra(Intent.EXTRA_MIME_TYPES, arrayOf("image/jpeg", "image/png", "image/bmp", "image/x-ms-bmp", "image/gif"))
392+
}
393+
startActivityForResult(
394+
Intent.createChooser(action, getString(R.string.upload_chooser_title)),
395+
REQUEST_CODE__SELECT_CONTENT_FROM_APPS
396+
)
397+
}
386398
}
387399
}
388400
}
@@ -398,6 +410,7 @@ class SpacesListFragment :
398410
const val DRIVES_READ_WRITE_ALL_PERMISSION = "Drives.ReadWrite.all"
399411
const val DRIVES_READ_WRITE_PROJECT_QUOTA_ALL_PERMISSION = "Drives.ReadWriteProjectQuota.all"
400412
const val DRIVES_DELETE_PROJECT_ALL_PERMISSION = "Drives.DeleteProject.all"
413+
const val IMAGE_FILES_SAF_REGEX = "image/*"
401414

402415
private const val DIALOG_CREATE_SPACE = "DIALOG_CREATE_SPACE"
403416

0 commit comments

Comments
 (0)