Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a30787b8 authored by arangelov's avatar arangelov
Browse files

When calculating share sheet height, account for empty state screens.

As we calculate the share sheet height only for the current profile,
there is a rare case when the current profile may have no results.
For that case, we need to adjust the share sheet offset so that
it includes the empty state screen height.

In addition, this CL also does an early return if we are
in the non-main profile (e.g. personal tab in work profile)
to prevent the height from being recalculated upon tab switch.

Fixes: 150939637
Test: manual
Change-Id: Ia465f53d7a2006e1b7c67ad1e95729ed79e2c3a0
parent 5527ace0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -452,7 +452,7 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
            mEmptyStateView = rootView.findViewById(R.id.resolver_empty_state);
        }

        private ViewGroup getEmptyStateView() {
        protected ViewGroup getEmptyStateView() {
            return mEmptyStateView;
        }
    }
+44 −30
Original line number Diff line number Diff line
@@ -2411,6 +2411,8 @@ public class ChooserActivity extends ResolverActivity implements
                mChooserMultiProfilePagerAdapter.getActiveAdapterView()
                        .setAdapter(mChooserMultiProfilePagerAdapter.getCurrentRootAdapter());
                return;
            } else if (mChooserMultiProfilePagerAdapter.getCurrentUserHandle() != getUser()) {
                return;
            }

            getMainThreadHandler().post(() -> {
@@ -2455,6 +2457,7 @@ public class ChooserActivity extends ResolverActivity implements
                    offset += tabDivider.getHeight();
                }

                if (recyclerView.getVisibility() == View.VISIBLE) {
                    int directShareHeight = 0;
                    rowsToShow = Math.min(4, rowsToShow);
                    mLastNumberOfChildren = recyclerView.getChildCount();
@@ -2489,12 +2492,23 @@ public class ChooserActivity extends ResolverActivity implements

                        offset = Math.min(offset, minHeight);
                    }
                } else {
                    ViewGroup currentEmptyStateView = getCurrentEmptyStateView();
                    if (currentEmptyStateView.getVisibility() == View.VISIBLE) {
                        offset += currentEmptyStateView.getHeight();
                    }
                }

                mResolverDrawerLayout.setCollapsibleHeightReserved(Math.min(offset, bottom - top));
            });
        }
    }

    private ViewGroup getCurrentEmptyStateView() {
        int currentPage = mChooserMultiProfilePagerAdapter.getCurrentPage();
        return mChooserMultiProfilePagerAdapter.getItem(currentPage).getEmptyStateView();
    }

    static class BaseChooserTargetComparator implements Comparator<ChooserTarget> {
        @Override
        public int compare(ChooserTarget lhs, ChooserTarget rhs) {