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

Commit 416a1b34 authored by arangelov's avatar arangelov
Browse files

Show 2nd row if we have 1 row in active profile and empty state in other

Fixes: 157982025
Test: manual
Test: atest ChooserActivityTest
Test: atest ResolverActivityTest
Change-Id: Ifa525bad5d89d2ea6192044c6e2bb63310c57693
parent 7c510c22
Loading
Loading
Loading
Loading
+16 −0
Original line number Original line Diff line number Diff line
@@ -2648,6 +2648,7 @@ public class ChooserActivity extends ResolverActivity implements
                if (recyclerView.getVisibility() == View.VISIBLE) {
                if (recyclerView.getVisibility() == View.VISIBLE) {
                    int directShareHeight = 0;
                    int directShareHeight = 0;
                    rowsToShow = Math.min(4, rowsToShow);
                    rowsToShow = Math.min(4, rowsToShow);
                    boolean shouldShowExtraRow = shouldShowExtraRow(rowsToShow);
                    mLastNumberOfChildren = recyclerView.getChildCount();
                    mLastNumberOfChildren = recyclerView.getChildCount();
                    for (int i = 0, childCount = recyclerView.getChildCount();
                    for (int i = 0, childCount = recyclerView.getChildCount();
                            i < childCount && rowsToShow > 0; i++) {
                            i < childCount && rowsToShow > 0; i++) {
@@ -2658,6 +2659,9 @@ public class ChooserActivity extends ResolverActivity implements
                        }
                        }
                        int height = child.getHeight();
                        int height = child.getHeight();
                        offset += height;
                        offset += height;
                        if (shouldShowExtraRow) {
                            offset += height;
                        }


                        if (gridAdapter.getTargetType(
                        if (gridAdapter.getTargetType(
                                recyclerView.getChildAdapterPosition(child))
                                recyclerView.getChildAdapterPosition(child))
@@ -2692,6 +2696,18 @@ public class ChooserActivity extends ResolverActivity implements
        }
        }
    }
    }


    /**
     * If we have a tabbed view and are showing 1 row in the current profile and an empty
     * state screen in the other profile, to prevent cropping of the empty state screen we show
     * a second row in the current profile.
     */
    private boolean shouldShowExtraRow(int rowsToShow) {
        return shouldShowTabs()
                && rowsToShow == 1
                && mChooserMultiProfilePagerAdapter.shouldShowEmptyStateScreen(
                        mChooserMultiProfilePagerAdapter.getInactiveListAdapter());
    }

    /**
    /**
     * Returns {@link #PROFILE_PERSONAL}, {@link #PROFILE_WORK}, or -1 if the given user handle
     * Returns {@link #PROFILE_PERSONAL}, {@link #PROFILE_WORK}, or -1 if the given user handle
     * does not match either the personal or work user handle.
     * does not match either the personal or work user handle.