bluetooth scan & connect UI rework

This commit is contained in:
andrekir 2022-05-03 12:16:44 -03:00
parent c3b6105730
commit ef9114ddc1
2 changed files with 102 additions and 86 deletions

View file

@ -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"}