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

[mod] 알림 권한 거부 시 뜨는 스낵바 디자인 변경 #237

Merged
merged 20 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8a1e666
[chore] #236 위니피드 업로드, 삭제 관련 스낵바 띄우는 함수 이름 변경
leeeha Jan 22, 2024
7338ae8
[ui] #236 공통 스낵바 디자인 변경
leeeha Jan 22, 2024
97a6e48
[mod] #236 스낵바 띄우는 함수에 named argument 적용
leeeha Jan 22, 2024
19cc309
[mod] #236 함수 선언 순서 변경
leeeha Jan 22, 2024
2def73d
[mod] #236 알림 권한 관련 스낵바는 넘기는 인자가 다르도록 변경
leeeha Jan 22, 2024
39cbe94
[chore] #236 스코프 함수 사용하도록 변경
leeeha Jan 22, 2024
94a1f1d
[feat] #236 액션 버튼 클릭하면 시스템 설정창으로 이동
leeeha Jan 22, 2024
d425bb8
[del] #236 사용하지 않는 문자열 삭제
leeeha Jan 22, 2024
649be96
[mod] #236 알림 설정 시스템 창 띄우는 코드 변경
leeeha Jan 22, 2024
ff14ebe
[refactor] #236 스낵바 타입을 sealed class 이용하여 구분하도록 변경
leeeha Jan 23, 2024
049dfad
[refactor] #236 마이페이지 프래그먼트 파일에서 코드의 흐름 순으로 함수 정의하기
leeeha Jan 23, 2024
68b8dd0
[refactor] #236 알림 토글 on/off 시키는 코드 함수화
leeeha Jan 23, 2024
19f16b4
[chore] #236 알림 권한 바꾸는 함수의 선언 위치 변경
leeeha Jan 23, 2024
23c7cef
[rename] #236 알림 권한 관련 함수 이름 변경
leeeha Jan 23, 2024
eaa1ae3
[comment] #236 todo 주석 대신에 설명 추가
leeeha Jan 23, 2024
025dcfe
[chore] #236 ktlint 반영
leeeha Jan 23, 2024
d8e18dc
[refactor] #236 위니 스낵바 클래스를 추상 클래스로 변경
leeeha Jan 27, 2024
497021a
[chore] #236 스낵바 클래스의 패키지 위치 변경
leeeha Jan 27, 2024
198a14f
[del] #236 사용하지 않는 임포트문 삭제
leeeha Jan 27, 2024
ca71962
Merge branch 'develop' of https://github.com/team-winey/Winey-AOS int…
leeeha Feb 4, 2024
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 @@ -5,6 +5,7 @@ import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.core.content.ContextCompat
Expand All @@ -29,24 +30,29 @@ import org.go.sopt.winey.util.binding.BindingActivity
import org.go.sopt.winey.util.context.snackBar
import org.go.sopt.winey.util.context.stringOf
import org.go.sopt.winey.util.context.wineySnackbar
import org.go.sopt.winey.util.view.SnackbarType
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 notiType by lazy { intent.extras?.getString(KEY_NOTI_TYPE, "") }
private val feedId by lazy { intent.extras?.getString(KEY_FEED_ID) }

private val notificationPermissionLauncher =
registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted ->
if (!isGranted) {
wineySnackbar(
anchorView = binding.root,
isSuccess = false,
message = stringOf(R.string.snackbar_notification_permission_fail)
message = stringOf(R.string.snackbar_noti_permission_denied),
type = SnackbarType.NotiPermission(
onActionClicked = { showSystemNotificationSetting() }
)
)
}
}
Expand All @@ -59,13 +65,23 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
// 위니피드, 마이페이지 프래그먼트에서 getUserState 관찰
mainViewModel.getUser()
mainViewModel.patchFcmToken()

initNotiTypeHandler()
initFragment()
initBnvItemSelectedListener()
syncBottomNavigationSelection()

setupLogoutState()
showSuccessSnackBar()
showWineyFeedResultSnackBar()
}

private fun showSystemNotificationSetting() {
Intent().apply {
action = Settings.ACTION_APP_NOTIFICATION_SETTINGS
putExtra(Settings.EXTRA_APP_PACKAGE, packageName)
flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(this)
}
}

private fun requestNotificationPermission() {
Expand All @@ -91,6 +107,7 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main

NotificationType.LIKE_NOTIFICATION, NotificationType.COMMENT_NOTIFICATION
-> navigateToDetail(feedId?.toInt())

NotificationType.HOW_TO_LEVEL_UP -> navigateToLevelupHelp()
else -> {}
}
Expand All @@ -108,13 +125,21 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
}
}

private fun showSuccessSnackBar() {
private fun showWineyFeedResultSnackBar() {
if (isUploadSuccess == true) {
wineySnackbar(binding.root, true, stringOf(R.string.snackbar_upload_success))
wineySnackbar(
anchorView = binding.root,
message = stringOf(R.string.snackbar_upload_success),
type = SnackbarType.WineyFeedResult(isSuccess = true)
)
}

if (isDeleteSuccess == true) {
wineySnackbar(binding.root, true, stringOf(R.string.snackbar_feed_delete_success))
wineySnackbar(
anchorView = binding.root,
message = stringOf(R.string.snackbar_feed_delete_success),
type = SnackbarType.WineyFeedResult(isSuccess = true)
)
}
}

Expand Down Expand Up @@ -203,7 +228,6 @@ 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_FEED_ID = "feedId"
private const val KEY_NOTI_TYPE = "notiType"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import org.go.sopt.winey.util.fragment.stringOf
import org.go.sopt.winey.util.fragment.viewLifeCycle
import org.go.sopt.winey.util.fragment.viewLifeCycleScope
import org.go.sopt.winey.util.fragment.wineySnackbar
import org.go.sopt.winey.util.view.SnackbarType
import org.go.sopt.winey.util.view.UiState
import org.go.sopt.winey.util.view.WineyPopupMenu
import org.go.sopt.winey.util.view.setOnSingleClickListener
Expand Down Expand Up @@ -236,10 +237,11 @@ class WineyFeedFragment :
deletePagingDataItem(response.feedId.toInt())

wineySnackbar(
binding.root,
true,
stringOf(R.string.snackbar_feed_delete_success)
anchorView = binding.root,
message = stringOf(R.string.snackbar_feed_delete_success),
type = SnackbarType.WineyFeedResult(isSuccess = true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위니에서도 named Argument 적극 도입해보자 아자잣 👍

)

viewModel.initDeleteFeedState()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.go.sopt.winey.util.context.snackBar
import org.go.sopt.winey.util.context.stringOf
import org.go.sopt.winey.util.context.wineySnackbar
import org.go.sopt.winey.util.fragment.WineyDialogFragment
import org.go.sopt.winey.util.view.SnackbarType
import org.go.sopt.winey.util.view.UiState
import org.go.sopt.winey.util.view.WineyPopupMenu
import org.json.JSONException
Expand Down Expand Up @@ -356,7 +357,11 @@ class DetailActivity : BindingActivity<ActivityDetailBinding>(R.layout.activity_
}

is UiState.Failure -> {
wineySnackbar(binding.root, false, stringOf(R.string.snackbar_delete_fail))
wineySnackbar(
anchorView = binding.root,
message = stringOf(R.string.snackbar_delete_fail),
type = SnackbarType.WineyFeedResult(isSuccess = false)
)
}

else -> Timber.tag("failure").e(MSG_DETAIL_ERROR)
Expand Down Expand Up @@ -409,18 +414,21 @@ class DetailActivity : BindingActivity<ActivityDetailBinding>(R.layout.activity_
}

wineySnackbar(
binding.root,
true,
stringOf(R.string.snackbar_comment_delete_success)
anchorView = binding.root,
message = stringOf(R.string.snackbar_comment_delete_success),
type = SnackbarType.WineyFeedResult(isSuccess = true)
)
}

is UiState.Failure -> {
wineySnackbar(binding.root, false, stringOf(R.string.snackbar_delete_fail))
wineySnackbar(
anchorView = binding.root,
message = stringOf(R.string.snackbar_delete_fail),
type = SnackbarType.WineyFeedResult(isSuccess = false)
)
}

else -> {
}
else -> {}
}
}.launchIn(lifecycleScope)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.go.sopt.winey.util.fragment.viewLifeCycle
import org.go.sopt.winey.util.fragment.viewLifeCycleScope
import org.go.sopt.winey.util.fragment.wineySnackbar
import org.go.sopt.winey.util.multipart.UriToRequestBody
import org.go.sopt.winey.util.view.SnackbarType
import org.go.sopt.winey.util.view.UiState
import org.go.sopt.winey.util.view.setOnSingleClickListener
import java.text.DecimalFormat
Expand Down Expand Up @@ -68,7 +69,12 @@ class AmountFragment : BindingFragment<FragmentAmountBinding>(R.layout.fragment_
}

is UiState.Failure -> {
wineySnackbar(binding.root, false, stringOf(R.string.snackbar_upload_fail))
wineySnackbar(
anchorView = binding.root,
message = stringOf(R.string.snackbar_upload_fail),
type = SnackbarType.WineyFeedResult(isSuccess = false)
)

uploadViewModel.initPostWineyFeedState()
}

Expand Down
Loading