From 13314611ffbcb3fd67004586cd42918cffd4e06d Mon Sep 17 00:00:00 2001 From: Alison Cichowlas Date: Thu, 11 Apr 2019 15:20:39 -0400 Subject: [PATCH] Use the correct targets-per-row count for Landscape. Bug: 126566208 Test: Manual verification, both orientations Change-Id: I971a033628a56c41c7c926d519106114c66bce80 --- .../android/internal/app/ChooserActivity.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index b51f8080569f7..e49a6d3bd0ff2 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -1429,11 +1429,9 @@ public class ChooserActivity extends ResolverActivity { } private void updateAlphabeticalList() { - if (getDisplayList().size() > MAX_RANKED_TARGETS) { - mSortedList.clear(); - mSortedList.addAll(getDisplayList()); - Collections.sort(mSortedList, new AzInfoComparator(ChooserActivity.this)); - } + mSortedList.clear(); + mSortedList.addAll(getDisplayList()); + Collections.sort(mSortedList, new AzInfoComparator(ChooserActivity.this)); } /** @@ -2049,12 +2047,13 @@ public class ChooserActivity extends ResolverActivity { @Override public int getUnfilteredCount() { int appTargets = super.getUnfilteredCount(); - if (appTargets > MAX_RANKED_TARGETS) { - appTargets = appTargets + MAX_RANKED_TARGETS; + if (appTargets > getMaxRankedTargets()) { + appTargets = appTargets + getMaxRankedTargets(); } return appTargets + getSelectableServiceTargetCount() + getCallerTargetCount(); } + public int getCallerTargetCount() { return Math.min(mCallerTargets.size(), MAX_SUGGESTED_APP_TARGETS); } @@ -2082,14 +2081,17 @@ public class ChooserActivity extends ResolverActivity { int getAlphaTargetCount() { int standardCount = super.getCount(); - return standardCount > MAX_RANKED_TARGETS ? standardCount : 0; + return standardCount > getMaxRankedTargets() ? standardCount : 0; } int getRankedTargetCount() { - int spacesAvailable = MAX_RANKED_TARGETS - getCallerTargetCount(); + int spacesAvailable = getMaxRankedTargets() - getCallerTargetCount(); return Math.min(spacesAvailable, super.getCount()); } + private int getMaxRankedTargets() { + return mChooserRowAdapter == null ? 4 : mChooserRowAdapter.getMaxTargetsPerRow(); + } public int getPositionTargetType(int position) { int offset = 0;