Adding diags to getWidget

Also avoiding scrolling widgets horizontally when the gesture could
happen in the lower system gesture area.

Change-Id: I80192db7e407f8c1715aad3b96178c00b5710e71
This commit is contained in:
vadimt
2020-04-06 12:39:21 -07:00
committed by Vadim Tryshev
parent 16cd3677bc
commit 180c2e10fc
@@ -88,8 +88,9 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer {
}
public Widget getWidget(String labelText) {
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"getting widget " + labelText + " in widgets list")) {
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"getting widget " + labelText + " in widgets list")) {
final UiObject2 widgetsContainer = verifyActiveContainer();
final Point displaySize = mLauncher.getRealDisplaySize();
final BySelector labelSelector = By.clazz("android.widget.TextView").text(labelText);
@@ -114,17 +115,17 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer {
maxWidth = Math.max(mLauncher.getVisibleBounds(sibling).width(), maxWidth);
}
int visibleDelta = maxWidth - mLauncher.getVisibleBounds(widget).width();
if (visibleDelta > 0) {
Rect parentBounds = mLauncher.getVisibleBounds(cell);
mLauncher.linearGesture(parentBounds.centerX() + visibleDelta
+ mLauncher.getTouchSlop(),
parentBounds.centerY(), parentBounds.centerX(),
parentBounds.centerY(), 10, true, GestureScope.INSIDE);
}
if (mLauncher.getVisibleBounds(widget).bottom
<= displaySize.y - mLauncher.getBottomGestureSize()) {
int visibleDelta = maxWidth - mLauncher.getVisibleBounds(widget).width();
if (visibleDelta > 0) {
Rect parentBounds = mLauncher.getVisibleBounds(cell);
mLauncher.linearGesture(parentBounds.centerX() + visibleDelta
+ mLauncher.getTouchSlop(),
parentBounds.centerY(), parentBounds.centerX(),
parentBounds.centerY(), 10, true, GestureScope.INSIDE);
}
return new Widget(mLauncher, widget);
}
}