add a folderName value to tracks
This commit is contained in:
parent
3c3c8a6a8b
commit
fc9188ed64
4 changed files with 14 additions and 5 deletions
|
@ -16,7 +16,7 @@ import com.simplemobiletools.musicplayer.models.*
|
|||
import com.simplemobiletools.musicplayer.objects.MyExecutor
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
@Database(entities = [Track::class, Playlist::class, QueueItem::class, Artist::class, Album::class], version = 7)
|
||||
@Database(entities = [Track::class, Playlist::class, QueueItem::class, Artist::class, Album::class], version = 8)
|
||||
abstract class SongsDatabase : RoomDatabase() {
|
||||
|
||||
abstract fun SongsDao(): SongsDao
|
||||
|
@ -52,6 +52,7 @@ abstract class SongsDatabase : RoomDatabase() {
|
|||
.addMigrations(MIGRATION_4_5)
|
||||
.addMigrations(MIGRATION_5_6)
|
||||
.addMigrations(MIGRATION_6_7)
|
||||
.addMigrations(MIGRATION_7_8)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
@ -147,5 +148,11 @@ abstract class SongsDatabase : RoomDatabase() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val MIGRATION_7_8 = object : Migration(7, 8) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("ALTER TABLE tracks ADD COLUMN folder_name TEXT default '' NOT NULL")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.simplemobiletools.commons.extensions.*
|
|||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.helpers.isOreoPlus
|
||||
import com.simplemobiletools.commons.helpers.isQPlus
|
||||
import com.simplemobiletools.commons.helpers.mydebug
|
||||
import com.simplemobiletools.musicplayer.databases.SongsDatabase
|
||||
import com.simplemobiletools.musicplayer.helpers.*
|
||||
import com.simplemobiletools.musicplayer.interfaces.*
|
||||
|
@ -206,7 +207,7 @@ fun Context.getAlbumTracksSync(albumId: Long): ArrayList<Track> {
|
|||
val path = cursor.getStringValue(Audio.Media.DATA)
|
||||
val artist = cursor.getStringValue(Audio.Media.ARTIST) ?: MediaStore.UNKNOWN_STRING
|
||||
val album = cursor.getStringValue(Audio.Media.ALBUM)
|
||||
val track = Track(0, id, title, artist, path, duration, album, coverArt, 0, trackId)
|
||||
val track = Track(0, id, title, artist, path, duration, album, coverArt, 0, trackId, "")
|
||||
tracks.add(track)
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class RoomHelper(val context: Context) {
|
|||
val album = cursor.getStringValue(Audio.Media.ALBUM)
|
||||
val albumId = cursor.getLongValue(Audio.Media.ALBUM_ID)
|
||||
val coverArt = ContentUris.withAppendedId(artworkUri, albumId).toString()
|
||||
val song = Track(0, mediaStoreId, title, artist, path, duration, album, coverArt, playlistId, 0)
|
||||
val song = Track(0, mediaStoreId, title, artist, path, duration, album, coverArt, playlistId, 0, "")
|
||||
song.title = song.getProperTitle(showFilename)
|
||||
songs.add(song)
|
||||
pathsMap.remove(path)
|
||||
|
@ -65,7 +65,7 @@ class RoomHelper(val context: Context) {
|
|||
pathsMap.forEach {
|
||||
val unknown = MediaStore.UNKNOWN_STRING
|
||||
val title = context.getTitle(it) ?: unknown
|
||||
val song = Track(0, 0, title, context.getArtist(it) ?: unknown, it, context.getDuration(it) ?: 0, "", "", playlistId, 0)
|
||||
val song = Track(0, 0, title, context.getArtist(it) ?: unknown, it, context.getDuration(it) ?: 0, "", "", playlistId, 0, "")
|
||||
song.title = song.getProperTitle(showFilename)
|
||||
songs.add(song)
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ data class Track(
|
|||
@ColumnInfo(name = "album") var album: String,
|
||||
@ColumnInfo(name = "cover_art") val coverArt: String,
|
||||
@ColumnInfo(name = "playlist_id") var playListId: Int,
|
||||
@ColumnInfo(name = "track_id") val trackId: Int // order id within the tracks' album
|
||||
@ColumnInfo(name = "track_id") val trackId: Int, // order id within the tracks' album
|
||||
@ColumnInfo(name = "folder_name") var folderName: String
|
||||
) : Serializable, Comparable<Track>, ListItem() {
|
||||
|
||||
companion object {
|
||||
|
|
Loading…
Reference in a new issue