Merge "Fix one-action choosers with EXTRA_INITIAL_INTENTS" into mnc-dev

This commit is contained in:
Adam Powell
2015-06-01 22:37:37 +00:00
committed by Android (Google) Code Review
2 changed files with 31 additions and 8 deletions

View File

@@ -659,11 +659,16 @@ public class ChooserActivity extends ResolverActivity {
return super.getCount() + mServiceTargets.size() + mCallerTargets.size();
}
public int getCallerTargetsCount() {
@Override
public int getUnfilteredCount() {
return super.getUnfilteredCount() + mServiceTargets.size() + mCallerTargets.size();
}
public int getCallerTargetCount() {
return mCallerTargets.size();
}
public int getServiceTargetsCount() {
public int getServiceTargetCount() {
return mServiceTargets.size();
}
@@ -696,6 +701,11 @@ public class ChooserActivity extends ResolverActivity {
@Override
public TargetInfo getItem(int position) {
return targetInfoForPosition(position, true);
}
@Override
public TargetInfo targetInfoForPosition(int position, boolean filtered) {
int offset = 0;
final int callerTargetCount = mCallerTargets.size();
@@ -710,7 +720,8 @@ public class ChooserActivity extends ResolverActivity {
}
offset += serviceTargetCount;
return super.getItem(position - offset);
return filtered ? super.getItem(position - offset)
: getDisplayInfoAt(position - offset);
}
public void addServiceResults(DisplayResolveInfo origTarget, List<ChooserTarget> targets) {
@@ -764,8 +775,8 @@ public class ChooserActivity extends ResolverActivity {
@Override
public int getCount() {
return (int) (
Math.ceil((float) mChooserListAdapter.getCallerTargetsCount() / mColumnCount)
+ Math.ceil((float) mChooserListAdapter.getServiceTargetsCount() / mColumnCount)
Math.ceil((float) mChooserListAdapter.getCallerTargetCount() / mColumnCount)
+ Math.ceil((float) mChooserListAdapter.getServiceTargetCount() / mColumnCount)
+ Math.ceil((float) mChooserListAdapter.getStandardTargetCount() / mColumnCount)
);
}
@@ -845,14 +856,14 @@ public class ChooserActivity extends ResolverActivity {
}
int getFirstRowPosition(int row) {
final int callerCount = mChooserListAdapter.getCallerTargetsCount();
final int callerCount = mChooserListAdapter.getCallerTargetCount();
final int callerRows = (int) Math.ceil((float) callerCount / mColumnCount);
if (row < callerRows) {
return row * mColumnCount;
}
final int serviceCount = mChooserListAdapter.getServiceTargetsCount();
final int serviceCount = mChooserListAdapter.getServiceTargetCount();
final int serviceRows = (int) Math.ceil((float) serviceCount / mColumnCount);
if (row < callerRows + serviceRows) {

View File

@@ -785,7 +785,7 @@ public class ResolverActivity extends Activity {
}
mAlwaysUseOption = alwaysUseOption;
int count = mAdapter.mDisplayList.size();
int count = mAdapter.getUnfilteredCount();
if (count > 1 || (count == 1 && mAdapter.getOtherProfile() != null)) {
setContentView(layoutId);
mAdapterView = (AbsListView) findViewById(R.id.resolver_list);
@@ -1392,6 +1392,18 @@ public class ResolverActivity extends Activity {
return result;
}
public int getUnfilteredCount() {
return mDisplayList.size();
}
public int getDisplayInfoCount() {
return mDisplayList.size();
}
public DisplayResolveInfo getDisplayInfoAt(int index) {
return mDisplayList.get(index);
}
public TargetInfo getItem(int position) {
if (mFilterLastUsed && mLastChosenPosition >= 0 && position >= mLastChosenPosition) {
position++;