Compare commits
26 Commits
1.0.0
...
1.1.0-beta
Author | SHA1 | Date |
---|---|---|
Jannik | a13eb15adf | |
Jannik | d40ab9519c | |
Jannik | 2e7db26d1d | |
Jannik | 8b7fb3ac5f | |
Jannik | 097383a082 | |
Jannik | 9380f98098 | |
Jannik | e0f05169f5 | |
Jannik | e113a9c795 | |
Jannik | 8e397e13d2 | |
Jannik | 31e7adac03 | |
Jannik | 63f5e69094 | |
Jannik | bf6f2d916e | |
Jannik | 81a20e0aa9 | |
Jannik | ed8f3fdcda | |
Jannik | fffbeaeb49 | |
Jannik | 21caa8eb1b | |
Jannik | bbc819551b | |
Jannik | 2004a3f483 | |
Jannik | 0a31c2fd88 | |
Jannik | f49b5a2730 | |
Jannik | a95813e91e | |
Jannik | 8bdaa8122b | |
Jannik | e2ea0a364e | |
Jannik | 777c6e0212 | |
Jannik | 71d5c58653 | |
Jannik | 6624e71228 |
|
@ -12,8 +12,8 @@ android {
|
||||||
applicationId "org.mosad.teapod"
|
applicationId "org.mosad.teapod"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 32
|
targetSdkVersion 32
|
||||||
versionCode 100000 //01.00.000
|
versionCode 100990 //01.00.000
|
||||||
versionName "1.0.0"
|
versionName "1.1.0-beta1"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
resValue "string", "build_time", buildTime()
|
resValue "string", "build_time", buildTime()
|
||||||
|
@ -49,20 +49,20 @@ dependencies {
|
||||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||||
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3'
|
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1'
|
||||||
|
|
||||||
implementation 'androidx.core:core-ktx:1.9.0'
|
implementation 'androidx.core:core-ktx:1.9.0'
|
||||||
implementation 'androidx.core:core-splashscreen:1.0.0'
|
implementation 'androidx.core:core-splashscreen:1.0.0'
|
||||||
implementation 'androidx.appcompat:appcompat:1.5.1'
|
implementation 'androidx.appcompat:appcompat:1.6.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.2'
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.5.2'
|
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
|
||||||
implementation 'androidx.security:security-crypto:1.1.0-alpha03'
|
implementation 'androidx.security:security-crypto:1.1.0-alpha04'
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
|
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
|
||||||
|
|
||||||
implementation 'com.google.android.material:material:1.6.1'
|
implementation 'com.google.android.material:material:1.7.0'
|
||||||
implementation "com.google.android.exoplayer:exoplayer-core:$exo_version"
|
implementation "com.google.android.exoplayer:exoplayer-core:$exo_version"
|
||||||
implementation "com.google.android.exoplayer:exoplayer-hls:$exo_version"
|
implementation "com.google.android.exoplayer:exoplayer-hls:$exo_version"
|
||||||
implementation "com.google.android.exoplayer:exoplayer-dash:$exo_version"
|
implementation "com.google.android.exoplayer:exoplayer-dash:$exo_version"
|
||||||
|
@ -71,7 +71,7 @@ dependencies {
|
||||||
|
|
||||||
implementation 'com.facebook.shimmer:shimmer:0.5.0'
|
implementation 'com.facebook.shimmer:shimmer:0.5.0'
|
||||||
|
|
||||||
implementation 'com.github.bumptech.glide:glide:4.13.2'
|
implementation 'com.github.bumptech.glide:glide:4.14.2'
|
||||||
implementation 'jp.wasabeef:glide-transformations:4.3.0'
|
implementation 'jp.wasabeef:glide-transformations:4.3.0'
|
||||||
|
|
||||||
implementation "io.ktor:ktor-client-core:$ktor_version"
|
implementation "io.ktor:ktor-client-core:$ktor_version"
|
||||||
|
@ -80,8 +80,8 @@ dependencies {
|
||||||
implementation "io.ktor:ktor-serialization-kotlinx-json:$ktor_version"
|
implementation "io.ktor:ktor-serialization-kotlinx-json:$ktor_version"
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,9 @@
|
||||||
# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
|
# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
|
||||||
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault
|
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault
|
||||||
|
|
||||||
|
# This is generated automatically by the Android Gradle plugin.
|
||||||
|
-dontwarn org.slf4j.impl.StaticLoggerBinder
|
||||||
|
|
||||||
#misc
|
#misc
|
||||||
-dontwarn java.lang.instrument.ClassFileTransformer
|
-dontwarn java.lang.instrument.ClassFileTransformer
|
||||||
-dontwarn java.lang.ClassValue
|
-dontwarn java.lang.ClassValue
|
||||||
|
|
|
@ -31,9 +31,11 @@ import io.ktor.client.request.*
|
||||||
import io.ktor.client.request.forms.*
|
import io.ktor.client.request.forms.*
|
||||||
import io.ktor.client.statement.*
|
import io.ktor.client.statement.*
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
|
import io.ktor.serialization.*
|
||||||
import io.ktor.serialization.kotlinx.json.*
|
import io.ktor.serialization.kotlinx.json.*
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.serialization.SerializationException
|
import kotlinx.serialization.SerializationException
|
||||||
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
import kotlinx.serialization.json.buildJsonObject
|
import kotlinx.serialization.json.buildJsonObject
|
||||||
|
@ -52,6 +54,7 @@ object Crunchyroll {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private const val baseUrl = "https://beta-api.crunchyroll.com"
|
private const val baseUrl = "https://beta-api.crunchyroll.com"
|
||||||
|
private const val staticUrl = "https://static.crunchyroll.com"
|
||||||
private const val basicApiTokenUrl = "https://gitlab.com/-/snippets/2274956/raw/main/snippetfile1.txt"
|
private const val basicApiTokenUrl = "https://gitlab.com/-/snippets/2274956/raw/main/snippetfile1.txt"
|
||||||
private var basicApiToken: String = ""
|
private var basicApiToken: String = ""
|
||||||
|
|
||||||
|
@ -164,12 +167,15 @@ object Crunchyroll {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a HTTP GET request with [params] to the [endpoint] at [url], if url is empty use baseUrl
|
||||||
|
*/
|
||||||
private suspend inline fun <reified T> requestGet(
|
private suspend inline fun <reified T> requestGet(
|
||||||
endpoint: String,
|
endpoint: String,
|
||||||
params: List<Pair<String, Any?>> = listOf(),
|
params: List<Pair<String, Any?>> = listOf(),
|
||||||
url: String = ""
|
url: String = ""
|
||||||
): T {
|
): T {
|
||||||
val path = url.ifEmpty { "$baseUrl$endpoint" }
|
val path = url.ifEmpty { baseUrl }.plus(endpoint)
|
||||||
|
|
||||||
return request(path, HttpMethod.Get, params)
|
return request(path, HttpMethod.Get, params)
|
||||||
}
|
}
|
||||||
|
@ -240,7 +246,7 @@ object Crunchyroll {
|
||||||
|
|
||||||
val account: Account = try {
|
val account: Account = try {
|
||||||
requestGet(indexEndpoint)
|
requestGet(indexEndpoint)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in account(). This is bad!", ex)
|
Log.e(TAG, "SerializationException in account(). This is bad!", ex)
|
||||||
NoneAccount
|
NoneAccount
|
||||||
}
|
}
|
||||||
|
@ -270,7 +276,7 @@ object Crunchyroll {
|
||||||
): BrowseResult {
|
): BrowseResult {
|
||||||
val browseEndpoint = "/content/v1/browse"
|
val browseEndpoint = "/content/v1/browse"
|
||||||
val parameters = mutableListOf(
|
val parameters = mutableListOf(
|
||||||
"locale" to Preferences.preferredLocale.toLanguageTag(),
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag(),
|
||||||
"sort_by" to sortBy.str,
|
"sort_by" to sortBy.str,
|
||||||
"start" to start,
|
"start" to start,
|
||||||
"n" to n
|
"n" to n
|
||||||
|
@ -293,14 +299,15 @@ object Crunchyroll {
|
||||||
Log.d(TAG, "browse result not cached, fetching: $parameters")
|
Log.d(TAG, "browse result not cached, fetching: $parameters")
|
||||||
val browseResult: BrowseResult = try {
|
val browseResult: BrowseResult = try {
|
||||||
requestGet(browseEndpoint, parameters)
|
requestGet(browseEndpoint, parameters)
|
||||||
}catch (ex: SerializationException) {
|
}catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in browse().", ex)
|
Log.e(TAG, "SerializationException in browse().", ex)
|
||||||
NoneBrowseResult
|
NoneBrowseResult
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the cache has more than 100 entries clear it, so it doesn't become a memory problem
|
// if the cache has more than 100 entries clear it, so it doesn't become a memory problem
|
||||||
// Note: this value is totally guessed and should be replaced by a properly researched value
|
// Note: this value is totally guessed and should be replaced by a properly researched value
|
||||||
if (browsingCache.size > 100) {
|
// TODO 100 is way to high as it's not the number of items but BrowseResults
|
||||||
|
if (browsingCache.size > 10) {
|
||||||
browsingCache.clear()
|
browsingCache.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,6 +322,8 @@ object Crunchyroll {
|
||||||
* Search fo a query term.
|
* Search fo a query term.
|
||||||
* Note: currently this function only supports series/tv shows.
|
* Note: currently this function only supports series/tv shows.
|
||||||
*
|
*
|
||||||
|
* TODO migrate to v2
|
||||||
|
*
|
||||||
* @param query The query term as String
|
* @param query The query term as String
|
||||||
* @param n The maximum number of results to return, default = 10
|
* @param n The maximum number of results to return, default = 10
|
||||||
* @return A **[SearchResult]** object
|
* @return A **[SearchResult]** object
|
||||||
|
@ -322,7 +331,7 @@ object Crunchyroll {
|
||||||
suspend fun search(query: String, n: Int = 10): SearchResult {
|
suspend fun search(query: String, n: Int = 10): SearchResult {
|
||||||
val searchEndpoint = "/content/v1/search"
|
val searchEndpoint = "/content/v1/search"
|
||||||
val parameters = listOf(
|
val parameters = listOf(
|
||||||
"locale" to Preferences.preferredLocale.toLanguageTag(),
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag(),
|
||||||
"q" to query,
|
"q" to query,
|
||||||
"n" to n,
|
"n" to n,
|
||||||
"type" to "series"
|
"type" to "series"
|
||||||
|
@ -333,8 +342,8 @@ object Crunchyroll {
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
requestGet(searchEndpoint, parameters)
|
requestGet(searchEndpoint, parameters)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in search(), with query = \"$query\".", ex)
|
Log.e(TAG, "Exception in search(), with query = \"$query\".", ex)
|
||||||
NoneSearchResult
|
NoneSearchResult
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,7 +358,7 @@ object Crunchyroll {
|
||||||
suspend fun objects(objects: List<String>): Collection<Item> {
|
suspend fun objects(objects: List<String>): Collection<Item> {
|
||||||
val episodesEndpoint = "/cms/v2/DE/M3/crunchyroll/objects/${objects.joinToString(",")}"
|
val episodesEndpoint = "/cms/v2/DE/M3/crunchyroll/objects/${objects.joinToString(",")}"
|
||||||
val parameters = listOf(
|
val parameters = listOf(
|
||||||
"locale" to Preferences.preferredLocale.toLanguageTag(),
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag(),
|
||||||
"Signature" to signature,
|
"Signature" to signature,
|
||||||
"Policy" to policy,
|
"Policy" to policy,
|
||||||
"Key-Pair-Id" to keyPairID
|
"Key-Pair-Id" to keyPairID
|
||||||
|
@ -357,28 +366,12 @@ object Crunchyroll {
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
requestGet(episodesEndpoint, parameters)
|
requestGet(episodesEndpoint, parameters)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in objects().", ex)
|
Log.e(TAG, "Exception in objects().", ex)
|
||||||
NoneCollection
|
NoneCollection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* List all available seasons as **[SeasonListItem]**.
|
|
||||||
*/
|
|
||||||
@Suppress("unused")
|
|
||||||
suspend fun seasonList(): DiscSeasonList {
|
|
||||||
val seasonListEndpoint = "/content/v1/season_list"
|
|
||||||
val parameters = listOf("locale" to Preferences.preferredLocale.toLanguageTag())
|
|
||||||
|
|
||||||
return try {
|
|
||||||
requestGet(seasonListEndpoint, parameters)
|
|
||||||
} catch (ex: SerializationException) {
|
|
||||||
Log.e(TAG, "SerializationException in seasonList().", ex)
|
|
||||||
NoneDiscSeasonList
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main media functions: series, season, episodes, playback
|
* Main media functions: series, season, episodes, playback
|
||||||
*/
|
*/
|
||||||
|
@ -387,18 +380,16 @@ object Crunchyroll {
|
||||||
* series id == crunchyroll id?
|
* series id == crunchyroll id?
|
||||||
*/
|
*/
|
||||||
suspend fun series(seriesId: String): Series {
|
suspend fun series(seriesId: String): Series {
|
||||||
val seriesEndpoint = "/cms/v2/${token.country}/M3/crunchyroll/series/$seriesId"
|
val seriesEndpoint = "/content/v2/cms/series/$seriesId"
|
||||||
val parameters = listOf(
|
val parameters = listOf(
|
||||||
"locale" to Preferences.preferredLocale.toLanguageTag(),
|
"preferred_audio_language" to Preferences.preferredAudioLocale.toLanguageTag(),
|
||||||
"Signature" to signature,
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag()
|
||||||
"Policy" to policy,
|
|
||||||
"Key-Pair-Id" to keyPairID
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
requestGet(seriesEndpoint, parameters)
|
requestGet(seriesEndpoint, parameters)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in series().", ex)
|
Log.e(TAG, "Exception in series().", ex)
|
||||||
NoneSeries
|
NoneSeries
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,21 +397,29 @@ object Crunchyroll {
|
||||||
/**
|
/**
|
||||||
* Get the next episode for a series.
|
* Get the next episode for a series.
|
||||||
*
|
*
|
||||||
|
* FIXME up_next returns no content if the is no next episode
|
||||||
|
*
|
||||||
* @param seriesId The series id for which to call up next
|
* @param seriesId The series id for which to call up next
|
||||||
* @return A **[UpNextSeriesItem]** with a Panel representing the up next episode
|
* @return A **[UpNextSeriesItem]** with a Panel representing the up next episode
|
||||||
*/
|
*/
|
||||||
suspend fun upNextSeries(seriesId: String): UpNextSeriesItem {
|
suspend fun upNextSeries(seriesId: String): UpNextSeriesList {
|
||||||
val upNextSeriesEndpoint = "/content/v1/up_next_series"
|
val upNextSeriesEndpoint = "/content/v2/discover/up_next/$seriesId"
|
||||||
val parameters = listOf(
|
val parameters = listOf(
|
||||||
"series_id" to seriesId,
|
"preferred_audio_language" to Preferences.preferredAudioLocale.toLanguageTag(),
|
||||||
"locale" to Preferences.preferredLocale.toLanguageTag()
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag()
|
||||||
)
|
)
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
requestGet(upNextSeriesEndpoint, parameters)
|
requestGet(upNextSeriesEndpoint, parameters)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: NoTransformationFoundException) {
|
||||||
Log.e(TAG, "SerializationException in upNextSeries().", ex)
|
// should be 204 No Content
|
||||||
NoneUpNextSeriesItem
|
NoneUpNextSeriesList
|
||||||
|
} catch (ex: JsonConvertException) {
|
||||||
|
Log.e(TAG, "JsonConvertException in upNextSeries() with seriesId=$seriesId", ex)
|
||||||
|
NoneUpNextSeriesList
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
Log.e(TAG, "Exception in upNextSeries().", ex)
|
||||||
|
NoneUpNextSeriesList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,19 +430,16 @@ object Crunchyroll {
|
||||||
* @return A **[Seasons]** object with a list of **[Season]**
|
* @return A **[Seasons]** object with a list of **[Season]**
|
||||||
*/
|
*/
|
||||||
suspend fun seasons(seriesId: String): Seasons {
|
suspend fun seasons(seriesId: String): Seasons {
|
||||||
val seasonsEndpoint = "/cms/v2/${token.country}/M3/crunchyroll/seasons"
|
val seasonsEndpoint = "/content/v2/cms/series/$seriesId/seasons"
|
||||||
val parameters = listOf(
|
val parameters = listOf(
|
||||||
"series_id" to seriesId,
|
"preferred_audio_language" to Preferences.preferredSubtitleLocale.toLanguageTag(),
|
||||||
"locale" to Preferences.preferredLocale.toLanguageTag(),
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag()
|
||||||
"Signature" to signature,
|
|
||||||
"Policy" to policy,
|
|
||||||
"Key-Pair-Id" to keyPairID
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
requestGet(seasonsEndpoint, parameters)
|
requestGet(seasonsEndpoint, parameters)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in seasons().", ex)
|
Log.e(TAG, "Exception in seasons().", ex)
|
||||||
NoneSeasons
|
NoneSeasons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -455,19 +451,16 @@ object Crunchyroll {
|
||||||
* @return A **[Episodes]** object with a list of **[Episode]**
|
* @return A **[Episodes]** object with a list of **[Episode]**
|
||||||
*/
|
*/
|
||||||
suspend fun episodes(seasonId: String): Episodes {
|
suspend fun episodes(seasonId: String): Episodes {
|
||||||
val episodesEndpoint = "/cms/v2/${token.country}/M3/crunchyroll/episodes"
|
val episodesEndpoint = "/content/v2/cms/seasons/$seasonId/episodes"
|
||||||
val parameters = listOf(
|
val parameters = listOf(
|
||||||
"season_id" to seasonId,
|
"preferred_audio_language" to Preferences.preferredSubtitleLocale.toLanguageTag(),
|
||||||
"locale" to Preferences.preferredLocale.toLanguageTag(),
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag()
|
||||||
"Signature" to signature,
|
|
||||||
"Policy" to policy,
|
|
||||||
"Key-Pair-Id" to keyPairID
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
requestGet(episodesEndpoint, parameters)
|
requestGet(episodesEndpoint, parameters)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in episodes().", ex)
|
Log.e(TAG, "Exception in episodes().", ex)
|
||||||
NoneEpisodes
|
NoneEpisodes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -475,18 +468,28 @@ object Crunchyroll {
|
||||||
/**
|
/**
|
||||||
* Get all available subtitles and streams of a episode.
|
* Get all available subtitles and streams of a episode.
|
||||||
*
|
*
|
||||||
* @param url The playback url of a episode
|
* @param url The streams url of a episode
|
||||||
* @return A **[Playback]** object
|
* @return A **[Streams]** object
|
||||||
*/
|
*/
|
||||||
suspend fun playback(url: String): Playback {
|
suspend fun streams(url: String): Streams {
|
||||||
|
val parameters = listOf(
|
||||||
|
"preferred_audio_language" to Preferences.preferredSubtitleLocale.toLanguageTag(),
|
||||||
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag()
|
||||||
|
)
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
requestGet("", url = url)
|
requestGet(url, parameters)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in playback(), with url = $url.", ex)
|
Log.e(TAG, "Exception in streams().", ex)
|
||||||
NonePlayback
|
NoneStreams
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun streamsFromMediaGUID(mediaGUID: String): Streams {
|
||||||
|
val streamsEndpoint = "/content/v2/cms/videos/$mediaGUID/streams"
|
||||||
|
return streams(streamsEndpoint)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional media functions: watchlist (series), playhead, similar to
|
* Additional media functions: watchlist (series), playhead, similar to
|
||||||
*/
|
*/
|
||||||
|
@ -498,14 +501,18 @@ object Crunchyroll {
|
||||||
* @return **[Boolean]**: ture if it was found, else false
|
* @return **[Boolean]**: ture if it was found, else false
|
||||||
*/
|
*/
|
||||||
suspend fun isWatchlist(seriesId: String): Boolean {
|
suspend fun isWatchlist(seriesId: String): Boolean {
|
||||||
val watchlistSeriesEndpoint = "/content/v1/watchlist/$accountID/$seriesId"
|
val watchlistSeriesEndpoint = "/content/v2/$accountID/watchlist"
|
||||||
val parameters = listOf("locale" to Preferences.preferredLocale.toLanguageTag())
|
val parameters = listOf(
|
||||||
|
"content_ids" to seriesId,
|
||||||
|
"preferred_audio_language" to Preferences.preferredAudioLocale.toLanguageTag(),
|
||||||
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag()
|
||||||
|
)
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
(requestGet(watchlistSeriesEndpoint, parameters) as JsonObject)
|
(requestGet(watchlistSeriesEndpoint, parameters) as Collection2<IsWatchlistItem>)
|
||||||
.containsKey(seriesId)
|
.total == 1
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in isWatchlist() with seriesId = $seriesId", ex)
|
Log.e(TAG, "Exception in isWatchlist() with seriesId = $seriesId", ex)
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -516,14 +523,21 @@ object Crunchyroll {
|
||||||
* @param seriesId The crunchyroll series id of the media to check
|
* @param seriesId The crunchyroll series id of the media to check
|
||||||
*/
|
*/
|
||||||
suspend fun postWatchlist(seriesId: String) {
|
suspend fun postWatchlist(seriesId: String) {
|
||||||
val watchlistPostEndpoint = "/content/v1/watchlist/$accountID"
|
val watchlistPostEndpoint = "/content/v2/$accountID/watchlist"
|
||||||
val parameters = listOf("locale" to Preferences.preferredLocale.toLanguageTag())
|
val parameters = listOf(
|
||||||
|
"preferred_audio_language" to Preferences.preferredAudioLocale.toLanguageTag(),
|
||||||
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag()
|
||||||
|
)
|
||||||
|
|
||||||
val json = buildJsonObject {
|
val json = buildJsonObject {
|
||||||
put("content_id", seriesId)
|
put("content_id", seriesId)
|
||||||
}
|
}
|
||||||
|
|
||||||
requestPost(watchlistPostEndpoint, parameters, json)
|
try {
|
||||||
|
requestPost(watchlistPostEndpoint, parameters, json)
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
Log.e(TAG, "Exception in postWatchlist() with seriesId = $seriesId", ex)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -532,10 +546,17 @@ object Crunchyroll {
|
||||||
* @param seriesId The crunchyroll series id of the media to check
|
* @param seriesId The crunchyroll series id of the media to check
|
||||||
*/
|
*/
|
||||||
suspend fun deleteWatchlist(seriesId: String) {
|
suspend fun deleteWatchlist(seriesId: String) {
|
||||||
val watchlistDeleteEndpoint = "/content/v1/watchlist/$accountID/$seriesId"
|
val watchlistDeleteEndpoint = "/content/v2/$accountID/watchlist/$seriesId"
|
||||||
val parameters = listOf("locale" to Preferences.preferredLocale.toLanguageTag())
|
val parameters = listOf(
|
||||||
|
"preferred_audio_language" to Preferences.preferredAudioLocale.toLanguageTag(),
|
||||||
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag()
|
||||||
|
)
|
||||||
|
|
||||||
requestDelete(watchlistDeleteEndpoint, parameters)
|
try {
|
||||||
|
requestDelete(watchlistDeleteEndpoint, parameters)
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
Log.e(TAG, "Exception in deleteWatchlist() with seriesId = $seriesId", ex)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -546,18 +567,20 @@ object Crunchyroll {
|
||||||
* @param episodeIDs A **[List]** of episodes IDs as strings.
|
* @param episodeIDs A **[List]** of episodes IDs as strings.
|
||||||
* @return A **[Map]**<String, **[PlayheadObject]**> containing playback info.
|
* @return A **[Map]**<String, **[PlayheadObject]**> containing playback info.
|
||||||
*/
|
*/
|
||||||
suspend fun playheads(episodeIDs: List<String>): PlayheadsMap {
|
suspend fun playheads(episodeIDs: List<String>): Playheads {
|
||||||
val playheadsEndpoint = "/content/v1/playheads/$accountID/${episodeIDs.joinToString(",")}"
|
val playheadsEndpoint = "/content/v2/$accountID/playheads"
|
||||||
val parameters = listOf("locale" to Preferences.preferredLocale.toLanguageTag())
|
val parameters = listOf(
|
||||||
|
"content_ids" to episodeIDs.joinToString(","),
|
||||||
|
"preferred_audio_language" to Preferences.preferredAudioLocale.toLanguageTag(),
|
||||||
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
requestGet(playheadsEndpoint, parameters)
|
requestGet(playheadsEndpoint, parameters)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in playheads().", ex)
|
|
||||||
emptyMap()
|
|
||||||
} catch (ex: Throwable) {
|
|
||||||
Log.e(TAG, "Exception in playheads().", ex.cause)
|
Log.e(TAG, "Exception in playheads().", ex.cause)
|
||||||
emptyMap()
|
NonePlayheads
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,7 +592,7 @@ object Crunchyroll {
|
||||||
*/
|
*/
|
||||||
suspend fun postPlayheads(episodeId: String, playhead: Int) {
|
suspend fun postPlayheads(episodeId: String, playhead: Int) {
|
||||||
val playheadsEndpoint = "/content/v1/playheads/$accountID"
|
val playheadsEndpoint = "/content/v1/playheads/$accountID"
|
||||||
val parameters = listOf("locale" to Preferences.preferredLocale.toLanguageTag())
|
val parameters = listOf("locale" to Preferences.preferredSubtitleLocale.toLanguageTag())
|
||||||
|
|
||||||
val json = buildJsonObject {
|
val json = buildJsonObject {
|
||||||
put("content_id", episodeId)
|
put("content_id", episodeId)
|
||||||
|
@ -578,11 +601,32 @@ object Crunchyroll {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
requestPost(playheadsEndpoint, parameters, json)
|
requestPost(playheadsEndpoint, parameters, json)
|
||||||
} catch (ex: Throwable) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "Exception in postPlayheads()", ex.cause)
|
Log.e(TAG, "Exception in postPlayheads()", ex.cause)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the intro meta data including start, end and duration of the intro.
|
||||||
|
*
|
||||||
|
* @param episodeId A episode ID as strings.
|
||||||
|
*/
|
||||||
|
suspend fun datalabIntro(episodeId: String): DatalabIntro {
|
||||||
|
val datalabIntroEndpoint = "/datalab-intro-v2/$episodeId.json"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wtf crunchyroll, why do you return an xml error message when some data is missing,
|
||||||
|
* this is a json endpoint. For fucks sake, return at least a valid json message.
|
||||||
|
*/
|
||||||
|
return try {
|
||||||
|
val response: HttpResponse = requestGet(datalabIntroEndpoint, url = staticUrl)
|
||||||
|
Json.decodeFromString(response.bodyAsText())
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
Log.e(TAG, "Exception in datalabIntro(). EpisodeId=$episodeId", ex)
|
||||||
|
NoneDatalabIntro
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get similar media for a show/movie.
|
* Get similar media for a show/movie.
|
||||||
*
|
*
|
||||||
|
@ -594,14 +638,14 @@ object Crunchyroll {
|
||||||
val similarToEndpoint = "/content/v1/$accountID/similar_to"
|
val similarToEndpoint = "/content/v1/$accountID/similar_to"
|
||||||
val parameters = listOf(
|
val parameters = listOf(
|
||||||
"guid" to seriesId,
|
"guid" to seriesId,
|
||||||
"locale" to Preferences.preferredLocale.toLanguageTag(),
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag(),
|
||||||
"n" to n
|
"n" to n
|
||||||
)
|
)
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
requestGet(similarToEndpoint, parameters)
|
requestGet(similarToEndpoint, parameters)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in similarTo().", ex)
|
Log.e(TAG, "Exception in similarTo().", ex)
|
||||||
NoneSimilarToResult
|
NoneSimilarToResult
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -614,23 +658,24 @@ object Crunchyroll {
|
||||||
* List items present in the watchlist.
|
* List items present in the watchlist.
|
||||||
*
|
*
|
||||||
* @param n Number of items to return, defaults to 20.
|
* @param n Number of items to return, defaults to 20.
|
||||||
* @return A **[Watchlist]** containing up to n **[Item]**.
|
* @return A **[Collection]** containing up to n **[Item]**.
|
||||||
*/
|
*/
|
||||||
suspend fun watchlist(n: Int = 20): Watchlist {
|
suspend fun watchlist(n: Int = 20): Collection<Item> {
|
||||||
val watchlistEndpoint = "/content/v1/$accountID/watchlist"
|
val watchlistEndpoint = "/content/v2/discover/$accountID/watchlist"
|
||||||
val parameters = listOf(
|
val parameters = listOf(
|
||||||
"locale" to Preferences.preferredLocale.toLanguageTag(),
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag(),
|
||||||
"n" to n
|
"n" to n,
|
||||||
|
"preferred_audio_language" to Preferences.preferredAudioLocale.toLanguageTag()
|
||||||
)
|
)
|
||||||
|
|
||||||
val list: ContinueWatchingList = try {
|
val list: Watchlist = try {
|
||||||
requestGet(watchlistEndpoint, parameters)
|
requestGet(watchlistEndpoint, parameters)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in watchlist().", ex)
|
Log.e(TAG, "Exception in watchlist().", ex)
|
||||||
NoneContinueWatchingList
|
NoneWatchlist
|
||||||
}
|
}
|
||||||
|
|
||||||
val objects = list.items.map{ it.panel.episodeMetadata.seriesId }
|
val objects = list.data.map{ it.panel.episodeMetadata.seriesId }
|
||||||
return objects(objects)
|
return objects(objects)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,27 +683,27 @@ object Crunchyroll {
|
||||||
* List the next up episodes for the logged in account.
|
* List the next up episodes for the logged in account.
|
||||||
*
|
*
|
||||||
* @param n Number of items to return, defaults to 20.
|
* @param n Number of items to return, defaults to 20.
|
||||||
* @return A **[ContinueWatchingList]** containing up to n **[ContinueWatchingItem]**.
|
* @return A **[HistoryList]** containing up to n **[UpNextAccountItem]**.
|
||||||
*/
|
*/
|
||||||
suspend fun upNextAccount(n: Int = 20): ContinueWatchingList {
|
suspend fun upNextAccount(n: Int = 20): HistoryList {
|
||||||
val watchlistEndpoint = "/content/v1/$accountID/up_next_account"
|
val watchlistEndpoint = "/content/v2/discover/$accountID/history"
|
||||||
val parameters = listOf(
|
val parameters = listOf(
|
||||||
"locale" to Preferences.preferredLocale.toLanguageTag(),
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag(),
|
||||||
"n" to n
|
"n" to n
|
||||||
)
|
)
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
requestGet(watchlistEndpoint, parameters)
|
requestGet(watchlistEndpoint, parameters)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in upNextAccount().", ex)
|
Log.e(TAG, "Exception in upNextAccount().", ex)
|
||||||
NoneContinueWatchingList
|
NoneHistoryList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun recommendations(n: Int = 20, start: Int = 0): RecommendationsList {
|
suspend fun recommendations(n: Int = 20, start: Int = 0): RecommendationsList {
|
||||||
val recommendationsEndpoint = "/content/v1/$accountID/recommendations"
|
val recommendationsEndpoint = "/content/v1/$accountID/recommendations"
|
||||||
val parameters = listOf(
|
val parameters = listOf(
|
||||||
"locale" to Preferences.preferredLocale.toLanguageTag(),
|
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag(),
|
||||||
"n" to n,
|
"n" to n,
|
||||||
"start" to start,
|
"start" to start,
|
||||||
"variant_id" to 0
|
"variant_id" to 0
|
||||||
|
@ -666,8 +711,8 @@ object Crunchyroll {
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
requestGet(recommendationsEndpoint, parameters)
|
requestGet(recommendationsEndpoint, parameters)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in recommendations().", ex)
|
Log.e(TAG, "Exception in recommendations().", ex)
|
||||||
NoneRecommendationsList
|
NoneRecommendationsList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -686,8 +731,8 @@ object Crunchyroll {
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
requestGet(profileEndpoint)
|
requestGet(profileEndpoint)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in profile().", ex)
|
Log.e(TAG, "Exception in profile().", ex)
|
||||||
NoneProfile
|
NoneProfile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -716,8 +761,8 @@ object Crunchyroll {
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
requestGet(profileEndpoint)
|
requestGet(profileEndpoint)
|
||||||
} catch (ex: SerializationException) {
|
} catch (ex: Exception) {
|
||||||
Log.e(TAG, "SerializationException in benefits().", ex)
|
Log.e(TAG, "Exception in benefits().", ex)
|
||||||
NoneBenefits
|
NoneBenefits
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,24 +117,19 @@ data class Collection<T>(
|
||||||
@SerialName("items") val items: List<T>
|
@SerialName("items") val items: List<T>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Collection2<T>(
|
||||||
|
@SerialName("total") val total: Int,
|
||||||
|
@SerialName("data") val data: List<T>
|
||||||
|
)
|
||||||
|
|
||||||
typealias SearchResult = Collection<SearchCollection>
|
typealias SearchResult = Collection<SearchCollection>
|
||||||
typealias SearchCollection = Collection<Item>
|
typealias SearchCollection = Collection<Item>
|
||||||
typealias BrowseResult = Collection<Item>
|
typealias BrowseResult = Collection<Item>
|
||||||
typealias SimilarToResult = Collection<Item>
|
typealias SimilarToResult = Collection<Item>
|
||||||
typealias DiscSeasonList = Collection<SeasonListItem>
|
|
||||||
typealias Watchlist = Collection<Item>
|
|
||||||
typealias ContinueWatchingList = Collection<ContinueWatchingItem>
|
|
||||||
typealias RecommendationsList = Collection<Item>
|
typealias RecommendationsList = Collection<Item>
|
||||||
typealias Benefits = Collection<Benefit>
|
typealias Benefits = Collection<Benefit>
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class UpNextSeriesItem(
|
|
||||||
@SerialName("playhead") val playhead: Int,
|
|
||||||
@SerialName("fully_watched") val fullyWatched: Boolean,
|
|
||||||
@SerialName("never_watched") val neverWatched: Boolean,
|
|
||||||
@SerialName("panel") val panel: EpisodePanel,
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* panel data classes
|
* panel data classes
|
||||||
*/
|
*/
|
||||||
|
@ -161,35 +156,45 @@ data class Images(val poster_tall: List<List<Poster>>, val poster_wide: List<Lis
|
||||||
data class Poster(val height: Int, val width: Int, val source: String, val type: String)
|
data class Poster(val height: Int, val width: Int, val source: String, val type: String)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* season list data classes
|
* up next & watchlist data classes
|
||||||
*/
|
*/
|
||||||
@Serializable
|
|
||||||
data class SeasonListItem(
|
typealias Watchlist = Collection2<WatchlistItem>
|
||||||
@SerialName("id") val id: String,
|
typealias HistoryList = Collection2<UpNextAccountItem>
|
||||||
@SerialName("localization") val localization: SeasonListLocalization
|
typealias UpNextSeriesList = Collection2<UpNextSeriesItem>
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SeasonListLocalization(
|
data class WatchlistItem(
|
||||||
@SerialName("title") val title: String,
|
|
||||||
@SerialName("description") val description: String,
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* continue_watching_item data classes
|
|
||||||
*/
|
|
||||||
@Serializable
|
|
||||||
data class ContinueWatchingItem(
|
|
||||||
@SerialName("panel") val panel: EpisodePanel,
|
@SerialName("panel") val panel: EpisodePanel,
|
||||||
@SerialName("new") val new: Boolean,
|
@SerialName("new") val new: Boolean,
|
||||||
@SerialName("new_content") val newContent: Boolean,
|
|
||||||
// not present in up_next_account -> continue_watching_item
|
|
||||||
// @SerialName("is_favorite") val isFavorite: Boolean,
|
|
||||||
// @SerialName("never_watched") val neverWatched: Boolean,
|
|
||||||
// @SerialName("completion_status") val completionStatus: Boolean,
|
|
||||||
@SerialName("playhead") val playhead: Int,
|
@SerialName("playhead") val playhead: Int,
|
||||||
// not present in watchlist -> continue_watching_item
|
|
||||||
@SerialName("fully_watched") val fullyWatched: Boolean = false,
|
@SerialName("fully_watched") val fullyWatched: Boolean = false,
|
||||||
|
@SerialName("never_watched") val neverWatched: Boolean = false,
|
||||||
|
@SerialName("is_favorite") val isFavorite: Boolean,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class IsWatchlistItem(
|
||||||
|
@SerialName("id") val id: String,
|
||||||
|
@SerialName("is_favorite") val isFavorite: Boolean,
|
||||||
|
@SerialName("date_added") val dateAdded: String
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class UpNextAccountItem(
|
||||||
|
@SerialName("panel") val panel: EpisodePanel,
|
||||||
|
@SerialName("new") val new: Boolean,
|
||||||
|
@SerialName("playhead") val playhead: Int,
|
||||||
|
@SerialName("fully_watched") val fullyWatched: Boolean = false,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class UpNextSeriesItem(
|
||||||
|
@SerialName("panel") val panel: EpisodePanel,
|
||||||
|
@SerialName("playhead") val playhead: Int,
|
||||||
|
@SerialName("fully_watched") val fullyWatched: Boolean,
|
||||||
|
@SerialName("never_watched") val neverWatched: Boolean,
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// EpisodePanel is used in ContinueWatchingItem and UpNextSeriesItem
|
// EpisodePanel is used in ContinueWatchingItem and UpNextSeriesItem
|
||||||
|
@ -202,7 +207,7 @@ data class EpisodePanel(
|
||||||
@SerialName("description") val description: String,
|
@SerialName("description") val description: String,
|
||||||
@SerialName("episode_metadata") val episodeMetadata: EpisodeMetadata,
|
@SerialName("episode_metadata") val episodeMetadata: EpisodeMetadata,
|
||||||
@SerialName("images") val images: Thumbnail,
|
@SerialName("images") val images: Thumbnail,
|
||||||
@SerialName("playback") val playback: String,
|
// @SerialName("streams_link") val streamsLink: String,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@ -216,38 +221,36 @@ data class EpisodeMetadata(
|
||||||
@SerialName("series_title") val seriesTitle: String,
|
@SerialName("series_title") val seriesTitle: String,
|
||||||
)
|
)
|
||||||
|
|
||||||
val NoneItem = Item("", "", "", "", "", Images(emptyList(), emptyList()))
|
|
||||||
val NoneEpisodeMetadata = EpisodeMetadata(0, 0, "", 0, "", "", "")
|
|
||||||
val NoneEpisodePanel = EpisodePanel("", "", "", "", "", NoneEpisodeMetadata, Thumbnail(listOf()), "")
|
|
||||||
|
|
||||||
val NoneCollection = Collection<Item>(0, emptyList())
|
val NoneCollection = Collection<Item>(0, emptyList())
|
||||||
val NoneSearchResult = SearchResult(0, emptyList())
|
val NoneSearchResult = SearchResult(0, emptyList())
|
||||||
val NoneBrowseResult = BrowseResult(0, emptyList())
|
val NoneBrowseResult = BrowseResult(0, emptyList())
|
||||||
val NoneSimilarToResult = SimilarToResult(0, emptyList())
|
val NoneSimilarToResult = SimilarToResult(0, emptyList())
|
||||||
val NoneDiscSeasonList = DiscSeasonList(0, emptyList())
|
val NoneWatchlist = Watchlist(0, emptyList())
|
||||||
val NoneContinueWatchingList = ContinueWatchingList(0, emptyList())
|
val NoneHistoryList = HistoryList(0, emptyList())
|
||||||
|
val NoneUpNextSeriesList = UpNextSeriesList(0, emptyList())
|
||||||
val NoneRecommendationsList = RecommendationsList(0, emptyList())
|
val NoneRecommendationsList = RecommendationsList(0, emptyList())
|
||||||
val NoneBenefits = Benefits(0, emptyList())
|
val NoneBenefits = Benefits(0, emptyList())
|
||||||
|
|
||||||
val NoneUpNextSeriesItem = UpNextSeriesItem(
|
|
||||||
playhead = 0,
|
|
||||||
fullyWatched = false,
|
|
||||||
neverWatched = false,
|
|
||||||
panel = NoneEpisodePanel
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* series data class
|
* series data class
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
typealias Series = Collection2<SeriesItem>
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Series(
|
data class SeriesItem(
|
||||||
@SerialName("id") val id: String,
|
@SerialName("id") val id: String,
|
||||||
@SerialName("title") val title: String,
|
@SerialName("title") val title: String,
|
||||||
@SerialName("description") val description: String,
|
@SerialName("description") val description: String,
|
||||||
@SerialName("images") val images: Images,
|
@SerialName("images") val images: Images,
|
||||||
@SerialName("maturity_ratings") val maturityRatings: List<String>
|
@SerialName("is_simulcast") val isSimulcast: Boolean,
|
||||||
|
@SerialName("maturity_ratings") val maturityRatings: List<String>,
|
||||||
|
@SerialName("audio_locales") val audioLocales: List<String>
|
||||||
|
|
||||||
)
|
)
|
||||||
val NoneSeries = Series("", "", "", Images(emptyList(), emptyList()), emptyList())
|
|
||||||
|
val NoneSeriesItem = SeriesItem("", "", "", Images(emptyList(), emptyList()), false, emptyList(), emptyList())
|
||||||
|
val NoneSeries = Series(1, listOf(NoneSeriesItem))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Seasons data classes
|
* Seasons data classes
|
||||||
|
@ -255,18 +258,8 @@ val NoneSeries = Series("", "", "", Images(emptyList(), emptyList()), emptyList(
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Seasons(
|
data class Seasons(
|
||||||
@SerialName("total") val total: Int,
|
@SerialName("total") val total: Int,
|
||||||
@SerialName("items") val items: List<Season>
|
@SerialName("data") val data: List<Season>
|
||||||
) {
|
)
|
||||||
fun getPreferredSeason(local: Locale): Season {
|
|
||||||
return items.firstOrNull { season ->
|
|
||||||
// try to get the the first seasons which matches the preferred local
|
|
||||||
season.slugTitle.endsWith("${local.getDisplayLanguage(Locale.ENGLISH)}-dub", true)
|
|
||||||
} ?: items.firstOrNull { season ->
|
|
||||||
// if there is no season with the preferred local, try to find a subbed season
|
|
||||||
season.isSubbed
|
|
||||||
} ?: items.first() // if no preferred language and no sub, use the first season
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Season(
|
data class Season(
|
||||||
|
@ -289,7 +282,7 @@ val NoneSeason = Season("", "", "", "", 0, isSubbed = false, isDubbed = false)
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Episodes(
|
data class Episodes(
|
||||||
@SerialName("total") val total: Int,
|
@SerialName("total") val total: Int,
|
||||||
@SerialName("items") val items: List<Episode>
|
@SerialName("data") val data: List<Episode>
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@ -309,7 +302,8 @@ data class Episode(
|
||||||
@SerialName("is_dubbed") val isDubbed: Boolean,
|
@SerialName("is_dubbed") val isDubbed: Boolean,
|
||||||
@SerialName("images") val images: Thumbnail,
|
@SerialName("images") val images: Thumbnail,
|
||||||
@SerialName("duration_ms") val durationMs: Int,
|
@SerialName("duration_ms") val durationMs: Int,
|
||||||
@SerialName("playback") val playback: String,
|
@SerialName("versions") val versions: List<Version>,
|
||||||
|
@SerialName("streams_link") val streamsLink: String,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@ -317,6 +311,17 @@ data class Thumbnail(
|
||||||
@SerialName("thumbnail") val thumbnail: List<List<Poster>>
|
@SerialName("thumbnail") val thumbnail: List<List<Poster>>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Version(
|
||||||
|
@SerialName("audio_locale") val audioLocale: String,
|
||||||
|
@SerialName("guid") val guid: String,
|
||||||
|
@SerialName("is_premium_only") val isPremiumOnly: Boolean,
|
||||||
|
@SerialName("media_guid") val mediaGUID: String,
|
||||||
|
@SerialName("original") val original: Boolean,
|
||||||
|
@SerialName("season_guid") val seasonGUID: String,
|
||||||
|
@SerialName("variant") val variant: String,
|
||||||
|
)
|
||||||
|
|
||||||
val NoneEpisodes = Episodes(0, listOf())
|
val NoneEpisodes = Episodes(0, listOf())
|
||||||
val NoneEpisode = Episode(
|
val NoneEpisode = Episode(
|
||||||
id = "",
|
id = "",
|
||||||
|
@ -334,10 +339,21 @@ val NoneEpisode = Episode(
|
||||||
isDubbed = false,
|
isDubbed = false,
|
||||||
images = Thumbnail(listOf()),
|
images = Thumbnail(listOf()),
|
||||||
durationMs = 0,
|
durationMs = 0,
|
||||||
playback = ""
|
versions = emptyList(),
|
||||||
|
streamsLink = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
typealias PlayheadsMap = Map<String, PlayheadObject>
|
val NoneVersion = Version(
|
||||||
|
audioLocale = "",
|
||||||
|
guid = "",
|
||||||
|
isPremiumOnly = false,
|
||||||
|
mediaGUID = "",
|
||||||
|
original = true,
|
||||||
|
seasonGUID = "",
|
||||||
|
variant = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
typealias Playheads = Collection2<PlayheadObject>
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class PlayheadObject(
|
data class PlayheadObject(
|
||||||
|
@ -347,37 +363,47 @@ data class PlayheadObject(
|
||||||
@SerialName("last_modified") val lastModified: String,
|
@SerialName("last_modified") val lastModified: String,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val NonePlayheads = Playheads(0, emptyList())
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Meta data for a episode intro. All time values are in seconds.
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
data class DatalabIntro(
|
||||||
|
@SerialName("media_id") val mediaId: String,
|
||||||
|
@SerialName("startTime") val startTime: Float,
|
||||||
|
@SerialName("endTime") val endTime: Float,
|
||||||
|
@SerialName("duration") val duration: Float,
|
||||||
|
@SerialName("comparedWith") val comparedWith: String,
|
||||||
|
@SerialName("ordering") val ordering: String,
|
||||||
|
@SerialName("last_updated") val lastUpdated: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
val NoneDatalabIntro = DatalabIntro("", 0f, 0f, 0f, "", "", "")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* playback/stream data classes
|
* playback/stream data classes
|
||||||
*/
|
*/
|
||||||
@Serializable
|
|
||||||
data class Playback(
|
|
||||||
@SerialName("audio_locale") val audioLocale: String,
|
|
||||||
@SerialName("subtitles") val subtitles: Map<String, Subtitle>,
|
|
||||||
@SerialName("streams") val streams: Streams,
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class Subtitle(
|
|
||||||
@SerialName("locale") val locale: String,
|
|
||||||
@SerialName("url") val url: String,
|
|
||||||
@SerialName("format") val format: String,
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Streams(
|
data class Streams(
|
||||||
|
@SerialName("total") val total: Int,
|
||||||
|
@SerialName("data") val data: List<StreamList>,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class StreamList(
|
||||||
@SerialName("adaptive_dash") val adaptive_dash: Map<String, Stream>,
|
@SerialName("adaptive_dash") val adaptive_dash: Map<String, Stream>,
|
||||||
@SerialName("adaptive_hls") val adaptive_hls: Map<String, Stream>,
|
@SerialName("adaptive_hls") val adaptive_hls: Map<String, Stream>,
|
||||||
|
@SerialName("download_dash") val downloadDash: Map<String, Stream>,
|
||||||
@SerialName("download_hls") val download_hls: Map<String, Stream>,
|
@SerialName("download_hls") val download_hls: Map<String, Stream>,
|
||||||
@SerialName("drm_adaptive_dash") val drm_adaptive_dash: Map<String, Stream>,
|
// @SerialName("drm_adaptive_dash") val drmAdaptiveDash: Map<String, Stream>,
|
||||||
@SerialName("drm_adaptive_hls") val drm_adaptive_hls: Map<String, Stream>,
|
// @SerialName("drm_adaptive_hls") val drmAdaptiveHls: Map<String, Stream>,
|
||||||
@SerialName("drm_download_hls") val drm_download_hls: Map<String, Stream>,
|
// @SerialName("drm_download_dash") val drmDownloadDash: Map<String, Stream>,
|
||||||
@SerialName("trailer_dash") val trailer_dash: Map<String, Stream>,
|
// @SerialName("drm_download_hls") val drmDownloadHls: Map<String, Stream>,
|
||||||
@SerialName("trailer_hls") val trailer_hls: Map<String, Stream>,
|
// @SerialName("vo_adaptive_dash") val vo_adaptive_dash: Map<String, Stream>,
|
||||||
@SerialName("vo_adaptive_dash") val vo_adaptive_dash: Map<String, Stream>,
|
// @SerialName("vo_adaptive_hls") val vo_adaptive_hls: Map<String, Stream>,
|
||||||
@SerialName("vo_adaptive_hls") val vo_adaptive_hls: Map<String, Stream>,
|
// @SerialName("vo_drm_adaptive_dash") val vo_drm_adaptive_dash: Map<String, Stream>,
|
||||||
@SerialName("vo_drm_adaptive_dash") val vo_drm_adaptive_dash: Map<String, Stream>,
|
// @SerialName("vo_drm_adaptive_hls") val vo_drm_adaptive_hls: Map<String, Stream>,
|
||||||
@SerialName("vo_drm_adaptive_hls") val vo_drm_adaptive_hls: Map<String, Stream>,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@ -387,13 +413,11 @@ data class Stream(
|
||||||
@SerialName("vcodec") val vcodec: String = "", // default/nullable value since optional
|
@SerialName("vcodec") val vcodec: String = "", // default/nullable value since optional
|
||||||
)
|
)
|
||||||
|
|
||||||
val NonePlayback = Playback(
|
val NoneStreams = Streams(
|
||||||
"",
|
0,
|
||||||
mapOf(),
|
arrayListOf(StreamList(
|
||||||
Streams(
|
mapOf(), mapOf(), mapOf(), mapOf()
|
||||||
mapOf(), mapOf(), mapOf(), mapOf(), mapOf(), mapOf(),
|
))
|
||||||
mapOf(), mapOf(), mapOf(), mapOf(), mapOf(), mapOf(),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -404,6 +428,7 @@ data class Profile(
|
||||||
@SerialName("avatar") val avatar: String,
|
@SerialName("avatar") val avatar: String,
|
||||||
@SerialName("email") val email: String,
|
@SerialName("email") val email: String,
|
||||||
@SerialName("maturity_rating") val maturityRating: String,
|
@SerialName("maturity_rating") val maturityRating: String,
|
||||||
|
@SerialName("preferred_content_audio_language") val preferredContentAudioLanguage: String,
|
||||||
@SerialName("preferred_content_subtitle_language") val preferredContentSubtitleLanguage: String,
|
@SerialName("preferred_content_subtitle_language") val preferredContentSubtitleLanguage: String,
|
||||||
@SerialName("username") val username: String,
|
@SerialName("username") val username: String,
|
||||||
)
|
)
|
||||||
|
@ -411,6 +436,7 @@ val NoneProfile = Profile(
|
||||||
avatar = "",
|
avatar = "",
|
||||||
email = "",
|
email = "",
|
||||||
maturityRating = "",
|
maturityRating = "",
|
||||||
|
preferredContentAudioLanguage = "",
|
||||||
preferredContentSubtitleLanguage = "",
|
preferredContentSubtitleLanguage = "",
|
||||||
username = ""
|
username = ""
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,7 +8,9 @@ import java.util.*
|
||||||
|
|
||||||
object Preferences {
|
object Preferences {
|
||||||
|
|
||||||
var preferredLocale: Locale = Locale.forLanguageTag("en-US") // TODO this should be saved (potential offline usage) but fetched on start
|
var preferredAudioLocale: Locale = Locale.forLanguageTag("en-US")
|
||||||
|
internal set
|
||||||
|
var preferredSubtitleLocale: Locale = Locale.forLanguageTag("en-US")
|
||||||
internal set
|
internal set
|
||||||
var preferSubbed = false
|
var preferSubbed = false
|
||||||
internal set
|
internal set
|
||||||
|
@ -30,13 +32,22 @@ object Preferences {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun savePreferredLocal(context: Context, preferredLocale: Locale) {
|
fun savePreferredAudioLocal(context: Context, preferredLocale: Locale) {
|
||||||
with(getSharedPref(context).edit()) {
|
with(getSharedPref(context).edit()) {
|
||||||
putString(context.getString(R.string.save_key_preferred_local), preferredLocale.toLanguageTag())
|
putString(context.getString(R.string.save_key_preferred_local), preferredLocale.toLanguageTag())
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.preferredLocale = preferredLocale
|
this.preferredAudioLocale = preferredLocale
|
||||||
|
}
|
||||||
|
|
||||||
|
fun savePreferredSubtitleLocal(context: Context, preferredLocale: Locale) {
|
||||||
|
with(getSharedPref(context).edit()) {
|
||||||
|
putString(context.getString(R.string.save_key_preferred_local), preferredLocale.toLanguageTag())
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
this.preferredSubtitleLocale = preferredLocale
|
||||||
}
|
}
|
||||||
|
|
||||||
fun savePreferSecondary(context: Context, preferSubbed: Boolean) {
|
fun savePreferSecondary(context: Context, preferSubbed: Boolean) {
|
||||||
|
@ -90,7 +101,12 @@ object Preferences {
|
||||||
fun load(context: Context) {
|
fun load(context: Context) {
|
||||||
val sharedPref = getSharedPref(context)
|
val sharedPref = getSharedPref(context)
|
||||||
|
|
||||||
preferredLocale = Locale.forLanguageTag(
|
preferredAudioLocale = Locale.forLanguageTag(
|
||||||
|
sharedPref.getString(
|
||||||
|
context.getString(R.string.save_key_preferred_audio_local), "en-US"
|
||||||
|
) ?: "en-US"
|
||||||
|
)
|
||||||
|
preferredSubtitleLocale = Locale.forLanguageTag(
|
||||||
sharedPref.getString(
|
sharedPref.getString(
|
||||||
context.getString(R.string.save_key_preferred_local), "en-US"
|
context.getString(R.string.save_key_preferred_local), "en-US"
|
||||||
) ?: "en-US"
|
) ?: "en-US"
|
||||||
|
|
|
@ -40,10 +40,9 @@ import org.mosad.teapod.preferences.EncryptedPreferences
|
||||||
import org.mosad.teapod.preferences.Preferences
|
import org.mosad.teapod.preferences.Preferences
|
||||||
import org.mosad.teapod.ui.activity.main.fragments.AccountFragment
|
import org.mosad.teapod.ui.activity.main.fragments.AccountFragment
|
||||||
import org.mosad.teapod.ui.activity.main.fragments.HomeFragment
|
import org.mosad.teapod.ui.activity.main.fragments.HomeFragment
|
||||||
|
import org.mosad.teapod.ui.activity.main.fragments.MyListsFragment
|
||||||
import org.mosad.teapod.ui.activity.main.fragments.LibraryFragment
|
import org.mosad.teapod.ui.activity.main.fragments.LibraryFragment
|
||||||
import org.mosad.teapod.ui.activity.main.fragments.SearchFragment
|
|
||||||
import org.mosad.teapod.ui.activity.onboarding.OnboardingActivity
|
import org.mosad.teapod.ui.activity.onboarding.OnboardingActivity
|
||||||
import org.mosad.teapod.ui.activity.player.PlayerActivity
|
|
||||||
import org.mosad.teapod.util.DataTypes
|
import org.mosad.teapod.util.DataTypes
|
||||||
import org.mosad.teapod.util.metadb.MetaDBController
|
import org.mosad.teapod.util.metadb.MetaDBController
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -101,12 +100,12 @@ class MainActivity : AppCompatActivity(), NavigationBarView.OnItemSelectedListen
|
||||||
activeBaseFragment = HomeFragment()
|
activeBaseFragment = HomeFragment()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.navigation_library -> {
|
R.id.navigation_my_lists -> {
|
||||||
activeBaseFragment = LibraryFragment()
|
activeBaseFragment = MyListsFragment()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.navigation_search -> {
|
R.id.navigation_library -> {
|
||||||
activeBaseFragment = SearchFragment()
|
activeBaseFragment = LibraryFragment()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.navigation_account -> {
|
R.id.navigation_account -> {
|
||||||
|
@ -170,9 +169,12 @@ class MainActivity : AppCompatActivity(), NavigationBarView.OnItemSelectedListen
|
||||||
scope.launch { Crunchyroll.account() },
|
scope.launch { Crunchyroll.account() },
|
||||||
scope.launch {
|
scope.launch {
|
||||||
// update the local preferred content language, since it may have changed
|
// update the local preferred content language, since it may have changed
|
||||||
val locale = Locale.forLanguageTag(Crunchyroll.profile().preferredContentSubtitleLanguage)
|
val profile = Crunchyroll.profile()
|
||||||
Preferences.savePreferredLocal(this@MainActivity, locale)
|
|
||||||
|
|
||||||
|
val audioLocale = Locale.forLanguageTag(profile.preferredContentAudioLanguage)
|
||||||
|
val subtitleLocale = Locale.forLanguageTag(profile.preferredContentSubtitleLanguage)
|
||||||
|
Preferences.savePreferredAudioLocal(this@MainActivity, audioLocale)
|
||||||
|
Preferences.savePreferredSubtitleLocal(this@MainActivity, subtitleLocale)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -190,17 +192,6 @@ class MainActivity : AppCompatActivity(), NavigationBarView.OnItemSelectedListen
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* start the player as new activity
|
|
||||||
*/
|
|
||||||
fun startPlayer(seasonId: String, episodeId: String) {
|
|
||||||
val intent = Intent(this, PlayerActivity::class.java).apply {
|
|
||||||
putExtra(getString(R.string.intent_season_id), seasonId)
|
|
||||||
putExtra(getString(R.string.intent_episode_id), episodeId)
|
|
||||||
}
|
|
||||||
startActivity(intent)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* use custom restart instead of recreate(), since it has animations
|
* use custom restart instead of recreate(), since it has animations
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -168,7 +168,7 @@ class AccountFragment : Fragment() {
|
||||||
|
|
||||||
}.invokeOnCompletion {
|
}.invokeOnCompletion {
|
||||||
// update the local preferred content language
|
// update the local preferred content language
|
||||||
Preferences.savePreferredLocal(requireContext(), preferredLocale)
|
Preferences.savePreferredSubtitleLocal(requireContext(), preferredLocale)
|
||||||
|
|
||||||
// update profile since the language selection might have changed
|
// update profile since the language selection might have changed
|
||||||
profile = lifecycleScope.async { Crunchyroll.profile() }
|
profile = lifecycleScope.async { Crunchyroll.profile() }
|
||||||
|
|
|
@ -27,6 +27,8 @@ import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.core.view.children
|
import androidx.core.view.children
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
@ -42,10 +44,9 @@ import org.mosad.teapod.databinding.FragmentHomeBinding
|
||||||
import org.mosad.teapod.ui.activity.main.viewmodel.HomeViewModel
|
import org.mosad.teapod.ui.activity.main.viewmodel.HomeViewModel
|
||||||
import org.mosad.teapod.util.adapter.MediaEpisodeListAdapter
|
import org.mosad.teapod.util.adapter.MediaEpisodeListAdapter
|
||||||
import org.mosad.teapod.util.adapter.MediaItemListAdapter
|
import org.mosad.teapod.util.adapter.MediaItemListAdapter
|
||||||
import org.mosad.teapod.util.decoration.MediaItemDecoration
|
import org.mosad.teapod.util.playerIntent
|
||||||
import org.mosad.teapod.util.setDrawableTop
|
import org.mosad.teapod.util.setDrawableTop
|
||||||
import org.mosad.teapod.util.showFragment
|
import org.mosad.teapod.util.showFragment
|
||||||
import org.mosad.teapod.util.startPlayer
|
|
||||||
import org.mosad.teapod.util.toItemMediaList
|
import org.mosad.teapod.util.toItemMediaList
|
||||||
|
|
||||||
class HomeFragment : Fragment() {
|
class HomeFragment : Fragment() {
|
||||||
|
@ -54,6 +55,12 @@ class HomeFragment : Fragment() {
|
||||||
private val model: HomeViewModel by viewModels()
|
private val model: HomeViewModel by viewModels()
|
||||||
private lateinit var binding: FragmentHomeBinding
|
private lateinit var binding: FragmentHomeBinding
|
||||||
|
|
||||||
|
private val itemOffset = 21
|
||||||
|
|
||||||
|
private val playerResult = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||||
|
model.updateUpNextItems()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
binding = FragmentHomeBinding.inflate(inflater, container, false)
|
binding = FragmentHomeBinding.inflate(inflater, container, false)
|
||||||
return binding.root
|
return binding.root
|
||||||
|
@ -62,40 +69,39 @@ class HomeFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
binding.recyclerUpNext.addItemDecoration(MediaItemDecoration(9))
|
|
||||||
binding.recyclerWatchlist.addItemDecoration(MediaItemDecoration(9))
|
|
||||||
binding.recyclerRecommendations.addItemDecoration(MediaItemDecoration(9))
|
|
||||||
binding.recyclerNewTitles.addItemDecoration(MediaItemDecoration(9))
|
|
||||||
binding.recyclerTopTen.addItemDecoration(MediaItemDecoration(9))
|
|
||||||
|
|
||||||
binding.recyclerUpNext.adapter = MediaEpisodeListAdapter(
|
binding.recyclerUpNext.adapter = MediaEpisodeListAdapter(
|
||||||
MediaEpisodeListAdapter.OnClickListener {
|
MediaEpisodeListAdapter.OnClickListener {
|
||||||
activity?.startPlayer(it.panel.episodeMetadata.seasonId, it.panel.id)
|
playerResult.launch(playerIntent(it.panel.episodeMetadata.seasonId, it.panel.id))
|
||||||
}
|
},
|
||||||
|
itemOffset
|
||||||
)
|
)
|
||||||
|
|
||||||
binding.recyclerWatchlist.adapter = MediaItemListAdapter(
|
binding.recyclerWatchlist.adapter = MediaItemListAdapter(
|
||||||
MediaItemListAdapter.OnClickListener {
|
MediaItemListAdapter.OnClickListener {
|
||||||
activity?.showFragment(MediaFragment(it.id))
|
activity?.showFragment(MediaFragment(it.id))
|
||||||
}
|
},
|
||||||
|
itemOffset
|
||||||
)
|
)
|
||||||
|
|
||||||
binding.recyclerRecommendations.adapter = MediaItemListAdapter(
|
binding.recyclerRecommendations.adapter = MediaItemListAdapter(
|
||||||
MediaItemListAdapter.OnClickListener {
|
MediaItemListAdapter.OnClickListener {
|
||||||
activity?.showFragment(MediaFragment(it.id))
|
activity?.showFragment(MediaFragment(it.id))
|
||||||
}
|
},
|
||||||
|
itemOffset
|
||||||
)
|
)
|
||||||
|
|
||||||
binding.recyclerNewTitles.adapter = MediaItemListAdapter(
|
binding.recyclerNewTitles.adapter = MediaItemListAdapter(
|
||||||
MediaItemListAdapter.OnClickListener {
|
MediaItemListAdapter.OnClickListener {
|
||||||
activity?.showFragment(MediaFragment(it.id))
|
activity?.showFragment(MediaFragment(it.id))
|
||||||
}
|
},
|
||||||
|
itemOffset
|
||||||
)
|
)
|
||||||
|
|
||||||
binding.recyclerTopTen.adapter = MediaItemListAdapter(
|
binding.recyclerTopTen.adapter = MediaItemListAdapter(
|
||||||
MediaItemListAdapter.OnClickListener {
|
MediaItemListAdapter.OnClickListener {
|
||||||
activity?.showFragment(MediaFragment(it.id))
|
activity?.showFragment(MediaFragment(it.id))
|
||||||
}
|
},
|
||||||
|
itemOffset
|
||||||
)
|
)
|
||||||
|
|
||||||
binding.textHighlightMyList.setOnClickListener {
|
binding.textHighlightMyList.setOnClickListener {
|
||||||
|
@ -106,6 +112,13 @@ class HomeFragment : Fragment() {
|
||||||
// TODO since this might take a few seconds show a loading animation for the watchlist button
|
// TODO since this might take a few seconds show a loading animation for the watchlist button
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the shimmer items size as it's depending on the screen size
|
||||||
|
setShimmerLayoutItemSize(binding.shimmerLayoutUpNext)
|
||||||
|
setShimmerLayoutItemSize(binding.shimmerLayoutWatchlist)
|
||||||
|
setShimmerLayoutItemSize(binding.shimmerLayoutRecommendations)
|
||||||
|
setShimmerLayoutItemSize(binding.shimmerLayoutNewTitles)
|
||||||
|
setShimmerLayoutItemSize(binding.shimmerLayoutTopTen)
|
||||||
|
|
||||||
viewLifecycleOwner.lifecycleScope.launch {
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||||
model.onUiState(viewLifecycleOwner.lifecycleScope) { uiState ->
|
model.onUiState(viewLifecycleOwner.lifecycleScope) { uiState ->
|
||||||
|
@ -154,7 +167,7 @@ class HomeFragment : Fragment() {
|
||||||
|
|
||||||
binding.buttonPlayHighlight.setOnClickListener {
|
binding.buttonPlayHighlight.setOnClickListener {
|
||||||
val panel = uiState.highlightItemUpNext.panel
|
val panel = uiState.highlightItemUpNext.panel
|
||||||
activity?.startPlayer(panel.episodeMetadata.seasonId, panel.id)
|
playerResult.launch(playerIntent(panel.episodeMetadata.seasonId, panel.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable the shimmer effect
|
// disable the shimmer effect
|
||||||
|
@ -167,10 +180,19 @@ class HomeFragment : Fragment() {
|
||||||
private fun bindUiStateLoading() {
|
private fun bindUiStateLoading() {
|
||||||
// hide highlights layout
|
// hide highlights layout
|
||||||
binding.linearHighlight.isVisible = false
|
binding.linearHighlight.isVisible = false
|
||||||
println(binding.root.childCount)
|
|
||||||
binding.root.children.filter { it is ShimmerFrameLayout }.forEach {
|
binding.shimmerLayoutUpNext.startShimmer()
|
||||||
it as ShimmerFrameLayout
|
binding.shimmerLayoutWatchlist.startShimmer()
|
||||||
it.startShimmer()
|
binding.shimmerLayoutRecommendations.startShimmer()
|
||||||
|
binding.shimmerLayoutNewTitles.startShimmer()
|
||||||
|
binding.shimmerLayoutTopTen.startShimmer()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setShimmerLayoutItemSize(shimmerLayout: ShimmerFrameLayout) {
|
||||||
|
(shimmerLayout.children.first() as? LinearLayout)?.children?.forEach { child ->
|
||||||
|
child.layoutParams.apply {
|
||||||
|
width = (resources.displayMetrics.widthPixels / requireContext().resources.getInteger(R.integer.item_media_columns)) - itemOffset
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,29 +1,30 @@
|
||||||
package org.mosad.teapod.ui.activity.main.fragments
|
package org.mosad.teapod.ui.activity.main.fragments
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.viewModels
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.mosad.teapod.databinding.FragmentLibraryBinding
|
import org.mosad.teapod.databinding.FragmentLibraryBinding
|
||||||
import org.mosad.teapod.parser.crunchyroll.Crunchyroll
|
import org.mosad.teapod.ui.activity.main.viewmodel.LibraryFragmentViewModel
|
||||||
import org.mosad.teapod.util.ItemMedia
|
import org.mosad.teapod.util.adapter.MediaItemListAdapter
|
||||||
import org.mosad.teapod.util.adapter.MediaItemAdapter
|
|
||||||
import org.mosad.teapod.util.decoration.MediaItemDecoration
|
|
||||||
import org.mosad.teapod.util.showFragment
|
import org.mosad.teapod.util.showFragment
|
||||||
|
|
||||||
class LibraryFragment : Fragment() {
|
class LibraryFragment : Fragment() {
|
||||||
|
|
||||||
private lateinit var binding: FragmentLibraryBinding
|
private lateinit var binding: FragmentLibraryBinding
|
||||||
private lateinit var adapter: MediaItemAdapter
|
private lateinit var adapter: MediaItemListAdapter
|
||||||
|
private val model: LibraryFragmentViewModel by viewModels()
|
||||||
private val itemList = arrayListOf<ItemMedia>()
|
|
||||||
private val pageSize = 30
|
|
||||||
private var nextItemIndex = 0
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
binding = FragmentLibraryBinding.inflate(inflater, container, false)
|
binding = FragmentLibraryBinding.inflate(inflater, container, false)
|
||||||
|
@ -33,57 +34,79 @@ class LibraryFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
// init async
|
// TODO replace with pagination3
|
||||||
lifecycleScope.launch {
|
// https://medium.com/swlh/paging3-recyclerview-pagination-made-easy-333c7dfa8797
|
||||||
// create and set the adapter, needs context
|
binding.recyclerMediaSearch.addOnScrollListener(PaginationScrollListener())
|
||||||
context?.let {
|
|
||||||
val initialResults = Crunchyroll.browse(n = pageSize)
|
|
||||||
itemList.addAll(initialResults.items.map { item ->
|
|
||||||
ItemMedia(item.id, item.title, item.images.poster_wide[0][0].source)
|
|
||||||
})
|
|
||||||
nextItemIndex += pageSize
|
|
||||||
|
|
||||||
adapter = MediaItemAdapter(itemList)
|
adapter = MediaItemListAdapter(MediaItemListAdapter.OnClickListener {
|
||||||
adapter.onItemClick = { mediaIdStr, _ ->
|
binding.searchText.clearFocus()
|
||||||
activity?.showFragment(MediaFragment(mediaIdStr))
|
activity?.showFragment(MediaFragment(it.id))
|
||||||
}
|
})
|
||||||
|
binding.recyclerMediaSearch.adapter = adapter
|
||||||
|
|
||||||
binding.recyclerMediaLibrary.adapter = adapter
|
binding.searchText.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||||
binding.recyclerMediaLibrary.addItemDecoration(MediaItemDecoration(9))
|
override fun onQueryTextSubmit(query: String?): Boolean {
|
||||||
// TODO replace with pagination3
|
query?.let { model.search(it) }
|
||||||
// https://medium.com/swlh/paging3-recyclerview-pagination-made-easy-333c7dfa8797
|
return false // return false to dismiss the keyboard
|
||||||
binding.recyclerMediaLibrary.addOnScrollListener(PaginationScrollListener())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
override fun onQueryTextChange(newText: String?): Boolean {
|
||||||
}
|
newText?.let { model.search(it) }
|
||||||
|
return false // return false to dismiss the keyboard
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
inner class PaginationScrollListener: RecyclerView.OnScrollListener() {
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
private var isLoading = false
|
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||||
|
model.onUiState(viewLifecycleOwner.lifecycleScope) { uiState ->
|
||||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
when (uiState) {
|
||||||
super.onScrolled(recyclerView, dx, dy)
|
is LibraryFragmentViewModel.UiState.Browse -> bindUiStateBrowse(uiState)
|
||||||
val layoutManager = recyclerView.layoutManager as GridLayoutManager?
|
is LibraryFragmentViewModel.UiState.Search -> bindUiStateSearch(uiState)
|
||||||
|
is LibraryFragmentViewModel.UiState.Loading -> bindUiStateLoading()
|
||||||
if (!isLoading) layoutManager?.let {
|
is LibraryFragmentViewModel.UiState.Error -> bindUiStateError(uiState)
|
||||||
// itemList.size - 5 to start loading a bit earlier than the actual end
|
|
||||||
if (layoutManager.findLastCompletelyVisibleItemPosition() >= (itemList.size - 5)) {
|
|
||||||
// load new browse results async
|
|
||||||
isLoading = true
|
|
||||||
lifecycleScope.launch {
|
|
||||||
val firstNewItemIndex = itemList.lastIndex + 1
|
|
||||||
val results = Crunchyroll.browse(start = nextItemIndex, n = pageSize)
|
|
||||||
itemList.addAll(results.items.map { item ->
|
|
||||||
ItemMedia(item.id, item.title, item.images.poster_wide[0][0].source)
|
|
||||||
})
|
|
||||||
nextItemIndex += pageSize
|
|
||||||
|
|
||||||
adapter.notifyItemRangeInserted(firstNewItemIndex, pageSize)
|
|
||||||
isLoading = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
private fun bindUiStateBrowse(uiState: LibraryFragmentViewModel.UiState.Browse) {
|
||||||
|
adapter.submitList(uiState.itemList)
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
private fun bindUiStateSearch(uiState: LibraryFragmentViewModel.UiState.Search) {
|
||||||
|
adapter.submitList(uiState.itemList)
|
||||||
|
adapter.notifyDataSetChanged() // this is needed, else the adapter will not update
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun bindUiStateLoading() {
|
||||||
|
// currently not used
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun bindUiStateError(uiState: LibraryFragmentViewModel.UiState.Error) {
|
||||||
|
// currently not used
|
||||||
|
Log.e(javaClass.name, "A error occurred while loading a UiState: ${uiState.message}")
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class PaginationScrollListener: RecyclerView.OnScrollListener() {
|
||||||
|
|
||||||
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
|
super.onScrolled(recyclerView, dx, dy)
|
||||||
|
|
||||||
|
if (!model.isLazyLoading) {
|
||||||
|
val layoutManager = recyclerView.layoutManager as? GridLayoutManager
|
||||||
|
layoutManager?.let {
|
||||||
|
// adapter.itemCount - 10 to start loading a bit earlier than the actual end
|
||||||
|
if (layoutManager.findLastCompletelyVisibleItemPosition() >= (adapter.itemCount - 10)) {
|
||||||
|
model.onLazyLoad().invokeOnCompletion {
|
||||||
|
adapter.notifyItemRangeInserted(adapter.itemCount, model.PAGESIZE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
@ -19,12 +20,13 @@ import jp.wasabeef.glide.transformations.BlurTransformation
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.mosad.teapod.R
|
import org.mosad.teapod.R
|
||||||
import org.mosad.teapod.databinding.FragmentMediaBinding
|
import org.mosad.teapod.databinding.FragmentMediaBinding
|
||||||
import org.mosad.teapod.parser.crunchyroll.NoneUpNextSeriesItem
|
import org.mosad.teapod.parser.crunchyroll.NoneUpNextSeriesList
|
||||||
import org.mosad.teapod.ui.activity.main.MainActivity
|
|
||||||
import org.mosad.teapod.ui.activity.main.viewmodel.MediaFragmentViewModel
|
import org.mosad.teapod.ui.activity.main.viewmodel.MediaFragmentViewModel
|
||||||
|
import org.mosad.teapod.util.playerIntent
|
||||||
import org.mosad.teapod.util.tmdb.TMDBApiController
|
import org.mosad.teapod.util.tmdb.TMDBApiController
|
||||||
import org.mosad.teapod.util.tmdb.TMDBMovie
|
import org.mosad.teapod.util.tmdb.TMDBMovie
|
||||||
import org.mosad.teapod.util.tmdb.TMDBTVShow
|
import org.mosad.teapod.util.tmdb.TMDBTVShow
|
||||||
|
import org.mosad.teapod.util.toItemMediaList
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The media detail fragment.
|
* The media detail fragment.
|
||||||
|
@ -40,7 +42,10 @@ class MediaFragment(private val mediaIdStr: String) : Fragment() {
|
||||||
|
|
||||||
private val fragments = arrayListOf<Fragment>()
|
private val fragments = arrayListOf<Fragment>()
|
||||||
private var watchlistJobRunning = false
|
private var watchlistJobRunning = false
|
||||||
private var runOnResume = false
|
|
||||||
|
private val playerResult = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||||
|
playerFinishedCallback()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
|
@ -74,33 +79,6 @@ class MediaFragment(private val mediaIdStr: String) : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
|
|
||||||
if (runOnResume) {
|
|
||||||
/**
|
|
||||||
* FIXME
|
|
||||||
* this is currently also run on back press when multiple MediaFragments have
|
|
||||||
* been open and closed via similar tab
|
|
||||||
*/
|
|
||||||
|
|
||||||
lifecycleScope.launch {
|
|
||||||
model.updateOnResume()
|
|
||||||
|
|
||||||
if (model.upNextSeries != NoneUpNextSeriesItem) {
|
|
||||||
binding.textTitle.text = model.upNextSeries.panel.title
|
|
||||||
}
|
|
||||||
|
|
||||||
// needs to be called after model.updateOnResume()
|
|
||||||
if (fragments.elementAtOrNull(0) is MediaFragmentEpisodes) {
|
|
||||||
(fragments[0] as MediaFragmentEpisodes).updateWatchedState()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
runOnResume = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if tmdb data is present, use it, else use the aod data
|
* if tmdb data is present, use it, else use the aod data
|
||||||
*/
|
*/
|
||||||
|
@ -120,14 +98,14 @@ class MediaFragment(private val mediaIdStr: String) : Fragment() {
|
||||||
.into(binding.imageBackdrop)
|
.into(binding.imageBackdrop)
|
||||||
|
|
||||||
binding.textYear.text = when(tmdbResult) {
|
binding.textYear.text = when(tmdbResult) {
|
||||||
is TMDBTVShow -> (tmdbResult as TMDBTVShow).firstAirDate.substring(0, 4)
|
is TMDBTVShow -> (tmdbResult as TMDBTVShow).firstAirDate?.substring(0, 4)
|
||||||
is TMDBMovie -> (tmdbResult as TMDBMovie).releaseDate.substring(0, 4)
|
is TMDBMovie -> (tmdbResult as TMDBMovie).releaseDate.substring(0, 4)
|
||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
binding.textAge.text = seriesCrunchy.maturityRatings.firstOrNull()
|
binding.textAge.text = seriesCrunchy.maturityRatings.firstOrNull()
|
||||||
|
|
||||||
binding.textTitle.text = if (upNextSeries != NoneUpNextSeriesItem) {
|
binding.textTitle.text = if (upNextSeries != NoneUpNextSeriesList) {
|
||||||
upNextSeries.panel.title
|
upNextSeries.data.first().panel.title
|
||||||
} else seriesCrunchy.title
|
} else seriesCrunchy.title
|
||||||
binding.textOverview.text = seriesCrunchy.description
|
binding.textOverview.text = seriesCrunchy.description
|
||||||
|
|
||||||
|
@ -149,6 +127,20 @@ class MediaFragment(private val mediaIdStr: String) : Fragment() {
|
||||||
pagerAdapter.notifyItemInserted(fragments.indexOf(it))
|
pagerAdapter.notifyItemInserted(fragments.indexOf(it))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if has similar titles
|
||||||
|
if (model.similarTo.total > 0) {
|
||||||
|
MediaFragmentSimilar(model.similarTo.toItemMediaList()).also {
|
||||||
|
fragments.add(it)
|
||||||
|
pagerAdapter.notifyItemInserted(fragments.indexOf(it))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// disable scrolling on appbar, if no tabs where added
|
||||||
|
if(fragments.isEmpty()) {
|
||||||
|
val params = binding.linearMedia.layoutParams as AppBarLayout.LayoutParams
|
||||||
|
params.scrollFlags = 0 // clear all scroll flags
|
||||||
|
}
|
||||||
|
|
||||||
// specific gui (via tmdb)
|
// specific gui (via tmdb)
|
||||||
when (tmdbResult) {
|
when (tmdbResult) {
|
||||||
is TMDBTVShow -> {
|
is TMDBTVShow -> {
|
||||||
|
@ -177,27 +169,14 @@ class MediaFragment(private val mediaIdStr: String) : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if has similar titles
|
|
||||||
if (model.similarTo.total > 0) {
|
|
||||||
MediaFragmentSimilar().also {
|
|
||||||
fragments.add(it)
|
|
||||||
pagerAdapter.notifyItemInserted(fragments.indexOf(it))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// disable scrolling on appbar, if no tabs where added
|
|
||||||
if(fragments.isEmpty()) {
|
|
||||||
val params = binding.linearMedia.layoutParams as AppBarLayout.LayoutParams
|
|
||||||
params.scrollFlags = 0 // clear all scroll flags
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.frameLoading.visibility = View.GONE // hide loading indicator
|
binding.frameLoading.visibility = View.GONE // hide loading indicator
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initActions() = with(model) {
|
private fun initActions() = with(model) {
|
||||||
binding.buttonPlay.setOnClickListener {
|
binding.buttonPlay.setOnClickListener {
|
||||||
if (upNextSeries != NoneUpNextSeriesItem) {
|
if (upNextSeries != NoneUpNextSeriesList) {
|
||||||
playEpisode(upNextSeries.panel.episodeMetadata.seasonId, upNextSeries.panel.id)
|
val panel = upNextSeries.data.first().panel
|
||||||
|
playEpisode(panel.episodeMetadata.seasonId, panel.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,15 +197,25 @@ class MediaFragment(private val mediaIdStr: String) : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private fun playerFinishedCallback() = lifecycleScope.launch {
|
||||||
* play the current episode
|
model.updateOnResume()
|
||||||
* TODO this is also used in MediaFragmentEpisode, we should only have on implementation
|
|
||||||
*/
|
|
||||||
private fun playEpisode(seasonId: String, episodeId: String) {
|
|
||||||
(activity as MainActivity).startPlayer(seasonId, episodeId)
|
|
||||||
Log.d(javaClass.name, "Started Player with episodeId: $episodeId")
|
|
||||||
|
|
||||||
//model.updateNextEpisode(episodeId) // set the correct next episode
|
if (model.upNextSeries != NoneUpNextSeriesList) {
|
||||||
|
binding.textTitle.text = model.upNextSeries.data.first().panel.title
|
||||||
|
}
|
||||||
|
|
||||||
|
// needs to be called after model.updateOnResume()
|
||||||
|
(fragments.elementAtOrNull(0) as? MediaFragmentEpisodes)?.updateWatchedState()
|
||||||
|
|
||||||
|
Log.d(javaClass.name, "Updated model and gui after player closed")
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* play a episode, also runs callback on player result return
|
||||||
|
*/
|
||||||
|
fun playEpisode(seasonId: String, episodeId: String) {
|
||||||
|
playerResult.launch(playerIntent(seasonId, episodeId))
|
||||||
|
Log.d(javaClass.name, "Started Player with episodeId: $episodeId")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.mosad.teapod.ui.activity.main.fragments
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -13,7 +12,6 @@ import androidx.lifecycle.lifecycleScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.mosad.teapod.R
|
import org.mosad.teapod.R
|
||||||
import org.mosad.teapod.databinding.FragmentMediaEpisodesBinding
|
import org.mosad.teapod.databinding.FragmentMediaEpisodesBinding
|
||||||
import org.mosad.teapod.ui.activity.main.MainActivity
|
|
||||||
import org.mosad.teapod.ui.activity.main.viewmodel.MediaFragmentViewModel
|
import org.mosad.teapod.ui.activity.main.viewmodel.MediaFragmentViewModel
|
||||||
import org.mosad.teapod.util.adapter.EpisodeItemAdapter
|
import org.mosad.teapod.util.adapter.EpisodeItemAdapter
|
||||||
|
|
||||||
|
@ -37,7 +35,7 @@ class MediaFragmentEpisodes : Fragment() {
|
||||||
model.tmdbTVSeason.episodes,
|
model.tmdbTVSeason.episodes,
|
||||||
model.currentPlayheads,
|
model.currentPlayheads,
|
||||||
EpisodeItemAdapter.OnClickListener { episode ->
|
EpisodeItemAdapter.OnClickListener { episode ->
|
||||||
playEpisode(episode.seasonId, episode.id)
|
(requireParentFragment() as? MediaFragment)?.playEpisode(episode.seasonId, episode.id)
|
||||||
},
|
},
|
||||||
EpisodeItemAdapter.ViewType.MEDIA_FRAGMENT
|
EpisodeItemAdapter.ViewType.MEDIA_FRAGMENT
|
||||||
)
|
)
|
||||||
|
@ -69,7 +67,7 @@ class MediaFragmentEpisodes : Fragment() {
|
||||||
private fun showSeasonSelection(v: View) {
|
private fun showSeasonSelection(v: View) {
|
||||||
// TODO replace with Exposed dropdown menu: https://material.io/components/menus/android#exposed-dropdown-menus
|
// TODO replace with Exposed dropdown menu: https://material.io/components/menus/android#exposed-dropdown-menus
|
||||||
val popup = PopupMenu(requireContext(), v)
|
val popup = PopupMenu(requireContext(), v)
|
||||||
model.seasonsCrunchy.items.forEach { season ->
|
model.seasonsCrunchy.data.forEach { season ->
|
||||||
popup.menu.add(getString(
|
popup.menu.add(getString(
|
||||||
R.string.season_number_title,
|
R.string.season_number_title,
|
||||||
season.seasonNumber,
|
season.seasonNumber,
|
||||||
|
@ -106,11 +104,4 @@ class MediaFragmentEpisodes : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun playEpisode(seasonId: String, episodeId: String) {
|
|
||||||
(activity as MainActivity).startPlayer(seasonId, episodeId)
|
|
||||||
Log.d(javaClass.name, "Started Player with episodeId: $episodeId")
|
|
||||||
|
|
||||||
//model.updateNextEpisode(episodeId) // set the correct next episode
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -27,17 +27,13 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.viewModels
|
|
||||||
import org.mosad.teapod.databinding.FragmentMediaSimilarBinding
|
import org.mosad.teapod.databinding.FragmentMediaSimilarBinding
|
||||||
import org.mosad.teapod.ui.activity.main.viewmodel.MediaFragmentViewModel
|
import org.mosad.teapod.util.ItemMedia
|
||||||
import org.mosad.teapod.util.adapter.MediaItemListAdapter
|
import org.mosad.teapod.util.adapter.MediaItemListAdapter
|
||||||
import org.mosad.teapod.util.decoration.MediaItemDecoration
|
|
||||||
import org.mosad.teapod.util.showFragment
|
import org.mosad.teapod.util.showFragment
|
||||||
import org.mosad.teapod.util.toItemMediaList
|
|
||||||
|
|
||||||
class MediaFragmentSimilar : Fragment() {
|
class MediaFragmentSimilar(val items: List<ItemMedia>) : Fragment() {
|
||||||
|
|
||||||
private val model: MediaFragmentViewModel by viewModels({requireParentFragment()})
|
|
||||||
private lateinit var binding: FragmentMediaSimilarBinding
|
private lateinit var binding: FragmentMediaSimilarBinding
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
|
@ -48,7 +44,6 @@ class MediaFragmentSimilar : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
binding.recyclerMediaSimilar.addItemDecoration(MediaItemDecoration(9))
|
|
||||||
binding.recyclerMediaSimilar.adapter = MediaItemListAdapter(
|
binding.recyclerMediaSimilar.adapter = MediaItemListAdapter(
|
||||||
MediaItemListAdapter.OnClickListener {
|
MediaItemListAdapter.OnClickListener {
|
||||||
activity?.showFragment(MediaFragment(it.id))
|
activity?.showFragment(MediaFragment(it.id))
|
||||||
|
@ -56,6 +51,6 @@ class MediaFragmentSimilar : Fragment() {
|
||||||
)
|
)
|
||||||
|
|
||||||
val adapterSimilar = binding.recyclerMediaSimilar.adapter as MediaItemListAdapter
|
val adapterSimilar = binding.recyclerMediaSimilar.adapter as MediaItemListAdapter
|
||||||
adapterSimilar.submitList(model.similarTo.toItemMediaList())
|
adapterSimilar.submitList(items)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package org.mosad.teapod.ui.activity.main.fragments
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||||
|
import com.google.android.material.tabs.TabLayoutMediator
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import org.mosad.teapod.R
|
||||||
|
import org.mosad.teapod.databinding.FragmentMyListsBinding
|
||||||
|
import org.mosad.teapod.parser.crunchyroll.Crunchyroll
|
||||||
|
import org.mosad.teapod.util.toItemMediaList
|
||||||
|
|
||||||
|
class MyListsFragment : Fragment() {
|
||||||
|
|
||||||
|
private lateinit var binding: FragmentMyListsBinding
|
||||||
|
private lateinit var pagerAdapter: FragmentStateAdapter
|
||||||
|
|
||||||
|
private val fragments = arrayListOf<Fragment>()
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
|
binding = FragmentMyListsBinding.inflate(inflater, container, false)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
// tab layout and pager
|
||||||
|
pagerAdapter = ScreenSlidePagerAdapter(this)
|
||||||
|
binding.pagerMyLists.adapter = pagerAdapter
|
||||||
|
|
||||||
|
// TODO is position 0 always episodes? (and 1 always similar titles)
|
||||||
|
TabLayoutMediator(binding.tabMyLists, binding.pagerMyLists) { tab, position ->
|
||||||
|
tab.text = when(position) {
|
||||||
|
0 -> getString(R.string.my_list)
|
||||||
|
1 -> getString(R.string.crunchylists)
|
||||||
|
2 -> getString(R.string.downloads)
|
||||||
|
else -> ""
|
||||||
|
}
|
||||||
|
}.attach()
|
||||||
|
|
||||||
|
lifecycleScope.launch {
|
||||||
|
val items = Crunchyroll.watchlist(50)
|
||||||
|
|
||||||
|
MediaFragmentSimilar(items.toItemMediaList()).also {
|
||||||
|
fragments.add(it)
|
||||||
|
pagerAdapter.notifyItemInserted(fragments.indexOf(it))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple pager adapter
|
||||||
|
* TODO also present in MediaFragment
|
||||||
|
*/
|
||||||
|
private inner class ScreenSlidePagerAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
|
||||||
|
override fun getItemCount(): Int = fragments.size
|
||||||
|
|
||||||
|
override fun createFragment(position: Int): Fragment = fragments[position]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,118 +0,0 @@
|
||||||
package org.mosad.teapod.ui.activity.main.fragments
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.SearchView
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import kotlinx.coroutines.Job
|
|
||||||
import kotlinx.coroutines.async
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import org.mosad.teapod.databinding.FragmentSearchBinding
|
|
||||||
import org.mosad.teapod.parser.crunchyroll.Crunchyroll
|
|
||||||
import org.mosad.teapod.util.ItemMedia
|
|
||||||
import org.mosad.teapod.util.adapter.MediaItemAdapter
|
|
||||||
import org.mosad.teapod.util.decoration.MediaItemDecoration
|
|
||||||
import org.mosad.teapod.util.showFragment
|
|
||||||
|
|
||||||
class SearchFragment : Fragment() {
|
|
||||||
|
|
||||||
private lateinit var binding: FragmentSearchBinding
|
|
||||||
private lateinit var adapter: MediaItemAdapter
|
|
||||||
|
|
||||||
private val itemList = arrayListOf<ItemMedia>()
|
|
||||||
private var searchJob: Job? = null
|
|
||||||
private var oldSearchQuery = ""
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
|
||||||
binding = FragmentSearchBinding.inflate(inflater, container, false)
|
|
||||||
return binding.root
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
lifecycleScope.launch {
|
|
||||||
// create and set the adapter, needs context
|
|
||||||
context?.let {
|
|
||||||
adapter = MediaItemAdapter(itemList)
|
|
||||||
adapter.onItemClick = { mediaIdStr, _ ->
|
|
||||||
binding.searchText.clearFocus()
|
|
||||||
activity?.showFragment(MediaFragment(mediaIdStr))
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.recyclerMediaSearch.adapter = adapter
|
|
||||||
binding.recyclerMediaSearch.addItemDecoration(MediaItemDecoration(9))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
initActions()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initActions() {
|
|
||||||
binding.searchText.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
|
||||||
override fun onQueryTextSubmit(query: String?): Boolean {
|
|
||||||
query?.let { search(it) }
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onQueryTextChange(newText: String?): Boolean {
|
|
||||||
newText?.let { search(it) }
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun search(query: String) {
|
|
||||||
// if the query hasn't changed since the last successful search, return
|
|
||||||
if (query == oldSearchQuery) return
|
|
||||||
|
|
||||||
// cancel search job if one is already running
|
|
||||||
if (searchJob?.isActive == true) searchJob?.cancel()
|
|
||||||
|
|
||||||
searchJob = lifecycleScope.async {
|
|
||||||
// TODO maybe wait a few ms (500ms?) before searching, if the user inputs any other chars
|
|
||||||
val results = Crunchyroll.search(query, 50)
|
|
||||||
|
|
||||||
itemList.clear() // TODO needs clean up
|
|
||||||
|
|
||||||
// TODO add top results first heading
|
|
||||||
itemList.addAll(results.items[0].items.map { item ->
|
|
||||||
ItemMedia(item.id, item.title, item.images.poster_wide[0][0].source)
|
|
||||||
})
|
|
||||||
|
|
||||||
// TODO currently only tv shows are supported, hence only the first items array
|
|
||||||
// should be always present
|
|
||||||
|
|
||||||
// // TODO add tv shows heading
|
|
||||||
// if (results.items.size >= 2) {
|
|
||||||
// itemList.addAll(results.items[1].items.map { item ->
|
|
||||||
// ItemMedia(item.id, item.title, item.images.poster_wide[0][0].source)
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // TODO add movies heading
|
|
||||||
// if (results.items.size >= 3) {
|
|
||||||
// itemList.addAll(results.items[2].items.map { item ->
|
|
||||||
// ItemMedia(item.id, item.title, item.images.poster_wide[0][0].source)
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // TODO add episodes heading
|
|
||||||
// if (results.items.size >= 4) {
|
|
||||||
// itemList.addAll(results.items[3].items.map { item ->
|
|
||||||
// ItemMedia(item.id, item.title, item.images.poster_wide[0][0].source)
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
adapter.notifyDataSetChanged()
|
|
||||||
//adapter.notifyItemRangeInserted(0, itemList.size)
|
|
||||||
|
|
||||||
// after successfully searching the query term, add it as old query, to make sure we
|
|
||||||
// don't search again if the query hasn't changed
|
|
||||||
oldSearchQuery = query
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,19 +26,22 @@ import androidx.lifecycle.LifecycleCoroutineScope
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import kotlinx.coroutines.flow.update
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.mosad.teapod.parser.crunchyroll.*
|
import org.mosad.teapod.parser.crunchyroll.*
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
class HomeViewModel : ViewModel() {
|
class HomeViewModel : ViewModel() {
|
||||||
|
|
||||||
|
private val WATCHLIST_LENGTH = 50
|
||||||
|
|
||||||
private val uiState = MutableStateFlow<UiState>(UiState.Loading)
|
private val uiState = MutableStateFlow<UiState>(UiState.Loading)
|
||||||
|
|
||||||
sealed class UiState {
|
sealed class UiState {
|
||||||
object Loading : UiState()
|
object Loading : UiState()
|
||||||
data class Normal(
|
data class Normal(
|
||||||
val upNextItems: List<ContinueWatchingItem>,
|
val upNextItems: List<UpNextAccountItem>,
|
||||||
val watchlistItems: List<Item>,
|
val watchlistItems: List<Item>,
|
||||||
val recommendationsItems: List<Item>,
|
val recommendationsItems: List<Item>,
|
||||||
val recentlyAddedItems: List<Item>,
|
val recentlyAddedItems: List<Item>,
|
||||||
|
@ -63,8 +66,8 @@ class HomeViewModel : ViewModel() {
|
||||||
uiState.emit(UiState.Loading)
|
uiState.emit(UiState.Loading)
|
||||||
try {
|
try {
|
||||||
// run the loading in parallel to speed up the process
|
// run the loading in parallel to speed up the process
|
||||||
val upNextJob = viewModelScope.async { Crunchyroll.upNextAccount().items }
|
val upNextJob = viewModelScope.async { Crunchyroll.upNextAccount().data }
|
||||||
val watchlistJob = viewModelScope.async { Crunchyroll.watchlist(50).items }
|
val watchlistJob = viewModelScope.async { Crunchyroll.watchlist(WATCHLIST_LENGTH).items }
|
||||||
val recommendationsJob = viewModelScope.async {
|
val recommendationsJob = viewModelScope.async {
|
||||||
Crunchyroll.recommendations(20).items
|
Crunchyroll.recommendations(20).items
|
||||||
}
|
}
|
||||||
|
@ -79,7 +82,7 @@ class HomeViewModel : ViewModel() {
|
||||||
// FIXME crashes on newTitles.items.size == 0
|
// FIXME crashes on newTitles.items.size == 0
|
||||||
val highlightItem = recentlyAddedItems[Random.nextInt(recentlyAddedItems.size)]
|
val highlightItem = recentlyAddedItems[Random.nextInt(recentlyAddedItems.size)]
|
||||||
val highlightItemUpNextJob = viewModelScope.async {
|
val highlightItemUpNextJob = viewModelScope.async {
|
||||||
Crunchyroll.upNextSeries(highlightItem.id)
|
Crunchyroll.upNextSeries(highlightItem.id).data.first()
|
||||||
}
|
}
|
||||||
val highlightItemIsWatchlistJob = viewModelScope.async {
|
val highlightItemIsWatchlistJob = viewModelScope.async {
|
||||||
Crunchyroll.isWatchlist(highlightItem.id)
|
Crunchyroll.isWatchlist(highlightItem.id)
|
||||||
|
@ -111,7 +114,7 @@ class HomeViewModel : ViewModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the watchlist after a item has been added/removed
|
// update the watchlist after a item has been added/removed
|
||||||
val watchlistItems = Crunchyroll.watchlist(50).items
|
val watchlistItems = Crunchyroll.watchlist(WATCHLIST_LENGTH).items
|
||||||
|
|
||||||
currentUiState.copy(
|
currentUiState.copy(
|
||||||
watchlistItems = watchlistItems,
|
watchlistItems = watchlistItems,
|
||||||
|
@ -123,4 +126,20 @@ class HomeViewModel : ViewModel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* Update the up next list. To be used on player result callbacks.
|
||||||
|
*/
|
||||||
|
fun updateUpNextItems() {
|
||||||
|
viewModelScope.launch {
|
||||||
|
uiState.update { currentUiState ->
|
||||||
|
if (currentUiState is UiState.Normal) {
|
||||||
|
val upNextItems = Crunchyroll.upNextAccount().data
|
||||||
|
currentUiState.copy(upNextItems = upNextItems)
|
||||||
|
} else {
|
||||||
|
currentUiState
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,131 @@
|
||||||
|
package org.mosad.teapod.ui.activity.main.viewmodel
|
||||||
|
|
||||||
|
import androidx.lifecycle.LifecycleCoroutineScope
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.async
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import kotlinx.coroutines.flow.update
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import org.mosad.teapod.parser.crunchyroll.Crunchyroll
|
||||||
|
import org.mosad.teapod.util.ItemMedia
|
||||||
|
import org.mosad.teapod.util.toItemMediaList
|
||||||
|
|
||||||
|
class LibraryFragmentViewModel : ViewModel() {
|
||||||
|
|
||||||
|
val PAGESIZE = 50
|
||||||
|
|
||||||
|
private val uiState = MutableStateFlow<UiState>(UiState.Loading)
|
||||||
|
private var oldSearchQuery = ""
|
||||||
|
private var searchJob: Job? = null
|
||||||
|
var isLazyLoading = false
|
||||||
|
internal set
|
||||||
|
|
||||||
|
sealed class UiState {
|
||||||
|
object Loading : UiState()
|
||||||
|
data class Browse(
|
||||||
|
val itemList: MutableList<ItemMedia>
|
||||||
|
) : UiState()
|
||||||
|
data class Search(
|
||||||
|
val itemList: List<ItemMedia>
|
||||||
|
) : UiState()
|
||||||
|
data class Error(val message: String?) : UiState()
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
load()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onUiState(scope: LifecycleCoroutineScope, collector: (UiState) -> Unit) {
|
||||||
|
scope.launch { uiState.collect { collector(it) } }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initially load the first n browsing items
|
||||||
|
*/
|
||||||
|
private fun load() {
|
||||||
|
viewModelScope.launch {
|
||||||
|
uiState.emit(UiState.Loading)
|
||||||
|
|
||||||
|
try {
|
||||||
|
initBrowse()
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
uiState.emit(UiState.Error(ex.message))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for a query string at Crunchyroll and emit the new ui state.
|
||||||
|
*/
|
||||||
|
fun search(query: String) {
|
||||||
|
// return if nothing has changed
|
||||||
|
if (query == oldSearchQuery) return
|
||||||
|
|
||||||
|
// update the old query since it has changed
|
||||||
|
oldSearchQuery = query
|
||||||
|
|
||||||
|
viewModelScope.launch {
|
||||||
|
|
||||||
|
// always cancel a running search job
|
||||||
|
if (searchJob?.isActive == true) searchJob?.cancel()
|
||||||
|
|
||||||
|
// handle state change: browse <-> search
|
||||||
|
if (query.isEmpty()) {
|
||||||
|
// if the query is empty change back to browse state
|
||||||
|
initBrowse()
|
||||||
|
} else {
|
||||||
|
// TODO handle errors
|
||||||
|
|
||||||
|
// if the current ui state is not search, clear the recyclerview
|
||||||
|
if (uiState.value !is UiState.Search) {
|
||||||
|
uiState.emit(UiState.Search(emptyList()))
|
||||||
|
}
|
||||||
|
|
||||||
|
// create a new search job
|
||||||
|
searchJob = viewModelScope.async {
|
||||||
|
// wait for a few ms: if the user is typing the task will get canceled
|
||||||
|
delay(250)
|
||||||
|
|
||||||
|
val results = Crunchyroll.search(query, 50)
|
||||||
|
.items.firstOrNull()?.items?.toItemMediaList()
|
||||||
|
?: listOf()
|
||||||
|
uiState.emit(UiState.Search(results))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onLazyLoad() = viewModelScope.launch {
|
||||||
|
isLazyLoading = true
|
||||||
|
|
||||||
|
try {
|
||||||
|
uiState.update { currentUiState ->
|
||||||
|
if (currentUiState is UiState.Browse) {
|
||||||
|
val newBrowseItems = Crunchyroll.browse(start = currentUiState.itemList.size, n = PAGESIZE)
|
||||||
|
.toItemMediaList()
|
||||||
|
currentUiState.itemList.addAll(newBrowseItems)
|
||||||
|
}
|
||||||
|
currentUiState
|
||||||
|
}
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
uiState.emit(UiState.Error(ex.message))
|
||||||
|
}
|
||||||
|
|
||||||
|
isLazyLoading = false
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun initBrowse() {
|
||||||
|
try {
|
||||||
|
val initialBrowseItems = Crunchyroll.browse(n = PAGESIZE)
|
||||||
|
.toItemMediaList()
|
||||||
|
.toMutableList()
|
||||||
|
uiState.emit(UiState.Browse(initialBrowseItems))
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
uiState.emit(UiState.Error(ex.message))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,12 +3,13 @@ package org.mosad.teapod.ui.activity.main.viewmodel
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import androidx.lifecycle.AndroidViewModel
|
import androidx.lifecycle.AndroidViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.joinAll
|
import kotlinx.coroutines.joinAll
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.mosad.teapod.parser.crunchyroll.*
|
import org.mosad.teapod.parser.crunchyroll.*
|
||||||
import org.mosad.teapod.preferences.Preferences
|
|
||||||
import org.mosad.teapod.util.DataTypes.MediaType
|
import org.mosad.teapod.util.DataTypes.MediaType
|
||||||
import org.mosad.teapod.util.tmdb.*
|
import org.mosad.teapod.util.tmdb.*
|
||||||
|
import org.mosad.teapod.util.toPlayheadsMap
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handle media, next ep and tmdb
|
* handle media, next ep and tmdb
|
||||||
|
@ -16,7 +17,7 @@ import org.mosad.teapod.util.tmdb.*
|
||||||
*/
|
*/
|
||||||
class MediaFragmentViewModel(application: Application) : AndroidViewModel(application) {
|
class MediaFragmentViewModel(application: Application) : AndroidViewModel(application) {
|
||||||
|
|
||||||
var seriesCrunchy = NoneSeries // movies are also series
|
var seriesCrunchy = NoneSeriesItem // movies are also series
|
||||||
internal set
|
internal set
|
||||||
var seasonsCrunchy = NoneSeasons
|
var seasonsCrunchy = NoneSeasons
|
||||||
internal set
|
internal set
|
||||||
|
@ -26,11 +27,12 @@ class MediaFragmentViewModel(application: Application) : AndroidViewModel(applic
|
||||||
internal set
|
internal set
|
||||||
val currentEpisodesCrunchy = arrayListOf<Episode>() // used for EpisodeItemAdapter (easier updates)
|
val currentEpisodesCrunchy = arrayListOf<Episode>() // used for EpisodeItemAdapter (easier updates)
|
||||||
|
|
||||||
// additional media info
|
// additional media info, might change during during user interaction
|
||||||
|
// use a map to update the episode adapter values
|
||||||
val currentPlayheads: MutableMap<String, PlayheadObject> = mutableMapOf()
|
val currentPlayheads: MutableMap<String, PlayheadObject> = mutableMapOf()
|
||||||
var isWatchlist = false
|
var isWatchlist = false
|
||||||
internal set
|
internal set
|
||||||
var upNextSeries = NoneUpNextSeriesItem
|
var upNextSeries = NoneUpNextSeriesList
|
||||||
internal set
|
internal set
|
||||||
var similarTo = NoneSimilarToResult
|
var similarTo = NoneSimilarToResult
|
||||||
internal set
|
internal set
|
||||||
|
@ -50,36 +52,38 @@ class MediaFragmentViewModel(application: Application) : AndroidViewModel(applic
|
||||||
suspend fun loadCrunchy(crunchyId: String) {
|
suspend fun loadCrunchy(crunchyId: String) {
|
||||||
// load series and seasons info in parallel
|
// load series and seasons info in parallel
|
||||||
listOf(
|
listOf(
|
||||||
viewModelScope.launch { seriesCrunchy = Crunchyroll.series(crunchyId) },
|
viewModelScope.launch { seriesCrunchy = Crunchyroll.series(crunchyId).data.first() },
|
||||||
viewModelScope.launch { seasonsCrunchy = Crunchyroll.seasons(crunchyId) },
|
viewModelScope.launch { seasonsCrunchy = Crunchyroll.seasons(crunchyId) },
|
||||||
viewModelScope.launch { isWatchlist = Crunchyroll.isWatchlist(crunchyId) },
|
viewModelScope.launch { isWatchlist = Crunchyroll.isWatchlist(crunchyId) },
|
||||||
viewModelScope.launch { upNextSeries = Crunchyroll.upNextSeries(crunchyId) },
|
viewModelScope.launch { upNextSeries = Crunchyroll.upNextSeries(crunchyId) },
|
||||||
viewModelScope.launch { similarTo = Crunchyroll.similarTo(crunchyId) }
|
viewModelScope.launch { similarTo = Crunchyroll.similarTo(crunchyId) }
|
||||||
).joinAll()
|
).joinAll()
|
||||||
|
|
||||||
// load the preferred season (preferred language, language per season, not per stream)
|
// load the preferred season:
|
||||||
currentSeasonCrunchy = seasonsCrunchy.getPreferredSeason(Preferences.preferredLocale)
|
// next episode > first season
|
||||||
|
currentSeasonCrunchy = if (upNextSeries != NoneUpNextSeriesList) {
|
||||||
|
seasonsCrunchy.data.firstOrNull{ season ->
|
||||||
|
season.id == upNextSeries.data.first().panel.episodeMetadata.seasonId
|
||||||
|
} ?: seasonsCrunchy.data.first()
|
||||||
|
} else {
|
||||||
|
seasonsCrunchy.data.first()
|
||||||
|
}
|
||||||
|
|
||||||
// Note: if we need to query metaDB, do it now
|
// Note: if we need to query metaDB, do it now
|
||||||
|
|
||||||
// load episodes and metaDB in parallel (tmdb needs mediaType, which is set via episodes)
|
// load episodes and metaDB in parallel (tmdb needs mediaType, which is set via episodes)
|
||||||
viewModelScope.launch { episodesCrunchy = Crunchyroll.episodes(currentSeasonCrunchy.id) }.join()
|
viewModelScope.launch { episodesCrunchy = Crunchyroll.episodes(currentSeasonCrunchy.id) }.join()
|
||||||
currentEpisodesCrunchy.clear()
|
currentEpisodesCrunchy.clear()
|
||||||
currentEpisodesCrunchy.addAll(episodesCrunchy.items)
|
currentEpisodesCrunchy.addAll(episodesCrunchy.data)
|
||||||
|
|
||||||
// set media type
|
// set media type
|
||||||
mediaType = episodesCrunchy.items.firstOrNull()?.let {
|
mediaType = episodesCrunchy.data.firstOrNull()?.let {
|
||||||
if (it.episodeNumber != null) MediaType.TVSHOW else MediaType.MOVIE
|
if (it.episodeNumber != null) MediaType.TVSHOW else MediaType.MOVIE
|
||||||
} ?: MediaType.OTHER
|
} ?: MediaType.OTHER
|
||||||
|
|
||||||
// load playheads and tmdb in parallel
|
// load playheads and tmdb in parallel
|
||||||
listOf(
|
listOf(
|
||||||
viewModelScope.launch {
|
updatePlayheadsAsync(),
|
||||||
// get playheads (including fully watched state)
|
|
||||||
val episodeIDs = episodesCrunchy.items.map { it.id }
|
|
||||||
currentPlayheads.clear()
|
|
||||||
currentPlayheads.putAll(Crunchyroll.playheads(episodeIDs))
|
|
||||||
},
|
|
||||||
viewModelScope.launch { loadTmdbInfo() } // use tmdb search to get media info
|
viewModelScope.launch { loadTmdbInfo() } // use tmdb search to get media info
|
||||||
).joinAll()
|
).joinAll()
|
||||||
}
|
}
|
||||||
|
@ -96,7 +100,6 @@ class MediaFragmentViewModel(application: Application) : AndroidViewModel(applic
|
||||||
MediaType.TVSHOW -> tmdbApiController.searchTVShow(seriesCrunchy.title)
|
MediaType.TVSHOW -> tmdbApiController.searchTVShow(seriesCrunchy.title)
|
||||||
else -> NoneTMDBSearch
|
else -> NoneTMDBSearch
|
||||||
}
|
}
|
||||||
// println(tmdbSearchResult)
|
|
||||||
|
|
||||||
tmdbResult = if (tmdbSearchResult.results.isNotEmpty()) {
|
tmdbResult = if (tmdbSearchResult.results.isNotEmpty()) {
|
||||||
when (val result = tmdbSearchResult.results.first()) {
|
when (val result = tmdbSearchResult.results.first()) {
|
||||||
|
@ -105,7 +108,6 @@ class MediaFragmentViewModel(application: Application) : AndroidViewModel(applic
|
||||||
else -> NoneTMDB
|
else -> NoneTMDB
|
||||||
}
|
}
|
||||||
} else NoneTMDB
|
} else NoneTMDB
|
||||||
// println(tmdbResult)
|
|
||||||
|
|
||||||
// currently not used
|
// currently not used
|
||||||
// tmdbTVSeason = if (tmdbResult is TMDBTVShow) {
|
// tmdbTVSeason = if (tmdbResult is TMDBTVShow) {
|
||||||
|
@ -113,6 +115,16 @@ class MediaFragmentViewModel(application: Application) : AndroidViewModel(applic
|
||||||
// } else NoneTMDBTVSeason
|
// } else NoneTMDBTVSeason
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current playheads for all episodes
|
||||||
|
*/
|
||||||
|
private fun updatePlayheadsAsync() = viewModelScope.async {
|
||||||
|
currentPlayheads.clear()
|
||||||
|
currentPlayheads.putAll(
|
||||||
|
Crunchyroll.playheads(episodesCrunchy.data.map { it.id }).toPlayheadsMap()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set currentSeasonCrunchy based on the season id. Also set the new seasons episodes.
|
* Set currentSeasonCrunchy based on the season id. Also set the new seasons episodes.
|
||||||
*
|
*
|
||||||
|
@ -124,18 +136,16 @@ class MediaFragmentViewModel(application: Application) : AndroidViewModel(applic
|
||||||
|
|
||||||
// set currentSeasonCrunchy to the new season with id == seasonId, if the id isn't found,
|
// set currentSeasonCrunchy to the new season with id == seasonId, if the id isn't found,
|
||||||
// don't change the current season (this should/can never happen)
|
// don't change the current season (this should/can never happen)
|
||||||
currentSeasonCrunchy = seasonsCrunchy.items.firstOrNull {
|
currentSeasonCrunchy = seasonsCrunchy.data.firstOrNull {
|
||||||
it.id == seasonId
|
it.id == seasonId
|
||||||
} ?: currentSeasonCrunchy
|
} ?: currentSeasonCrunchy
|
||||||
|
|
||||||
episodesCrunchy = Crunchyroll.episodes(currentSeasonCrunchy.id)
|
episodesCrunchy = Crunchyroll.episodes(currentSeasonCrunchy.id)
|
||||||
currentEpisodesCrunchy.clear()
|
currentEpisodesCrunchy.clear()
|
||||||
currentEpisodesCrunchy.addAll(episodesCrunchy.items)
|
currentEpisodesCrunchy.addAll(episodesCrunchy.data)
|
||||||
|
|
||||||
// update playheads playheads (including fully watched state)
|
// update playheads playheads (including fully watched state)
|
||||||
val episodeIDs = episodesCrunchy.items.map { it.id }
|
updatePlayheadsAsync().await()
|
||||||
currentPlayheads.clear()
|
|
||||||
currentPlayheads.putAll(Crunchyroll.playheads(episodeIDs))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun setWatchlist() {
|
suspend fun setWatchlist() {
|
||||||
|
@ -150,11 +160,7 @@ class MediaFragmentViewModel(application: Application) : AndroidViewModel(applic
|
||||||
|
|
||||||
suspend fun updateOnResume() {
|
suspend fun updateOnResume() {
|
||||||
joinAll(
|
joinAll(
|
||||||
viewModelScope.launch {
|
updatePlayheadsAsync(),
|
||||||
val episodeIDs = episodesCrunchy.items.map { it.id }
|
|
||||||
currentPlayheads.clear()
|
|
||||||
currentPlayheads.putAll(Crunchyroll.playheads(episodeIDs))
|
|
||||||
},
|
|
||||||
viewModelScope.launch { upNextSeries = Crunchyroll.upNextSeries(seriesCrunchy.id) }
|
viewModelScope.launch { upNextSeries = Crunchyroll.upNextSeries(seriesCrunchy.id) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ import androidx.lifecycle.lifecycleScope
|
||||||
import com.google.android.exoplayer2.ExoPlayer
|
import com.google.android.exoplayer2.ExoPlayer
|
||||||
import com.google.android.exoplayer2.Player
|
import com.google.android.exoplayer2.Player
|
||||||
import com.google.android.exoplayer2.ui.StyledPlayerControlView
|
import com.google.android.exoplayer2.ui.StyledPlayerControlView
|
||||||
|
import com.google.android.exoplayer2.ui.StyledPlayerView
|
||||||
import com.google.android.exoplayer2.util.Util
|
import com.google.android.exoplayer2.util.Util
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.mosad.teapod.R
|
import org.mosad.teapod.R
|
||||||
|
@ -251,7 +252,7 @@ class PlayerActivity : AppCompatActivity() {
|
||||||
playerBinding.videoView.player = model.player
|
playerBinding.videoView.player = model.player
|
||||||
|
|
||||||
// when the player controls get hidden, hide the bars too
|
// when the player controls get hidden, hide the bars too
|
||||||
playerBinding.videoView.setControllerVisibilityListener {
|
playerBinding.videoView.setControllerVisibilityListener(StyledPlayerView.ControllerVisibilityListener {
|
||||||
when (it) {
|
when (it) {
|
||||||
View.GONE -> {
|
View.GONE -> {
|
||||||
hideBars()
|
hideBars()
|
||||||
|
@ -259,7 +260,7 @@ class PlayerActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
View.VISIBLE -> updateControls()
|
View.VISIBLE -> updateControls()
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
playerBinding.videoView.setOnTouchListener { _, event ->
|
playerBinding.videoView.setOnTouchListener { _, event ->
|
||||||
gestureDetector.onTouchEvent(event)
|
gestureDetector.onTouchEvent(event)
|
||||||
|
@ -317,19 +318,18 @@ class PlayerActivity : AppCompatActivity() {
|
||||||
hideButtonNextEp()
|
hideButtonNextEp()
|
||||||
}
|
}
|
||||||
|
|
||||||
// if meta data is present and opening_start & opening_duration are valid, show skip opening
|
// into metadata is present and we can show the skip button
|
||||||
model.currentEpisodeMeta?.let {
|
if (model.currentIntroMetadata.duration >= 10) {
|
||||||
if (it.openingDuration > 0 &&
|
val startTime = model.currentIntroMetadata.startTime.toInt() * 1000
|
||||||
currentPosition in it.openingStart..(it.openingStart + 10000) &&
|
if (currentPosition in startTime..(startTime + 10000) && !playerBinding.buttonSkipOp.isVisible) {
|
||||||
!playerBinding.buttonSkipOp.isVisible
|
|
||||||
) {
|
|
||||||
showButtonSkipOp()
|
showButtonSkipOp()
|
||||||
} else if (playerBinding.buttonSkipOp.isVisible &&
|
} else if (playerBinding.buttonSkipOp.isVisible &&
|
||||||
currentPosition !in it.openingStart..(it.openingStart + 10000)
|
currentPosition !in startTime..(startTime + 10000)
|
||||||
) {
|
) {
|
||||||
// the button should only be visible, if currentEpisodeMeta != null
|
// the button should only be visible if currentEpisodeMeta != null
|
||||||
hideButtonSkipOp()
|
hideButtonSkipOp()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if controls are visible, update them
|
// if controls are visible, update them
|
||||||
|
@ -444,8 +444,9 @@ class PlayerActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private fun skipOpening() {
|
private fun skipOpening() {
|
||||||
// calculate the seek time
|
// calculate the seek time
|
||||||
model.currentEpisodeMeta?.let {
|
if (model.currentIntroMetadata.duration > 10) {
|
||||||
val seekTime = (it.openingStart + it.openingDuration) - model.player.currentPosition
|
val endTime = model.currentIntroMetadata.endTime.toInt() * 1000
|
||||||
|
val seekTime = endTime - model.player.currentPosition
|
||||||
model.seekToOffset(seekTime)
|
model.seekToOffset(seekTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.mosad.teapod.util.metadb.EpisodeMeta
|
||||||
import org.mosad.teapod.util.metadb.Meta
|
import org.mosad.teapod.util.metadb.Meta
|
||||||
import org.mosad.teapod.util.metadb.MetaDBController
|
import org.mosad.teapod.util.metadb.MetaDBController
|
||||||
import org.mosad.teapod.util.metadb.TVShowMeta
|
import org.mosad.teapod.util.metadb.TVShowMeta
|
||||||
|
import org.mosad.teapod.util.toPlayheadsMap
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.concurrent.scheduleAtFixedRate
|
import kotlin.concurrent.scheduleAtFixedRate
|
||||||
|
|
||||||
|
@ -63,7 +64,9 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
||||||
internal set
|
internal set
|
||||||
var currentEpisodeMeta: EpisodeMeta? = null
|
var currentEpisodeMeta: EpisodeMeta? = null
|
||||||
internal set
|
internal set
|
||||||
var currentPlayheads: PlayheadsMap = mutableMapOf()
|
var currentPlayheads = mapOf<String, PlayheadObject>()
|
||||||
|
internal set
|
||||||
|
var currentIntroMetadata: DatalabIntro = NoneDatalabIntro
|
||||||
internal set
|
internal set
|
||||||
// var tmdbTVSeason: TMDBTVSeason? =null
|
// var tmdbTVSeason: TMDBTVSeason? =null
|
||||||
// internal set
|
// internal set
|
||||||
|
@ -73,13 +76,21 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
||||||
internal set
|
internal set
|
||||||
var currentEpisode = NoneEpisode
|
var currentEpisode = NoneEpisode
|
||||||
internal set
|
internal set
|
||||||
var currentPlayback = NonePlayback
|
var currentVersion = NoneVersion
|
||||||
|
internal set
|
||||||
|
var currentStreams = NoneStreams
|
||||||
|
internal set
|
||||||
|
|
||||||
// current playback settings
|
// current playback settings
|
||||||
var currentLanguage: Locale = Preferences.preferredLocale
|
var currentAudioLocale: Locale = Preferences.preferredAudioLocale
|
||||||
|
internal set
|
||||||
|
var currentSubtitleLocale: Locale = Preferences.preferredSubtitleLocale
|
||||||
internal set
|
internal set
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
// disable platform diagnostics since they might be shared with google
|
||||||
|
ExoPlayer.Builder(application).setUsePlatformDiagnostics(false)
|
||||||
|
|
||||||
initMediaSession()
|
initMediaSession()
|
||||||
|
|
||||||
player.addListener(object : Player.Listener {
|
player.addListener(object : Player.Listener {
|
||||||
|
@ -129,10 +140,10 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
||||||
episodes = Crunchyroll.episodes(seasonId)
|
episodes = Crunchyroll.episodes(seasonId)
|
||||||
|
|
||||||
listOf(
|
listOf(
|
||||||
viewModelScope.launch { mediaMeta = loadMediaMeta(episodes.items.first().seriesId) },
|
viewModelScope.launch { mediaMeta = loadMediaMeta(episodes.data.first().seriesId) },
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val episodeIDs = episodes.items.map { it.id }
|
val episodeIDs = episodes.data.map { it.id }
|
||||||
currentPlayheads = Crunchyroll.playheads(episodeIDs)
|
currentPlayheads = Crunchyroll.playheads(episodeIDs).toPlayheadsMap()
|
||||||
}
|
}
|
||||||
).joinAll()
|
).joinAll()
|
||||||
Log.d(classTag, "meta: $mediaMeta")
|
Log.d(classTag, "meta: $mediaMeta")
|
||||||
|
@ -141,13 +152,35 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
||||||
playCurrentMedia(currentPlayhead)
|
playCurrentMedia(currentPlayhead)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setLanguage(language: Locale) {
|
fun setLanguage(newAudioLocale: Locale, newSubtitleLocale: Locale) {
|
||||||
currentLanguage = language
|
// TODO if the audio locale has changes update the streams, if only the subtitle locale has changed load the new stream
|
||||||
playCurrentMedia(player.currentPosition)
|
if (newAudioLocale != currentAudioLocale) {
|
||||||
|
currentAudioLocale = newAudioLocale
|
||||||
|
|
||||||
|
currentVersion = currentEpisode.versions.firstOrNull {
|
||||||
|
it.audioLocale == currentAudioLocale.toLanguageTag()
|
||||||
|
} ?: currentEpisode.versions.first()
|
||||||
|
|
||||||
|
viewModelScope.launch {
|
||||||
|
currentStreams = Crunchyroll.streamsFromMediaGUID(currentVersion.mediaGUID)
|
||||||
|
Log.d(classTag, currentVersion.toString())
|
||||||
|
|
||||||
|
playCurrentMedia(player.currentPosition)
|
||||||
|
}
|
||||||
|
} else if (newSubtitleLocale != currentSubtitleLocale) {
|
||||||
|
currentSubtitleLocale = newSubtitleLocale
|
||||||
|
playCurrentMedia(player.currentPosition)
|
||||||
|
}
|
||||||
|
|
||||||
|
// else nothing has changed so no need do do anything
|
||||||
}
|
}
|
||||||
|
|
||||||
// player actions
|
// player actions
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seeks to a offset position specified in milliseconds in the current MediaItem.
|
||||||
|
* @param offset The offset position in the current MediaItem.
|
||||||
|
*/
|
||||||
fun seekToOffset(offset: Long) {
|
fun seekToOffset(offset: Long) {
|
||||||
player.seekTo(player.currentPosition + offset)
|
player.seekTo(player.currentPosition + offset)
|
||||||
}
|
}
|
||||||
|
@ -161,15 +194,15 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
||||||
*/
|
*/
|
||||||
fun playNextEpisode() = currentEpisode.nextEpisodeId?.let { nextEpisodeId ->
|
fun playNextEpisode() = currentEpisode.nextEpisodeId?.let { nextEpisodeId ->
|
||||||
updatePlayhead() // update playhead before switching to new episode
|
updatePlayhead() // update playhead before switching to new episode
|
||||||
setCurrentEpisode(nextEpisodeId, startPlayback = true)
|
viewModelScope.launch { setCurrentEpisode(nextEpisodeId, startPlayback = true) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set currentEpisodeCr to the episode of the given ID
|
* Set currentEpisodeCr to the episode of the given ID
|
||||||
* @param episodeId The ID of the episode you want to set currentEpisodeCr to
|
* @param episodeId The ID of the episode you want to set currentEpisodeCr to
|
||||||
*/
|
*/
|
||||||
fun setCurrentEpisode(episodeId: String, startPlayback: Boolean = false) {
|
suspend fun setCurrentEpisode(episodeId: String, startPlayback: Boolean = false) {
|
||||||
currentEpisode = episodes.items.find { episode ->
|
currentEpisode = episodes.data.find { episode ->
|
||||||
episode.id == episodeId
|
episode.id == episodeId
|
||||||
} ?: NoneEpisode
|
} ?: NoneEpisode
|
||||||
|
|
||||||
|
@ -187,24 +220,36 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
||||||
currentEpisodeChangedListener.forEach { it() }
|
currentEpisodeChangedListener.forEach { it() }
|
||||||
|
|
||||||
// needs to be blocking, currentPlayback must be present when calling playCurrentMedia()
|
// needs to be blocking, currentPlayback must be present when calling playCurrentMedia()
|
||||||
runBlocking {
|
joinAll(
|
||||||
joinAll(
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
currentVersion = if (Preferences.preferSubbed) {
|
||||||
currentPlayback = Crunchyroll.playback(currentEpisode.playback)
|
currentEpisode.versions.first { it.original }
|
||||||
},
|
} else {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
currentEpisode.versions
|
||||||
Crunchyroll.playheads(listOf(currentEpisode.id))[currentEpisode.id]?.let {
|
.firstOrNull { it.audioLocale == currentAudioLocale.toLanguageTag() }
|
||||||
// if the episode was fully watched, start at the beginning
|
?: currentEpisode.versions.first()
|
||||||
currentPlayhead = if (it.fullyWatched) {
|
}
|
||||||
0
|
|
||||||
} else {
|
currentStreams = Crunchyroll.streamsFromMediaGUID(currentVersion.mediaGUID)
|
||||||
(it.playhead.times(1000)).toLong()
|
Log.d(classTag, currentVersion.toString())
|
||||||
}
|
},
|
||||||
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
Crunchyroll.playheads(listOf(currentEpisode.id)).data.firstOrNull {
|
||||||
|
it.contentId == currentEpisode.id
|
||||||
|
}?.let {
|
||||||
|
// if the episode was fully watched, start at the beginning
|
||||||
|
currentPlayhead = if (it.fullyWatched) {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
(it.playhead.times(1000)).toLong()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
},
|
||||||
}
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
Log.d(classTag, "playback: ${currentEpisode.playback}")
|
currentIntroMetadata = NoneDatalabIntro //Crunchyroll.datalabIntro(currentEpisode.id)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Log.d(classTag, "streams: ${currentEpisode.streamsLink}")
|
||||||
|
|
||||||
if (startPlayback) {
|
if (startPlayback) {
|
||||||
playCurrentMedia()
|
playCurrentMedia()
|
||||||
|
@ -212,26 +257,26 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Play the current media from currentPlaybackCr.
|
* Play the current media from currentStreams.
|
||||||
*
|
*
|
||||||
* @param seekPosition The seek position for the episode (default = 0).
|
* @param seekPosition The seek position for the media (default = 0).
|
||||||
*/
|
*/
|
||||||
fun playCurrentMedia(seekPosition: Long = 0) {
|
fun playCurrentMedia(seekPosition: Long = 0) {
|
||||||
// get preferred stream url, set current language if it differs from the preferred one
|
// get preferred stream url, set current language if it differs from the preferred one
|
||||||
val preferredLocale = currentLanguage
|
val preferredLocale = currentSubtitleLocale
|
||||||
val fallbackLocal = Locale.US
|
val fallbackLocal = Locale.US
|
||||||
val url = when {
|
val url = when {
|
||||||
currentPlayback.streams.adaptive_hls.containsKey(preferredLocale.toLanguageTag()) -> {
|
currentStreams.data[0].adaptive_hls.containsKey(preferredLocale.toLanguageTag()) -> {
|
||||||
currentPlayback.streams.adaptive_hls[preferredLocale.toLanguageTag()]?.url
|
currentStreams.data[0].adaptive_hls[preferredLocale.toLanguageTag()]?.url
|
||||||
}
|
}
|
||||||
currentPlayback.streams.adaptive_hls.containsKey(fallbackLocal.toLanguageTag()) -> {
|
currentStreams.data[0].adaptive_hls.containsKey(fallbackLocal.toLanguageTag()) -> {
|
||||||
currentLanguage = fallbackLocal
|
currentSubtitleLocale = fallbackLocal
|
||||||
currentPlayback.streams.adaptive_hls[fallbackLocal.toLanguageTag()]?.url
|
currentStreams.data[0].adaptive_hls[fallbackLocal.toLanguageTag()]?.url
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
// if no language tag is present use the first entry
|
// if no language tag is present use the first entry
|
||||||
currentLanguage = Locale.ROOT
|
currentSubtitleLocale = Locale.ROOT
|
||||||
currentPlayback.streams.adaptive_hls.entries.first().value.url
|
currentStreams.data[0].adaptive_hls.entries.first().value.url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.i(classTag, "stream url: $url")
|
Log.i(classTag, "stream url: $url")
|
||||||
|
@ -267,7 +312,7 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
||||||
* @return Boolean: true if it is the last, else false.
|
* @return Boolean: true if it is the last, else false.
|
||||||
*/
|
*/
|
||||||
fun currentEpisodeIsLastEpisode(): Boolean {
|
fun currentEpisodeIsLastEpisode(): Boolean {
|
||||||
return episodes.items.lastOrNull()?.id == currentEpisode.id
|
return episodes.data.lastOrNull()?.id == currentEpisode.id
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun loadMediaMeta(crSeriesId: String): Meta? {
|
private suspend fun loadMediaMeta(crSeriesId: String): Meta? {
|
||||||
|
@ -287,8 +332,8 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val episodeIDs = episodes.items.map { it.id }
|
val episodeIDs = episodes.data.map { it.id }
|
||||||
currentPlayheads = Crunchyroll.playheads(episodeIDs)
|
currentPlayheads = Crunchyroll.playheads(episodeIDs).toPlayheadsMap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.mosad.teapod.R
|
import org.mosad.teapod.R
|
||||||
import org.mosad.teapod.databinding.PlayerEpisodesListBinding
|
import org.mosad.teapod.databinding.PlayerEpisodesListBinding
|
||||||
import org.mosad.teapod.ui.activity.player.PlayerViewModel
|
import org.mosad.teapod.ui.activity.player.PlayerViewModel
|
||||||
|
@ -41,18 +42,21 @@ class EpisodeListDialogFragment : DialogFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
val adapterRecEpisodes = EpisodeItemAdapter(
|
val adapterRecEpisodes = EpisodeItemAdapter(
|
||||||
model.episodes.items,
|
model.episodes.data,
|
||||||
null,
|
null,
|
||||||
model.currentPlayheads.toMap(),
|
model.currentPlayheads,
|
||||||
EpisodeItemAdapter.OnClickListener { episode ->
|
EpisodeItemAdapter.OnClickListener { episode ->
|
||||||
dismiss()
|
dismiss()
|
||||||
model.setCurrentEpisode(episode.id, startPlayback = true)
|
// TODO make this none blocking, if necessary?
|
||||||
|
runBlocking {
|
||||||
|
model.setCurrentEpisode(episode.id, startPlayback = true)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
EpisodeItemAdapter.ViewType.PLAYER
|
EpisodeItemAdapter.ViewType.PLAYER
|
||||||
)
|
)
|
||||||
|
|
||||||
// get the position/index of the currently playing episode
|
// get the position/index of the currently playing episode
|
||||||
adapterRecEpisodes.currentSelected = model.episodes.items.indexOfFirst { it.id == model.currentEpisode.id }
|
adapterRecEpisodes.currentSelected = model.episodes.data.indexOfFirst { it.id == model.currentEpisode.id }
|
||||||
|
|
||||||
binding.recyclerEpisodesPlayer.adapter = adapterRecEpisodes
|
binding.recyclerEpisodesPlayer.adapter = adapterRecEpisodes
|
||||||
binding.recyclerEpisodesPlayer.scrollToPosition(adapterRecEpisodes.currentSelected)
|
binding.recyclerEpisodesPlayer.scrollToPosition(adapterRecEpisodes.currentSelected)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.view.children
|
import androidx.core.view.children
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
|
@ -24,7 +25,8 @@ class LanguageSettingsDialogFragment : DialogFragment() {
|
||||||
private lateinit var model: PlayerViewModel
|
private lateinit var model: PlayerViewModel
|
||||||
private lateinit var binding: PlayerLanguageSettingsBinding
|
private lateinit var binding: PlayerLanguageSettingsBinding
|
||||||
|
|
||||||
private var selectedLocale = Locale.ROOT
|
private var selectedSubtitleLocale = Locale.ROOT
|
||||||
|
private var selectedAudioLocale = Locale.ROOT
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "LanguageSettingsDialogFragment"
|
const val TAG = "LanguageSettingsDialogFragment"
|
||||||
|
@ -34,7 +36,7 @@ class LanguageSettingsDialogFragment : DialogFragment() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setStyle(STYLE_NO_TITLE, R.style.FullScreenDialogStyle)
|
setStyle(STYLE_NO_TITLE, R.style.FullScreenDialogStyle)
|
||||||
model = ViewModelProvider(requireActivity())[PlayerViewModel::class.java]
|
model = ViewModelProvider(requireActivity())[PlayerViewModel::class.java]
|
||||||
selectedLocale = model.currentLanguage
|
selectedSubtitleLocale = model.currentSubtitleLocale
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
|
@ -45,23 +47,55 @@ class LanguageSettingsDialogFragment : DialogFragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
model.currentPlayback.streams.adaptive_hls.keys.forEach { languageTag ->
|
var selectedSubtitleView: TextView? = null
|
||||||
|
model.currentStreams.data[0].adaptive_hls.keys.forEach { languageTag ->
|
||||||
val locale = Locale.forLanguageTag(languageTag)
|
val locale = Locale.forLanguageTag(languageTag)
|
||||||
addLanguage(locale, locale == model.currentLanguage) { v ->
|
val subtitleView = addLanguage(binding.linearSubtitleLanguages, locale) { v ->
|
||||||
selectedLocale = locale
|
selectedSubtitleLocale = locale
|
||||||
updateSelectedLanguage(v as TextView)
|
updateSelectedLanguage(binding.linearSubtitleLanguages, v as TextView)
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the view is the currently selected one, highlight it
|
||||||
|
if (locale == model.currentSubtitleLocale) {
|
||||||
|
selectedSubtitleView = subtitleView
|
||||||
|
updateSelectedLanguage(binding.linearSubtitleLanguages, subtitleView)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val currentAudioLocal = Locale.forLanguageTag(model.currentVersion.audioLocale)
|
||||||
|
var selectedAudioView: TextView? = null
|
||||||
|
model.currentEpisode.versions.forEach { version ->
|
||||||
|
val locale = Locale.forLanguageTag(version.audioLocale)
|
||||||
|
val audioView = addLanguage(binding.linearAudioLanguages, locale) { v ->
|
||||||
|
selectedAudioLocale = locale
|
||||||
|
updateSelectedLanguage(binding.linearAudioLanguages, v as TextView)
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the view is the currently selected one, highlight it
|
||||||
|
if (locale == currentAudioLocal) {
|
||||||
|
selectedAudioView = audioView
|
||||||
|
updateSelectedLanguage(binding.linearAudioLanguages, audioView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.buttonCloseLanguageSettings.setOnClickListener { dismiss() }
|
binding.buttonCloseLanguageSettings.setOnClickListener { dismiss() }
|
||||||
binding.buttonCancel.setOnClickListener { dismiss() }
|
binding.buttonCancel.setOnClickListener { dismiss() }
|
||||||
binding.buttonSelect.setOnClickListener {
|
binding.buttonSelect.setOnClickListener {
|
||||||
model.setLanguage(selectedLocale)
|
model.setLanguage(selectedAudioLocale, selectedSubtitleLocale)
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
// initially hide the status and navigation bar
|
// initially hide the status and navigation bar
|
||||||
hideBars(requireDialog().window, binding.root)
|
hideBars(requireDialog().window, binding.root)
|
||||||
|
|
||||||
|
// scroll to the position of the view, if it's the selected language
|
||||||
|
binding.scrollSubtitleLanguages.post {
|
||||||
|
binding.scrollSubtitleLanguages.scrollTo(0, selectedSubtitleView?.top ?: 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.scrollAudioLanguages.post {
|
||||||
|
binding.scrollSubtitleLanguages.scrollTo(0, selectedAudioView?.top ?: 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDismiss(dialog: DialogInterface) {
|
override fun onDismiss(dialog: DialogInterface) {
|
||||||
|
@ -69,33 +103,32 @@ class LanguageSettingsDialogFragment : DialogFragment() {
|
||||||
model.player.play()
|
model.player.play()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addLanguage(locale: Locale, isSelected: Boolean, onClick: View.OnClickListener) {
|
private fun addLanguage(linear: LinearLayout, locale: Locale, onClick: View.OnClickListener): TextView {
|
||||||
val text = TextView(context).apply {
|
val text = TextView(context).apply {
|
||||||
height = 96
|
height = 96
|
||||||
gravity = Gravity.CENTER_VERTICAL
|
gravity = Gravity.CENTER_VERTICAL
|
||||||
text = if (locale == Locale.ROOT) context.getString(R.string.no_subtitles) else locale.displayLanguage
|
text = if (locale == Locale.ROOT) context.getString(R.string.no_subtitles) else locale.displayLanguage
|
||||||
setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f)
|
setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f)
|
||||||
|
setTextColor(context.resources.getColor(R.color.textSecondaryDark, context.theme))
|
||||||
if (isSelected) {
|
setPadding(75, 0, 0, 0)
|
||||||
setTextColor(context.resources.getColor(R.color.textPrimaryDark, context.theme))
|
|
||||||
setTypeface(null, Typeface.BOLD)
|
|
||||||
setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_baseline_check_24, 0, 0, 0)
|
|
||||||
compoundDrawablesRelative.getOrNull(0)?.setTint(Color.WHITE)
|
|
||||||
compoundDrawablePadding = 12
|
|
||||||
} else {
|
|
||||||
setTextColor(context.resources.getColor(R.color.textSecondaryDark, context.theme))
|
|
||||||
setPadding(75, 0, 0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
setOnClickListener(onClick)
|
setOnClickListener(onClick)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.linearLanguages.addView(text)
|
linear.addView(text)
|
||||||
|
|
||||||
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSelectedLanguage(selected: TextView) {
|
/**
|
||||||
|
* Highlights the selected audio/subtitle language
|
||||||
|
*
|
||||||
|
* @param languageLayout The audio/subtitle Layout to update
|
||||||
|
* @param selected The newly selected language TextView
|
||||||
|
*/
|
||||||
|
private fun updateSelectedLanguage(languageLayout: LinearLayout, selected: TextView) {
|
||||||
// rest all tf to not selected style
|
// rest all tf to not selected style
|
||||||
binding.linearLanguages.children.forEach { child ->
|
languageLayout.children.forEach { child ->
|
||||||
if (child is TextView) {
|
if (child is TextView) {
|
||||||
child.apply {
|
child.apply {
|
||||||
setTextColor(context.resources.getColor(R.color.textPrimaryDark, context.theme))
|
setTextColor(context.resources.getColor(R.color.textPrimaryDark, context.theme))
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package org.mosad.teapod.ui.components
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.KeyEvent
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.appcompat.R
|
||||||
|
import androidx.appcompat.widget.SearchView
|
||||||
|
|
||||||
|
// see https://stackoverflow.com/questions/30046201/android-searchview-empty-query-doesnt-work
|
||||||
|
class EmptySubmitSearchView : SearchView {
|
||||||
|
|
||||||
|
constructor(context: Context) : super(context)
|
||||||
|
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||||
|
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
||||||
|
|
||||||
|
override fun setOnQueryTextListener(listener: OnQueryTextListener?) {
|
||||||
|
super.setOnQueryTextListener(listener)
|
||||||
|
|
||||||
|
findViewById<SearchAutoComplete?>(R.id.search_src_text).setOnEditorActionListener { _: TextView?, _: Int, event: KeyEvent? ->
|
||||||
|
if (event != null && event.keyCode == KeyEvent.KEYCODE_ENTER) {
|
||||||
|
listener?.onQueryTextSubmit(query.toString())
|
||||||
|
} else {
|
||||||
|
listener?.onQueryTextSubmit(query.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -9,7 +9,6 @@ import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.fragment.app.commit
|
import androidx.fragment.app.commit
|
||||||
import org.mosad.teapod.R
|
import org.mosad.teapod.R
|
||||||
import org.mosad.teapod.ui.activity.player.PlayerActivity
|
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,20 +24,6 @@ fun FragmentActivity.showFragment(fragment: Fragment) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Start the player as new activity.
|
|
||||||
*
|
|
||||||
* @param seasonId The ID of the season the episode to be played is in
|
|
||||||
* @param episodeId The ID of the episode to play
|
|
||||||
*/
|
|
||||||
fun Activity.startPlayer(seasonId: String, episodeId: String) {
|
|
||||||
val intent = Intent(this, PlayerActivity::class.java).apply {
|
|
||||||
putExtra(getString(R.string.intent_season_id), seasonId)
|
|
||||||
putExtra(getString(R.string.intent_episode_id), episodeId)
|
|
||||||
}
|
|
||||||
startActivity(intent)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hide the status and navigation bar
|
* hide the status and navigation bar
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,16 +1,32 @@
|
||||||
package org.mosad.teapod.util
|
package org.mosad.teapod.util
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.Window
|
import android.view.Window
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.core.view.WindowInsetsControllerCompat
|
import androidx.core.view.WindowInsetsControllerCompat
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import org.mosad.teapod.R
|
||||||
import org.mosad.teapod.parser.crunchyroll.Collection
|
import org.mosad.teapod.parser.crunchyroll.Collection
|
||||||
import org.mosad.teapod.parser.crunchyroll.ContinueWatchingItem
|
import org.mosad.teapod.parser.crunchyroll.Collection2
|
||||||
import org.mosad.teapod.parser.crunchyroll.Item
|
import org.mosad.teapod.parser.crunchyroll.Item
|
||||||
|
import org.mosad.teapod.parser.crunchyroll.PlayheadObject
|
||||||
|
import org.mosad.teapod.ui.activity.player.PlayerActivity
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Intent for PlayerActivity with season and episode id.
|
||||||
|
*
|
||||||
|
* @param seasonId The ID of the season the episode to be played is in
|
||||||
|
* @param episodeId The ID of the episode to play
|
||||||
|
*/
|
||||||
|
fun Fragment.playerIntent(seasonId: String, episodeId: String) = Intent(context, PlayerActivity::class.java).apply {
|
||||||
|
putExtra(getString(R.string.intent_season_id), seasonId)
|
||||||
|
putExtra(getString(R.string.intent_episode_id), episodeId)
|
||||||
|
}
|
||||||
|
|
||||||
fun TextView.setDrawableTop(drawable: Int) {
|
fun TextView.setDrawableTop(drawable: Int) {
|
||||||
this.setCompoundDrawablesWithIntrinsicBounds(0, drawable, 0, 0)
|
this.setCompoundDrawablesWithIntrinsicBounds(0, drawable, 0, 0)
|
||||||
}
|
}
|
||||||
|
@ -33,19 +49,6 @@ fun List<Item>.toItemMediaList(): List<ItemMedia> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmName("toItemMediaListContinueWatchingItem")
|
|
||||||
fun Collection<ContinueWatchingItem>.toItemMediaList(): List<ItemMedia> {
|
|
||||||
return items.map {
|
|
||||||
ItemMedia(it.panel.episodeMetadata.seriesId, it.panel.title, it.panel.images.thumbnail[0][0].source)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun List<ContinueWatchingItem>.toItemMediaList(): List<ItemMedia> {
|
|
||||||
return this.map {
|
|
||||||
ItemMedia(it.panel.episodeMetadata.seriesId, it.panel.title, it.panel.images.thumbnail[0][0].source)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Locale.toDisplayString(fallback: String): String {
|
fun Locale.toDisplayString(fallback: String): String {
|
||||||
return if (this.displayLanguage.isNotEmpty() && this.displayCountry.isNotEmpty()) {
|
return if (this.displayLanguage.isNotEmpty() && this.displayCountry.isNotEmpty()) {
|
||||||
"${this.displayLanguage} (${this.displayCountry})"
|
"${this.displayLanguage} (${this.displayCountry})"
|
||||||
|
@ -56,6 +59,10 @@ fun Locale.toDisplayString(fallback: String): String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Collection2<PlayheadObject>.toPlayheadsMap(): Map<String, PlayheadObject> {
|
||||||
|
return this.data.associateBy { it.contentId }
|
||||||
|
}
|
||||||
|
|
||||||
fun hideBars(window: Window?, root: View) {
|
fun hideBars(window: Window?, root: View) {
|
||||||
if (window != null) {
|
if (window != null) {
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
|
|
|
@ -16,13 +16,12 @@ import org.mosad.teapod.databinding.ItemEpisodeBinding
|
||||||
import org.mosad.teapod.databinding.ItemEpisodePlayerBinding
|
import org.mosad.teapod.databinding.ItemEpisodePlayerBinding
|
||||||
import org.mosad.teapod.parser.crunchyroll.Episode
|
import org.mosad.teapod.parser.crunchyroll.Episode
|
||||||
import org.mosad.teapod.parser.crunchyroll.PlayheadObject
|
import org.mosad.teapod.parser.crunchyroll.PlayheadObject
|
||||||
import org.mosad.teapod.parser.crunchyroll.PlayheadsMap
|
|
||||||
import org.mosad.teapod.util.tmdb.TMDBTVEpisode
|
import org.mosad.teapod.util.tmdb.TMDBTVEpisode
|
||||||
|
|
||||||
class EpisodeItemAdapter(
|
class EpisodeItemAdapter(
|
||||||
private val episodes: List<Episode>,
|
private val episodes: List<Episode>,
|
||||||
private val tmdbEpisodes: List<TMDBTVEpisode>?,
|
private val tmdbEpisodes: List<TMDBTVEpisode>?,
|
||||||
private val playheads: PlayheadsMap,
|
private val playheads: Map<String, PlayheadObject>,
|
||||||
private val onClickListener: OnClickListener,
|
private val onClickListener: OnClickListener,
|
||||||
private val viewType: ViewType
|
private val viewType: ViewType
|
||||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||||
|
|
|
@ -9,18 +9,21 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import org.mosad.teapod.R
|
import org.mosad.teapod.R
|
||||||
import org.mosad.teapod.databinding.ItemMediaBinding
|
import org.mosad.teapod.databinding.ItemMediaBinding
|
||||||
import org.mosad.teapod.parser.crunchyroll.ContinueWatchingItem
|
import org.mosad.teapod.parser.crunchyroll.UpNextAccountItem
|
||||||
|
|
||||||
class MediaEpisodeListAdapter(private val onClickListener: OnClickListener) : ListAdapter<ContinueWatchingItem, MediaEpisodeListAdapter.MediaViewHolder>(DiffCallback) {
|
class MediaEpisodeListAdapter(private val onClickListener: OnClickListener, private val itemOffset: Int = 0) : ListAdapter<UpNextAccountItem, MediaEpisodeListAdapter.MediaViewHolder>(DiffCallback) {
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MediaViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MediaViewHolder {
|
||||||
return MediaViewHolder(
|
val binding = ItemMediaBinding.inflate(
|
||||||
ItemMediaBinding.inflate(
|
LayoutInflater.from(parent.context),
|
||||||
LayoutInflater.from(parent.context),
|
parent,
|
||||||
parent,
|
false
|
||||||
false
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
binding.root.layoutParams.apply {
|
||||||
|
width = (parent.measuredWidth / parent.context.resources.getInteger(R.integer.item_media_columns)) - itemOffset
|
||||||
|
}
|
||||||
|
|
||||||
|
return MediaViewHolder(binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: MediaViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: MediaViewHolder, position: Int) {
|
||||||
|
@ -34,7 +37,7 @@ class MediaEpisodeListAdapter(private val onClickListener: OnClickListener) : Li
|
||||||
inner class MediaViewHolder(val binding: ItemMediaBinding) :
|
inner class MediaViewHolder(val binding: ItemMediaBinding) :
|
||||||
RecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
|
|
||||||
fun bind(item: ContinueWatchingItem) {
|
fun bind(item: UpNextAccountItem) {
|
||||||
val metadata = item.panel.episodeMetadata
|
val metadata = item.panel.episodeMetadata
|
||||||
|
|
||||||
binding.textTitle.text = binding.root.context.getString(R.string.season_episode_title,
|
binding.textTitle.text = binding.root.context.getString(R.string.season_episode_title,
|
||||||
|
@ -54,17 +57,17 @@ class MediaEpisodeListAdapter(private val onClickListener: OnClickListener) : Li
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object DiffCallback : DiffUtil.ItemCallback<ContinueWatchingItem>() {
|
companion object DiffCallback : DiffUtil.ItemCallback<UpNextAccountItem>() {
|
||||||
override fun areItemsTheSame(oldItem: ContinueWatchingItem, newItem: ContinueWatchingItem): Boolean {
|
override fun areItemsTheSame(oldItem: UpNextAccountItem, newItem: UpNextAccountItem): Boolean {
|
||||||
return oldItem.panel.id == newItem.panel.id
|
return oldItem.panel.id == newItem.panel.id
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun areContentsTheSame(oldItem: ContinueWatchingItem, newItem: ContinueWatchingItem): Boolean {
|
override fun areContentsTheSame(oldItem: UpNextAccountItem, newItem: UpNextAccountItem): Boolean {
|
||||||
return oldItem == newItem
|
return oldItem == newItem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OnClickListener(val clickListener: (item: ContinueWatchingItem) -> Unit) {
|
class OnClickListener(val clickListener: (item: UpNextAccountItem) -> Unit) {
|
||||||
fun onClick(item: ContinueWatchingItem) = clickListener(item)
|
fun onClick(item: UpNextAccountItem) = clickListener(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,44 +0,0 @@
|
||||||
package org.mosad.teapod.util.adapter
|
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.core.view.isVisible
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import com.bumptech.glide.Glide
|
|
||||||
import org.mosad.teapod.databinding.ItemMediaBinding
|
|
||||||
import org.mosad.teapod.util.ItemMedia
|
|
||||||
|
|
||||||
@Deprecated("Use MediaItemListAdapter instead")
|
|
||||||
class MediaItemAdapter(private val items: List<ItemMedia>) : RecyclerView.Adapter<MediaItemAdapter.MediaViewHolder>() {
|
|
||||||
|
|
||||||
var onItemClick: ((id: String, position: Int) -> Unit)? = null
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MediaItemAdapter.MediaViewHolder {
|
|
||||||
return MediaViewHolder(ItemMediaBinding.inflate(LayoutInflater.from(parent.context), parent, false))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: MediaItemAdapter.MediaViewHolder, position: Int) {
|
|
||||||
holder.binding.root.apply {
|
|
||||||
holder.binding.textTitle.text = items[position].title
|
|
||||||
Glide.with(context).load(items[position].posterUrl).into(holder.binding.imagePoster)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
|
||||||
return items.size
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class MediaViewHolder(val binding: ItemMediaBinding) :
|
|
||||||
RecyclerView.ViewHolder(binding.root) {
|
|
||||||
init {
|
|
||||||
binding.imageEpisodePlay.isVisible = false // hide the play button for media items
|
|
||||||
binding.root.setOnClickListener {
|
|
||||||
onItemClick?.invoke(
|
|
||||||
items[bindingAdapterPosition].id,
|
|
||||||
bindingAdapterPosition
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -7,19 +7,23 @@ import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.ListAdapter
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
import org.mosad.teapod.R
|
||||||
import org.mosad.teapod.databinding.ItemMediaBinding
|
import org.mosad.teapod.databinding.ItemMediaBinding
|
||||||
import org.mosad.teapod.util.ItemMedia
|
import org.mosad.teapod.util.ItemMedia
|
||||||
|
|
||||||
class MediaItemListAdapter(private val onClickListener: OnClickListener) : ListAdapter<ItemMedia, MediaItemListAdapter.MediaViewHolder>(DiffCallback) {
|
class MediaItemListAdapter(private val onClickListener: OnClickListener, private val itemOffset: Int = 0) : ListAdapter<ItemMedia, MediaItemListAdapter.MediaViewHolder>(DiffCallback) {
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MediaViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MediaViewHolder {
|
||||||
return MediaViewHolder(
|
val binding = ItemMediaBinding.inflate(
|
||||||
ItemMediaBinding.inflate(
|
LayoutInflater.from(parent.context),
|
||||||
LayoutInflater.from(parent.context),
|
parent,
|
||||||
parent,
|
false
|
||||||
false
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
binding.root.layoutParams.apply {
|
||||||
|
width = (parent.measuredWidth / parent.context.resources.getInteger(R.integer.item_media_columns)) - itemOffset
|
||||||
|
}
|
||||||
|
|
||||||
|
return MediaViewHolder(binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: MediaViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: MediaViewHolder, position: Int) {
|
||||||
|
@ -36,7 +40,7 @@ class MediaItemListAdapter(private val onClickListener: OnClickListener) : ListA
|
||||||
fun bind(item: ItemMedia) {
|
fun bind(item: ItemMedia) {
|
||||||
binding.textTitle.text = item.title
|
binding.textTitle.text = item.title
|
||||||
|
|
||||||
Glide.with(binding.imagePoster)
|
Glide.with(binding.root.context)
|
||||||
.load(item.posterUrl)
|
.load(item.posterUrl)
|
||||||
.into(binding.imagePoster)
|
.into(binding.imagePoster)
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ class TMDBApiController {
|
||||||
): T = coroutineScope {
|
): T = coroutineScope {
|
||||||
val path = "$apiUrl$endpoint"
|
val path = "$apiUrl$endpoint"
|
||||||
val params = concatenate(
|
val params = concatenate(
|
||||||
listOf("api_key" to apiKey, "language" to Preferences.preferredLocale.language),
|
listOf("api_key" to apiKey, "language" to Preferences.preferredSubtitleLocale.language),
|
||||||
parameters
|
parameters
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -102,9 +102,9 @@ data class TMDBTVShow(
|
||||||
@SerialName("overview")override val overview: String,
|
@SerialName("overview")override val overview: String,
|
||||||
@SerialName("poster_path") override val posterPath: String?,
|
@SerialName("poster_path") override val posterPath: String?,
|
||||||
@SerialName("backdrop_path") override val backdropPath: String?,
|
@SerialName("backdrop_path") override val backdropPath: String?,
|
||||||
@SerialName("first_air_date") val firstAirDate: String,
|
@SerialName("first_air_date") val firstAirDate: String?,
|
||||||
@SerialName("last_air_date") val lastAirDate: String,
|
@SerialName("last_air_date") val lastAirDate: String?,
|
||||||
@SerialName("status") val status: String,
|
@SerialName("status") val status: String?,
|
||||||
// TODO genres
|
// TODO genres
|
||||||
) : TMDBResult
|
) : TMDBResult
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M17,3L7,3c-1.1,0 -1.99,0.9 -1.99,2L5,21l7,-3 7,3L19,5c0,-1.1 -0.9,-2 -2,-2zM17,18l-5,-2.18L7,18L7,5h10v13z"/>
|
||||||
|
</vector>
|
|
@ -19,6 +19,6 @@
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:layout_marginStart="42dp"
|
android:layout_marginStart="42dp"
|
||||||
android:text="@string/fwd_10_s"
|
android:text="@string/fwd_10_s"
|
||||||
android:textColor="@color/exo_white"
|
android:textColor="@color/player_white"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
|
@ -20,7 +20,7 @@
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:layout_marginEnd="42dp"
|
android:layout_marginEnd="42dp"
|
||||||
android:text="@string/rwd_10_s"
|
android:text="@string/rwd_10_s"
|
||||||
android:textColor="@color/exo_white"
|
android:textColor="@color/player_white"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="7dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.facebook.shimmer.ShimmerFrameLayout
|
<com.facebook.shimmer.ShimmerFrameLayout
|
||||||
|
@ -120,9 +121,8 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/linear_up_next"
|
android:id="@+id/linear_up_next"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
android:paddingBottom="7dp">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_up_next"
|
android:id="@+id/text_up_next"
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
<com.facebook.shimmer.ShimmerFrameLayout
|
<com.facebook.shimmer.ShimmerFrameLayout
|
||||||
android:id="@+id/shimmer_layout_up_next"
|
android:id="@+id/shimmer_layout_up_next"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
tools:visibility="gone">
|
tools:visibility="gone">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -149,6 +149,9 @@
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.facebook.shimmer.ShimmerFrameLayout>
|
</com.facebook.shimmer.ShimmerFrameLayout>
|
||||||
|
@ -156,7 +159,7 @@
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recycler_up_next"
|
android:id="@+id/recycler_up_next"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
tools:listitem="@layout/item_media" />
|
tools:listitem="@layout/item_media" />
|
||||||
|
@ -166,8 +169,7 @@
|
||||||
android:id="@+id/linear_watchlist"
|
android:id="@+id/linear_watchlist"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
android:paddingBottom="7dp">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_watchlist"
|
android:id="@+id/text_watchlist"
|
||||||
|
@ -194,6 +196,9 @@
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.facebook.shimmer.ShimmerFrameLayout>
|
</com.facebook.shimmer.ShimmerFrameLayout>
|
||||||
|
@ -201,7 +206,7 @@
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recycler_watchlist"
|
android:id="@+id/recycler_watchlist"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
tools:listitem="@layout/item_media" />
|
tools:listitem="@layout/item_media" />
|
||||||
|
@ -239,6 +244,9 @@
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.facebook.shimmer.ShimmerFrameLayout>
|
</com.facebook.shimmer.ShimmerFrameLayout>
|
||||||
|
@ -256,8 +264,7 @@
|
||||||
android:id="@+id/linear_new_titles"
|
android:id="@+id/linear_new_titles"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
android:paddingBottom="7dp">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_new_titles"
|
android:id="@+id/text_new_titles"
|
||||||
|
@ -284,6 +291,9 @@
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.facebook.shimmer.ShimmerFrameLayout>
|
</com.facebook.shimmer.ShimmerFrameLayout>
|
||||||
|
@ -301,8 +311,7 @@
|
||||||
android:id="@+id/linear_top_ten"
|
android:id="@+id/linear_top_ten"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
android:paddingBottom="7dp">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_top_ten"
|
android:id="@+id/text_top_ten"
|
||||||
|
@ -329,6 +338,9 @@
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
<include layout="@layout/item_media_shimmer" />
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
|
<include layout="@layout/item_media_shimmer" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.facebook.shimmer.ShimmerFrameLayout>
|
</com.facebook.shimmer.ShimmerFrameLayout>
|
||||||
|
|
|
@ -7,19 +7,34 @@
|
||||||
android:background="?themePrimary"
|
android:background="?themePrimary"
|
||||||
tools:context=".ui.activity.main.fragments.LibraryFragment">
|
tools:context=".ui.activity.main.fragments.LibraryFragment">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<org.mosad.teapod.ui.components.EmptySubmitSearchView
|
||||||
android:id="@+id/recycler_media_library"
|
android:id="@+id/search_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="0dp"
|
||||||
|
android:background="?themeSecondary"
|
||||||
|
android:elevation="8dp"
|
||||||
|
android:iconifiedByDefault="false"
|
||||||
|
android:paddingBottom="5dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
</org.mosad.teapod.ui.components.EmptySubmitSearchView>
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recycler_media_search"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:padding="3dp"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
android:padding="3dp"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toBottomOf="@+id/search_text"
|
||||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
app:spanCount="@integer/item_media_columns"
|
||||||
app:spanCount="2"
|
tools:listitem="@layout/item_media">
|
||||||
tools:listitem="@layout/item_media" />
|
|
||||||
|
</androidx.recyclerview.widget.RecyclerView>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -24,29 +24,42 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
app:layout_scrollFlags="scroll">
|
app:layout_scrollFlags="scroll">
|
||||||
|
|
||||||
<RelativeLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<ImageView
|
<FrameLayout
|
||||||
android:id="@+id/image_backdrop"
|
android:id="@+id/frame_image_progress"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
android:adjustViewBounds="false"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
android:contentDescription="@string/media_poster_backdrop_desc"
|
app:layout_constraintDimensionRatio="H,16:9"
|
||||||
android:maxHeight="231dp"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:minHeight="220dp"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:scaleType="centerCrop" />
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<com.google.android.material.imageview.ShapeableImageView
|
<ImageView
|
||||||
android:id="@+id/image_poster"
|
android:id="@+id/image_backdrop"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="200dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_centerInParent="true"
|
android:contentDescription="@string/media_poster_backdrop_desc"
|
||||||
app:shapeAppearance="@style/ShapeAppearance.Teapod.RoundedPoster"
|
android:scaleType="fitCenter"
|
||||||
tools:src="@drawable/ic_launcher_background" />
|
tools:srcCompat="@drawable/placeholder_image" />
|
||||||
|
|
||||||
</RelativeLayout>
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
|
android:id="@+id/image_poster"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_marginTop="7dp"
|
||||||
|
android:layout_marginBottom="7dp"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
app:shapeAppearance="@style/ShapeAppearance.Teapod.RoundedPoster"
|
||||||
|
tools:src="@drawable/ic_launcher_background" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/linear_media_info"
|
android:id="@+id/linear_media_info"
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
android:paddingEnd="3dp"
|
android:paddingEnd="3dp"
|
||||||
android:paddingBottom="3dp"
|
android:paddingBottom="3dp"
|
||||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||||
app:spanCount="2"
|
app:spanCount="@integer/item_media_columns"
|
||||||
tools:listitem="@layout/item_media" />
|
tools:listitem="@layout/item_media" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?themePrimary"
|
||||||
|
tools:context=".ui.activity.main.fragments.MyListsFragment">
|
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabLayout
|
||||||
|
android:id="@+id/tab_my_lists"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:tabMode="fixed"
|
||||||
|
app:tabSelectedTextColor="?textPrimary"
|
||||||
|
app:tabTextColor="?textSecondary">
|
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabItem
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/my_list" />
|
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabItem
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/crunchylists" />
|
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabItem
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/downloads" />
|
||||||
|
</com.google.android.material.tabs.TabLayout>
|
||||||
|
|
||||||
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
|
android:id="@+id/pager_my_lists"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/tab_my_lists" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1,43 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="?themePrimary"
|
|
||||||
tools:context=".ui.activity.main.fragments.SearchFragment">
|
|
||||||
|
|
||||||
<SearchView
|
|
||||||
android:id="@+id/search_text"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:background="?themeSecondary"
|
|
||||||
android:elevation="8dp"
|
|
||||||
android:iconifiedByDefault="false"
|
|
||||||
android:paddingBottom="5dp"
|
|
||||||
android:queryHint="@string/search_hint"
|
|
||||||
android:searchIcon="@drawable/ic_baseline_search_24"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
|
||||||
|
|
||||||
</SearchView>
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/recycler_media_search"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:clipToPadding="false"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="3dp"
|
|
||||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/search_text"
|
|
||||||
app:spanCount="2"
|
|
||||||
tools:listitem="@layout/item_media">
|
|
||||||
|
|
||||||
</androidx.recyclerview.widget.RecyclerView>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
|
@ -1,71 +1,80 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:backgroundTint="?themeSecondary"
|
|
||||||
app:cardCornerRadius="7dp"
|
|
||||||
app:cardElevation="4dp">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintWidth_max="195dp">
|
android:backgroundTint="?themeSecondary"
|
||||||
|
app:cardCornerRadius="7dp"
|
||||||
|
app:cardElevation="4dp"
|
||||||
|
app:cardUseCompatPadding="true"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<FrameLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/frame_image_progress"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="0dp"
|
android:layout_height="wrap_content">
|
||||||
android:layout_height="0dp"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/text_title"
|
|
||||||
app:layout_constraintDimensionRatio="H,16:9"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintWidth="195dp">
|
|
||||||
|
|
||||||
<ImageView
|
<FrameLayout
|
||||||
android:id="@+id/image_poster"
|
android:id="@+id/frame_image_progress"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="0dp"
|
||||||
android:contentDescription="@string/media_poster_desc"
|
app:layout_constraintBottom_toTopOf="@+id/text_title"
|
||||||
android:scaleType="centerCrop"
|
app:layout_constraintDimensionRatio="H,16:9"
|
||||||
tools:srcCompat="@color/imagePlaceholder" />
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image_episode_play"
|
android:id="@+id/image_poster"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:contentDescription="@string/media_poster_desc"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
tools:srcCompat="@drawable/placeholder_image" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/image_episode_play"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="@drawable/bg_circle__black_transparent_24dp"
|
||||||
|
android:contentDescription="@string/button_play"
|
||||||
|
app:srcCompat="@drawable/ic_baseline_play_arrow_24"
|
||||||
|
app:tint="#FFFFFF" />
|
||||||
|
|
||||||
|
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||||
|
android:id="@+id/progress_playhead"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:max="100"
|
||||||
|
app:trackColor="#00FFFFFF"
|
||||||
|
app:trackThickness="2dp" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_title"
|
||||||
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:gravity="center"
|
||||||
android:background="@drawable/bg_circle__black_transparent_24dp"
|
android:lines="2"
|
||||||
android:contentDescription="@string/button_play"
|
android:maxLines="2"
|
||||||
app:srcCompat="@drawable/ic_baseline_play_arrow_24"
|
android:padding="3dp"
|
||||||
app:tint="#FFFFFF" />
|
android:text="@string/text_title_ex"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textSize="15sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/frame_image_progress" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
</com.google.android.material.card.MaterialCardView>
|
||||||
android:id="@+id/progress_playhead"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:max="100"
|
|
||||||
app:trackColor="#00FFFFFF"
|
|
||||||
app:trackThickness="2dp" />
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<TextView
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
android:id="@+id/text_title"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
android:lines="2"
|
|
||||||
android:maxLines="2"
|
|
||||||
android:padding="3dp"
|
|
||||||
android:text="@string/text_title_ex"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:textSize="15sp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/frame_image_progress" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
|
@ -1,50 +1,58 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:layout_marginStart="4dp"
|
|
||||||
android:layout_marginEnd="3dp"
|
|
||||||
android:backgroundTint="?themeSecondary"
|
|
||||||
app:cardCornerRadius="7dp"
|
|
||||||
app:cardElevation="4dp">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintWidth_max="195dp">
|
android:backgroundTint="?themeSecondary"
|
||||||
|
app:cardCornerRadius="7dp"
|
||||||
|
app:cardElevation="4dp"
|
||||||
|
app:cardUseCompatPadding="true"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<FrameLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/frame_image_progress"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="0dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="0dp"
|
app:layout_constraintWidth_max="195dp">
|
||||||
app:layout_constraintDimensionRatio="H,16:9"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
<FrameLayout
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
android:id="@+id/frame_image_progress"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
android:layout_width="0dp"
|
||||||
app:layout_constraintWidth="195dp">
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintDimensionRatio="H,16:9"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/image_poster"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?shapeTextBackground"
|
||||||
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image_poster"
|
android:id="@+id/image_dummy_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="128dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="19dp"
|
||||||
android:background="?shapeTextBackground"
|
android:layout_margin="11dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/frame_image_progress"
|
||||||
|
app:srcCompat="@drawable/shape_rounded_corner"
|
||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
<ImageView
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
android:id="@+id/image_dummy_text"
|
|
||||||
android:layout_width="128dp"
|
|
||||||
android:layout_height="19dp"
|
|
||||||
android:layout_margin="11dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/frame_image_progress"
|
|
||||||
app:srcCompat="@drawable/shape_rounded_corner"
|
|
||||||
tools:ignore="ContentDescription" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
|
@ -131,7 +131,7 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="7dp"
|
android:layout_marginEnd="7dp"
|
||||||
android:text="@string/subtitles"
|
android:text="@string/language"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
app:icon="@drawable/ic_baseline_subtitles_24"
|
app:icon="@drawable/ic_baseline_subtitles_24"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="44dp"
|
android:layout_marginEnd="44dp"
|
||||||
android:text="@string/subtitles"
|
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textColor="@color/player_white"
|
android:textColor="@color/player_white"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
|
@ -45,16 +44,79 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/linear_languages"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginStart="56dp"
|
android:orientation="horizontal"
|
||||||
android:layout_marginEnd="56dp"
|
|
||||||
android:orientation="vertical"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/linear_bottom"
|
app:layout_constraintBottom_toTopOf="@+id/linear_bottom"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/linear_top" />
|
app:layout_constraintTop_toBottomOf="@+id/linear_top">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_audio"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/audio"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textColor="@color/player_white"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/scroll_audio_languages"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:contentDescription="@string/audio">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/linear_audio_languages"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="56dp"
|
||||||
|
android:layout_marginEnd="56dp"
|
||||||
|
android:orientation="vertical" />
|
||||||
|
</ScrollView>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_subtitles"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/subtitles"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textColor="@color/player_white"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/scroll_subtitle_languages"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:contentDescription="@string/subtitles">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/linear_subtitle_languages"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="56dp"
|
||||||
|
android:layout_marginEnd="56dp"
|
||||||
|
android:orientation="vertical" />
|
||||||
|
</ScrollView>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/linear_bottom"
|
android:id="@+id/linear_bottom"
|
||||||
|
|
|
@ -6,15 +6,15 @@
|
||||||
android:icon="@drawable/ic_home_black_24dp"
|
android:icon="@drawable/ic_home_black_24dp"
|
||||||
android:title="@string/title_home" />
|
android:title="@string/title_home" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/navigation_my_lists"
|
||||||
|
android:icon="@drawable/ic_baseline_bookmark_border_24"
|
||||||
|
android:title="@string/title_my_lists" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/navigation_library"
|
android:id="@+id/navigation_library"
|
||||||
android:icon="@drawable/ic_baseline_video_library_24"
|
android:icon="@drawable/ic_baseline_video_library_24"
|
||||||
android:title="@string/title_library" />
|
android:title="@string/title_library" />
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/navigation_search"
|
|
||||||
android:icon="@drawable/ic_baseline_search_24"
|
|
||||||
android:title="@string/title_search" />
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/navigation_account"
|
android:id="@+id/navigation_account"
|
||||||
android:icon="@drawable/ic_baseline_account_box_24"
|
android:icon="@drawable/ic_baseline_account_box_24"
|
||||||
|
|
|
@ -11,18 +11,18 @@
|
||||||
android:label="@string/title_home"
|
android:label="@string/title_home"
|
||||||
tools:layout="@layout/fragment_home" />
|
tools:layout="@layout/fragment_home" />
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/navigation_my_lists"
|
||||||
|
android:name="org.mosad.teapod.ui.activity.main.fragments.MyListsFragment"
|
||||||
|
android:label="@string/title_my_lists"
|
||||||
|
tools:layout="@layout/fragment_my_lists" />
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/navigation_library"
|
android:id="@+id/navigation_library"
|
||||||
android:name="org.mosad.teapod.ui.activity.main.fragments.LibraryFragment"
|
android:name="org.mosad.teapod.ui.activity.main.fragments.LibraryFragment"
|
||||||
android:label="@string/title_library"
|
android:label="@string/title_library"
|
||||||
tools:layout="@layout/fragment_library" />
|
tools:layout="@layout/fragment_library" />
|
||||||
|
|
||||||
<fragment
|
|
||||||
android:id="@+id/navigation_search"
|
|
||||||
android:name="org.mosad.teapod.ui.activity.main.fragments.SearchFragment"
|
|
||||||
android:label="@string/title_search"
|
|
||||||
tools:layout="@layout/fragment_search" />
|
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/navigation_account"
|
android:id="@+id/navigation_account"
|
||||||
android:name="org.mosad.teapod.ui.activity.main.fragments.AccountFragment"
|
android:name="org.mosad.teapod.ui.activity.main.fragments.AccountFragment"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="title_home">Startseite</string>
|
<string name="title_home">Startseite</string>
|
||||||
|
<string name="title_my_lists">Meine Listen</string>
|
||||||
<string name="title_library">Übersicht</string>
|
<string name="title_library">Übersicht</string>
|
||||||
<string name="title_search">Suche</string>
|
|
||||||
<string name="title_account">Account</string>
|
<string name="title_account">Account</string>
|
||||||
|
|
||||||
<!-- home fragment -->
|
<!-- home fragment -->
|
||||||
|
@ -18,6 +18,9 @@
|
||||||
<!-- search fragment -->
|
<!-- search fragment -->
|
||||||
<string name="search_hint">Suche nach Filmen und Serien</string>
|
<string name="search_hint">Suche nach Filmen und Serien</string>
|
||||||
|
|
||||||
|
<!-- my lists fragment -->
|
||||||
|
<string name="downloads">Downloads</string>
|
||||||
|
|
||||||
<!-- media fragment -->
|
<!-- media fragment -->
|
||||||
<string name="button_play">Abspielen</string>
|
<string name="button_play">Abspielen</string>
|
||||||
<plurals name="text_episodes_count">
|
<plurals name="text_episodes_count">
|
||||||
|
@ -83,6 +86,7 @@
|
||||||
<string name="next_episode">Nächste Folge</string>
|
<string name="next_episode">Nächste Folge</string>
|
||||||
<string name="skip_opening">Intro überspringen</string>
|
<string name="skip_opening">Intro überspringen</string>
|
||||||
<string name="language">Sprache</string>
|
<string name="language">Sprache</string>
|
||||||
|
<string name="audio">Audio</string>
|
||||||
<string name="subtitles">Untertitel</string>
|
<string name="subtitles">Untertitel</string>
|
||||||
<string name="episodes">Folgen</string>
|
<string name="episodes">Folgen</string>
|
||||||
<string name="episode">Folge</string>
|
<string name="episode">Folge</string>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<item name="item_media_columns" type="integer">3</item>
|
||||||
|
</resources>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<item name="item_media_columns" type="integer">4</item>
|
||||||
|
</resources>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<item name="item_media_columns" type="integer">5</item>
|
||||||
|
</resources>
|
|
@ -2,4 +2,5 @@
|
||||||
<resources>
|
<resources>
|
||||||
<dimen name="player_styled_progress_layout_height">28dp</dimen>
|
<dimen name="player_styled_progress_layout_height">28dp</dimen>
|
||||||
<dimen name="player_styled_progress_margin_bottom">52dp</dimen>
|
<dimen name="player_styled_progress_margin_bottom">52dp</dimen>
|
||||||
|
<item name="item_media_columns" type="integer">2</item>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name" translatable="false">Teapod</string>
|
<string name="app_name" translatable="false">Teapod</string>
|
||||||
<string name="title_home">Home</string>
|
<string name="title_home">Home</string>
|
||||||
|
<string name="title_my_lists">My Lists</string>
|
||||||
<string name="title_library">Library</string>
|
<string name="title_library">Library</string>
|
||||||
<string name="title_search">Search</string>
|
|
||||||
<string name="title_account">Account</string>
|
<string name="title_account">Account</string>
|
||||||
|
|
||||||
<!-- home fragment -->
|
<!-- home fragment -->
|
||||||
|
@ -21,6 +21,10 @@
|
||||||
<string name="media_poster_desc" translatable="false">poster</string>
|
<string name="media_poster_desc" translatable="false">poster</string>
|
||||||
<string name="media_poster_backdrop_desc" translatable="false">poster backdrop</string>
|
<string name="media_poster_backdrop_desc" translatable="false">poster backdrop</string>
|
||||||
|
|
||||||
|
<!-- my lists fragment -->
|
||||||
|
<string name="crunchylists" translatable="false">Crunchylists</string>
|
||||||
|
<string name="downloads">Downloads</string>
|
||||||
|
|
||||||
<!-- media fragment -->
|
<!-- media fragment -->
|
||||||
<string name="button_play">Play</string>
|
<string name="button_play">Play</string>
|
||||||
<string name="text_title_ex" translatable="false">A Silent Voice</string>
|
<string name="text_title_ex" translatable="false">A Silent Voice</string>
|
||||||
|
@ -108,6 +112,7 @@
|
||||||
<string name="time_min_sec" translatable="false">%1$02d:%2$02d</string>
|
<string name="time_min_sec" translatable="false">%1$02d:%2$02d</string>
|
||||||
<string name="time_hour_min_sec" translatable="false">%1$d:%2$02d:%3$02d</string>
|
<string name="time_hour_min_sec" translatable="false">%1$d:%2$02d:%3$02d</string>
|
||||||
<string name="language">Language</string>
|
<string name="language">Language</string>
|
||||||
|
<string name="audio">Audio</string>
|
||||||
<string name="subtitles">Subtitles</string>
|
<string name="subtitles">Subtitles</string>
|
||||||
<string name="episodes">Episodes</string>
|
<string name="episodes">Episodes</string>
|
||||||
<string name="episode">Episode</string>
|
<string name="episode">Episode</string>
|
||||||
|
@ -146,6 +151,7 @@
|
||||||
<string name="save_key_user_password" translatable="false">org.mosad.teapod.user_password</string>
|
<string name="save_key_user_password" translatable="false">org.mosad.teapod.user_password</string>
|
||||||
<!-- for legacy reasons the prefer subbed key is called prefer_secondary-->
|
<!-- for legacy reasons the prefer subbed key is called prefer_secondary-->
|
||||||
<string name="save_key_prefer_secondary" translatable="false">org.mosad.teapod.prefer_secondary</string>
|
<string name="save_key_prefer_secondary" translatable="false">org.mosad.teapod.prefer_secondary</string>
|
||||||
|
<string name="save_key_preferred_audio_local" translatable="false">org.mosad.teapod.preferred_audio_local</string>
|
||||||
<string name="save_key_preferred_local" translatable="false">org.mosad.teapod.preferred_local</string>
|
<string name="save_key_preferred_local" translatable="false">org.mosad.teapod.preferred_local</string>
|
||||||
<string name="save_key_autoplay" translatable="false">org.mosad.teapod.autoplay</string>
|
<string name="save_key_autoplay" translatable="false">org.mosad.teapod.autoplay</string>
|
||||||
<string name="save_key_dev_settings" translatable="false">org.mosad.teapod.dev.settings</string>
|
<string name="save_key_dev_settings" translatable="false">org.mosad.teapod.dev.settings</string>
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
<item name="colorAccent">@color/colorAccent</item>
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
<item name="popupMenuStyle">@style/Widget.App.PopupMenu</item>
|
<item name="popupMenuStyle">@style/Widget.App.PopupMenu</item>
|
||||||
|
<item name="searchViewStyle">@style/SearchViewStyle</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.Light" parent="AppTheme">
|
<style name="AppTheme.Light" parent="AppTheme">
|
||||||
|
@ -50,6 +51,13 @@
|
||||||
<item name="android:textColor">?textPrimary</item>
|
<item name="android:textColor">?textPrimary</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- search view theme -->
|
||||||
|
<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView.ActionBar">
|
||||||
|
<item name="iconifiedByDefault">false</item>
|
||||||
|
<item name="searchIcon">@drawable/ic_baseline_search_24</item>
|
||||||
|
<item name="queryHint">@string/search_hint</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<!-- player theme -->
|
<!-- player theme -->
|
||||||
<style name="PlayerTheme" parent="AppTheme">
|
<style name="PlayerTheme" parent="AppTheme">
|
||||||
<item name="android:windowNoTitle">true</item>
|
<item name="android:windowNoTitle">true</item>
|
||||||
|
@ -74,7 +82,6 @@
|
||||||
<item name="postSplashScreenTheme">@style/AppTheme.Dark</item> # Required.
|
<item name="postSplashScreenTheme">@style/AppTheme.Dark</item> # Required.
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<!-- shapes -->
|
<!-- shapes -->
|
||||||
<style name="ShapeAppearance.Teapod.RoundedPoster" parent="ShapeAppearance.MaterialComponents.LargeComponent">
|
<style name="ShapeAppearance.Teapod.RoundedPoster" parent="ShapeAppearance.MaterialComponents.LargeComponent">
|
||||||
<item name="cornerFamily">rounded</item>
|
<item name="cornerFamily">rounded</item>
|
||||||
|
@ -95,5 +102,4 @@
|
||||||
<item name="android:windowTranslucentNavigation">true</item>
|
<item name="android:windowTranslucentNavigation">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -1,14 +1,14 @@
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = "1.7.10"
|
ext.kotlin_version = "1.7.20"
|
||||||
ext.ktor_version = "2.1.1"
|
ext.ktor_version = "2.2.1"
|
||||||
ext.exo_version = "2.17.1"
|
ext.exo_version = "2.18.2"
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.3.0'
|
classpath 'com.android.tools.build:gradle:7.4.1'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
Dies ist der erste beta Release von Teapod 1.1.
|
||||||
|
|
||||||
|
* Unterstützung für Crunchyroll v2 API
|
||||||
|
* Intro überspringen hinzugefügt
|
||||||
|
* Seperaten Screen für Meine Liste
|
||||||
|
* Dynamische SPaltenanzahl für alle Screes um große Bildschirme besser zu unterstützen
|
||||||
|
* Kleine UI/UX Verbesserungen
|
||||||
|
|
||||||
|
Alle Änderungen: https://git.mosad.xyz/Seil0/teapod/compare/1.0.0...1.1.0-beta1
|
|
@ -0,0 +1,9 @@
|
||||||
|
This is the first beta release of Teapod 1.1.
|
||||||
|
|
||||||
|
* Migrate crunchyroll parser to v2 (fixes crunchyroll)
|
||||||
|
* Add skip intro function
|
||||||
|
* Add a separate Watchlist fragment
|
||||||
|
* Dynamically set coulmn count based on the display size
|
||||||
|
* Minor UI/UX improvements
|
||||||
|
|
||||||
|
Full changelog: https://git.mosad.xyz/Seil0/teapod/compare/1.0.0...1.1.0-beta1
|
Binary file not shown.
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
@ -205,6 +205,12 @@ set -- \
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
Loading…
Reference in New Issue