Search in sources :

Example 11 with DefaultAppInfo

use of com.android.settingslib.applications.DefaultAppInfo in project android_packages_apps_Settings by omnirom.

the class WebViewAppPickerTest method testDisabledPackageShownAsDisabled.

@Test
public void testDisabledPackageShownAsDisabled() {
    DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mContext.getPackageManager(), createApplicationInfo(PACKAGE_NAME), "disabled");
    RadioButtonPreference preference = mock(RadioButtonPreference.class);
    mPicker.bindPreference(preference, PACKAGE_NAME, webviewAppInfo, null);
    mPicker.bindPreferenceExtra(preference, PACKAGE_NAME, webviewAppInfo, null, null);
    verify(preference, times(1)).setEnabled(eq(false));
    verify(preference, never()).setEnabled(eq(true));
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Test(org.junit.Test)

Example 12 with DefaultAppInfo

use of com.android.settingslib.applications.DefaultAppInfo in project android_packages_apps_Settings by omnirom.

the class WebViewAppPickerTest method testDisabledPackageShowsDisabledReasonSummary.

@Test
public void testDisabledPackageShowsDisabledReasonSummary() {
    String disabledReason = "disabled";
    DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mContext.getPackageManager(), createApplicationInfo(PACKAGE_NAME), disabledReason);
    RadioButtonPreference preference = mock(RadioButtonPreference.class);
    mPicker.bindPreference(preference, PACKAGE_NAME, webviewAppInfo, null);
    mPicker.bindPreferenceExtra(preference, PACKAGE_NAME, webviewAppInfo, null, null);
    verify(preference, times(1)).setSummary(eq(disabledReason));
    // Ensure we haven't called setSummary several times.
    verify(preference, times(1)).setSummary(any());
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Test(org.junit.Test)

Example 13 with DefaultAppInfo

use of com.android.settingslib.applications.DefaultAppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WebViewAppPickerTest method testWebViewVersionAddedAfterLabel.

/**
 * Ensure that the version name of a WebView package is displayed after its name in the
 * preference title.
 */
@Test
public void testWebViewVersionAddedAfterLabel() {
    final DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mContext.getPackageManager(), createApplicationInfo(PACKAGE_NAME), "");
    final RadioButtonPreference mockPreference = mock(RadioButtonPreference.class);
    mPicker.bindPreference(mockPreference, PACKAGE_NAME, webviewAppInfo, null);
    mPicker.bindPreferenceExtra(mockPreference, PACKAGE_NAME, webviewAppInfo, null, null);
    verify(mockPreference).setTitle(eq(PACKAGE_NAME + " " + PACKAGE_VERSION));
    verify(mockPreference).setTitle(any());
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) Test(org.junit.Test)

Example 14 with DefaultAppInfo

use of com.android.settingslib.applications.DefaultAppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WebViewAppPickerTest method testEnabledPackageShownAsEnabled.

@Test
public void testEnabledPackageShownAsEnabled() {
    String disabledReason = "";
    DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mContext.getPackageManager(), createApplicationInfo(PACKAGE_NAME), disabledReason);
    RadioButtonPreference preference = mock(RadioButtonPreference.class);
    mPicker.bindPreference(preference, PACKAGE_NAME, webviewAppInfo, null);
    mPicker.bindPreferenceExtra(preference, PACKAGE_NAME, webviewAppInfo, null, null);
    verify(preference, times(1)).setEnabled(eq(true));
    verify(preference, never()).setEnabled(eq(false));
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) Test(org.junit.Test)

Example 15 with DefaultAppInfo

use of com.android.settingslib.applications.DefaultAppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DefaultAppPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    final DefaultAppInfo app = getDefaultAppInfo();
    CharSequence defaultAppLabel = getDefaultAppLabel();
    if (preference instanceof TwoTargetPreference) {
        // For use small icon because we are displaying an app preference.
        // We only need to do this for TwoTargetPreference because the other prefs are
        // already using AppPreference so their icon is already normalized.
        ((TwoTargetPreference) preference).setIconSize(ICON_SIZE_MEDIUM);
    }
    if (!TextUtils.isEmpty(defaultAppLabel)) {
        preference.setSummary(defaultAppLabel);
        Utils.setSafeIcon(preference, getDefaultAppIcon());
    } else {
        Log.d(TAG, "No default app");
        preference.setSummary(R.string.app_list_preference_none);
        preference.setIcon(null);
    }
    mayUpdateGearIcon(app, preference);
}
Also used : TwoTargetPreference(com.android.settingslib.TwoTargetPreference) DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo)

Aggregations

DefaultAppInfo (com.android.settingslib.applications.DefaultAppInfo)23 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)7 Context (android.content.Context)5 RadioButtonPreference (com.android.settings.widget.RadioButtonPreference)5 RadioButtonPreference (com.android.settingslib.widget.RadioButtonPreference)5 ComponentName (android.content.ComponentName)4 ApplicationInfo (android.content.pm.ApplicationInfo)3 PackageItemInfo (android.content.pm.PackageItemInfo)2 ResolveInfo (android.content.pm.ResolveInfo)2 ServiceInfo (android.content.pm.ServiceInfo)2 CandidateInfo (com.android.settingslib.widget.CandidateInfo)2 Config (org.robolectric.annotation.Config)2 Pair (android.util.Pair)1 TwoTargetPreference (com.android.settingslib.TwoTargetPreference)1 TwoTargetPreference (com.android.settingslib.widget.TwoTargetPreference)1