Skip to content

Commit

Permalink
Merge pull request #279 from team-peekabook/feature/#278-refactor-dep…
Browse files Browse the repository at this point in the history
…recated-function

#278 [refactor] deprecated된 함수 수정 및 네트워크 에러 분기처리
  • Loading branch information
2zerozu authored Dec 15, 2023
2 parents 9c47823 + 1248dde commit fb19397
Show file tree
Hide file tree
Showing 62 changed files with 520 additions and 511 deletions.
9 changes: 2 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id 'dagger.hilt.android.plugin'
id 'kotlin-parcelize'
id "org.jlleitschuh.gradle.ktlint" version "10.3.0"
id 'org.jetbrains.kotlin.plugin.serialization' version '1.7.20'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.0'
id 'com.google.gms.google-services'
}

Expand Down Expand Up @@ -59,10 +59,6 @@ android {

dependencies {

// glide
implementation 'com.github.bumptech.glide:glide:4.13.2'
kapt 'com.github.bumptech.glide:compiler:4.13.2'

// hilt
implementation 'com.google.dagger:hilt-android:2.48.1'
kapt 'com.google.dagger:hilt-compiler:2.48.1'
Expand All @@ -84,8 +80,7 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'

// network
implementation 'com.squareup.okhttp3:logging-interceptor:4.11.0'
implementation(platform('com.squareup.okhttp3:okhttp-bom:4.11.0'))
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0'

Expand Down
13 changes: 8 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

<uses-feature
android:name="android.hardware.camera"
android:required="false" />
android:required="true" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />

<uses-permission
Expand All @@ -34,9 +36,10 @@
android:theme="@style/Theme.PeekabookAOS"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity android:name=".presentation.forceUpdate.ForceUpdateActivity"
<activity
android:name=".presentation.forceUpdate.ForcedUpdateActivity"
android:exported="false"
android:screenOrientation="portrait"/>
android:screenOrientation="portrait" />
<activity
android:name=".presentation.profileModify.ProfileModifyActivity"
android:exported="false"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.sopt.peekabookaos.data.entity.response

import kotlinx.serialization.Serializable

@Serializable
data class ForcedUpdateResponse(
val imageUrl: String,
val androidForceVersion: String,
val text: String
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.sopt.peekabookaos.data.repository

import com.sopt.peekabookaos.data.source.local.LocalPrefDataSource
import com.sopt.peekabookaos.data.source.local.LocalSplashDataSource
import com.sopt.peekabookaos.data.source.local.LocalSignedUpDataSource
import com.sopt.peekabookaos.data.source.local.LocalTokenDataSource
import com.sopt.peekabookaos.data.source.remote.AuthDataSource
import com.sopt.peekabookaos.domain.entity.SplashState
import com.sopt.peekabookaos.domain.entity.Token
import com.sopt.peekabookaos.domain.repository.AuthRepository
import javax.inject.Inject
Expand All @@ -13,7 +12,7 @@ class AuthRepositoryImpl @Inject constructor(
private val authDataSource: AuthDataSource,
private val localTokenDataSource: LocalTokenDataSource,
private val localPrefDataSource: LocalPrefDataSource,
private val localSplashDataSource: LocalSplashDataSource
private val localSignedUpDataSource: LocalSignedUpDataSource
) : AuthRepository {
override suspend fun postLogin(socialPlatform: String): Result<Token> =
kotlin.runCatching { authDataSource.postLogin(socialPlatform) }.map { response ->
Expand All @@ -28,15 +27,10 @@ class AuthRepositoryImpl @Inject constructor(
localTokenDataSource.refreshToken = refreshToken
}

override fun setSplashState(splashState: SplashState) {
localSplashDataSource.splashState = splashState.toString()
}

override fun getSplashState(): SplashState {
return SplashState.valueOf(localSplashDataSource.splashState)
}
override fun clearLocalPref() = localPrefDataSource.clearLocalPref()

override fun clearLocalPref() {
localPrefDataSource.clearLocalPref()
override fun getSignedUp(): Boolean = localSignedUpDataSource.isSignedUp
override fun setSignedUp() {
localSignedUpDataSource.isSignedUp = true
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.sopt.peekabookaos.data.repository

import com.sopt.peekabookaos.data.source.remote.ForcedUpdateDataSource
import com.sopt.peekabookaos.domain.entity.ForcedUpdate
import com.sopt.peekabookaos.domain.entity.UpdateInformation
import com.sopt.peekabookaos.domain.entity.Version
import com.sopt.peekabookaos.domain.repository.ForcedUpdateRepository
import javax.inject.Inject

class ForcedUpdateRepositoryImpl @Inject constructor(
private val forcedUpdateDataSource: ForcedUpdateDataSource
) : ForcedUpdateRepository {
override suspend fun hasForceUpdateVersion(
currentVersion: String
): Result<ForcedUpdate> = kotlin.runCatching {
forcedUpdateDataSource.getForcedUpdateVersion()
}.map { response ->
val (imageUrl, androidForceVersion, text) = requireNotNull(response.data)
if (Version.of(androidForceVersion).greaterThan(Version.of(currentVersion))) {
return@map ForcedUpdate.Need(UpdateInformation(imageUrl, text))
} else {
return@map ForcedUpdate.None
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.sopt.peekabookaos.data.service

import com.sopt.peekabookaos.data.entity.BaseResponse
import com.sopt.peekabookaos.data.entity.response.ForcedUpdateResponse
import retrofit2.http.GET

interface ForcedUpdateService {
@GET("user/v1/version")
suspend fun getVersion(): BaseResponse<ForcedUpdateResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.sopt.peekabookaos.data.source.local

import android.content.SharedPreferences
import androidx.core.content.edit
import javax.inject.Inject

class LocalSignedUpDataSource @Inject constructor(
private val prefs: SharedPreferences
) {
var isSignedUp: Boolean
set(value) = prefs.edit { putBoolean(SIGNED_UP, value) }
get() = prefs.getBoolean(SIGNED_UP, false)

companion object {
private const val SIGNED_UP = "signed up"
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.sopt.peekabookaos.data.source.remote

import com.sopt.peekabookaos.data.entity.BaseResponse
import com.sopt.peekabookaos.data.entity.response.ForcedUpdateResponse
import com.sopt.peekabookaos.data.service.ForcedUpdateService
import javax.inject.Inject

class ForcedUpdateDataSource @Inject constructor(
private val forcedUpdateService: ForcedUpdateService
) {
suspend fun getForcedUpdateVersion(): BaseResponse<ForcedUpdateResponse> =
forcedUpdateService.getVersion()
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.sopt.peekabookaos.data.repository.AuthRepositoryImpl
import com.sopt.peekabookaos.data.repository.BlockRepositoryImpl
import com.sopt.peekabookaos.data.repository.BookRepositoryImpl
import com.sopt.peekabookaos.data.repository.DetailRepositoryImpl
import com.sopt.peekabookaos.data.repository.ForceUpdateRepositoryImpl
import com.sopt.peekabookaos.data.repository.ForcedUpdateRepositoryImpl
import com.sopt.peekabookaos.data.repository.MyPageRepositoryImpl
import com.sopt.peekabookaos.data.repository.NaverRepositoryImpl
import com.sopt.peekabookaos.data.repository.NotificationRepositoryImpl
Expand All @@ -18,7 +18,7 @@ import com.sopt.peekabookaos.domain.repository.AuthRepository
import com.sopt.peekabookaos.domain.repository.BlockRepository
import com.sopt.peekabookaos.domain.repository.BookRepository
import com.sopt.peekabookaos.domain.repository.DetailRepository
import com.sopt.peekabookaos.domain.repository.ForceUpdateRepository
import com.sopt.peekabookaos.domain.repository.ForcedUpdateRepository
import com.sopt.peekabookaos.domain.repository.MyPageRepository
import com.sopt.peekabookaos.domain.repository.NaverRepository
import com.sopt.peekabookaos.domain.repository.NotificationRepository
Expand Down Expand Up @@ -118,6 +118,6 @@ abstract class RepositoryModule {
@Binds
@Singleton
abstract fun bindToForceUpdateRepository(
forceUpdateRepositoryImpl: ForceUpdateRepositoryImpl
): ForceUpdateRepository
forceUpdateRepositoryImpl: ForcedUpdateRepositoryImpl
): ForcedUpdateRepository
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.sopt.peekabookaos.data.service.AuthService
import com.sopt.peekabookaos.data.service.BlockService
import com.sopt.peekabookaos.data.service.BookService
import com.sopt.peekabookaos.data.service.DetailService
import com.sopt.peekabookaos.data.service.ForceUpdateService
import com.sopt.peekabookaos.data.service.ForcedUpdateService
import com.sopt.peekabookaos.data.service.MyPageService
import com.sopt.peekabookaos.data.service.NaverService
import com.sopt.peekabookaos.data.service.NotificationService
Expand All @@ -22,7 +22,6 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import retrofit2.create

@Module
@InstallIn(SingletonComponent::class)
Expand Down Expand Up @@ -80,6 +79,6 @@ object RetrofitServiceModule {
retrofit.create(ReportService::class.java)

@Provides
fun providesForceUpdateService(@PeekaType retrofit: Retrofit): ForceUpdateService =
retrofit.create(ForceUpdateService::class.java)
fun providesForceUpdateService(@PeekaType retrofit: Retrofit): ForcedUpdateService =
retrofit.create(ForcedUpdateService::class.java)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.sopt.peekabookaos.domain.entity

sealed class ForcedUpdate {
data object None : ForcedUpdate()
data class Need(val updateInformation: UpdateInformation) : ForcedUpdate()
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.sopt.peekabookaos.domain.entity

sealed class SplashUiState {
data object Idle : SplashUiState()
data object Error : SplashUiState()
data object ShowSplash : SplashUiState()
data object CanStartOnboarding : SplashUiState()
data object CanStartMain : SplashUiState()
data class ForceUpdate(val data: UpdateInformation) : SplashUiState()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.sopt.peekabookaos.domain.entity

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class UpdateInformation(
val imageUrl: String = "",
val text: String = ""
) : Parcelable
25 changes: 17 additions & 8 deletions app/src/main/java/com/sopt/peekabookaos/domain/entity/Version.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
package com.sopt.peekabookaos.domain.entity

import android.os.Parcelable
import kotlinx.parcelize.Parcelize
class Version private constructor(
private val major: Int,
private val minor: Int
) {

@Parcelize
data class Version(
val imageUrl: String = "",
val androidForceVersion: String = "",
val versionText: String = ""
) : Parcelable
fun greaterThan(other: Version): Boolean = other.major < major || other.minor < minor

companion object {
private const val VERSION_SPLIT_SIGN = "."
private const val MAJOR_POSITION = 0
private const val MINOR_POSITION = 1
fun of(version: String) = version.split(VERSION_SPLIT_SIGN).map {
it.toInt()
}.let {
Version(it[MAJOR_POSITION], it[MINOR_POSITION])
}
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit fb19397

Please sign in to comment.