mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-09-01 07:30:00 +02:00
Fix: downloaded filename is different in android 10 #13
This commit is contained in:
parent
993ff5341d
commit
6dbbfdbc04
4 changed files with 24 additions and 5 deletions
|
@ -13,8 +13,8 @@ android {
|
||||||
applicationId "com.audiobookshelf.app"
|
applicationId "com.audiobookshelf.app"
|
||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 20
|
versionCode 21
|
||||||
versionName "0.9.4-beta"
|
versionName "0.9.5-beta"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
aaptOptions {
|
aaptOptions {
|
||||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||||
|
|
|
@ -253,6 +253,7 @@ class AudioDownloader : Plugin() {
|
||||||
|
|
||||||
var dlfilename = audiobookId + "." + File(filename).extension
|
var dlfilename = audiobookId + "." + File(filename).extension
|
||||||
var coverdlfilename = audiobookId + "." + File(coverFilename).extension
|
var coverdlfilename = audiobookId + "." + File(coverFilename).extension
|
||||||
|
Log.d(tag, "DL Filename $dlfilename | Cover DL Filename $coverdlfilename")
|
||||||
|
|
||||||
var canWriteToFolder = folder.canWrite()
|
var canWriteToFolder = folder.canWrite()
|
||||||
if (!canWriteToFolder) {
|
if (!canWriteToFolder) {
|
||||||
|
@ -264,7 +265,7 @@ class AudioDownloader : Plugin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var dlRequest = DownloadManager.Request(Uri.parse(url))
|
var dlRequest = DownloadManager.Request(Uri.parse(url))
|
||||||
dlRequest.setTitle(title)
|
dlRequest.setTitle("Ab: $title")
|
||||||
dlRequest.setDescription("Downloading to ${folder.name}")
|
dlRequest.setDescription("Downloading to ${folder.name}")
|
||||||
dlRequest.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
dlRequest.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||||
dlRequest.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, dlfilename)
|
dlRequest.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, dlfilename)
|
||||||
|
@ -295,21 +296,36 @@ class AudioDownloader : Plugin() {
|
||||||
var doneReceiver : (id:Long, success: Boolean) -> Unit = { id:Long, success: Boolean ->
|
var doneReceiver : (id:Long, success: Boolean) -> Unit = { id:Long, success: Boolean ->
|
||||||
Log.d(tag, "RECEIVER DONE $id, SUCCES? $success")
|
Log.d(tag, "RECEIVER DONE $id, SUCCES? $success")
|
||||||
var docfile:DocumentFile? = null
|
var docfile:DocumentFile? = null
|
||||||
|
|
||||||
|
// Download was complete, now find downloaded file
|
||||||
if (id == coverDownloadId) {
|
if (id == coverDownloadId) {
|
||||||
docfile = DocumentFileCompat.fromPublicFolder(context, PublicDirectory.DOWNLOADS, coverdlfilename)
|
docfile = DocumentFileCompat.fromPublicFolder(context, PublicDirectory.DOWNLOADS, coverdlfilename)
|
||||||
|
|
||||||
Log.d(tag, "Move Cover File ${docfile?.name}")
|
Log.d(tag, "Move Cover File ${docfile?.name}")
|
||||||
|
|
||||||
|
// For unknown reason, Android 10 test was using the title set in "setTitle" for the dl manager as the filename
|
||||||
|
// check if this was the case
|
||||||
|
if (docfile?.name == null) {
|
||||||
|
docfile = DocumentFileCompat.fromPublicFolder(context, PublicDirectory.DOWNLOADS, "Cover: $title")
|
||||||
|
Log.d(tag, "Cover File name attempt 2 ${docfile?.name}")
|
||||||
|
}
|
||||||
} else if (id == audiobookDownloadId) {
|
} else if (id == audiobookDownloadId) {
|
||||||
docfile = DocumentFileCompat.fromPublicFolder(context, PublicDirectory.DOWNLOADS, dlfilename)
|
docfile = DocumentFileCompat.fromPublicFolder(context, PublicDirectory.DOWNLOADS, dlfilename)
|
||||||
Log.d(tag, "Move Audiobook File ${docfile?.name}")
|
Log.d(tag, "Move Audiobook File ${docfile?.name}")
|
||||||
|
|
||||||
|
if (docfile?.name == null) {
|
||||||
|
docfile = DocumentFileCompat.fromPublicFolder(context, PublicDirectory.DOWNLOADS, "Ab: $title")
|
||||||
|
Log.d(tag, "File name attempt 2 ${docfile?.name}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Callback for moving the downloaded file
|
||||||
var callback = object : FileCallback() {
|
var callback = object : FileCallback() {
|
||||||
override fun onPrepare() {
|
override fun onPrepare() {
|
||||||
Log.d(tag, "PREPARING MOVE FILE")
|
Log.d(tag, "PREPARING MOVE FILE")
|
||||||
}
|
}
|
||||||
override fun onFailed(errorCode:ErrorCode) {
|
override fun onFailed(errorCode:ErrorCode) {
|
||||||
Log.e(tag, "FAILED MOVE FILE $errorCode")
|
Log.e(tag, "FAILED MOVE FILE $errorCode")
|
||||||
|
|
||||||
docfile?.delete()
|
docfile?.delete()
|
||||||
coverDocFile?.delete()
|
coverDocFile?.delete()
|
||||||
|
|
||||||
|
@ -353,6 +369,7 @@ class AudioDownloader : Plugin() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// After file is downloaded, move the files into an audiobook directory inside the user selected folder
|
||||||
val executorService: ExecutorService = Executors.newFixedThreadPool(4)
|
val executorService: ExecutorService = Executors.newFixedThreadPool(4)
|
||||||
executorService.execute {
|
executorService.execute {
|
||||||
if (id == coverDownloadId) {
|
if (id == coverDownloadId) {
|
||||||
|
|
|
@ -109,11 +109,13 @@ export default {
|
||||||
// })
|
// })
|
||||||
// },
|
// },
|
||||||
async checkForUpdate() {
|
async checkForUpdate() {
|
||||||
|
console.log('Checking for app update')
|
||||||
const result = await AppUpdate.getAppUpdateInfo()
|
const result = await AppUpdate.getAppUpdateInfo()
|
||||||
if (!result) {
|
if (!result) {
|
||||||
console.error('Invalid version check')
|
console.error('Invalid version check')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
console.log('App Update Info', JSON.stringify(result))
|
||||||
this.$store.commit('setAppUpdateInfo', result)
|
this.$store.commit('setAppUpdateInfo', result)
|
||||||
if (result.updateAvailability === 2) {
|
if (result.updateAvailability === 2) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "audiobookshelf-app",
|
"name": "audiobookshelf-app",
|
||||||
"version": "v0.9.4-beta",
|
"version": "v0.9.5-beta",
|
||||||
"author": "advplyr",
|
"author": "advplyr",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxt --hostname localhost --port 1337",
|
"dev": "nuxt --hostname localhost --port 1337",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue