Scroll to show WidgetCell when it is tapped.

Scroll to show WidgetCell when it is tapped in a widget sheet.
Otherwise, the add button may show/hide without the user seeing
it if the bottom is clipped.

Bug: 329861721
Test: manual- tap WidgetCell when top or bottom is scrolled out of view
Flag: ACONFIG com.android.launcher3.enable_widget_tap_to_add TEAMFOOD

Change-Id: Ie21730c193e845cb1c1fa447b7c0a7e719984a8f
This commit is contained in:
Willie Koomson
2024-04-04 23:33:35 +00:00
parent 7a6036516c
commit dcc2d82d4e
6 changed files with 156 additions and 0 deletions

View File

@@ -36,6 +36,9 @@ import androidx.recyclerview.widget.RecyclerView;
import com.android.launcher3.R;
import java.util.ArrayList;
import java.util.List;
/**
* A {@link LinearLayout} container which allows scrolling parts of its content based on the
* scroll of a different view. Views which are marked as sticky are not scrolled, giving the
@@ -242,6 +245,22 @@ public class StickyHeaderLayout extends LinearLayout implements
return p instanceof MyLayoutParams;
}
/**
* Return a list of all the children that have the sticky layout param set.
*/
public List<View> getStickyChildren() {
List<View> stickyChildren = new ArrayList<>();
int count = getChildCount();
for (int i = 0; i < count; i++) {
View v = getChildAt(i);
MyLayoutParams lp = (MyLayoutParams) v.getLayoutParams();
if (lp.sticky) {
stickyChildren.add(v);
}
}
return stickyChildren;
}
private static class MyLayoutParams extends LayoutParams {
public final boolean sticky;