mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +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,10 +123,11 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
var hiddenCnt = 0
|
||||
var unhiddenCnt = 0
|
||||
selectedPositions.mapNotNull { dirs.getOrNull(it)?.path }.forEach {
|
||||
if (File(it).containsNoMedia())
|
||||
if (File(it).containsNoMedia()) {
|
||||
hiddenCnt++
|
||||
else
|
||||
} else {
|
||||
unhiddenCnt++
|
||||
}
|
||||
}
|
||||
|
||||
menu.findItem(R.id.cab_hide).isVisible = unhiddenCnt > 0
|
||||
|
@ -138,10 +139,11 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
var pinnedCnt = 0
|
||||
var unpinnedCnt = 0
|
||||
selectedPositions.mapNotNull { dirs.getOrNull(it)?.path }.forEach {
|
||||
if (pinnedFolders.contains(it))
|
||||
if (pinnedFolders.contains(it)) {
|
||||
pinnedCnt++
|
||||
else
|
||||
} else {
|
||||
unpinnedCnt++
|
||||
}
|
||||
}
|
||||
|
||||
menu.findItem(R.id.cab_pin).isVisible = unpinnedCnt > 0
|
||||
|
|
|
@ -224,11 +224,11 @@ fun SimpleActivity.addNoMedia(path: String, callback: () -> Unit) {
|
|||
|
||||
if (needsStupidWritePermissions(path)) {
|
||||
handleSAFDialog(file) {
|
||||
try {
|
||||
getFileDocument(path)?.createFile("", NOMEDIA)
|
||||
} catch (e: Exception) {
|
||||
val fileDocument = getFileDocument(path)
|
||||
if (fileDocument?.exists() == true && fileDocument.isDirectory) {
|
||||
fileDocument.createFile("", NOMEDIA)
|
||||
} else
|
||||
toast(R.string.unknown_error_occurred)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue