From 1f3b7299257fa7e5e90d0b1d1a9a1011b1c2ddc6 Mon Sep 17 00:00:00 2001 From: Siqi Zhao <77391690+Z-Siqi@users.noreply.github.com> Date: Thu, 21 Nov 2024 17:40:54 +0800 Subject: [PATCH] Try to fix CI Failed [Added system version check to clickFeedback] --- .../checklist/ui/main/backup/BackupAndRestoreLayout.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/sqz/checklist/ui/main/backup/BackupAndRestoreLayout.kt b/app/src/main/java/com/sqz/checklist/ui/main/backup/BackupAndRestoreLayout.kt index c3700c6..c9a04e2 100644 --- a/app/src/main/java/com/sqz/checklist/ui/main/backup/BackupAndRestoreLayout.kt +++ b/app/src/main/java/com/sqz/checklist/ui/main/backup/BackupAndRestoreLayout.kt @@ -3,6 +3,7 @@ package com.sqz.checklist.ui.main.backup import android.content.Context import android.media.AudioManager import android.net.Uri +import android.os.Build import android.os.VibrationEffect import android.os.Vibrator import android.util.Log @@ -242,9 +243,11 @@ private fun TitleText(text: String, modifier: Modifier = Modifier) = Text( ) private fun clickFeedback(view: View, audioManager: AudioManager) { - if (audioManager.ringerMode == AudioManager.RINGER_MODE_VIBRATE) { - val vibrate = view.context?.let { getSystemService(it, Vibrator::class.java) } - vibrate?.vibrate(VibrationEffect.createPredefined(VibrationEffect.EFFECT_TICK)) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + if (audioManager.ringerMode == AudioManager.RINGER_MODE_VIBRATE) { + val vibrate = view.context?.let { getSystemService(it, Vibrator::class.java) } + vibrate?.vibrate(VibrationEffect.createPredefined(VibrationEffect.EFFECT_TICK)) + } else view.playSoundEffect(SoundEffectConstants.CLICK) } else { view.playSoundEffect(SoundEffectConstants.CLICK) }