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

@@ -44,6 +44,7 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.model.data.PackageItemInfo;
import com.android.launcher3.recyclerview.ViewHolderBinder;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.widget.WidgetCell;
import com.android.launcher3.widget.model.WidgetsListBaseEntry;
import com.android.launcher3.widget.model.WidgetsListContentEntry;
import com.android.launcher3.widget.model.WidgetsListHeaderEntry;
@@ -423,6 +424,23 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet {
return true;
}
@Override
protected int getHeaderTopClip(@NonNull WidgetCell cell) {
return 0;
}
@Override
protected void scrollCellContainerByY(WidgetCell wc, int scrollByY) {
for (ViewParent parent = wc.getParent(); parent != null; parent = parent.getParent()) {
if (parent instanceof ScrollView scrollView) {
scrollView.smoothScrollBy(0, scrollByY);
return;
} else if (parent == this) {
return;
}
}
}
/**
* This is a listener for when the selected header gets changed in the left pane.
*/