From 167fd983a78550223e1f201e1c9678d12dfc0f5d Mon Sep 17 00:00:00 2001 From: Jan Guegel Date: Thu, 2 Oct 2025 10:58:14 +0200 Subject: [PATCH 1/8] fix removing double getIsPathDirectory code --- .../org/fossify/filemanager/adapters/ItemsAdapter.kt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/filemanager/adapters/ItemsAdapter.kt b/app/src/main/kotlin/org/fossify/filemanager/adapters/ItemsAdapter.kt index 67712316..69b575f7 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/adapters/ItemsAdapter.kt @@ -831,16 +831,6 @@ class ItemsAdapter( val base = "${mainFilePath.getParentPath()}/" res = zout queue.push(mainFilePath) - if (activity.getIsPathDirectory(mainFilePath)) { - name = "${mainFilePath.getFilenameFromPath()}/" - val dirModified = File(mainFilePath).lastModified() - zout.putNextEntry( - ZipParameters().also { - it.fileNameInZip = name - it.lastModifiedFileTime = dirModified - } - ) - } while (!queue.isEmpty()) { mainFilePath = queue.pop() From 957c02349ec07b4070078559e97405f3440353e0 Mon Sep 17 00:00:00 2001 From: Jan Guegel Date: Wed, 8 Oct 2025 14:08:42 +0200 Subject: [PATCH 2/8] fix removing double getIsPathDirectory code --- .../org/fossify/filemanager/adapters/ItemsAdapter.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/kotlin/org/fossify/filemanager/adapters/ItemsAdapter.kt b/app/src/main/kotlin/org/fossify/filemanager/adapters/ItemsAdapter.kt index 69b575f7..67712316 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/adapters/ItemsAdapter.kt @@ -831,6 +831,16 @@ class ItemsAdapter( val base = "${mainFilePath.getParentPath()}/" res = zout queue.push(mainFilePath) + if (activity.getIsPathDirectory(mainFilePath)) { + name = "${mainFilePath.getFilenameFromPath()}/" + val dirModified = File(mainFilePath).lastModified() + zout.putNextEntry( + ZipParameters().also { + it.fileNameInZip = name + it.lastModifiedFileTime = dirModified + } + ) + } while (!queue.isEmpty()) { mainFilePath = queue.pop() From 47675f5e0adc6d20e78a120a04d938db2d24accc Mon Sep 17 00:00:00 2001 From: Jan Guegel Date: Wed, 8 Oct 2025 14:28:40 +0200 Subject: [PATCH 3/8] fix double folders for password protected zip --- .../activities/DecompressActivity.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) 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..e83a9e0f 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/activities/DecompressActivity.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/activities/DecompressActivity.kt @@ -265,18 +265,20 @@ class DecompressActivity : SimpleActivity() { val lastModified = zipEntry.lastModifiedTime val filename = zipEntry.fileName.removeSuffix("/") - allFiles.add( - ListItem( - mPath = filename, - mName = filename.getFilenameFromPath(), - mIsDirectory = zipEntry.isDirectory, - mChildren = 0, - mSize = 0L, - mModified = lastModified, - isSectionTitle = false, - isGridTypeDivider = false + if (allFiles.none { it.mPath == filename }) { + allFiles.add( + ListItem( + mPath = filename, + mName = filename.getFilenameFromPath(), + mIsDirectory = zipEntry.isDirectory, + mChildren = 0, + mSize = 0L, + mModified = lastModified, + isSectionTitle = false, + isGridTypeDivider = false + ) ) - ) + } } runOnUiThread { From 4bb0d160612e329724706c4c6b3480a5c52b2596 Mon Sep 17 00:00:00 2001 From: Jan Guegel Date: Wed, 8 Oct 2025 14:50:58 +0200 Subject: [PATCH 4/8] add refreshFragment when resuming --- .../kotlin/org/fossify/filemanager/fragments/ItemsFragment.kt | 1 + 1 file changed, 1 insertion(+) 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() { From a08c9d027568e836f20a25e0ec8548183ae3b40e Mon Sep 17 00:00:00 2001 From: Jan Guegel Date: Wed, 8 Oct 2025 14:55:02 +0200 Subject: [PATCH 5/8] update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3af47ee7..14b2a2fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ 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 +83,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 +95,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 From 4c581c477b2bbce94b1425fa667c845b576c2e17 Mon Sep 17 00:00:00 2001 From: Jan Guegel Date: Wed, 8 Oct 2025 14:55:22 +0200 Subject: [PATCH 6/8] update changelog --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14b2a2fa..8208f12d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed duplicated folders in decompressActivity ([#76]) - Fixed missing refresh after resume to fragment ([194]) - ## [1.3.0] - 2025-09-30 ### Added - Added a separate "Save as" option in the text editor ([#224]) From e7eda60097449b89ae5ca69a2a309b0a32467e59 Mon Sep 17 00:00:00 2001 From: Jan Guegel Date: Wed, 8 Oct 2025 14:55:45 +0200 Subject: [PATCH 7/8] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8208f12d..6c4a47c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### 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]) +- Fixed missing refresh after resume to fragment ([#194]) ## [1.3.0] - 2025-09-30 ### Added From 63edcc0162fa47273f73632bc32c8b292d56ea45 Mon Sep 17 00:00:00 2001 From: Jan Guegel Date: Wed, 8 Oct 2025 15:25:21 +0200 Subject: [PATCH 8/8] fix detekt complexMethod by using smaller functions --- .../activities/DecompressActivity.kt | 112 +++++++++--------- 1 file changed, 55 insertions(+), 57 deletions(-) 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 e83a9e0f..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,78 +214,76 @@ 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) { - break - } - - if (zipEntry == null) { + zipEntry = zipInputStream.nextEntry ?: break + } catch (e: ZipException) { + handleZipException(e) break } + handleZipEntry(zipEntry) + } + } - // Show progress bar only after password dialog is dismissed. - runOnUiThread { - if (binding.progressIndicator.isGone()) { - binding.progressIndicator.show() - } - } - - if (passwordDialog != null) { - passwordDialog?.dismiss(notify = false) - passwordDialog = null - } - - val lastModified = zipEntry.lastModifiedTime - val filename = zipEntry.fileName.removeSuffix("/") - if (allFiles.none { it.mPath == filename }) { - allFiles.add( - ListItem( - mPath = filename, - mName = filename.getFilenameFromPath(), - mIsDirectory = zipEntry.isDirectory, - mChildren = 0, - mSize = 0L, - mModified = lastModified, - isSectionTitle = false, - isGridTypeDivider = false - ) - ) + 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) } + } + private fun handleZipEntry(zipEntry: LocalFileHeader) { runOnUiThread { - binding.progressIndicator.hide() + if (binding.progressIndicator.isGone()) { + binding.progressIndicator.show() + } + } + passwordDialog?.dismiss(notify = false) + passwordDialog = null + + val filename = zipEntry.fileName.removeSuffix("/") + val lastModified = zipEntry.lastModifiedTime + + if (allFiles.none { it.mPath == filename }) { + allFiles.add( + ListItem( + mPath = filename, + mName = filename.getFilenameFromPath(), + mIsDirectory = zipEntry.isDirectory, + mChildren = 0, + mSize = 0L, + mModified = lastModified, + isSectionTitle = false, + isGridTypeDivider = false + ) + ) } - - callback() } private fun askForPassword() {