use of com.android.tools.idea.ui.designer.EditorDesignSurface in project android by JetBrains.
the class RenderErrorContributor method reportRenderingFidelityProblems.
private void reportRenderingFidelityProblems(@NotNull RenderLogger logger, @NotNull final RenderTask renderTask) {
List<RenderProblem> fidelityWarnings = logger.getFidelityWarnings();
if (fidelityWarnings == null || fidelityWarnings.isEmpty()) {
return;
}
HtmlBuilder builder = new HtmlBuilder();
builder.add("The graphics preview in the layout editor may not be accurate:").newline();
builder.beginList();
int count = 0;
for (final RenderProblem warning : fidelityWarnings) {
builder.listItem();
warning.appendHtml(builder.getStringBuilder());
final Object clientData = warning.getClientData();
if (clientData != null) {
builder.addLink(" (Ignore for this session)", myLinkManager.createRunnableLink(() -> {
RenderLogger.ignoreFidelityWarning(clientData);
EditorDesignSurface surface = renderTask.getDesignSurface();
if (surface != null) {
surface.requestRender();
}
}));
}
builder.newline();
count++;
// Only display the first 3 render fidelity issues
if (count == 3) {
@SuppressWarnings("ConstantConditions") int remaining = fidelityWarnings.size() - count;
if (remaining > 0) {
builder.add("(").addHtml(Integer.toString(remaining)).add(" additional render fidelity issues hidden)");
break;
}
}
}
builder.endList();
builder.addLink("Ignore all fidelity warnings for this session", myLinkManager.createRunnableLink(() -> {
RenderLogger.ignoreAllFidelityWarnings();
EditorDesignSurface surface = renderTask.getDesignSurface();
if (surface != null) {
surface.requestRender();
}
}));
builder.newline();
addIssue().setSeverity(HighlightSeverity.WARNING).setSummary("Layout fidelity warning").setHtmlContent(builder).build();
}
use of com.android.tools.idea.ui.designer.EditorDesignSurface in project android by JetBrains.
the class RenderErrorContributor method reportRtlNotEnabled.
private void reportRtlNotEnabled(@NotNull RenderLogger logger, @Nullable RenderTask task) {
ApplicationManager.getApplication().runReadAction(() -> {
Project project = logger.getProject();
if (project == null || project.isDisposed()) {
return;
}
Module module = logger.getModule();
if (module == null) {
return;
}
AndroidFacet facet = AndroidFacet.getInstance(module);
Manifest manifest = facet != null ? facet.getManifest() : null;
Application application = manifest != null ? manifest.getApplication() : null;
if (application == null) {
return;
}
final XmlTag applicationTag = application.getXmlTag();
if (applicationTag == null) {
return;
}
HtmlBuilder builder = new HtmlBuilder();
builder.add("(").addLink("Add android:supportsRtl=\"true\" to the manifest", logger.getLinkManager().createRunnableLink(() -> {
new SetAttributeFix(project, applicationTag, AndroidManifest.ATTRIBUTE_SUPPORTS_RTL, ANDROID_URI, VALUE_TRUE).execute();
EditorDesignSurface surface = task != null ? task.getDesignSurface() : null;
if (surface != null) {
surface.requestRender(true);
}
})).add(")");
addIssue().setSeverity(HighlightSeverity.ERROR).setSummary("RTL support requires android:supportsRtl=\"true\" in the manifest").setHtmlContent(builder).build();
});
}
Aggregations