mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Issue #369 - Expand bluetooth repository use cases
Changes:
- Adds support for obtaining bonded devices
- Adds support for obtaining BLE scanner
- Consolidates state into a single, immutable data class instance
- Simplified and renamed broadcast receiver
- Renamed view model permissionsUpdated fun to identify the intended use
(cherry picked from commit 9592fd68de)
This commit is contained in:
parent
c0fe9213f1
commit
49188adc36
7 changed files with 99 additions and 44 deletions
|
|
@ -4,6 +4,7 @@ import androidx.lifecycle.ViewModel
|
|||
import androidx.lifecycle.asLiveData
|
||||
import com.geeksville.mesh.repository.bluetooth.BluetoothRepository
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.map
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
|
|
@ -13,7 +14,11 @@ import javax.inject.Inject
|
|||
class BluetoothViewModel @Inject constructor(
|
||||
private val bluetoothRepository: BluetoothRepository,
|
||||
) : ViewModel() {
|
||||
fun refreshState() = bluetoothRepository.refreshState()
|
||||
/**
|
||||
* Called when permissions have been updated. This causes an explicit refresh of the
|
||||
* bluetooth state.
|
||||
*/
|
||||
fun permissionsUpdated() = bluetoothRepository.refreshState()
|
||||
|
||||
val enabled = bluetoothRepository.enabled.asLiveData()
|
||||
val enabled = bluetoothRepository.state.map { it.enabled }.asLiveData()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue