Skip to content

Commit b38e095

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

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
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
2930
import android.view.Menu
3031
import android.view.MenuInflater
3132
import android.view.View
3233
import android.view.ViewGroup
34+
import androidx.activity.result.contract.ActivityResultContracts
3335
import androidx.appcompat.widget.SearchView
3436
import androidx.core.content.res.ResourcesCompat
3537
import androidx.core.os.bundleOf
@@ -92,6 +94,9 @@ class SpacesListFragment :
9294
)
9395
}
9496

97+
private val editSpaceImageLauncher =
98+
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { }
99+
95100
private lateinit var spacesListAdapter: SpacesListAdapter
96101

97102
override fun onCreateView(
@@ -382,7 +387,14 @@ class SpacesListFragment :
382387
negativeButtonText = getString(R.string.common_no)
383388
)
384389
}
385-
SpaceMenuOption.EDIT_IMAGE -> { }
390+
SpaceMenuOption.EDIT_IMAGE -> {
391+
val action = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
392+
addCategory(Intent.CATEGORY_OPENABLE)
393+
type = "image/*"
394+
putExtra(Intent.EXTRA_MIME_TYPES, arrayOf("image/jpeg", "image/png", "image/bmp", "image/x-ms-bmp", "image/gif"))
395+
}
396+
editSpaceImageLauncher.launch(action)
397+
}
386398
}
387399
}
388400
}

0 commit comments

Comments
 (0)