-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/360 입장 확인 고도화 #363
base: develop
Are you sure you want to change the base?
Changes from all commits
055ab2a
4fd32ca
7ec1ca2
dcb34f1
61eb6ec
aab014f
8a36250
29514c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
package com.nexters.boolti.presentation | ||
|
||
import android.Manifest | ||
import android.content.Context | ||
import android.hardware.Camera | ||
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 | ||
|
@@ -24,6 +30,7 @@ import kotlinx.coroutines.launch | |
|
||
@AndroidEntryPoint | ||
class QrScanActivity : ComponentActivity() { | ||
var isBackCamera = true | ||
|
||
private val barcodeView: DecoratedBarcodeView by lazy { | ||
DecoratedBarcodeView(this).apply { | ||
|
@@ -40,6 +47,21 @@ class QrScanActivity : ComponentActivity() { | |
private val callback = BarcodeCallback { result: BarcodeResult -> | ||
result.text ?: return@BarcodeCallback | ||
viewModel.scan(result.text) | ||
|
||
val vibrator = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추후에 진동 요구사항이 또 들어오면 확장으로 만들어도 좋을 듯 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 반영하겠슴당 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 급한건 아니었는데 여유 있으면 해줘! |
||
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() | ||
|
@@ -58,7 +80,8 @@ class QrScanActivity : ComponentActivity() { | |
BooltiTheme { | ||
QrScanScreen( | ||
barcodeView = barcodeView, | ||
onClickClose = { finish() } | ||
onClickClose = { finish() }, | ||
onClickSwitchCamera = ::switchCamera | ||
) | ||
} | ||
} | ||
|
@@ -77,4 +100,15 @@ class QrScanActivity : ComponentActivity() { | |
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { | ||
return barcodeView.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event) | ||
} | ||
|
||
private fun switchCamera() { | ||
barcodeView.pause() | ||
isBackCamera = !isBackCamera | ||
barcodeView.cameraSettings.requestedCameraId = if (isBackCamera) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 분명 전/후면 카메라 중 하나가 없는 기기가 있을텐데, 그럴 땐 어떻게 동작해? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 맞아 그 부분이 문제긴 해. 전면 카메라 식별이 가능한 거 같은데, 전면 카메라 없으면 버튼을 없애는 식으로 처리해 볼게 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 레거시이긴 하지만 오히려 Camera2 를 지원하지 않는 기기들이 있어서 호환성은 아이러니하게 Camera1이 더 좋은 상황... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 마져 camerax가 요구 api가 되게 높았던 거 같다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 라고 생각했는데 21이라네 뭐징 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 근데 xzing 도 사용하는데 무리없어서 마이그레이션이 급한 건은 아닌 듯 |
||
Camera.CameraInfo.CAMERA_FACING_BACK | ||
} else { | ||
Camera.CameraInfo.CAMERA_FACING_FRONT | ||
} | ||
barcodeView.resume() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 속성을 여기서 관리했을 때 카메라 방향 싱크가 안 맞는 문제는 없을까?