fix(audio): 오디오 알림 route extra를 전달한다
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("ktlint:package-name", "ktlint:standard:package-name")
|
||||
|
||||
package kr.co.vividnext.sodalive.audio_content
|
||||
|
||||
import android.app.NotificationChannel
|
||||
@@ -471,9 +473,17 @@ class AudioContentPlayService :
|
||||
}
|
||||
|
||||
private fun updateNotification() {
|
||||
val intent = Intent(this, MainV2Activity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||
val intent = Intent(this, MainV2Activity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||
putExtra(
|
||||
MainV2Activity.EXTRA_AUDIO_NOTIFICATION_ROUTE,
|
||||
MainV2Activity.ROUTE_AUDIO_DETAIL
|
||||
)
|
||||
contentId?.let {
|
||||
putExtra(Constants.EXTRA_AUDIO_CONTENT_ID, it)
|
||||
}
|
||||
}
|
||||
val pendingIntent = PendingIntent.getActivity(
|
||||
this,
|
||||
0,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("ktlint:package-name", "ktlint:standard:package-name")
|
||||
|
||||
package kr.co.vividnext.sodalive.audio_content.player
|
||||
|
||||
import android.app.PendingIntent
|
||||
@@ -155,6 +157,10 @@ class AudioContentPlayerService : MediaSessionService() {
|
||||
private fun initMediaSession() {
|
||||
val contextIntent = Intent(applicationContext, MainV2Activity::class.java).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
putExtra(
|
||||
MainV2Activity.EXTRA_AUDIO_NOTIFICATION_ROUTE,
|
||||
MainV2Activity.ROUTE_AUDIO_PLAYER
|
||||
)
|
||||
}
|
||||
val pendingIntent = PendingIntent.getActivity(
|
||||
applicationContext,
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
@file:Suppress("ktlint:package-name", "ktlint:standard:package-name")
|
||||
|
||||
package kr.co.vividnext.sodalive.audio_content
|
||||
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class AudioContentPlayServiceNotificationRouteSourceTest {
|
||||
|
||||
private val source = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/audio_content/AudioContentPlayService.kt"
|
||||
).readText()
|
||||
|
||||
@Test
|
||||
fun `기존 오디오 알림은 상세 route와 content id를 전달한다`() {
|
||||
assertTrue(source.contains("MainV2Activity.EXTRA_AUDIO_NOTIFICATION_ROUTE"))
|
||||
assertTrue(source.contains("MainV2Activity.ROUTE_AUDIO_DETAIL"))
|
||||
assertTrue(source.contains("Constants.EXTRA_AUDIO_CONTENT_ID"))
|
||||
assertTrue(source.contains("PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_CANCEL_CURRENT"))
|
||||
}
|
||||
|
||||
private fun projectFile(relativePath: String): File {
|
||||
val candidates = listOf(File(relativePath), File("../$relativePath"))
|
||||
return candidates.firstOrNull { it.exists() }
|
||||
?: error("Project file not found: $relativePath")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
@file:Suppress("ktlint:package-name", "ktlint:standard:package-name")
|
||||
|
||||
package kr.co.vividnext.sodalive.audio_content.player
|
||||
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class AudioContentPlayerServiceNotificationRouteSourceTest {
|
||||
|
||||
private val source = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/audio_content/player/AudioContentPlayerService.kt"
|
||||
).readText()
|
||||
|
||||
@Test
|
||||
fun `MediaSession session activity는 플레이어 route를 전달한다`() {
|
||||
assertTrue(source.contains("MainV2Activity.EXTRA_AUDIO_NOTIFICATION_ROUTE"))
|
||||
assertTrue(source.contains("MainV2Activity.ROUTE_AUDIO_PLAYER"))
|
||||
assertTrue(source.contains("PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE"))
|
||||
}
|
||||
|
||||
private fun projectFile(relativePath: String): File {
|
||||
val candidates = listOf(File(relativePath), File("../$relativePath"))
|
||||
return candidates.firstOrNull { it.exists() }
|
||||
?: error("Project file not found: $relativePath")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user