Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ class UserRepository
}
}

suspend fun removeTermsAgreementChecked() {
userStorage.edit { preferences ->
preferences.remove(TERMS_AGREEMENT_CHECKED_KEY)
}
}

companion object {
val NOVEL_DETAIL_FIRST_LAUNCHED_KEY = booleanPreferencesKey("NOVEL_DETAIL_FIRST_LAUNCHED")
val TERMS_AGREEMENT_CHECKED_KEY = booleanPreferencesKey("terms_agreement_checked")
Expand Down
15 changes: 11 additions & 4 deletions app/src/main/java/com/into/websoso/ui/main/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,17 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
updateFCMToken(isFirstLaunch = false)
}

homeViewModel.showTermsAgreementDialog.collectWithLifecycle(viewLifecycleOwner) { shouldShow ->
if (shouldShow) {
showTermsAgreementDialog()
}
homeViewModel.showTermsAgreementDialog.collectWithLifecycle(viewLifecycleOwner) { isShown ->
if (!isShown) return@collectWithLifecycle

val existingDialog =
parentFragmentManager.findFragmentByTag(TermsAgreementDialogFragment.TERMS_AGREEMENT_TAG)
val existingBottomSheet =
parentFragmentManager.findFragmentByTag(TermsAgreementDialogFragment.TERMS_AGREEMENT_BOTTOM_SHEET_TAG)

if (existingDialog != null || existingBottomSheet != null) return@collectWithLifecycle

showTermsAgreementDialog()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,20 @@ class TermsAgreementDialogFragment :
}

private fun showTermsAgreementBottomSheet() {
TermsAgreementDialogBottomSheet
.newInstance(isFromHome = true)
.show(parentFragmentManager, "TermsAgreementDialogBottomSheet")
val isBottomSheetShown =
parentFragmentManager.findFragmentByTag(TERMS_AGREEMENT_BOTTOM_SHEET_TAG)

if (isBottomSheetShown == null) {
TermsAgreementDialogBottomSheet
.newInstance(isFromHome = true)
.show(parentFragmentManager, TERMS_AGREEMENT_BOTTOM_SHEET_TAG)
}
dismiss()
}

companion object {
const val TERMS_AGREEMENT_TAG = "TermsAgreementDialog"
const val TERMS_AGREEMENT_BOTTOM_SHEET_TAG = "TermsAgreementDialogBottomSheet"

fun newInstance(): TermsAgreementDialogFragment = TermsAgreementDialogFragment()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.into.websoso.ui.termsAgreement

import android.content.DialogInterface
import android.content.Intent
import android.net.Uri
import android.os.Bundle
Expand All @@ -24,6 +25,7 @@ import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class TermsAgreementDialogBottomSheet : BaseBottomSheetDialog<DialogTermsAgreementBinding>(R.layout.dialog_terms_agreement) {
private val termsAgreementViewModel: TermsAgreementViewModel by viewModels()
private var onDismissListener: (() -> Unit)? = null

override fun onViewCreated(
view: View,
Expand Down Expand Up @@ -69,7 +71,7 @@ class TermsAgreementDialogBottomSheet : BaseBottomSheetDialog<DialogTermsAgreeme
}

private fun onTermsAgreementToggleClick() {
binding.ivTermsAgreementAll.setOnClickListener { termsAgreementViewModel.updateTermsAgreementsAll() }
binding.llTermsAgreementAll.setOnClickListener { termsAgreementViewModel.updateTermsAgreementsAll() }

binding.ivTermsAgreementService.setOnClickListener {
termsAgreementViewModel.updateTermsAgreements(
Expand All @@ -95,7 +97,7 @@ class TermsAgreementDialogBottomSheet : BaseBottomSheetDialog<DialogTermsAgreeme
}

private fun sendTermsAgreement() {
if (!termsAgreementViewModel.isRequiredAgreementsChecked.value) return // 필수 항목 미체크 시 요청 안 함
if (!termsAgreementViewModel.isRequiredAgreementsChecked.value) return

termsAgreementViewModel.saveTermsAgreements()
}
Expand Down Expand Up @@ -153,6 +155,11 @@ class TermsAgreementDialogBottomSheet : BaseBottomSheetDialog<DialogTermsAgreeme
}
}

override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
onDismissListener?.invoke()
}

companion object {
private const val IS_FROM_HOME_TAG = "IS_FROM_HOME"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.into.websoso.data.repository.AuthRepository
import com.into.websoso.data.repository.UserRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class WithdrawSecondViewModel @Inject constructor(
private val authRepository: AuthRepository,
private val userRepository: UserRepository,
) : ViewModel() {
private val _withdrawReason: MutableLiveData<String> = MutableLiveData("")
val withdrawReason: LiveData<String> get() = _withdrawReason
Expand Down Expand Up @@ -77,6 +79,7 @@ class WithdrawSecondViewModel @Inject constructor(
authRepository.withdraw(withdrawReason)
}.onSuccess {
_isWithDrawSuccess.value = true
userRepository.removeTermsAgreementChecked()
authRepository.updateIsAutoLogin(false)
}.onFailure {
_isWithDrawSuccess.value = false
Expand All @@ -87,4 +90,4 @@ class WithdrawSecondViewModel @Inject constructor(
companion object {
private const val ETC_INPUT_REASON = "직접입력"
}
}
}
5 changes: 4 additions & 1 deletion app/src/main/res/layout/dialog_terms_agreement.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
android:background="@drawable/btn_feed_novel_info"
android:orientation="horizontal"
android:gravity="center_vertical"
android:padding="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_terms_agreement_sub_title">
Expand All @@ -50,6 +49,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingHorizontal="16dp"
android:paddingVertical="8dp"
android:text="@string/string_terms_agreement_all"
android:textAppearance="@style/title2"
android:textColor="@color/primary_100_6A5DFD" />
Expand All @@ -58,6 +59,8 @@
android:id="@+id/iv_terms_agreement_All"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="16dp"
android:paddingVertical="16dp"
android:src="@drawable/ic_terms_agreement_unselected" />
</LinearLayout>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/deepLinks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<string name="privacy_policy_link">https://websoso.notion.site/143600bd746880668556fb005fcef491?pvs=4</string>
<string name="minimum_version_popup_menu_url">https://play.google.com/store/apps/details?id=com.into.websoso</string>
<string name="terms_agreement_service">https://www.notion.so/websoso/143600bd74688050be18f4da31d9403e?pvs=4</string>
<string name="terms_agreement_privacy">https://www.notion.so/kimmjabc/18e9e64a45328048842ed4dd7b17e5b3?pvs=25</string>
<string name="terms_agreement_privacy">https://websoso.notion.site/198600bd746880699fd6f22dd42a7215?pvs=4</string>

</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@

<!-- 약관동의 바텀시트 뷰-->
<string name="string_terms_agreement_service"><u>서비스 이용약관 동의</u> (필수)</string>
<string name="string_terms_agreement_privacy"><u>개인정보 수집 및 이용 안내</u> (필수)</string>
<string name="string_terms_agreement_privacy"><u>개인정보 수집 및 이용 동의</u> (필수)</string>
<string name="string_terms_agreement_marketing">마켓팅 정보 수신 동의 (선택)</string>
<string name="string_terms_agreement_next">다음으로</string>
<string name="string_terms_agreement_complete">완료</string>
Expand Down