[Lyrics] Added lyrics editing on A11+ devices
This commit is contained in:
parent
39a2c45081
commit
af4347c4ff
6 changed files with 147 additions and 14 deletions
|
@ -0,0 +1,16 @@
|
|||
package code.name.monkey.retromusic.util
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import java.io.File
|
||||
|
||||
object FileUtils {
|
||||
fun copyFileToUri(context: Context, fromFile: File, toUri: Uri) {
|
||||
context.contentResolver.openOutputStream(toUri)
|
||||
?.use { output ->
|
||||
fromFile.inputStream().use { input ->
|
||||
input.copyTo(output)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -118,7 +118,7 @@ object LyricUtil {
|
|||
return "$lrcRootPath$title - $artist.lrc"
|
||||
}
|
||||
|
||||
private fun getLrcOriginalPath(filePath: String): String {
|
||||
fun getLrcOriginalPath(filePath: String): String {
|
||||
return filePath.replace(filePath.substring(filePath.lastIndexOf(".") + 1), "lrc")
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package code.name.monkey.retromusic.util
|
||||
|
||||
import android.content.ContentUris
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.MediaStore
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
object UriUtil {
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
fun getUriFromPath(context: Context, path: String): Uri {
|
||||
val uri = MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL)
|
||||
val proj = arrayOf(MediaStore.Files.FileColumns._ID)
|
||||
context.contentResolver.query(
|
||||
uri, proj, MediaStore.Files.FileColumns.DATA + "=?", arrayOf(path), null
|
||||
)?.use { cursor ->
|
||||
if (cursor.count != 0) {
|
||||
cursor.moveToFirst()
|
||||
return ContentUris.withAppendedId(uri, cursor.getLong(0))
|
||||
}
|
||||
}
|
||||
return Uri.EMPTY
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue