Skip to content

Commit 630d7b2

Browse files
jguegelJan Guegelnaveensingh
authored
fix: avoid truncated prints (#275)
* fix change print enconding to base64 #104 Signed-off-by: Jan Guegel <jan@guegel.eu> * 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 <jan@guegel.eu> --------- Signed-off-by: Jan Guegel <jan@guegel.eu> Co-authored-by: Jan Guegel <jan@guegel.eu> Co-authored-by: Naveen Singh <36371707+naveensingh@users.noreply.github.com>
1 parent 223e644 commit 630d7b2

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- Fixed folders showing up incorrectly as files in copy/move dialog ([#267])
1010
- Fixed error when saving files with unsupported characters ([#250])
1111
- Fixed missing permission prompt on initial "Save as" launch ([#85])
12+
- Fixed printing text files containing a "#" ([#104])
1213

1314
## [1.2.3] - 2025-09-15
1415
### Fixed
@@ -78,6 +79,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7879
[#267]: https://github.com/FossifyOrg/File-Manager/issues/267
7980
[#250]: https://github.com/FossifyOrg/File-Manager/issues/250
8081
[#85]: https://github.com/FossifyOrg/File-Manager/issues/85
82+
[#104]: https://github.com/FossifyOrg/File-Manager/issues/104
8183

8284
[Unreleased]: https://github.com/FossifyOrg/File-Manager/compare/1.2.3...HEAD
8385
[1.2.3]: https://github.com/FossifyOrg/File-Manager/compare/1.2.2...1.2.3

app/src/main/kotlin/org/fossify/filemanager/activities/ReadTextActivity.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import android.net.Uri
77
import android.os.Bundle
88
import android.print.PrintAttributes
99
import android.print.PrintManager
10+
import android.util.Base64
1011
import android.view.inputmethod.EditorInfo
1112
import android.webkit.WebResourceRequest
1213
import android.webkit.WebView
@@ -229,7 +230,17 @@ class ReadTextActivity : SimpleActivity() {
229230
}
230231
}
231232

232-
webView.loadData(binding.readTextView.text.toString(), "text/plain", "UTF-8")
233+
val text = binding.readTextView.text.toString()
234+
ensureBackgroundThread {
235+
try {
236+
val base64 = Base64.encodeToString(text.toByteArray(), Base64.DEFAULT)
237+
runOnUiThread {
238+
webView.loadData(base64, "text/plain", "base64")
239+
}
240+
} catch (e: Exception) {
241+
showErrorToast(e)
242+
}
243+
}
233244
} catch (e: Exception) {
234245
showErrorToast(e)
235246
}

0 commit comments

Comments
 (0)