Search in sources :

Example 6 with MergedManifest

use of com.android.tools.idea.model.MergedManifest in project android by JetBrains.

the class StringResourceViewPanel method hyperlinkUpdate.

@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
    StringBuilder sb = new StringBuilder("https://translate.google.com/manager/android_studio/");
    // Application Version
    sb.append("?asVer=");
    ApplicationInfo ideInfo = ApplicationInfo.getInstance();
    // @formatter:off
    sb.append(ideInfo.getMajorVersion()).append('.').append(ideInfo.getMinorVersion()).append('.').append(ideInfo.getMicroVersion()).append('.').append(ideInfo.getPatchVersion());
    // @formatter:on
    // Package name
    MergedManifest manifest = MergedManifest.get(myFacet);
    String pkg = manifest.getPackage();
    if (pkg != null) {
        sb.append("&pkgName=");
        sb.append(pkg.replace('.', '_'));
    }
    // Application ID
    AndroidModuleInfo moduleInfo = AndroidModuleInfo.get(myFacet);
    String appId = moduleInfo.getPackage();
    if (appId != null) {
        sb.append("&appId=");
        sb.append(appId.replace('.', '_'));
    }
    // Version code
    Integer versionCode = manifest.getVersionCode();
    if (versionCode != null) {
        sb.append("&apkVer=");
        sb.append(versionCode.toString());
    }
    // If we support additional IDE languages, we can send the language used in the IDE here
    //sb.append("&lang=en");
    BrowserUtil.browse(sb.toString());
}
Also used : AndroidModuleInfo(com.android.tools.idea.model.AndroidModuleInfo) MergedManifest(com.android.tools.idea.model.MergedManifest) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo)

Example 7 with MergedManifest

use of com.android.tools.idea.model.MergedManifest in project android by JetBrains.

the class ActionBarHandler method getActivityAttributes.

@Nullable
private ActivityAttributes getActivityAttributes() {
    boolean token = RenderSecurityManager.enterSafeRegion(myCredential);
    try {
        MergedManifest manifest = MergedManifest.get(myRenderTask.getModule());
        String activity = StringUtil.notNullize(myRenderTask.getConfiguration().getActivity());
        return manifest.getActivityAttributes(activity);
    } finally {
        RenderSecurityManager.exitSafeRegion(token);
    }
}
Also used : MergedManifest(com.android.tools.idea.model.MergedManifest) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with MergedManifest

use of com.android.tools.idea.model.MergedManifest in project android by JetBrains.

the class OnClickEnumSupport method getAllValues.

@Override
@NotNull
public List<ValueWithDisplayString> getAllValues() {
    Module module = myProperty.getModel().getModule();
    Configuration configuration = myProperty.getModel().getConfiguration();
    String activityClassName = configuration.getActivity();
    JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject());
    Collection<PsiClass> classes;
    if (activityClassName != null) {
        if (activityClassName.startsWith(".")) {
            MergedManifest manifest = MergedManifest.get(module);
            String pkg = StringUtil.notNullize(manifest.getPackage());
            activityClassName = pkg + activityClassName;
        }
        PsiClass activityClass = facade.findClass(activityClassName, module.getModuleScope());
        if (activityClass != null) {
            classes = Collections.singletonList(activityClass);
        } else {
            classes = Collections.emptyList();
        }
    } else {
        GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, false);
        PsiClass activityClass = facade.findClass(CLASS_ACTIVITY, scope);
        if (activityClass != null) {
            classes = ClassInheritorsSearch.search(activityClass, scope, true).findAll();
        } else {
            classes = Collections.emptyList();
        }
    }
    List<ValueWithDisplayString> values = new ArrayList<>();
    Set<String> found = new HashSet<>();
    for (PsiClass psiClass : classes) {
        for (PsiMethod method : psiClass.getAllMethods()) {
            if (OnClickConverter.CONVERTER_FOR_LAYOUT.checkSignature(method) && found.add(method.getName()) && method instanceof PsiMethodImpl) {
                values.add(new ValueWithDisplayString(method.getName(), method.getName(), psiClass.getName()));
            }
        }
    }
    return values;
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) Configuration(com.android.tools.idea.configurations.Configuration) MergedManifest(com.android.tools.idea.model.MergedManifest) PsiMethod(com.intellij.psi.PsiMethod) PsiMethodImpl(com.intellij.psi.impl.source.PsiMethodImpl) PsiClass(com.intellij.psi.PsiClass) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with MergedManifest

use of com.android.tools.idea.model.MergedManifest in project android by JetBrains.

the class ManifestUtils method getActionLocation.

@NotNull
static SourceFilePosition getActionLocation(@NotNull Module module, @NotNull Actions.Record record) {
    SourceFilePosition sourceFilePosition = record.getActionLocation();
    SourceFile sourceFile = sourceFilePosition.getFile();
    File file = sourceFile.getSourceFile();
    SourcePosition sourcePosition = sourceFilePosition.getPosition();
    if (file != null && !SourcePosition.UNKNOWN.equals(sourcePosition)) {
        VirtualFile vFile = VfsUtil.findFileByIoFile(file, false);
        assert vFile != null;
        Module fileModule = ModuleUtilCore.findModuleForFile(vFile, module.getProject());
        if (fileModule != null && !fileModule.equals(module)) {
            MergedManifest manifest = MergedManifest.get(fileModule);
            Document document = manifest.getDocument();
            assert document != null;
            Element root = document.getDocumentElement();
            assert root != null;
            int startLine = sourcePosition.getStartLine();
            int startColumn = sourcePosition.getStartColumn();
            Node node = PositionXmlParser.findNodeAtLineAndCol(document, startLine, startColumn);
            if (node == null) {
                Logger.getInstance(ManifestPanel.class).warn("Can not find node in " + fileModule + " for " + sourceFilePosition);
            } else {
                List<? extends Actions.Record> records = getRecords(manifest, node);
                if (!records.isEmpty()) {
                    return getActionLocation(fileModule, records.get(0));
                }
            }
        }
    }
    return sourceFilePosition;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MergedManifest(com.android.tools.idea.model.MergedManifest) Actions(com.android.manifmerger.Actions) XmlNode(com.android.manifmerger.XmlNode) SourceFilePosition(com.android.ide.common.blame.SourceFilePosition) SourcePosition(com.android.ide.common.blame.SourcePosition) SourceFile(com.android.ide.common.blame.SourceFile) Module(com.intellij.openapi.module.Module) XmlFile(com.intellij.psi.xml.XmlFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) SourceFile(com.android.ide.common.blame.SourceFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with MergedManifest

use of com.android.tools.idea.model.MergedManifest in project android by JetBrains.

the class LaunchUtils method isWatchFeatureRequired.

/** Returns whether the watch hardware feature is required for the given facet. */
public static boolean isWatchFeatureRequired(@NotNull AndroidFacet facet) {
    MergedManifest mergedManifest = MergedManifest.get(facet);
    Element feature = mergedManifest.findUsedFeature(UsesFeature.HARDWARE_TYPE_WATCH);
    return feature != null && isRequired(feature);
}
Also used : MergedManifest(com.android.tools.idea.model.MergedManifest) Element(org.w3c.dom.Element)

Aggregations

MergedManifest (com.android.tools.idea.model.MergedManifest)14 NotNull (org.jetbrains.annotations.NotNull)5 Module (com.intellij.openapi.module.Module)4 Nullable (org.jetbrains.annotations.Nullable)3 Element (org.w3c.dom.Element)3 ResourceResolver (com.android.ide.common.resources.ResourceResolver)2 Configuration (com.android.tools.idea.configurations.Configuration)2 ActivityAttributes (com.android.tools.idea.model.MergedManifest.ActivityAttributes)2 JavaPsiFacade (com.intellij.psi.JavaPsiFacade)2 PsiClass (com.intellij.psi.PsiClass)2 IOException (java.io.IOException)2 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)2 SourceFile (com.android.ide.common.blame.SourceFile)1 SourceFilePosition (com.android.ide.common.blame.SourceFilePosition)1 SourcePosition (com.android.ide.common.blame.SourcePosition)1 LayoutDirectionQualifier (com.android.ide.common.resources.configuration.LayoutDirectionQualifier)1 Actions (com.android.manifmerger.Actions)1 MergingReport (com.android.manifmerger.MergingReport)1 XmlNode (com.android.manifmerger.XmlNode)1 IAndroidTarget (com.android.sdklib.IAndroidTarget)1