-
Notifications
You must be signed in to change notification settings - Fork 72
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
(Proposal) [#264] media3 integration #266
Changes from all commits
4d024e6
69cb906
3c0e6ef
7495ff4
ef74596
e3ce3fe
b4504e6
145707a
8fde836
c684829
dce8d02
9a5e251
64f7472
9190130
a31c1c0
a399cf8
baa6902
172945e
01ef8b9
8897b93
4fda44b
a6239cf
b6c95ec
11f16f3
1ac9923
3be75f9
6cd0f3a
c55d900
93c5e6a
ab565ef
7d9204d
8f3638c
ef0a703
99b5a04
35a16d2
9955684
8f4377c
eb2781b
d905dc4
e788ab6
649e73c
29674ec
aec471e
2263e4c
bb6dc76
e4ad4f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
plugins { | ||
id("droidknights.android.application") | ||
} | ||
|
||
android { | ||
namespace = "com.droidknights.app2023.automotive" | ||
|
||
defaultConfig { | ||
applicationId = "com.droidknights.app2023.automotive" | ||
versionCode = 1 | ||
versionName = "1.0" | ||
} | ||
|
||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
buildTypes { | ||
getByName("release") { | ||
signingConfig = signingConfigs.getByName("debug") | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(projects.core.playback) | ||
implementation(projects.core.designsystem) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> | ||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" /> | ||
|
||
<uses-feature | ||
android:name="android.hardware.type.automotive" | ||
android:required="true" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:appCategory="audio" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.DroidKnights2023" | ||
android:name=".DroidKnightsApplication"> | ||
|
||
<meta-data android:name="com.android.automotive" | ||
android:resource="@xml/automotive_app_desc"/> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.droidknights.app2023.automotive | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class DroidKnightsApplication : Application() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.droidknights.app2023.automotive.di | ||
|
||
import android.app.PendingIntent | ||
import android.content.Context | ||
import com.droidknights.app2023.core.playback.session.SessionActivityIntentProvider | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
internal object AndroidModule { | ||
@Provides | ||
fun provideContext(@ApplicationContext context: Context): Context = context | ||
|
||
@Provides | ||
fun toPlayerIntentProvider(): SessionActivityIntentProvider = | ||
object : SessionActivityIntentProvider { | ||
override fun toPlayer(): PendingIntent? = null | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<background android:drawable="@color/ic_launcher_background"/> | ||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/> | ||
</adaptive-icon> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<background android:drawable="@color/ic_launcher_background"/> | ||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/> | ||
</adaptive-icon> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="purple_200">#FFBB86FC</color> | ||
<color name="purple_500">#FF6200EE</color> | ||
<color name="purple_700">#FF3700B3</color> | ||
<color name="teal_200">#FF03DAC5</color> | ||
<color name="teal_700">#FF018786</color> | ||
<color name="black">#FF000000</color> | ||
<color name="white">#FFFFFFFF</color> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="ic_launcher_background">#141414</color> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">드로이드나이츠 2023 for automotive</string> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<automotiveApp> | ||
<uses name="media" /> | ||
</automotiveApp> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
plugins { | ||
id("droidknights.android.application") | ||
} | ||
|
||
android { | ||
namespace = "com.droidknights.app2023.tv" | ||
|
||
defaultConfig { | ||
applicationId = "com.droidknights.app2023.tv" | ||
versionCode = 1 | ||
versionName = "1.0" | ||
} | ||
|
||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
buildTypes { | ||
getByName("release") { | ||
signingConfig = signingConfigs.getByName("debug") | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(projects.core.playback) | ||
implementation(projects.feature.player) | ||
implementation(projects.feature.tvMain) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> | ||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" /> | ||
|
||
<uses-feature | ||
android:name="android.hardware.touchscreen" | ||
android:required="false" /> | ||
<uses-feature | ||
android:name="android.software.leanback" | ||
android:required="false" /> | ||
|
||
<application | ||
android:name=".DroidKnightsApplication" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.DroidKnights2023" | ||
tools:targetApi="31" /> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.droidknights.app2023.tv | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class DroidKnightsApplication : Application() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.droidknights.app2023.tv.di | ||
|
||
import android.app.Application | ||
import android.content.Context | ||
import com.droidknights.app2023.core.playback.session.SessionActivityIntentProvider | ||
import com.droidknights.app2023.tv.misc.SessionActivityIntentProviderImpl | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
internal object AndroidModule { | ||
@Provides | ||
fun provideContext(@ApplicationContext context: Context): Context = context | ||
|
||
@Provides | ||
fun toPlayerIntentProvider( | ||
impl: SessionActivityIntentProviderImpl | ||
): SessionActivityIntentProvider = impl | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.droidknights.app2023.tv.misc | ||
|
||
import android.app.PendingIntent | ||
import android.content.Context | ||
import android.content.Intent | ||
import androidx.core.app.TaskStackBuilder | ||
import androidx.core.net.toUri | ||
import com.droidknights.app2023.core.playback.session.SessionActivityIntentProvider | ||
import com.droidknights.app2023.feature.player.navigation.PlayerRoute | ||
import com.droidknights.app2023.feature.tvmain.TvMainActivity | ||
import javax.inject.Inject | ||
|
||
class SessionActivityIntentProviderImpl @Inject constructor( | ||
private val context: Context, | ||
) : SessionActivityIntentProvider { | ||
override fun toPlayer(): PendingIntent? { | ||
val deepLinkIntent = Intent( | ||
Intent.ACTION_VIEW, | ||
PlayerRoute.deepLinkUriPattern.toUri(), | ||
context, | ||
TvMainActivity::class.java | ||
) | ||
|
||
val deepLinkPendingIntent: PendingIntent? = TaskStackBuilder.create(context).run { | ||
addNextIntentWithParentStack(deepLinkIntent) | ||
getPendingIntent( | ||
0, | ||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) | ||
|
||
} | ||
return deepLinkPendingIntent | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 질문) 이 class의 목적이 어떻게 될까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. core:playback module에서 MediaLibrarySession.Builder에서 MediaSession 클릭 시 사용자를 이동시키기 위한 setSessionActivity method에 쓰입니다. 각 앱마다 동작이 다르기에 interface를 선언하고 각 앱마다 다른 구현체를 넣어줬습니다. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<background android:drawable="@color/ic_launcher_background"/> | ||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/> | ||
</adaptive-icon> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<background android:drawable="@color/ic_launcher_background"/> | ||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/> | ||
</adaptive-icon> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="ic_launcher_background">#141414</color> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">드로이드나이츠 2023 for tv</string> | ||
</resources> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: SessionActivityIntentProvider interface의 구현체를 주입하기 위함인데 본 레퍼런스에선 이런 분리를 세세하게 고민하지 않았던 편.