From 865143c5448e671f4a74192cc5bbb59861143bb4 Mon Sep 17 00:00:00 2001 From: CraZyLegenD Date: Mon, 4 Jan 2021 16:20:27 +0100 Subject: [PATCH] fix: edge to edge padding bottom inclusion --- .../kotlinextensions/effects/Vibration.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/effects/Vibration.kt b/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/effects/Vibration.kt index c82beb7f9..de3a5b8dc 100644 --- a/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/effects/Vibration.kt +++ b/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/effects/Vibration.kt @@ -29,6 +29,19 @@ fun Context.vibrate(milliseconds: Long) { } } +/** + * Vibrate from context with milliseconds + */ +@RequiresPermission(allOf = [VIBRATE]) +fun Context.vibrate(milliseconds: Long, effect: Int? = null) { + if (Build.VERSION.SDK_INT >= 26) { + (getSystemService(VIBRATOR_SERVICE) as Vibrator).vibrate(VibrationEffect.createOneShot(milliseconds, + effect ?: VibrationEffect.DEFAULT_AMPLITUDE)) + } else { + (getSystemService(VIBRATOR_SERVICE) as Vibrator).vibrate(milliseconds) + } +} + /** * Check whether device has Vibrator