mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: use MeshUser object as setOwner parameter
This commit is contained in:
parent
451a20d207
commit
2d9f0a56f2
5 changed files with 26 additions and 33 deletions
|
|
@ -125,7 +125,7 @@ fun DeviceSettingsItemList(viewModel: UIViewModel = viewModel()) {
|
|||
userInput = ourNodeInfo?.user
|
||||
}, onSaveClicked = {
|
||||
focusManager.clearFocus()
|
||||
userInput?.let { viewModel.setOwner(it.longName, it.shortName, it.isLicensed) }
|
||||
userInput?.let { viewModel.setOwner(it) }
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import com.geeksville.mesh.databinding.SettingsFragmentBinding
|
|||
import com.geeksville.mesh.model.BTScanModel
|
||||
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
|
||||
|
|
@ -169,7 +170,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
binding.provideLocationCheckbox.visibility = if (model.isConnected()) View.VISIBLE else View.GONE
|
||||
|
||||
if (connected == MeshService.ConnectionState.DISCONNECTED)
|
||||
model.setOwner("")
|
||||
binding.usernameEditText.setText("")
|
||||
|
||||
if (requireContext().hasGps()) {
|
||||
binding.provideLocationCheckbox.isEnabled = true
|
||||
|
|
@ -369,7 +370,10 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
binding.usernameEditText.onEditorAction(EditorInfo.IME_ACTION_DONE) {
|
||||
debug("received IME_ACTION_DONE")
|
||||
val n = binding.usernameEditText.text.toString().trim()
|
||||
if (n.isNotEmpty()) model.setOwner(n)
|
||||
model.ourNodeInfo.value?.user?.let {
|
||||
val user = it.copy(longName = n, shortName = getInitials(n))
|
||||
if (n.isNotEmpty()) model.setOwner(user)
|
||||
}
|
||||
requireActivity().hideKeyboard()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue