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:
Fan Zhang
2017-07-11 16:26:58 -07:00
parent b3e20232d4
commit 2ea6700336
25 changed files with 372 additions and 177 deletions

View File

@@ -23,8 +23,6 @@ import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
import com.android.settings.applications.PackageManagerWrapper;
@@ -58,28 +56,21 @@ public class DefaultHomePreferenceController extends DefaultAppPreferenceControl
return true;
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
final DefaultAppInfo defaultApp = getDefaultAppInfo();
final CharSequence defaultAppLabel = defaultApp != null ? defaultApp.loadLabel() : null;
if (TextUtils.isEmpty(defaultAppLabel)) {
final String onlyAppLabel = getOnlyAppLabel();
if (!TextUtils.isEmpty(onlyAppLabel)) {
preference.setSummary(onlyAppLabel);
}
}
}
@Override
protected DefaultAppInfo getDefaultAppInfo() {
final ArrayList<ResolveInfo> homeActivities = new ArrayList<>();
final ComponentName currentDefaultHome = mPackageManager.getHomeActivities(homeActivities);
return new DefaultAppInfo(mPackageManager, mUserId, currentDefaultHome);
if (currentDefaultHome != null) {
return new DefaultAppInfo(mPackageManager, mUserId, currentDefaultHome);
}
final ActivityInfo onlyAppInfo = getOnlyAppInfo();
if (onlyAppInfo != null) {
return new DefaultAppInfo(mPackageManager, mUserId, onlyAppInfo.getComponentName());
}
return null;
}
private String getOnlyAppLabel() {
private ActivityInfo getOnlyAppInfo() {
final List<ResolveInfo> homeActivities = new ArrayList<>();
final List<ActivityInfo> appLabels = new ArrayList<>();
@@ -92,7 +83,7 @@ public class DefaultHomePreferenceController extends DefaultAppPreferenceControl
appLabels.add(info);
}
return appLabels.size() == 1
? appLabels.get(0).loadLabel(mPackageManager.getPackageManager()).toString()
? appLabels.get(0)
: null;
}