From 5b6870398d1c573a946736f3fca8273678de46f2 Mon Sep 17 00:00:00 2001 From: Mark Renouf Date: Thu, 2 May 2024 16:06:13 -0400 Subject: Clean up onApplyWindowInsets and apply in all cases Profile pager empty state inset padding was only applied when 'hasWorkProfile' was true. This seems to have been an alias for "are tabs shown", however this is no longer correct. Instead the "empty content" padding should include system bar insets unconditionally. For a test case, enable 3-button nav, add a private profile and test sharing content which has no matching apps (ShareTest with no text). The empty state view is shown partially beneath the nav bar. Bug: 338447666 Test: manually; see change description Flag: com.android.intentresolver.fix_empty_state_padding Change-Id: I8a65214095de3517330d75e20da9bf0d35a82bac --- .../android/intentresolver/ChooserActivity.java | 28 +++++++++------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'java') diff --git a/java/src/com/android/intentresolver/ChooserActivity.java b/java/src/com/android/intentresolver/ChooserActivity.java index ccf2a3dc..1922c05c 100644 --- a/java/src/com/android/intentresolver/ChooserActivity.java +++ b/java/src/com/android/intentresolver/ChooserActivity.java @@ -1170,19 +1170,6 @@ public class ChooserActivity extends Hilt_ChooserActivity implements safelyStartActivityAsUser(cti, user, null); } - protected WindowInsets super_onApplyWindowInsets(View v, WindowInsets insets) { - mSystemWindowInsets = insets.getSystemWindowInsets(); - - mResolverDrawerLayout.setPadding(mSystemWindowInsets.left, mSystemWindowInsets.top, - mSystemWindowInsets.right, 0); - - // Need extra padding so the list can fully scroll up - // To accommodate for window insets - applyFooterView(mSystemWindowInsets.bottom); - - return insets.consumeSystemWindowInsets(); - } - @Override // ResolverListCommunicator public final void onHandlePackagesChanged(ResolverListAdapter listAdapter) { if (!mChooserMultiProfilePagerAdapter.onHandlePackagesChanged( @@ -2649,16 +2636,23 @@ public class ChooserActivity extends Hilt_ChooserActivity implements } protected WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { - if (mProfiles.getWorkProfilePresent()) { + mSystemWindowInsets = insets.getInsets(WindowInsets.Type.systemBars()); + if (mFeatureFlags.fixEmptyStatePadding() || mProfiles.getWorkProfilePresent()) { mChooserMultiProfilePagerAdapter - .setEmptyStateBottomOffset(insets.getSystemWindowInsetBottom()); + .setEmptyStateBottomOffset(mSystemWindowInsets.bottom); } - WindowInsets result = super_onApplyWindowInsets(v, insets); + mResolverDrawerLayout.setPadding(mSystemWindowInsets.left, mSystemWindowInsets.top, + mSystemWindowInsets.right, 0); + + // Need extra padding so the list can fully scroll up + // To accommodate for window insets + applyFooterView(mSystemWindowInsets.bottom); + if (mResolverDrawerLayout != null) { mResolverDrawerLayout.requestLayout(); } - return result; + return WindowInsets.CONSUMED; } private void setHorizontalScrollingEnabled(boolean enabled) { -- cgit v1.2.3-59-g8ed1b