Skip to content

Fix widget album art warping due to manual image resize#130

Merged
theovilardo merged 8 commits intotheovilardo:masterfrom
ColbyCabrera:fix/widget-album-art-warping
Sep 9, 2025
Merged

Fix widget album art warping due to manual image resize#130
theovilardo merged 8 commits intotheovilardo:masterfrom
ColbyCabrera:fix/widget-album-art-warping

Conversation

@ColbyCabrera
Copy link
Copy Markdown
Contributor

@ColbyCabrera ColbyCabrera commented Sep 9, 2025

Fix for the album art in the widget and also an error from the ColorProvider used in the divider in the widget.

ColbyCabrera and others added 8 commits September 8, 2025 13:13
This commit refactors the shuffle functionality within `PlayerViewModel` for a more robust and predictable user experience.

Key changes:
- **Shuffle Logic Update:**
    - When shuffle mode is enabled and the current media item count is zero, a new shuffled queue is generated from the master list of all songs. The `playSongs` function is then called with this new queue, starting playback from the first song in the shuffled list.
    - The `updateCurrentPlaybackQueueFromPlayer` method has been modified. When shuffle mode is enabled, it now calls a new `createShuffledQueue` function. This function creates a new shuffled list of songs and updates the `currentPlaybackQueue` in the UI state.
- **New `createShuffledQueue` Function:**
    - This new private function takes a list of `Song` objects, randomly selects one song to be the first in the queue, and then shuffles the remaining songs. The selected first song is then added to the beginning of the shuffled list.
- **Timeline Change Handling:**
    - Logging has been added to `onTimelineChanged` when the reason for the change is `TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED`. The direct call to `updateCurrentPlaybackQueueFromPlayer` has been commented out in this callback, likely to prevent redundant updates or potential race conditions with the new shuffle logic.
- **Logging:**
    - Additional logging has been introduced in various parts of the `PlayerViewModel`, particularly around queue updates and song playback, to aid in debugging and understanding the flow of operations.
This commit refactors the `PlayerViewModel` to simplify queue handling and remove unnecessary logging statements.

Key changes:
- **Simplified `updateCurrentPlaybackQueueFromPlayer`**: The logic for updating the current playback queue when shuffle mode is enabled has been removed. The queue now directly reflects the order from the `MediaController`'s timeline.
- **Removed redundant logging**: Several `Log.d` and `println` statements used for debugging have been removed from various functions, including `combine` for `favoriteSongs`, `updateCurrentPlaybackQueueFromPlayer`, `setupMediaControllerListeners`, `internalPlaySongs`, and `loadAndPlaySong`.
- **Improved `createShuffledQueue`**: Added a check for an empty songs list to prevent potential errors.
The previous shuffle implementation would only toggle the shuffle mode and then either pause the current song or start playing the first song in the library.

This change introduces a new `shuffleAllSongs` function in the `PlayerViewModel` that, when called:
1.  Enables shuffle mode on the media player.
2.  Selects a random song from the full list of songs.
3.  Starts playback with the random song and a shuffled queue of all songs.

The shuffle button in the library screen is updated to call this new function, providing the user with the expected shuffle behavior.

A unit test has been added to verify that the `shuffleAllSongs` function correctly calls the underlying `playSongs` method with a random starting song and the full song list.
Refactor library shuffle button functionality to play a random song when there are no songs playing / displayed, and generate a shuffled queue.
The album art in the Glance widget was being manually scaled to the exact dimensions of its container, ignoring the original aspect ratio. This caused the image to appear warped or stretched in non-square widget sizes.

This commit removes the manual `Bitmap.scale()` call and relies on the `Image` composable's `ContentScale.Crop` to handle scaling correctly. `ContentScale.Crop` ensures the aspect ratio is preserved while the image fills its bounds, preventing any distortion.
This commit removes an obsolete comment related to bitmap scaling in the `PixelPlayGlanceWidget.kt` file. The comment indicated that bitmap scaling was no longer handled in that specific code block, which is now the default behavior.
This commit introduces minor refactoring to the `PixelPlayGlanceWidget`.

Key changes:
- **Import Order:** The import statement for `androidx.glance.unit.ColorProvider` has been moved to align with standard import ordering.
- **Divider Color:** The `dividerColor` variable was removed and its `ColorProvider` value is now directly applied to the background modifier of a `Box` used as a divider. This simplifies the code by removing an intermediate variable.
- **Padding:** A comment indicating a fix for applying padding to an outer `Box` has been updated to reflect the change more accurately.
@theovilardo theovilardo merged commit d9f7e55 into theovilardo:master Sep 9, 2025
@ColbyCabrera ColbyCabrera deleted the fix/widget-album-art-warping branch September 10, 2025 17:55
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.

2 participants