From 95ede7fb5380a2f862175114f9e74916652d1fa8 Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Fri, 6 Dec 2019 13:55:54 -0500 Subject: [DO NOT MERGE] Resolver/Chooser - Window inset fixes Resolver supports numerous layouts, with optional ViewGroups. Need to make sure the window inset is applied to the correct view. If there is a List present, add a footer so that the list scrolls underneath the navbar. Test: atest ResolverActivityTest Bug: 145670872 Change-Id: I94652c5e0068436878a307701b5785f02060b8d6 --- .../com/android/internal/app/ChooserActivity.java | 6 ++++++ .../com/android/internal/app/ResolverActivity.java | 20 +++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index efa0432e5d17..8f2aea3937c6 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -2562,6 +2562,12 @@ public class ChooserActivity extends ResolverActivity { } } + @Override + protected boolean shouldAddFooterView() { + // To accommodate for window insets + return true; + } + public class ChooserListAdapter extends ResolveListAdapter { public static final int TARGET_BAD = -1; public static final int TARGET_CALLER = 0; diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java index f82c28e8e970..3a9d4d545e78 100644 --- a/core/java/com/android/internal/app/ResolverActivity.java +++ b/core/java/com/android/internal/app/ResolverActivity.java @@ -382,14 +382,30 @@ public class ResolverActivity extends Activity { finish(); } + /** + * Numerous layouts are supported, each with optional ViewGroups. + * Make sure the inset gets added to the correct View, using + * a footer for Lists so it can properly scroll under the navbar. + */ + protected boolean shouldAddFooterView() { + if (useLayoutWithDefault()) return true; + + View buttonBar = findViewById(R.id.button_bar); + if (buttonBar == null || buttonBar.getVisibility() == View.GONE) return true; + + return false; + } + protected WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { mSystemWindowInsets = insets.getSystemWindowInsets(); mResolverDrawerLayout.setPadding(mSystemWindowInsets.left, mSystemWindowInsets.top, mSystemWindowInsets.right, 0); + resetButtonBar(); + // Need extra padding so the list can fully scroll up - if (useLayoutWithDefault()) { + if (shouldAddFooterView()) { if (mFooterSpacer == null) { mFooterSpacer = new Space(getApplicationContext()); } else { @@ -407,8 +423,6 @@ public class ResolverActivity extends Activity { } } - resetButtonBar(); - return insets.consumeSystemWindowInsets(); } -- cgit v1.2.3-59-g8ed1b