diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index ad4f4ba0..a7cb6c9a 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -2,5 +2,6 @@ + \ No newline at end of file diff --git a/presentation/src/main/java/com/nexters/boolti/presentation/QrScanActivity.kt b/presentation/src/main/java/com/nexters/boolti/presentation/QrScanActivity.kt index d892d373..d987da43 100644 --- a/presentation/src/main/java/com/nexters/boolti/presentation/QrScanActivity.kt +++ b/presentation/src/main/java/com/nexters/boolti/presentation/QrScanActivity.kt @@ -1,7 +1,12 @@ package com.nexters.boolti.presentation import android.Manifest +import android.content.Context +import android.os.Build import android.os.Bundle +import android.os.VibrationEffect +import android.os.Vibrator +import android.os.VibratorManager import android.view.KeyEvent import androidx.activity.ComponentActivity import androidx.activity.compose.setContent @@ -40,6 +45,21 @@ class QrScanActivity : ComponentActivity() { private val callback = BarcodeCallback { result: BarcodeResult -> result.text ?: return@BarcodeCallback viewModel.scan(result.text) + + val vibrator = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + (getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager).defaultVibrator + } else { + getSystemService(Context.VIBRATOR_SERVICE) as Vibrator + } + + vibrator.vibrate( + VibrationEffect.createOneShot( + 100, + VibrationEffect.DEFAULT_AMPLITUDE + ) + ) + lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { barcodeView.pause()