Skip to content

Conversation

@Kota-Jagadeesh
Copy link
Collaborator

@Kota-Jagadeesh Kota-Jagadeesh commented Jan 5, 2026

Description (required)

Fixes #6607 (Specifically addressing TODOs in ImageFileLoader and related classes)

Changes implemented:

  • SHA-1 Fingerprinting: Added SHA-1 generation logic in ImageFileLoader during the initial device scan. This ensures each Image model carries its digital fingerprint from the start, allowing ImageLoader to perform duplicate checks on Commons without redundant file I/O.
  • Resource Management (Abort Logic): Implemented an abortLoadImage mechanism in ImageFileLoader using Coroutine Job cancellation.
  • Lifecycle Integration: Linked the abort logic to the ImageAdapter cleanup phase and CustomSelectorViewModel's onCleared method to ensure background scanning stops immediately when the user exits the gallery.
  • Dependency Injection: Updated ImageFragment and CustomSelectorViewModelFactory to support the new ImageFileLoader dependency requirements.

Why?
These changes resolve long-standing TODOs in the codebase meant to improve app performance and prevent accidental duplicate uploads by making the SHA-1 consistently available across the Custom Selector components.

Tests performed (required)

Tested ProDebug variant on Redmi Note 13 Pro with API level 35.

  • Unit Tests: Updated ImageFileLoaderTest and ImageAdapterTest to verify:
    • Successful SHA-1 calculation for local files.
    • Proper cancellation of the loading Job when abortLoadImage is called.
    • Correct synchronization with the Main Looper using shadowOf(Looper.getMainLooper()).idle().

Screenshots (for UI changes only)

N/A (Logic and performance optimization)

@Kota-Jagadeesh Kota-Jagadeesh changed the title Fix/custom selector todo resolutions feat: Implement SHA-1 pre-calculation and image loading abort logic Jan 5, 2026
@Kota-Jagadeesh Kota-Jagadeesh self-assigned this Jan 5, 2026
@github-actions
Copy link

github-actions bot commented Jan 5, 2026

✅ Generated APK variants!

@nicolas-raoul
Copy link
Member

Would you mind first creating an issue describing the problem? Thanks! 🙂

@Kota-Jagadeesh
Copy link
Collaborator Author

Certainly! I will create an issue for this now. To clarify, this pr is to address two specific TODO comments located in ImageFileLoader.kt:

// todo Abort loading images. - Implementing lifecycle-aware cancellation of the background image scanner.
// todo Sha1 for image - Implementing SHA-1 pre-calculation to enable efficient duplicate detection on Commons.

I'll link the new issue to the PR shortly. Thanks! 🙂

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Implement background task cancellation and SHA-1 pre-calculation for Custom Selector

2 participants