use of com.android.settings.applications.defaultapps.DefaultBrowserPreferenceController in project android_packages_apps_Settings by SudaMod.
the class InstalledAppDetails method updateDynamicPrefs.
private void updateDynamicPrefs() {
final Context context = getContext();
Preference pref = findPreference("default_home");
if (pref != null) {
pref.setSummary(DefaultHomePreferenceController.isHomeDefault(mPackageName, new PackageManagerWrapperImpl(context.getPackageManager())) ? R.string.yes : R.string.no);
}
pref = findPreference("default_browser");
if (pref != null) {
pref.setSummary(new DefaultBrowserPreferenceController(context).isBrowserDefault(mPackageName, mUserId) ? R.string.yes : R.string.no);
}
pref = findPreference("default_phone_app");
if (pref != null) {
pref.setSummary(DefaultPhonePreferenceController.isPhoneDefault(mPackageName, context) ? R.string.yes : R.string.no);
}
pref = findPreference("default_emergency_app");
if (pref != null) {
pref.setSummary(DefaultEmergencyPreferenceController.isEmergencyDefault(mPackageName, getContext()) ? R.string.yes : R.string.no);
}
pref = findPreference("default_sms_app");
if (pref != null) {
pref.setSummary(DefaultSmsPreferenceController.isSmsDefault(mPackageName, context) ? R.string.yes : R.string.no);
}
pref = findPreference("system_alert_window");
if (pref != null) {
pref.setSummary(DrawOverlayDetails.getSummary(getContext(), mAppEntry));
}
pref = findPreference("picture_in_picture");
if (pref != null) {
pref.setSummary(PictureInPictureDetails.getPreferenceSummary(getContext(), mPackageInfo.applicationInfo.uid, mPackageName));
}
pref = findPreference("write_settings_apps");
if (pref != null) {
pref.setSummary(WriteSettingsDetails.getSummary(getContext(), mAppEntry));
}
pref = findPreference("install_other_apps");
if (pref != null) {
pref.setSummary(ExternalSourcesDetails.getPreferenceSummary(getContext(), mAppEntry));
}
}
use of com.android.settings.applications.defaultapps.DefaultBrowserPreferenceController in project platform_packages_apps_Settings by BlissRoms.
the class DefaultAppSettingsTest method setListening_shouldUpdateSummary.
@Test
public void setListening_shouldUpdateSummary() {
final SummaryLoader summaryLoader = mock(SummaryLoader.class);
final DefaultAppSettings.SummaryProvider summaryProvider = new DefaultAppSettings.SummaryProvider(mContext, summaryLoader);
final DefaultSmsPreferenceController defaultSms = mock(DefaultSmsPreferenceController.class);
final DefaultBrowserPreferenceController defaultBrowser = mock(DefaultBrowserPreferenceController.class);
final DefaultPhonePreferenceController defaultPhone = mock(DefaultPhonePreferenceController.class);
ReflectionHelpers.setField(summaryProvider, "mDefaultSmsPreferenceController", defaultSms);
ReflectionHelpers.setField(summaryProvider, "mDefaultBrowserPreferenceController", defaultBrowser);
ReflectionHelpers.setField(summaryProvider, "mDefaultPhonePreferenceController", defaultPhone);
// all available
when(defaultSms.getDefaultAppLabel()).thenReturn("Sms1");
when(defaultBrowser.getDefaultAppLabel()).thenReturn("Browser1");
when(defaultPhone.getDefaultAppLabel()).thenReturn("Phone1");
summaryProvider.setListening(true);
verify(summaryLoader).setSummary(summaryProvider, "Sms1, Browser1, Phone1");
// 2 available
when(defaultSms.getDefaultAppLabel()).thenReturn(null);
when(defaultBrowser.getDefaultAppLabel()).thenReturn("Browser1");
when(defaultPhone.getDefaultAppLabel()).thenReturn("Phone1");
summaryProvider.setListening(true);
verify(summaryLoader).setSummary(summaryProvider, "Browser1, Phone1");
when(defaultSms.getDefaultAppLabel()).thenReturn("Sms1");
when(defaultBrowser.getDefaultAppLabel()).thenReturn(null);
when(defaultPhone.getDefaultAppLabel()).thenReturn("Phone1");
summaryProvider.setListening(true);
verify(summaryLoader).setSummary(summaryProvider, "Sms1, Phone1");
when(defaultSms.getDefaultAppLabel()).thenReturn("Sms1");
when(defaultBrowser.getDefaultAppLabel()).thenReturn("Browser1");
when(defaultPhone.getDefaultAppLabel()).thenReturn(null);
summaryProvider.setListening(true);
verify(summaryLoader).setSummary(summaryProvider, "Sms1, Browser1");
// 1 available
when(defaultSms.getDefaultAppLabel()).thenReturn(null);
when(defaultBrowser.getDefaultAppLabel()).thenReturn("Browser1");
when(defaultPhone.getDefaultAppLabel()).thenReturn(null);
summaryProvider.setListening(true);
verify(summaryLoader).setSummary(summaryProvider, "Browser1");
when(defaultSms.getDefaultAppLabel()).thenReturn("Sms1");
when(defaultBrowser.getDefaultAppLabel()).thenReturn(null);
when(defaultPhone.getDefaultAppLabel()).thenReturn(null);
summaryProvider.setListening(true);
verify(summaryLoader).setSummary(summaryProvider, "Sms1");
when(defaultSms.getDefaultAppLabel()).thenReturn(null);
when(defaultBrowser.getDefaultAppLabel()).thenReturn(null);
when(defaultPhone.getDefaultAppLabel()).thenReturn("Phone1");
summaryProvider.setListening(true);
verify(summaryLoader).setSummary(summaryProvider, "Phone1");
// None available
when(defaultSms.getDefaultAppLabel()).thenReturn(null);
when(defaultBrowser.getDefaultAppLabel()).thenReturn(null);
when(defaultPhone.getDefaultAppLabel()).thenReturn(null);
summaryProvider.setListening(true);
verify(summaryLoader, never()).setSummary(summaryProvider, eq(anyString()));
}
use of com.android.settings.applications.defaultapps.DefaultBrowserPreferenceController in project platform_packages_apps_Settings by BlissRoms.
the class InstalledAppDetails method updateDynamicPrefs.
private void updateDynamicPrefs() {
final Context context = getContext();
Preference pref = findPreference("default_home");
if (pref != null) {
pref.setSummary(DefaultHomePreferenceController.isHomeDefault(mPackageName, new PackageManagerWrapperImpl(context.getPackageManager())) ? R.string.yes : R.string.no);
}
pref = findPreference("default_browser");
if (pref != null) {
pref.setSummary(new DefaultBrowserPreferenceController(context).isBrowserDefault(mPackageName, mUserId) ? R.string.yes : R.string.no);
}
pref = findPreference("default_phone_app");
if (pref != null) {
pref.setSummary(DefaultPhonePreferenceController.isPhoneDefault(mPackageName, context) ? R.string.yes : R.string.no);
}
pref = findPreference("default_emergency_app");
if (pref != null) {
pref.setSummary(DefaultEmergencyPreferenceController.isEmergencyDefault(mPackageName, getContext()) ? R.string.yes : R.string.no);
}
pref = findPreference("default_sms_app");
if (pref != null) {
pref.setSummary(DefaultSmsPreferenceController.isSmsDefault(mPackageName, context) ? R.string.yes : R.string.no);
}
pref = findPreference("system_alert_window");
if (pref != null) {
pref.setSummary(DrawOverlayDetails.getSummary(getContext(), mAppEntry));
}
pref = findPreference("picture_in_picture");
if (pref != null) {
pref.setSummary(PictureInPictureDetails.getPreferenceSummary(getContext(), mPackageInfo.applicationInfo.uid, mPackageName));
}
pref = findPreference("write_settings_apps");
if (pref != null) {
pref.setSummary(WriteSettingsDetails.getSummary(getContext(), mAppEntry));
}
pref = findPreference("install_other_apps");
if (pref != null) {
pref.setSummary(ExternalSourcesDetails.getPreferenceSummary(getContext(), mAppEntry));
}
}
Aggregations