Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,11 @@ app/src/main/java/com/metrolist/music/listentogether/proto/*
# FFTW third-party library build artifacts
.build-fftw
app/src/main/cpp/coverart/

# Agents dir
.claude
.antigravity*
.gemini
.opencode
.cursor*
.codeium
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:resizeableActivity="true"
android:theme="@style/Theme.Metrolist"
android:windowSoftInputMode="adjustResize">
<intent-filter>
Expand Down
26 changes: 25 additions & 1 deletion app/src/main/kotlin/com/metrolist/music/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.LocalWindowInfo
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastAny
import androidx.compose.ui.window.Dialog
Expand Down Expand Up @@ -641,6 +643,26 @@ class MainActivity : ComponentActivity() {
pureBlack = pureBlack,
themeColor = themeColor,
) {
val currentDensity = LocalDensity.current
val windowInfo = LocalWindowInfo.current
val containerWidthDp = windowInfo.containerDpSize.width

val densityScale = remember(containerWidthDp) {
when {
containerWidthDp >= 840.dp -> 1.25f
containerWidthDp >= 720.dp -> 1.15f
containerWidthDp >= 600.dp -> 1.1f
else -> 1.0f
}
}
val scaledDensity: Density = remember(currentDensity, densityScale) {
Density(
density = currentDensity.density * densityScale,
fontScale = currentDensity.fontScale,
)
}

CompositionLocalProvider(LocalDensity provides scaledDensity) {
BoxWithConstraints(
modifier =
Modifier
Expand Down Expand Up @@ -756,8 +778,9 @@ class MainActivity : ComponentActivity() {
}

val isLandscape = configuration.containerDpSize.width > configuration.containerDpSize.height
val isTablet = configuration.containerDpSize.width >= 600.dp

val showRail = isLandscape && !inSearchScreen
val showRail = (isLandscape || isTablet) && !inSearchScreen

val navPadding =
if (shouldShowNavigationBar && !showRail) {
Expand Down Expand Up @@ -1367,6 +1390,7 @@ class MainActivity : ComponentActivity() {
}
}
}
}
}
}

Expand Down
18 changes: 17 additions & 1 deletion app/src/main/kotlin/com/metrolist/music/db/MusicDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import java.util.Date
import java.util.Locale

class MusicDatabase(
private val delegate: InternalDatabase,
val delegate: InternalDatabase,
) : DatabaseDao by delegate.dao {
val speedDialDao: SpeedDialDao
get() = delegate.speedDialDao
Expand Down Expand Up @@ -177,6 +177,7 @@ abstract class InternalDatabase : RoomDatabase() {
MIGRATION_21_24,
MIGRATION_22_24,
MIGRATION_24_25,
MIGRATION_38_37,
).fallbackToDestructiveMigration(dropAllTables = true)
.setJournalMode(RoomDatabase.JournalMode.WRITE_AHEAD_LOGGING)
.setTransactionExecutor(
Expand Down Expand Up @@ -813,6 +814,21 @@ val MIGRATION_24_25 =
}
}

val MIGRATION_38_37 =
object : Migration(38, 37) {
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL("DROP TABLE IF EXISTS `ArtistPageCache`")
db.execSQL(
"CREATE TABLE IF NOT EXISTS `artist_new` (`id` TEXT NOT NULL, `name` TEXT NOT NULL, `thumbnailUrl` TEXT, `channelId` TEXT, `lastUpdateTime` INTEGER NOT NULL, `bookmarkedAt` INTEGER, `isLocal` INTEGER NOT NULL DEFAULT 0, `isPodcastChannel` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`id`))"
)
db.execSQL(
"INSERT INTO `artist_new` (`id`, `name`, `thumbnailUrl`, `channelId`, `lastUpdateTime`, `bookmarkedAt`, `isLocal`, `isPodcastChannel`) SELECT `id`, `name`, `thumbnailUrl`, `channelId`, `lastUpdateTime`, `bookmarkedAt`, `isLocal`, `isPodcastChannel` FROM `artist`"
)
db.execSQL("DROP TABLE `artist`")
db.execSQL("ALTER TABLE `artist_new` RENAME TO `artist`")
}
}

class Migration29To30 : AutoMigrationSpec {
override fun onPostMigrate(db: SupportSQLiteDatabase) {
// Ensure isVideo column exists (safeguard)
Expand Down
12 changes: 5 additions & 7 deletions app/src/main/kotlin/com/metrolist/music/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,15 @@ object AppModule {

@Singleton
@Provides
fun provideInternalDatabase(
fun provideDatabase(
@ApplicationContext context: Context,
): InternalDatabase = Room
.databaseBuilder(context, InternalDatabase::class.java, InternalDatabase.DB_NAME)
.build()
): MusicDatabase = InternalDatabase.newInstance(context)

@Singleton
@Provides
fun provideDatabase(
internalDatabase: InternalDatabase,
): MusicDatabase = MusicDatabase(internalDatabase)
fun provideInternalDatabase(
database: MusicDatabase,
): InternalDatabase = database.delegate

@Singleton
@Provides
Expand Down
122 changes: 74 additions & 48 deletions innertube/src/main/kotlin/com/metrolist/innertube/YouTube.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,11 @@ object YouTube {
if (name != null) return@run Artist(name = name, id = browseId)
}

val fromMusicHeaderStrapline = response.header?.musicHeaderRenderer
?.straplineTextOne?.runs?.firstOrNull()
?.let { Artist(name = it.text, id = it.navigationEndpoint?.browseEndpoint?.browseId) }
if (fromMusicHeaderStrapline != null) return@run fromMusicHeaderStrapline

null
}

Expand All @@ -1013,14 +1018,13 @@ object YouTube {
PlaylistItem(
id = playlistId,
title =
header
?.title
?.runs
?.firstOrNull()
?.text!!,
header?.title?.runs?.firstOrNull()?.text
?: response.header?.musicHeaderRenderer?.title?.runs?.firstOrNull()?.text
?: "",
author = author,
songCountText =
header.secondSubtitle
(header?.secondSubtitle
?: response.header?.musicHeaderRenderer?.secondSubtitle)
?.runs
?.findLast {
it.text.any { c -> c.isDigit() } &&
Expand All @@ -1029,68 +1033,90 @@ object YouTube {
!it.text.contains("minute", ignoreCase = true)
}?.text,
thumbnail =
header.thumbnail
header?.thumbnail
?.musicThumbnailRenderer
?.thumbnail
?.thumbnails
?.lastOrNull()
?.url!!,
?.url
?: response.header
?.musicHeaderRenderer
?.thumbnail
?.musicThumbnailRenderer
?.thumbnails
?.lastOrNull()
?.url
?: "",
playEndpoint = null,
shuffleEndpoint =
header.buttons
.lastOrNull()
?.menuRenderer
?.items
?.firstOrNull()
?.menuNavigationItemRenderer
?.navigationEndpoint
?.watchPlaylistEndpoint!!,
header?.buttons?.lastOrNull()
?.menuRenderer?.items?.firstOrNull()
?.menuNavigationItemRenderer?.navigationEndpoint?.watchPlaylistEndpoint
?: response.header?.musicHeaderRenderer?.buttons?.lastOrNull()
?.menuRenderer?.items?.firstOrNull()
?.menuNavigationItemRenderer?.navigationEndpoint?.watchPlaylistEndpoint,
radioEndpoint =
header.buttons
.getOrNull(2)
?.menuRenderer
?.items
?.find {
header?.buttons?.getOrNull(2)
?.menuRenderer?.items?.find {
it.menuNavigationItemRenderer?.icon?.iconType == "MIX"
}?.menuNavigationItemRenderer
?.navigationEndpoint
?.watchPlaylistEndpoint,
}?.menuNavigationItemRenderer?.navigationEndpoint?.watchPlaylistEndpoint
?: response.header?.musicHeaderRenderer?.buttons?.getOrNull(2)
?.menuRenderer?.items?.find {
it.menuNavigationItemRenderer?.icon?.iconType == "MIX"
}?.menuNavigationItemRenderer?.navigationEndpoint?.watchPlaylistEndpoint,
isEditable = editable,
description = description,
authorAvatarUrl = authorAvatarUrl,
),
songs =
response.contents
?.twoColumnBrowseResultsRenderer
?.secondaryContents
?.sectionListRenderer
?.contents
?.firstOrNull()
?.musicPlaylistShelfRenderer
songs = run {
val twoColShelf =
response.contents
?.twoColumnBrowseResultsRenderer
?.secondaryContents
?.sectionListRenderer
?.contents
?.firstOrNull()
?.musicPlaylistShelfRenderer
val singleColShelf =
response.contents
?.singleColumnBrowseResultsRenderer
?.tabs
?.firstOrNull()
?.tabRenderer
?.content
?.sectionListRenderer
?.contents
?.firstOrNull()
?.musicPlaylistShelfRenderer
(twoColShelf ?: singleColShelf)
?.contents
?.getItems()
?.mapNotNull {
PlaylistPage.fromMusicResponsiveListItemRenderer(it)
} ?: emptyList(),
songsContinuation =
response.contents
?.twoColumnBrowseResultsRenderer
?.secondaryContents
?.sectionListRenderer
?.contents
?.firstOrNull()
?.musicPlaylistShelfRenderer
?.contents
?.getContinuation()
?: response.contents
?.mapNotNull { PlaylistPage.fromMusicResponsiveListItemRenderer(it) }
?: emptyList()
},
songsContinuation = run {
val twoColShelf =
response.contents
?.twoColumnBrowseResultsRenderer
?.secondaryContents
?.sectionListRenderer
?.contents
?.firstOrNull()
?.musicPlaylistShelfRenderer
?.continuations
?.getContinuation(),
val singleColShelf =
response.contents
?.singleColumnBrowseResultsRenderer
?.tabs
?.firstOrNull()
?.tabRenderer
?.content
?.sectionListRenderer
?.contents
?.firstOrNull()
?.musicPlaylistShelfRenderer
val shelf = twoColShelf ?: singleColShelf
shelf?.contents?.getContinuation() ?: shelf?.continuations?.getContinuation()
},
continuation =
response.contents
?.twoColumnBrowseResultsRenderer
Expand Down