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

release v1.2.1 #275

Merged
merged 15 commits into from
Oct 13, 2024
Merged
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
2 changes: 1 addition & 1 deletion build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies {
compileOnly(libs.gradle.android)
compileOnly(libs.gradle.kotlin)
compileOnly(libs.gradle.androidx.room)
// compileOnly(libs.compose.compiler.extension)
compileOnly(libs.compose.compiler.extension)

compileOnly(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import org.gradle.kotlin.dsl.configure

internal class AndroidApplicationComposeConventionPlugin : BuildLogicConventionPlugin(
{
// applyPlugins(Plugins.ANDROID_APPLICATION, Plugins.COMPOSE_COMPILER)
applyPlugins(Plugins.ANDROID_APPLICATION)
applyPlugins(Plugins.ANDROID_APPLICATION, Plugins.COMPOSE_COMPILER)
// applyPlugins(Plugins.ANDROID_APPLICATION)

extensions.configure<ApplicationExtension> {
configureCompose(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import org.gradle.kotlin.dsl.configure

internal class AndroidLibraryComposeConventionPlugin : BuildLogicConventionPlugin(
{
// applyPlugins(Plugins.ANDROID_LIBRARY, Plugins.COMPOSE_COMPILER)
applyPlugins(Plugins.ANDROID_LIBRARY)
applyPlugins(Plugins.ANDROID_LIBRARY, Plugins.COMPOSE_COMPILER)
// applyPlugins(Plugins.ANDROID_LIBRARY)

extensions.configure<LibraryExtension> {
configureCompose(this)
Expand Down
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/com/unifest/android/Android.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension

internal fun Project.configureAndroid(extension: CommonExtension<*, *, *, *, *>) {
internal fun Project.configureAndroid(extension: CommonExtension<*, *, *, *, *, >) {
extension.apply {
compileSdk = libs.versions.compileSdk.get().toInt()

Expand Down
92 changes: 46 additions & 46 deletions build-logic/src/main/kotlin/com/unifest/android/Compose.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,59 @@ package com.unifest.android
import com.android.build.api.dsl.CommonExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

//internal fun Project.configureCompose(extension: CommonExtension<*, *, *, *, *, *>) {
// extension.apply {
// dependencies {
// implementation(libs.bundles.androidx.compose)
// debugImplementation(libs.androidx.compose.ui.tooling)
// }
//
// configure<ComposeCompilerGradlePluginExtension> {
// enableStrongSkippingMode.set(true)
// includeSourceInformation.set(true)
//
// metricsDestination.file("build/composeMetrics")
// reportsDestination.file("build/composeReports")
//
// stabilityConfigurationFile.set(project.rootDir.resolve("stability.config.conf"))
// }
// }
//}
import org.gradle.kotlin.dsl.configure
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension

internal fun Project.configureCompose(extension: CommonExtension<*, *, *, *, *>) {
extension.apply {
buildFeatures {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get()
}

dependencies {
implementation(libs.androidx.compose.bom)
androidTestImplementation(libs.androidx.compose.bom)
implementation(libs.androidx.compose.material.iconsExtended)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.bundles.androidx.compose)
debugImplementation(libs.androidx.compose.ui.tooling)
}
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=$rootDir/report/compose-metrics",
)
freeCompilerArgs = freeCompilerArgs + listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=$rootDir/report/compose-reports",
)
configure<ComposeCompilerGradlePluginExtension> {
enableStrongSkippingMode.set(true)
includeSourceInformation.set(true)

metricsDestination.file("build/composeMetrics")
reportsDestination.file("build/composeReports")

stabilityConfigurationFile.set(project.rootDir.resolve("stability.config.conf"))
}
}
}

//internal fun Project.configureCompose(extension: CommonExtension<*, *, *, *, *>) {
// extension.apply {
// buildFeatures {
// compose = true
// }
//
// composeOptions {
// kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get()
// }
//
// dependencies {
// implementation(libs.androidx.compose.bom)
// androidTestImplementation(libs.androidx.compose.bom)
// implementation(libs.androidx.compose.material.iconsExtended)
// implementation(libs.androidx.compose.material3)
// implementation(libs.androidx.compose.ui)
// implementation(libs.androidx.compose.ui.tooling.preview)
// debugImplementation(libs.androidx.compose.ui.tooling)
// }
// }
//
// tasks.withType<KotlinCompile>().configureEach {
// kotlinOptions {
// freeCompilerArgs = freeCompilerArgs + listOf(
// "-P",
// "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=$rootDir/report/compose-metrics",
// )
// freeCompilerArgs = freeCompilerArgs + listOf(
// "-P",
// "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=$rootDir/report/compose-reports",
// )
// }
// }
//}
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/com/unifest/android/Plugins.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal object Plugins {

const val ANDROID_APPLICATION = "com.android.application"
const val ANDROID_LIBRARY = "com.android.library"
// const val COMPOSE_COMPILER = "org.jetbrains.kotlin.plugin.compose"
const val COMPOSE_COMPILER = "org.jetbrains.kotlin.plugin.compose"

const val ANDROIDX_ROOM = "androidx.room"

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.androidx.room) apply false
// alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.hilt) apply false
alias(libs.plugins.google.service) apply false
alias(libs.plugins.firebase.crashlytics) apply false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.unifest.android.core.common

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ErrorResponse(
@SerialName("code")
val code: Int,
@SerialName("message")
val message: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.unifest.android.core.common

import kotlinx.serialization.SerializationException
import kotlinx.serialization.json.Json
import retrofit2.HttpException
import timber.log.Timber
import java.io.IOException
import java.net.SocketTimeoutException
import java.net.UnknownHostException

private val jsonRule = Json {
encodeDefaults = true
ignoreUnknownKeys = true
prettyPrint = true
isLenient = true
}

interface QRErrorHandlerActions {
fun setServerErrorDialogVisible(flag: Boolean)
fun setNetworkErrorDialogVisible(flag: Boolean)
fun showErrorMessage(message: UiText)
}

fun handleException(exception: Throwable, actions: QRErrorHandlerActions) {
when (exception) {
is HttpException -> {
handleHttpException(exception, actions)
}

is UnknownHostException -> {
actions.setNetworkErrorDialogVisible(true)
}

is SocketTimeoutException -> {
actions.setServerErrorDialogVisible(true)
}

else -> {
Timber.e(exception)
}
}
}

private fun handleHttpException(exception: HttpException, actions: QRErrorHandlerActions) {
when (exception.code()) {
in 400..499 -> {
val errorBody = exception.response()?.errorBody()?.string()
try {
val errorResponse = errorBody?.let { jsonRule.decodeFromString(ErrorResponse.serializer(), it) }
if (errorResponse != null && errorResponse.code == 9000) {
actions.showErrorMessage(UiText.StringResource(R.string.already_collected_stamp))
} else {
actions.showErrorMessage(UiText.StringResource(R.string.not_found_stamp))
}
} catch (e: SerializationException) {
Timber.e(e)
actions.showErrorMessage(UiText.StringResource(R.string.not_found_stamp))
} catch (e: IllegalArgumentException) {
Timber.e(e)
actions.showErrorMessage(UiText.StringResource(R.string.not_found_stamp))
} catch (e: IOException) {
Timber.e(e)
actions.showErrorMessage(UiText.StringResource(R.string.not_found_stamp))
}
}

in 500..511 -> actions.setServerErrorDialogVisible(true)
else -> Timber.e(exception)
}
}
5 changes: 5 additions & 0 deletions core/common/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="already_collected_stamp">이미 스탬프를 찍은 부스입니다.</string>
<string name="not_found_stamp">올바르지 않은 QR 코드입니다. 운영자에 문의바랍니다.</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import com.unifest.android.core.data.repository.RemoteConfigRepository
import com.unifest.android.core.data.repository.RemoteConfigRepositoryImpl
import com.unifest.android.core.data.repository.SettingRepository
import com.unifest.android.core.data.repository.SettingRepositoryImpl
import com.unifest.android.core.data.repository.StampRepository
import com.unifest.android.core.data.repository.StampRepositoryImpl
import com.unifest.android.core.data.repository.WaitingRepository
import com.unifest.android.core.data.repository.WaitingRepositoryImpl
import dagger.Binds
Expand Down Expand Up @@ -62,4 +64,8 @@ internal abstract class RepositoryModule {
@Binds
@Singleton
abstract fun bindSettingRepository(settingRepositoryImpl: SettingRepositoryImpl): SettingRepository

@Binds
@Singleton
abstract fun bindStampRepository(stampRepositoryImpl: StampRepositoryImpl): StampRepository
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import com.unifest.android.core.model.BoothDetailModel
import com.unifest.android.core.model.BoothModel
import com.unifest.android.core.model.LikedBoothModel
import com.unifest.android.core.model.MenuModel
import com.unifest.android.core.model.StampBoothModel
import com.unifest.android.core.model.WaitingModel
import com.unifest.android.core.network.response.Booth
import com.unifest.android.core.network.response.BoothDetail
import com.unifest.android.core.network.response.LikedBooth
import com.unifest.android.core.network.response.Menu
import com.unifest.android.core.network.response.Waiting
import com.unifest.android.core.network.response.booth.Booth
import com.unifest.android.core.network.response.booth.BoothDetail
import com.unifest.android.core.network.response.booth.LikedBooth
import com.unifest.android.core.network.response.booth.Menu
import com.unifest.android.core.network.response.booth.StampBooth

internal fun BoothDetail.toModel(): BoothDetailModel {
return BoothDetailModel(
Expand Down Expand Up @@ -80,3 +82,21 @@ internal fun Waiting.toModel(): WaitingModel {
boothName = boothName,
)
}

internal fun StampBooth.toModel(): StampBoothModel {
return StampBoothModel(
id = id,
name = name,
category = category,
description = description,
thumbnail = thumbnail,
location = location,
latitude = latitude,
longitude = longitude,
enabled = enabled,
waitingEnabled = waitingEnabled,
openTime = openTime,
closeTime = closeTime,
stampEnabled = stampEnabled,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.unifest.android.core.data.repository

import com.unifest.android.core.model.StampBoothModel

interface StampRepository {
suspend fun getCollectedStampCount(): Result<Int>
suspend fun getStampEnabledBoothList(): Result<List<StampBoothModel>>
suspend fun registerStamp(boothId: Long): Result<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.unifest.android.core.data.repository

import android.content.Context
import com.unifest.android.core.common.getDeviceId
import com.unifest.android.core.data.mapper.toModel
import com.unifest.android.core.data.util.runSuspendCatching
import com.unifest.android.core.datastore.RecentLikedFestivalDataSource
import com.unifest.android.core.network.request.RegisterStampRequest
import com.unifest.android.core.network.service.UnifestService
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject

internal class StampRepositoryImpl @Inject constructor(
@ApplicationContext private val context: Context,
private val service: UnifestService,
private val recentLikedFestivalDataSource: RecentLikedFestivalDataSource,
) : StampRepository {
override suspend fun getCollectedStampCount() = runSuspendCatching {
val deviceId = getDeviceId(context)
service.getCollectedStampCount(deviceId).data
}

override suspend fun getStampEnabledBoothList() = runSuspendCatching {
val festivalId = recentLikedFestivalDataSource.getRecentLikedFestivalId()
service.getStampEnabledBoothList(festivalId).data.map { it.toModel() }
}

override suspend fun registerStamp(boothId: Long) = runSuspendCatching {
val deviceId = getDeviceId(context)
service.registerStamp(RegisterStampRequest(token = deviceId, boothId = boothId))
}
}
38 changes: 38 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_qr_scan_crosshair.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="61dp"
android:height="61dp"
android:viewportWidth="61"
android:viewportHeight="61">
<path
android:strokeWidth="1"
android:pathData="M30.5,24V35"
android:fillColor="#00000000"
android:strokeColor="#EFDC3B"
android:strokeLineCap="round"/>
<path
android:strokeWidth="1"
android:pathData="M36,29.5L25,29.5"
android:fillColor="#00000000"
android:strokeColor="#EFDC3B"
android:strokeLineCap="round"/>
<path
android:pathData="M60,13.5V4C60,2.343 58.657,1 57,1H47"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#EFDC3B"/>
<path
android:pathData="M1,13.5V4C1,2.343 2.343,1 4,1H14"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#EFDC3B"/>
<path
android:pathData="M1,47V56.5C1,58.157 2.343,59.5 4,59.5H14"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#EFDC3B"/>
<path
android:pathData="M60,47V56.5C60,58.157 58.657,59.5 57,59.5H47"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#EFDC3B"/>
</vector>
Loading
Loading