Companion

object Companion

Companion object containing methods for handling the posting of an artwork in relation to choosing a photo from the Gallery or taking a photo using the device camera, alongside constants associated with these operations.

Properties

FROM_CAMERA
Link copied to clipboard
const val FROM_CAMERA: String
Denotes that the photo was taken using the device camera.
FROM_GALLERY
Link copied to clipboard
const val FROM_GALLERY: String
Denotes that the photo was chosen the Gallery.
PACKAGE_NAME
Link copied to clipboard
private const val PACKAGE_NAME: String
Name of the package to which this class belongs.
PHOTO_DEFAULT_FILE_NAME
Link copied to clipboard
private const val PHOTO_DEFAULT_FILE_NAME: String
Default file name (excluding the file extension) of a photo taken using the device camera.

Functions

chooseFromGallery
Link copied to clipboard
fun chooseFromGallery(activity: Activity, galleryLauncher: ActivityResultLauncher<Intent>)
Obtains the necessary permissions for choosing a photo from the Gallery.
chooseFromGalleryIntent
Link copied to clipboard
private fun chooseFromGalleryIntent(galleryLauncher: ActivityResultLauncher<Intent>)
Launches the Gallery should the user decide to choose a photo from it.
getPhotoFile
Link copied to clipboard
private fun getPhotoFile(context: Context, name: String): File
Returns a temporary file given the specified file name and a fixed extension of ".jpg" (associated with an image) and stores this in the standard directory for pictures.
permissionsResultCamera
Link copied to clipboard
fun permissionsResultCamera(grantResults: IntArray, activity: Activity, context: Context, cameraLauncher: ActivityResultLauncher<Intent>): File?
Defines the behavior depending on whether the user granted (or denied) the necessary permissions for taking a photo using the device camera.
permissionsResultGallery
Link copied to clipboard
fun permissionsResultGallery(grantResults: IntArray, context: Context, galleryLauncher: ActivityResultLauncher<Intent>)
Defines the behavior depending on whether the user granted (or denied) the necessary permissions for choosing a photo from the Gallery.
takeFromCamera
Link copied to clipboard
fun takeFromCamera(activity: Activity, context: Context, cameraLauncher: ActivityResultLauncher<Intent>): File
Obtains the necessary permissions for taking a photo using the device camera.
takeFromCameraIntent
Link copied to clipboard
private fun takeFromCameraIntent(intent: Intent, cameraLauncher: ActivityResultLauncher<Intent>, activity: Activity, context: Context)
Launches the activity result pertaining to the device camera should the user decide to take a photo using it.