use of com.android.ide.common.resources.configuration.Configurable in project android by JetBrains.
the class ResolutionUtils method getFolderConfiguration.
/**
* Gets the {@link FolderConfiguration} of a ResourceValue
* e.g. if we resolve a drawable using a mdpi configuration, yet that drawable only exists inside xhdpi, this method will return xhdpi
* @param configuration the FolderConfiguration that was used for resolving the ResourceValue
* @return the FolderConfiguration of the ResourceValue
*/
@NotNull
public static FolderConfiguration getFolderConfiguration(@NotNull AndroidFacet facet, @NotNull ResourceValue resolvedValue, @NotNull FolderConfiguration configuration) {
List<? extends Configurable> configurables;
if (resolvedValue.isFramework()) {
ConfigurationManager configurationManager = facet.getConfigurationManager();
// same as getHighestApiTarget();
IAndroidTarget target = configurationManager.getDefaultTarget();
assert target != null;
ResourceRepository resourceRepository = configurationManager.getResolverCache().getFrameworkResources(configuration, target);
assert resourceRepository != null;
ResourceItem resourceItem = resourceRepository.getResourceItem(resolvedValue.getResourceType(), resolvedValue.getName());
configurables = resourceItem.getSourceFileList();
} else {
AppResourceRepository appResourceRepository = facet.getAppResources(true);
configurables = appResourceRepository.getResourceItem(resolvedValue.getResourceType(), resolvedValue.getName());
}
Configurable configurable = configuration.findMatchingConfigurable(configurables);
assert configurable != null;
return configurable.getConfiguration();
}
use of com.android.ide.common.resources.configuration.Configurable in project android by JetBrains.
the class ThemeAttributeResolver method resolveAll.
@NotNull
private List<EditedStyleItem> resolveAll() {
ThemeEditorStyle theme = new ThemeEditorStyle(myManager, myStyle.getQualifiedName());
for (FolderConfiguration folder : theme.getFolders()) {
resolveFromInheritance(myStyle, folder, new RestrictedConfiguration(), new HashSet<String>());
}
List<EditedStyleItem> result = Lists.newArrayList();
FolderConfiguration configuration = myStyle.getConfiguration().getFullConfig();
for (String key : myItemValueMap.keySet()) {
Collection<ConfiguredElement<ItemResourceValue>> itemValues = myItemValueMap.get(key);
final ConfiguredElement<ItemResourceValue> selectedValue = (ConfiguredElement<ItemResourceValue>) configuration.findMatchingConfigurable(Lists.<Configurable>newArrayList(itemValues));
if (selectedValue == null) {
// TODO: there is NO value for this attribute in the current config,so instead we need to show "no value for current device"
result.add(new EditedStyleItem(itemValues.iterator().next(), itemValues, myStyle));
} else {
itemValues.remove(selectedValue);
assert !itemValues.contains(selectedValue);
result.add(new EditedStyleItem(selectedValue, itemValues, myStyle));
}
}
return result;
}
Aggregations