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

[feat] 위니피드, 상세피드 / 신고하기 구글폼 연결 #228

Merged
merged 4 commits into from
Nov 18, 2023
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 @@ -26,10 +26,9 @@ import org.go.sopt.winey.util.view.UiState
@AndroidEntryPoint
class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main) {
private val mainViewModel by viewModels<MainViewModel>()
private val isUploadSuccess by lazy { intent.extras?.getBoolean(EXTRA_UPLOAD_KEY, false) }
private val isDeleteSuccess by lazy { intent.extras?.getBoolean(EXTRA_DELETE_KEY, false) }
private val isReportSuccess by lazy { intent.extras?.getBoolean(EXTRA_REPORT_KEY, false) }
private val prevScreenName by lazy { intent.extras?.getString(KEY_PREV_SCREEN, "") }
private val isUploadSuccess by lazy { intent.extras?.getBoolean(KEY_FEED_UPLOAD, false) }
private val isDeleteSuccess by lazy { intent.extras?.getBoolean(KEY_FEED_DELETE, false) }
private val prevScreenName by lazy { intent.extras?.getString(KEY_PREV_SCREEN_NAME, "") }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -49,7 +48,7 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
if (intent.getBooleanExtra(KEY_TO_MYPAGE, false)) {
navigateToMyPageWithBundle(KEY_FROM_NOTI, true)
} else {
if (prevScreenName == MY_FEED_SCREEN) {
if (prevScreenName == VAL_MY_FEED_SCREEN) {
navigateToMyPageWithBundle(KEY_TO_MYFEED, true)
} else {
navigateTo<WineyFeedFragment>()
Expand All @@ -58,15 +57,13 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
}

private fun showSuccessSnackBar() {
if (isUploadSuccess != null && isUploadSuccess == true) {
if (isUploadSuccess == true) {
wineySnackbar(binding.root, true, stringOf(R.string.snackbar_upload_success))
}
if (isDeleteSuccess != null && isDeleteSuccess == true) {

if (isDeleteSuccess == true) {
wineySnackbar(binding.root, true, stringOf(R.string.snackbar_feed_delete_success))
}
if (isReportSuccess != null && isReportSuccess == true) {
wineySnackbar(binding.root, true, stringOf(R.string.snackbar_report_success))
}
}

private fun initBnvItemSelectedListener() {
Expand Down Expand Up @@ -141,15 +138,12 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
}

companion object {
private const val EXTRA_UPLOAD_KEY = "upload"
private const val EXTRA_DELETE_KEY = "delete"
private const val EXTRA_REPORT_KEY = "report"

private const val KEY_PREV_SCREEN = "PREV_SCREEN_NAME"
private const val KEY_FEED_UPLOAD = "upload"
private const val KEY_FEED_DELETE = "delete"
private const val KEY_PREV_SCREEN_NAME = "PREV_SCREEN_NAME"
private const val KEY_FROM_NOTI = "fromNoti"
private const val KEY_TO_MYFEED = "toMyFeed"
private const val KEY_TO_MYPAGE = "navigateMypage"

private const val MY_FEED_SCREEN = "MyFeedFragment"
private const val VAL_MY_FEED_SCREEN = "MyFeedFragment"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.go.sopt.winey.presentation.main.feed.upload.UploadActivity
import org.go.sopt.winey.presentation.main.mypage.MyPageFragment
import org.go.sopt.winey.presentation.main.notification.NotificationActivity
import org.go.sopt.winey.presentation.model.WineyDialogLabel
import org.go.sopt.winey.util.activity.showReportGoogleForm
import org.go.sopt.winey.util.amplitude.AmplitudeUtils
import org.go.sopt.winey.util.amplitude.type.EventType
import org.go.sopt.winey.util.amplitude.type.EventType.TYPE_CLICK_FEED_ITEM
Expand Down Expand Up @@ -212,11 +213,7 @@ class WineyFeedFragment :
),
handleNegativeButton = {},
handlePositiveButton = {
wineySnackbar(
binding.root,
true,
stringOf(R.string.snackbar_report_success)
)
requireActivity().showReportGoogleForm()
}
)
dialog.show(parentFragmentManager, TAG_FEED_REPORT_DIALOG)
Expand Down Expand Up @@ -447,7 +444,7 @@ class WineyFeedFragment :
Intent(requireContext(), DetailActivity::class.java).apply {
putExtra(KEY_FEED_ID, wineyFeed.feedId)
putExtra(KEY_FEED_WRITER_ID, wineyFeed.userId)
putExtra(KEY_PREV_SCREEN, WINEY_FEED_SCREEN)
putExtra(KEY_PREV_SCREEN_NAME, VAL_WINEY_FEED_SCREEN)
startActivity(this)
}
}
Expand Down Expand Up @@ -515,8 +512,8 @@ class WineyFeedFragment :
private const val KEY_FROM_WINEY_FEED = "fromWineyFeed"
private const val KEY_FEED_ID = "feedId"
private const val KEY_FEED_WRITER_ID = "feedWriterId"
private const val KEY_PREV_SCREEN = "PREV_SCREEN_NAME"
private const val WINEY_FEED_SCREEN = "WineyFeedFragment"
private const val KEY_PREV_SCREEN_NAME = "PREV_SCREEN_NAME"
private const val VAL_WINEY_FEED_SCREEN = "WineyFeedFragment"
private const val INSTAGRAM_URL =
"https://instagram.com/winey__official?igshid=MzRlODBiNWFlZA=="
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.go.sopt.winey.domain.repository.DataStoreRepository
import org.go.sopt.winey.presentation.main.MainActivity
import org.go.sopt.winey.presentation.model.WineyDialogLabel
import org.go.sopt.winey.util.activity.hideKeyboard
import org.go.sopt.winey.util.activity.showReportGoogleForm
import org.go.sopt.winey.util.amplitude.AmplitudeUtils
import org.go.sopt.winey.util.amplitude.type.EventType
import org.go.sopt.winey.util.binding.BindingActivity
Expand All @@ -45,7 +46,7 @@ class DetailActivity : BindingActivity<ActivityDetailBinding>(R.layout.activity_
private val viewModel by viewModels<DetailViewModel>()
private val feedId by lazy { intent.getIntExtra(KEY_FEED_ID, 0) }
private val feedWriterId by lazy { intent.getIntExtra(KEY_FEED_WRITER_ID, 0) }
private val prevScreenName by lazy { intent.extras?.getString(KEY_PREV_SCREEN, "") }
private val prevScreenName by lazy { intent.extras?.getString(KEY_PREV_SCREEN_NAME, "") }

private var _detailFeedAdapter: DetailFeedAdapter? = null
private val detailFeedAdapter get() = requireNotNull(_detailFeedAdapter)
Expand Down Expand Up @@ -154,7 +155,7 @@ class DetailActivity : BindingActivity<ActivityDetailBinding>(R.layout.activity_
showFeedDeletePopupMenu(anchorView)
} else {
// 다른 사람 게시물 신고
showReportPopupMenu(anchorView, TARGET_DETAIL_FEED)
showReportPopupMenu(anchorView)
}
}
}
Expand All @@ -169,15 +170,15 @@ class DetailActivity : BindingActivity<ActivityDetailBinding>(R.layout.activity_
showCommentDeletePopupMenu(anchorView, commentId)
} else {
// 방문자 댓글 삭제/신고
showAllPopupMenu(anchorView, commentId)
showDeleteReportPopupMenu(anchorView, commentId)
}
} else {
if (isMyComment(currentUserId, commentAuthorId)) {
// 내 댓글 삭제
showCommentDeletePopupMenu(anchorView, commentId)
} else {
// 다른 사람 댓글 신고
showReportPopupMenu(anchorView, TARGET_COMMENT)
showReportPopupMenu(anchorView)
}
}
}
Expand All @@ -201,15 +202,15 @@ class DetailActivity : BindingActivity<ActivityDetailBinding>(R.layout.activity_
}
}

private fun showAllPopupMenu(anchorView: View, commentId: Long) {
private fun showDeleteReportPopupMenu(anchorView: View, commentId: Long) {
val menuTitles = listOf(
stringOf(R.string.popup_delete_title),
stringOf(R.string.popup_report_title)
)
WineyPopupMenu(context = anchorView.context, titles = menuTitles) { _, _, position ->
when (position) {
0 -> showCommentDeleteDialog(commentId)
1 -> showReportDialog(TARGET_COMMENT)
1 -> showReportDialog()
}
}.apply {
showCustomPosition(anchorView)
Expand Down Expand Up @@ -244,17 +245,16 @@ class DetailActivity : BindingActivity<ActivityDetailBinding>(R.layout.activity_
dialog.show(supportFragmentManager, TAG_COMMENT_DELETE_DIALOG)
}

private fun showReportPopupMenu(anchorView: View, target: String) {
private fun showReportPopupMenu(anchorView: View) {
val reportTitle = listOf(stringOf(R.string.popup_report_title))
WineyPopupMenu(context = anchorView.context, titles = reportTitle) { _, _, _ ->
showReportDialog(target)
showReportDialog()
}.apply {
showCustomPosition(anchorView)
}
}

// 신고의 대상이 무엇인지에 따라 스낵바가 뜨는 위치가 달라지도록
private fun showReportDialog(target: String) {
private fun showReportDialog() {
val dialog = WineyDialogFragment.newInstance(
WineyDialogLabel(
stringOf(R.string.report_dialog_title),
Expand All @@ -264,19 +264,12 @@ class DetailActivity : BindingActivity<ActivityDetailBinding>(R.layout.activity_
),
handleNegativeButton = {},
handlePositiveButton = {
when (target) {
TARGET_DETAIL_FEED -> navigateToMainWithBundle(EXTRA_REPORT_KEY)
TARGET_COMMENT -> showCommentReportSnackbar()
}
showReportGoogleForm()
}
)
dialog.show(supportFragmentManager, TAG_REPORT_DIALOG)
}

private fun showCommentReportSnackbar() {
wineySnackbar(binding.root, true, stringOf(R.string.snackbar_report_success))
}

private fun isMyFeed(currentUserId: Int?) = currentUserId == feedWriterId

private fun isMyComment(currentUserId: Int?, commentAuthorId: Int) =
Expand Down Expand Up @@ -359,7 +352,7 @@ class DetailActivity : BindingActivity<ActivityDetailBinding>(R.layout.activity_
viewModel.deleteFeedDetailState.flowWithLifecycle(lifecycle).onEach { state ->
when (state) {
is UiState.Success -> {
navigateToMainWithBundle(EXTRA_DELETE_KEY)
navigateToMainWithBundle()
}

is UiState.Failure -> {
Expand Down Expand Up @@ -434,11 +427,11 @@ class DetailActivity : BindingActivity<ActivityDetailBinding>(R.layout.activity_

private fun isCommentNumberZero(commentNumber: Int) = commentNumber == 0

private fun navigateToMainWithBundle(extraKey: String) {
private fun navigateToMainWithBundle() {
Intent(this, MainActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
putExtra(extraKey, true)
putExtra(KEY_PREV_SCREEN, prevScreenName)
putExtra(KEY_PREV_SCREEN_NAME, prevScreenName)
putExtra(KEY_FEED_DELETE, true)
startActivity(this)
}
}
Expand Down Expand Up @@ -477,18 +470,16 @@ class DetailActivity : BindingActivity<ActivityDetailBinding>(R.layout.activity_
companion object {
private const val KEY_FEED_ID = "feedId"
private const val KEY_FEED_WRITER_ID = "feedWriterId"
private const val KEY_PREV_SCREEN = "PREV_SCREEN_NAME"
private const val KEY_PREV_SCREEN_NAME = "PREV_SCREEN_NAME"
private const val KEY_FEED_DELETE = "delete"

private const val TAG_FEED_DELETE_DIALOG = "FEED_DELETE_DIALOG"
private const val TAG_COMMENT_DELETE_DIALOG = "COMMENT_DELETE_DIALOG"
private const val TAG_REPORT_DIALOG = "REPORT_DIALOG"

private const val POPUP_MENU_POS_OFFSET = 65
private const val MSG_DETAIL_ERROR = "ERROR"
private const val EXTRA_DELETE_KEY = "delete"
private const val EXTRA_REPORT_KEY = "report"
private const val TARGET_DETAIL_FEED = "detailFeed"
private const val TARGET_COMMENT = "comment"

private const val ACTION_COMMENT_POST = "POST"
private const val ACTION_COMMENT_DELETE = "DELETE"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class AmountFragment : BindingFragment<FragmentAmountBinding>(R.layout.fragment_

private fun navigateLoadingScreen() {
Intent(requireContext(), LoadingActivity::class.java).apply {
putExtra(EXTRA_AMOUNT_KEY, uploadViewModel.amount.removeComma())
putExtra(KEY_SAVE_AMOUNT, uploadViewModel.amount.removeComma())
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(this)
}
Expand Down Expand Up @@ -135,6 +135,6 @@ class AmountFragment : BindingFragment<FragmentAmountBinding>(R.layout.fragment_
}

companion object {
private const val EXTRA_AMOUNT_KEY = "amount"
private const val KEY_SAVE_AMOUNT = "amount"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.go.sopt.winey.presentation.main.MainActivity
import org.go.sopt.winey.util.binding.BindingActivity

class LoadingActivity : BindingActivity<ActivityLoadingBinding>(R.layout.activity_loading) {
private val amountString by lazy { intent.extras?.getString(EXTRA_AMOUNT_KEY, "") }
private val amountString by lazy { intent.extras?.getString(KEY_SAVE_AMOUNT, "") }
private val amountRange by lazy { resources.getIntArray(R.array.save_amount_range) }
private val itemCategories by lazy { resources.getStringArray(R.array.save_item_categories) }

Expand Down Expand Up @@ -76,14 +76,14 @@ class LoadingActivity : BindingActivity<ActivityLoadingBinding>(R.layout.activit
private fun navigateToMainScreen() {
Intent(this, MainActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
putExtra(EXTRA_UPLOAD_KEY, true)
putExtra(KEY_FEED_UPLOAD, true)
startActivity(this)
}
}

companion object {
private const val DELAY_TIME = 3000L
private const val EXTRA_AMOUNT_KEY = "amount"
private const val EXTRA_UPLOAD_KEY = "upload"
private const val KEY_SAVE_AMOUNT = "amount"
private const val KEY_FEED_UPLOAD = "upload"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class MyPageFragment : BindingFragment<FragmentMyPageBinding>(R.layout.fragment_
handleNegativeButton = { myPageViewModel.deleteUser() },
handlePositiveButton = {}
)
dialog.show(parentFragmentManager, TAGE_WITHDRAW_DIALOG)
dialog.show(parentFragmentManager, TAG_WITHDRAW_DIALOG)
}
}

Expand Down Expand Up @@ -223,7 +223,7 @@ class MyPageFragment : BindingFragment<FragmentMyPageBinding>(R.layout.fragment_

private fun navigateToNicknameScreen() {
Intent(requireContext(), NicknameActivity::class.java).apply {
putExtra(KEY_PREV_SCREEN, VALUE_MY_PAGE_SCREEN)
putExtra(KEY_PREV_SCREEN_NAME, VAL_MY_PAGE_SCREEN)
startActivity(this)
}
}
Expand Down Expand Up @@ -329,14 +329,16 @@ class MyPageFragment : BindingFragment<FragmentMyPageBinding>(R.layout.fragment_
private const val LEVEL_KNIGHT = "기사"
private const val LEVEL_NOBLESS = "귀족"
private const val LEVEL_KING = "황제"

private const val ONE_ON_ONE_URL = "https://open.kakao.com/o/s751Susf"
private const val TERMS_URL =
"https://empty-weaver-a9f.notion.site/iney-9dbfe130c7df4fb9a0903481c3e377e6?pvs=4"

private const val TAG_LOGOUT_DIALOG = "LOGOUT_DIALOG"
private const val TAGE_WITHDRAW_DIALOG = "WITHDRAW_DIALOG"
private const val TAG_WITHDRAW_DIALOG = "WITHDRAW_DIALOG"

private const val KEY_PREV_SCREEN = "PREV_SCREEN_NAME"
private const val VALUE_MY_PAGE_SCREEN = "MyPageFragment"
private const val KEY_PREV_SCREEN_NAME = "PREV_SCREEN_NAME"
private const val VAL_MY_PAGE_SCREEN = "MyPageFragment"
private const val KEY_FROM_NOTI = "fromNoti"
private const val KEY_FROM_WINEY_FEED = "fromWineyFeed"
private const val KEY_TO_MYFEED = "toMyFeed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class MyFeedFragment : BindingFragment<FragmentMyfeedBinding>(R.layout.fragment_
Intent(requireContext(), DetailActivity::class.java).apply {
putExtra(KEY_FEED_ID, wineyFeed.feedId)
putExtra(KEY_FEED_WRITER_ID, wineyFeed.userId)
putExtra(KEY_PREV_SCREEN, MY_FEED_SCREEN)
putExtra(KEY_PREV_SCREEN_NAME, VAL_MY_FEED_SCREEN)
startActivity(this)
}
}
Expand All @@ -277,10 +277,12 @@ class MyFeedFragment : BindingFragment<FragmentMyfeedBinding>(R.layout.fragment_
companion object {
private const val KEY_FEED_ID = "feedId"
private const val KEY_FEED_WRITER_ID = "feedWriterId"
private const val KEY_PREV_SCREEN = "PREV_SCREEN_NAME"
private const val KEY_PREV_SCREEN_NAME = "PREV_SCREEN_NAME"

private const val POPUP_MENU_OFFSET = 65
private const val MSG_MYFEED_ERROR = "ERROR"

private const val TAG_FEED_DELETE_DIALOG = "DELETE_DIALOG"
private const val MY_FEED_SCREEN = "MyFeedFragment"
private const val VAL_MY_FEED_SCREEN = "MyFeedFragment"
}
}
Loading