Skip to content

Show amount attachments and notes on export#973

Merged
Crustack merged 1 commit intomainfrom
fix/972
Apr 12, 2026
Merged

Show amount attachments and notes on export#973
Crustack merged 1 commit intomainfrom
fix/972

Conversation

@Crustack
Copy link
Copy Markdown
Owner

@Crustack Crustack commented Apr 12, 2026

Fixes #970

Summary by CodeRabbit

  • New Features
    • Export/backup confirmations now display a combined "Exported" label with pluralized note and attachment counts.
    • Progress dialogs during exports append localized attachment counts for clearer per-item progress.
    • Added pluralized strings for notes and attachments to ensure correct singular/plural wording.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 12, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7962ad92-79f2-4142-aa5b-41fe71e29785

📥 Commits

Reviewing files that changed from the base of the PR and between 245983f and 23e4b61.

⛔ Files ignored due to path filters (1)
  • app/translations.xlsx is excluded by !**/*.xlsx
📒 Files selected for processing (7)
  • app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt
  • app/src/main/java/com/philkes/notallyx/presentation/view/misc/Progress.kt
  • app/src/main/java/com/philkes/notallyx/presentation/viewmodel/BaseNoteModel.kt
  • app/src/main/java/com/philkes/notallyx/presentation/viewmodel/progress/BackupProgress.kt
  • app/src/main/java/com/philkes/notallyx/utils/ErrorActivity.kt
  • app/src/main/java/com/philkes/notallyx/utils/backup/ExportExtensions.kt
  • app/src/main/res/values/strings.xml

📝 Walkthrough

Walkthrough

Progress and export now report both note and attachment counts: Progress gains an optional countSuffix, backup export returns NotesAndAttachments (pair of counts), progress updates include localized attachment suffixes, and completion toasts use a new Context.exportedText(...) formatter.

Changes

Cohort / File(s) Summary
Progress Model & Subclass
app/src/main/java/com/philkes/notallyx/presentation/view/misc/Progress.kt, app/src/main/java/com/philkes/notallyx/presentation/viewmodel/progress/BackupProgress.kt
Added optional countSuffix: String? = null to Progress; BackupProgress accepts and forwards the new parameter.
Export Implementation
app/src/main/java/com/philkes/notallyx/utils/backup/ExportExtensions.kt
exportAsZip return type changed from Int to NotesAndAttachments (typealias Pair<Int,Int>). Progress emissions include localized countSuffix for attachments; attachment-export loop posts progress with suffix.
UI Extensions
app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt
Added fun Context.exportedText(notesAndAttachments: NotesAndAttachments): String. Default progress count text now appends optional progress.countSuffix when present.
ViewModel / Error Handling
app/src/main/java/com/philkes/notallyx/presentation/viewmodel/BaseNoteModel.kt, app/src/main/java/com/philkes/notallyx/utils/ErrorActivity.kt
Callsites updated to consume NotesAndAttachments and build completion/toast messages via exportedText(...) instead of using note-only pluralization.
Resources
app/src/main/res/values/strings.xml
Added plurals attachments, notes, and string exported to support attachment-aware messaging.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant VM as BaseNoteModel
    participant Export as ContextWrapper.exportAsZip
    participant ProgressBus as LiveData/Progress
    participant UI as ProgressDialog / Context

    User->>VM: trigger exportBackup()
    VM->>Export: exportAsZip(...)
    Export->>ProgressBus: post BackupProgress(current,total,countSuffix)
    ProgressBus->>UI: show/update progress dialog
    Export-->>VM: return NotesAndAttachments (notes, attachments)
    VM->>UI: application.exportedText(notes, attachments) -> show toast
    UI->>User: display completion toast
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through code with bright delight,
Counts for notes and attachments now in sight.
A suffix here, a plural there,
Progress truthful, messages fair.
Hooray — exports balanced, snug, and right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: showing the amount of attachments and notes on export, directly addressing the misleading progress reporting issue.
Linked Issues check ✅ Passed The PR fully addresses issue #970 by implementing consistent export progress reporting that distinguishes between notes and attachments counts.
Out of Scope Changes check ✅ Passed All changes are directly related to the export progress reporting objective; no unrelated modifications were introduced.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/972

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Crustack Crustack changed the title Show amaount attachments and notes on export Show amount attachments and notes on export Apr 12, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/src/main/java/com/philkes/notallyx/utils/backup/ExportExtensions.kt (1)

131-133: ⚠️ Potential issue | 🟡 Minor

Log message will now display confusing output due to changed return type.

Since exportAsZip now returns Pair<Int, Int> instead of Int, line 133's log message will print something like "Exported (150, 200) notes" instead of the intended "Exported 150 notes". Consider updating the log to destructure the pair.

🐛 Proposed fix for clearer logging
-                val exportedNotes =
+                val (exportedNotes, exportedAttachments) =
                     app.exportAsZip(zipUri, password = preferences.backupPassword.value)
-                log(TAG, msg = "Exported $exportedNotes notes")
+                log(TAG, msg = "Exported $exportedNotes notes, $exportedAttachments attachments")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/philkes/notallyx/utils/backup/ExportExtensions.kt`
around lines 131 - 133, exportAsZip now returns a Pair<Int, Int>, so the
existing log("Exported $exportedNotes notes") will print the pair instead of the
exported count; update the call site in ExportExtensions.kt to destructure the
result from exportAsZip (e.g. val (exportedCount, total) =
app.exportAsZip(zipUri, password = preferences.backupPassword.value)) and then
call log(TAG, msg = "Exported $exportedCount notes") (or include both values in
a clearer message) so the logged output shows the actual exported note count
rather than the Pair representation.
🧹 Nitpick comments (1)
app/src/main/res/values/strings.xml (1)

278-281: Potential resource name conflict with existing <string name="notes">.

Line 277 has <string name="notes">Notes</string> and lines 278-281 add <plurals name="notes">. While Android allows a string and plurals to share the same name (they're accessed via different methods: getString() vs getQuantityString()), this can cause confusion during maintenance. Consider renaming the plurals to something like notes_count or leaving as-is with a comment clarifying the distinction.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/res/values/strings.xml` around lines 278 - 281, The plurals
entry uses the same resource name "notes" as the existing string resource
"notes", which is legal but confusing; rename the plurals resource to a distinct
identifier (e.g., change plurals name="notes" to name="notes_count" or similar)
and update any calls using getQuantityString(...) to use the new name, or
alternatively leave the name and add a clear comment above the plurals to
document the deliberate difference between the string resource "notes" and the
plurals resource "notes".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt`:
- Around line 1192-1193: The exportedText function currently uses a manual
conditional `if (notesAndAttachments.first < 2)` causing wrong grammar for 0
notes; replace that conditional with Android's plural helper by calling
getQuantityString for the note plural (e.g., use
getQuantityString(R.plurals.note, notesAndAttachments.first)) and build the
string using that result (keep attachments using
getQuantityString(R.plurals.attachments, notesAndAttachments.second)); update
the function exportedText to use getQuantityString for the notes count instead
of the `< 2` check.

---

Outside diff comments:
In `@app/src/main/java/com/philkes/notallyx/utils/backup/ExportExtensions.kt`:
- Around line 131-133: exportAsZip now returns a Pair<Int, Int>, so the existing
log("Exported $exportedNotes notes") will print the pair instead of the exported
count; update the call site in ExportExtensions.kt to destructure the result
from exportAsZip (e.g. val (exportedCount, total) = app.exportAsZip(zipUri,
password = preferences.backupPassword.value)) and then call log(TAG, msg =
"Exported $exportedCount notes") (or include both values in a clearer message)
so the logged output shows the actual exported note count rather than the Pair
representation.

---

Nitpick comments:
In `@app/src/main/res/values/strings.xml`:
- Around line 278-281: The plurals entry uses the same resource name "notes" as
the existing string resource "notes", which is legal but confusing; rename the
plurals resource to a distinct identifier (e.g., change plurals name="notes" to
name="notes_count" or similar) and update any calls using getQuantityString(...)
to use the new name, or alternatively leave the name and add a clear comment
above the plurals to document the deliberate difference between the string
resource "notes" and the plurals resource "notes".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aa7a01f2-9d6f-44eb-9031-12027d45ea47

📥 Commits

Reviewing files that changed from the base of the PR and between 795db70 and ed2259b.

⛔ Files ignored due to path filters (1)
  • app/translations.xlsx is excluded by !**/*.xlsx
📒 Files selected for processing (7)
  • app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt
  • app/src/main/java/com/philkes/notallyx/presentation/view/misc/Progress.kt
  • app/src/main/java/com/philkes/notallyx/presentation/viewmodel/BaseNoteModel.kt
  • app/src/main/java/com/philkes/notallyx/presentation/viewmodel/progress/BackupProgress.kt
  • app/src/main/java/com/philkes/notallyx/utils/ErrorActivity.kt
  • app/src/main/java/com/philkes/notallyx/utils/backup/ExportExtensions.kt
  • app/src/main/res/values/strings.xml

Comment on lines +1192 to +1193
fun Context.exportedText(notesAndAttachments: NotesAndAttachments) =
"${getString(R.string.exported)} ${notesAndAttachments.first} ${if(notesAndAttachments.first < 2) getString(R.string.note) else getString(R.string.notes)} (${notesAndAttachments.second} ${getQuantityString(R.plurals.attachments, notesAndAttachments.second)})"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Incorrect pluralization logic for notes count.

The condition notesAndAttachments.first < 2 produces incorrect grammar when there are 0 notes (would display "0 Note" instead of "0 Notes"). For consistency with how attachments are handled, use getQuantityString for notes as well.

🐛 Proposed fix using getQuantityString for notes
 fun Context.exportedText(notesAndAttachments: NotesAndAttachments) =
-    "${getString(R.string.exported)} ${notesAndAttachments.first} ${if(notesAndAttachments.first < 2) getString(R.string.note) else getString(R.string.notes)} (${notesAndAttachments.second} ${getQuantityString(R.plurals.attachments, notesAndAttachments.second)})"
+    "${getString(R.string.exported)} ${notesAndAttachments.first} ${getQuantityString(R.plurals.notes, notesAndAttachments.first)} (${notesAndAttachments.second} ${getQuantityString(R.plurals.attachments, notesAndAttachments.second)})"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt` around
lines 1192 - 1193, The exportedText function currently uses a manual conditional
`if (notesAndAttachments.first < 2)` causing wrong grammar for 0 notes; replace
that conditional with Android's plural helper by calling getQuantityString for
the note plural (e.g., use getQuantityString(R.plurals.note,
notesAndAttachments.first)) and build the string using that result (keep
attachments using getQuantityString(R.plurals.attachments,
notesAndAttachments.second)); update the function exportedText to use
getQuantityString for the notes count instead of the `< 2` check.

@Crustack Crustack force-pushed the fix/972 branch 2 times, most recently from 245983f to e0dcfe7 Compare April 12, 2026 11:41
@Crustack Crustack merged commit d0ecce9 into main Apr 12, 2026
@Crustack Crustack deleted the fix/972 branch April 12, 2026 11:41
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.

Export Backup Progress Bar Misleading

1 participant