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