Continued work on #369: Inject radio interface implementations (#481)

This required creation of new interfaces in order to break the
static coupling.  This also allowed for the removal of some plumbing
of dependencies of these implementations since they are now directly
injected.
This commit is contained in:
Mike Cumings 2023-10-24 12:09:18 -07:00 committed by GitHub
parent 121376201d
commit a7b0d70c03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 370 additions and 220 deletions

View file

@ -29,13 +29,10 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.asLiveData
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.geeksville.mesh.analytics.DataPair
import com.geeksville.mesh.android.GeeksvilleApplication
import com.geeksville.mesh.android.Logging
import com.geeksville.mesh.android.hideKeyboard
import com.geeksville.mesh.ConfigProtos
import com.geeksville.mesh.MainActivity
import com.geeksville.mesh.R
import com.geeksville.mesh.ConfigProtos
import com.geeksville.mesh.analytics.DataPair
import com.geeksville.mesh.ModuleConfigProtos
import com.geeksville.mesh.android.*
import com.geeksville.mesh.databinding.SettingsFragmentBinding
@ -44,8 +41,7 @@ import com.geeksville.mesh.model.BluetoothViewModel
import com.geeksville.mesh.model.UIViewModel
import com.geeksville.mesh.model.getInitials
import com.geeksville.mesh.repository.location.LocationRepository
import com.geeksville.mesh.repository.radio.MockInterface
import com.geeksville.mesh.repository.usb.UsbRepository
import com.geeksville.mesh.repository.radio.RadioInterfaceService
import com.geeksville.mesh.service.MeshService
import com.geeksville.mesh.service.SoftwareUpdateService
import com.geeksville.mesh.util.PendingIntentCompat
@ -71,7 +67,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
private val model: UIViewModel by activityViewModels()
@Inject
internal lateinit var usbRepository: UsbRepository
internal lateinit var radioInterfaceServiceLazy: dagger.Lazy<RadioInterfaceService>
@Inject
internal lateinit var locationRepository: LocationRepository
@ -506,7 +502,8 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
// If we are running on an emulator, always leave this message showing so we can test the worst case layout
val curRadio = scanModel.selectedAddress
if (curRadio != null && !MockInterface.addressValid(requireContext(), usbRepository, "")) {
val radioInterfaceService = radioInterfaceServiceLazy.get()
if (curRadio != null && !radioInterfaceService.isAddressValid(radioInterfaceService.mockInterfaceAddress)) {
binding.warningNotPaired.visibility = View.GONE
} else if (bluetoothViewModel.enabled.value == true) {
binding.warningNotPaired.visibility = View.VISIBLE