Skip to content

Commit

Permalink
버그 수정 및 코드 개선 (#120)
Browse files Browse the repository at this point in the history
* fix: 프로필 이미지 선택 화면에서 권한 요청 관련 무한 loop 유발 코드 삭제

* feat: 회원 탈퇴 시 삭제 가능 여부 확인 로직 추가

* style: 안내 View에 dark theme 적용

* feat: 계정 삭제 요청 주소가 아직 로딩 되지 않은 경우 대응

* chore: 약관 화면 삭제

* style: 다크 theme 대응되는 색상 조정

* refactor: WorkManager의 state를 이용해 delay 없이 결괏값 관측할 수 있도록 수정
  • Loading branch information
DoTheBestMayB authored Jul 4, 2024
1 parent 9d442d2 commit f169de2
Show file tree
Hide file tree
Showing 23 changed files with 125 additions and 81 deletions.
7 changes: 7 additions & 0 deletions app/src/main/java/com/bestapp/zipbab/model/SignOutState.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.bestapp.zipbab.model

sealed interface SignOutState {
data object Success: SignOutState
data object Fail: SignOutState
data object IsNotAllowed: SignOutState
}
10 changes: 9 additions & 1 deletion app/src/main/java/com/bestapp/zipbab/model/UiStateMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ import com.bestapp.zipbab.args.SelectImageArgs
import com.bestapp.zipbab.ui.profile.ProfileUiState
import com.bestapp.zipbab.ui.profileedit.ProfileEditUiState
import com.bestapp.zipbab.data.model.local.GalleryImageInfo
import com.bestapp.zipbab.data.model.local.SignOutEntity
import com.bestapp.zipbab.ui.profilepostimageselect.model.PostGalleryUiState
import com.bestapp.zipbab.ui.profilepostimageselect.model.SelectedImageUiState
import com.bestapp.zipbab.ui.profilepostimageselect.model.SubmitInfo

// Data -> UiState

fun SignOutEntity.toUiState(): SignOutState {
return when(this) {
SignOutEntity.Fail -> SignOutState.Fail
SignOutEntity.IsNotAllowed -> SignOutState.IsNotAllowed
SignOutEntity.Success -> SignOutState.Success
}
}
fun FilterResponse.Cost.toUiState() = FilterUiState.CostUiState(
name = name,
icon = icon,
Expand Down Expand Up @@ -216,7 +224,7 @@ fun SelectedImageUiState.toGalleryUiState() = PostGalleryUiState(
order = order,
)

// Ui -> UiState
// Args -> UiState

fun ProfileEditArgs.toUiState() = ProfileEditUiState(
userDocumentID = userDocumentID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,6 @@ class ProfileImageSelectFragment : Fragment() {
permissionManager.requestFullImageAccessPermission(requestMultiplePermissionLauncher) {
onGranted()
}
} else {
permissionManager.requestPartialImageAccessPermission(
requestMultiplePermissionLauncher,
false
) {
onGranted()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,19 @@ class SettingFragment : Fragment() {
val text = when (message) {
SettingMessage.LOGOUT_FAIL -> getString(R.string.message_when_log_out_fail)
SettingMessage.SIGN_OUT_FAIL -> getString(R.string.message_when_sign_out_fail)
SettingMessage.SIGN_OUT_IS_NOT_ALLOWED -> getString(R.string.sign_out_is_not_allowed)
}
Toast.makeText(requireContext(), text, Toast.LENGTH_LONG).show()
}
}
launch {
viewModel.requestDeleteUrl.collect { url ->
binding.userDocumentIdInstructionView.tvUrl.setOnClickListener {
// 인터넷 연결이 느려서 로딩이 안 된 경우 대응
if (url.isBlank()) {
showNotYetLoaded(getString(R.string.text_for_delete_request_title))
return@setOnClickListener
}
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.bestapp.zipbab.ui.setting

enum class SettingMessage {
LOGOUT_FAIL, SIGN_OUT_FAIL
LOGOUT_FAIL, SIGN_OUT_FAIL, SIGN_OUT_IS_NOT_ALLOWED
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.lifecycle.viewModelScope
import com.bestapp.zipbab.data.model.remote.Privacy
import com.bestapp.zipbab.data.repository.AppSettingRepository
import com.bestapp.zipbab.data.repository.UserRepository
import com.bestapp.zipbab.model.SignOutState
import com.bestapp.zipbab.model.UserUiState
import dagger.hilt.android.lifecycle.HiltViewModel
import com.bestapp.zipbab.model.toUiState
Expand Down Expand Up @@ -78,12 +79,14 @@ class SettingViewModel @Inject constructor(
viewModelScope.launch {
runCatching {
val userDocumentID = userUiState.firstOrNull()?.userDocumentID ?: return@runCatching
val isSuccess = userRepository.signOutUser(userDocumentID)
if (isSuccess) {
appSettingRepository.removeUserDocumentId()
} else {
_message.emit(SettingMessage.SIGN_OUT_FAIL)
val signOutState = userRepository.signOutUser(userDocumentID).toUiState()
when (signOutState) {
SignOutState.Fail -> _message.emit(SettingMessage.SIGN_OUT_FAIL)
SignOutState.IsNotAllowed -> _message.emit(SettingMessage.SIGN_OUT_IS_NOT_ALLOWED)
SignOutState.Success -> appSettingRepository.removeUserDocumentId()
}
}.onFailure {
throw it
}
}
}
Expand Down
30 changes: 0 additions & 30 deletions app/src/main/java/com/bestapp/zipbab/ui/term/TermFragment.kt

This file was deleted.

4 changes: 2 additions & 2 deletions app/src/main/res/drawable/instruction_background.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/guidance_color" />
<solid android:color="@color/instruction_view_color" />

<stroke
android:width="3dp"
android:color="@color/guidance_color" />
android:color="@color/instruction_view_color" />

<corners android:radius="4dp" />

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/triangle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
android:viewportHeight="100"
android:viewportWidth="100">
<path
android:fillColor="@color/guidance_color"
android:fillColor="@color/instruction_view_color"
android:pathData="m 50,0 l 50,100 -100,0 z" />
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/upper_triangle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
android:viewportHeight="100"
android:viewportWidth="100">
<path
android:fillColor="@color/guidance_color"
android:fillColor="@color/instruction_view_color"
android:pathData="m 50,100 l -50,-100 100,0 z" />
</vector>
9 changes: 0 additions & 9 deletions app/src/main/res/layout/fragment_term.xml

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/res/layout/temperature_instruction_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
android:maxEms="15"
android:padding="12dp"
android:text="@string/temperature_instruction"
android:textColor="@color/white"
android:textColor="@color/text_reverse_color"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/user_document_id_instruction_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:layout_margin="@dimen/default_margin8"
android:maxEms="10"
android:text="@string/user_document_id_instruction"
android:textColor="@color/white"
android:textColor="@color/text_reverse_color"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="@id/v_background"
Expand All @@ -43,7 +43,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/text_for_delete_request_url"
android:textColor="@color/white"
android:textColor="@color/text_reverse_color"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginBottom="@dimen/default_margin8"
Expand Down
8 changes: 0 additions & 8 deletions app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,11 @@
android:name="com.bestapp.zipbab.ui.signup.SignUpFragment"
android:label="fragment_sign_up"
tools:layout="@layout/fragment_sign_up">
<action
android:id="@+id/action_signUpFragment_to_termFragment"
app:destination="@id/termFragment" />
<action
android:id="@+id/action_signUpFragment_to_loginFragment"
app:destination="@id/loginFragment"
app:popUpTo="@id/settingFragment"/>
</fragment>
<fragment
android:id="@+id/termFragment"
android:name="com.bestapp.zipbab.ui.term.TermFragment"
android:label="fragment_term"
tools:layout="@layout/fragment_term" />
<fragment
android:id="@+id/profileFragment"
android:name="com.bestapp.zipbab.ui.profile.ProfileFragment"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="drawable_default_color">@color/white</color>
<color name="text_reverse_color">@color/black</color>
<color name="main_color">#34C5F0</color>
<color name="main_color_light">#99C5D8</color>
<color name="main_color_transparent_20">#3334C5F0</color>
Expand Down Expand Up @@ -36,4 +37,5 @@
<color name="snackbar_background">#121212</color>
<color name="snackbar_text">#ffffff</color>
<color name="bottomsheet_background_color">#121212</color>
<color name="instruction_view_color">@color/white</color>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="drawable_default_color">@color/black</color>
<color name="text_reverse_color">@color/white</color>
<color name="main_color">#34C5F0</color>
<color name="main_color_light">#99C5D8</color>
<color name="main_color_transparent_20">#3334C5F0</color>
Expand Down Expand Up @@ -38,4 +39,5 @@
<color name="snackbar_background">#CC121212</color>
<color name="snackbar_text">#ffffff</color>
<color name="bottomsheet_background_color">#FFFFFF</color>
<color name="instruction_view_color">#202123</color>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@

<string name="user_document_id_instruction">계정 삭제 요청 시 사용하는 고유번호입니다.</string>
<string name="text_for_delete_request_url"><u>삭제 요청 바로가기</u></string>
<string name="text_for_delete_request_title"><u>삭제 요청 주소</u></string>
<string name="label_user_document_id">사용자 고유 식별 번호</string>
<string name="user_document_id_is_copied">사용자 고유 식별 번호가 복사되었습니다.</string>
<string name="meeting_list_title">내 모임 보기</string>
Expand Down Expand Up @@ -185,4 +186,5 @@
<string name="recruit_default_image"><![CDATA[https://firebasestorage.googleapis.com/v0/b/food-879fc.appspot.com/o/dummy%2F30120875_7640343.jpg?alt=media&token=eee9fbba-8544-451f-857b-c0bea1b2e768]]></string>
<string name="not_yet_loaded">%1$s가(이) 아직 로딩 되지 않았습니다. 인터넷 연결 상태를 확인해주세요.</string>
<string name="user_info">사용자 정보</string>
<string name="sign_out_is_not_allowed">회원 탈퇴가 허용되지 않은 계정입니다.</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ class FirestoreDB @Inject constructor(
return firebaseFirestore.collection("token")
}

fun getPolicyDB() : CollectionReference {
return firebaseFirestore.collection("policy")
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.bestapp.zipbab.data.model.local

sealed interface SignOutEntity {
data object Success: SignOutEntity
data object Fail: SignOutEntity
data object IsNotAllowed: SignOutEntity
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.bestapp.zipbab.data.model.remote

data class SignOutForbiddenResponse(
val userDocumentIDs: List<String> = listOf(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.graphics.Bitmap
import com.bestapp.zipbab.data.model.remote.Review
import com.bestapp.zipbab.data.notification.fcm.AccessToken
import com.bestapp.zipbab.data.model.UploadStateEntity
import com.bestapp.zipbab.data.model.local.SignOutEntity
import com.bestapp.zipbab.data.model.remote.NotificationTypeResponse
import com.bestapp.zipbab.data.model.remote.UserResponse
import kotlinx.coroutines.flow.Flow
Expand All @@ -13,7 +14,7 @@ interface UserRepository {
suspend fun getUser(userDocumentID: String): UserResponse
suspend fun login(id: String, pw: String): String
suspend fun signUpUser(userResponse: UserResponse): String
suspend fun signOutUser(userDocumentID: String): Boolean
suspend fun signOutUser(userDocumentID: String): SignOutEntity
suspend fun updateUserNickname(userDocumentID: String, nickname: String): Boolean
suspend fun updateUserTemperature(reviews: List<Review>): Boolean
suspend fun updateUserMeetingCount(userDocumentID: String): Boolean
Expand Down
Loading

0 comments on commit f169de2

Please sign in to comment.