From 630d7b2cea6720f772b19e35d6003b33786a4316 Mon Sep 17 00:00:00 2001 From: Jan <4600407+jguegel@users.noreply.github.com> Date: Sun, 28 Sep 2025 09:47:40 +0200 Subject: [PATCH] fix: avoid truncated prints (#275) * fix change print enconding to base64 #104 Signed-off-by: Jan Guegel * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Naveen Singh <36371707+naveensingh@users.noreply.github.com> * use ensureBackgroundThread to avoid ANR on large files Signed-off-by: Jan Guegel --------- Signed-off-by: Jan Guegel Co-authored-by: Jan Guegel Co-authored-by: Naveen Singh <36371707+naveensingh@users.noreply.github.com> --- CHANGELOG.md | 2 ++ .../filemanager/activities/ReadTextActivity.kt | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d48133b..c8359a95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed folders showing up incorrectly as files in copy/move dialog ([#267]) - Fixed error when saving files with unsupported characters ([#250]) - Fixed missing permission prompt on initial "Save as" launch ([#85]) +- Fixed printing text files containing a "#" ([#104]) ## [1.2.3] - 2025-09-15 ### Fixed @@ -78,6 +79,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#267]: https://github.com/FossifyOrg/File-Manager/issues/267 [#250]: https://github.com/FossifyOrg/File-Manager/issues/250 [#85]: https://github.com/FossifyOrg/File-Manager/issues/85 +[#104]: https://github.com/FossifyOrg/File-Manager/issues/104 [Unreleased]: https://github.com/FossifyOrg/File-Manager/compare/1.2.3...HEAD [1.2.3]: https://github.com/FossifyOrg/File-Manager/compare/1.2.2...1.2.3 diff --git a/app/src/main/kotlin/org/fossify/filemanager/activities/ReadTextActivity.kt b/app/src/main/kotlin/org/fossify/filemanager/activities/ReadTextActivity.kt index c01aed37..4e7678cf 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/activities/ReadTextActivity.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/activities/ReadTextActivity.kt @@ -7,6 +7,7 @@ import android.net.Uri import android.os.Bundle import android.print.PrintAttributes import android.print.PrintManager +import android.util.Base64 import android.view.inputmethod.EditorInfo import android.webkit.WebResourceRequest import android.webkit.WebView @@ -229,7 +230,17 @@ class ReadTextActivity : SimpleActivity() { } } - webView.loadData(binding.readTextView.text.toString(), "text/plain", "UTF-8") + val text = binding.readTextView.text.toString() + ensureBackgroundThread { + try { + val base64 = Base64.encodeToString(text.toByteArray(), Base64.DEFAULT) + runOnUiThread { + webView.loadData(base64, "text/plain", "base64") + } + } catch (e: Exception) { + showErrorToast(e) + } + } } catch (e: Exception) { showErrorToast(e) }