Search in sources :

Example 1 with Application

use of org.jetbrains.android.dom.manifest.Application in project android by JetBrains.

the class AddActivityToManifest method invoke.

@Override
void invoke(@NotNull PsiClass psiClass, @NotNull Manifest manifest) {
    final Application application = manifest.getApplication();
    application.addActivity().getActivityClass().setValue(psiClass);
}
Also used : Application(org.jetbrains.android.dom.manifest.Application)

Example 2 with Application

use of org.jetbrains.android.dom.manifest.Application in project android by JetBrains.

the class AddServiceToManifest method invoke.

@Override
void invoke(@NotNull PsiClass psiClass, @NotNull Manifest manifest) {
    final Application application = manifest.getApplication();
    application.addService().getServiceClass().setValue(psiClass);
}
Also used : Application(org.jetbrains.android.dom.manifest.Application)

Example 3 with Application

use of org.jetbrains.android.dom.manifest.Application 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();
    });
}
Also used : Project(com.intellij.openapi.project.Project) EditorDesignSurface(com.android.tools.idea.ui.designer.EditorDesignSurface) HtmlBuilder(com.android.utils.HtmlBuilder) Module(com.intellij.openapi.module.Module) AndroidManifest(com.android.xml.AndroidManifest) Manifest(org.jetbrains.android.dom.manifest.Manifest) Application(org.jetbrains.android.dom.manifest.Application) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) XmlTag(com.intellij.psi.xml.XmlTag)

Example 4 with Application

use of org.jetbrains.android.dom.manifest.Application in project android by JetBrains.

the class AddBroadcastReceiverToManifest method invoke.

@Override
void invoke(@NotNull PsiClass psiClass, @NotNull Manifest manifest) {
    final Application application = manifest.getApplication();
    application.addReceiver().getReceiverClass().setValue(psiClass);
}
Also used : Application(org.jetbrains.android.dom.manifest.Application)

Example 5 with Application

use of org.jetbrains.android.dom.manifest.Application in project android by JetBrains.

the class AndroidActivityAliasCompletionContributor method doCollectActivityAliases.

private static void doCollectActivityAliases(@NotNull AndroidFacet facet, @NotNull Set<String> result) {
    final Manifest manifest = facet.getManifest();
    if (manifest == null) {
        return;
    }
    final String aPackage = manifest.getPackage().getStringValue();
    final Application application = manifest.getApplication();
    if (application == null) {
        return;
    }
    for (ActivityAlias activityAlias : application.getActivityAliases()) {
        String alias = activityAlias.getName().getStringValue();
        if (alias != null && alias.length() > 0) {
            if (!alias.startsWith(".")) {
                if (alias.indexOf('.') > 0) {
                    result.add(alias);
                }
                alias = "." + alias;
            }
            if (aPackage != null && aPackage.length() > 0 && StringUtil.commonPrefixLength(aPackage, alias) == 0) {
                result.add(aPackage + alias);
            }
        }
    }
}
Also used : ActivityAlias(org.jetbrains.android.dom.manifest.ActivityAlias) Manifest(org.jetbrains.android.dom.manifest.Manifest) Application(org.jetbrains.android.dom.manifest.Application)

Aggregations

Application (org.jetbrains.android.dom.manifest.Application)5 Manifest (org.jetbrains.android.dom.manifest.Manifest)2 EditorDesignSurface (com.android.tools.idea.ui.designer.EditorDesignSurface)1 HtmlBuilder (com.android.utils.HtmlBuilder)1 AndroidManifest (com.android.xml.AndroidManifest)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 XmlTag (com.intellij.psi.xml.XmlTag)1 ActivityAlias (org.jetbrains.android.dom.manifest.ActivityAlias)1 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)1