Skip to content

Commit d074c7b

Browse files
MHShettythestinger
authored andcommitted
Prevent specifying preview stabilization option for unsupported devices
(Video stabilization has two modes, ON and PREVIEW_STABILIZATION; the second one gets enabled when enabling preview stabilization which might not be supported on all devices)
1 parent 593e674 commit d074c7b

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

app/src/main/java/app/grapheneos/camera/CamConfig.kt

+12-3
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ class CamConfig(private val mActivity: MainActivity) {
441441

442442
var enableEIS: Boolean
443443
get() {
444-
return isStabilizationSupported() && mActivity.settingsDialog.enableEISToggle.isChecked
444+
return isVideoStabilizationSupported() && mActivity.settingsDialog.enableEISToggle.isChecked
445445
}
446446
set(value) {
447447
val editor = commonPref.edit()
@@ -557,7 +557,16 @@ class CamConfig(private val mActivity: MainActivity) {
557557
camera!!.cameraInfo.isZslSupported
558558
}
559559

560-
fun isStabilizationSupported() : Boolean {
560+
fun isVideoStabilizationSupported() : Boolean {
561+
return isRecorderStabilizationSupported()
562+
}
563+
564+
private fun isPreviewStabilizationSupported() : Boolean {
565+
return Preview.getPreviewCapabilities(getCurrentCameraInfo()).isStabilizationSupported
566+
}
567+
568+
569+
private fun isRecorderStabilizationSupported() : Boolean {
561570
return Recorder.getVideoCapabilities(getCurrentCameraInfo()).isStabilizationSupported
562571
}
563572

@@ -1196,7 +1205,7 @@ class CamConfig(private val mActivity: MainActivity) {
11961205
ResolutionSelector.Builder().setAspectRatioStrategy(aspectRatioStrategy).build()
11971206
)
11981207

1199-
if (isVideoMode) {
1208+
if (isVideoMode && isPreviewStabilizationSupported()) {
12001209
previewBuilder.setPreviewStabilizationEnabled(enableEIS)
12011210
}
12021211

app/src/main/java/app/grapheneos/camera/ui/SettingsDialog.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ class SettingsDialog(val mActivity: MainActivity) :
400400
includeAudioSetting.visibility = View.VISIBLE
401401
enableEISSetting.visibility = View.GONE
402402
videoQualitySetting.visibility = View.VISIBLE
403-
enableEISSetting.visibility = if (camConfig.isStabilizationSupported()) {
403+
enableEISSetting.visibility = if (camConfig.isVideoStabilizationSupported()) {
404404
View.VISIBLE
405405
} else {
406406
View.GONE

0 commit comments

Comments
 (0)