Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/#159-qa
Browse files Browse the repository at this point in the history
  • Loading branch information
lsakee authored Mar 6, 2024
2 parents 894bbf6 + 02cee44 commit 57f7e1c
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class LinkMindBottomSheet(context: Context) {

fun setBottomSheetText(text: String) {
binding.etvBottomSheet.editText.setText(text)
binding.etvBottomSheet.setEditTextSelection()
}

fun bottomSheetConfirmBtnClick(onClick: (String) -> Unit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class LinkMindEditTextBox @JvmOverloads constructor(
fun checkTextLength(value: Int) =
binding.editText.text.length >= value

fun setEditTextSelection() = binding.editText.setSelection(editText.text.length)

fun onClickTextClear(onClick: () -> Unit) {
binding.ivCancel.onThrottleClick {
binding.editText.text.clear()
Expand Down
2 changes: 1 addition & 1 deletion core/designsystem/src/main/res/font/font_suit_medium.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:font="@font/suit_bold"
android:font="@font/suit_medium"
android:fontStyle="normal"
android:fontWeight="500" />
</font-family>
16 changes: 8 additions & 8 deletions core/designsystem/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


<!-- mypage -->
<string name="mypage_link_number_now">지금 까지 읽은 링크수</string>
<string name="mypage_link_number_now">지금까지 읽은 링크 수</string>
<string name="mypage_number">개</string>
<string name="mypage_this_week_read_link">이번주 열람한 링크</string>
<string name="mypage_this_week_save_link">이번주 저장한 링크</string>
Expand Down Expand Up @@ -61,8 +61,8 @@
<string name="settings_withdraw">탈퇴하기</string>
<string name="settings_logout">로그아웃</string>
<string name="settings_term">이용약관</string>
<string name="settings_question">1:1문의</string>
<string name="settings_alert">알림설정</string>
<string name="settings_question">1:1 문의</string>
<string name="settings_alert">알림 설정</string>

<!-- edit clip -->
<string name="edit_clip_guide_msg">클립을 누른 뒤 위아래로 드래그하여 순서를 수정하세요!</string>
Expand Down Expand Up @@ -97,7 +97,7 @@
<string name="clip_unread_link">미열람</string>
<string name="clip_ex_num_count">n개</string>
<string name="clip_text_clip">clip</string>
<string name="clip_already_read">읽음</string>
<string name="clip_already_read">열람</string>
<string name="clip_text_title">Title</string>
<string name="clip_ex_url">https://~~</string>

Expand All @@ -120,15 +120,15 @@


<!-- home -->
<string name="home_correction_clip">클립수정</string>
<string name="home_add_clip">클립추가</string>
<string name="home_correction_clip">클립 수정</string>
<string name="home_add_clip">클립 추가</string>
<string name="home_new_clip_info">"새로운 클립의 이름을 입력해주세요"</string>
<string name="home_error_clip_info">공백 또는 15글자 이상은 안됩니다.</string>
<string name="home_error_clip_info">클립의 이름은 최대 15자까지 입력 가능해요</string>
<string name="home_enter_search_word">검색어를 입력해주세요</string>
<string name="home_ex_user_name">홍길동</string>
<string name="home_name_nim">님</string>
<string name="home_with_toaster">토스터로</string>
<string name="home_link_count">0개의 링크</string>
<string name="home_link_count"> 0개의 링크</string>
<string name="home_collect_stamps">를</string>
<string name="home_unforget_read">잊지 않고 읽었어요!</string>
<string name="home_toast_progress_link">nn</string>
Expand Down
5 changes: 3 additions & 2 deletions feature/clip/src/main/java/org/sopt/clip/clip/ClipFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ class ClipFragment : BindingFragment<FragmentClipBinding>({ FragmentClipBinding.
is UiState.Success -> {
if (!state.data.isDuplicate) {
requireContext().linkMindSnackBar(binding.vSnack, "클립 생성 완료!", false)
viewModel.initializeDuplicateState()
} else {
requireContext().linkMindSnackBar(binding.vSnack, "이미 같은 이름의 클립이 있습니다.", false)
viewModel.updateDuplicateState()
viewModel.initializeDuplicateState()
}
}
else -> {}
Expand All @@ -97,7 +98,7 @@ class ClipFragment : BindingFragment<FragmentClipBinding>({ FragmentClipBinding.

private fun initClipAdapter() {
clipAdapter = ClipAdapter { category ->
val action = ClipFragmentDirections.actionNavigationClipToNavigationClipLink(category.categoryId ?: 0)
val action = ClipFragmentDirections.actionNavigationClipToNavigationClipLink(category.categoryId ?: 0, category.categoryTitle ?: "전체 클립")
findNavController().navigate(action)
}
binding.rvClipClip.adapter = clipAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class ClipViewModel @Inject constructor(
fun updateDuplicateState() = viewModelScope.launch {
_duplicateState.emit(UiState.Success(CategoryDuplicate(false)))
}

fun initializeDuplicateState() = viewModelScope.launch {
_duplicateState.emit(UiState.Empty)
}
fun getCategoryDuplicate(title: String) = viewModelScope.launch {
getCategoryDuplicate.invoke(param = GetCategoryDuplicateUseCase.Param(title)).onSuccess {
Log.d("test", "$it")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import org.sopt.ui.fragment.viewLifeCycleScope
import org.sopt.ui.nav.DeepLinkUtil
import org.sopt.ui.view.UiState
import org.sopt.ui.view.onThrottleClick
import java.net.URLEncoder
import java.nio.charset.StandardCharsets

@AndroidEntryPoint
class ClipLinkFragment : BindingFragment<FragmentClipLinkBinding>({ FragmentClipLinkBinding.inflate(it) }) {
Expand All @@ -31,12 +33,15 @@ class ClipLinkFragment : BindingFragment<FragmentClipLinkBinding>({ FragmentClip
var isDataNull: Boolean = true
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel.initState()
val args: ClipLinkFragmentArgs by navArgs()
val categoryId = args.categoryId
val categoryName = args.categoryName
if (args.categoryId.toInt() == 0) {
viewModel.getCategoryLink("ALL", 0)
} else {
viewModel.getCategoryLink("ALL", categoryId)
binding.tvClipLinkTitle.text = categoryName
}
binding.tvClipLinkEntire.setOnClickListener {
updateState(
Expand Down Expand Up @@ -208,7 +213,8 @@ class ClipLinkFragment : BindingFragment<FragmentClipLinkBinding>({ FragmentClip
}

private fun naviagateToWebViewFragment(site: String, toastId: Long, isRead: Boolean) {
navigateToDestination("featureSaveLink://webViewFragment?site=$site,,,$toastId,,,$isRead")
val encodedURL = URLEncoder.encode(site, StandardCharsets.UTF_8.toString())
navigateToDestination("featureSaveLink://webViewFragment/$toastId/$isRead/${true}/$encodedURL")
}

private fun onClickBackButton() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ class ClipLinkViewModel @Inject constructor(
Log.d("카테 안의 링크 검색", it.message.toString())
}
}

fun initState() {
_linkState.value = UiState.Empty
}
}
30 changes: 18 additions & 12 deletions feature/clip/src/main/java/org/sopt/clip/webview/WebViewFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.lifecycle.flowWithLifecycle
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import dagger.hilt.android.AndroidEntryPoint
import designsystem.components.toast.linkMindSnackBar
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.sopt.clip.R
Expand All @@ -26,18 +27,21 @@ import org.sopt.ui.context.hideKeyboard
import org.sopt.ui.fragment.viewLifeCycle
import org.sopt.ui.fragment.viewLifeCycleScope
import org.sopt.ui.view.onThrottleClick
import java.net.URLDecoder
import java.nio.charset.StandardCharsets

@AndroidEntryPoint
class WebViewFragment : BindingFragment<FragmentWebviewBinding>({ FragmentWebviewBinding.inflate(it) }) {
private val viewModel: WebViewViewModel by viewModels()
val args: WebViewFragmentArgs by navArgs()
var isRead: Boolean = false
var isPatched: Boolean = false

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val decodedURL = URLDecoder.decode(args.site, StandardCharsets.UTF_8.toString())
binding.wbClip.settings.javaScriptEnabled = true
val arg = args.site.split(",,,")
if (arg.size == 3) {
when (arg[2].toBoolean()) {
if (args.isMylink) {
when (args.isRead) {
true -> {
viewModel.patchReadLinkResult.value = true
}
Expand All @@ -46,31 +50,33 @@ class WebViewFragment : BindingFragment<FragmentWebviewBinding>({ FragmentWebvie
viewModel.patchReadLinkResult.value = false
}
}
if (arg[1].toInt() == 0) {
binding.ivRead.isInvisible = true
binding.ivRead.isClickable = false
}
} else {
binding.ivRead.isInvisible = true
binding.ivRead.isClickable = false
}
Log.d("test", "$arg")

binding.ivRead.onThrottleClick {
Log.e("읽음", "누름")
if (arg.size == 3) viewModel.patchReadLink(arg[1].toLong(), !viewModel.patchReadLinkResult.value)
if (args.isMylink) {
viewModel.patchReadLink(args.toastId, !viewModel.patchReadLinkResult.value)
isPatched = true
}
}

viewModel.patchReadLinkResult.flowWithLifecycle(viewLifeCycle).onEach {
when (it) {
true -> {
binding.ivRead.setImageResource(org.sopt.mainfeature.R.drawable.ic_read_after_24)
if (isPatched) requireActivity().linkMindSnackBar(binding.clBottomBar, "열람 완료")
}

false -> {
binding.ivRead.setImageResource(R.drawable.ic_read_before_24)
if (isPatched) requireActivity().linkMindSnackBar(binding.clBottomBar, "열람 취소")
}
}
}.launchIn(viewLifeCycleScope)
Log.e("어케나오노", arg[0])
setupWebView(arg[0])
setupWebView(decodedURL)
onClickClipLink()
onClickWebViewClose()
onClickWebViewReStart()
Expand Down
16 changes: 14 additions & 2 deletions feature/clip/src/main/res/navigation/nav_graph_clip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
<argument
android:name="categoryId"
app:argType="long"/>
<argument
android:name="categoryName"
app:argType="string"/>
<deepLink
app:uri="featureSaveLink://ClipLinkFragment?categoryId={categoryId}" />
app:uri="featureSaveLink://ClipLinkFragment/{categoryId}/{categoryName}" />
<action
android:id="@+id/action_navigation_clip_link_to_webViewFragment"
app:destination="@id/webViewFragment" />
Expand All @@ -38,8 +41,17 @@
<argument
android:name="site"
app:argType="string" />
<argument
android:name="toastId"
app:argType="long" />
<argument
android:name="isRead"
app:argType="boolean" />
<argument
android:name="isMylink"
app:argType="boolean" />
<deepLink
app:uri="featureSaveLink://webViewFragment?site={site}" />
app:uri="featureSaveLink://webViewFragment/{toastId}/{isRead}/{isMylink}/{site}" />
</fragment>
<fragment
android:id="@+id/navigation_clip_edit"
Expand Down
1 change: 1 addition & 0 deletions feature/home/src/main/java/org/sopt/home/HomeContract.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data class HomeState(
val recommendLink: List<RecommendLink> = emptyList(),
val url: String = "",
val categoryId: Long? = 0,
val categoryName: String? = "전체 클립",
) {
fun calculateProgress(): Int {
if (readToastNum > allToastNum) return 0
Expand Down
14 changes: 10 additions & 4 deletions feature/home/src/main/java/org/sopt/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import org.sopt.home.databinding.FragmentHomeBinding
import org.sopt.ui.base.BindingFragment
import org.sopt.ui.nav.DeepLinkUtil
import org.sopt.ui.view.onThrottleClick
import java.net.URLEncoder
import java.nio.charset.StandardCharsets

@AndroidEntryPoint
class HomeFragment : BindingFragment<FragmentHomeBinding>({ FragmentHomeBinding.inflate(it) }) {
Expand Down Expand Up @@ -58,14 +60,18 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>({ FragmentHomeBinding.
is HomeSideEffect.NavigateSearch -> navigateToDestination("featureMyPage://fragmentSearch")
is HomeSideEffect.NavigateSetting -> navigateToDestination("featureMyPage://fragmentSetting")
is HomeSideEffect.NavigateClipLink -> navigateToDestination(
"featureSaveLink://ClipLinkFragment?categoryId=${viewModel.container.stateFlow.value.categoryId}",
"featureSaveLink://ClipLinkFragment/${viewModel.container.stateFlow.value.categoryId}/${viewModel.container.stateFlow.value.categoryName}",
)
is HomeSideEffect.ShowBottomSheet -> showHomeBottomSheet()
is HomeSideEffect.NavigateWebView -> navigateToDestination(
"featureSaveLink://webViewFragment?site=${viewModel.container.stateFlow.value.url},,,${0},,,false",
)

else -> {}
is HomeSideEffect.NavigateWebView -> {
val encodedURL = URLEncoder.encode(viewModel.container.stateFlow.value.url, StandardCharsets.UTF_8.toString())
navigateToDestination(
"featureSaveLink://webViewFragment/${0}/${false}/${false}/$encodedURL",
)
}
}
}

Expand Down Expand Up @@ -94,7 +100,7 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>({ FragmentHomeBinding.
private fun setClipAdapter() {
homeClipAdapter = HomeClipAdapter(
onClickClip = {
viewModel.navigateClipLink(it.categoryId)
viewModel.navigateClipLink(it.categoryId, it.categoryTitle)
},
onClickEmptyClip = {
viewModel.showBottomSheet()
Expand Down
9 changes: 7 additions & 2 deletions feature/home/src/main/java/org/sopt/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,13 @@ class HomeViewModel @Inject constructor(
fun showBottomSheet() = intent { postSideEffect(HomeSideEffect.ShowBottomSheet) }

@OptIn(OrbitExperimental::class)
fun navigateClipLink(categoryId: Long?) = blockingIntent {
reduce { state.copy(categoryId = categoryId) }
fun navigateClipLink(categoryId: Long?, categoryName: String?) = blockingIntent {
reduce {
state.copy(
categoryId = categoryId,
categoryName = categoryName,
)
}
postSideEffect(HomeSideEffect.NavigateClipLink)
}

Expand Down
2 changes: 2 additions & 0 deletions feature/mypage/src/main/res/layout/fragment_my.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
android:id="@+id/iv_mypage_please_wait"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginTop="30dp"
android:src="@drawable/img_mypage_alarm"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -210,6 +211,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/mypage_please_wait"
android:gravity="center"
android:textAppearance="@style/Typography.suit.regular_16_128"
android:textColor="@color/neutrals500"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
1 change: 1 addition & 0 deletions feature/mypage/src/main/res/layout/fragment_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
android:layout_marginVertical="20dp"
android:layout_marginStart="20dp"
android:text="@string/settings_alert"
android:textStyle="normal"
android:textAppearance="@style/Typography.suit.medium_18"
android:textColor="@color/neutrals900"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down

0 comments on commit 57f7e1c

Please sign in to comment.