summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2015-09-17 13:38:16 -0700
committerAdam Powell <adamp@google.com>2015-09-17 20:56:00 +0000
commit00f4aad704198a8293b9a1d2b931b8708073fe15 (patch)
treed991d8f457b5362f9cd10529e734e5ade97b2519 /core
parent952d5b334ccdf9cab0f56673861906e59d4e9933 (diff)
downloadframeworks_base-00f4aad704198a8293b9a1d2b931b8708073fe15.zip
frameworks_base-00f4aad704198a8293b9a1d2b931b8708073fe15.tar.gz
frameworks_base-00f4aad704198a8293b9a1d2b931b8708073fe15.tar.bz2
Badge ChooserActivity choices with their app icon for disambig
When two or more activities with the same user-visible label are shown, we have traditionally shown the app name or package name if the app names also match. This was to help the user tell the difference between multiple apps publishing similar activities and avoid unintentionally starting the wrong one. However, in the case of explicit choosers (e.g. ACTION_SEND sharing) a few common collisions occur in practice and falling all the way back to package name isn't very helpful. Instead, we now assume that the app icon, which the user has seen before at install time, is unique enough on its own to disambiguate these cases and avoid user confusion. We no longer show the app name or package name as secondary text in the chooser. In cases where an activity has a different icon from its containing app, we now badge the activity icon with the app icon so that the user knows which app a potentially ambiguous choice belongs to. Bug 24113937 Change-Id: Ie54fbf77bfcc86e50768f93be2be0e53cf2ce7b5
Diffstat (limited to 'core')
-rw-r--r--core/java/com/android/internal/app/ChooserActivity.java8
-rw-r--r--core/java/com/android/internal/app/ResolverActivity.java25
2 files changed, 26 insertions, 7 deletions
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 80f9b0f..3219dcb 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -647,7 +647,8 @@ public class ChooserActivity extends ResolverActivity {
@Override
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
@@ -740,9 +741,8 @@ public class ChooserActivity extends ResolverActivity {
@Override
public boolean showsExtendedInfo(TargetInfo info) {
- // Reserve space to show extended info if any one of the items in the adapter has
- // extended info. This keeps grid item sizes uniform.
- return hasExtendedInfo();
+ // We have badges so we don't need this text shown.
+ return false;
}
@Override
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 9272193..ef9d1ce 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -896,6 +896,7 @@ public class ResolverActivity extends Activity {
private final ResolveInfo mResolveInfo;
private final CharSequence mDisplayLabel;
private Drawable mDisplayIcon;
+ private Drawable mBadge;
private final CharSequence mExtendedInfo;
private final Intent mResolvedIntent;
private final List<Intent> mSourceIntents = new ArrayList<>();
@@ -940,7 +941,25 @@ public class ResolverActivity extends Activity {
}
public Drawable getBadgeIcon() {
- return null;
+ // 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;
+ }
+
+ 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
@@ -1378,8 +1397,8 @@ public class ResolverActivity extends Activity {
} else {
mHasExtendedInfo = true;
boolean usePkg = false;
- CharSequence startApp = ro.getResolveInfoAt(0).activityInfo.applicationInfo
- .loadLabel(mPm);
+ final ApplicationInfo ai = ro.getResolveInfoAt(0).activityInfo.applicationInfo;
+ final CharSequence startApp = ai.loadLabel(mPm);
if (startApp == null) {
usePkg = true;
}