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

[PC-596] 설정 페이지 웹뷰 및 API 연결 #67

Merged
merged 10 commits into from
Feb 14, 2025
4 changes: 4 additions & 0 deletions .github/workflows/android_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ jobs:
echo "KAKAO_APP_KEY=${{ secrets.KAKAO_APP_KEY }}" >> local.properties
echo "PIECE_DEV_BASE_URL=${{ secrets.PIECE_DEV_BASE_URL }}" >> local.properties
echo "PIECE_PROD_BASE_URL=${{ secrets.PIECE_PROD_BASE_URL }}" >> local.properties
echo "PIECE_NOTICE_URL=${{ secrets.PIECE_NOTICE_URL }}" >> local.properties
echo "PIECE_PRIVACY_AND_POLICY_URL=${{ secrets.PIECE_PRIVACY_AND_POLICY_URL }}" >> local.properties
echo "PIECE_TERMS_OF_USE_URL=${{ secrets.PIECE_TERMS_OF_USE_URL }}" >> local.properties
echo "PIECE_CHANNEL_TALK_URL=${{ secrets.PIECE_CHANNEL_TALK_URL }}" >> local.properties
echo "GOOGLE_WEB_CLIENT_ID=${{ secrets.GOOGLE_WEB_CLIENT_ID }}" >> local.properties

- name: Create google-services.json
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/android_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ jobs:
echo "KAKAO_APP_KEY=${{ secrets.KAKAO_APP_KEY }}" >> local.properties
echo "PIECE_DEV_BASE_URL=${{ secrets.PIECE_DEV_BASE_URL }}" >> local.properties
echo "PIECE_PROD_BASE_URL=${{ secrets.PIECE_PROD_BASE_URL }}" >> local.properties
echo "PIECE_NOTICE_URL=${{ secrets.PIECE_NOTICE_URL }}" >> local.properties
echo "PIECE_PRIVACY_AND_POLICY_URL=${{ secrets.PIECE_PRIVACY_AND_POLICY_URL }}" >> local.properties
echo "PIECE_TERMS_OF_USE_URL=${{ secrets.PIECE_TERMS_OF_USE_URL }}" >> local.properties
echo "PIECE_CHANNEL_TALK_URL=${{ secrets.PIECE_CHANNEL_TALK_URL }}" >> local.properties
echo "GOOGLE_WEB_CLIENT_ID=${{ secrets.GOOGLE_WEB_CLIENT_ID }}" >> local.properties

- name: Create google-services.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class ImageResizerImpl @Inject constructor(
}

private fun calculateInSampleSize(
options: BitmapFactory.Options, reqWidth: Int, reqHeight: Int
options: BitmapFactory.Options,
reqWidth: Int,
reqHeight: Int,
): Int {
val (height: Int, width: Int) = options.run { outHeight to outWidth }
var inSampleSize = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,31 @@ package com.puzzle.data.repository
import com.puzzle.common.suspendRunCatching
import com.puzzle.datastore.datasource.user.LocalUserDataSource
import com.puzzle.domain.model.user.UserRole
import com.puzzle.domain.model.user.UserSetting
import com.puzzle.domain.repository.UserRepository
import com.puzzle.network.model.user.GetSettingInfoResponse
import com.puzzle.network.source.user.UserDataSource
import kotlinx.coroutines.flow.first
import javax.inject.Inject

class UserRepositoryImpl @Inject constructor(
private val localUserDataSource: LocalUserDataSource,
private val userDataSource: UserDataSource,
) : UserRepository {
override suspend fun getUserRole(): Result<UserRole> = suspendRunCatching {
val userRoleString = localUserDataSource.userRole.first()
UserRole.create(userRoleString)
}

override suspend fun getUserSettingInfo(): Result<UserSetting> =
userDataSource.getSettingsInfo().mapCatching(GetSettingInfoResponse::toDomain)

override suspend fun updatePushNotification(toggle: Boolean): Result<Unit> =
userDataSource.updatePushNotification(toggle)

override suspend fun updateMatchNotification(toggle: Boolean): Result<Unit> =
userDataSource.updateMatchNotification(toggle)

override suspend fun updateBlockAcquaintances(toggle: Boolean): Result<Unit> =
userDataSource.updateBlockAcquaintances(toggle)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.puzzle.designsystem.component

import android.webkit.WebChromeClient
import android.view.ViewGroup
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.compose.runtime.Composable
Expand All @@ -23,9 +23,13 @@ fun PieceWebView(
AndroidView(
factory = {
webView = WebView(context).apply {
settings.javaScriptEnabled = true
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
)
webViewClient = object : WebViewClient() {}
webChromeClient = object : WebChromeClient() {}
settings.javaScriptEnabled = true
settings.domStorageEnabled = true
}
webView!!
},
Expand Down
3 changes: 2 additions & 1 deletion core/designsystem/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

<!--Verification-->
<string name="verification_subtitle">신뢰도 높은 매칭과 안전한 커뮤니티를 위해\n휴대폰 번호로 인증해 주세요.</string>
<string name="verification_submit">확인</string>
<string name="confirm">확인</string>
<string name="verification_next">다음</string>
<string name="verification_do_not_share">어떤 경우에도 타인에게 공유하지 마세요</string>
<string name="verification_verified">전화번호 인증을 완료했어요</string>
Expand Down Expand Up @@ -137,6 +137,7 @@
<string name="setting_screen">Setting</string>
<string name="setting_other">기타</string>
<string name="setting_logout">로그아웃</string>
<string name="setting_logout_description">로그아웃하시겠습니까?</string>
<string name="setting_guidance">안내</string>
<string name="setting_announcement">공지사항</string>
<string name="setting_privacy_policy">개인정보처리방침</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.puzzle.domain.model.user

data class UserSetting(
val isNotificationEnabled: Boolean,
val isMatchNotificationEnabled: Boolean,
val isAcquaintanceBlockEnabled: Boolean,
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.puzzle.domain.repository

import com.puzzle.domain.model.user.UserRole
import com.puzzle.domain.model.user.UserSetting

interface UserRepository {
suspend fun getUserRole(): Result<UserRole>
suspend fun getUserSettingInfo(): Result<UserSetting>
suspend fun updatePushNotification(toggle: Boolean): Result<Unit>
suspend fun updateMatchNotification(toggle: Boolean): Result<Unit>
suspend fun updateBlockAcquaintances(toggle: Boolean): Result<Unit>
}
3 changes: 3 additions & 0 deletions core/navigation/src/main/java/com/puzzle/navigation/Route.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ sealed class SettingGraphDest : Route {

@Serializable
data object WithdrawRoute : SettingGraphDest()

@Serializable
data class WebViewRoute(val title: String, val url: String) : SettingGraphDest()
Comment on lines +31 to +32
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 화면에서는 네비게이션 바가 없어져야 해서 추가했습니다!

}

@Serializable
Expand Down
14 changes: 14 additions & 0 deletions core/network/src/main/java/com/puzzle/network/api/PieceApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import com.puzzle.network.model.terms.AgreeTermsRequest
import com.puzzle.network.model.terms.LoadTermsResponse
import com.puzzle.network.model.token.RefreshTokenRequest
import com.puzzle.network.model.token.RefreshTokenResponse
import com.puzzle.network.model.user.GetSettingInfoResponse
import com.puzzle.network.model.user.UpdateSettingRequest
import okhttp3.MultipartBody
import retrofit2.http.Body
import retrofit2.http.GET
Expand Down Expand Up @@ -123,4 +125,16 @@ interface PieceApi {

@POST("/api/matches/accept")
suspend fun acceptMatching(): Result<ApiResponse<Unit>>

@GET("/api/settings/infos")
suspend fun getSettingInfos(): Result<ApiResponse<GetSettingInfoResponse>>

@PUT("/api/settings/notification")
suspend fun updatePushNotification(@Body updateSettingRequest: UpdateSettingRequest): Result<ApiResponse<Unit>>

@PUT("/api/settings/notification/match")
suspend fun updateMatchNotification(@Body updateSettingRequest: UpdateSettingRequest): Result<ApiResponse<Unit>>

@PUT("/api/settings/block/acquaintance")
suspend fun updateBlockAcquaintances(@Body updateSettingRequest: UpdateSettingRequest): Result<ApiResponse<Unit>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.puzzle.network.model.user

import com.puzzle.domain.model.user.UserSetting
import kotlinx.serialization.Serializable

@Serializable
data class GetSettingInfoResponse(
val isNotificationEnabled: Boolean?,
val isMatchNotificationEnabled: Boolean?,
val isAcquaintanceBlockEnabled: Boolean?,
) {
fun toDomain() = UserSetting(
isNotificationEnabled = isNotificationEnabled ?: false,
isMatchNotificationEnabled = isMatchNotificationEnabled ?: false,
isAcquaintanceBlockEnabled = isAcquaintanceBlockEnabled ?: false,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.puzzle.network.model.user

import kotlinx.serialization.Serializable

@Serializable
data class UpdateSettingRequest(
val toggle: Boolean,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.puzzle.network.source.user

import com.puzzle.network.api.PieceApi
import com.puzzle.network.model.unwrapData
import com.puzzle.network.model.user.GetSettingInfoResponse
import com.puzzle.network.model.user.UpdateSettingRequest
import javax.inject.Inject

class UserDataSource @Inject constructor(
private val pieceApi: PieceApi,
) {
suspend fun getSettingsInfo(): Result<GetSettingInfoResponse> =
pieceApi.getSettingInfos().unwrapData()

suspend fun updatePushNotification(toggle: Boolean): Result<Unit> =
pieceApi.updatePushNotification(UpdateSettingRequest(toggle)).unwrapData()

suspend fun updateMatchNotification(toggle: Boolean): Result<Unit> =
pieceApi.updateMatchNotification(UpdateSettingRequest(toggle)).unwrapData()

suspend fun updateBlockAcquaintances(toggle: Boolean): Result<Unit> =
pieceApi.updateBlockAcquaintances(UpdateSettingRequest(toggle)).unwrapData()
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private fun VerificationScreen(
Spacer(modifier = Modifier.weight(1f))

PieceSolidButton(
label = stringResource(R.string.verification_submit),
label = stringResource(R.string.confirm),
onClick = { navigate(NavigationEvent.NavigateTo(AuthGraphDest.SignUpRoute)) },
enabled = state.authCodeStatus == VERIFIED,
modifier = Modifier
Expand Down Expand Up @@ -282,7 +282,7 @@ private fun AuthCodeBody(
)

PieceSolidButton(
label = stringResource(R.string.verification_submit),
label = stringResource(R.string.confirm),
onClick = onVerifyClick,
enabled = isVerifyButtonEnabled,
modifier = Modifier.padding(start = 8.dp)
Expand Down
31 changes: 31 additions & 0 deletions feature/setting/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
import java.util.Properties

plugins {
id("piece.android.feature")
}

android {
namespace = "com.puzzle.setting"

defaultConfig {
val localProperties = Properties()
localProperties.load(project.rootProject.file("local.properties").bufferedReader())
buildConfigField(
type = "String",
name = "PIECE_CHANNEL_TALK_URL",
value = "\"${localProperties["PIECE_CHANNEL_TALK_URL"]}\""
)
buildConfigField(
type = "String",
name = "PIECE_TERMS_OF_USE_URL",
value = "\"${localProperties["PIECE_TERMS_OF_USE_URL"]}\""
)
buildConfigField(
type = "String",
name = "PIECE_PRIVACY_AND_POLICY_URL",
value = "\"${localProperties["PIECE_PRIVACY_AND_POLICY_URL"]}\""
)
buildConfigField(
type = "String",
name = "PIECE_NOTICE_URL",
value = "\"${localProperties["PIECE_NOTICE_URL"]}\""
)
}

buildFeatures {
buildConfig = true
}
}
Loading