Merge pull request #1275 from 66Omar/1220-add-last-modified

1220 add last modified to song (file) details
This commit is contained in:
Prathamesh More 2022-03-03 22:02:56 +05:30 committed by GitHub
commit 535bd8d872
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 67 additions and 0 deletions

View file

@ -49,6 +49,7 @@ class SongDetailDialog : DialogFragment() {
val fileName: TextView = dialogView.findViewById(R.id.fileName)
val filePath: TextView = dialogView.findViewById(R.id.filePath)
val fileSize: TextView = dialogView.findViewById(R.id.fileSize)
val dateModified: TextView = dialogView.findViewById(R.id.dateModified)
val fileFormat: TextView = dialogView.findViewById(R.id.fileFormat)
val trackLength: TextView = dialogView.findViewById(R.id.trackLength)
val bitRate: TextView = dialogView.findViewById(R.id.bitrate)
@ -67,6 +68,10 @@ class SongDetailDialog : DialogFragment() {
fileName.text = makeTextWithTitle(context, R.string.label_file_name, songFile.name)
filePath.text =
makeTextWithTitle(context, R.string.label_file_path, songFile.absolutePath)
dateModified.text = makeTextWithTitle(context, R.string.label_last_modified,
MusicUtil.getDateModifiedString(songFile.lastModified()))
fileSize.text =
makeTextWithTitle(
context,

View file

@ -39,6 +39,7 @@ import org.koin.core.component.KoinComponent
import org.koin.core.component.get
import java.io.File
import java.io.IOException
import java.text.SimpleDateFormat
import java.util.*
import java.util.regex.Pattern
@ -294,6 +295,14 @@ object MusicUtil : KoinComponent {
return songs.indexOfFirst { it.id == songId }
}
fun getDateModifiedString(date: Long): String {
val calendar: Calendar = Calendar.getInstance()
val pattern = "dd/MM/yyyy hh:mm:ss"
calendar.timeInMillis = date
val formatter = SimpleDateFormat(pattern, Locale.ENGLISH)
return formatter.format(calendar.time)
}
fun insertAlbumArt(
context: Context,
albumId: Long,