Merge "Sharesheet - Add logic to when 4->8 expansion occurs" into qt-dev

This commit is contained in:
TreeHugger Robot
2019-05-02 21:27:34 +00:00
committed by Android (Google) Code Review

View File

@@ -2072,6 +2072,8 @@ public class ChooserActivity extends ResolverActivity {
private static final int MAX_SERVICE_TARGETS = 8;
private int mNumShortcutResults = 0;
// Reserve spots for incoming direct share targets by adding placeholders
private ChooserTargetInfo mPlaceHolderTargetInfo = new PlaceHolderTargetInfo();
private final List<ChooserTargetInfo> mServiceTargets = new ArrayList<>();
@@ -2407,9 +2409,15 @@ public class ChooserActivity extends ResolverActivity {
// This incents ChooserTargetServices to define what's truly better.
targetScore = lastScore * 0.95f;
}
shouldNotify |= insertServiceTarget(
boolean isInserted = insertServiceTarget(
new SelectableTargetInfo(origTarget, target, targetScore));
if (isInserted && isShortcutResult) {
mNumShortcutResults++;
}
shouldNotify |= isInserted;
if (DEBUG) {
Log.d(TAG, " => " + target.toString() + " score=" + targetScore
+ " base=" + target.getScore()
@@ -2425,6 +2433,10 @@ public class ChooserActivity extends ResolverActivity {
}
}
private int getNumShortcutResults() {
return mNumShortcutResults;
}
/**
* Use the scoring system along with artificial boosts to create up to 3 distinct buckets:
* <ol>
@@ -2955,7 +2967,15 @@ public class ChooserActivity extends ResolverActivity {
}
public void handleScroll(View v, int y, int oldy) {
if (mDirectShareViewHolder != null) {
// 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.
int orientation = getResources().getConfiguration().orientation;
boolean canExpandDirectShare =
mChooserListAdapter.getNumShortcutResults() > getMaxTargetsPerRow()
&& orientation == Configuration.ORIENTATION_PORTRAIT;
if (mDirectShareViewHolder != null && canExpandDirectShare) {
mDirectShareViewHolder.handleScroll(mAdapterView, y, oldy, getMaxTargetsPerRow());
}
}