Improve widget responsive design and add glance previews#143
Merged
theovilardo merged 20 commits intotheovilardo:masterfrom Sep 11, 2025
Merged
Improve widget responsive design and add glance previews#143theovilardo merged 20 commits intotheovilardo:masterfrom
theovilardo merged 20 commits intotheovilardo:masterfrom
Conversation
…zing and move `AlbumArtBitmapCache` This commit refactors the `PixelPlayGlanceWidget` to enhance its layout responsiveness and code organization. Key changes: - **Responsive Sizing:** The widget now uses `SizeMode.Responsive` instead of `SizeMode.Exact`. A predefined set of `DpSize` values has been introduced (e.g., `ONE_BY_ONE_SIZE`, `TWO_BY_TWO_SIZE`) to support various widget configurations. The layout selection logic in `PixelPlayGlanceAppWidgetContent` has been updated to use a `when` statement based on the current `LocalSize.current` to determine the appropriate layout composable. - **`AlbumArtBitmapCache` Relocation:** The `AlbumArtBitmapCache` object, previously a nested object within `PixelPlayGlanceWidget.Companion`, has been moved to the top level of the `PixelPlayGlanceWidget.kt` file. This change improves its accessibility, particularly for composable functions that might need to interact with the cache. - **Layout Definitions:** The previous verbose list of layout size constants (e.g., `VERY_THIN_LAYOUT_SIZE`, `GABE_LAYOUT_SIZE`) has been replaced with a more structured set of sizes based on common grid cell configurations (e.g., 1x1, 2x1, 3x2). - **Preview Added:** A new `@Preview` composable, `ExtraLargeWidgetLayoutPreview`, has been added to facilitate UI development and testing of the `ExtraLargeWidgetLayout`. - **Minor UI Adjustments:** Small adjustments to padding and spacers within the `ExtraLargeWidgetLayout` for better visual spacing.
This commit applies automated code formatting to the `PixelPlayGlanceWidget.kt` file. The changes primarily involve: - Adjusting parameter alignment in function definitions and calls. - Normalizing spacing around operators and modifiers. - Adding or removing blank lines for better readability, particularly within the `WidgetUi` composable's `when` statement.
This change adds generated previews for the Glance widget, following the modern Android guidelines. It introduces a new file, `WidgetPreviews.kt`, which contains `@Preview` composables for all 13 supported widget sizes. This allows developers to easily preview the widget in different configurations within Android Studio. The old `previewLayout` attribute has been removed from the widget's XML definition in favor of this new, more flexible approach. The `WidgetUi` composable has been made public to be accessible from the new preview file.
This commit introduces the `androidx.glance:glance-preview` dependency to the project. Key changes: - Added `glancePreview` to the `versions` section and `androidx-glance-preview` to the `libraries` section in `gradle/libs.versions.toml`. - Included `implementation(libs.androidx.glance.preview)` in the `dependencies` block of `app/build.gradle.kts`. - Updated the import statement in `app/src/main/java/com/theveloper/pixelplay/ui/glancewidget/WidgetPreviews.kt` from `androidx.glance.appwidget.preview.ExperimentalGlancePreviewApi` to `androidx.glance.preview.ExperimentalGlancePreviewApi` to reflect the new dependency. This allows for the use of preview functionality for Glance widgets.
This commit refactors the Glance widget preview functionality and updates related project configurations.
Key changes:
- **Dependency Update:** Added `androidx.glance:glance-appwidget-preview:1.2.0-alpha01` as a debug implementation dependency in `app/build.gradle.kts`.
- **Preview Refactoring:**
- The `WidgetPreviews.kt` file was significantly refactored.
- Introduced `PixelPlayGlanceWidgetPreviewProvider` class that extends `GlanceAppWidget` to provide the widget content for previews.
- Consolidated multiple specific-size preview functions (e.g., `OneByOneWidgetPreview`, `TwoByTwoWidgetPreview`) into a single `PixelPlayWidget_Preview` function that utilizes the new provider. This simplifies the preview setup and makes it more maintainable.
- **Inspection Profile Update:** Updated `.idea/inspectionProfiles/Project_Default.xml` to include `previewFile` option for various Glance preview inspection tools. This likely enhances how the IDE lints and validates Glance preview code.
- **Minor UI Tweak:** In `PixelPlayGlanceWidget.kt`, the vertical padding for a `Box` acting as a divider was changed from `5.dp` to `4.dp`.
This commit introduces a suite of new `@Preview` Composable functions for the `PixelPlayGlanceWidget` to visualize its appearance across various common widget sizes. Key changes: - **Expanded Previews:** Added previews for multiple aspect ratios and sizes, including 1x1, 1x2, 2x1, 2x2, 3x1, 3x2, 3x3, 4x2, 4x3, 4x4, 5x3, 5x4, and 5x5. - **Preview Refactor:** The existing generic `PixelPlayWidget_Preview` has been replaced by these more specific size previews. - **Code Formatting:** Minor code formatting adjustments were made, such as condensing `QueueItem` declarations and `WidgetUi` parameters onto single lines.
This commit refactors the `PixelPlayGlanceWidget` and its previews to improve visual spacing and component sizing.
Key changes:
- **Widget Previews:**
- Wrapped the `PixelPlayGlanceWidget` preview in a `Box` with a light blue background for better visual separation.
- **PixelPlayGlanceWidget:**
- Reduced padding in various `Box` layouts.
- Adjusted the height and spacing of `AlbumArtImageGlance`, `Spacer`, `PlayPauseButtonGlance`, `PreviousButtonGlance`, and `NextButtonGlance` components across different widget sizes to optimize layout. For instance, the album art height in the vertical layout was reduced from `48.dp` to `44.dp`, and associated spacer heights were also decreased. Similar adjustments were made to button heights and album art sizes in other layouts.
This commit introduces changes to the `PixelPlayGlanceWidget`. Key changes: - **Corner Radius:** The background corner radius for the `OneByOneWidgetLayout` has been changed from `28.dp` to `100.dp`. - **Debug Code Removal:** A `println(size)` statement, likely used for debugging, has been removed.
…` for smaller sizes This commit refactors the layout of the `PixelPlayGlanceWidget` when displayed in its smaller configurations. Key changes: - **Album Art:** The album art is now displayed in a `Row` that takes up one-third of the available height and spans the full width. The corner radius has been changed to 16.dp. - **Play/Pause Button:** The `PlayPauseButtonGlance` now also occupies one-third of the available height. - **Control Buttons Row:** The `Row` containing the previous, next, and options buttons similarly takes up one-third of the height. - **Spacers:** The vertical spacing between the album art and the play/pause button has been increased from 8.dp to 10.dp. - **Height Calculation:** Introduced `contentHeight` and `oneThirdHeight` variables to dynamically calculate the height for the main components based on the available space, accounting for padding and spacers. - **Removed Fixed Heights:** Removed fixed height constraints (e.g., `height(48.dp)`, `height(30.dp)`) from various components, allowing them to adapt to the calculated one-third height. - **Debugging Output:** Added `println` statements to log `contentHeight` and `oneThirdHeight` for debugging purposes.
…low buttons to scale larger or smaller
This commit refactors the `PixelPlayGlanceWidget` to adjust padding and layout for a more consistent appearance. Key changes: - Removed unused `albumArtSize` and `size` variables as they are no longer used for manual sizing. - Reduced horizontal padding around content from `16.dp` to `12.dp` in one layout. - Applied `defaultWeight()` to the `AlbumArtImageGlance` to allow it to proportionally fill available space. - Reduced the `Spacer` width between the album art and play/pause button from `14.dp` to `10.dp`.
This change updates the build script to use the version catalog for the Glance preview dependency, following best practices.
This commit removes the `contentHeight` and `oneThirdHeight` variables from `PixelPlayGlanceWidget.kt`. These variables and their associated `println` statements, used for calculating and debugging component heights, are no longer utilized in the codebase.
…into feature/glance-widget-previews
Update widget spacing and styling and add generated previews for Glance widget
Moves the `androidx.glance:glance-appwidget-preview` dependency from being hardcoded in `app/build.gradle.kts` to the `gradle/libs.versions.toml` version catalog. This change follows best practices for dependency management in Gradle projects by centralizing dependency versions and making them easier to manage.
Refactor: Move glance-appwidget-preview to version catalog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces comprehensive support for Glance widget previews in the PixelPlay app, allowing developers to visualize the widget in various sizes and configurations directly in the IDE. The changes include new dependencies, updates to inspection profiles for preview support, and the addition of a dedicated preview provider with multiple preview composables.
Glance Widget Preview Support
WidgetPreviews.kt, which contains aPixelPlayGlanceWidgetPreviewProviderand multiple@Previewcomposables to render the widget in various grid sizes for development and testing.Build and Dependency Updates
androidx.glance.previewandandroidx.glance.appwidget.previewdependencies to the project for preview functionality, withandroidx.glance.appwidget.previewset as a debug implementation. [1] [2] [3] [4] [5]IDE and Inspection Profile Enhancements
.idea/inspectionProfiles/Project_Default.xmlto enable preview file support for Glance-related inspection tools, improving IDE code analysis for widget previews.Miscellaneous
android:previewLayoutattribute from the widget info XML, as previews are now handled via the new composable previews.app/build.gradle.ktsfor improved formatting.Before




After