am 1b67a6b8: Merge "Badge ChooserActivity choices with their app icon for disambig" into mnc-dr-dev
* commit '1b67a6b84d133e1fdac352d0821034ceca739a71': Badge ChooserActivity choices with their app icon for disambig
This commit is contained in:
@@ -647,7 +647,8 @@ public class ChooserActivity extends ResolverActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getExtendedInfo() {
|
public CharSequence getExtendedInfo() {
|
||||||
return mSourceInfo != null ? mSourceInfo.getExtendedInfo() : null;
|
// ChooserTargets have badge icons, so we won't show the extended info to disambiguate.
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -740,9 +741,8 @@ public class ChooserActivity extends ResolverActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showsExtendedInfo(TargetInfo info) {
|
public boolean showsExtendedInfo(TargetInfo info) {
|
||||||
// Reserve space to show extended info if any one of the items in the adapter has
|
// We have badges so we don't need this text shown.
|
||||||
// extended info. This keeps grid item sizes uniform.
|
return false;
|
||||||
return hasExtendedInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -896,6 +896,7 @@ public class ResolverActivity extends Activity {
|
|||||||
private final ResolveInfo mResolveInfo;
|
private final ResolveInfo mResolveInfo;
|
||||||
private final CharSequence mDisplayLabel;
|
private final CharSequence mDisplayLabel;
|
||||||
private Drawable mDisplayIcon;
|
private Drawable mDisplayIcon;
|
||||||
|
private Drawable mBadge;
|
||||||
private final CharSequence mExtendedInfo;
|
private final CharSequence mExtendedInfo;
|
||||||
private final Intent mResolvedIntent;
|
private final Intent mResolvedIntent;
|
||||||
private final List<Intent> mSourceIntents = new ArrayList<>();
|
private final List<Intent> mSourceIntents = new ArrayList<>();
|
||||||
@@ -940,9 +941,27 @@ public class ResolverActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Drawable getBadgeIcon() {
|
public Drawable getBadgeIcon() {
|
||||||
|
// We only expose a badge if we have extended info.
|
||||||
|
// The badge is a higher-priority disambiguation signal
|
||||||
|
// but we don't need one if we wouldn't show extended info at all.
|
||||||
|
if (TextUtils.isEmpty(getExtendedInfo())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mBadge == null && mResolveInfo != null && mResolveInfo.activityInfo != null
|
||||||
|
&& mResolveInfo.activityInfo.applicationInfo != null) {
|
||||||
|
if (mResolveInfo.activityInfo.icon == 0 || mResolveInfo.activityInfo.icon
|
||||||
|
== mResolveInfo.activityInfo.applicationInfo.icon) {
|
||||||
|
// Badging an icon with exactly the same icon is silly.
|
||||||
|
// If the activityInfo icon resid is 0 it will fall back
|
||||||
|
// to the application's icon, making it a match.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
mBadge = mResolveInfo.activityInfo.applicationInfo.loadIcon(mPm);
|
||||||
|
}
|
||||||
|
return mBadge;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getBadgeContentDescription() {
|
public CharSequence getBadgeContentDescription() {
|
||||||
return null;
|
return null;
|
||||||
@@ -1378,8 +1397,8 @@ public class ResolverActivity extends Activity {
|
|||||||
} else {
|
} else {
|
||||||
mHasExtendedInfo = true;
|
mHasExtendedInfo = true;
|
||||||
boolean usePkg = false;
|
boolean usePkg = false;
|
||||||
CharSequence startApp = ro.getResolveInfoAt(0).activityInfo.applicationInfo
|
final ApplicationInfo ai = ro.getResolveInfoAt(0).activityInfo.applicationInfo;
|
||||||
.loadLabel(mPm);
|
final CharSequence startApp = ai.loadLabel(mPm);
|
||||||
if (startApp == null) {
|
if (startApp == null) {
|
||||||
usePkg = true;
|
usePkg = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user