Show default app icon in default app screen.
- Renamed AdvancedAppSettings to DefaultAppSettings. - Add logic to DefaultAppPreferenceController to also display icon. - Modified DefautlAssistPrefController to suppress gear icon, and use the controller in default app setting UI to display icon. - Remove dynamic injected payment setting activity and create the setting statically in xml. - Add DefaultPaymentSettingsPreference to display default payment app title (no icon because we can't get it) Change-Id: I6b8c768da0bafe5ec9a85ba9c79c7993b449be25 Fix: 36458534 Test: robotests
This commit is contained in:
@@ -21,6 +21,7 @@ import android.content.Intent;
|
||||
import android.content.pm.ComponentInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.text.TextUtils;
|
||||
@@ -86,6 +87,18 @@ public class DefaultBrowserPreferenceController extends DefaultAppPreferenceCont
|
||||
return getOnlyAppLabel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getDefaultAppIcon() {
|
||||
if (!isAvailable()) {
|
||||
return null;
|
||||
}
|
||||
final DefaultAppInfo defaultApp = getDefaultAppInfo();
|
||||
if (defaultApp != null) {
|
||||
return defaultApp.loadIcon();
|
||||
}
|
||||
return getOnlyAppIcon();
|
||||
}
|
||||
|
||||
private List<ResolveInfo> getCandidates() {
|
||||
return mPackageManager.queryIntentActivitiesAsUser(BROWSE_PROBE, PackageManager.MATCH_ALL,
|
||||
mUserId);
|
||||
@@ -105,6 +118,18 @@ public class DefaultBrowserPreferenceController extends DefaultAppPreferenceCont
|
||||
return null;
|
||||
}
|
||||
|
||||
private Drawable getOnlyAppIcon() {
|
||||
final List<ResolveInfo> list = getCandidates();
|
||||
if (list != null && list.size() == 1) {
|
||||
final ResolveInfo info = list.get(0);
|
||||
final ComponentInfo cn = info.getComponentInfo();
|
||||
final String packageName = cn == null ? null : cn.packageName;
|
||||
Log.d(TAG, "Getting icon for the only browser app: " + packageName);
|
||||
return info.loadIcon(mPackageManager.getPackageManager());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the pkg contains browser capability
|
||||
*/
|
||||
|
Reference in New Issue
Block a user