allow selecting Cover photo from any folder
This commit is contained in:
parent
021a1cbf74
commit
7132e09047
3 changed files with 42 additions and 23 deletions
|
@ -215,10 +215,11 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
}
|
||||
|
||||
private fun pinFolders(pin: Boolean) {
|
||||
if (pin)
|
||||
if (pin) {
|
||||
config.addPinnedFolders(getSelectedPaths())
|
||||
else
|
||||
} else {
|
||||
config.removePinnedFolders(getSelectedPaths())
|
||||
}
|
||||
|
||||
pinnedFolders = config.pinnedFolders
|
||||
listener?.recheckPinnedFolders()
|
||||
|
@ -302,20 +303,30 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
return
|
||||
|
||||
val path = dirs[selectedPositions.first()].path
|
||||
var albumCovers = config.parseAlbumCovers()
|
||||
|
||||
if (useDefault) {
|
||||
albumCovers = albumCovers.filterNot { it.path == path } as ArrayList
|
||||
val albumCovers = getAlbumCoversWithout(path)
|
||||
storeCovers(albumCovers)
|
||||
} else {
|
||||
pickMediumFrom(path, path)
|
||||
}
|
||||
}
|
||||
|
||||
private fun pickMediumFrom(targetFolder: String, path: String) {
|
||||
PickMediumDialog(activity, path) {
|
||||
albumCovers = albumCovers.filterNot { it.path == path } as ArrayList
|
||||
albumCovers.add(AlbumCover(path, it))
|
||||
if (File(it).isDirectory) {
|
||||
pickMediumFrom(targetFolder, it)
|
||||
} else {
|
||||
val albumCovers = getAlbumCoversWithout(path)
|
||||
val cover = AlbumCover(targetFolder, it)
|
||||
albumCovers.add(cover)
|
||||
storeCovers(albumCovers)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAlbumCoversWithout(path: String) = config.parseAlbumCovers().filterNot { it.path == path } as ArrayList
|
||||
|
||||
private fun storeCovers(albumCovers: ArrayList<AlbumCover>) {
|
||||
activity.config.albumCovers = Gson().toJson(albumCovers)
|
||||
actMode?.finish()
|
||||
|
|
|
@ -37,6 +37,7 @@ class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String,
|
|||
.setNeutralButton(R.string.other_folder, { dialogInterface, i -> showOtherFolder() })
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.select_destination)
|
||||
}
|
||||
|
||||
val dirs = activity.getCachedDirectories()
|
||||
if (dirs.isNotEmpty()) {
|
||||
|
@ -47,7 +48,6 @@ class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String,
|
|||
gotDirectories(activity.addTempFolderIfNeeded(it))
|
||||
}.execute()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showOtherFolder() {
|
||||
val showHidden = activity.config.shouldShowHidden
|
||||
|
|
|
@ -31,8 +31,10 @@ class PickMediumDialog(val activity: SimpleActivity, val path: String, val callb
|
|||
dialog = AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setNeutralButton(R.string.other_folder, { dialogInterface, i -> showOtherFolder() })
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.select_photo)
|
||||
}
|
||||
|
||||
val media = activity.getCachedMedia(path).filter { !it.video } as ArrayList
|
||||
if (media.isNotEmpty()) {
|
||||
|
@ -43,6 +45,12 @@ class PickMediumDialog(val activity: SimpleActivity, val path: String, val callb
|
|||
gotMedia(it)
|
||||
}.execute()
|
||||
}
|
||||
|
||||
private fun showOtherFolder() {
|
||||
PickDirectoryDialog(activity, path) {
|
||||
callback(it)
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
private fun gotMedia(media: ArrayList<Medium>) {
|
||||
|
|
Loading…
Reference in a new issue