Skip to content

Commit

Permalink
apply ktlintFormat & change provides to binds in noti module
Browse files Browse the repository at this point in the history
  • Loading branch information
l2hyunwoo committed Oct 8, 2023
1 parent fab4442 commit 0f1303a
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class SoptFirebaseMessagingService : FirebaseMessagingService() {
private val job = SupervisorJob()
private val scope = CoroutineScope(Dispatchers.IO + job)


override fun onNewToken(token: String) {
if (dataStore.userStatus == UserStatus.UNAUTHENTICATED.name) return
scope.launch {
Expand Down Expand Up @@ -82,7 +81,6 @@ class SoptFirebaseMessagingService : FirebaseMessagingService() {
link: String,
notificationId: Int
): NotificationCompat.Builder {

val intent = Intent(this@SoptFirebaseMessagingService, AuthActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
putExtra(REMOTE_MESSAGE_EVENT_TYPE, remoteMessageLinkType.name)
Expand All @@ -96,7 +94,9 @@ class SoptFirebaseMessagingService : FirebaseMessagingService() {
intent,
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
} else PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
} else {
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
}
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface AuthService {
@DELETE("user")
suspend fun withdraw()

@HTTP(method = "DELETE", path="user/logout", hasBody = true)
@HTTP(method = "DELETE", path = "user/logout", hasBody = true)
suspend fun logOut(
@Body body: LogOutRequest
): LogOutResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ interface NotificationService {
@Body body: UpdatePushTokenRequest
): UpdatePushTokenResponse


@GET("notification")
suspend fun getNotificationHistory(
@Query("page") page: Int
Expand All @@ -36,13 +35,11 @@ interface NotificationService {
@Path("notificationId") notificationId: Long
): NotificationDetailResponse


@PATCH("notification/{notificationId}")
suspend fun updateNotificationReadingState(
@Path("notificationId") notificationId: Long
): NotificationReadingStateResponse

@PATCH("notification")
suspend fun updateEntireNotificationReadingState(
): NotificationReadingStateResponse
suspend fun updateEntireNotificationReadingState(): NotificationReadingStateResponse
}
13 changes: 7 additions & 6 deletions app/src/main/java/org/sopt/official/di/NotificationModule.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sopt.official.di

import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand All @@ -23,11 +24,11 @@ object NotificationModule {
return retrofit.create(NotificationService::class.java)
}

@Provides
@Singleton
fun provideNotificationRepository(
repository: NotificationRepositoryImpl
): NotificationRepository {
return repository
@Module
@InstallIn(SingletonComponent::class)
interface Binder {
@Binds
@Singleton
fun bindNotificationRepository(repository: NotificationRepositoryImpl): NotificationRepository
}
}
47 changes: 29 additions & 18 deletions app/src/main/java/org/sopt/official/feature/auth/AuthActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,20 @@ class AuthActivity : AppCompatActivity() {
val remoteMessageEventLink = it.getStringExtra(REMOTE_MESSAGE_EVENT_LINK) ?: ""

if (
dataStore.userStatus.isNotBlank()
&& dataStore.userStatus != UserStatus.UNAUTHENTICATED.name
&& remoteMessageEventType.isNotBlank()
dataStore.userStatus.isNotBlank() &&
dataStore.userStatus != UserStatus.UNAUTHENTICATED.name &&
remoteMessageEventType.isNotBlank()
) {
startActivity(HomeActivity.getIntent(this,
HomeActivity.StartArgs(
UserStatus.of(dataStore.userStatus),
remoteMessageEventType,
remoteMessageEventLink
startActivity(
HomeActivity.getIntent(
this,
HomeActivity.StartArgs(
UserStatus.of(dataStore.userStatus),
remoteMessageEventType,
remoteMessageEventLink
)
)
))
)
}
}
}
Expand All @@ -109,13 +112,16 @@ class AuthActivity : AppCompatActivity() {
val remoteMessageEventLink = intent.getStringExtra(REMOTE_MESSAGE_EVENT_LINK) ?: ""
when (event) {
is AuthUiEvent.Success -> {
startActivity(HomeActivity.getIntent(this,
HomeActivity.StartArgs(
event.userStatus,
remoteMessageEventType,
remoteMessageEventLink
startActivity(
HomeActivity.getIntent(
this,
HomeActivity.StartArgs(
event.userStatus,
remoteMessageEventType,
remoteMessageEventLink
)
)
))
)
}

is AuthUiEvent.Failure -> {
Expand Down Expand Up @@ -175,9 +181,14 @@ class AuthActivity : AppCompatActivity() {
}
}
binding.btnSoptNotMember.setOnSingleClickListener {
startActivity(HomeActivity.getIntent(this, HomeActivity.StartArgs(
UserStatus.UNAUTHENTICATED
)))
startActivity(
HomeActivity.getIntent(
this,
HomeActivity.StartArgs(
UserStatus.UNAUTHENTICATED
)
)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class NotificationDetailActivity : AppCompatActivity() {
textViewNotificationTitle.text = notification.title
textViewNotificationContent.text = notification.content
linearLayoutNewsDetailButton.visibility = when (
notification.deepLink.isNullOrBlank()
&& notification.webLink.isNullOrBlank()
notification.deepLink.isNullOrBlank() &&
notification.webLink.isNullOrBlank()
) {
true -> View.GONE
false -> View.VISIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import org.sopt.official.R
import org.sopt.official.databinding.ActivityNotificationHistoryBinding
import org.sopt.official.util.viewBinding


@AndroidEntryPoint
class NotificationHistoryActivity : AppCompatActivity() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class NotificationHistoryListViewAdapter(
notifyDataSetChanged()
}


inner class ViewHolder(
private val viewBinding: ItemNotificationHistoryBinding
) : RecyclerView.ViewHolder(viewBinding.root) {
Expand Down Expand Up @@ -98,8 +97,8 @@ class NotificationHistoryListViewAdapter(

return when {
diffInDays >= 1 -> "${diffInDays}일 전"
diffInHours >= 1 ->"${diffInHours}시간 전"
diffInMinutes >= 1 ->"${diffInMinutes}분 전"
diffInHours >= 1 -> "${diffInHours}시간 전"
diffInMinutes >= 1 -> "${diffInMinutes}분 전"
else -> "방금"
}
}
Expand Down

0 comments on commit 0f1303a

Please sign in to comment.