From 4b441290d56054a3e253c097bf079054961f9216 Mon Sep 17 00:00:00 2001 From: Sagar Date: Sat, 4 Jan 2025 10:19:39 +0530 Subject: [PATCH] Fixes #13853 --- .../securesms/mediasend/v2/MediaSelectionNavigator.kt | 7 +++++++ .../securesms/mediasend/v2/capture/MediaCaptureFragment.kt | 2 +- .../mediasend/v2/gallery/MediaSelectionGalleryFragment.kt | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/mediasend/v2/MediaSelectionNavigator.kt b/app/src/main/java/org/thoughtcrime/securesms/mediasend/v2/MediaSelectionNavigator.kt index 0209f2398b5..a2af3355eab 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mediasend/v2/MediaSelectionNavigator.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/mediasend/v2/MediaSelectionNavigator.kt @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.mediasend.v2 import android.Manifest import android.widget.Toast +import androidx.core.os.bundleOf import androidx.fragment.app.Fragment import androidx.navigation.NavController import org.thoughtcrime.securesms.R @@ -29,6 +30,12 @@ class MediaSelectionNavigator( navController.safeNavigate(toGallery) } + fun goToGalleryWithDisabledCamera(navController: NavController) { + if (toGallery == -1) return + + navController.safeNavigate(toGallery, bundleOf("isCameraEnabled" to false)) + } + companion object { fun Fragment.requestPermissionsForCamera( onGranted: () -> Unit diff --git a/app/src/main/java/org/thoughtcrime/securesms/mediasend/v2/capture/MediaCaptureFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/mediasend/v2/capture/MediaCaptureFragment.kt index ec9690a67d1..77357ea2d46 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mediasend/v2/capture/MediaCaptureFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/mediasend/v2/capture/MediaCaptureFragment.kt @@ -169,7 +169,7 @@ class MediaCaptureFragment : Fragment(R.layout.fragment_container), CameraFragme override fun onGalleryClicked() { val controller = findNavController() captureChildFragment.fadeOutControls { - navigator.goToGallery(controller) + navigator.goToGalleryWithDisabledCamera(controller) } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/mediasend/v2/gallery/MediaSelectionGalleryFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/mediasend/v2/gallery/MediaSelectionGalleryFragment.kt index 569126564ed..92c258a772c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mediasend/v2/gallery/MediaSelectionGalleryFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/mediasend/v2/gallery/MediaSelectionGalleryFragment.kt @@ -129,6 +129,10 @@ class MediaSelectionGalleryFragment : Fragment(R.layout.fragment_container), Med navigator.goToReview(findNavController()) } + override fun isCameraEnabled(): Boolean { + return arguments?.getBoolean("isCameraEnabled") ?: super.isCameraEnabled() + } + override fun onNavigateToCamera() { val controller = findNavController() requestPermissionsForCamera {