Skip to content

add save as in menu in TextEditor#277

Merged
naveensingh merged 4 commits intoFossifyOrg:mainfrom
jguegel:change-to-save-224
Sep 29, 2025
Merged

add save as in menu in TextEditor#277
naveensingh merged 4 commits intoFossifyOrg:mainfrom
jguegel:change-to-save-224

Conversation

@jguegel
Copy link
Copy Markdown
Contributor

@jguegel jguegel commented Sep 29, 2025

Type of change(s)

  • Bug fix
  • Feature / enhancement
  • Infrastructure / tooling (CI, build, deps, tests)
  • Documentation

What changed and why

  • add save as in menu
  • rename saveText to saveAsText()
  • add new save() without confirmation

Unsure about:

  • added deprecation-Tag because otherwise I couldn't build locally
@Suppress("DEPRECATION")
startActivityForResult(this, requestCode)
  • using same icon for Save and Save as
    Suggested idea, change order to:
  1. Print displayed as Action ifRoom
  2. Save As displayed as Action never
  3. Open with displayed as Action never

Tests performed

  • new Save-Button saves without confirmation
  • Save As-Button uses old Save Logic

Before & after preview

  • new "Save as"-menuItem in TextEditor
image

Closes the following issue(s)

Checklist

  • I read the contribution guidelines.
  • I manually tested my changes on device/emulator (if applicable).
  • I updated the "Unreleased" section in CHANGELOG.md (if applicable).
  • I have self-reviewed my pull request (no typos, formatting errors, etc.).
  • All checks are passing.

Jan Guegel added 2 commits September 29, 2025 13:58
rename saveText to saveAsText()
add new save() without confirmation

Signed-off-by: Jan Guegel <jan@guegel.eu>
Signed-off-by: Jan Guegel <jan@guegel.eu>
Comment thread app/src/main/kotlin/org/fossify/filemanager/activities/ReadTextActivity.kt Outdated
Comment thread app/src/main/kotlin/org/fossify/filemanager/activities/ReadTextActivity.kt Outdated
Comment thread app/src/main/kotlin/org/fossify/filemanager/activities/ReadTextActivity.kt Outdated
Comment thread app/src/main/kotlin/org/fossify/filemanager/activities/ReadTextActivity.kt Outdated
Comment thread app/src/main/res/menu/menu_editor.xml Outdated
Comment thread CHANGELOG.md
@naveensingh
Copy link
Copy Markdown
Member

Bug-ish: It still displays a confirmation dialog when pressing back without saving and then pressing Save on the unsaved changes dialog.

getFilePath to updateFilePath
menuItem SaveAs never displayed with icon
backButtonPressed now uses Save without confirmation

Signed-off-by: Jan Guegel <jan@guegel.eu>
@jguegel
Copy link
Copy Markdown
Contributor Author

jguegel commented Sep 29, 2025

fixed the back button issue and applied your code review feedback.
hopefully the quality is getting better

@jguegel jguegel requested a review from naveensingh September 29, 2025 13:13
Copy link
Copy Markdown
Member

@naveensingh naveensingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hopefully the quality is getting better

Yeah, if you keep at it, you'll put me out of a job in a year or two.

@jguegel
Copy link
Copy Markdown
Contributor Author

jguegel commented Sep 29, 2025

@naveensingh i am thinking about this, am i on the right track?

private fun isCloudFile(): Boolean {
    if (intent.data?.scheme == "content") {
        return true
    }
    
    return isRestrictedSAFOnlyRoot(filePath)
}

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

    if (filePath.isEmpty() || isCloudFile()) {
        saveAsText(shouldExitAfterSaving)
    } else if (hasStoragePermission()) {
        val file = File(filePath)
        getFileOutputStream(file.toFileDirItem(this), true) {
            saveTextContent(it, shouldExitAfterSaving, true)
        }
    } else {
        toast(R.string.no_storage_permissions)
    }
}

it looks like intent.data?.scheme == "content" is always true...

Signed-off-by: Jan Guegel <jan@guegel.eu>
@jguegel
Copy link
Copy Markdown
Contributor Author

jguegel commented Sep 29, 2025

I can't find a proper solution and not sure how to test it, therefore i go with filePath.isEmpty() for now
idea, but not sure how to test, since my phone is not rooted neither to i have external content
if (filePath.isEmpty() || filePath == "external" || filePath == isRestrictedSAFOnlyRoot(filePath))

Copy link
Copy Markdown
Member

@naveensingh naveensingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix it later, thanks.

@naveensingh naveensingh merged commit 8647071 into FossifyOrg:main Sep 29, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not show Overwrite dialog when you're editing an already existing file and add "Save as" option

2 participants