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

Commit 28bb4fe9 authored by arangelov's avatar arangelov
Browse files

Add bottom offset to empty state screens for chooser

Test: manual
Test: atest ResolverActivityTest
Test: atest ChooserActivityTest
Fixes: 153654313
Change-Id: I36f55425a2c4daff52d7732d5c71445eb2c03527
parent dfb06b85
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.Button;
@@ -2677,7 +2678,7 @@ public class ChooserActivity extends ResolverActivity implements
                        offset = Math.min(offset, minHeight);
                    }
                } else {
                    ViewGroup currentEmptyStateView = getCurrentEmptyStateView();
                    ViewGroup currentEmptyStateView = getActiveEmptyStateView();
                    if (currentEmptyStateView.getVisibility() == View.VISIBLE) {
                        offset += currentEmptyStateView.getHeight();
                    }
@@ -2702,7 +2703,7 @@ public class ChooserActivity extends ResolverActivity implements
        return -1;
    }

    private ViewGroup getCurrentEmptyStateView() {
    private ViewGroup getActiveEmptyStateView() {
        int currentPage = mChooserMultiProfilePagerAdapter.getCurrentPage();
        return mChooserMultiProfilePagerAdapter.getItem(currentPage).getEmptyStateView();
    }
@@ -3027,6 +3028,17 @@ public class ChooserActivity extends ResolverActivity implements
        intent.fixUris(UserHandle.myUserId());
    }

    @Override
    protected WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
        if (shouldShowTabs()) {
            mChooserMultiProfilePagerAdapter
                    .setEmptyStateBottomOffset(insets.getSystemWindowInsetBottom());
            mChooserMultiProfilePagerAdapter.setupContainerPadding(
                    getActiveEmptyStateView().findViewById(R.id.resolver_empty_state_container));
        }
        return super.onApplyWindowInsets(v, insets);
    }

    /**
     * Adapter for all types of items and targets in ShareSheet.
     * Note that ranked sections like Direct Share - while appearing grid-like - are handled on the
+11 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd

    private final ChooserProfileDescriptor[] mItems;
    private final boolean mIsSendAction;
    private int mBottomOffset;

    ChooserMultiProfilePagerAdapter(Context context,
            ChooserActivity.ChooserGridAdapter adapter,
@@ -245,6 +246,16 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd
        }
    }

    void setEmptyStateBottomOffset(int bottomOffset) {
        mBottomOffset = bottomOffset;
    }

    @Override
    protected void setupContainerPadding(View container) {
        container.setPadding(container.getPaddingLeft(), container.getPaddingTop(),
                container.getPaddingRight(), container.getPaddingBottom() + mBottomOffset);
    }

    class ChooserProfileDescriptor extends ProfileDescriptor {
        private ChooserActivity.ChooserGridAdapter chooserGridAdapter;
        private RecyclerView recyclerView;