Synchronize direct share expansion between work and personal tabs am: 2b15d71b58
Change-Id: Ied3fb046d5611f54918592d5d79852947e293206
This commit is contained in:
@@ -2885,6 +2885,13 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
return METRICS_CATEGORY_CHOOSER;
|
return METRICS_CATEGORY_CHOOSER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onProfileTabSelected() {
|
||||||
|
ChooserGridAdapter currentRootAdapter =
|
||||||
|
mChooserMultiProfilePagerAdapter.getCurrentRootAdapter();
|
||||||
|
currentRootAdapter.updateDirectShareExpansion();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter for all types of items and targets in ShareSheet.
|
* 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
|
* Note that ranked sections like Direct Share - while appearing grid-like - are handled on the
|
||||||
@@ -3357,15 +3364,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleScroll(View v, int y, int oldy) {
|
public void handleScroll(View v, int y, int oldy) {
|
||||||
// Only expand direct share area if there is a minimum number of shortcuts,
|
boolean canExpandDirectShare = canExpandDirectShare();
|
||||||
// which will help reduce the amount of visible shuffling due to older-style
|
|
||||||
// direct share targets.
|
|
||||||
int orientation = getResources().getConfiguration().orientation;
|
|
||||||
boolean canExpandDirectShare =
|
|
||||||
mChooserListAdapter.getNumShortcutResults() > getMaxTargetsPerRow()
|
|
||||||
&& orientation == Configuration.ORIENTATION_PORTRAIT
|
|
||||||
&& !isInMultiWindowMode();
|
|
||||||
|
|
||||||
if (mDirectShareViewHolder != null && canExpandDirectShare) {
|
if (mDirectShareViewHolder != null && canExpandDirectShare) {
|
||||||
mDirectShareViewHolder.handleScroll(
|
mDirectShareViewHolder.handleScroll(
|
||||||
mChooserMultiProfilePagerAdapter.getActiveAdapterView(), y, oldy,
|
mChooserMultiProfilePagerAdapter.getActiveAdapterView(), y, oldy,
|
||||||
@@ -3373,6 +3372,18 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only expand direct share area if there is a minimum number of shortcuts,
|
||||||
|
* which will help reduce the amount of visible shuffling due to older-style
|
||||||
|
* direct share targets.
|
||||||
|
*/
|
||||||
|
private boolean canExpandDirectShare() {
|
||||||
|
int orientation = getResources().getConfiguration().orientation;
|
||||||
|
return mChooserListAdapter.getNumShortcutResults() > getMaxTargetsPerRow()
|
||||||
|
&& orientation == Configuration.ORIENTATION_PORTRAIT
|
||||||
|
&& !isInMultiWindowMode();
|
||||||
|
}
|
||||||
|
|
||||||
public ChooserListAdapter getListAdapter() {
|
public ChooserListAdapter getListAdapter() {
|
||||||
return mChooserListAdapter;
|
return mChooserListAdapter;
|
||||||
}
|
}
|
||||||
@@ -3380,6 +3391,19 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
boolean shouldCellSpan(int position) {
|
boolean shouldCellSpan(int position) {
|
||||||
return getItemViewType(position) == VIEW_TYPE_NORMAL;
|
return getItemViewType(position) == VIEW_TYPE_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateDirectShareExpansion() {
|
||||||
|
if (mDirectShareViewHolder == null || !canExpandDirectShare()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
RecyclerView activeAdapterView =
|
||||||
|
mChooserMultiProfilePagerAdapter.getActiveAdapterView();
|
||||||
|
if (mResolverDrawerLayout.isCollapsed()) {
|
||||||
|
mDirectShareViewHolder.collapse(activeAdapterView);
|
||||||
|
} else {
|
||||||
|
mDirectShareViewHolder.expand(activeAdapterView);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3577,6 +3601,20 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
newHeight = Math.max(newHeight, mDirectShareMinHeight);
|
newHeight = Math.max(newHeight, mDirectShareMinHeight);
|
||||||
yDiff = newHeight - prevHeight;
|
yDiff = newHeight - prevHeight;
|
||||||
|
|
||||||
|
updateDirectShareRowHeight(view, yDiff, newHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void expand(RecyclerView view) {
|
||||||
|
updateDirectShareRowHeight(view, mDirectShareMaxHeight - mDirectShareCurrHeight,
|
||||||
|
mDirectShareMaxHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void collapse(RecyclerView view) {
|
||||||
|
updateDirectShareRowHeight(view, mDirectShareMinHeight - mDirectShareCurrHeight,
|
||||||
|
mDirectShareMinHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDirectShareRowHeight(RecyclerView view, int yDiff, int newHeight) {
|
||||||
if (view == null || view.getChildCount() == 0 || yDiff == 0) {
|
if (view == null || view.getChildCount() == 0 || yDiff == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1622,6 +1622,7 @@ public class ResolverActivity extends Activity implements
|
|||||||
}
|
}
|
||||||
setupViewVisibilities();
|
setupViewVisibilities();
|
||||||
maybeLogProfileChange();
|
maybeLogProfileChange();
|
||||||
|
onProfileTabSelected();
|
||||||
DevicePolicyEventLogger
|
DevicePolicyEventLogger
|
||||||
.createEvent(DevicePolicyEnums.RESOLVER_SWITCH_TABS)
|
.createEvent(DevicePolicyEnums.RESOLVER_SWITCH_TABS)
|
||||||
.setInt(viewPager.getCurrentItem())
|
.setInt(viewPager.getCurrentItem())
|
||||||
@@ -1640,6 +1641,12 @@ public class ResolverActivity extends Activity implements
|
|||||||
findViewById(R.id.resolver_tab_divider).setVisibility(View.VISIBLE);
|
findViewById(R.id.resolver_tab_divider).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback called when user changes the profile tab.
|
||||||
|
* <p>This method is intended to be overridden by subclasses.
|
||||||
|
*/
|
||||||
|
protected void onProfileTabSelected() { }
|
||||||
|
|
||||||
private void resetCheckedItem() {
|
private void resetCheckedItem() {
|
||||||
if (!isIntentPicker()) {
|
if (!isIntentPicker()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user