diff --git a/CHANGELOG.md b/CHANGELOG.md index 3af47ee7..6c4a47c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 @@ -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 diff --git a/app/src/main/kotlin/org/fossify/filemanager/activities/DecompressActivity.kt b/app/src/main/kotlin/org/fossify/filemanager/activities/DecompressActivity.kt index 90dc83e9..9cd61462 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/activities/DecompressActivity.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/activities/DecompressActivity.kt @@ -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 }) { allFiles.add( ListItem( mPath = filename, @@ -278,12 +284,6 @@ class DecompressActivity : SimpleActivity() { ) ) } - - runOnUiThread { - binding.progressIndicator.hide() - } - - callback() } private fun askForPassword() { diff --git a/app/src/main/kotlin/org/fossify/filemanager/fragments/ItemsFragment.kt b/app/src/main/kotlin/org/fossify/filemanager/fragments/ItemsFragment.kt index d7589648..c3555c98 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/fragments/ItemsFragment.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/fragments/ItemsFragment.kt @@ -82,6 +82,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF itemsSwipeRefresh.isEnabled = lastSearchedText.isEmpty() && activity?.config?.enablePullToRefresh != false } + refreshFragment() } override fun setupFontSize() {