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

Merged
merged 15 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 8 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.

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

Copy link
Member Author

Choose a reason for hiding this comment

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

private fun switchCamera() {
        barcodeView.pause()
        isBackCamera = !isBackCamera
        barcodeView.cameraSettings.requestedCameraId = if (isBackCamera) {
            Camera.CameraInfo.CAMERA_FACING_BACK
        } else {
            Camera.CameraInfo.CAMERA_FACING_FRONT
        }
        barcodeView.resume()
    }

지금 코드가 이렇게 되어 있고, 내 생각엔 없을 거 같긴 한데 혹시 더 좋은 방법이 있을까?

Copy link
Member Author

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 =
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) {
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