@@ -18,9 +18,9 @@ import android.view.animation.Animation
18
18
import android.view.animation.LinearInterpolator
19
19
import android.widget.Button
20
20
import androidx.annotation.StringRes
21
- import androidx.camera.camera2.interop.Camera2Interop
22
21
import androidx.camera.core.AspectRatio
23
22
import androidx.camera.core.Camera
23
+ import androidx.camera.core.CameraInfo
24
24
import androidx.camera.core.CameraSelector
25
25
import androidx.camera.core.ImageAnalysis
26
26
import androidx.camera.core.ImageCapture
@@ -429,7 +429,7 @@ class CamConfig(private val mActivity: MainActivity) {
429
429
430
430
var enableEIS: Boolean
431
431
get() {
432
- return mActivity.settingsDialog.enableEISToggle.isChecked
432
+ return isStabilizationSupported() && mActivity.settingsDialog.enableEISToggle.isChecked
433
433
}
434
434
set(value) {
435
435
val editor = commonPref.edit()
@@ -532,6 +532,10 @@ class CamConfig(private val mActivity: MainActivity) {
532
532
camera!! .cameraInfo.isZslSupported
533
533
}
534
534
535
+ fun isStabilizationSupported () : Boolean {
536
+ return Recorder .getVideoCapabilities(getCurrentConfigCameraInfo()!! ).isStabilizationSupported
537
+ }
538
+
535
539
fun shouldShowGyroscope (): Boolean {
536
540
return isInPhotoMode && gSuggestions
537
541
}
@@ -894,6 +898,14 @@ class CamConfig(private val mActivity: MainActivity) {
894
898
startCamera(true )
895
899
}
896
900
901
+ // Will always return a valid CameraInfo if called within startCamera
902
+ private fun getCurrentConfigCameraInfo () : CameraInfo ? {
903
+ for (cameraInfo in cameraProvider!! .availableCameraInfos) {
904
+ if (cameraInfo.lensFacing == lensFacing) return cameraInfo
905
+ }
906
+ return null
907
+ }
908
+
897
909
fun toggleCameraSelector () {
898
910
899
911
// Manually switch to the opposite lens facing
@@ -1111,7 +1123,6 @@ class CamConfig(private val mActivity: MainActivity) {
1111
1123
ResolutionSelector .Builder ().setAspectRatioStrategy(aspectRatioStrategy).build()
1112
1124
)
1113
1125
1114
- @androidx.camera.camera2.interop.ExperimentalCamera2Interop
1115
1126
if (isVideoMode) {
1116
1127
previewBuilder.setPreviewStabilizationEnabled(enableEIS)
1117
1128
}
0 commit comments