Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into feature/25-custom-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
GrakovNe committed Nov 5, 2024
2 parents 773c512 + 6752a6a commit ae077f0
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 45 deletions.
11 changes: 8 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ android {
applicationId = "org.grakovne.lissen"
minSdk = 28
targetSdk = 35
versionCode = 21
versionName = "1.0.20"
versionCode = 22
versionName = "1.0.21"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}

ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}
}

buildTypes {
Expand Down Expand Up @@ -61,6 +65,7 @@ android {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}

}

dependencies {
Expand All @@ -69,7 +74,7 @@ dependencies {
implementation(libs.accompanist.systemuicontroller)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.navigation.compose)
implementation (libs.material)
implementation(libs.material)
implementation(libs.material3)

implementation(libs.androidx.material)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class LibraryItemIdResponseConverter @Inject constructor() {
return DetailedBook(
id = item.id,
title = item.media.metadata.title,
author = item.media.metadata.authors.joinToString(", ", transform = Author::name),
author = item.media.metadata.authors?.joinToString(", ", transform = Author::name),
files = item
.media
.audioFiles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ data class Metadata(
val title: String,
val titleIgnorePrefix: String,
val subtitle: String?,
val authorName: String,
val narratorName: String,
val seriesName: String,
val authorName: String?,
val genres: List<String>,
val publishedYear: String?,
val publishedDate: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package org.grakovne.lissen.channel.audiobookshelf.model
data class MediaMetadataResponse(
val title: String,
val subtitle: String?,
val authors: List<org.grakovne.lissen.channel.audiobookshelf.model.Author>,
val genres: List<String>,
val authors: List<Author>?,
val publishedYear: Int?,
val publishedDate: String?,
val publisher: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ object LocalCacheModule {
name = DATABASE_NAME
)

return database.build()
return database
.addMigrations(MIGRATION_1_2)
.build()
}

@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import org.grakovne.lissen.content.cache.entity.MediaProgressEntity
MediaProgressEntity::class,
CachedLibraryEntity::class
],
version = 1
version = 2,
exportSchema = true
)
abstract class LocalCacheStorage : RoomDatabase() {

Expand Down
30 changes: 30 additions & 0 deletions app/src/main/java/org/grakovne/lissen/content/cache/Migrations.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.grakovne.lissen.content.cache

import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase

val MIGRATION_1_2 = object : Migration(1, 2) {
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL("ALTER TABLE detailed_books RENAME TO detailed_books_old")

db.execSQL(
"""
CREATE TABLE detailed_books (
id TEXT NOT NULL PRIMARY KEY,
title TEXT NOT NULL,
author TEXT,
duration INTEGER NOT NULL
)
""".trimIndent()
)

db.execSQL(
"""
INSERT INTO detailed_books (id, title, author, duration)
SELECT id, title, author, duration FROM detailed_books_old
""".trimIndent()
)

db.execSQL("DROP TABLE detailed_books_old")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ data class CachedBookEntity(
data class BookEntity(
@PrimaryKey val id: String,
val title: String,
val author: String,
val author: String?,
val duration: Int
) : Serializable

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/grakovne/lissen/domain/Book.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.grakovne.lissen.domain
data class Book(
val id: String,
val title: String,
val author: String,
val author: String?,
val duration: Int,
val cachedState: BookCachedState
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.io.Serializable
data class DetailedBook(
val id: String,
val title: String,
val author: String,
val author: String?,
val files: List<BookFile>,
val chapters: List<BookChapter>,
val progress: MediaProgress?
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/grakovne/lissen/domain/RecentBook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package org.grakovne.lissen.domain
data class RecentBook(
val id: String,
val title: String,
val author: String
val author: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,11 @@ class MediaRepository @Inject constructor(
else -> factor
}

mediaController.setPlaybackSpeed(speed)
_playbackSpeed.postValue(speed)
if (::mediaController.isInitialized) {
mediaController.setPlaybackSpeed(speed)
}

_playbackSpeed.postValue(speed)
preferences.savePlaybackSpeed(speed)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ import org.grakovne.lissen.ui.screens.library.composables.SearchActionComposable
import org.grakovne.lissen.ui.screens.library.composables.fallback.LibraryFallbackComposable
import org.grakovne.lissen.ui.screens.library.composables.placeholder.LibraryPlaceholderComposable
import org.grakovne.lissen.ui.screens.library.composables.placeholder.RecentBooksPlaceholderComposable
import org.grakovne.lissen.ui.theme.LissenTheme
import org.grakovne.lissen.viewmodel.CachingModelView
import org.grakovne.lissen.viewmodel.LibraryViewModel
import org.grakovne.lissen.viewmodel.PlayerViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,19 @@ fun BookComposable(
maxLines = 2,
overflow = TextOverflow.Ellipsis
)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = book.author,
style = MaterialTheme.typography.bodyMedium.copy(
color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.6f)
),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
book
.author
?.let {
Spacer(modifier = Modifier.height(4.dp))
Text(
text = it,
style = MaterialTheme.typography.bodyMedium.copy(
color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.6f)
),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
}

Spacer(modifier = Modifier.width(16.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,18 @@ fun MiniPlayerComposable(
maxLines = 2,
overflow = TextOverflow.Ellipsis
)
Text(
text = book.author,
style = MaterialTheme.typography.bodyMedium.copy(
color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.6f)
),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
book
.author
?.let {
Text(
text = it,
style = MaterialTheme.typography.bodyMedium.copy(
color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.6f)
),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
}

Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,18 @@ fun RecentBookItemComposable(

Spacer(modifier = Modifier.height(4.dp))

Text(
text = book.author,
style = MaterialTheme.typography.bodySmall.copy(
color = MaterialTheme.colorScheme.onBackground.copy(
alpha = 0.6f
)
),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
book.author?.let {
Text(
text = book.author,
style = MaterialTheme.typography.bodySmall.copy(
color = MaterialTheme.colorScheme.onBackground.copy(
alpha = 0.6f
)
),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
}
}
}

0 comments on commit ae077f0

Please sign in to comment.