Search in sources :

Example 6 with ProviderTile

use of com.android.settingslib.drawer.ProviderTile in project android_packages_apps_Settings by omnirom.

the class DashboardFeatureProviderImplTest method bindPreference_onCheckedChangedError_shouldRevertCheckedState.

@Test
@Config(shadows = { ShadowTileUtils.class })
public void bindPreference_onCheckedChangedError_shouldRevertCheckedState() {
    final SwitchPreference preference = new SwitchPreference(RuntimeEnvironment.application);
    final Tile tile = new ProviderTile(mProviderInfo, CategoryKey.CATEGORY_HOMEPAGE, mSwitchMetaData);
    final Bundle bundle = new Bundle();
    bundle.putBoolean(EXTRA_SWITCH_SET_CHECKED_ERROR, true);
    ShadowTileUtils.setResultBundle(bundle);
    mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, preference, tile, null, /*key */
    Preference.DEFAULT_ORDER);
    preference.callChangeListener(true);
    assertThat(preference.isChecked()).isFalse();
    preference.callChangeListener(false);
    assertThat(preference.isChecked()).isTrue();
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Bundle(android.os.Bundle) ActivityTile(com.android.settingslib.drawer.ActivityTile) ProviderTile(com.android.settingslib.drawer.ProviderTile) Tile(com.android.settingslib.drawer.Tile) ProviderTile(com.android.settingslib.drawer.ProviderTile) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 7 with ProviderTile

use of com.android.settingslib.drawer.ProviderTile in project android_packages_apps_Settings by omnirom.

the class CategoryManagerTest method createProviderTile.

private Tile createProviderTile(String categoryKey, String packageName, String className, String authority, String key, int order) {
    final ProviderInfo providerInfo = new ProviderInfo();
    final Bundle metaData = new Bundle();
    providerInfo.packageName = packageName;
    providerInfo.name = className;
    providerInfo.authority = authority;
    metaData.putString(META_DATA_PREFERENCE_KEYHINT, key);
    metaData.putInt(META_DATA_KEY_ORDER, order);
    return new ProviderTile(providerInfo, categoryKey, metaData);
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) Bundle(android.os.Bundle) ProviderTile(com.android.settingslib.drawer.ProviderTile)

Aggregations

ProviderTile (com.android.settingslib.drawer.ProviderTile)7 ActivityTile (com.android.settingslib.drawer.ActivityTile)5 Tile (com.android.settingslib.drawer.Tile)5 Bundle (android.os.Bundle)4 SwitchPreference (androidx.preference.SwitchPreference)4 Test (org.junit.Test)4 Config (org.robolectric.annotation.Config)3 ProviderInfo (android.content.pm.ProviderInfo)2 DashboardCategory (com.android.settingslib.drawer.DashboardCategory)2 ComponentName (android.content.ComponentName)1 Context (android.content.Context)1 ActivityInfo (android.content.pm.ActivityInfo)1 ArraySet (android.util.ArraySet)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 Preference (androidx.preference.Preference)1 Before (org.junit.Before)1