Search in sources :

Example 1 with TwoTargetPreference

use of com.android.settingslib.widget.TwoTargetPreference in project android_packages_apps_Settings by omnirom.

the class DefaultAppPreferenceControllerTest method updateState_twoTargetPref_shouldUseMediumIcon.

@Test
public void updateState_twoTargetPref_shouldUseMediumIcon() {
    final TwoTargetPreference pref = mock(TwoTargetPreference.class);
    mController = new TestPreferenceController(mContext);
    mController.updateState(pref);
    verify(pref).setIconSize(ICON_SIZE_MEDIUM);
}
Also used : TwoTargetPreference(com.android.settingslib.widget.TwoTargetPreference) Test(org.junit.Test)

Example 2 with TwoTargetPreference

use of com.android.settingslib.widget.TwoTargetPreference 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

TwoTargetPreference (com.android.settingslib.widget.TwoTargetPreference)2 DefaultAppInfo (com.android.settingslib.applications.DefaultAppInfo)1 Test (org.junit.Test)1