Search in sources :

Example 1 with Manifest

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

the class UsingReportAction method report.

private void report(Project project, PsiFile psiFile) {
    Module module = ModuleUtilCore.findModuleForFile(psiFile.getVirtualFile(), project);
    assert module != null;
    AndroidFacet facet = AndroidFacet.getInstance(module);
    assert facet != null;
    Manifest manifest = facet.getManifest();
    if (manifest == null) {
        NotificationUtils.errorNotification("manifest file is null.");
        return;
    }
    String packageName = manifest.getPackage().getValue();
    if (packageName != null && packageName.length() > 0) {
        UsingReportAsync task = new UsingReportAsync(packageName, this);
        ApplicationManager.getApplication().executeOnPooledThread(task);
    }
}
Also used : Module(com.intellij.openapi.module.Module) Manifest(org.jetbrains.android.dom.manifest.Manifest) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 2 with Manifest

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

the class PackageClassConverter method toString.

@Override
@Nullable
public String toString(@Nullable PsiClass psiClass, ConvertContext context) {
    DomElement domElement = context.getInvocationElement();
    Manifest manifest = domElement.getParentOfType(Manifest.class, true);
    final String packageName = manifest == null ? null : manifest.getPackage().getValue();
    return classToString(psiClass, packageName, "");
}
Also used : Manifest(org.jetbrains.android.dom.manifest.Manifest) MergedManifest(com.android.tools.idea.model.MergedManifest) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with Manifest

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

the class AndroidResourceUtil method isRJavaFile.

public static boolean isRJavaFile(@NotNull AndroidFacet facet, @NotNull PsiFile file) {
    if (file.getName().equals(AndroidCommonUtils.R_JAVA_FILENAME) && file instanceof PsiJavaFile) {
        final PsiJavaFile javaFile = (PsiJavaFile) file;
        final Manifest manifest = facet.getManifest();
        if (manifest != null) {
            final String manifestPackage = manifest.getPackage().getValue();
            if (manifestPackage != null && javaFile.getPackageName().equals(manifestPackage)) {
                return true;
            }
        }
        for (String aPackage : AndroidUtils.getDepLibsPackages(facet.getModule())) {
            if (javaFile.getPackageName().equals(aPackage)) {
                return true;
            }
        }
    }
    return false;
}
Also used : Manifest(org.jetbrains.android.dom.manifest.Manifest)

Example 4 with Manifest

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

the class AndroidResourceUtil method manifestPackageForModule.

@Nullable
private static String manifestPackageForModule(@NotNull Module module) {
    AndroidFacet facet = AndroidFacet.getInstance(module);
    if (facet == null) {
        return null;
    }
    Manifest manifest = facet.getManifest();
    if (manifest == null) {
        return null;
    }
    return manifest.getPackage().getValue();
}
Also used : Manifest(org.jetbrains.android.dom.manifest.Manifest) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with Manifest

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

the class AndroidFrameworkDetector method doImportSdkAndFacetConfiguration.

public static void doImportSdkAndFacetConfiguration(@NotNull AndroidFacet facet, @Nullable ModifiableRootModel model) {
    Module module = facet.getModule();
    AndroidSdkUtils.setupAndroidPlatformIfNecessary(module, true);
    if (model != null && !model.isDisposed() && model.isWritable()) {
        model.setSdk(ModuleRootManager.getInstance(module).getSdk());
    }
    Pair<String, VirtualFile> manifestMergerProperty = getProjectPropertyValue(module, ANDROID_MANIFEST_MERGER_PROPERTY);
    if (manifestMergerProperty != null) {
        facet.getProperties().ENABLE_MANIFEST_MERGING = getFirstAsBoolean(manifestMergerProperty);
    }
    Pair<String, VirtualFile> dexDisableMergerProperty = getProjectPropertyValue(module, ANDROID_DEX_DISABLE_MERGER);
    if (dexDisableMergerProperty != null) {
        facet.getProperties().ENABLE_PRE_DEXING = !getFirstAsBoolean(dexDisableMergerProperty);
    }
    // Left here for compatibility with loading older projects
    Pair<String, VirtualFile> androidLibraryProperty = getProjectPropertyValue(module, ANDROID_LIBRARY_PROPERTY);
    if (androidLibraryProperty != null && getFirstAsBoolean(androidLibraryProperty)) {
        facet.setProjectType(PROJECT_TYPE_LIBRARY);
    }
    Pair<String, VirtualFile> androidProjectTypeProperty = getProjectPropertyValue(module, ANDROID_PROJECT_TYPE_PROPERTY);
    if (androidProjectTypeProperty != null) {
        facet.setProjectType(Integer.parseInt(androidProjectTypeProperty.getFirst()));
    }
    if (facet.isAppProject()) {
        Pair<String, VirtualFile> dexForceJumboProperty = getProjectPropertyValue(module, ANDROID_DEX_FORCE_JUMBO_PROPERTY);
        if (dexForceJumboProperty != null) {
            showDexOptionNotification(module, ANDROID_DEX_FORCE_JUMBO_PROPERTY);
        }
        Manifest manifest = facet.getManifest();
        if (manifest != null && DefaultActivityLocator.getDefaultLauncherActivityName(module.getProject(), manifest) != null) {
            AndroidRunConfigurations.getInstance().addRunConfiguration(facet, null, null, null);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Module(com.intellij.openapi.module.Module) 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