Skip to content

Widget preview fix 4704854465524987041#625

Merged
theovilardo merged 5 commits intomasterfrom
widget-preview-fix-4704854465524987041
Dec 23, 2025
Merged

Widget preview fix 4704854465524987041#625
theovilardo merged 5 commits intomasterfrom
widget-preview-fix-4704854465524987041

Conversation

@theovilardo
Copy link
Owner

No description provided.

theovilardo and others added 5 commits December 23, 2025 14:56
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.
@theovilardo theovilardo merged commit da3d47d into master Dec 23, 2025
@lostf1sh lostf1sh deleted the widget-preview-fix-4704854465524987041 branch January 16, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant