use of com.android.tools.idea.npw.ThemeHelper in project android by JetBrains.
the class NewAndroidComponentAction method update.
@Override
public void update(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
Module module = LangDataKeys.MODULE.getData(dataContext);
if (module == null) {
return;
}
AndroidModuleInfo moduleInfo = AndroidModuleInfo.get(module);
if (moduleInfo == null) {
return;
}
Presentation presentation = e.getPresentation();
int moduleMinSdkVersion = moduleInfo.getMinSdkVersion().getApiLevel();
if (myMinSdkVersion > moduleMinSdkVersion) {
presentation.setText(AndroidBundle.message("android.wizard.action.requires.minsdk", myTemplateName, myMinSdkVersion));
presentation.setEnabled(false);
} else if (myRequireAppTheme) {
ThemeHelper themeHelper = new ThemeHelper(module);
if (themeHelper.getAppThemeName() == null) {
presentation.setText(AndroidBundle.message("android.wizard.action.no.app.theme", myTemplateName));
presentation.setEnabled(false);
}
}
}
use of com.android.tools.idea.npw.ThemeHelper in project android by JetBrains.
the class FmGetApplicationThemeMethod method exec.
@Override
public Object exec(List arguments) throws TemplateModelException {
String modulePath = (String) myParamMap.get(TemplateMetadata.ATTR_PROJECT_OUT);
if (modulePath == null) {
return null;
}
Module module = FmUtil.findModule(modulePath);
if (module == null) {
return null;
}
ThemeHelper helper = new ThemeHelper(module);
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet == null) {
return null;
}
VirtualFile projectFile = module.getProject().getProjectFile();
if (projectFile == null) {
return null;
}
ConfigurationManager manager = facet.getConfigurationManager();
Configuration configuration = manager.getConfiguration(projectFile);
String themeName = helper.getAppThemeName();
if (themeName == null) {
return null;
}
Map<String, Object> map = Maps.newHashMap();
map.put("name", themeName);
map.put("isAppCompat", helper.isAppCompatTheme(themeName));
Boolean hasActionBar = ThemeHelper.hasActionBar(configuration, themeName);
addDerivedTheme(map, themeName, "NoActionBar", hasActionBar == Boolean.FALSE, helper, configuration);
addDerivedTheme(map, themeName, "AppBarOverlay", false, helper, configuration);
addDerivedTheme(map, themeName, "PopupOverlay", false, helper, configuration);
return map;
}
Aggregations