use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class CategoryManagerTest method createActivityTile.
private Tile createActivityTile(String categoryKey, String packageName, String className, int order) {
final ActivityInfo activityInfo = new ActivityInfo();
activityInfo.packageName = packageName;
activityInfo.name = className;
activityInfo.metaData = new Bundle();
activityInfo.metaData.putInt(META_DATA_KEY_ORDER, order);
return new ActivityTile(activityInfo, categoryKey);
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class CategoryManagerTest method backwardCompatCleanupForCategory_shouldChangeCategoryForOldKeys.
@Test
public void backwardCompatCleanupForCategory_shouldChangeCategoryForOldKeys() {
final String oldCategory = "com.android.settings.category.wireless";
final Tile tile1 = new ActivityTile(mActivityInfo, oldCategory);
tile1.setCategory(oldCategory);
final DashboardCategory category1 = new DashboardCategory(oldCategory);
category1.addTile(tile1);
mCategoryByKeyMap.put(oldCategory, category1);
mTileByComponentCache.put(new Pair<>("PACKAGE", "CLASS1"), tile1);
mCategoryManager.backwardCompatCleanupForCategory(mTileByComponentCache, mCategoryByKeyMap);
// Added 1 more category to category map.
assertThat(mCategoryByKeyMap.size()).isEqualTo(2);
// The new category map has CATEGORY_NETWORK type now, which contains 1 tile.
assertThat(mCategoryByKeyMap.get(CategoryKey.CATEGORY_NETWORK).getTilesCount()).isEqualTo(1);
// Old category still exists.
assertThat(mCategoryByKeyMap.get(oldCategory).getTilesCount()).isEqualTo(1);
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImpl method bindPreferenceToTileAndGetObservers.
@Override
public List<DynamicDataObserver> bindPreferenceToTileAndGetObservers(FragmentActivity activity, boolean forceRoundedIcon, int sourceMetricsCategory, Preference pref, Tile tile, String key, int baseOrder) {
if (pref == null) {
return null;
}
if (!TextUtils.isEmpty(key)) {
pref.setKey(key);
} else {
pref.setKey(getDashboardKeyForTile(tile));
}
final List<DynamicDataObserver> outObservers = new ArrayList<>();
DynamicDataObserver observer = bindTitleAndGetObserver(pref, tile);
if (observer != null) {
outObservers.add(observer);
}
observer = bindSummaryAndGetObserver(pref, tile);
if (observer != null) {
outObservers.add(observer);
}
observer = bindSwitchAndGetObserver(pref, tile);
if (observer != null) {
outObservers.add(observer);
}
bindIcon(pref, tile, forceRoundedIcon);
if (tile instanceof ActivityTile) {
final Bundle metadata = tile.getMetaData();
String clsName = null;
String action = null;
if (metadata != null) {
clsName = metadata.getString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS);
action = metadata.getString(META_DATA_KEY_INTENT_ACTION);
}
if (!TextUtils.isEmpty(clsName)) {
pref.setFragment(clsName);
} else {
final Intent intent = new Intent(tile.getIntent());
intent.putExtra(MetricsFeatureProvider.EXTRA_SOURCE_METRICS_CATEGORY, sourceMetricsCategory);
if (action != null) {
intent.setAction(action);
}
pref.setOnPreferenceClickListener(preference -> {
launchIntentOrSelectProfile(activity, tile, intent, sourceMetricsCategory);
return true;
});
}
}
if (tile.hasOrder()) {
final String skipOffsetPackageName = activity.getPackageName();
final int order = tile.getOrder();
boolean shouldSkipBaseOrderOffset = TextUtils.equals(skipOffsetPackageName, tile.getIntent().getComponent().getPackageName());
if (shouldSkipBaseOrderOffset || baseOrder == Preference.DEFAULT_ORDER) {
pref.setOrder(order);
} else {
pref.setOrder(order + baseOrder);
}
}
return outObservers.isEmpty() ? null : outObservers;
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class AccountDetailDashboardFragmentTest method refreshDashboardTiles_OtherAccountType_shouldNotDisplay.
@Test
public void refreshDashboardTiles_OtherAccountType_shouldNotDisplay() {
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
mActivityInfo.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
mActivityInfo.metaData.putString(METADATA_ACCOUNT_TYPE, "com.other");
assertThat(mFragment.displayTile(tile)).isFalse();
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class AccountDetailDashboardFragmentTest method refreshDashboardTiles_HasAccountType_shouldDisplay.
@Test
public void refreshDashboardTiles_HasAccountType_shouldDisplay() {
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
mActivityInfo.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
mActivityInfo.metaData.putString(METADATA_ACCOUNT_TYPE, "com.abc");
assertThat(mFragment.displayTile(tile)).isTrue();
}
Aggregations