Search in sources :

Example 11 with ConfigurationManager

use of com.android.tools.idea.configurations.ConfigurationManager in project android by JetBrains.

the class ResourceFolderRepository method bitmapUpdated.

/**
   * Called when a bitmap has been changed/deleted. In that case we need to clear out any caches for that
   * image held by layout lib.
   */
private void bitmapUpdated() {
    ConfigurationManager configurationManager = myFacet.getConfigurationManager(false);
    if (configurationManager != null) {
        IAndroidTarget target = configurationManager.getTarget();
        if (target != null) {
            Module module = myFacet.getModule();
            AndroidTargetData targetData = AndroidTargetData.getTargetData(target, module);
            if (targetData != null) {
                targetData.clearLayoutBitmapCache(module);
            }
        }
    }
}
Also used : IAndroidTarget(com.android.sdklib.IAndroidTarget) Module(com.intellij.openapi.module.Module) ConfigurationManager(com.android.tools.idea.configurations.ConfigurationManager) AndroidTargetData(org.jetbrains.android.sdk.AndroidTargetData)

Example 12 with ConfigurationManager

use of com.android.tools.idea.configurations.ConfigurationManager in project android by JetBrains.

the class ConfiguredThemeEditorStyleTest method testGetParentNamesParenInName.

/**
   * Test {@link ConfiguredThemeEditorStyle#getParentNames()} for a style:
   * <style name="ATheme.Red"></style>, i.e parent defined in the name
   */
public void testGetParentNamesParenInName() {
    VirtualFile virtualFile = myFixture.copyFileToProject("themeEditor/themeEditorStyle/styles.xml", "res/values/styles.xml");
    myFixture.copyFileToProject("themeEditor/themeEditorStyle/styles_1.xml", "res/values-v19/styles.xml");
    ConfigurationManager configurationManager = myFacet.getConfigurationManager();
    Configuration configuration = configurationManager.getConfiguration(virtualFile);
    ThemeResolver resolver = new ThemeResolver(configuration);
    ConfiguredThemeEditorStyle theme = resolver.getTheme("ATheme.Red");
    assertNotNull(theme);
    HashSet<String> parents = Sets.newHashSet();
    for (ConfiguredElement<String> parent : theme.getParentNames()) {
        parents.add(parent.getElement());
    }
    assertEquals(2, parents.size());
    assertContainsElements(parents, "ATheme", "BTheme");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FolderConfiguration(com.android.ide.common.resources.configuration.FolderConfiguration) Configuration(com.android.tools.idea.configurations.Configuration) ConfigurationManager(com.android.tools.idea.configurations.ConfigurationManager) ConfiguredThemeEditorStyle(com.android.tools.idea.editors.theme.datamodels.ConfiguredThemeEditorStyle)

Example 13 with ConfigurationManager

use of com.android.tools.idea.configurations.ConfigurationManager in project android by JetBrains.

the class ConfiguredThemeEditorStyleTest method doTestForParentApi.

private void doTestForParentApi(@NotNull String newParent, @NotNull String afterDirectoryName) {
    VirtualFile virtualFile = myFixture.copyFileToProject("themeEditor/apiTestBefore/stylesApi.xml", "res/values/styles.xml");
    myFixture.copyFileToProject("themeEditor/apiTestBefore/stylesApi-v14.xml", "res/values-v14/styles.xml");
    myFixture.copyFileToProject("themeEditor/apiTestBefore/stylesApi-v19.xml", "res/values-v19/styles.xml");
    myFixture.copyFileToProject("themeEditor/apiTestBefore/stylesApi-v21.xml", "res/values-v21/styles.xml");
    ConfigurationManager configurationManager = myFacet.getConfigurationManager();
    Configuration configuration = configurationManager.getConfiguration(virtualFile);
    ThemeResolver themeResolver = new ThemeResolver(configuration);
    ConfiguredThemeEditorStyle theme = themeResolver.getTheme("Theme.MyTheme");
    assertNotNull(theme);
    theme.setParent(newParent);
    myFixture.checkResultByFile("res/values/styles.xml", "themeEditor/" + afterDirectoryName + "/stylesApi.xml", true);
    myFixture.checkResultByFile("res/values-v14/styles.xml", "themeEditor/" + afterDirectoryName + "/stylesApi-v14.xml", true);
    myFixture.checkResultByFile("res/values-v19/styles.xml", "themeEditor/" + afterDirectoryName + "/stylesApi-v19.xml", true);
    myFixture.checkResultByFile("res/values-v21/styles.xml", "themeEditor/" + afterDirectoryName + "/stylesApi-v21.xml", true);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FolderConfiguration(com.android.ide.common.resources.configuration.FolderConfiguration) Configuration(com.android.tools.idea.configurations.Configuration) ConfigurationManager(com.android.tools.idea.configurations.ConfigurationManager) ConfiguredThemeEditorStyle(com.android.tools.idea.editors.theme.datamodels.ConfiguredThemeEditorStyle)

Example 14 with ConfigurationManager

use of com.android.tools.idea.configurations.ConfigurationManager in project android by JetBrains.

the class ConfiguredThemeEditorStyleTest method testGetParentNamesWithDependency.

public void testGetParentNamesWithDependency() {
    VirtualFile virtualFile = myFixture.copyFileToProject("themeEditor/themeEditorStyle/styles.xml", "res/values/styles.xml");
    myFixture.copyFileToProject("themeEditor/themeEditorStyle/styles_1.xml", "additionalModules/moduleA/res/values-v19/styles.xml");
    ConfigurationManager configurationManager = myFacet.getConfigurationManager();
    Configuration configuration = configurationManager.getConfiguration(virtualFile);
    ThemeResolver resolver = new ThemeResolver(configuration);
    ConfiguredThemeEditorStyle theme = resolver.getTheme("AppTheme");
    assertNotNull(theme);
    assertEquals(2, theme.getParentNames().size());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FolderConfiguration(com.android.ide.common.resources.configuration.FolderConfiguration) Configuration(com.android.tools.idea.configurations.Configuration) ConfigurationManager(com.android.tools.idea.configurations.ConfigurationManager) ConfiguredThemeEditorStyle(com.android.tools.idea.editors.theme.datamodels.ConfiguredThemeEditorStyle)

Example 15 with ConfigurationManager

use of com.android.tools.idea.configurations.ConfigurationManager in project android by JetBrains.

the class ConfiguredThemeEditorStyleTest method testSettingInHighApiTheme.

/**
   * Test setting a low-api attributes and parent in a theme defined only in higher api files
   */
public void testSettingInHighApiTheme() {
    VirtualFile virtualFile = myFixture.copyFileToProject("themeEditor/apiTestBefore/stylesApi.xml", "res/values/styles.xml");
    myFixture.copyFileToProject("themeEditor/apiTestBefore/stylesApi-v14.xml", "res/values-v14/styles.xml");
    myFixture.copyFileToProject("themeEditor/apiTestBefore/stylesApi-v19.xml", "res/values-v19/styles.xml");
    myFixture.copyFileToProject("themeEditor/apiTestBefore/stylesApi-v21.xml", "res/values-v21/styles.xml");
    ConfigurationManager configurationManager = myFacet.getConfigurationManager();
    Configuration configuration = configurationManager.getConfiguration(virtualFile);
    ThemeResolver themeResolver = new ThemeResolver(configuration);
    ConfiguredThemeEditorStyle theme = themeResolver.getTheme("Theme.MyOtherTheme");
    assertNotNull(theme);
    theme.setValue("android:windowIsFloating", "holo_purple");
    theme.setValue("android:actionBarDivider", "myValue");
    theme.setParent("android:Theme.Holo.Light.DarkActionBar");
    myFixture.checkResultByFile("res/values/styles.xml", "themeEditor/apiTestAfter8/stylesApi.xml", true);
    myFixture.checkResultByFile("res/values-v14/styles.xml", "themeEditor/apiTestAfter8/stylesApi-v14.xml", true);
    myFixture.checkResultByFile("res/values-v19/styles.xml", "themeEditor/apiTestAfter8/stylesApi-v19.xml", true);
    myFixture.checkResultByFile("res/values-v21/styles.xml", "themeEditor/apiTestAfter8/stylesApi-v21.xml", true);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FolderConfiguration(com.android.ide.common.resources.configuration.FolderConfiguration) Configuration(com.android.tools.idea.configurations.Configuration) ConfigurationManager(com.android.tools.idea.configurations.ConfigurationManager) ConfiguredThemeEditorStyle(com.android.tools.idea.editors.theme.datamodels.ConfiguredThemeEditorStyle)

Aggregations

ConfigurationManager (com.android.tools.idea.configurations.ConfigurationManager)20 Configuration (com.android.tools.idea.configurations.Configuration)14 VirtualFile (com.intellij.openapi.vfs.VirtualFile)14 FolderConfiguration (com.android.ide.common.resources.configuration.FolderConfiguration)9 ConfiguredThemeEditorStyle (com.android.tools.idea.editors.theme.datamodels.ConfiguredThemeEditorStyle)8 IAndroidTarget (com.android.sdklib.IAndroidTarget)6 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)5 CompatibilityRenderTarget (com.android.tools.idea.rendering.multi.CompatibilityRenderTarget)4 NotNull (org.jetbrains.annotations.NotNull)4 Module (com.intellij.openapi.module.Module)3 ItemResourceValue (com.android.ide.common.rendering.api.ItemResourceValue)2 ResourceResolver (com.android.ide.common.resources.ResourceResolver)2 VersionQualifier (com.android.ide.common.resources.configuration.VersionQualifier)2 ResourceValue (com.android.ide.common.rendering.api.ResourceValue)1 ResourceItem (com.android.ide.common.res2.ResourceItem)1 ResourceItem (com.android.ide.common.resources.ResourceItem)1 ResourceRepository (com.android.ide.common.resources.ResourceRepository)1 Configurable (com.android.ide.common.resources.configuration.Configurable)1 LocaleQualifier (com.android.ide.common.resources.configuration.LocaleQualifier)1 Device (com.android.sdklib.devices.Device)1