From 31fa653ef34ca655c4ea1d1a5931f5be49b80b50 Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 14 Apr 2020 19:21:07 -0700 Subject: [PATCH] Manually marking widgets recycler as non-scrollable of frozen There was hope that freezing automatically marks it as non-scrollable, but this happened to be not true. Sending accessibility event per pweaver@'s instructions. Bug: 152354290 Change-Id: Idd04c69cef9e8e621775ef86112f35e3d9d9d2da --- .../android/launcher3/BaseRecyclerView.java | 28 +++++++++++++++++++ .../launcher3/widget/WidgetsRecyclerView.java | 21 -------------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/com/android/launcher3/BaseRecyclerView.java b/src/com/android/launcher3/BaseRecyclerView.java index 9e8441a0dd..41eeb78bc7 100644 --- a/src/com/android/launcher3/BaseRecyclerView.java +++ b/src/com/android/launcher3/BaseRecyclerView.java @@ -16,17 +16,21 @@ package com.android.launcher3; +import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED; + import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.accessibility.AccessibilityNodeInfo; import androidx.recyclerview.widget.RecyclerView; import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.testing.TestProtocol; +import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.RecyclerViewFastScroller; @@ -187,4 +191,28 @@ public abstract class BaseRecyclerView extends RecyclerView { AccessibilityManagerCompat.sendScrollFinishedEventToTest(getContext()); } } + + @Override + public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(info); + if (isLayoutSuppressed()) info.setScrollable(false); + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, + "onInitializeAccessibilityNodeInfo, scrollable: " + info.isScrollable()); + } + } + + @Override + public void setLayoutFrozen(boolean frozen) { + final boolean changing = frozen != isLayoutSuppressed(); + super.setLayoutFrozen(frozen); + if (changing) { + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "setLayoutFrozen " + frozen + + " @ " + Log.getStackTraceString(new Throwable())); + ActivityContext.lookupContext(getContext()).getDragLayer() + .sendAccessibilityEvent(TYPE_WINDOW_CONTENT_CHANGED); + } + } + } } \ No newline at end of file diff --git a/src/com/android/launcher3/widget/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/WidgetsRecyclerView.java index 63e063f59e..17baa271e2 100644 --- a/src/com/android/launcher3/widget/WidgetsRecyclerView.java +++ b/src/com/android/launcher3/widget/WidgetsRecyclerView.java @@ -22,7 +22,6 @@ import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.View; -import android.view.accessibility.AccessibilityNodeInfo; import com.android.launcher3.BaseRecyclerView; import com.android.launcher3.R; @@ -210,24 +209,4 @@ public class WidgetsRecyclerView extends BaseRecyclerView implements OnItemTouch } super.stopNestedScroll(); } - - @Override - public void setLayoutFrozen(boolean frozen) { - if (frozen != isLayoutSuppressed()) { - if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { - Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "setLayoutFrozen " + frozen - + " @ " + android.util.Log.getStackTraceString(new Throwable())); - } - } - super.setLayoutFrozen(frozen); - } - - @Override - public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfo(info); - if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { - Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, - "onInitializeAccessibilityNodeInfo, scrollable: " + info.isScrollable()); - } - } } \ No newline at end of file