Skip to content
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

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.nexters.boolti.data.network.response

import com.nexters.boolti.data.util.toLocalDate
import com.nexters.boolti.data.util.toLocalDateTime
import com.nexters.boolti.domain.model.Show
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand All @@ -10,13 +12,16 @@ import java.time.LocalDateTime
internal data class HostedShowDto(
@SerialName("showId") val showId: String,
@SerialName("showName") val showName: String,
@SerialName("date") val date: String,
@SerialName("salesStartTime") val salesStartDate: String,
@SerialName("salesEndTime") val salesEndDate: String,
) {
fun toDomain(): Show = Show(
id = showId,
name = showName,
date = LocalDateTime.now(),
salesStartDate = LocalDate.now(),
salesEndDate = LocalDate.now(),
date = date.toLocalDateTime(),
salesStartDate = salesStartDate.toLocalDate(),
salesEndDate = salesEndDate.toLocalDate(),
thumbnailImage = "",
)
}
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,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
Expand All @@ -24,6 +30,7 @@ import kotlinx.coroutines.launch

@AndroidEntryPoint
class QrScanActivity : ComponentActivity() {
var isBackCamera = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 속성을 여기서 관리했을 때 카메라 방향 싱크가 안 맞는 문제는 없을까?


private val barcodeView: DecoratedBarcodeView by lazy {
DecoratedBarcodeView(this).apply {
Expand All @@ -40,6 +47,21 @@ class QrScanActivity : ComponentActivity() {
private val callback = BarcodeCallback { result: BarcodeResult ->
result.text ?: return@BarcodeCallback
viewModel.scan(result.text)

val vibrator =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추후에 진동 요구사항이 또 들어오면 확장으로 만들어도 좋을 듯

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영하겠슴당

Copy link
Member

Choose a reason for hiding this comment

The 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()
Expand All @@ -58,7 +80,8 @@ class QrScanActivity : ComponentActivity() {
BooltiTheme {
QrScanScreen(
barcodeView = barcodeView,
onClickClose = { finish() }
onClickClose = { finish() },
onClickSwitchCamera = ::switchCamera
)
}
}
Expand All @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

분명 전/후면 카메라 중 하나가 없는 기기가 있을텐데, 그럴 땐 어떻게 동작해?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞아 그 부분이 문제긴 해.
사실 xzing 라이브러리 자체가 camera2보다 이전인 camera 기반으로 동작하는 레거시이긴 하더라고...
그래서 mlkit에 있는 바코드 스캐너 사용해 보려 했는데 급하게 작성하느라... 허허...

전면 카메라 식별이 가능한 거 같은데, 전면 카메라 없으면 버튼을 없애는 식으로 처리해 볼게

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

레거시이긴 하지만 오히려 Camera2 를 지원하지 않는 기기들이 있어서 호환성은 아이러니하게 Camera1이 더 좋은 상황...
카메라 식별해서 버튼 없애는 건 좋은 것 같아!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 마져 camerax가 요구 api가 되게 높았던 거 같다

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

라고 생각했는데 21이라네 뭐징

Copy link
Member

Choose a reason for hiding this comment

The 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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fun ToastSnackbarHost(
) {
if (leadingIcon != null) {
leadingIcon()
Spacer(modifier = Modifier.padding(end = 12.dp))
Spacer(modifier = Modifier.padding(end = 8.dp))
}
Text(
modifier = Modifier.padding(vertical = 12.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import com.nexters.boolti.presentation.R
import com.nexters.boolti.presentation.component.BtBackAppBar
import com.nexters.boolti.presentation.theme.BooltiTheme
import com.nexters.boolti.presentation.theme.Grey30
import com.nexters.boolti.presentation.theme.Grey60
import com.nexters.boolti.presentation.theme.Grey50
import com.nexters.boolti.presentation.theme.point1
import java.time.LocalDate
import java.time.LocalDateTime
Expand Down Expand Up @@ -94,7 +94,7 @@ private fun HostedShowItem(
onClick: (showId: String, showName: String) -> Unit,
) {
val enable = LocalDate.now().toEpochDay() <= show.date.toLocalDate().toEpochDay()
val tint = if (enable) White else Grey60
val tint = if (enable) White else Grey50

Row(
modifier = Modifier
Expand All @@ -117,18 +117,6 @@ private fun HostedShowItem(
}
}

@Preview
@Composable
fun HostedShowItemPreview() {
BooltiTheme {
Surface {
HostedShowItem(
Show("", "hello world", LocalDateTime.now(), LocalDate.now(), LocalDate.now(), "")
) { _, _ -> }
}
}
}

@Composable
fun EmptyHostedShow(
modifier: Modifier,
Expand Down Expand Up @@ -161,3 +149,34 @@ fun EmptyHostedShow(
}
}
}

@Preview
@Composable
fun HostedShowItemPreview() {
BooltiTheme {
Surface {
HostedShowItem(
Show("", "hello world", LocalDateTime.now(), LocalDate.now(), LocalDate.now(), "")
) { _, _ -> }
}
}
}

@Preview
@Composable
fun OutDatedHostedShowItemPreview() {
BooltiTheme {
Surface {
HostedShowItem(
Show(
"",
"hello world",
LocalDateTime.now().minusDays(1),
LocalDate.now(),
LocalDate.now(),
""
)
) { _, _ -> }
}
}
}
Loading
Loading