Retain add button on rotation for two-pane and bottom sheet

Reselects the WidgetCell that was selected when reloading the sheet on
rotation. WidgetsFullSheet is excluded because it does not retain the
open header on rotation.

Bug: 331429554
Test: manual, see screencast
Flag: ACONFIG com.android.launcher3.enable_widget_tap_to_add NEXTFOOD
Change-Id: Id3d21f44b1dc525e144296f513f5a460fc51474c
This commit is contained in:
Willie Koomson committed 2024-05-08 22:56:52 +00:00
1 parent 49e364cd0b
commit 245c244fed
5 files changed
+125 -8

No files matched your search

@@ -503,6 +503,15 @@ public class WidgetCell extends LinearLayout {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
if (changed && isShowingAddButton()) {
post(this::setupIconOrTextButton);
}
}
/**
* Loads a high resolution package icon to show next to the widget title.
*/
@@ -627,4 +636,19 @@ public class WidgetCell extends LinearLayout {
set.playSequentially(hideAnim, showAnim);
set.start();
}
/**
* Returns true if this WidgetCell is displaying the same item as info.
*/
public boolean matchesItem(WidgetItem info) {
if (info == null || mItem == null) return false;
if (info.widgetInfo != null && mItem.widgetInfo != null) {
return info.widgetInfo.getUser().equals(mItem.widgetInfo.getUser())
&& info.widgetInfo.getComponent().equals(mItem.widgetInfo.getComponent());
} else if (info.activityInfo != null && mItem.activityInfo != null) {
return info.activityInfo.getUser().equals(mItem.activityInfo.getUser())
&& info.activityInfo.getComponent().equals(mItem.activityInfo.getComponent());
}
return false;
}
}