Merge "Add badge content description to TargetInfo, use in ResolverActivity" into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e76bf46ab9
@ -517,6 +517,7 @@ public class ChooserActivity extends ResolverActivity {
|
||||
private final ResolveInfo mBackupResolveInfo;
|
||||
private final ChooserTarget mChooserTarget;
|
||||
private Drawable mBadgeIcon = null;
|
||||
private CharSequence mBadgeContentDescription;
|
||||
private Drawable mDisplayIcon;
|
||||
private final Intent mFillInIntent;
|
||||
private final int mFillInFlags;
|
||||
@ -532,7 +533,9 @@ public class ChooserActivity extends ResolverActivity {
|
||||
if (ri != null) {
|
||||
final ActivityInfo ai = ri.activityInfo;
|
||||
if (ai != null && ai.applicationInfo != null) {
|
||||
mBadgeIcon = getPackageManager().getApplicationIcon(ai.applicationInfo);
|
||||
final PackageManager pm = getPackageManager();
|
||||
mBadgeIcon = pm.getApplicationIcon(ai.applicationInfo);
|
||||
mBadgeContentDescription = pm.getApplicationLabel(ai.applicationInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -555,6 +558,7 @@ public class ChooserActivity extends ResolverActivity {
|
||||
mBackupResolveInfo = other.mBackupResolveInfo;
|
||||
mChooserTarget = other.mChooserTarget;
|
||||
mBadgeIcon = other.mBadgeIcon;
|
||||
mBadgeContentDescription = other.mBadgeContentDescription;
|
||||
mDisplayIcon = other.mDisplayIcon;
|
||||
mFillInIntent = fillInIntent;
|
||||
mFillInFlags = flags;
|
||||
@ -646,6 +650,11 @@ public class ChooserActivity extends ResolverActivity {
|
||||
return mBadgeIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getBadgeContentDescription() {
|
||||
return mBadgeContentDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetInfo cloneFilledIn(Intent fillInIntent, int flags) {
|
||||
return new ChooserTargetInfo(this, fillInIntent, flags);
|
||||
|
@ -931,6 +931,11 @@ public class ResolverActivity extends Activity {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getBadgeContentDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetInfo cloneFilledIn(Intent fillInIntent, int flags) {
|
||||
return new DisplayResolveInfo(this, fillInIntent, flags);
|
||||
@ -1071,6 +1076,11 @@ public class ResolverActivity extends Activity {
|
||||
*/
|
||||
public Drawable getBadgeIcon();
|
||||
|
||||
/**
|
||||
* @return The content description for the badge icon
|
||||
*/
|
||||
public CharSequence getBadgeContentDescription();
|
||||
|
||||
/**
|
||||
* Clone this target with the given fill-in information.
|
||||
*/
|
||||
@ -1542,6 +1552,7 @@ public class ResolverActivity extends Activity {
|
||||
final Drawable badge = info.getBadgeIcon();
|
||||
if (badge != null) {
|
||||
holder.badge.setImageDrawable(badge);
|
||||
holder.badge.setContentDescription(info.getBadgeContentDescription());
|
||||
holder.badge.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.badge.setVisibility(View.GONE);
|
||||
|
Reference in New Issue
Block a user