Search in sources :

Example 21 with Manifest

use of org.jetbrains.android.dom.manifest.Manifest 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 22 with Manifest

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

the class SpecificActivityLocator method doesPackageContainMavenProperty.

private static boolean doesPackageContainMavenProperty(@NotNull AndroidFacet facet) {
    final Manifest manifest = facet.getManifest();
    if (manifest == null) {
        return false;
    }
    final String aPackage = manifest.getPackage().getStringValue();
    return aPackage != null && aPackage.contains("${");
}
Also used : MergedManifest(com.android.tools.idea.model.MergedManifest) Manifest(org.jetbrains.android.dom.manifest.Manifest)

Example 23 with Manifest

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

the class PackageClassConverter method getManifestPackage.

@Nullable
private String getManifestPackage(@NotNull ConvertContext context) {
    DomElement domElement = context.getInvocationElement();
    Manifest manifest = domElement.getParentOfType(Manifest.class, true);
    String manifestPackage = manifest != null ? manifest.getPackage().getValue() : null;
    if (manifestPackage == null && myUseManifestBasePackage) {
        Module module = context.getModule();
        if (module != null) {
            manifestPackage = MergedManifest.get(module).getPackage();
        }
    }
    return manifestPackage;
}
Also used : Manifest(org.jetbrains.android.dom.manifest.Manifest) MergedManifest(com.android.tools.idea.model.MergedManifest) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 24 with Manifest

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

the class ManifestInnerClass method getFields.

@NotNull
@Override
public PsiField[] getFields() {
    if (myFieldsCache == null) {
        myFieldsCache = CachedValuesManager.getManager(getProject()).createCachedValue(new CachedValueProvider<PsiField[]>() {

            @Override
            public Result<PsiField[]> compute() {
                final Manifest manifest = myFacet.getManifest();
                if (manifest == null) {
                    return Result.create(PsiField.EMPTY_ARRAY, PsiModificationTracker.MODIFICATION_COUNT);
                }
                final List<Pair<String, String>> pairs = doGetFields(manifest);
                final PsiField[] result = new PsiField[pairs.size()];
                final PsiClassType stringType = PsiType.getJavaLangString(myManager, GlobalSearchScope.allScope(getProject()));
                final PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject());
                int i = 0;
                for (Pair<String, String> pair : pairs) {
                    final AndroidLightField field = new AndroidLightField(pair.getFirst(), ManifestInnerClass.this, stringType, true, pair.getSecond());
                    field.setInitializer(factory.createExpressionFromText("\"" + pair.getSecond() + "\"", field));
                    result[i++] = field;
                }
                final XmlElement xmlElement = manifest.getXmlElement();
                final PsiFile psiManifestFile = xmlElement != null ? xmlElement.getContainingFile() : null;
                return Result.create(result, psiManifestFile != null ? psiManifestFile : PsiModificationTracker.MODIFICATION_COUNT);
            }
        });
    }
    return myFieldsCache.getValue();
}
Also used : CachedValueProvider(com.intellij.psi.util.CachedValueProvider) Manifest(org.jetbrains.android.dom.manifest.Manifest) XmlElement(com.intellij.psi.xml.XmlElement) Pair(com.intellij.openapi.util.Pair) NotNull(org.jetbrains.annotations.NotNull)

Example 25 with Manifest

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

the class AndroidGotoDeclarationHandler method collectManifestElements.

private static void collectManifestElements(@NotNull String nestedClassName, @NotNull String fieldName, @NotNull AndroidFacet facet, @NotNull List<PsiElement> result) {
    final Manifest manifest = facet.getManifest();
    if (manifest == null) {
        return;
    }
    List<? extends ManifestElementWithRequiredName> list;
    if ("permission".equals(nestedClassName)) {
        list = manifest.getPermissions();
    } else if ("permission_group".equals(nestedClassName)) {
        list = manifest.getPermissionGroups();
    } else {
        return;
    }
    for (ManifestElementWithRequiredName domElement : list) {
        final AndroidAttributeValue<String> nameAttribute = domElement.getName();
        final String name = nameAttribute.getValue();
        if (AndroidUtils.equal(name, fieldName, false)) {
            final XmlElement psiElement = nameAttribute.getXmlAttributeValue();
            if (psiElement != null) {
                result.add(psiElement);
            }
        }
    }
}
Also used : ManifestElementWithRequiredName(org.jetbrains.android.dom.manifest.ManifestElementWithRequiredName) XmlElement(com.intellij.psi.xml.XmlElement) Manifest(org.jetbrains.android.dom.manifest.Manifest)

Aggregations

Manifest (org.jetbrains.android.dom.manifest.Manifest)29 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)14 Module (com.intellij.openapi.module.Module)10 Nullable (org.jetbrains.annotations.Nullable)7 XmlElement (com.intellij.psi.xml.XmlElement)6 HashSet (com.intellij.util.containers.HashSet)5 NotNull (org.jetbrains.annotations.NotNull)5 Project (com.intellij.openapi.project.Project)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 File (java.io.File)4 MergedManifest (com.android.tools.idea.model.MergedManifest)3 IOException (java.io.IOException)3 AndroidManifest (com.android.xml.AndroidManifest)2 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)2 Pair (com.intellij.openapi.util.Pair)2 PsiFile (com.intellij.psi.PsiFile)2 HashMap (com.intellij.util.containers.HashMap)2 GenericAttributeValue (com.intellij.util.xml.GenericAttributeValue)2 Application (org.jetbrains.android.dom.manifest.Application)2 ManifestElementWithRequiredName (org.jetbrains.android.dom.manifest.ManifestElementWithRequiredName)2