Skip to content

Comments

Fix background image visibility based on collection state #18073#18162

Merged
lukstbit merged 6 commits intoankidroid:mainfrom
Tushar4059x:solving-#18073
Apr 9, 2025
Merged

Fix background image visibility based on collection state #18073#18162
lukstbit merged 6 commits intoankidroid:mainfrom
Tushar4059x:solving-#18073

Conversation

@Tushar4059x
Copy link
Contributor

@Tushar4059x Tushar4059x commented Mar 26, 2025

Purpose / Description

Previously, the background image remained visible even when the collection was empty, causing readability issues. This update ensures that the background image is correctly toggled based on whether there are decks in the collection.

Fixes

Approach

  • Adjusted updateBackgroundVisibility to properly show/hide the background image based on deck presence.

How Has This Been Tested?

  • Tested on Pixel 8 Android Emulator (API 34).
  • Verified that the background image correctly appears when decks are added and disappears when the collection is empty.
  • Ensured there were no UI glitches or unexpected behavior during deck updates.
  • Checked performance to confirm no redundant memory usage.

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Uploading Screen Recording 2025-03-26 at 6.37.36 PM.mov…

This commit ensures that the background image is correctly shown or hidden based on the collection state. Previously, `currentAnkiDroidDirectory` was being redeclared locally, causing unnecessary shadowing. The fix properly assigns the directory to the existing class-level property and correctly references it.

Changes:
- Removed redundant local variable declaration for `currentAnkiDroidDirectory`.
- Used the existing `lateinit var currentAnkiDroidDirectory` to store the directory path.
- Updated the `updateBackgroundVisibility` function to correctly toggle the background image based on whether the collection is empty.

Impact:
- Prevents redundant memory allocation.
- Ensures the background image is hidden when the collection is empty.
- Shows the background image when decks are added.

Tested to verify the correct behavior of background visibility when decks are added or removed.
@Tushar4059x
Copy link
Contributor Author

Screen.Recording.2025-03-26.at.6.37.36.PM.mov

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

Thanks!

Re implemented the solution based on the placeholder logic
@ericli3690
Copy link
Member

Hi! It's advised that you force push on top of your old commit so that there's only one commit associated with each issue. This way, the commit history of the repo stays clean and descriptive. This was a mistake I made when I first contributed. You can do this by running git reset --soft [commit hash to revert to], committing, then running git push -f origin [branch name].

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

Code looks good! A couple of 'line noise' changes in the diff which should be reverted to keep things clean

And a request for a comment change to explain why the line exists

@david-allison david-allison added Needs Second Approval Has one approval, one more approval to merge Needs Author Reply Waiting for a reply from the original author labels Mar 31, 2025
@david-allison david-allison removed the Needs Author Reply Waiting for a reply from the original author label Apr 1, 2025
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

Cheers, thanks so much, looks great!

@david-allison david-allison added the squash-merge A squash & force push is required. The PR author may do this to speed up the merge process. label Apr 1, 2025
fabLinearLayout.layoutParams = layoutParams
}
}
Timber.d("Startup - Deck List UI Completed")
Copy link
Member

Choose a reason for hiding this comment

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

Wait... this line shouldn't be removed

(missed this on the diff from my notifications)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay i'll just add it again

@david-allison david-allison added Needs Author Reply Waiting for a reply from the original author and removed Needs Second Approval Has one approval, one more approval to merge labels Apr 1, 2025
@Tushar4059x
Copy link
Contributor Author

done

Copy link
Member

@lukstbit lukstbit left a comment

Choose a reason for hiding this comment

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

Ok, thanks for contributing!

@lukstbit lukstbit added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Author Reply Waiting for a reply from the original author labels Apr 9, 2025
@lukstbit lukstbit merged commit f8462e8 into ankidroid:main Apr 9, 2025
9 checks passed
@github-actions github-actions bot added this to the 2.21 release milestone Apr 9, 2025
@github-actions github-actions bot removed Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) squash-merge A squash & force push is required. The PR author may do this to speed up the merge process. labels Apr 9, 2025
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.

Improve background when the collection is empty

4 participants