mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
adding some OTG file recycle bin related improvements
This commit is contained in:
parent
04ecb6e0b4
commit
1c7fbc19ad
3 changed files with 16 additions and 5 deletions
|
@ -62,7 +62,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.18.26'
|
implementation 'com.simplemobiletools:commons:5.18.27'
|
||||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
||||||
implementation 'androidx.multidex:multidex:2.0.1'
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||||
|
|
|
@ -891,7 +891,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun tryDeleteFiles(fileDirItems: ArrayList<FileDirItem>) {
|
override fun tryDeleteFiles(fileDirItems: ArrayList<FileDirItem>) {
|
||||||
val filtered = fileDirItems.filter { File(it.path).isFile && it.path.isMediaFile() } as ArrayList
|
val filtered = fileDirItems.filter { !getIsPathDirectory(it.path) && it.path.isMediaFile() } as ArrayList
|
||||||
if (filtered.isEmpty()) {
|
if (filtered.isEmpty()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ fun BaseSimpleActivity.movePathsInRecycleBin(paths: ArrayList<String>, mediumDao
|
||||||
|
|
||||||
out?.flush()
|
out?.flush()
|
||||||
|
|
||||||
if (fileDocument?.getItemSize(false) == copiedSize && getDoesFilePathExist(destination)) {
|
if (fileDocument?.getItemSize(true) == copiedSize && getDoesFilePathExist(destination)) {
|
||||||
mediumDao.updateDeleted("$RECYCLE_BIN$source", System.currentTimeMillis(), source)
|
mediumDao.updateDeleted("$RECYCLE_BIN$source", System.currentTimeMillis(), source)
|
||||||
pathsCnt--
|
pathsCnt--
|
||||||
}
|
}
|
||||||
|
@ -306,8 +306,19 @@ fun BaseSimpleActivity.restoreRecycleBinPaths(paths: ArrayList<String>, mediumDa
|
||||||
try {
|
try {
|
||||||
out = getFileOutputStreamSync(destination, source.getMimeType())
|
out = getFileOutputStreamSync(destination, source.getMimeType())
|
||||||
inputStream = getFileInputStreamSync(source)
|
inputStream = getFileInputStreamSync(source)
|
||||||
inputStream!!.copyTo(out!!)
|
|
||||||
if (File(source).length() == File(destination).length()) {
|
var copiedSize = 0L
|
||||||
|
val buffer = ByteArray(DEFAULT_BUFFER_SIZE)
|
||||||
|
var bytes = inputStream!!.read(buffer)
|
||||||
|
while (bytes >= 0) {
|
||||||
|
out!!.write(buffer, 0, bytes)
|
||||||
|
copiedSize += bytes
|
||||||
|
bytes = inputStream.read(buffer)
|
||||||
|
}
|
||||||
|
|
||||||
|
out?.flush()
|
||||||
|
|
||||||
|
if (File(source).length() == copiedSize) {
|
||||||
mediumDao.updateDeleted(destination.removePrefix(recycleBinPath), 0, "$RECYCLE_BIN$destination")
|
mediumDao.updateDeleted(destination.removePrefix(recycleBinPath), 0, "$RECYCLE_BIN$destination")
|
||||||
}
|
}
|
||||||
newPaths.add(destination)
|
newPaths.add(destination)
|
||||||
|
|
Loading…
Reference in a new issue