mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
bluetooth scan & connect UI rework
This commit is contained in:
parent
c3b6105730
commit
ef9114ddc1
2 changed files with 102 additions and 86 deletions
|
|
@ -10,6 +10,8 @@ import android.content.pm.PackageManager
|
|||
import android.hardware.usb.UsbManager
|
||||
import android.os.Build
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.geeksville.android.GeeksvilleApplication
|
||||
import com.geeksville.mesh.MainActivity
|
||||
|
||||
/**
|
||||
* @return null on platforms without a BlueTooth driver (i.e. the emulator)
|
||||
|
|
@ -18,8 +20,11 @@ val Context.bluetoothManager: BluetoothManager? get() = getSystemService(Context
|
|||
|
||||
val Context.deviceManager: CompanionDeviceManager?
|
||||
@SuppressLint("InlinedApi")
|
||||
get() = if (hasCompanionDeviceApi()) getSystemService(Context.COMPANION_DEVICE_SERVICE) as? CompanionDeviceManager?
|
||||
else null
|
||||
get() {
|
||||
val activity: MainActivity? = GeeksvilleApplication.currentActivity as MainActivity?
|
||||
return if (hasCompanionDeviceApi()) activity?.getSystemService(Context.COMPANION_DEVICE_SERVICE) as? CompanionDeviceManager?
|
||||
else null
|
||||
}
|
||||
|
||||
val Context.usbManager: UsbManager get() = requireNotNull(getSystemService(Context.USB_SERVICE) as? UsbManager?) { "USB_SERVICE is not available"}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue