Skip to content

Commit

Permalink
feat : QR 인식 시 진동 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
HamBP committed Jan 7, 2025
1 parent 7ec1ca2 commit dcb34f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions presentation/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.VIBRATE" />

</manifest>
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit dcb34f1

Please sign in to comment.