From ad41a56166333f839eb8536ce07676bb610706ab Mon Sep 17 00:00:00 2001 From: Pierre Barbier de Reuille Date: Thu, 25 Mar 2021 16:44:40 +0000 Subject: [PATCH] Stop trying to draw a view not attached to the view tree The behavior of the framework when we try to do so is undefined. In our case, it almost work, but no clipping is applied, which is a problem for Android S (before that, widget couldn't use clipping in the first place). Instead of drawing the view through a drawable, this really add the view and adds also a badge ImageView for badges instead of drawing them indirectly. Note that, temporarily, we have to re-allow drawing the view after it has been attached, but the underlying framework bug being fixed, this should be fine (I tested it and it really seems to be). Bug: 183609936 Test: Using hand designed app (see bug) Change-Id: I929ef8fc81c98c49406f2d940cd5efc28319886d --- res/layout/widget_cell_content.xml | 27 +++++-- .../dragndrop/AppWidgetHostViewDrawable.java | 29 +------- .../launcher3/widget/BaseWidgetSheet.java | 21 ++++-- .../widget/PendingItemDragHelper.java | 1 + .../android/launcher3/widget/WidgetCell.java | 73 +++++++++++++------ .../launcher3/widget/WidgetCellPreview.java | 46 ++++++++++++ .../launcher3/widget/WidgetImageView.java | 22 +----- .../WidgetsListTableViewHolderBinder.java | 3 +- 8 files changed, 137 insertions(+), 85 deletions(-) create mode 100644 src/com/android/launcher3/widget/WidgetCellPreview.java diff --git a/res/layout/widget_cell_content.xml b/res/layout/widget_cell_content.xml index 30bd8b19d5..0f6fc6cdb7 100644 --- a/res/layout/widget_cell_content.xml +++ b/res/layout/widget_cell_content.xml @@ -17,16 +17,31 @@ android:layout_width="wrap_content" android:layout_height="wrap_content"> - - + android:layout_marginVertical="8dp"> + + + + +