diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3434f77c..1d0746f5 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -28,7 +28,7 @@ android { applicationId = "com.teamwiney.winey" minSdk = 24 targetSdk = 34 - versionCode = 1 + versionCode = 2 versionName = "1.0" signingConfig = signingConfigs.getByName("debug") diff --git a/data/src/main/java/com/teamwiney/data/di/NetworkModule.kt b/data/src/main/java/com/teamwiney/data/di/NetworkModule.kt index b3bcd3a0..39ceffef 100644 --- a/data/src/main/java/com/teamwiney/data/di/NetworkModule.kt +++ b/data/src/main/java/com/teamwiney/data/di/NetworkModule.kt @@ -32,19 +32,23 @@ object NetworkModule { fun providesOkHttpClient( authInterceptor: AuthInterceptor, @ApplicationContext context: Context - ): OkHttpClient = - OkHttpClient.Builder() + ): OkHttpClient { + val builder = OkHttpClient.Builder() .addInterceptor(authInterceptor) .addNetworkInterceptor( - HttpLoggingInterceptor() - .apply { - if (BuildConfig.DEBUG) { - setLevel(HttpLoggingInterceptor.Level.BODY) - } + HttpLoggingInterceptor().apply { + if (BuildConfig.DEBUG) { + level = HttpLoggingInterceptor.Level.BODY } + } ) - .addNetworkInterceptor(ChuckerInterceptor(context)) - .build() + + if (BuildConfig.DEBUG) { + builder.addNetworkInterceptor(ChuckerInterceptor(context)) + } + + return builder.build() + } @Provides @Singleton diff --git a/feature/mypage/build.gradle.kts b/feature/mypage/build.gradle.kts index 73875ebd..4c6c6efa 100644 --- a/feature/mypage/build.gradle.kts +++ b/feature/mypage/build.gradle.kts @@ -53,4 +53,7 @@ dependencies { implementation(libs.bundles.hilt.navigation) implementation(libs.lifecycle.runtime.compose) implementation(libs.datastore) + + implementation(libs.kakao.sdk.user) + implementation(libs.play.services.auth) } \ No newline at end of file diff --git a/feature/mypage/src/main/java/com/teamwiney/mypage/MyPageViewModel.kt b/feature/mypage/src/main/java/com/teamwiney/mypage/MyPageViewModel.kt index 6f331696..584d76cd 100644 --- a/feature/mypage/src/main/java/com/teamwiney/mypage/MyPageViewModel.kt +++ b/feature/mypage/src/main/java/com/teamwiney/mypage/MyPageViewModel.kt @@ -1,7 +1,11 @@ package com.teamwiney.mypage +import android.app.Activity import androidx.lifecycle.viewModelScope import androidx.navigation.navOptions +import com.google.android.gms.auth.api.signin.GoogleSignIn +import com.google.android.gms.auth.api.signin.GoogleSignInOptions +import com.kakao.sdk.user.UserApiClient import com.teamwiney.core.common.base.BaseViewModel import com.teamwiney.core.common.navigation.AuthDestinations import com.teamwiney.core.common.navigation.HomeDestinations @@ -209,7 +213,7 @@ class MyPageViewModel @Inject constructor( } } - fun withdrawal() = viewModelScope.launch { + fun withdrawal(activity: Activity) = viewModelScope.launch { val userId = runBlocking { dataStoreRepository.getIntValue(USER_ID).first() } val reason = if (currentState.isWithdrawalReasonDirectInput) { currentState.withdrawalReasonDirectInput @@ -223,6 +227,20 @@ class MyPageViewModel @Inject constructor( updateState(currentState.copy(isLoading = false)) when (it) { is ApiResult.Success -> { + val googleSignInClient = GoogleSignIn.getClient( + activity, + GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).build() + ) + googleSignInClient.signOut() + + UserApiClient.instance.logout { error -> + if (error != null) { + postEffect( + MyPageContract.Effect.ShowSnackBar("${error.message}") + ) + } + } + dataStoreRepository.deleteStringValue(ACCESS_TOKEN) dataStoreRepository.deleteStringValue(REFRESH_TOKEN) postEffect( @@ -276,7 +294,7 @@ class MyPageViewModel @Inject constructor( } } - fun logOut() = viewModelScope.launch { + fun logOut(activity: Activity) = viewModelScope.launch { val deviceId = runBlocking { dataStoreRepository.getStringValue(DEVICE_ID).first() } authRepository.logOut(deviceId).onStart { @@ -285,6 +303,20 @@ class MyPageViewModel @Inject constructor( updateState(currentState.copy(isLoading = false)) when (it) { is ApiResult.Success -> { + val googleSignInClient = GoogleSignIn.getClient( + activity, + GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).build() + ) + googleSignInClient.signOut() + + UserApiClient.instance.logout { error -> + if (error != null) { + postEffect( + MyPageContract.Effect.ShowSnackBar("${error.message}") + ) + } + } + postEffect(MyPageContract.Effect.NavigateTo( AuthDestinations.Login.ROUTE, navOptions = navOptions { popUpTo(HomeDestinations.ROUTE) { diff --git a/feature/mypage/src/main/java/com/teamwiney/mypage/account/MyPageAccountScreen.kt b/feature/mypage/src/main/java/com/teamwiney/mypage/account/MyPageAccountScreen.kt index 758ddf8f..d86f2fd7 100644 --- a/feature/mypage/src/main/java/com/teamwiney/mypage/account/MyPageAccountScreen.kt +++ b/feature/mypage/src/main/java/com/teamwiney/mypage/account/MyPageAccountScreen.kt @@ -1,5 +1,6 @@ package com.teamwiney.mypage.account +import android.app.Activity import androidx.activity.compose.BackHandler import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -20,6 +21,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.unit.dp @@ -43,6 +45,7 @@ fun MyPageAccountScreen( bottomSheetState: WineyBottomSheetState ) { val effectFlow = viewModel.effect + val activity = LocalContext.current as Activity BackHandler { if (bottomSheetState.bottomSheetState.isVisible) { @@ -70,7 +73,7 @@ fun MyPageAccountScreen( MyPageLogOutBottomSheet( onConfirm = { bottomSheetState.hideBottomSheet() - viewModel.logOut() + viewModel.logOut(activity) }, onCancel = { bottomSheetState.hideBottomSheet() diff --git a/feature/mypage/src/main/java/com/teamwiney/mypage/account/MyPageWithdrawalConfirmScreen.kt b/feature/mypage/src/main/java/com/teamwiney/mypage/account/MyPageWithdrawalConfirmScreen.kt index 1d06f1ca..1f4f3195 100644 --- a/feature/mypage/src/main/java/com/teamwiney/mypage/account/MyPageWithdrawalConfirmScreen.kt +++ b/feature/mypage/src/main/java/com/teamwiney/mypage/account/MyPageWithdrawalConfirmScreen.kt @@ -39,7 +39,7 @@ fun MyPageWithdrawalConfirmScreen( ) { val effectFlow = viewModel.effect - val activity = (LocalContext.current as? Activity) + val activity = LocalContext.current as Activity LaunchedEffect(true) { effectFlow.collectLatest { effect -> @@ -57,7 +57,7 @@ fun MyPageWithdrawalConfirmScreen( is MyPageContract.BottomSheet.WithdrawalComplete -> { bottomSheetState.showBottomSheet { MyPageWithdrawalCompleteBottomSheet { - activity?.finish() + activity.finish() } } } @@ -149,7 +149,7 @@ fun MyPageWithdrawalConfirmScreen( WButton( text = "계정 삭제", - onClick = { viewModel.withdrawal() }, + onClick = { viewModel.withdrawal(activity) }, modifier = Modifier.padding(bottom = 20.dp) ) }