Add toast when long pressing camera button and video is not supported.

This commit is contained in:
Alex Hart
2023-04-14 13:53:16 -03:00
committed by Cody Henthorne
parent 3090a8521c
commit 0b21481539
5 changed files with 22 additions and 5 deletions

View File

@@ -337,6 +337,11 @@ public class Camera1Fragment extends LoggingFragment implements CameraFragment,
onCaptureClicked();
});
captureButton.setOnLongClickListener(unused -> {
CameraFragment.toastVideoRecordingNotAvailable(requireContext());
return true;
});
orderEnforcer.run(Stage.CAMERA_PROPERTIES_AVAILABLE, () -> {
if (properties.getCameraCount() > 1) {
flipButton.setVisibility(properties.getCameraCount() > 1 ? View.VISIBLE : View.GONE);

View File

@@ -186,11 +186,6 @@ public class CameraButtonView extends View {
canvas.drawArc(progressRect, 270f, 360f * progressPercent, false, progressPaint);
}
@Override
public void setOnLongClickListener(@Nullable OnLongClickListener listener) {
throw new IllegalStateException("Use setVideoCaptureListener instead");
}
public void setVideoCaptureListener(@Nullable VideoCaptureListener videoCaptureListener) {
if (isRecordingVideo) throw new IllegalStateException("Cannot set video capture listener while recording");

View File

@@ -1,14 +1,17 @@
package org.thoughtcrime.securesms.mediasend;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Configuration;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.camera.view.video.ExperimentalVideo;
import androidx.fragment.app.Fragment;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.mediasend.camerax.CameraXUtil;
import org.thoughtcrime.securesms.mms.MediaConstraints;
@@ -47,6 +50,11 @@ public interface CameraFragment {
}
}
static void toastVideoRecordingNotAvailable(@NonNull Context context) {
Toast.makeText(context, R.string.CameraFragment__video_recording_is_not_supported_on_your_device, Toast.LENGTH_SHORT)
.show();
}
void presentHud(int selectedMediaCount);
void fadeOutControls(@NonNull Runnable onEndAction);
void fadeInControls();

View File

@@ -398,6 +398,11 @@ public class CameraXFragment extends LoggingFragment implements CameraFragment {
Log.w(TAG, "Video capture is not supported on this device.", e);
}
} else {
captureButton.setOnLongClickListener(unused -> {
CameraFragment.toastVideoRecordingNotAvailable(requireContext());
return true;
});
Log.i(TAG, "Video capture not supported. " +
"API: " + Build.VERSION.SDK_INT + ", " +
"MFD: " + MemoryFileDescriptor.supported() + ", " +