Skip to content

Notify user when renaming a file/folder to its original name - #4669

Merged
EmmanuelMess merged 2 commits into
TeamAmaze:release/4.0from
SajalDevX:fix/4660-rename-no-change-warning
Jul 12, 2026
Merged

EmmanuelMess merged 2 commits into
TeamAmaze:release/4.0from
SajalDevX:fix/4660-rename-no-change-warning

Conversation

@SajalDevX

@SajalDevX SajalDevX commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Opening the rename dialog and leaving the EditText value untouched
(typing nothing, or simply not editing) provides no inline feedback
that the operation is a no-op. The user must tap submit, the dialog
closes, and a backend-side Toast appears — or, on plain local files,
nothing visible happens at all. The user has already committed to
tapping a destructive-looking button before being told the rename
will do nothing.

Root cause

The rename dialog's validator lambda in MainFragment.rename(...)
covers only the invalid-filename, leading-space, and empty-text
states. There is no branch that compares the typed text against the
source file's current name and surfaces a result for that condition;
the dialog relies on MainActivityHelper.rename(...) to detect
the no-change case after the user has already submitted.

Fix to #4660

Added an additional branch to the validator lambda that returns
STATE_WARNING carrying R.string.no_changes_while_rename whenever
the typed text equals the source file's name. This renders inline
beneath the EditText through the existing WarnableTextInputLayout
helper-text area — the same surface used by mkfile() for its
hidden-file and .txt-extension warnings — so no new UI elements
are introduced and the layout matches the project's established
pattern for inline dialog warnings.

Files changed

app/src/main/java/com/amaze/filemanager/ui/fragments/MainFragment.java
rename(HybridFileParcelable f) validator lambda: added an
else if (text.equals(f.getName(getMainActivity()))) branch that
returns WarnableTextInputValidator.ReturnState.STATE_WARNING with
R.string.no_changes_while_rename, then formatting pass via Spotless.
No changes to MainActivityHelper, Operations, string resources,
dialog layouts, or WarnableTextInputValidator itself.

Testing

  1. Long-press a folder/file → Rename.
  2. Leave the EditText value as the current name → verify the helper
    text "No changes were made as the new name matches the old name."
    appears below the EditText in the warning helper-text style.
  3. Type any extra character → warning disappears; revert → warning
    reappears.
  • Device: Vivo V27
  • OS: Android 14

SajalDevX added 2 commits July 9, 2026 10:11
Adds a STATE_WARNING branch to the validator lambda in
MainFragment.rename(...) so that when the typed EditText text
equals the source file name, R.string.no_changes_while_rename
is rendered inline below the field via the existing
WarnableTextInputLayout - mirroring the warning pattern already
used by mkfile() for hidden-file / .txt-extension suggestions.

The backend early-return + Toast in MainActivityHelper.rename
is intentionally preserved as a safety net for direct callers.

Fixes TeamAmaze#4660
@SajalDevX SajalDevX changed the title Notify user when renaming a file/folder to its original name Fix[4660] Notify user when renaming a file/folder to its original name Jul 9, 2026
@VishnuSanal VishnuSanal added the PR-Awaiting-Initial-Review DEPRECATED use PR-Code-Review-Passed or PR-Manual-Testing-Passed label Jul 10, 2026
@EmmanuelMess EmmanuelMess changed the title Fix[4660] Notify user when renaming a file/folder to its original name Notify user when renaming a file/folder to its original name Jul 12, 2026

@EmmanuelMess EmmanuelMess left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works, and looks OK.

@EmmanuelMess
EmmanuelMess enabled auto-merge July 12, 2026 15:10
@EmmanuelMess
EmmanuelMess merged commit 8ee8d62 into TeamAmaze:release/4.0 Jul 12, 2026
5 checks passed
@EmmanuelMess

Copy link
Copy Markdown
Member

If this was done with automated coding tools, please tell me which one you used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-Awaiting-Initial-Review DEPRECATED use PR-Code-Review-Passed or PR-Manual-Testing-Passed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants