mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
add an extra check at creating .nomedia file on the SD card
This commit is contained in:
parent
7132e09047
commit
2dbbc2bbdb
2 changed files with 10 additions and 8 deletions
|
@ -123,11 +123,12 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
var hiddenCnt = 0
|
var hiddenCnt = 0
|
||||||
var unhiddenCnt = 0
|
var unhiddenCnt = 0
|
||||||
selectedPositions.mapNotNull { dirs.getOrNull(it)?.path }.forEach {
|
selectedPositions.mapNotNull { dirs.getOrNull(it)?.path }.forEach {
|
||||||
if (File(it).containsNoMedia())
|
if (File(it).containsNoMedia()) {
|
||||||
hiddenCnt++
|
hiddenCnt++
|
||||||
else
|
} else {
|
||||||
unhiddenCnt++
|
unhiddenCnt++
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
menu.findItem(R.id.cab_hide).isVisible = unhiddenCnt > 0
|
menu.findItem(R.id.cab_hide).isVisible = unhiddenCnt > 0
|
||||||
menu.findItem(R.id.cab_unhide).isVisible = hiddenCnt > 0
|
menu.findItem(R.id.cab_unhide).isVisible = hiddenCnt > 0
|
||||||
|
@ -138,11 +139,12 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
var pinnedCnt = 0
|
var pinnedCnt = 0
|
||||||
var unpinnedCnt = 0
|
var unpinnedCnt = 0
|
||||||
selectedPositions.mapNotNull { dirs.getOrNull(it)?.path }.forEach {
|
selectedPositions.mapNotNull { dirs.getOrNull(it)?.path }.forEach {
|
||||||
if (pinnedFolders.contains(it))
|
if (pinnedFolders.contains(it)) {
|
||||||
pinnedCnt++
|
pinnedCnt++
|
||||||
else
|
} else {
|
||||||
unpinnedCnt++
|
unpinnedCnt++
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
menu.findItem(R.id.cab_pin).isVisible = unpinnedCnt > 0
|
menu.findItem(R.id.cab_pin).isVisible = unpinnedCnt > 0
|
||||||
menu.findItem(R.id.cab_unpin).isVisible = pinnedCnt > 0
|
menu.findItem(R.id.cab_unpin).isVisible = pinnedCnt > 0
|
||||||
|
|
|
@ -224,12 +224,12 @@ fun SimpleActivity.addNoMedia(path: String, callback: () -> Unit) {
|
||||||
|
|
||||||
if (needsStupidWritePermissions(path)) {
|
if (needsStupidWritePermissions(path)) {
|
||||||
handleSAFDialog(file) {
|
handleSAFDialog(file) {
|
||||||
try {
|
val fileDocument = getFileDocument(path)
|
||||||
getFileDocument(path)?.createFile("", NOMEDIA)
|
if (fileDocument?.exists() == true && fileDocument.isDirectory) {
|
||||||
} catch (e: Exception) {
|
fileDocument.createFile("", NOMEDIA)
|
||||||
|
} else
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
file.createNewFile()
|
file.createNewFile()
|
||||||
|
|
Loading…
Reference in a new issue