use of org.jetbrains.android.sdk.AndroidTargetData in project android by JetBrains.
the class ConstantFieldConverter method getFilteringSet.
@Nullable
private static Set<String> getFilteringSet(@NotNull ConvertContext context) {
final Module module = context.getModule();
if (module == null) {
return null;
}
final AndroidPlatform platform = AndroidPlatform.getInstance(module);
if (platform == null) {
return null;
}
IAndroidTarget target = platform.getTarget();
final AndroidTargetData targetData = platform.getSdkData().getTargetData(target);
DomElement element = context.getInvocationElement().getParent();
if (element instanceof Category) {
return targetData.getStaticConstantsData().getCategories();
} else if (element instanceof Action) {
element = element.getParent();
if (element instanceof IntentFilter) {
element = element.getParent();
if (element instanceof Activity) {
return targetData.getStaticConstantsData().getActivityActions();
} else if (element instanceof Service) {
return targetData.getStaticConstantsData().getServiceActions();
} else if (element instanceof Receiver) {
return targetData.getStaticConstantsData().getReceiverActions();
}
}
}
return null;
}
use of org.jetbrains.android.sdk.AndroidTargetData in project android by JetBrains.
the class ResourceResolverCache method getFrameworkResources.
/**
* Returns a {@link LocalResourceRepository} for the framework resources based on the current configuration selection.
*
* @return the framework resources or {@code null} if not found.
*/
@Nullable
public ResourceRepository getFrameworkResources(@NotNull FolderConfiguration configuration, @NotNull IAndroidTarget target) {
int apiLevel = target.getVersion().getFeatureLevel();
LocaleQualifier locale = configuration.getLocaleQualifier();
boolean needLocales = locale != null && !locale.hasFakeValue() || myManager.getLocale() != Locale.ANY;
AndroidTargetData targetData = myFrameworkResources.get(apiLevel);
if (targetData == null) {
AndroidPlatform platform = AndroidPlatform.getInstance(myManager.getModule());
if (platform == null) {
return null;
}
// uses soft ref
targetData = platform.getSdkData().getTargetData(target);
myFrameworkResources.put(apiLevel, targetData);
}
try {
return targetData.getFrameworkResources(needLocales);
} catch (IOException e) {
LOG.error(e);
}
return null;
}
use of org.jetbrains.android.sdk.AndroidTargetData in project android by JetBrains.
the class EditedStyleItem method isPublicAttribute.
public boolean isPublicAttribute() {
if (!getSelectedValue().isFrameworkAttr()) {
return true;
}
Configuration configuration = mySourceTheme.getConfiguration();
IAndroidTarget target = configuration.getRealTarget();
if (target == null) {
LOG.error("Unable to get IAndroidTarget.");
return false;
}
AndroidTargetData androidTargetData = AndroidTargetData.getTargetData(target, configuration.getModule());
if (androidTargetData == null) {
LOG.error("Unable to get AndroidTargetData.");
return false;
}
return androidTargetData.isResourcePublic(ResourceType.ATTR.getName(), getName());
}
use of org.jetbrains.android.sdk.AndroidTargetData in project android by JetBrains.
the class ThemeEditorStyle method isPublic.
/**
* Returns whether this style is public.
*/
public boolean isPublic() {
if (!isFramework()) {
return true;
}
IAndroidTarget target = myManager.getTarget();
if (target == null) {
LOG.error("Unable to get IAndroidTarget.");
return false;
}
AndroidTargetData androidTargetData = AndroidTargetData.getTargetData(target, myManager.getModule());
if (androidTargetData == null) {
LOG.error("Unable to get AndroidTargetData.");
return false;
}
return androidTargetData.isResourcePublic(ResourceType.STYLE.getName(), getName());
}
use of org.jetbrains.android.sdk.AndroidTargetData in project android by JetBrains.
the class RenderErrorContributor method reportTagResourceFormat.
private void reportTagResourceFormat(@NotNull RenderResult result, @NotNull RenderProblem message) {
Object clientData = message.getClientData();
if (!(clientData instanceof String[])) {
return;
}
String[] strings = (String[]) clientData;
if (strings.length != 2) {
return;
}
RenderTask renderTask = result.getRenderTask();
if (renderTask == null) {
return;
}
IAndroidTarget target = renderTask.getConfiguration().getRealTarget();
if (target == null) {
return;
}
AndroidPlatform platform = renderTask.getPlatform();
if (platform == null) {
return;
}
AndroidTargetData targetData = platform.getSdkData().getTargetData(target);
AttributeDefinitions definitionLookup = targetData.getPublicAttrDefs(result.getFile().getProject());
final String attributeName = strings[0];
final String currentValue = strings[1];
if (definitionLookup == null) {
return;
}
AttributeDefinition definition = definitionLookup.getAttrDefByName(attributeName);
if (definition == null) {
return;
}
Set<AttributeFormat> formats = definition.getFormats();
if (formats.contains(AttributeFormat.Flag) || formats.contains(AttributeFormat.Enum)) {
String[] values = definition.getValues();
if (values.length > 0) {
HtmlBuilder builder = new HtmlBuilder();
builder.add("Change ").add(currentValue).add(" to: ");
boolean first = true;
for (String value : values) {
if (first) {
first = false;
} else {
builder.add(", ");
}
builder.addLink(value, myLinkManager.createReplaceAttributeValueUrl(attributeName, currentValue, value));
}
addRefreshAction(builder);
addIssue().setSummary("Incorrect resource value format").setHtmlContent(builder).build();
}
}
}
Aggregations