Search in sources :

Example 16 with DefaultAppInfo

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

the class DefaultAssistPreferenceControllerTest method getDefaultAppInfo_hasDefaultAssist_shouldReturnKey.

@Test
@Config(shadows = { ShadowSecureSettings.class })
public void getDefaultAppInfo_hasDefaultAssist_shouldReturnKey() {
    final String flattenKey = "com.android.settings/assist";
    Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.ASSISTANT, flattenKey);
    DefaultAppInfo appInfo = mController.getDefaultAppInfo();
    assertThat(appInfo.getKey()).isEqualTo(flattenKey);
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 17 with DefaultAppInfo

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

the class DefaultAssistPreferenceControllerTest method getDefaultAppInfo_hasDefaultAssist_shouldReturnKey.

@Test
@Config(shadows = { ShadowSecureSettings.class })
public void getDefaultAppInfo_hasDefaultAssist_shouldReturnKey() {
    final String flattenKey = "com.android.settings/assist";
    Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.ASSISTANT, flattenKey);
    DefaultAppInfo appInfo = mController.getDefaultAppInfo();
    assertThat(appInfo.getKey()).isEqualTo(flattenKey);
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 18 with DefaultAppInfo

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

the class DefaultAutofillPickerTest method getConfirmationMessage_shouldNotBeNull.

@Test
public void getConfirmationMessage_shouldNotBeNull() {
    mPicker.onAttach((Context) mActivity);
    final DefaultAppInfo info = mock(DefaultAppInfo.class);
    when(info.loadLabel()).thenReturn("test_app_name");
    assertThat(mPicker.getConfirmationMessage(info)).isNotNull();
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) Test(org.junit.Test)

Example 19 with DefaultAppInfo

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

the class NotificationAssistantPicker method onServicesReloaded.

@Override
public void onServicesReloaded(List<ServiceInfo> services) {
    List<CandidateInfo> list = new ArrayList<>();
    services.sort(new PackageItemInfo.DisplayNameComparator(mPm));
    for (ServiceInfo service : services) {
        if (mContext.getPackageManager().checkPermission(android.Manifest.permission.REQUEST_NOTIFICATION_ASSISTANT_SERVICE, service.packageName) == PackageManager.PERMISSION_GRANTED) {
            final ComponentName cn = new ComponentName(service.packageName, service.name);
            list.add(new DefaultAppInfo(mContext, mPm, mUserId, cn));
        }
    }
    list.add(new CandidateNone(mContext));
    mCandidateInfos = list;
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) CandidateInfo(com.android.settingslib.widget.CandidateInfo) ArrayList(java.util.ArrayList) PackageItemInfo(android.content.pm.PackageItemInfo) ComponentName(android.content.ComponentName) DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo)

Example 20 with DefaultAppInfo

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

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)) {
        if (showLabelAsTitle()) {
            preference.setTitle(defaultAppLabel);
        } else {
            preference.setSummary(defaultAppLabel);
        }
        preference.setIcon(Utils.getSafeIcon(getDefaultAppIcon()));
    } else {
        Log.d(TAG, "No default app");
        if (showLabelAsTitle()) {
            preference.setTitle(R.string.app_list_preference_none);
        } else {
            preference.setSummary(R.string.app_list_preference_none);
        }
        preference.setIcon(null);
    }
    mayUpdateGearIcon(app, preference);
}
Also used : TwoTargetPreference(com.android.settingslib.widget.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