Skip to content

Commit

Permalink
fix: Get rid of unnecessary disableAF setting
Browse files Browse the repository at this point in the history
  • Loading branch information
feelfreelinux committed Jul 14, 2024
1 parent 5f55b93 commit ed15936
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 27 deletions.
8 changes: 1 addition & 7 deletions app/app/src/main/java/com/octo4a/camera/CameraService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,7 @@ class CameraService : LifecycleService(), MJpegFrameProvider {
getCameraControl()?.apply {
val control = Camera2CameraControl.from(this)
val ext = CaptureRequestOptions.Builder()
if (_cameraSettings.disableAF) {
ext.setCaptureRequestOption(
CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_OFF)
ext.setCaptureRequestOption(
CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL)
ext.setCaptureRequestOption(CaptureRequest.LENS_FOCUS_DISTANCE, 0f)
} else if (_cameraSettings.manualAF) {
if (_cameraSettings.manualAF) {
ext.setCaptureRequestOption(
CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_OFF)
ext.setCaptureRequestOption(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import com.google.android.material.slider.Slider.OnSliderTouchListener
import com.octo4a.R
import com.octo4a.camera.CameraService
import com.octo4a.repository.LoggerRepository
import com.octo4a.utils.isServiceRunning
import com.octo4a.utils.preferences.MainPreferences
import kotlinx.android.synthetic.main.dialog_camera_preview.manualFocusCheckbox
import kotlinx.android.synthetic.main.dialog_camera_preview.manualFocusSlider
Expand Down
12 changes: 2 additions & 10 deletions app/app/src/main/java/com/octo4a/ui/fragments/SettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
private val flashWhenObserved by lazy { findPreference<SwitchPreferenceCompat>("flashWhenObserved") }
private val installPluginExtras by lazy { findPreference<Preference>("installPluginExtras") }
private val imageRotation by lazy { findPreference<ListPreference>("imageRotation") }
private val disableAF by lazy { findPreference<SwitchPreferenceCompat>("disableAF") }
private val manualAF by lazy { findPreference<SwitchPreferenceCompat>("manualAF") }
private val enableBugReporting by lazy { findPreference<SwitchPreferenceCompat>("enableBugReporting") }

Expand Down Expand Up @@ -237,22 +236,15 @@ class SettingsFragment : PreferenceFragmentCompat() {
prefs.selectedVideoResolution = selectedResolution?.readableString()
}

disableAF?.apply {
manualAF?.apply {
setOnPreferenceChangeListener { _, newValue ->
prefs.disableAF = newValue as Boolean
prefs.manualAF = newValue as Boolean
stopCameraServer()
startCameraServer()
true
}
}

disableAF?.isVisible = disableAF!!.isVisible && !prefs.manualAF

manualAF?.setOnPreferenceChangeListener { _, newValue ->
disableAF?.isVisible = !(newValue as Boolean)
true
}

selectedCameraPref?.apply {
// Set values and descriptions
entries = cameras.map { it.describeString() }.toTypedArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class MainPreferences(context: Context) : Preferences(context, true) {
var selectedResolution by stringPref()
var selectedVideoResolution by stringPref()
var enableSSH by booleanPref(defaultValue = false)
var disableAF by booleanPref(defaultValue = false)
var manualAF by booleanPref(defaultValue = false)
var manualAFValue by floatPref(defaultValue = 0f)
var changeSSHPassword by stringPref()
Expand Down
9 changes: 1 addition & 8 deletions app/app/src/main/res/xml/main_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,8 @@
app:key="manualAF"
app:dependency="enableCameraServer"
app:defaultValue="false"
app:title="Manual autofocus"
app:title="Manual camera focus"
app:summary="Adjust in the camera preview dialog."/>
<SwitchPreferenceCompat
app:iconSpaceReserved="false"
app:key="disableAF"
app:dependency="enableCameraServer"
app:defaultValue="false"
app:title="Disable autofocus"
app:summary="Disables camera autofocus"/>
</PreferenceCategory>


Expand Down

0 comments on commit ed15936

Please sign in to comment.