Merge "Fix sharesheet scroll jankiness." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
afbd12c4ed
@@ -158,6 +158,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
private static final String TAG = "ChooserActivity";
|
private static final String TAG = "ChooserActivity";
|
||||||
private AppPredictor mPersonalAppPredictor;
|
private AppPredictor mPersonalAppPredictor;
|
||||||
private AppPredictor mWorkAppPredictor;
|
private AppPredictor mWorkAppPredictor;
|
||||||
|
private boolean mShouldDisplayLandscape;
|
||||||
|
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public ChooserActivity() {
|
public ChooserActivity() {
|
||||||
@@ -716,6 +717,8 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
mCallerChooserTargets = targets;
|
mCallerChooserTargets = targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mShouldDisplayLandscape = shouldDisplayLandscape(
|
||||||
|
getResources().getConfiguration().orientation);
|
||||||
setRetainInOnStop(intent.getBooleanExtra(EXTRA_PRIVATE_RETAIN_IN_ON_STOP, false));
|
setRetainInOnStop(intent.getBooleanExtra(EXTRA_PRIVATE_RETAIN_IN_ON_STOP, false));
|
||||||
super.onCreate(savedInstanceState, target, title, defaultTitleRes, initialIntents,
|
super.onCreate(savedInstanceState, target, title, defaultTitleRes, initialIntents,
|
||||||
null, false);
|
null, false);
|
||||||
@@ -1073,6 +1076,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
|
|
||||||
|
mShouldDisplayLandscape = shouldDisplayLandscape(newConfig.orientation);
|
||||||
adjustPreviewWidth(newConfig.orientation, null);
|
adjustPreviewWidth(newConfig.orientation, null);
|
||||||
updateStickyContentPreview();
|
updateStickyContentPreview();
|
||||||
}
|
}
|
||||||
@@ -1086,7 +1090,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
|
|
||||||
private void adjustPreviewWidth(int orientation, View parent) {
|
private void adjustPreviewWidth(int orientation, View parent) {
|
||||||
int width = -1;
|
int width = -1;
|
||||||
if (shouldDisplayLandscape(orientation)) {
|
if (mShouldDisplayLandscape) {
|
||||||
width = getResources().getDimensionPixelSize(R.dimen.chooser_preview_width);
|
width = getResources().getDimensionPixelSize(R.dimen.chooser_preview_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2940,6 +2944,19 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
.setSubtype(previewType));
|
.setSubtype(previewType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ViewHolderBase extends RecyclerView.ViewHolder {
|
||||||
|
private int mViewType;
|
||||||
|
|
||||||
|
ViewHolderBase(View itemView, int viewType) {
|
||||||
|
super(itemView);
|
||||||
|
this.mViewType = viewType;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getViewType() {
|
||||||
|
return mViewType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to bind types of individual item including
|
* Used to bind types of individual item including
|
||||||
* {@link ChooserGridAdapter#VIEW_TYPE_NORMAL},
|
* {@link ChooserGridAdapter#VIEW_TYPE_NORMAL},
|
||||||
@@ -2947,12 +2964,12 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
* {@link ChooserGridAdapter#VIEW_TYPE_PROFILE},
|
* {@link ChooserGridAdapter#VIEW_TYPE_PROFILE},
|
||||||
* and {@link ChooserGridAdapter#VIEW_TYPE_AZ_LABEL}.
|
* and {@link ChooserGridAdapter#VIEW_TYPE_AZ_LABEL}.
|
||||||
*/
|
*/
|
||||||
final class ItemViewHolder extends RecyclerView.ViewHolder {
|
final class ItemViewHolder extends ViewHolderBase {
|
||||||
ResolverListAdapter.ViewHolder mWrappedViewHolder;
|
ResolverListAdapter.ViewHolder mWrappedViewHolder;
|
||||||
int mListPosition = ChooserListAdapter.NO_POSITION;
|
int mListPosition = ChooserListAdapter.NO_POSITION;
|
||||||
|
|
||||||
ItemViewHolder(View itemView, boolean isClickable) {
|
ItemViewHolder(View itemView, boolean isClickable, int viewType) {
|
||||||
super(itemView);
|
super(itemView, viewType);
|
||||||
mWrappedViewHolder = new ResolverListAdapter.ViewHolder(itemView);
|
mWrappedViewHolder = new ResolverListAdapter.ViewHolder(itemView);
|
||||||
if (isClickable) {
|
if (isClickable) {
|
||||||
itemView.setOnClickListener(v -> startSelected(mListPosition,
|
itemView.setOnClickListener(v -> startSelected(mListPosition,
|
||||||
@@ -2970,9 +2987,9 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
/**
|
/**
|
||||||
* Add a footer to the list, to support scrolling behavior below the navbar.
|
* Add a footer to the list, to support scrolling behavior below the navbar.
|
||||||
*/
|
*/
|
||||||
final class FooterViewHolder extends RecyclerView.ViewHolder {
|
final class FooterViewHolder extends ViewHolderBase {
|
||||||
FooterViewHolder(View itemView) {
|
FooterViewHolder(View itemView, int viewType) {
|
||||||
super(itemView);
|
super(itemView, viewType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3083,7 +3100,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
|
|
||||||
int getMaxTargetsPerRow() {
|
int getMaxTargetsPerRow() {
|
||||||
int maxTargets = MAX_TARGETS_PER_ROW_PORTRAIT;
|
int maxTargets = MAX_TARGETS_PER_ROW_PORTRAIT;
|
||||||
if (shouldDisplayLandscape(getResources().getConfiguration().orientation)) {
|
if (mShouldDisplayLandscape) {
|
||||||
maxTargets = MAX_TARGETS_PER_ROW_LANDSCAPE;
|
maxTargets = MAX_TARGETS_PER_ROW_LANDSCAPE;
|
||||||
}
|
}
|
||||||
return maxTargets;
|
return maxTargets;
|
||||||
@@ -3191,13 +3208,14 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
switch (viewType) {
|
switch (viewType) {
|
||||||
case VIEW_TYPE_CONTENT_PREVIEW:
|
case VIEW_TYPE_CONTENT_PREVIEW:
|
||||||
return new ItemViewHolder(createContentPreviewView(parent), false);
|
return new ItemViewHolder(createContentPreviewView(parent), false, viewType);
|
||||||
case VIEW_TYPE_PROFILE:
|
case VIEW_TYPE_PROFILE:
|
||||||
return new ItemViewHolder(createProfileView(parent), false);
|
return new ItemViewHolder(createProfileView(parent), false, viewType);
|
||||||
case VIEW_TYPE_AZ_LABEL:
|
case VIEW_TYPE_AZ_LABEL:
|
||||||
return new ItemViewHolder(createAzLabelView(parent), false);
|
return new ItemViewHolder(createAzLabelView(parent), false, viewType);
|
||||||
case VIEW_TYPE_NORMAL:
|
case VIEW_TYPE_NORMAL:
|
||||||
return new ItemViewHolder(mChooserListAdapter.createView(parent), true);
|
return new ItemViewHolder(
|
||||||
|
mChooserListAdapter.createView(parent), true, viewType);
|
||||||
case VIEW_TYPE_DIRECT_SHARE:
|
case VIEW_TYPE_DIRECT_SHARE:
|
||||||
case VIEW_TYPE_CALLER_AND_RANK:
|
case VIEW_TYPE_CALLER_AND_RANK:
|
||||||
return createItemGroupViewHolder(viewType, parent);
|
return createItemGroupViewHolder(viewType, parent);
|
||||||
@@ -3205,7 +3223,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
Space sp = new Space(parent.getContext());
|
Space sp = new Space(parent.getContext());
|
||||||
sp.setLayoutParams(new RecyclerView.LayoutParams(
|
sp.setLayoutParams(new RecyclerView.LayoutParams(
|
||||||
LayoutParams.MATCH_PARENT, mFooterHeight));
|
LayoutParams.MATCH_PARENT, mFooterHeight));
|
||||||
return new FooterViewHolder(sp);
|
return new FooterViewHolder(sp, viewType);
|
||||||
default:
|
default:
|
||||||
// Since we catch all possible viewTypes above, no chance this is being called.
|
// Since we catch all possible viewTypes above, no chance this is being called.
|
||||||
return null;
|
return null;
|
||||||
@@ -3214,7 +3232,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||||
int viewType = getItemViewType(position);
|
int viewType = ((ViewHolderBase) holder).getViewType();
|
||||||
switch (viewType) {
|
switch (viewType) {
|
||||||
case VIEW_TYPE_DIRECT_SHARE:
|
case VIEW_TYPE_DIRECT_SHARE:
|
||||||
case VIEW_TYPE_CALLER_AND_RANK:
|
case VIEW_TYPE_CALLER_AND_RANK:
|
||||||
@@ -3325,7 +3343,6 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
viewGroup.setTag(holder);
|
viewGroup.setTag(holder);
|
||||||
|
|
||||||
return holder;
|
return holder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3352,14 +3369,15 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
parentGroup.addView(row2);
|
parentGroup.addView(row2);
|
||||||
|
|
||||||
mDirectShareViewHolder = new DirectShareViewHolder(parentGroup,
|
mDirectShareViewHolder = new DirectShareViewHolder(parentGroup,
|
||||||
Lists.newArrayList(row1, row2), getMaxTargetsPerRow());
|
Lists.newArrayList(row1, row2), getMaxTargetsPerRow(), viewType);
|
||||||
loadViewsIntoGroup(mDirectShareViewHolder);
|
loadViewsIntoGroup(mDirectShareViewHolder);
|
||||||
|
|
||||||
return mDirectShareViewHolder;
|
return mDirectShareViewHolder;
|
||||||
} else {
|
} else {
|
||||||
ViewGroup row = (ViewGroup) mLayoutInflater.inflate(R.layout.chooser_row, parent,
|
ViewGroup row = (ViewGroup) mLayoutInflater.inflate(R.layout.chooser_row, parent,
|
||||||
false);
|
false);
|
||||||
ItemGroupViewHolder holder = new SingleRowViewHolder(row, getMaxTargetsPerRow());
|
ItemGroupViewHolder holder =
|
||||||
|
new SingleRowViewHolder(row, getMaxTargetsPerRow(), viewType);
|
||||||
loadViewsIntoGroup(holder);
|
loadViewsIntoGroup(holder);
|
||||||
|
|
||||||
return holder;
|
return holder;
|
||||||
@@ -3521,14 +3539,14 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
* {@link ChooserGridAdapter#VIEW_TYPE_DIRECT_SHARE},
|
* {@link ChooserGridAdapter#VIEW_TYPE_DIRECT_SHARE},
|
||||||
* and {@link ChooserGridAdapter#VIEW_TYPE_CALLER_AND_RANK}.
|
* and {@link ChooserGridAdapter#VIEW_TYPE_CALLER_AND_RANK}.
|
||||||
*/
|
*/
|
||||||
abstract class ItemGroupViewHolder extends RecyclerView.ViewHolder {
|
abstract class ItemGroupViewHolder extends ViewHolderBase {
|
||||||
protected int mMeasuredRowHeight;
|
protected int mMeasuredRowHeight;
|
||||||
private int[] mItemIndices;
|
private int[] mItemIndices;
|
||||||
protected final View[] mCells;
|
protected final View[] mCells;
|
||||||
private final int mColumnCount;
|
private final int mColumnCount;
|
||||||
|
|
||||||
ItemGroupViewHolder(int cellCount, View itemView) {
|
ItemGroupViewHolder(int cellCount, View itemView, int viewType) {
|
||||||
super(itemView);
|
super(itemView, viewType);
|
||||||
this.mCells = new View[cellCount];
|
this.mCells = new View[cellCount];
|
||||||
this.mItemIndices = new int[cellCount];
|
this.mItemIndices = new int[cellCount];
|
||||||
this.mColumnCount = cellCount;
|
this.mColumnCount = cellCount;
|
||||||
@@ -3574,8 +3592,8 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
class SingleRowViewHolder extends ItemGroupViewHolder {
|
class SingleRowViewHolder extends ItemGroupViewHolder {
|
||||||
private final ViewGroup mRow;
|
private final ViewGroup mRow;
|
||||||
|
|
||||||
SingleRowViewHolder(ViewGroup row, int cellCount) {
|
SingleRowViewHolder(ViewGroup row, int cellCount, int viewType) {
|
||||||
super(cellCount, row);
|
super(cellCount, row, viewType);
|
||||||
|
|
||||||
this.mRow = row;
|
this.mRow = row;
|
||||||
}
|
}
|
||||||
@@ -3617,8 +3635,9 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
|
|
||||||
private final boolean[] mCellVisibility;
|
private final boolean[] mCellVisibility;
|
||||||
|
|
||||||
DirectShareViewHolder(ViewGroup parent, List<ViewGroup> rows, int cellCountPerRow) {
|
DirectShareViewHolder(ViewGroup parent, List<ViewGroup> rows, int cellCountPerRow,
|
||||||
super(rows.size() * cellCountPerRow, parent);
|
int viewType) {
|
||||||
|
super(rows.size() * cellCountPerRow, parent, viewType);
|
||||||
|
|
||||||
this.mParent = parent;
|
this.mParent = parent;
|
||||||
this.mRows = rows;
|
this.mRows = rows;
|
||||||
|
|||||||
@@ -182,6 +182,8 @@ public class ResolverActivity extends Activity implements
|
|||||||
private BroadcastReceiver mWorkProfileStateReceiver;
|
private BroadcastReceiver mWorkProfileStateReceiver;
|
||||||
private UserHandle mHeaderCreatorUser;
|
private UserHandle mHeaderCreatorUser;
|
||||||
|
|
||||||
|
private UserHandle mWorkProfileUserHandle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the string resource to be used as a label for the link to the resolver activity for an
|
* Get the string resource to be used as a label for the link to the resolver activity for an
|
||||||
* action.
|
* action.
|
||||||
@@ -363,6 +365,7 @@ public class ResolverActivity extends Activity implements
|
|||||||
// a more complicated UI that the current voice interaction flow is not able
|
// a more complicated UI that the current voice interaction flow is not able
|
||||||
// to handle.
|
// to handle.
|
||||||
boolean filterLastUsed = mSupportsAlwaysUseOption && !isVoiceInteraction();
|
boolean filterLastUsed = mSupportsAlwaysUseOption && !isVoiceInteraction();
|
||||||
|
mWorkProfileUserHandle = fetchWorkProfileUserProfile();
|
||||||
mMultiProfilePagerAdapter = createMultiProfilePagerAdapter(initialIntents, rList, filterLastUsed);
|
mMultiProfilePagerAdapter = createMultiProfilePagerAdapter(initialIntents, rList, filterLastUsed);
|
||||||
if (configureContentView()) {
|
if (configureContentView()) {
|
||||||
return;
|
return;
|
||||||
@@ -527,13 +530,18 @@ public class ResolverActivity extends Activity implements
|
|||||||
return UserHandle.of(ActivityManager.getCurrentUser());
|
return UserHandle.of(ActivityManager.getCurrentUser());
|
||||||
}
|
}
|
||||||
protected @Nullable UserHandle getWorkProfileUserHandle() {
|
protected @Nullable UserHandle getWorkProfileUserHandle() {
|
||||||
|
return mWorkProfileUserHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected @Nullable UserHandle fetchWorkProfileUserProfile() {
|
||||||
|
mWorkProfileUserHandle = null;
|
||||||
UserManager userManager = getSystemService(UserManager.class);
|
UserManager userManager = getSystemService(UserManager.class);
|
||||||
for (final UserInfo userInfo : userManager.getProfiles(ActivityManager.getCurrentUser())) {
|
for (final UserInfo userInfo : userManager.getProfiles(ActivityManager.getCurrentUser())) {
|
||||||
if (userInfo.isManagedProfile()) {
|
if (userInfo.isManagedProfile()) {
|
||||||
return userInfo.getUserHandle();
|
mWorkProfileUserHandle = userInfo.getUserHandle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return mWorkProfileUserHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasWorkProfile() {
|
private boolean hasWorkProfile() {
|
||||||
|
|||||||
Reference in New Issue
Block a user