use of com.android.ide.common.resources.FrameworkResources in project android_frameworks_base by ResurrectionRemix.
the class Main method setUp.
/**
* Initialize the bridge and the resource maps.
*/
@BeforeClass
public static void setUp() {
File data_dir = new File(PLATFORM_DIR, "data");
File res = new File(data_dir, "res");
sFrameworkRepo = new FrameworkResources(new FolderWrapper(res));
sFrameworkRepo.loadResources();
sFrameworkRepo.loadPublicResources(getLogger());
sProjectResources = new ResourceRepository(new FolderWrapper(TEST_RES_DIR + APP_TEST_RES), false) {
@NonNull
@Override
protected ResourceItem createResourceItem(@NonNull String name) {
return new ResourceItem(name);
}
};
sProjectResources.loadResources();
File fontLocation = new File(data_dir, "fonts");
File buildProp = new File(PLATFORM_DIR, "build.prop");
File attrs = new File(res, "values" + File.separator + "attrs.xml");
sBridge = new Bridge();
sBridge.init(ConfigGenerator.loadProperties(buildProp), fontLocation, ConfigGenerator.getEnumMap(attrs), getLayoutLog());
}
use of com.android.ide.common.resources.FrameworkResources in project android_frameworks_base by DirtyUnicorns.
the class Main method setUp.
/**
* Initialize the bridge and the resource maps.
*/
@BeforeClass
public static void setUp() {
File data_dir = new File(PLATFORM_DIR, "data");
File res = new File(data_dir, "res");
sFrameworkRepo = new FrameworkResources(new FolderWrapper(res));
sFrameworkRepo.loadResources();
sFrameworkRepo.loadPublicResources(getLogger());
sProjectResources = new ResourceRepository(new FolderWrapper(TEST_RES_DIR + APP_TEST_RES), false) {
@NonNull
@Override
protected ResourceItem createResourceItem(@NonNull String name) {
return new ResourceItem(name);
}
};
sProjectResources.loadResources();
File fontLocation = new File(data_dir, "fonts");
File buildProp = new File(PLATFORM_DIR, "build.prop");
File attrs = new File(res, "values" + File.separator + "attrs.xml");
sBridge = new Bridge();
sBridge.init(ConfigGenerator.loadProperties(buildProp), fontLocation, ConfigGenerator.getEnumMap(attrs), getLayoutLog());
}
use of com.android.ide.common.resources.FrameworkResources in project android_frameworks_base by AOSPA.
the class Main method setUp.
/**
* Initialize the bridge and the resource maps.
*/
@BeforeClass
public static void setUp() {
File data_dir = new File(PLATFORM_DIR, "data");
File res = new File(data_dir, "res");
sFrameworkRepo = new FrameworkResources(new FolderWrapper(res));
sFrameworkRepo.loadResources();
sFrameworkRepo.loadPublicResources(getLogger());
sProjectResources = new ResourceRepository(new FolderWrapper(TEST_RES_DIR + APP_TEST_RES), false) {
@NonNull
@Override
protected ResourceItem createResourceItem(@NonNull String name) {
return new ResourceItem(name);
}
};
sProjectResources.loadResources();
File fontLocation = new File(data_dir, "fonts");
File buildProp = new File(PLATFORM_DIR, "build.prop");
File attrs = new File(res, "values" + File.separator + "attrs.xml");
sBridge = new Bridge();
sBridge.init(ConfigGenerator.loadProperties(buildProp), fontLocation, ConfigGenerator.getEnumMap(attrs), getLayoutLog());
}
use of com.android.ide.common.resources.FrameworkResources in project android_frameworks_base by crdroidandroid.
the class Main method setUp.
/**
* Initialize the bridge and the resource maps.
*/
@BeforeClass
public static void setUp() {
File data_dir = new File(PLATFORM_DIR, "data");
File res = new File(data_dir, "res");
sFrameworkRepo = new FrameworkResources(new FolderWrapper(res));
sFrameworkRepo.loadResources();
sFrameworkRepo.loadPublicResources(getLogger());
sProjectResources = new ResourceRepository(new FolderWrapper(TEST_RES_DIR + APP_TEST_RES), false) {
@NonNull
@Override
protected ResourceItem createResourceItem(@NonNull String name) {
return new ResourceItem(name);
}
};
sProjectResources.loadResources();
File fontLocation = new File(data_dir, "fonts");
File buildProp = new File(PLATFORM_DIR, "build.prop");
File attrs = new File(res, "values" + File.separator + "attrs.xml");
sBridge = new Bridge();
sBridge.init(ConfigGenerator.loadProperties(buildProp), fontLocation, ConfigGenerator.getEnumMap(attrs), getLayoutLog());
}
use of com.android.ide.common.resources.FrameworkResources in project android by JetBrains.
the class ResourceHelper method getCompletionFromTypes.
/**
* Returns the list of all resource names that can be used as a value for one of the {@link ResourceType} in completionTypes,
* optionally sorting/not sorting the results.
*/
@NotNull
public static List<String> getCompletionFromTypes(@NotNull AndroidFacet facet, @NotNull EnumSet<ResourceType> completionTypes, boolean sort) {
EnumSet<ResourceType> types = Sets.newEnumSet(completionTypes, ResourceType.class);
// Use drawables for mipmaps
if (types.contains(ResourceType.MIPMAP)) {
types.add(ResourceType.DRAWABLE);
} else if (types.contains(ResourceType.DRAWABLE)) {
types.add(ResourceType.MIPMAP);
}
boolean completionTypesContainsColor = types.contains(ResourceType.COLOR);
if (types.contains(ResourceType.DRAWABLE)) {
// The Drawable type accepts colors as value but not color state lists.
types.add(ResourceType.COLOR);
}
AppResourceRepository repository = AppResourceRepository.getAppResources(facet, true);
ResourceVisibilityLookup lookup = repository.getResourceVisibility(facet);
AndroidPlatform androidPlatform = AndroidPlatform.getInstance(facet.getModule());
FrameworkResources frameworkResources = null;
if (androidPlatform != null) {
AndroidTargetData targetData = androidPlatform.getSdkData().getTargetData(androidPlatform.getTarget());
try {
frameworkResources = targetData.getFrameworkResources(true);
} catch (IOException ignore) {
}
}
List<String> resources = Lists.newArrayListWithCapacity(500);
for (ResourceType type : types) {
// If type == ResourceType.COLOR, we want to include file resources (i.e. color state lists) only in the case where
// color was present in completionTypes, and not if we added it because of the presence of ResourceType.DRAWABLES.
// For any other ResourceType, we always include file resources.
boolean includeFileResources = (type != ResourceType.COLOR) || completionTypesContainsColor;
if (frameworkResources != null) {
addFrameworkItems(resources, type, includeFileResources, frameworkResources);
}
addProjectItems(resources, type, includeFileResources, repository, lookup);
}
if (sort) {
Collections.sort(resources, ResourceHelper::compareResourceReferences);
}
return resources;
}
Aggregations