Skip to content

Commit

Permalink
Merge pull request #902 from TeamHavit/release
Browse files Browse the repository at this point in the history
[RELEASE] v1.0.10 배포완료
  • Loading branch information
kimhyeing authored Sep 10, 2023
2 parents 5981969 + 7a36645 commit 258398c
Show file tree
Hide file tree
Showing 35 changed files with 252 additions and 221 deletions.
11 changes: 5 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ properties.load(project.rootProject.file('local.properties').newDataInputStream(
def kakao_native_app_key = properties.get('KAKAO_NATIVE_APP_KEY_NO_QUEOTS')

android {
compileSdk 31
compileSdk 33

defaultConfig {
applicationId "org.sopt.havit"
minSdk 23
targetSdk 31
versionCode 108
versionName "1.0.8"
targetSdk 33
versionCode 110
versionName "1.0.10"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField("String", "HAVIT_BASE_URL_DEV", properties["HAVIT_BASE_URL_DEV"])
buildConfigField("String", "HAVIT_BASE_URL_PROD", properties["HAVIT_BASE_URL_PROD"])
Expand Down Expand Up @@ -80,7 +80,7 @@ android {
dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
Expand All @@ -100,7 +100,6 @@ dependencies {

//kakao
implementation "com.kakao.sdk:v2-user:2.11.0" // 카카오 로그인
implementation 'com.kakao.sdk:usermgmt:1.27.0' // 카카오 로그인 버튼 만들 때 사용

// Retrofit
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package="org.sopt.havit">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

<queries>
<package android:name="com.kakao.talk" />
Expand Down
9 changes: 3 additions & 6 deletions app/src/main/java/org/sopt/havit/FirebaseTokenManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@ import android.util.Log
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.sopt.havit.data.RetrofitObject
import org.sopt.havit.data.api.HavitApi
import org.sopt.havit.data.remote.FcmTokenParams
import org.sopt.havit.domain.repository.AuthRepository
import javax.inject.Inject

class FirebaseTokenManager @Inject constructor(
authRepository: AuthRepository,
private val havitApi: HavitApi
) {
private val accessToken = authRepository.getAccessToken()

fun sendRegistrationToServer(fcmToken: String) {
CoroutineScope(Dispatchers.IO).launch {
kotlin.runCatching {
RetrofitObject.provideHavitApi(accessToken)
.refreshFcmToken(FcmTokenParams(fcmToken))
havitApi.refreshFcmToken(FcmTokenParams(fcmToken))
}.onSuccess {
Log.d(ContentValues.TAG, "onNewToken: success")
}.onFailure {
Expand Down
44 changes: 0 additions & 44 deletions app/src/main/java/org/sopt/havit/data/RetrofitObject.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class HavitAuthLocalPreferences @Inject constructor(
) {
companion object {
private const val ACCESS_TOKEN = "ACCESS_TOKEN"
private const val REFRESH_TOKEN = "REFRESH_TOKEN"
private const val KAKAO_TOKEN = "KAKAO_TOKEN"
private const val USER_EMAIL = "USER_EMAIL"
private const val USER_AGE = "USER_AGE"
Expand All @@ -24,6 +25,8 @@ class HavitAuthLocalPreferences @Inject constructor(
fun setXAuthToken(token: String) = prefs.edit().putString(ACCESS_TOKEN, token).apply()

fun getXAuthToken(): String = prefs.getString(ACCESS_TOKEN, "").toString()
fun setRefreshToken(token: String) = prefs.edit().putString(REFRESH_TOKEN, token).apply()
fun getRefreshToken(): String = prefs.getString(REFRESH_TOKEN, "").toString()

fun setKakaoToken(token: String) = prefs.edit().putString(KAKAO_TOKEN, token).apply()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class AuthRepositoryImpl @Inject constructor(
authLocalDataSource.saveAccessToken(accessToken)
}

override fun saveRefreshToken(refreshToken: String) {
authLocalDataSource.saveRefreshToken(refreshToken)
}

override fun saveKakaoToken(kakaoToken: String) {
authLocalDataSource.saveKakaoToken(kakaoToken)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
package org.sopt.havit.data.repository

import org.sopt.havit.data.RetrofitObject
import org.sopt.havit.data.api.HavitApi
import org.sopt.havit.data.remote.BasicResponse
import org.sopt.havit.data.remote.ContentsHavitRequest
import org.sopt.havit.data.remote.ContentsHavitResponse
import org.sopt.havit.data.source.remote.contents.ContentsRemoteDataSource
import org.sopt.havit.domain.entity.Contents
import org.sopt.havit.domain.repository.ContentsRepository
import org.sopt.havit.util.HavitSharedPreference
import javax.inject.Inject

class ContentsRepositoryImpl @Inject constructor(
private val contentsRemoteDataSource: ContentsRemoteDataSource,
preference: HavitSharedPreference
private val havitApi: HavitApi
) : ContentsRepository {

private val pref = preference.getXAuthToken()

override suspend fun isSeen(contentsId: Int): ContentsHavitResponse {
return RetrofitObject.provideHavitApi(pref).isHavit(ContentsHavitRequest(contentsId))
return havitApi.isHavit(ContentsHavitRequest(contentsId))
}

override suspend fun getContentsByCategory(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.sopt.havit.data.repository

import org.sopt.havit.data.RetrofitObject
import org.sopt.havit.data.api.HavitApi
import org.sopt.havit.data.remote.UserResponse
import org.sopt.havit.data.source.local.AuthLocalDataSource
import org.sopt.havit.domain.repository.MyPageRepository
import javax.inject.Inject

class MyPageRepositoryImpl @Inject constructor(private val authLocalDataSource: AuthLocalDataSource) :
MyPageRepository {
class MyPageRepositoryImpl @Inject constructor(
private val havitApi: HavitApi
) : MyPageRepository {
override suspend fun getUserInfo(): UserResponse {
return RetrofitObject.provideHavitApi(authLocalDataSource.getAccessToken()).getUserData()
return havitApi.getUserData()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package org.sopt.havit.data.source.local
interface AuthLocalDataSource {
fun saveAccessToken(token: String)
fun getAccessToken(): String
fun saveRefreshToken(token: String)
fun getRefreshToken(): String
fun saveKakaoToken(kakaoToken: String)
fun getKakaoToken(): String
fun getUserAge():Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ class AuthLocalDataSourceImpl @Inject constructor(private val havitLocalPreferen
return havitLocalPreferences.getXAuthToken()
}

override fun saveRefreshToken(token: String) {
havitLocalPreferences.setRefreshToken(token)
}

override fun getRefreshToken(): String {
return havitLocalPreferences.getRefreshToken()
}

override fun saveKakaoToken(kakaoToken: String) =
havitLocalPreferences.setKakaoToken(kakaoToken)

Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/org/sopt/havit/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import org.sopt.havit.data.api.HavitApi
import org.sopt.havit.data.mapper.ContentsMapper
import org.sopt.havit.data.repository.*
import org.sopt.havit.data.source.local.AuthLocalDataSourceImpl
Expand All @@ -12,7 +13,6 @@ import org.sopt.havit.data.source.remote.SearchRemoteDataSourceImpl
import org.sopt.havit.data.source.remote.category.CategoryRemoteDataSourceImpl
import org.sopt.havit.data.source.remote.contents.ContentsRemoteDataSourceImpl
import org.sopt.havit.domain.repository.*
import org.sopt.havit.util.HavitSharedPreference
import javax.inject.Singleton

@Module
Expand All @@ -29,16 +29,16 @@ object RepositoryModule {
@Provides
@Singleton
fun provideMyPageRepository(
authLocalDataSourceImpl: AuthLocalDataSourceImpl
): MyPageRepository = MyPageRepositoryImpl(authLocalDataSourceImpl)
havitApi: HavitApi
): MyPageRepository = MyPageRepositoryImpl(havitApi)

@Provides
@Singleton
fun provideContentsRepository(
contentsRemoteDataSourceImpl: ContentsRemoteDataSourceImpl,
havitSharedPreference: HavitSharedPreference
havitApi: HavitApi
): ContentsRepository =
ContentsRepositoryImpl(contentsRemoteDataSourceImpl, havitSharedPreference)
ContentsRepositoryImpl(contentsRemoteDataSourceImpl, havitApi)

@Provides
@Singleton
Expand Down
68 changes: 39 additions & 29 deletions app/src/main/java/org/sopt/havit/di/RetrofitModule.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package org.sopt.havit.di

import android.content.Context
import android.content.Intent
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import org.sopt.havit.BuildConfig.*
import org.sopt.havit.BuildConfig
import org.sopt.havit.data.source.local.AuthLocalDataSourceImpl
import org.sopt.havit.ui.sign.SplashWithSignActivity
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import javax.inject.Singleton
Expand All @@ -21,35 +25,44 @@ object RetrofitModule {

@Provides
@Singleton
fun provideInterceptor(authLocalDataSourceImpl: AuthLocalDataSourceImpl) =
Interceptor { chain ->
with(chain) {
proceed(
request()
.newBuilder()
.addHeader(
"x-auth-token",
authLocalDataSourceImpl.getAccessToken()
)
.build()
)
fun provideAuthInterceptor(
@ApplicationContext context: Context,
authLocalDataSourceImpl: AuthLocalDataSourceImpl
): Interceptor {
return Interceptor { chain ->
val originalRequest = chain.request()
val newRequest = originalRequest.newBuilder()
.header("x-auth-token", authLocalDataSourceImpl.getAccessToken())
.build()
val response = chain.proceed(newRequest)
if (response.code() == 401) {
handle401Error(context, authLocalDataSourceImpl)
}
response
}
}

private fun handle401Error(context: Context, authLocalDataSourceImpl: AuthLocalDataSourceImpl) {
authLocalDataSourceImpl.removeHavitAuthToken()
authLocalDataSourceImpl.saveAccessToken(authLocalDataSourceImpl.getRefreshToken())
val intent = Intent(context, SplashWithSignActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
context.startActivity(intent)
}

@Provides
@Singleton
fun provideOkHttpClient(
interceptor: Interceptor
): OkHttpClient {
return OkHttpClient.Builder().apply {
addInterceptor(interceptor)
fun provideOkHttpClient(interceptor: Interceptor): OkHttpClient {
val httpClientBuilder = OkHttpClient.Builder()
.addInterceptor(interceptor)

if (DEBUG) {
addInterceptor(HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
})
}
}.build()
if (BuildConfig.DEBUG) {
httpClientBuilder.addInterceptor(HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
})
}

return httpClientBuilder.build()
}

@Provides
Expand All @@ -58,11 +71,8 @@ object RetrofitModule {

@Provides
@Singleton
fun provideRetrofit(
client: OkHttpClient,
gson: Gson
): Retrofit = Retrofit.Builder()
.baseUrl(if (IS_DEV) HAVIT_BASE_URL_DEV else HAVIT_BASE_URL_PROD)
fun provideRetrofit(client: OkHttpClient, gson: Gson): Retrofit = Retrofit.Builder()
.baseUrl(if (BuildConfig.IS_DEV) BuildConfig.HAVIT_BASE_URL_DEV else BuildConfig.HAVIT_BASE_URL_PROD)
.client(client)
.addConverterFactory(GsonConverterFactory.create(gson))
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface AuthRepository {
fun getFcmToken(getFcmToken: (String) -> Unit)

fun saveAccessToken(accessToken: String)
fun saveRefreshToken(refreshToken: String)

fun saveKakaoToken(kakaoToken: String)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.os.Bundle
import android.view.MotionEvent
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import androidx.activity.OnBackPressedCallback
import androidx.activity.viewModels
import androidx.core.widget.addTextChangedListener
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -33,8 +34,15 @@ class CategoryContentModifyActivity :
private lateinit var iconAdapter: IconAdapter
private lateinit var categoryTitleList: ArrayList<String>

private val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
setBackPressedAction()
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
this.onBackPressedDispatcher.addCallback(this, callback)
setContentView(binding.root)

initIconAdapter()
Expand All @@ -48,10 +56,6 @@ class CategoryContentModifyActivity :
observeModifyState()
}

override fun onBackPressed() {
setBackPressedAction()
}

override fun dispatchTouchEvent(event: MotionEvent): Boolean {
if (event.action == MotionEvent.ACTION_DOWN) {
val v = currentFocus
Expand Down
Loading

0 comments on commit 258398c

Please sign in to comment.