Merge "Fix handling of bad image previews." into rvc-qpr-dev am: a102616d48
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12684870 Change-Id: Id4d3c2c864c512e4d57d6552b0b357a2f3c60cf0
This commit is contained in:
@@ -273,8 +273,6 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
private int mLastNumberOfChildren = -1;
|
private int mLastNumberOfChildren = -1;
|
||||||
|
|
||||||
private static final String TARGET_DETAILS_FRAGMENT_TAG = "targetDetailsFragment";
|
private static final String TARGET_DETAILS_FRAGMENT_TAG = "targetDetailsFragment";
|
||||||
// TODO: Update to handle landscape instead of using static value
|
|
||||||
private static final int MAX_RANKED_TARGETS = 4;
|
|
||||||
|
|
||||||
private final List<ChooserTargetServiceConnection> mServiceConnections = new ArrayList<>();
|
private final List<ChooserTargetServiceConnection> mServiceConnections = new ArrayList<>();
|
||||||
private final Set<Pair<ComponentName, UserHandle>> mServicesRequested = new HashSet<>();
|
private final Set<Pair<ComponentName, UserHandle>> mServicesRequested = new HashSet<>();
|
||||||
@@ -951,7 +949,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
updateStickyContentPreview();
|
updateStickyContentPreview();
|
||||||
if (shouldShowStickyContentPreview()
|
if (shouldShowStickyContentPreview()
|
||||||
|| mChooserMultiProfilePagerAdapter
|
|| mChooserMultiProfilePagerAdapter
|
||||||
.getCurrentRootAdapter().getContentPreviewRowCount() != 0) {
|
.getCurrentRootAdapter().getSystemRowCount() != 0) {
|
||||||
logActionShareWithPreview();
|
logActionShareWithPreview();
|
||||||
}
|
}
|
||||||
return postRebuildListInternal(rebuildCompleted);
|
return postRebuildListInternal(rebuildCompleted);
|
||||||
@@ -1316,13 +1314,14 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
ViewGroup parent) {
|
ViewGroup parent) {
|
||||||
ViewGroup contentPreviewLayout = (ViewGroup) layoutInflater.inflate(
|
ViewGroup contentPreviewLayout = (ViewGroup) layoutInflater.inflate(
|
||||||
R.layout.chooser_grid_preview_image, parent, false);
|
R.layout.chooser_grid_preview_image, parent, false);
|
||||||
|
ViewGroup imagePreview = contentPreviewLayout.findViewById(R.id.content_preview_image_area);
|
||||||
|
|
||||||
final ViewGroup actionRow =
|
final ViewGroup actionRow =
|
||||||
(ViewGroup) contentPreviewLayout.findViewById(R.id.chooser_action_row);
|
(ViewGroup) contentPreviewLayout.findViewById(R.id.chooser_action_row);
|
||||||
//TODO: addActionButton(actionRow, createCopyButton());
|
//TODO: addActionButton(actionRow, createCopyButton());
|
||||||
addActionButton(actionRow, createNearbyButton(targetIntent));
|
addActionButton(actionRow, createNearbyButton(targetIntent));
|
||||||
|
|
||||||
mPreviewCoord = new ContentPreviewCoordinator(contentPreviewLayout, true);
|
mPreviewCoord = new ContentPreviewCoordinator(contentPreviewLayout, false);
|
||||||
|
|
||||||
String action = targetIntent.getAction();
|
String action = targetIntent.getAction();
|
||||||
if (Intent.ACTION_SEND.equals(action)) {
|
if (Intent.ACTION_SEND.equals(action)) {
|
||||||
@@ -1342,7 +1341,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
if (imageUris.size() == 0) {
|
if (imageUris.size() == 0) {
|
||||||
Log.i(TAG, "Attempted to display image preview area with zero"
|
Log.i(TAG, "Attempted to display image preview area with zero"
|
||||||
+ " available images detected in EXTRA_STREAM list");
|
+ " available images detected in EXTRA_STREAM list");
|
||||||
contentPreviewLayout.setVisibility(View.GONE);
|
imagePreview.setVisibility(View.GONE);
|
||||||
return contentPreviewLayout;
|
return contentPreviewLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2683,7 +2682,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
final int bottomInset = mSystemWindowInsets != null
|
final int bottomInset = mSystemWindowInsets != null
|
||||||
? mSystemWindowInsets.bottom : 0;
|
? mSystemWindowInsets.bottom : 0;
|
||||||
int offset = bottomInset;
|
int offset = bottomInset;
|
||||||
int rowsToShow = gridAdapter.getContentPreviewRowCount()
|
int rowsToShow = gridAdapter.getSystemRowCount()
|
||||||
+ gridAdapter.getProfileRowCount()
|
+ gridAdapter.getProfileRowCount()
|
||||||
+ gridAdapter.getServiceTargetRowCount()
|
+ gridAdapter.getServiceTargetRowCount()
|
||||||
+ gridAdapter.getCallerAndRankedTargetRowCount();
|
+ gridAdapter.getCallerAndRankedTargetRowCount();
|
||||||
@@ -3283,7 +3282,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
|
|
||||||
public int getRowCount() {
|
public int getRowCount() {
|
||||||
return (int) (
|
return (int) (
|
||||||
getContentPreviewRowCount()
|
getSystemRowCount()
|
||||||
+ getProfileRowCount()
|
+ getProfileRowCount()
|
||||||
+ getServiceTargetRowCount()
|
+ getServiceTargetRowCount()
|
||||||
+ getCallerAndRankedTargetRowCount()
|
+ getCallerAndRankedTargetRowCount()
|
||||||
@@ -3295,22 +3294,21 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns either {@code 0} or {@code 1} depending on whether we want to show the list item
|
* Whether the "system" row of targets is displayed.
|
||||||
* content preview. Not to be confused with the sticky content preview which is above the
|
* This area includes the content preview (if present) and action row.
|
||||||
* personal and work tabs.
|
|
||||||
*/
|
*/
|
||||||
public int getContentPreviewRowCount() {
|
public int getSystemRowCount() {
|
||||||
// For the tabbed case we show the sticky content preview above the tabs,
|
// For the tabbed case we show the sticky content preview above the tabs,
|
||||||
// please refer to shouldShowStickyContentPreview
|
// please refer to shouldShowStickyContentPreview
|
||||||
if (shouldShowTabs()) {
|
if (shouldShowTabs()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSendAction(getTargetIntent())) {
|
if (!isSendAction(getTargetIntent())) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHideContentPreview || mChooserListAdapter == null
|
if (mChooserListAdapter == null || mChooserListAdapter.getCount() == 0) {
|
||||||
|| mChooserListAdapter.getCount() == 0) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3352,7 +3350,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return (int) (
|
return (int) (
|
||||||
getContentPreviewRowCount()
|
getSystemRowCount()
|
||||||
+ getProfileRowCount()
|
+ getProfileRowCount()
|
||||||
+ getServiceTargetRowCount()
|
+ getServiceTargetRowCount()
|
||||||
+ getCallerAndRankedTargetRowCount()
|
+ getCallerAndRankedTargetRowCount()
|
||||||
@@ -3407,7 +3405,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
int countSum = (count = getContentPreviewRowCount());
|
int countSum = (count = getSystemRowCount());
|
||||||
if (count > 0 && position < countSum) return VIEW_TYPE_CONTENT_PREVIEW;
|
if (count > 0 && position < countSum) return VIEW_TYPE_CONTENT_PREVIEW;
|
||||||
|
|
||||||
countSum += (count = getProfileRowCount());
|
countSum += (count = getProfileRowCount());
|
||||||
@@ -3631,7 +3629,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
int getListPosition(int position) {
|
int getListPosition(int position) {
|
||||||
position -= getContentPreviewRowCount() + getProfileRowCount();
|
position -= getSystemRowCount() + getProfileRowCount();
|
||||||
|
|
||||||
final int serviceCount = mChooserListAdapter.getServiceTargetCount();
|
final int serviceCount = mChooserListAdapter.getServiceTargetCount();
|
||||||
final int serviceRows = (int) Math.ceil((float) serviceCount
|
final int serviceRows = (int) Math.ceil((float) serviceCount
|
||||||
|
|||||||
Reference in New Issue
Block a user