Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Camera not opened even if the permission is granted #4609

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -80,7 +80,7 @@ class EnvironmentProductFragment : BaseFragment() {
super.onViewCreated(view, savedInstanceState)
val langCode = localeManager.getLanguage()
productState = requireProductState()
binding.imageViewPackaging.setOnClickListener { openFullScreen() }
binding.imageViewPackaging.setOnClickListener { openFullScreenImage() }

// If Battery Level is low and the user has checked the Disable Image in Preferences , then set isLowBatteryMode to true
if (requireContext().isDisableImageLoad() && requireContext().isBatteryLevelLow()) {
Expand Down Expand Up @@ -172,7 +172,7 @@ class EnvironmentProductFragment : BaseFragment() {
refreshTagsPrompt()
}

private fun openFullScreen() {
private fun openFullScreenImage() {
val imageUrl = mUrlImage
val product = productState.product
if (imageUrl != null && product != null) {
Expand All @@ -194,6 +194,8 @@ class EnvironmentProductFragment : BaseFragment() {

private fun newPackagingImage() = doChooseOrTakePhotos()

override fun doOnPhotosPermissionGranted() = doChooseOrTakePhotos()

private fun loadPackagingPhoto(photoFile: File) {
// Create a new instance of ProductImage so we can load to server
val image = ProductImage(productState.product!!.code, ProductImageField.PACKAGING, photoFile, localeManager.getLanguage())
Expand Down
Expand Up @@ -93,10 +93,9 @@ abstract class BaseFragment : Fragment(), SwipeRefreshLayout.OnRefreshListener,
protected fun doChooseOrTakePhotos() {
if (canTakePhotos()) {
EasyImage.openCamera(this, 0)
return
} else {
cameraPermissionRequestLauncher.launch(Manifest.permission.CAMERA)
}
// Ask for permissions
cameraPermissionRequestLauncher.launch(Manifest.permission.CAMERA)
}

protected open fun doOnPhotosPermissionGranted() = Unit
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/fragment_environment_product.xml
Expand Up @@ -22,7 +22,6 @@
android:orientation="vertical"
android:paddingBottom="@dimen/nav_bar_height">


<openfoodfacts.github.scrachx.openfood.features.shared.views.TipBox
android:id="@+id/packagingImagetipBox"
android:layout_width="match_parent"
Expand Down