From f5aa74b0e83fb3325a88b1f3dd407ffe6176c2a2 Mon Sep 17 00:00:00 2001 From: Mark Renouf Date: Fri, 14 Mar 2025 14:14:24 -0400 Subject: [PATCH] Fixes 'capture more' on Settings home page This change excludes the contents of 'main_content_scrollable_container' from scroll capture search. Explanation: The inner-most child is selected whenever nested scrolling views are found. This is incorrect for Settings because the inner RecyclerView isn't actually scrollable (that is, the contents of it are not scrolled within it, the RecyclerView itself is scrolled by the outer ScrollView instead). View.canScrollVertically is unfortunately incorrect for RecyclerView in this case as well. This change excludes all children of the main ScrollView from the search. This ensures the outer ScrollView is chosen and this corrects the 'capture more' screenshot functionality on the Settings home page. Bug: 399810823 Test: manual; Open settings, screenshot, capture more Flag: com.android.settings.flags.extended_screenshots_exclude_nested_scrollables Change-Id: I3363d70b3649e2a34e541c45ab387d59547b8588 --- aconfig/settings_flag_declarations.aconfig | 10 ++++++++++ .../settings/homepage/SettingsHomepageActivity.java | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/aconfig/settings_flag_declarations.aconfig b/aconfig/settings_flag_declarations.aconfig index 2971d22b5de..548a733db7e 100644 --- a/aconfig/settings_flag_declarations.aconfig +++ b/aconfig/settings_flag_declarations.aconfig @@ -80,3 +80,13 @@ flag { purpose: PURPOSE_BUGFIX } } + +flag { + name: "extended_screenshots_exclude_nested_scrollables" + namespace: "systemui" + description: "Sets a flag on the main scrollable container to exclude any nested scrollable views as potential targets for extended screenshots." + bug: "399810823" + metadata { + purpose: PURPOSE_BUGFIX + } +} diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java index 08acbc74c7e..f89e8fd6c45 100644 --- a/src/com/android/settings/homepage/SettingsHomepageActivity.java +++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java @@ -775,6 +775,16 @@ public class SettingsHomepageActivity extends FragmentActivity implements // Prevent inner RecyclerView gets focus and invokes scrolling. view.setFocusableInTouchMode(true); view.requestFocus(); + + if (Flags.extendedScreenshotsExcludeNestedScrollables()) { + // Force scroll capture to select the NestedScrollView, instead of the non-scrollable + // RecyclerView which is contained inside it with no height constraint. + final View scrollableContainer = findViewById(R.id.main_content_scrollable_container); + if (scrollableContainer != null) { + scrollableContainer.setScrollCaptureHint( + View.SCROLL_CAPTURE_HINT_EXCLUDE_DESCENDANTS); + } + } } private void updateHomepageAppBar() {