Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Sagar0-0 committed Jan 4, 2025
1 parent ba79a3e commit 4b44129
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4b44129

Please sign in to comment.