From e8faa129879de450efc0b8389000e73b05b01527 Mon Sep 17 00:00:00 2001 From: Ben Reich Date: Fri, 7 Mar 2025 15:39:36 +1100 Subject: Add WindowInsets back on non-freeform window devices For Material3 the bottom window insets were removed. Unfortunately this means the navigation gesture swipe at the base of the window overlaps the picker / saver bottom bar. This is particularly bad in the saver where the bottom bar is a text box and the gesture navigation interferes with moving the cursor in the text box. This also has the benefit of adding the behaviour where the textbox appears above the soft keyboard. Prior to this if you pressed the textbox (with material 3 enabled) it would not appear above the soft keyboard and remain hidden. Bug: 400337159 Test: Deploy to Pixel 6 and observe bottom bar is above gesture bar Flag: com.android.documentsui.flags.use_material3 Change-Id: I846ff9718455183bc136fb6ff90adb7c9b590e6d --- src/com/android/documentsui/BaseActivity.java | 41 ++++++++++++++++----------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/com/android/documentsui/BaseActivity.java b/src/com/android/documentsui/BaseActivity.java index 0b5d96da9..790feeac4 100644 --- a/src/com/android/documentsui/BaseActivity.java +++ b/src/com/android/documentsui/BaseActivity.java @@ -569,23 +569,32 @@ public abstract class BaseActivity View root = findViewById(R.id.coordinator_layout); root.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); - root.setOnApplyWindowInsetsListener((v, insets) -> { - root.setPadding(insets.getSystemWindowInsetLeft(), - insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), 0); - - // When use_material3 flag is ON, no additional bottom gap in full screen mode. - if (!isUseMaterial3FlagEnabled()) { - View saveContainer = findViewById(R.id.container_save); - saveContainer.setPadding( - 0, 0, 0, insets.getSystemWindowInsetBottom()); - - View rootsContainer = findViewById(R.id.container_roots); - rootsContainer.setPadding( - 0, 0, 0, insets.getSystemWindowInsetBottom()); - } + root.setOnApplyWindowInsetsListener( + (v, insets) -> { + root.setPadding( + insets.getSystemWindowInsetLeft(), + insets.getSystemWindowInsetTop(), + insets.getSystemWindowInsetRight(), + 0); + + // When use_material3 flag is ON and FEATURE_FREEFORM_WINDOW_MANAGEMENT is + // enabled, then there should not be any additional bottom gap in full screen + // mode. Otherwise need to take into account the system window insets such as + // the bottom swipe up navigation gesture. + if (!isUseMaterial3FlagEnabled() + || !getApplicationContext() + .getPackageManager() + .hasSystemFeature( + PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT)) { + View saveContainer = findViewById(R.id.container_save); + saveContainer.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); + + View rootsContainer = findViewById(R.id.container_roots); + rootsContainer.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); + } - return insets.consumeSystemWindowInsets(); - }); + return insets.consumeSystemWindowInsets(); + }); getWindow().setNavigationBarDividerColor(Color.TRANSPARENT); if (Build.VERSION.SDK_INT >= 29) { -- cgit v1.2.3-59-g8ed1b