Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent specifying preview stabilization option for unsupported devices #462

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions app/src/main/java/app/grapheneos/camera/CamConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ class CamConfig(private val mActivity: MainActivity) {

var enableEIS: Boolean
get() {
return isStabilizationSupported() && mActivity.settingsDialog.enableEISToggle.isChecked
return isVideoStabilizationSupported() && mActivity.settingsDialog.enableEISToggle.isChecked
}
set(value) {
val editor = commonPref.edit()
Expand Down Expand Up @@ -557,7 +557,16 @@ class CamConfig(private val mActivity: MainActivity) {
camera!!.cameraInfo.isZslSupported
}

fun isStabilizationSupported() : Boolean {
fun isVideoStabilizationSupported() : Boolean {
return isRecorderStabilizationSupported()
}

private fun isPreviewStabilizationSupported() : Boolean {
return Preview.getPreviewCapabilities(getCurrentCameraInfo()).isStabilizationSupported
}


private fun isRecorderStabilizationSupported() : Boolean {
return Recorder.getVideoCapabilities(getCurrentCameraInfo()).isStabilizationSupported
}

Expand Down Expand Up @@ -1196,7 +1205,7 @@ class CamConfig(private val mActivity: MainActivity) {
ResolutionSelector.Builder().setAspectRatioStrategy(aspectRatioStrategy).build()
)

if (isVideoMode) {
if (isVideoMode && isPreviewStabilizationSupported()) {
previewBuilder.setPreviewStabilizationEnabled(enableEIS)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ class SettingsDialog(val mActivity: MainActivity) :
includeAudioSetting.visibility = View.VISIBLE
enableEISSetting.visibility = View.GONE
videoQualitySetting.visibility = View.VISIBLE
enableEISSetting.visibility = if (camConfig.isStabilizationSupported()) {
enableEISSetting.visibility = if (camConfig.isVideoStabilizationSupported()) {
View.VISIBLE
} else {
View.GONE
Expand Down