Widget preview fix 4704854465524987041#625
Merged
theovilardo merged 5 commits intomasterfrom Dec 23, 2025
Merged
Conversation
This change resolves the issue where the app widget often displays "can't load widget" in the launcher's widget selection screen. The fix involves two main parts: 1. **Robust `previewImage`:** Replaced the previous shape drawable (which was just a colored rectangle) with a new static `VectorDrawable` (`widget_preview_full.xml`) that visually replicates the widget's layout (album art, text, buttons). This ensures a valid and representative preview is shown on devices that rely on `previewImage` (Android < 12 and some OEM launchers). 2. **Safe `previewLayout`:** Updated the background drawables used by `previewLayout` (e.g., `widget_preview_background.xml`) to use static color resources (`@color/...`) instead of dynamic theme attributes (`?attr/...`). This prevents inflation failures in launchers that do not correctly apply the app's theme context to the preview RemoteViews. These changes ensure compatibility across a wide range of devices and Android versions without altering the actual widget's runtime behavior.
The "Can't load widget" error in the Android launcher occurs when the `previewLayout` fails to inflate, often due to missing theme attributes or restricted resource access in the launcher's `RemoteViews` context. This fix resolves the issue by: 1. **Removing `android:previewLayout`** from `appwidget-provider` XML. This forces the launcher to use `android:previewImage` instead. 2. **Replacing `android:previewImage`** with a new, static `VectorDrawable` (`widget_preview_full.xml`). This vector visually replicates the widget's layout (album art, text placeholders, buttons) using hardcoded paths and hex colors, ensuring it can be rendered by any launcher without external dependencies or inflation risks. 3. Updating the `ic_music_placeholder_preview` vector to use a static color tint, further removing attribute dependencies. This approach guarantees a consistent, high-quality preview on all devices and Android versions.
This commit addresses user feedback regarding the widget preview: 1. **Correct Icons:** Updated `widget_preview_full.xml` to use the correct vector paths for "Skip Previous", "Play", and "Skip Next" icons, matching the actual app icons (`rounded_skip_previous_24.xml`, etc.). 2. **Material 3 Colors:** Updated the static vector to use standard Material 3 "Baseline" hex colors (e.g., #FFF3EDF7 for Surface Container) instead of the previous arbitrary palette. This ensures the preview looks like a proper Material 3 widget even though it is a static image. 3. **Build Fix:** Reverted changes to `widget_preview_album_art_background.xml` and other unused drawable files. These files are not used by the new vector-based preview strategy but their modification had introduced undefined resource references that broke the build. 4. **Layout Improvements:** Adjusted spacing in the vector drawable to better reflect the real widget layout.
This commit finalizes the widget preview improvements by: 1. **Rounding Text Placeholders:** Updated the vector paths for the text lines in `widget_preview_full.xml` to have fully rounded ends (semicircles), matching the Material 3 Expressive design language requested by the user. 2. **Enabling Dynamic Colors:** Introduced a `drawable-v31` version of the preview vector. This version replaces the static hex colors with Android system color resources (e.g., `@android:color/system_accent1_100`), allowing the preview to adapt to the user's wallpaper on Android 12+ devices while maintaining a safe static fallback for older versions. 3. **Refining Static Colors:** Polished the static hex colors in the base `drawable/widget_preview_full.xml` to better align with the standard Material 3 Baseline Light palette (e.g., using correct Surface Container tones). This ensures a high-quality, adaptive preview that is robust against launcher crashes.
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.
No description provided.