Skip to content

Commit b8253b8

Browse files
committed
moving logic behing FF
1 parent 7635433 commit b8253b8

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

sync/sync-impl/src/main/java/com/duckduckgo/sync/impl/SyncFeature.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,7 @@ interface SyncFeature {
5353

5454
@Toggle.DefaultValue(true)
5555
fun automaticallyUpdateSyncSettings(): Toggle
56+
57+
@Toggle.DefaultValue(true)
58+
fun qrCodeScannerHints(): Toggle
5659
}

sync/sync-impl/src/main/java/com/duckduckgo/sync/impl/ui/qrcode/SyncBarcodeView.kt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import com.duckduckgo.common.utils.ConflatedJob
4242
import com.duckduckgo.common.utils.DispatcherProvider
4343
import com.duckduckgo.di.scopes.ViewScope
4444
import com.duckduckgo.sync.impl.R
45+
import com.duckduckgo.sync.impl.SyncFeature
4546
import com.duckduckgo.sync.impl.databinding.ViewSquareDecoratedBarcodeBinding
4647
import com.duckduckgo.sync.impl.ui.qrcode.SquareDecoratedBarcodeViewModel.Command
4748
import com.duckduckgo.sync.impl.ui.qrcode.SquareDecoratedBarcodeViewModel.Command.CheckCameraAvailable
@@ -80,6 +81,9 @@ constructor(
8081
@Inject
8182
lateinit var appBuildConfig: AppBuildConfig
8283

84+
@Inject
85+
lateinit var syncFeature: SyncFeature
86+
8387
private val cameraBlockedDrawable by lazy {
8488
ContextCompat.getDrawable(context, R.drawable.camera_blocked)
8589
}
@@ -95,6 +99,7 @@ constructor(
9599
}
96100

97101
private var beepManager: BeepManager? = null
102+
98103
private val cameraSettings = CameraSettings().apply {
99104
isAutoFocusEnabled = true
100105
isContinuousFocusEnabled = true
@@ -103,17 +108,12 @@ constructor(
103108
private val conflatedStateJob = ConflatedJob()
104109
private val conflatedCommandJob = ConflatedJob()
105110

106-
init {
107-
if (appBuildConfig.isInternalBuild()) {
108-
beepManager = BeepManager(getActivity())
109-
}
110-
initQRScanner()
111-
}
112-
113111
override fun onAttachedToWindow() {
114112
AndroidSupportInjection.inject(this)
115113
super.onAttachedToWindow()
116114

115+
initQRScanner()
116+
117117
findViewTreeLifecycleOwner()?.lifecycle?.addObserver(viewModel)
118118

119119
val scope = findViewTreeLifecycleOwner()?.lifecycleScope!!
@@ -132,8 +132,13 @@ constructor(
132132
}
133133

134134
private fun initQRScanner() {
135-
binding.barcodeView.cameraSettings = cameraSettings
136-
binding.barcodeView.decoderFactory = DefaultDecoderFactory(listOf(QR_CODE))
135+
if (syncFeature.qrCodeScannerHints().isEnabled()) {
136+
if (appBuildConfig.isInternalBuild()) {
137+
beepManager = BeepManager(getActivity())
138+
}
139+
binding.barcodeView.cameraSettings = cameraSettings
140+
binding.barcodeView.decoderFactory = DefaultDecoderFactory(listOf(QR_CODE))
141+
}
137142
}
138143

139144
override fun onDetachedFromWindow() {

0 commit comments

Comments
 (0)