Skip to content

Commit

Permalink
Merge pull request #438 from hyeeyoung/dev
Browse files Browse the repository at this point in the history
버전 코드 35 -> 36 업데이트
  • Loading branch information
youngjinc authored May 15, 2024
2 parents 5fc028d + 184a09f commit 0824959
Show file tree
Hide file tree
Showing 42 changed files with 427 additions and 292 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ android {
applicationId "com.hyeeyoung.wishboard"
minSdkVersion 24
targetSdkVersion 33
versionCode 30
versionName "1.2.1"
versionCode 36
versionName "1.2.4"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand All @@ -40,6 +40,7 @@ android {
buildTypes {
debug {
buildConfigField "String", "BASE_URL", properties["DEV_BASE_URL"]
versionNameSuffix = "-dev"
}
release {
minifyEnabled true
Expand Down
15 changes: 3 additions & 12 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hyeeyoung.wishboard">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Expand Down Expand Up @@ -42,23 +43,13 @@
android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="wishboard.com"
android:path="/main"
android:scheme="https" />
</intent-filter>
</activity>

<activity
android:name=".presentation.howtouse.screens.HowToUseActivity"
android:exported="false"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/AppThemePopup" />

<activity
android:name=".presentation.wishitem.screens.WishLinkSharingActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import androidx.databinding.ktx.BuildConfig
import androidx.security.crypto.EncryptedSharedPreferences
import androidx.security.crypto.MasterKey
import dagger.hilt.android.qualifiers.ApplicationContext
import timber.log.Timber
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeParseException
import javax.inject.Inject
import javax.inject.Singleton

Expand Down Expand Up @@ -59,6 +63,19 @@ class WishBoardPreference @Inject constructor(@ApplicationContext context: Conte
null
) ?: ""

var eventCloseBtnClickTime: LocalDateTime?
set(value) = dataStore.edit { putString(EVENT_X_BTN_CLICK_TIME, value.toString()) }
get() = dataStore.getString(
EVENT_X_BTN_CLICK_TIME, null
)?.let {
try {
LocalDateTime.parse(it, DateTimeFormatter.ISO_LOCAL_DATE_TIME)
} catch (e: DateTimeParseException) {
Timber.e(e.message)
null
}
}

fun setUserInfo(email: String, nickname: String?, accessToken: String, refreshToken: String) {
isLogin = true
userEmail = email
Expand Down Expand Up @@ -86,5 +103,6 @@ class WishBoardPreference @Inject constructor(@ApplicationContext context: Conte
const val IS_LOGIN = "isLogin"
const val USER_EMAIL = "userEmail"
const val USER_NICKNAME = "userNickname"
const val EVENT_X_BTN_CLICK_TIME = "eventXBtnClickTime"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,10 @@ class CartFragment : NetworkFragment<FragmentCartBinding>(R.layout.fragment_cart
}

private fun showCartDeleteDialog(cartItem: CartItem) {
TwoButtonDialogFragment(
getString(R.string.cart_delete_dialog_title),
getString(R.string.cart_delete_dialog_description),
getString(R.string.delete),
getString(R.string.cancel)
).apply {
TwoButtonDialogFragment.newInstance(title = getString(R.string.cart_delete_dialog_title),
description = getString(R.string.cart_delete_dialog_description),
yesValue = getString(R.string.delete),
noValue = getString(R.string.cancel)).apply {
setListener(object : DialogListener {
override fun onButtonClicked(clicked: String) {
if (clicked == DialogButtonReplyType.YES.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ import com.hyeeyoung.wishboard.presentation.base.screen.BaseDialogFragment
import com.hyeeyoung.wishboard.presentation.common.types.DialogButtonReplyType
import com.hyeeyoung.wishboard.util.DialogListener

class TwoButtonDialogFragment(
private val title: String,
private val description: String?,
private val yesValue: String,
private val noValue: String,
) : BaseDialogFragment<DialogTwoButtonBinding>(R.layout.dialog_two_button) {
class TwoButtonDialogFragment :
BaseDialogFragment<DialogTwoButtonBinding>(R.layout.dialog_two_button) {
private lateinit var listener: DialogListener

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

binding.title.text = title
binding.description.text = description
binding.yes.text = yesValue
binding.no.text = noValue
arguments?.let {
binding.title.text = it.getString(ARG_TITLE)
binding.description.text = it.getString(ARG_DESCRIPTION)
binding.yes.text = it.getString(ARG_YES_VALUE)
binding.no.text = it.getString(ARG_NO_VALUE)
val isWarningDialog = it.getBoolean(ARG_WARNING_DIALOG)
binding.yes.setTextColor(requireContext().getColor(if (isWarningDialog) R.color.pink else R.color.green_700))
}

addListener()
}
Expand All @@ -39,4 +39,30 @@ class TwoButtonDialogFragment(
fun setListener(listener: DialogListener) {
this.listener = listener
}

companion object {
private const val ARG_TITLE = "title"
private const val ARG_DESCRIPTION = "description"
private const val ARG_YES_VALUE = "yesValue"
private const val ARG_NO_VALUE = "noValue"
private const val ARG_WARNING_DIALOG = "isWarningDialog"

fun newInstance(
title: String,
description: String?,
yesValue: String,
noValue: String,
isWarningDialog: Boolean = true
): TwoButtonDialogFragment {
val args = Bundle().apply {
putString(ARG_TITLE, title)
putString(ARG_DESCRIPTION, description)
putString(ARG_YES_VALUE, yesValue)
putString(ARG_NO_VALUE, noValue)
putBoolean(ARG_WARNING_DIALOG, isWarningDialog)
}

return TwoButtonDialogFragment().apply { arguments = args }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,8 @@ class WebViewActivity : BaseActivity<ActivityWebviewBinding>(R.layout.activity_w
}
}

override fun onPause() {
super.onPause()
overridePendingTransition(0, 0)
}

companion object {
private const val ARG_WEB_VIEW_LINK = "link"
private const val ARG_WEB_VIEW_TITLE = "title"
const val ARG_WEB_VIEW_LINK = "link"
const val ARG_WEB_VIEW_TITLE = "title"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class FolderFragment : NetworkFragment<FragmentFolderBinding>(R.layout.fragment_
folderListAdapter.deleteData(deleteState.data)
viewModel.resetCompleteDeletion()
}

else -> {}
}
}
Expand All @@ -90,6 +91,7 @@ class FolderFragment : NetworkFragment<FragmentFolderBinding>(R.layout.fragment_
is UiState.Success -> {
folderListAdapter.setData(items = fetchState.data)
}

else -> {}
}
}
Expand Down Expand Up @@ -119,6 +121,7 @@ class FolderFragment : NetworkFragment<FragmentFolderBinding>(R.layout.fragment_
TwoOptionDialogReplyType.TOP_OPTION.name -> {
showFolderUploadDialog(folderItem)
}

TwoOptionDialogReplyType.BOTTOM_OPTION.name -> {
showFolderDeleteDialog(folderItem)
}
Expand Down Expand Up @@ -158,13 +161,12 @@ class FolderFragment : NetworkFragment<FragmentFolderBinding>(R.layout.fragment_

/** 폴더 삭제 다이얼로그 */
private fun showFolderDeleteDialog(folderItem: FolderItem) {
val dialog = TwoButtonDialogFragment(
getString(R.string.folder_delete),
getString(R.string.folder_delete_dialog_detail),
getString(R.string.delete),
getString(R.string.cancel),

).apply {
val dialog = TwoButtonDialogFragment.newInstance(
title = getString(R.string.folder_delete),
description = getString(R.string.folder_delete_dialog_detail),
yesValue = getString(R.string.delete),
noValue = getString(R.string.cancel)
).apply {
setListener(object : DialogListener {
override fun onButtonClicked(clicked: String) {
if (clicked == DialogButtonReplyType.YES.name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ class HomeFragment : NetworkFragment<FragmentHomeBinding>(R.layout.fragment_home
}

private fun addListeners() {
// binding.eventView.setOnClickListener {
// val intent = Intent(requireContext(), WebViewActivity::class.java)
// intent.putExtra(
// ARG_WEB_VIEW_LINK,
// "https://docs.google.com/forms/d/e/1FAIpQLSenh6xOvlDa61iw1UKBSM6SixdrgF17_i91Brb2osZcxB7MOQ/viewform"
// )
// startActivity(intent)
// }
// binding.eventClose.setOnClickListener {
// viewModel.updateEventXBtnClickTime()
// }
binding.cart.setOnClickListener {
findNavController().navigateSafe(R.id.action_home_to_cart)
}
Expand All @@ -72,9 +83,11 @@ class HomeFragment : NetworkFragment<FragmentHomeBinding>(R.layout.fragment_home
WishItemStatus.MODIFIED -> {
viewModel.updateWishItem(position, item ?: return@observe)
}

WishItemStatus.DELETED -> {
viewModel.deleteWishItem(position, item ?: return@observe)
}

WishItemStatus.ADDED -> {
viewModel.fetchLatestItem()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.hyeeyoung.wishboard.data.local.WishBoardPreference
import com.hyeeyoung.wishboard.data.model.folder.FolderItem
import com.hyeeyoung.wishboard.data.model.wish.WishItem
import com.hyeeyoung.wishboard.domain.repositories.CartRepository
Expand All @@ -13,15 +14,19 @@ import com.hyeeyoung.wishboard.presentation.cart.types.CartStateType
import com.hyeeyoung.wishboard.util.UiState
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import java.time.Duration
import java.time.LocalDateTime
import javax.inject.Inject

@HiltViewModel
class WishListViewModel @Inject constructor(
private val wishRepository: WishRepository,
private val cartRepository: CartRepository,
private val folderRepository: FolderRepository,
private val localStorage: WishBoardPreference
) : ViewModel() {
private val _wishListFetchState = MutableStateFlow<UiState<Boolean>>(UiState.Loading)
val wishListFetchState get() = _wishListFetchState.asStateFlow()
Expand All @@ -31,6 +36,20 @@ class WishListViewModel @Inject constructor(
private val wishListAdapter = WishListAdapter()
private var _folderItem: FolderItem? = null
val folderItem get() = _folderItem
private val _isVisibleEventView = MutableStateFlow(checkVisibleEventView())
val isVisibleEventView: StateFlow<Boolean> get() = _isVisibleEventView.asStateFlow()

private fun checkVisibleEventView(): Boolean {
val now = LocalDateTime.now()
val lastXBtnClickTime = localStorage.eventCloseBtnClickTime ?: return true
val secondDiff = Duration.between(lastXBtnClickTime, now).seconds
return secondDiff >= 86400
}

fun updateEventXBtnClickTime() {
_isVisibleEventView.value = false
localStorage.eventCloseBtnClickTime = LocalDateTime.now()
}

fun fetchWishList() {
viewModelScope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,31 @@ package com.hyeeyoung.wishboard.presentation.howtouse
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.hyeeyoung.wishboard.presentation.howtouse.screens.HowToFolderSettingFragment
import com.hyeeyoung.wishboard.presentation.howtouse.screens.HowToLinkSharingFragment
import com.hyeeyoung.wishboard.presentation.howtouse.screens.HowToNotiSettingFragment
import com.hyeeyoung.wishboard.R
import com.hyeeyoung.wishboard.presentation.howtouse.screens.HowToUseFragment

class HowToUseAdapter(fm: FragmentActivity) : FragmentStateAdapter(fm) {
override fun getItemCount(): Int = 3

override fun createFragment(position: Int): Fragment {
return when (position) {
0 -> HowToLinkSharingFragment()
1 -> HowToFolderSettingFragment()
else -> HowToNotiSettingFragment()
0 -> HowToUseFragment.newInstance(
titleRes = R.string.how_to_use_link_sharing_title,
descriptionRes = R.string.how_to_use_link_sharing_description,
imageRes = R.drawable.background_link_sharing
)

1 -> HowToUseFragment.newInstance(
titleRes = R.string.how_to_use_folder_setting,
descriptionRes = R.string.how_to_use_folder_setting_description,
imageRes = R.drawable.backgound_folder_setting
)

else -> HowToUseFragment.newInstance(
titleRes = R.string.noti_setting,
descriptionRes = R.string.how_to_use_noti_setting_description,
imageRes = R.drawable.background_noti_setting
)
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 0824959

Please sign in to comment.