diff options
| author | 2019-04-16 21:53:27 +0000 | |
|---|---|---|
| committer | 2019-04-16 21:53:27 +0000 | |
| commit | cb86e128cf58b057a1db2adc3f56fa6c4e587e3b (patch) | |
| tree | 00da33d4552203638961f45dd595ee7822600bd5 | |
| parent | f636d3cde86392cfb5b849ffcb0a51fd6574f231 (diff) | |
| parent | dadc0d1541e6615404b674f3fc18e49d95cc7df1 (diff) | |
Merge "Sharesheet - Merge EXTRA_INITIAL_INTENTS + Ranked apps" into qt-dev
| -rw-r--r-- | core/java/com/android/internal/app/ChooserActivity.java | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index ed851f86889d..54338bf6a176 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -2658,12 +2658,24 @@ public class ChooserActivity extends ResolverActivity { } } + /** + * Need to merge CALLER + ranked STANDARD into a single row. All other types + * are placed into their own row as determined by their target type, and dividers + * are added in the list to separate each type. + */ + int getRowType(int rowPosition) { + int positionType = mChooserListAdapter.getPositionTargetType(rowPosition); + if (positionType == ChooserListAdapter.TARGET_CALLER) { + return ChooserListAdapter.TARGET_STANDARD; + } + + return positionType; + } + void bindViewHolder(int rowPosition, RowViewHolder holder) { final int start = getFirstRowPosition(rowPosition); - final int startType = mChooserListAdapter.getPositionTargetType(start); - - final int lastStartType = mChooserListAdapter.getPositionTargetType( - getFirstRowPosition(rowPosition - 1)); + final int startType = getRowType(start); + final int lastStartType = getRowType(getFirstRowPosition(rowPosition - 1)); final ViewGroup row = holder.getViewGroup(); @@ -2675,7 +2687,7 @@ public class ChooserActivity extends ResolverActivity { int columnCount = holder.getColumnCount(); int end = start + columnCount - 1; - while (mChooserListAdapter.getPositionTargetType(end) != startType && end >= start) { + while (getRowType(end) != startType && end >= start) { end--; } @@ -2727,14 +2739,15 @@ public class ChooserActivity extends ResolverActivity { return row * getMaxTargetsPerRow(); } - final int callerCount = mChooserListAdapter.getCallerTargetCount(); - final int callerRows = (int) Math.ceil((float) callerCount / getMaxTargetsPerRow()); - if (row < callerRows + serviceRows) { + final int callerAndRankedCount = mChooserListAdapter.getCallerTargetCount() + + mChooserListAdapter.getRankedTargetCount(); + final int callerAndRankedRows = getCallerAndRankedTargetRowCount(); + if (row < callerAndRankedRows + serviceRows) { return serviceCount + (row - serviceRows) * getMaxTargetsPerRow(); } - return callerCount + serviceCount - + (row - callerRows - serviceRows) * getMaxTargetsPerRow(); + return callerAndRankedCount + serviceCount + + (row - callerAndRankedRows - serviceRows) * getMaxTargetsPerRow(); } public void handleScroll(View v, int y, int oldy) { |