Skip to content

Commit

Permalink
fix: declaring constant for image MIME
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhijeet6395 committed Feb 3, 2025
1 parent 430e687 commit d0d7d31
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,21 @@ internal class QRScannerActivity : AppCompatActivity() {
}
private val storagePermissionLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
if (granted) {
galleryLauncher.launch("image/*")
galleryLauncher.launch(IMAGE_MIME_TYPE)
} else {
onFailure(Exception("Storage permission required to select images"))
}
}
private fun launchGalleryPicker() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_MEDIA_IMAGES) == PackageManager.PERMISSION_GRANTED) {
galleryLauncher.launch("image/*")
galleryLauncher.launch(IMAGE_MIME_TYPE)
} else {
storagePermissionLauncher.launch(Manifest.permission.READ_MEDIA_IMAGES)
}
} else {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
galleryLauncher.launch("image/*")
galleryLauncher.launch(IMAGE_MIME_TYPE)
} else {
storagePermissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE)
}
Expand Down Expand Up @@ -284,6 +284,7 @@ internal class QRScannerActivity : AppCompatActivity() {
const val EXTRA_RESULT_TYPE = "quickie-type"
const val EXTRA_RESULT_PARCELABLE = "quickie-parcelable"
const val EXTRA_RESULT_EXCEPTION = "quickie-exception"
const val IMAGE_MIME_TYPE="image/*"
const val RESULT_MISSING_PERMISSION = RESULT_FIRST_USER + 1
const val RESULT_ERROR = RESULT_FIRST_USER + 2
}
Expand Down

0 comments on commit d0d7d31

Please sign in to comment.