Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed missing permission prompt on initial "Save as" launch ([#85])
- Fixed printing text files containing a "#" ([#104])

### Changed
- "Save as" moved to menu in Text Editor ([#224])

Comment thread
jguegel marked this conversation as resolved.
## [1.2.3] - 2025-09-15
### Fixed
- Fixed folders showing up incorrectly as files in some cases ([#80])
Expand Down Expand Up @@ -80,6 +83,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#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
[#224]: https://github.com/FossifyOrg/File-Manager/issues/224

[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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class ReadTextActivity : SimpleActivity() {
lastSavePromptTS = System.currentTimeMillis()
ConfirmationAdvancedDialog(this, "", R.string.save_before_closing, R.string.save, R.string.discard) {
if (it) {
saveText(true)
saveAsText(true)
} else {
super.onBackPressed()
}
Expand All @@ -144,6 +144,7 @@ class ReadTextActivity : SimpleActivity() {
when (menuItem.itemId) {
R.id.menu_search -> openSearch()
R.id.menu_save -> saveText()
R.id.menu_save_as -> saveAsText()
R.id.menu_open_with -> openPath(intent.dataString!!, true)
R.id.menu_print -> printText()
else -> return@setOnMenuItemClickListener false
Expand All @@ -165,10 +166,14 @@ class ReadTextActivity : SimpleActivity() {
}, 250)
}

private fun saveText(shouldExitAfterSaving: Boolean = false) {
private fun getFilePath(){
Comment thread
jguegel marked this conversation as resolved.
Outdated
if (filePath.isEmpty()) {
filePath = getRealPathFromURI(intent.data!!) ?: ""
}
}

private fun saveAsText(shouldExitAfterSaving: Boolean = false) {
getFilePath()

Comment thread
jguegel marked this conversation as resolved.
Outdated
if (filePath.isEmpty()) {
SaveAsDialog(this, filePath, true) { _, filename ->
Expand All @@ -182,6 +187,7 @@ class ReadTextActivity : SimpleActivity() {
} else {
SELECT_SAVE_FILE_INTENT
}
@Suppress("DEPRECATION")
startActivityForResult(this, requestCode)
}
}
Expand All @@ -200,6 +206,20 @@ class ReadTextActivity : SimpleActivity() {
}
}

private fun saveText(shouldExitAfterSaving: Boolean = false) {
getFilePath()

Comment thread
jguegel marked this conversation as resolved.
Outdated
Comment thread
jguegel marked this conversation as resolved.
if (hasStoragePermission()) {
val file = File(filePath)
getFileOutputStream(file.toFileDirItem(this), true) {
val shouldOverwriteOriginalText = true
saveTextContent(it, shouldExitAfterSaving, shouldOverwriteOriginalText)
Comment thread
jguegel marked this conversation as resolved.
Outdated
}
} else {
toast(R.string.no_storage_permissions)
}
}

private fun saveTextContent(outputStream: OutputStream?, shouldExitAfterSaving: Boolean, shouldOverwriteOriginalText: Boolean) {
if (outputStream != null) {
val currentText = binding.readTextView.text.toString()
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/res/menu/menu_editor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@
<item
android:id="@+id/menu_save"
android:icon="@drawable/ic_save_vector"
android:title="@string/save_as"
android:title="@string/save"
app:showAsAction="always" />
<item
android:id="@+id/menu_save_as"
android:icon="@drawable/ic_save_vector"
android:title="@string/save_as"
app:showAsAction="ifRoom" />
Comment thread
jguegel marked this conversation as resolved.
Outdated
<item
android:id="@+id/menu_print"
android:icon="@drawable/ic_print_vector"
Expand Down
Loading