mirror of
https://github.com/MaintainTeam/LastPipeBender.git
synced 2025-03-01 05:48:22 +03:00
BraveNewPipeLegacy: (Kitkat) fix missing supportsSource() method in DeviceUtils
This commit is contained in:
parent
228c1d3681
commit
ff9a10d4e3
2 changed files with 19 additions and 5 deletions
|
@ -0,0 +1,12 @@
|
|||
package org.schabi.newpipe.util
|
||||
|
||||
import android.os.Build
|
||||
import android.view.InputDevice
|
||||
|
||||
fun supportsSource(inputDevice: InputDevice, source: Int): Boolean {
|
||||
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
(inputDevice.sources and source) == source
|
||||
} else {
|
||||
inputDevice.supportsSource(source)
|
||||
}
|
||||
}
|
|
@ -178,11 +178,13 @@ public final class DeviceUtils {
|
|||
final InputManager im = (InputManager) context.getSystemService(INPUT_SERVICE);
|
||||
for (final int id : im.getInputDeviceIds()) {
|
||||
final InputDevice inputDevice = im.getInputDevice(id);
|
||||
if (inputDevice.supportsSource(InputDevice.SOURCE_BLUETOOTH_STYLUS)
|
||||
|| inputDevice.supportsSource(InputDevice.SOURCE_MOUSE)
|
||||
|| inputDevice.supportsSource(InputDevice.SOURCE_STYLUS)
|
||||
|| inputDevice.supportsSource(InputDevice.SOURCE_TOUCHPAD)
|
||||
|| inputDevice.supportsSource(InputDevice.SOURCE_TRACKBALL)) {
|
||||
|
||||
if (BraveDeviceUtilsKt.supportsSource(inputDevice, InputDevice.SOURCE_BLUETOOTH_STYLUS)
|
||||
|| BraveDeviceUtilsKt.supportsSource(inputDevice, InputDevice.SOURCE_MOUSE)
|
||||
|| BraveDeviceUtilsKt.supportsSource(inputDevice, InputDevice.SOURCE_STYLUS)
|
||||
|| BraveDeviceUtilsKt.supportsSource(inputDevice, InputDevice.SOURCE_TOUCHPAD)
|
||||
|| BraveDeviceUtilsKt.supportsSource(inputDevice,
|
||||
InputDevice.SOURCE_TRACKBALL)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue