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] 알림 목록 / 레벨업 가이드 화면 변경 #259

Merged
merged 10 commits into from
Mar 2, 2024
2 changes: 1 addition & 1 deletion app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 23,
"versionCode": 25,
"versionName": "1.1.0",
"outputFile": "app-release.apk"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.go.sopt.winey.databinding.ActivityMainBinding
import org.go.sopt.winey.presentation.main.feed.WineyFeedFragment
import org.go.sopt.winey.presentation.main.feed.detail.DetailActivity
import org.go.sopt.winey.presentation.main.mypage.MyPageFragment
import org.go.sopt.winey.presentation.main.mypage.MypageHelpActivity
import org.go.sopt.winey.presentation.main.mypage.goal.GoalPathActivity
import org.go.sopt.winey.presentation.main.recommend.RecommendFragment
import org.go.sopt.winey.presentation.model.NotificationType
import org.go.sopt.winey.presentation.onboarding.login.LoginActivity
Expand Down Expand Up @@ -106,11 +106,10 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
navigateToMyPageFragment(KEY_FROM_NOTI, true)
}

NotificationType.LIKE_NOTIFICATION, NotificationType.COMMENT_NOTIFICATION -> {
NotificationType.LIKE_NOTIFICATION, NotificationType.COMMENT_NOTIFICATION ->
navigateToDetailScreen(feedId?.toInt())
}

NotificationType.HOW_TO_LEVEL_UP -> navigateToLevelUpGuideScreen()
NotificationType.HOW_TO_LEVEL_UP -> navigateToGoalPathScreen()
else -> {}
}
}
Expand All @@ -121,7 +120,7 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
return
}

if (intent.getBooleanExtra(KEY_TO_MYPAGE, false)) {
if (intent.getBooleanExtra(KEY_TO_MY_PAGE, false)) {
navigateToMyPageFragment(KEY_FROM_NOTI, true)
return
}
Expand Down Expand Up @@ -228,24 +227,22 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
startActivity(intent)
}

// todo: 레벨업 가이드 화면 바꿔야 할텐데!
private fun navigateToLevelUpGuideScreen() {
val intent = Intent(this, MypageHelpActivity::class.java)
private fun navigateToGoalPathScreen() {
val intent = Intent(this, GoalPathActivity::class.java)
startActivity(intent)
}

companion object {
const val KEY_FEED_ID = "feedId"
const val KEY_TO_MY_PAGE = "navigateMyPage"
const val KEY_FROM_GOAL_PATH = "fromGoalPath"

private const val KEY_FEED_UPLOAD = "upload"
private const val KEY_FEED_DELETE = "delete"

private const val KEY_NOTI_TYPE = "notiType"
private const val KEY_FROM_NOTI = "fromNoti"
private const val KEY_TO_MYFEED = "toMyFeed"

const val KEY_FEED_ID = "feedId"
const val KEY_TO_MYPAGE = "navigateMypage"
const val KEY_FROM_GOAL_PATH = "fromGoalPath"

private const val KEY_PREV_SCREEN = "PREV_SCREEN_NAME"
private const val MY_FEED_SCREEN = "MyFeedFragment"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.go.sopt.winey.R
import org.go.sopt.winey.databinding.ActivityNotificationBinding
import org.go.sopt.winey.presentation.main.MainActivity
import org.go.sopt.winey.presentation.main.feed.detail.DetailActivity
import org.go.sopt.winey.presentation.main.mypage.MypageHelpActivity
import org.go.sopt.winey.presentation.main.mypage.goal.GoalPathActivity
import org.go.sopt.winey.util.binding.BindingActivity
import org.go.sopt.winey.util.context.snackBar
import org.go.sopt.winey.util.view.UiState
Expand All @@ -22,6 +22,7 @@ class NotificationActivity :
BindingActivity<ActivityNotificationBinding>(R.layout.activity_notification) {
private val viewModel by viewModels<NotificationViewModel>()
private lateinit var notificationAdapter: NotificationAdapter

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initNotificationAdapter()
Expand All @@ -34,8 +35,8 @@ class NotificationActivity :
private fun initNotificationAdapter() {
notificationAdapter = NotificationAdapter(
navigateFeedDetail = { feedId -> navigateToDetail(feedId) },
navigateLevelupHelp = { navigateToLevelupHelp() },
navigateMypage = { navigateToMypage() }
navigateGoalPath = { navigateToGoalPath() },
navigateMyPage = { navigateToMyPage() }
)
binding.rvNotificationPost.adapter = notificationAdapter
}
Expand Down Expand Up @@ -79,15 +80,15 @@ class NotificationActivity :
startActivity(intent)
}

private fun navigateToMypage() {
val intent = Intent(this, MainActivity::class.java)
intent.putExtra(MainActivity.KEY_TO_MYPAGE, true)
private fun navigateToGoalPath() {
val intent = Intent(this, GoalPathActivity::class.java)
startActivity(intent)
this.finish()
}

private fun navigateToLevelupHelp() {
val intent = Intent(this, MypageHelpActivity::class.java)
private fun navigateToMyPage() {
val intent = Intent(this, MainActivity::class.java)
intent.putExtra(MainActivity.KEY_TO_MY_PAGE, true)
startActivity(intent)
this.finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import org.go.sopt.winey.databinding.ItemNotificationPostBinding
import org.go.sopt.winey.domain.entity.Notification
import org.go.sopt.winey.presentation.model.NotificationType
import org.go.sopt.winey.util.view.ItemDiffCallback

class NotificationAdapter(
private val navigateFeedDetail: (feedId: Int?) -> Unit,
private val navigateMypage: () -> Unit,
private val navigateLevelupHelp: () -> Unit
private val navigateMyPage: () -> Unit,
private val navigateGoalPath: () -> Unit
) :
ListAdapter<Notification, NotificationAdapter.NotificationViewHolder>(DiffUtil) {

Expand All @@ -26,11 +27,12 @@ class NotificationAdapter(
data.notiReceiver == data.notiMessage.substring(0, data.notiReceiver.length)
}
}

class NotificationViewHolder(
private val binding: ItemNotificationPostBinding,
private val navigateFeedDetail: (feedId: Int?) -> Unit,
private val navigateMypage: () -> Unit,
private val navigateLevelupHelp: () -> Unit
private val navigateMyPage: () -> Unit,
private val navigateGoalPath: () -> Unit
) : RecyclerView.ViewHolder(binding.root) {

fun onBind(data: Notification?) {
Expand All @@ -39,13 +41,16 @@ class NotificationAdapter(
if (data == null) {
return
}

binding.root.setOnClickListener {
when (data?.notiType) {
"HOWTOLEVELUP" -> navigateLevelupHelp.invoke()
"LIKENOTI", "COMMENTNOTI" -> navigateFeedDetail(data.linkId)
else -> navigateMypage.invoke()
when (data.notiType) {
NotificationType.LIKE_NOTIFICATION.key,
NotificationType.COMMENT_NOTIFICATION.key -> navigateFeedDetail(data.linkId)
NotificationType.HOW_TO_LEVEL_UP.key -> navigateGoalPath.invoke()
else -> navigateMyPage.invoke()
}
}

executePendingBindings()
}
}
Expand All @@ -54,7 +59,7 @@ class NotificationAdapter(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NotificationViewHolder {
val binding =
ItemNotificationPostBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return NotificationViewHolder(binding, navigateFeedDetail, navigateMypage, navigateLevelupHelp)
return NotificationViewHolder(binding, navigateFeedDetail, navigateMyPage, navigateGoalPath)
}

override fun onBindViewHolder(holder: NotificationViewHolder, position: Int) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.go.sopt.winey.presentation.splash

import android.app.Activity
import android.content.Intent
import android.os.Build
import android.os.Bundle
Expand All @@ -19,13 +18,15 @@ import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.launch
import org.go.sopt.winey.BuildConfig
import org.go.sopt.winey.R
import org.go.sopt.winey.databinding.ActivitySplashBinding
import org.go.sopt.winey.domain.repository.DataStoreRepository
import org.go.sopt.winey.presentation.main.MainActivity
import org.go.sopt.winey.presentation.onboarding.guide.GuideActivity
import org.go.sopt.winey.util.binding.BindingActivity
import org.go.sopt.winey.util.context.colorOf
import org.go.sopt.winey.util.context.snackBar
import timber.log.Timber
import javax.inject.Inject

Expand Down Expand Up @@ -101,19 +102,19 @@ class SplashActivity : BindingActivity<ActivitySplashBinding>(R.layout.activity_
private fun showLottieAnimation() {
lifecycleScope.launch {
delay(DELAY_TIME)
checkAppUpdateInfo()
}
}

private inline fun <reified T : Activity> navigateTo() {
Intent(this, T::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(this)
if (BuildConfig.DEBUG) {
checkAutoLogin()
} else {
checkAppUpdateInfo()
}
}
}

private fun checkAppUpdateInfo() {
appUpdateManager.appUpdateInfo.addOnSuccessListener { appUpdateInfo ->
val appUpdateInfoTask = appUpdateManager.appUpdateInfo

appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE &&
appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
) {
Expand All @@ -123,6 +124,10 @@ class SplashActivity : BindingActivity<ActivitySplashBinding>(R.layout.activity_
checkAutoLogin()
}
}

appUpdateInfoTask.addOnFailureListener { t ->
snackBar(binding.root) { t.message.toString() }
}
}

private fun requestImmediateUpdate(appUpdateInfo: AppUpdateInfo) {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/DefaultConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ object DefaultConfig {
const val compileSdk = 33
const val minSdk = 28
const val targetSdk = 33
const val versionCode = 23
const val versionCode = 25
const val versionName = "1.1.0"
}
Loading