Skip to content

Commit

Permalink
Enable both use-cases if available.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-signal committed Aug 26, 2022
1 parent fae2cea commit 51647a5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Material3SearchToolbar @JvmOverloads constructor(
}

fun clearText() {
input.setText("");
input.setText("")
}

interface Listener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class MainActivityListHostFragment : Fragment(R.layout.main_activity_list_host_f

override fun onSearchOpened() {
conversationListTabsViewModel.onSearchOpened()
_searchToolbar.get().clearText();
_searchToolbar.get().clearText()
}

override fun onSearchClosed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
cameraController.setCameraSelector(CameraXUtil.toCameraSelector(TextSecurePreferences.getDirectCaptureCameraId(requireContext())));
cameraController.setTapToFocusEnabled(true);
cameraController.setImageCaptureMode(CameraXUtil.getOptimalCaptureMode());
cameraController.setEnabledUseCases(CameraController.IMAGE_CAPTURE);
cameraController.setEnabledUseCases(getSupportedUseCases());

previewView.setScaleType(PreviewView.ScaleType.FIT_CENTER);
previewView.setController(cameraController);
Expand Down Expand Up @@ -378,6 +378,15 @@ public void onVideoError(@Nullable Throwable cause) {
}
}

@CameraController.UseCases
private int getSupportedUseCases() {
if (isVideoRecordingSupported(requireContext())) {
return CameraController.IMAGE_CAPTURE | CameraController.VIDEO_CAPTURE;
} else {
return CameraController.IMAGE_CAPTURE;
}
}

private boolean isVideoRecordingSupported(@NonNull Context context) {
return Build.VERSION.SDK_INT >= 26 &&
requireArguments().getBoolean(IS_VIDEO_ENABLED, true) &&
Expand Down Expand Up @@ -445,7 +454,6 @@ private void onCaptureClicked() {
selfieFlash
);

cameraController.setEnabledUseCases(CameraController.IMAGE_CAPTURE);
cameraController.takePicture(Executors.mainThreadExecutor(), new ImageCapture.OnImageCapturedCallback() {
@Override
public void onCaptureSuccess(@NonNull ImageProxy image) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ private void beginCameraRecording() {

OutputFileOptions options = OutputFileOptions.builder(memoryFileDescriptor.getParcelFileDescriptor()).build();

cameraController.setEnabledUseCases(CameraController.VIDEO_CAPTURE);
cameraController.startRecording(options, Executors.mainThreadExecutor(), videoSavedListener);
updateProgressAnimator.start();
debouncer.publish(this::onVideoCaptureComplete);
Expand Down Expand Up @@ -190,7 +189,6 @@ public void onVideoCaptureComplete() {

Log.d(TAG, "onVideoCaptureComplete");
cameraController.stopRecording();
cameraController.setEnabledUseCases(CameraController.IMAGE_CAPTURE);

if (cameraMetricsAnimator != null && cameraMetricsAnimator.isRunning()) {
cameraMetricsAnimator.reverse();
Expand Down

0 comments on commit 51647a5

Please sign in to comment.