Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into feat/add-diary-view
Browse files Browse the repository at this point in the history
  • Loading branch information
HamBeomJoon committed Aug 5, 2024
2 parents 6418c62 + ab733a7 commit e153c57
Show file tree
Hide file tree
Showing 21 changed files with 95 additions and 74 deletions.
1 change: 1 addition & 0 deletions Nabi/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
.externalNativeBuild
.cxx
local.properties

3 changes: 0 additions & 3 deletions Nabi/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ dependencies {
// DataStore
implementation(libs.androidx.datastore.preferences)

// LoggerUtils
implementation(libs.logger)

// Kakao Login
implementation(libs.v2.user)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object DiaryMapper {
content = it.content,
diaryEntryDate = it.diaryEntryDate,
diaryId = it.diaryId,
emotion = it.emotion ?: "",
emotion = it.emotion,
isBookmarked = it.isBookmarked,
nickname = it.nickname
)
Expand Down
2 changes: 1 addition & 1 deletion Nabi/data/src/main/java/com/nabi/data/mapper/HomeMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object HomeMapper {
RecentFiveDiary(
content = diary.content,
diaryEntryDate = diary.diaryEntryDate,
emotion = diary.emotion ?: ""
emotion = diary.emotion
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.stringPreferencesKey
import com.nabi.data.utils.LoggerUtils
import com.nabi.domain.enums.AuthProvider
import com.nabi.domain.repository.DataStoreRepository
import kotlinx.coroutines.flow.first
Expand All @@ -21,72 +20,61 @@ class DataStoreRepositoryImpl @Inject constructor(
}

override suspend fun clearData(): Result<Boolean> {
LoggerUtils.d("clearData 호출")
return try {
dataStorePreferences.edit { preferences ->
preferences.clear()
}
Result.success(true)
} catch (e: Exception) {
LoggerUtils.e("clearData 실패 ${e.printStackTrace()}")
Result.success(false)
}
}

override suspend fun setAccessToken(accessToken: String) {
LoggerUtils.d("setAccessToken 호출")
dataStorePreferences.edit { preferences ->
preferences[ACCESS_TOKEN_KEY] = accessToken
}
}

override suspend fun getAccessToken(): Result<String> {
LoggerUtils.d("getAccessToken 호출")
return try {
val preferences = dataStorePreferences.data.first()
val accessToken = preferences[ACCESS_TOKEN_KEY] ?: ""
Result.success(accessToken)
} catch (e: Exception) {
LoggerUtils.e("getAccessToken 실패 ${e.printStackTrace()}")
Result.failure(e)
}
}

override suspend fun setRefreshToken(refreshToken: String) {
LoggerUtils.d("setRefreshToken 호출")
dataStorePreferences.edit { preferences ->
preferences[REFRESH_TOKEN_KEY] = refreshToken
}
}

override suspend fun getRefreshToken(): Result<String> {
LoggerUtils.d("getRefreshToken 호출")
return try {
val preferences = dataStorePreferences.data.first()
val refreshToken = preferences[REFRESH_TOKEN_KEY] ?: ""
Result.success(refreshToken)
} catch (e: Exception) {
LoggerUtils.e("getRefreshToken 실패 ${e.printStackTrace()}")
Result.failure(e)
}
}

override suspend fun setAuthProvider(provider: AuthProvider) {
LoggerUtils.d("setAuthProvider 호출")
dataStorePreferences.edit { preferences ->
preferences[LOGIN_PROVIDER_KEY] = provider.name
}
}

override suspend fun getAuthProvider(): Result<AuthProvider> {
LoggerUtils.d("getAuthProvider 호출")
return try {
val preferences = dataStorePreferences.data.first()
val providerName = preferences[LOGIN_PROVIDER_KEY] ?: ""
val provider = AuthProvider.valueOf(providerName)
Result.success(provider)
} catch (e: Exception) {
LoggerUtils.e("getAuthProvider 실패 ${e.printStackTrace()}")
Result.failure(e)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.nabi.data.service

import android.content.Context
import android.util.Log
import com.kakao.sdk.auth.model.OAuthToken
import com.kakao.sdk.user.UserApiClient
import com.nabi.data.utils.LoggerUtils
import com.nabi.domain.enums.AuthProvider
import dagger.hilt.android.qualifiers.ActivityContext
import javax.inject.Inject
Expand Down Expand Up @@ -41,28 +41,27 @@ class KakaoAuthService @Inject constructor(

private fun signInError(throwable: Throwable) {
val kakaoType = if (isKakaoTalkLoginAvailable) KAKAO_TALK else KAKAO_ACCOUNT
LoggerUtils.e("{$kakaoType}으로 로그인 실패 ${throwable.message}")
Log.e("KAKAO", "{$kakaoType}으로 로그인 실패 ${throwable.message}")
}

private fun signInSuccess(
oAuthToken: OAuthToken,
signInListener: KFunction2<String, AuthProvider, Unit>
) {
LoggerUtils.d("$KAKAO_ID_TOKEN ${oAuthToken.idToken}")
client.me { _, error ->
signInListener(oAuthToken.idToken ?: "", AuthProvider.KAKAO)
if (error != null) {
LoggerUtils.e("사용자 정보 요청 실패 $error")
Log.e("KAKAO", "사용자 정보 요청 실패 $error")
}
}
}

fun signOut(signOutListener: ((Throwable?) -> Unit)? = null) {
client.logout { error ->
if (error != null) {
LoggerUtils.e("로그아웃 실패. SDK에서 토큰 삭제됨 $error")
Log.e("KAKAO", "로그아웃 실패. SDK에서 토큰 삭제됨 $error")
} else {
LoggerUtils.i("로그아웃 성공. SDK에서 토큰 삭제됨")
Log.i("KAKAO", "로그아웃 성공. SDK에서 토큰 삭제됨")
}
signOutListener?.invoke(error)
}
Expand All @@ -71,9 +70,9 @@ class KakaoAuthService @Inject constructor(
fun withdraw(withdrawListener: ((Throwable?) -> Unit)? = null) {
client.unlink { error ->
if (error != null) {
LoggerUtils.e("회원탈퇴 실패 $error")
Log.e("KAKAO", "회원탈퇴 실패 $error")
} else {
LoggerUtils.i("회원탈퇴 성공")
Log.i("KAKAO", "회원탈퇴 성공")
}
withdrawListener?.invoke(error)
}
Expand Down
37 changes: 0 additions & 37 deletions Nabi/data/src/main/java/com/nabi/data/utils/LoggerUtils.kt

This file was deleted.

14 changes: 13 additions & 1 deletion Nabi/presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ android {
dataBinding = true
buildConfig = true
}

signingConfigs {
getByName("debug") {
keyAlias = properties["SIGNED_KEY_ALIAS"] as String?
keyPassword = properties["SIGNED_KEY_PASSWORD"] as String?
storeFile = properties["SIGNED_STORE_FILE"]?.let { file(it) }
storePassword = properties["SIGNED_STORE_PASSWORD"] as String?
}
}
}

dependencies {
Expand Down Expand Up @@ -101,5 +110,8 @@ dependencies {
implementation(libs.androidx.viewpager2)

// Tooltip - Balloon
implementation(libs.balloon)
implementation("com.github.skydoves:balloon:1.4.6")

// LoggerUtils
implementation(libs.logger)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import com.nabi.data.utils.LoggerUtils
import com.nabi.nabi.utils.LoggerUtils

abstract class BaseActivity<T: ViewDataBinding>(@LayoutRes private val layoutId: Int): AppCompatActivity() {
lateinit var binding: T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.nabi.nabi.base

import android.app.Application
import com.kakao.sdk.common.KakaoSdk
import com.kakao.sdk.common.util.Utility
import com.nabi.nabi.utils.LoggerUtils
import com.nabi.nabi.BuildConfig
import dagger.hilt.android.HiltAndroidApp

Expand All @@ -16,5 +18,12 @@ class NabiApplication : Application() {

application = this
KakaoSdk.init(this, BuildConfig.KAKAO_NATIVE_KEY)

getHashKey()
}

private fun getHashKey(){
val keyHash = Utility.getKeyHash(this)
LoggerUtils.i("KeyHash: $keyHash")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import androidx.work.WorkerParameters
import com.google.firebase.messaging.FirebaseMessaging
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import com.nabi.data.utils.LoggerUtils
import com.nabi.nabi.utils.LoggerUtils
import com.nabi.nabi.R
import com.nabi.nabi.views.splash.StartActivity
import kotlinx.coroutines.runBlocking
Expand Down
52 changes: 52 additions & 0 deletions Nabi/presentation/src/main/java/com/nabi/nabi/utils/LoggerUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.nabi.nabi.utils

import com.nabi.nabi.BuildConfig
import com.orhanobut.logger.AndroidLogAdapter
import com.orhanobut.logger.Logger

object LoggerUtils {

init {
if (BuildConfig.DEBUG) {
Logger.addLogAdapter(AndroidLogAdapter())
}
}

private const val TAG = "LOGGER"

fun d(message: String) {
if (BuildConfig.DEBUG) {
Logger.t(TAG).d(message)
}
}

fun i(message: String) {
if (BuildConfig.DEBUG) {
Logger.t(TAG).i(message)
}
}

fun w(message: String) {
if (BuildConfig.DEBUG) {
Logger.t(TAG).w(message)
}
}

fun e(message: String) {
if (BuildConfig.DEBUG) {
Logger.t(TAG).e(message)
}
}

fun json(message: String) {
if (BuildConfig.DEBUG) {
Logger.t(TAG).json(message)
}
}

fun xml(message: String) {
if (BuildConfig.DEBUG) {
Logger.t(TAG).xml(message)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.nabi.nabi.views.diary.add
import android.annotation.SuppressLint
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.nabi.data.utils.LoggerUtils
import com.nabi.nabi.utils.LoggerUtils
import com.nabi.nabi.R
import com.nabi.nabi.base.BaseFragment
import com.nabi.nabi.databinding.FragmentSelectDateBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.nabi.nabi.views.diary.view
import android.os.Bundle
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.GridLayoutManager
import com.nabi.data.utils.LoggerUtils
import com.nabi.nabi.utils.LoggerUtils
import com.nabi.domain.model.diary.DiaryInfo
import com.nabi.nabi.R
import com.nabi.nabi.base.BaseFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.nabi.nabi.views.home

import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.nabi.data.utils.LoggerUtils
import com.nabi.nabi.utils.LoggerUtils
import com.nabi.nabi.R
import com.nabi.nabi.base.BaseFragment
import com.nabi.nabi.databinding.FragmentHomeBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.nabi.data.utils.LoggerUtils
import com.nabi.nabi.utils.LoggerUtils
import com.nabi.domain.model.home.HomeInfo
import com.nabi.domain.repository.DataStoreRepository
import com.nabi.domain.usecase.home.HomeUseCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.view.View
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.content.ContextCompat
import androidx.fragment.app.viewModels
import com.nabi.data.utils.LoggerUtils
import com.nabi.nabi.utils.LoggerUtils
import com.nabi.nabi.R
import com.nabi.nabi.base.BaseFragment
import com.nabi.nabi.databinding.FragmentSignNicknameBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.nabi.nabi.views.sign
import android.content.Intent
import androidx.fragment.app.viewModels
import com.nabi.data.service.KakaoAuthService
import com.nabi.data.utils.LoggerUtils
import com.nabi.nabi.utils.LoggerUtils
import com.nabi.nabi.R
import com.nabi.nabi.base.BaseFragment
import com.nabi.nabi.databinding.FragmentSignProviderBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.nabi.data.utils.LoggerUtils
import com.nabi.nabi.utils.LoggerUtils
import com.nabi.domain.enums.AuthProvider
import com.nabi.domain.repository.DataStoreRepository
import com.nabi.domain.usecase.auth.SignInUseCase
Expand Down
Loading

0 comments on commit e153c57

Please sign in to comment.