Auto stop vibrations after 10 seconds - 2.17 🚀

Closes #198
This commit is contained in:
Brandon Presley 2024-02-11 18:04:52 +13:00
parent ff365c791b
commit 57bc6caffb
3 changed files with 9 additions and 7 deletions

View File

@ -85,8 +85,8 @@ android {
applicationId "com.massive"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 36231
versionName "2.16"
versionCode 36232
versionName "2.17"
}
signingConfigs {
release {

View File

@ -122,16 +122,18 @@ class AlarmService : Service(), OnPreparedListener {
val settings = getSettings()
playSound(settings)
if (!settings.vibrate) return START_STICKY
val pattern = longArrayOf(0, settings.duration, 1300, settings.duration, 1300, settings.duration / 2)
val pattern = longArrayOf(0, settings.duration, 1000, settings.duration, 1000, settings.duration)
vibrator = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val vibratorManager =
getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager
val vibratorManager = getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager
vibratorManager.defaultVibrator
} else {
@Suppress("DEPRECATION")
getSystemService(VIBRATOR_SERVICE) as Vibrator
}
vibrator!!.vibrate(VibrationEffect.createWaveform(pattern, 1))
vibrator!!.vibrate(VibrationEffect.createWaveform(pattern, -1))
val handler = Handler(Looper.getMainLooper())
handler.postDelayed({ vibrator!!.cancel() }, 10000)
return START_STICKY
}

View File

@ -1,6 +1,6 @@
{
"name": "massive",
"version": "2.16",
"version": "2.17",
"private": true,
"license": "GPL-3.0-only",
"scripts": {