Merge "Fix sharesheet height expansion." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9c3ed4de9f
@@ -154,7 +154,6 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
|
||||
@Override
|
||||
public ViewGroup instantiateItem(ViewGroup container, int position) {
|
||||
final ProfileDescriptor profileDescriptor = getItem(position);
|
||||
setupListAdapter(position);
|
||||
container.addView(profileDescriptor.rootView);
|
||||
return profileDescriptor.rootView;
|
||||
}
|
||||
@@ -208,8 +207,8 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
|
||||
abstract int getItemCount();
|
||||
|
||||
/**
|
||||
* Responsible for assigning an adapter to the list view for the relevant page, specified by
|
||||
* <code>pageIndex</code>, and other list view-related initialization procedures.
|
||||
* Performs view-related initialization procedures for the adapter specified
|
||||
* by <code>pageIndex</code>.
|
||||
*/
|
||||
abstract void setupListAdapter(int pageIndex);
|
||||
|
||||
|
||||
@@ -241,6 +241,7 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
private int mChooserRowServiceSpacing;
|
||||
|
||||
private int mCurrAvailableWidth = 0;
|
||||
private int mLastNumberOfChildren = -1;
|
||||
|
||||
private static final String TARGET_DETAILS_FRAGMENT_TAG = "targetDetailsFragment";
|
||||
// TODO: Update to handle landscape instead of using static value
|
||||
@@ -967,6 +968,7 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
adjustPreviewWidth(newConfig.orientation, null);
|
||||
updateStickyContentPreview();
|
||||
}
|
||||
|
||||
private boolean shouldDisplayLandscape(int orientation) {
|
||||
@@ -987,8 +989,6 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
updateLayoutWidth(R.id.content_preview_text_layout, width, parent);
|
||||
updateLayoutWidth(R.id.content_preview_title_layout, width, parent);
|
||||
updateLayoutWidth(R.id.content_preview_file_layout, width, parent);
|
||||
findViewById(R.id.content_preview_container)
|
||||
.setVisibility(shouldShowStickyContentPreview() ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
private void updateLayoutWidth(int layoutResourceId, int width, View parent) {
|
||||
@@ -2398,14 +2398,17 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
}
|
||||
|
||||
final int availableWidth = right - left - v.getPaddingLeft() - v.getPaddingRight();
|
||||
if (mChooserMultiProfilePagerAdapter.getCurrentUserHandle() != getUser()) {
|
||||
gridAdapter.calculateChooserTargetWidth(availableWidth);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gridAdapter.consumeLayoutRequest()
|
||||
|| gridAdapter.calculateChooserTargetWidth(availableWidth)
|
||||
|| recyclerView.getAdapter() == null
|
||||
|| mLastNumberOfChildren != recyclerView.getChildCount()
|
||||
|| availableWidth != mCurrAvailableWidth) {
|
||||
mCurrAvailableWidth = availableWidth;
|
||||
recyclerView.setAdapter(gridAdapter);
|
||||
((GridLayoutManager) recyclerView.getLayoutManager())
|
||||
.setSpanCount(gridAdapter.getMaxTargetsPerRow());
|
||||
|
||||
getMainThreadHandler().post(() -> {
|
||||
if (mResolverDrawerLayout == null || gridAdapter == null) {
|
||||
@@ -2415,7 +2418,8 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
final int bottomInset = mSystemWindowInsets != null
|
||||
? mSystemWindowInsets.bottom : 0;
|
||||
int offset = bottomInset;
|
||||
int rowsToShow = gridAdapter.getProfileRowCount()
|
||||
int rowsToShow = gridAdapter.getContentPreviewRowCount()
|
||||
+ gridAdapter.getProfileRowCount()
|
||||
+ gridAdapter.getServiceTargetRowCount()
|
||||
+ gridAdapter.getCallerAndRankedTargetRowCount();
|
||||
|
||||
@@ -2434,8 +2438,9 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
return;
|
||||
}
|
||||
|
||||
if (shouldShowStickyContentPreview()) {
|
||||
offset += findViewById(R.id.content_preview_container).getHeight();
|
||||
View stickyContentPreview = findViewById(R.id.content_preview_container);
|
||||
if (shouldShowStickyContentPreview() && isStickyContentPreviewShowing()) {
|
||||
offset += stickyContentPreview.getHeight();
|
||||
}
|
||||
|
||||
if (shouldShowTabs()) {
|
||||
@@ -2444,6 +2449,7 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
|
||||
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);
|
||||
@@ -2526,6 +2532,14 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
setupScrollListener();
|
||||
|
||||
ChooserListAdapter chooserListAdapter = (ChooserListAdapter) listAdapter;
|
||||
if (chooserListAdapter.getUserHandle()
|
||||
== mChooserMultiProfilePagerAdapter.getCurrentUserHandle()) {
|
||||
mChooserMultiProfilePagerAdapter.getActiveAdapterView()
|
||||
.setAdapter(mChooserMultiProfilePagerAdapter.getCurrentRootAdapter());
|
||||
mChooserMultiProfilePagerAdapter
|
||||
.setupListAdapter(mChooserMultiProfilePagerAdapter.getCurrentPage());
|
||||
}
|
||||
|
||||
if (chooserListAdapter.mDisplayList == null
|
||||
|| chooserListAdapter.mDisplayList.isEmpty()) {
|
||||
chooserListAdapter.notifyDataSetChanged();
|
||||
@@ -2617,14 +2631,29 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
* we instead show the content preview as a regular list item.
|
||||
*/
|
||||
private boolean shouldShowStickyContentPreview() {
|
||||
return shouldShowTabs()
|
||||
&& mMultiProfilePagerAdapter.getListAdapterForUserHandle(
|
||||
UserHandle.of(UserHandle.myUserId())).getCount() > 0
|
||||
&& isSendAction(getTargetIntent())
|
||||
return shouldShowStickyContentPreviewNoOrientationCheck()
|
||||
&& getResources().getBoolean(R.bool.sharesheet_show_content_preview);
|
||||
}
|
||||
|
||||
private boolean shouldShowStickyContentPreviewNoOrientationCheck() {
|
||||
return shouldShowTabs()
|
||||
&& mMultiProfilePagerAdapter.getListAdapterForUserHandle(
|
||||
UserHandle.of(UserHandle.myUserId())).getCount() > 0
|
||||
&& isSendAction(getTargetIntent());
|
||||
}
|
||||
|
||||
private void updateStickyContentPreview() {
|
||||
if (shouldShowStickyContentPreviewNoOrientationCheck()) {
|
||||
// The sticky content preview is only shown when we show the work and personal tabs.
|
||||
// We don't show it in landscape as otherwise there is no room for scrolling.
|
||||
// If the sticky content preview will be shown at some point with orientation change,
|
||||
// then always preload it to avoid subsequent resizing of the share sheet.
|
||||
ViewGroup contentPreviewContainer = findViewById(R.id.content_preview_container);
|
||||
if (contentPreviewContainer.getChildCount() == 0) {
|
||||
ViewGroup contentPreviewView = createContentPreviewView(contentPreviewContainer);
|
||||
contentPreviewContainer.addView(contentPreviewView);
|
||||
}
|
||||
}
|
||||
if (shouldShowStickyContentPreview()) {
|
||||
showStickyContentPreview();
|
||||
} else {
|
||||
@@ -2633,15 +2662,23 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
}
|
||||
|
||||
private void showStickyContentPreview() {
|
||||
if (isStickyContentPreviewShowing()) {
|
||||
return;
|
||||
}
|
||||
ViewGroup contentPreviewContainer = findViewById(R.id.content_preview_container);
|
||||
contentPreviewContainer.setVisibility(View.VISIBLE);
|
||||
ViewGroup contentPreviewView = createContentPreviewView(contentPreviewContainer);
|
||||
contentPreviewContainer.addView(contentPreviewView);
|
||||
}
|
||||
|
||||
private boolean isStickyContentPreviewShowing() {
|
||||
ViewGroup contentPreviewContainer = findViewById(R.id.content_preview_container);
|
||||
return contentPreviewContainer.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
|
||||
private void hideStickyContentPreview() {
|
||||
if (!isStickyContentPreviewShowing()) {
|
||||
return;
|
||||
}
|
||||
ViewGroup contentPreviewContainer = findViewById(R.id.content_preview_container);
|
||||
contentPreviewContainer.removeAllViews();
|
||||
contentPreviewContainer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,6 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd
|
||||
final RecyclerView recyclerView = getItem(pageIndex).recyclerView;
|
||||
ChooserActivity.ChooserGridAdapter chooserGridAdapter =
|
||||
getItem(pageIndex).chooserGridAdapter;
|
||||
recyclerView.setAdapter(chooserGridAdapter);
|
||||
GridLayoutManager glm = (GridLayoutManager) recyclerView.getLayoutManager();
|
||||
glm.setSpanCount(chooserGridAdapter.getMaxTargetsPerRow());
|
||||
glm.setSpanSizeLookup(
|
||||
|
||||
@@ -396,6 +396,11 @@ public class ResolverActivity extends Activity implements
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
||||
rdl.setOnApplyWindowInsetsListener(this::onApplyWindowInsets);
|
||||
|
||||
if (shouldShowTabs() && isIntentPicker()) {
|
||||
rdl.setMaxCollapsedHeight(getResources()
|
||||
.getDimensionPixelSize(R.dimen.resolver_max_collapsed_height_with_tabs));
|
||||
}
|
||||
|
||||
mResolverDrawerLayout = rdl;
|
||||
}
|
||||
|
||||
@@ -413,6 +418,10 @@ public class ResolverActivity extends Activity implements
|
||||
+ (categories != null ? Arrays.toString(categories.toArray()) : ""));
|
||||
}
|
||||
|
||||
private boolean isIntentPicker() {
|
||||
return getClass().equals(ResolverActivity.class);
|
||||
}
|
||||
|
||||
protected AbstractMultiProfilePagerAdapter createMultiProfilePagerAdapter(
|
||||
Intent[] initialIntents,
|
||||
List<ResolveInfo> rList,
|
||||
|
||||
@@ -93,6 +93,12 @@ public class ResolverMultiProfilePagerAdapter extends AbstractMultiProfilePagerA
|
||||
return mItems[pageIndex].resolverListAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewGroup instantiateItem(ViewGroup container, int position) {
|
||||
setupListAdapter(position);
|
||||
return super.instantiateItem(container, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
ResolverListAdapter getListAdapterForUserHandle(UserHandle userHandle) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.android.internal.widget.ViewPager;
|
||||
* A {@link ViewPager} which wraps around its tallest child's height.
|
||||
* <p>Normally {@link ViewPager} instances expand their height to cover all remaining space in
|
||||
* the layout.
|
||||
* <p>This class is used for the intent resolver's tabbed view.
|
||||
* <p>This class is used for the intent resolver and share sheet's tabbed view.
|
||||
*/
|
||||
public class ResolverViewPager extends ViewPager {
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
android:id="@android:id/tabcontent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<com.android.internal.widget.ViewPager
|
||||
<com.android.internal.app.ResolverViewPager
|
||||
android:id="@+id/profile_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:maxWidth="@dimen/resolver_max_width"
|
||||
android:maxCollapsedHeight="192dp"
|
||||
android:maxCollapsedHeight="@dimen/resolver_max_collapsed_height"
|
||||
android:maxCollapsedHeightSmall="56dp"
|
||||
android:id="@id/contentPanel">
|
||||
|
||||
|
||||
@@ -777,6 +777,8 @@
|
||||
<dimen name="resolver_elevation">1dp</dimen>
|
||||
<dimen name="resolver_empty_state_height">212dp</dimen>
|
||||
<dimen name="resolver_empty_state_height_with_tabs">268dp</dimen>
|
||||
<dimen name="resolver_max_collapsed_height">192dp</dimen>
|
||||
<dimen name="resolver_max_collapsed_height_with_tabs">248dp</dimen>
|
||||
|
||||
<dimen name="chooser_action_button_icon_size">18dp</dimen>
|
||||
|
||||
|
||||
@@ -3895,6 +3895,7 @@
|
||||
<java-symbol type="drawable" name="ic_no_apps" />
|
||||
<java-symbol type="dimen" name="resolver_empty_state_height" />
|
||||
<java-symbol type="dimen" name="resolver_empty_state_height_with_tabs" />
|
||||
<java-symbol type="dimen" name="resolver_max_collapsed_height_with_tabs" />
|
||||
<java-symbol type="bool" name="sharesheet_show_content_preview" />
|
||||
|
||||
<!-- Toast message for background started foreground service while-in-use permission restriction feature -->
|
||||
|
||||
Reference in New Issue
Block a user