Merge "When calculating share sheet height, account for empty state screens." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4b705f50ab
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,39 +2457,46 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
offset += tabDivider.getHeight();
|
||||
}
|
||||
|
||||
int directShareHeight = 0;
|
||||
rowsToShow = Math.min(4, rowsToShow);
|
||||
mLastNumberOfChildren = recyclerView.getChildCount();
|
||||
for (int i = 0, childCount = recyclerView.getChildCount();
|
||||
i < childCount && rowsToShow > 0; i++) {
|
||||
View child = recyclerView.getChildAt(i);
|
||||
if (((GridLayoutManager.LayoutParams)
|
||||
child.getLayoutParams()).getSpanIndex() != 0) {
|
||||
continue;
|
||||
if (recyclerView.getVisibility() == View.VISIBLE) {
|
||||
int directShareHeight = 0;
|
||||
rowsToShow = Math.min(4, rowsToShow);
|
||||
mLastNumberOfChildren = recyclerView.getChildCount();
|
||||
for (int i = 0, childCount = recyclerView.getChildCount();
|
||||
i < childCount && rowsToShow > 0; i++) {
|
||||
View child = recyclerView.getChildAt(i);
|
||||
if (((GridLayoutManager.LayoutParams)
|
||||
child.getLayoutParams()).getSpanIndex() != 0) {
|
||||
continue;
|
||||
}
|
||||
int height = child.getHeight();
|
||||
offset += height;
|
||||
|
||||
if (gridAdapter.getTargetType(
|
||||
recyclerView.getChildAdapterPosition(child))
|
||||
== ChooserListAdapter.TARGET_SERVICE) {
|
||||
directShareHeight = height;
|
||||
}
|
||||
rowsToShow--;
|
||||
}
|
||||
int height = child.getHeight();
|
||||
offset += height;
|
||||
|
||||
if (gridAdapter.getTargetType(
|
||||
recyclerView.getChildAdapterPosition(child))
|
||||
== ChooserListAdapter.TARGET_SERVICE) {
|
||||
directShareHeight = height;
|
||||
boolean isExpandable = getResources().getConfiguration().orientation
|
||||
== Configuration.ORIENTATION_PORTRAIT && !isInMultiWindowMode();
|
||||
if (directShareHeight != 0 && isSendAction(getTargetIntent())
|
||||
&& isExpandable) {
|
||||
// make sure to leave room for direct share 4->8 expansion
|
||||
int requiredExpansionHeight =
|
||||
(int) (directShareHeight / DIRECT_SHARE_EXPANSION_RATE);
|
||||
int topInset = mSystemWindowInsets != null ? mSystemWindowInsets.top : 0;
|
||||
int minHeight = bottom - top - mResolverDrawerLayout.getAlwaysShowHeight()
|
||||
- requiredExpansionHeight - topInset - bottomInset;
|
||||
|
||||
offset = Math.min(offset, minHeight);
|
||||
}
|
||||
} else {
|
||||
ViewGroup currentEmptyStateView = getCurrentEmptyStateView();
|
||||
if (currentEmptyStateView.getVisibility() == View.VISIBLE) {
|
||||
offset += currentEmptyStateView.getHeight();
|
||||
}
|
||||
rowsToShow--;
|
||||
}
|
||||
|
||||
boolean isExpandable = getResources().getConfiguration().orientation
|
||||
== Configuration.ORIENTATION_PORTRAIT && !isInMultiWindowMode();
|
||||
if (directShareHeight != 0 && isSendAction(getTargetIntent())
|
||||
&& isExpandable) {
|
||||
// make sure to leave room for direct share 4->8 expansion
|
||||
int requiredExpansionHeight =
|
||||
(int) (directShareHeight / DIRECT_SHARE_EXPANSION_RATE);
|
||||
int topInset = mSystemWindowInsets != null ? mSystemWindowInsets.top : 0;
|
||||
int minHeight = bottom - top - mResolverDrawerLayout.getAlwaysShowHeight()
|
||||
- requiredExpansionHeight - topInset - bottomInset;
|
||||
|
||||
offset = Math.min(offset, minHeight);
|
||||
}
|
||||
|
||||
mResolverDrawerLayout.setCollapsibleHeightReserved(Math.min(offset, bottom - top));
|
||||
@@ -2495,6 +2504,11 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user