kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
update common ui logic
rodzic
dd4fbc12d5
commit
b95dcbb26e
|
@ -26,7 +26,6 @@ import android.widget.Toast
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.AndroidViewModel
|
import androidx.lifecycle.AndroidViewModel
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.Observer
|
|
||||||
import com.geeksville.android.GeeksvilleApplication
|
import com.geeksville.android.GeeksvilleApplication
|
||||||
import com.geeksville.android.Logging
|
import com.geeksville.android.Logging
|
||||||
import com.geeksville.android.hideKeyboard
|
import com.geeksville.android.hideKeyboard
|
||||||
|
@ -335,7 +334,7 @@ class BTScanModel(app: Application) : AndroidViewModel(app), Logging {
|
||||||
*/
|
*/
|
||||||
override fun onInactive() {
|
override fun onInactive() {
|
||||||
super.onInactive()
|
super.onInactive()
|
||||||
stopScan()
|
// stopScan()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,16 +620,18 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Only let user edit their name or set software update while connected to a radio
|
// Only let user edit their name or set software update while connected to a radio
|
||||||
model.isConnected.observe(viewLifecycleOwner, Observer { _ ->
|
model.isConnected.observe(
|
||||||
|
viewLifecycleOwner, {
|
||||||
updateNodeInfo()
|
updateNodeInfo()
|
||||||
|
updateDevicesButtons(scanModel.devices.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Also watch myNodeInfo because it might change later
|
// Also watch myNodeInfo because it might change later
|
||||||
model.myNodeInfo.observe(viewLifecycleOwner, Observer {
|
model.myNodeInfo.observe(viewLifecycleOwner, {
|
||||||
updateNodeInfo()
|
updateNodeInfo()
|
||||||
})
|
})
|
||||||
|
|
||||||
scanModel.errorText.observe(viewLifecycleOwner, Observer { errMsg ->
|
scanModel.errorText.observe(viewLifecycleOwner, { errMsg ->
|
||||||
if (errMsg != null) {
|
if (errMsg != null) {
|
||||||
binding.scanStatusText.text = errMsg
|
binding.scanStatusText.text = errMsg
|
||||||
}
|
}
|
||||||
|
@ -638,11 +639,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
|
|
||||||
scanModel.devices.observe(
|
scanModel.devices.observe(
|
||||||
viewLifecycleOwner,
|
viewLifecycleOwner,
|
||||||
Observer { devices -> updateDevicesButtons(devices) })
|
{ devices -> updateDevicesButtons(devices) })
|
||||||
|
|
||||||
model.isConnected.observe(
|
|
||||||
viewLifecycleOwner,
|
|
||||||
{ updateDevicesButtons(scanModel.devices.value) })
|
|
||||||
|
|
||||||
binding.updateFirmwareButton.setOnClickListener {
|
binding.updateFirmwareButton.setOnClickListener {
|
||||||
doFirmwareUpdate()
|
doFirmwareUpdate()
|
||||||
|
@ -791,22 +788,15 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val hasBonded =
|
|
||||||
RadioInterfaceService.getBondedDeviceAddress(requireContext()) != null
|
|
||||||
|
|
||||||
// get rid of the warning text once at least one device is paired.
|
// get rid of the warning text once at least one device is paired.
|
||||||
// If we are running on an emulator, always leave this message showing so we can test the worst case layout
|
// If we are running on an emulator, always leave this message showing so we can test the worst case layout
|
||||||
binding.warningNotPaired.visibility =
|
|
||||||
if (hasBonded && !MockInterface.addressValid(requireContext(), ""))
|
|
||||||
View.GONE
|
|
||||||
else
|
|
||||||
View.VISIBLE
|
|
||||||
|
|
||||||
val curRadio = RadioInterfaceService.getBondedDeviceAddress(requireContext())
|
val curRadio = RadioInterfaceService.getBondedDeviceAddress(requireContext())
|
||||||
|
|
||||||
if (curRadio != null) {
|
if (curRadio != null && !MockInterface.addressValid(requireContext(), "")) {
|
||||||
|
binding.warningNotPaired.visibility = View.GONE
|
||||||
binding.scanStatusText.text = getString(R.string.current_pair).format(curRadio)
|
binding.scanStatusText.text = getString(R.string.current_pair).format(curRadio)
|
||||||
} else {
|
} else {
|
||||||
|
binding.warningNotPaired.visibility = View.VISIBLE
|
||||||
binding.scanStatusText.text = getString(R.string.not_paired_yet)
|
binding.scanStatusText.text = getString(R.string.not_paired_yet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue