Skip to content

Commit 5d8ee73

Browse files
authored
Merge branch 'main' into file-in-hidden-folder-shown-217
2 parents bcea718 + eb4d38d commit 5d8ee73

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Fixed printing text files containing a "#" ([#104])
1313
- Fixed files in hidden folders showing up in recent tab ([#217])
1414

15+
### Added
16+
- Added a separate "Save as" option in the text editor ([#224])
17+
18+
### Changed
19+
- Save button now overwrites files directly in the text editor ([#224])
20+
1521
## [1.2.3] - 2025-09-15
1622
### Fixed
1723
- Fixed folders showing up incorrectly as files in some cases ([#80])
@@ -81,6 +87,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8187
[#250]: https://github.com/FossifyOrg/File-Manager/issues/250
8288
[#85]: https://github.com/FossifyOrg/File-Manager/issues/85
8389
[#104]: https://github.com/FossifyOrg/File-Manager/issues/104
90+
[#224]: https://github.com/FossifyOrg/File-Manager/issues/224
8491
[#217]: https://github.com/FossifyOrg/File-Manager/issues/217
8592

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

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ class ReadTextActivity : SimpleActivity() {
144144
when (menuItem.itemId) {
145145
R.id.menu_search -> openSearch()
146146
R.id.menu_save -> saveText()
147+
R.id.menu_save_as -> saveAsText()
147148
R.id.menu_open_with -> openPath(intent.dataString!!, true)
148149
R.id.menu_print -> printText()
149150
else -> return@setOnMenuItemClickListener false
@@ -165,10 +166,14 @@ class ReadTextActivity : SimpleActivity() {
165166
}, 250)
166167
}
167168

168-
private fun saveText(shouldExitAfterSaving: Boolean = false) {
169+
private fun updateFilePath() {
169170
if (filePath.isEmpty()) {
170171
filePath = getRealPathFromURI(intent.data!!) ?: ""
171172
}
173+
}
174+
175+
private fun saveAsText(shouldExitAfterSaving: Boolean = false) {
176+
updateFilePath()
172177

173178
if (filePath.isEmpty()) {
174179
SaveAsDialog(this, filePath, true) { _, filename ->
@@ -182,6 +187,7 @@ class ReadTextActivity : SimpleActivity() {
182187
} else {
183188
SELECT_SAVE_FILE_INTENT
184189
}
190+
@Suppress("DEPRECATION")
185191
startActivityForResult(this, requestCode)
186192
}
187193
}
@@ -200,6 +206,21 @@ class ReadTextActivity : SimpleActivity() {
200206
}
201207
}
202208

209+
private fun saveText(shouldExitAfterSaving: Boolean = false) {
210+
updateFilePath()
211+
212+
if (filePath.isEmpty()) {
213+
saveAsText(shouldExitAfterSaving)
214+
} else if (hasStoragePermission()) {
215+
val file = File(filePath)
216+
getFileOutputStream(file.toFileDirItem(this), true) {
217+
saveTextContent(it, shouldExitAfterSaving, true)
218+
}
219+
} else {
220+
toast(R.string.no_storage_permissions)
221+
}
222+
}
223+
203224
private fun saveTextContent(outputStream: OutputStream?, shouldExitAfterSaving: Boolean, shouldOverwriteOriginalText: Boolean) {
204225
if (outputStream != null) {
205226
val currentText = binding.readTextView.text.toString()

app/src/main/res/menu/menu_editor.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@
1111
<item
1212
android:id="@+id/menu_save"
1313
android:icon="@drawable/ic_save_vector"
14-
android:title="@string/save_as"
14+
android:title="@string/save"
1515
app:showAsAction="always" />
16+
<item
17+
android:id="@+id/menu_save_as"
18+
android:showAsAction="never"
19+
android:title="@string/save_as"
20+
app:showAsAction="never" />
1621
<item
1722
android:id="@+id/menu_print"
1823
android:icon="@drawable/ic_print_vector"

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ detektCompose = "0.4.27"
88
androidx-swiperefreshlayout = "1.1.0"
99
androidx-documentfile = "1.1.0"
1010
#Fossify
11-
commons = "5.1.1"
11+
commons = "5.2.0"
1212
#Other
1313
autofittextview = "0.2.1"
1414
gestureviews = "2.8.3"

0 commit comments

Comments
 (0)