Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 813856ab authored by Pierre Barbier de Reuille's avatar Pierre Barbier de Reuille
Browse files

Correct the preview generation for App Widgets.

If the App Widget provider doesn't define a preview, we generate one. We
needed to update it to include the correct corner radius and remove the
shadow (as Material Next doesn't use shadows).

Fix: 184610987
Test: Manually using Youtube Music
Change-Id: Id6b88821ab1b406f1c40d94f6c50e133eb7fa808
parent 5f35ff02
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -457,10 +457,24 @@ public class WidgetPreviewLoader {
            drawable.setBounds(x, 0, x + previewWidth, previewHeight);
            drawable.draw(c);
        } else {
            RectF boxRect = drawBoxWithShadow(c, previewWidth, previewHeight);
            RectF boxRect;

            // Draw horizontal and vertical lines to represent individual columns.
            final Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);

            if (Utilities.ATLEAST_S) {
                boxRect = new RectF(/* left= */ 0, /* top= */ 0, /* right= */
                        previewWidth, /* bottom= */ previewHeight);

                p.setStyle(Paint.Style.FILL);
                p.setColor(Color.WHITE);
                float roundedCorner = mContext.getResources().getDimension(
                        android.R.dimen.system_app_widget_background_radius);
                c.drawRoundRect(boxRect, roundedCorner, roundedCorner, p);
            } else {
                boxRect = drawBoxWithShadow(c, previewWidth, previewHeight);
            }

            p.setStyle(Paint.Style.STROKE);
            p.setStrokeWidth(mContext.getResources()
                    .getDimension(R.dimen.widget_preview_cell_divider_width));