Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- Fixed files from hidden folders showing up in storage tab browser ([#217])
- Fixed duplicated folders in decompressActivity ([#76])
- Fixed missing refresh after resume to fragment ([#194])

## [1.3.0] - 2025-09-30
### Added
Expand Down Expand Up @@ -80,6 +82,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[#27]: https://github.com/FossifyOrg/File-Manager/issues/27
[#37]: https://github.com/FossifyOrg/File-Manager/issues/37
[#76]: https://github.com/FossifyOrg/File-Manager/issues/76
[#80]: https://github.com/FossifyOrg/File-Manager/issues/80
[#85]: https://github.com/FossifyOrg/File-Manager/issues/85
[#95]: https://github.com/FossifyOrg/File-Manager/issues/95
Expand All @@ -91,6 +94,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#149]: https://github.com/FossifyOrg/File-Manager/issues/149
[#150]: https://github.com/FossifyOrg/File-Manager/issues/150
[#176]: https://github.com/FossifyOrg/File-Manager/issues/176
[#194]: https://github.com/FossifyOrg/File-Manager/issues/194
[#217]: https://github.com/FossifyOrg/File-Manager/issues/217
[#224]: https://github.com/FossifyOrg/File-Manager/issues/224
[#250]: https://github.com/FossifyOrg/File-Manager/issues/250
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,57 +214,63 @@ class DecompressActivity : SimpleActivity() {
}

private fun fillAllListItems(uri: Uri, callback: () -> Unit) = ensureBackgroundThread {
val inputStream = try {
contentResolver.openInputStream(uri)
val zipStream = openZipInputStream(uri) ?: return@ensureBackgroundThread
processZipEntries(zipStream)
runOnUiThread { binding.progressIndicator.hide() }
callback()
}

private fun openZipInputStream(uri: Uri): ZipInputStream? {
return try {
val inputStream = contentResolver.openInputStream(uri)
ZipInputStream(BufferedInputStream(inputStream)).apply {
password?.let { setPassword(it.toCharArray()) }
}
} catch (e: Exception) {
showErrorToast(e)
return@ensureBackgroundThread
null
}
}

val zipInputStream = ZipInputStream(BufferedInputStream(inputStream))
if (password != null) {
zipInputStream.setPassword(password?.toCharArray())
}
private fun processZipEntries(zipInputStream: ZipInputStream) {
var zipEntry: LocalFileHeader?
while (true) {
try {
zipEntry = zipInputStream.nextEntry
} catch (passwordException: ZipException) {
if (passwordException.type == Type.WRONG_PASSWORD) {
if (password != null) {
toast(getString(R.string.invalid_password))
passwordDialog?.clearPassword()
} else {
runOnUiThread {
askForPassword()
}
}
return@ensureBackgroundThread
} else {
break
}
} catch (ignored: Exception) {
zipEntry = zipInputStream.nextEntry ?: break
} catch (e: ZipException) {
handleZipException(e)
break
}
handleZipEntry(zipEntry)
}
}

if (zipEntry == null) {
break
private fun handleZipException(e: ZipException) {
if (e.type == Type.WRONG_PASSWORD) {
if (password != null) {
toast(getString(R.string.invalid_password))
passwordDialog?.clearPassword()
} else {
runOnUiThread { askForPassword() }
}
} else {
showErrorToast(e)
}
}

// Show progress bar only after password dialog is dismissed.
runOnUiThread {
if (binding.progressIndicator.isGone()) {
binding.progressIndicator.show()
}
private fun handleZipEntry(zipEntry: LocalFileHeader) {
runOnUiThread {
if (binding.progressIndicator.isGone()) {
binding.progressIndicator.show()
}
}
passwordDialog?.dismiss(notify = false)
passwordDialog = null

if (passwordDialog != null) {
passwordDialog?.dismiss(notify = false)
passwordDialog = null
}
val filename = zipEntry.fileName.removeSuffix("/")
val lastModified = zipEntry.lastModifiedTime

val lastModified = zipEntry.lastModifiedTime
val filename = zipEntry.fileName.removeSuffix("/")
if (allFiles.none { it.mPath == filename }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, you are not fixing the root cause, i.e., the source of duplication. This filtering will also slow things down a bit on large archives.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: #301

allFiles.add(
ListItem(
mPath = filename,
Expand All @@ -278,12 +284,6 @@ class DecompressActivity : SimpleActivity() {
)
)
}

runOnUiThread {
binding.progressIndicator.hide()
}

callback()
}

private fun askForPassword() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF

itemsSwipeRefresh.isEnabled = lastSearchedText.isEmpty() && activity?.config?.enablePullToRefresh != false
}
refreshFragment()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reloading on every resume will be inefficient. That's why I didn't suggest it in #273.

}

override fun setupFontSize() {
Expand Down
Loading