Search in sources :

Example 6 with RepoPackage

use of com.android.repository.api.RepoPackage in project android by JetBrains.

the class UpgradeConstraintLayoutFix method apply.

public static void apply(@Nullable Module module) {
    if (module != null) {
        StudioSdkUtil.reloadRemoteSdkWithModalProgress();
        AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
        StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(AndroidLintMissingConstraintsInspection.class);
        RepoPackage p = SdkMavenRepository.findLatestVersion(LATEST_KNOWN_VERSION, sdkHandler, progress);
        if (p != null) {
            GradleCoordinate gc = SdkMavenRepository.getCoordinateFromSdkPath(p.getPath());
            if (gc != null) {
                // should always be the case unless the version suffix is somehow wrong
                // Update version dependency in the module. Note that this will trigger a sync too.
                GradleDependencyManager manager = GradleDependencyManager.getInstance(module.getProject());
                manager.updateLibrariesToVersion(module, Collections.singletonList(gc), null);
            }
        }
    }
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) GradleCoordinate(com.android.ide.common.repository.GradleCoordinate) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) GradleDependencyManager(com.android.tools.idea.gradle.dependencies.GradleDependencyManager) RepoPackage(com.android.repository.api.RepoPackage)

Example 7 with RepoPackage

use of com.android.repository.api.RepoPackage in project android by JetBrains.

the class ToolComponentsPanel method updateToolsItems.

private void updateToolsItems() {
    myToolsDetailsRootNode.removeAllChildren();
    myToolsSummaryRootNode.removeAllChildren();
    myStates.clear();
    ParentTreeNode mavenSummaryParent = new ParentTreeNode("Support Repository");
    ParentTreeNode mavenDetailsParent = new ParentTreeNode("Support Repository");
    for (String prefix : myMultiVersionPackages.keySet()) {
        Collection<UpdatablePackage> versions = myMultiVersionPackages.get(prefix);
        Set<DetailsTreeNode> detailsNodes = new TreeSet<>();
        boolean isMaven = false;
        for (UpdatablePackage info : versions) {
            RepoPackage representative = info.getRepresentative();
            if (representative.getTypeDetails() instanceof DetailsTypes.MavenType) {
                isMaven = true;
            }
            PackageNodeModel model = new PackageNodeModel(info);
            myStates.add(model);
            detailsNodes.add(new DetailsTreeNode(model, myModificationListener, myConfigurable));
        }
        MultiVersionTreeNode summaryNode = new MultiVersionTreeNode(detailsNodes);
        if (isMaven) {
            mavenSummaryParent.add(summaryNode);
        } else {
            myToolsSummaryRootNode.add(summaryNode);
        }
        UpdaterTreeNode multiVersionParent = new ParentTreeNode(summaryNode.getDisplayName());
        detailsNodes.forEach(multiVersionParent::add);
        if (isMaven) {
            mavenDetailsParent.add(multiVersionParent);
        } else {
            myToolsDetailsRootNode.add(multiVersionParent);
        }
    }
    for (UpdatablePackage info : myToolsPackages) {
        PackageNodeModel holder = new PackageNodeModel(info);
        myStates.add(holder);
        UpdaterTreeNode node = new DetailsTreeNode(holder, myModificationListener, myConfigurable);
        boolean isMaven = info.getPath().endsWith(RepoPackage.PATH_SEPARATOR + MavenInstallListener.MAVEN_DIR_NAME);
        if (isMaven) {
            mavenDetailsParent.add(node);
        } else {
            myToolsDetailsRootNode.add(node);
        }
        if (!info.getRepresentative().obsolete()) {
            UpdaterTreeNode summaryNode = new DetailsTreeNode(holder, myModificationListener, myConfigurable);
            if (isMaven) {
                mavenSummaryParent.add(summaryNode);
            } else {
                myToolsSummaryRootNode.add(summaryNode);
            }
        }
    }
    if (mavenSummaryParent.getChildCount() > 0) {
        myToolsSummaryRootNode.add(mavenSummaryParent);
        myToolsDetailsRootNode.add(mavenDetailsParent);
    }
    refreshModified();
    SdkUpdaterConfigPanel.resizeColumnsToFit(myToolsDetailTable);
    SdkUpdaterConfigPanel.resizeColumnsToFit(myToolsSummaryTable);
    myToolsDetailTable.updateUI();
    myToolsSummaryTable.updateUI();
    TreeUtil.expandAll(myToolsDetailTable.getTree());
    TreeUtil.expandAll(myToolsSummaryTable.getTree());
}
Also used : UpdatablePackage(com.android.repository.api.UpdatablePackage) RepoPackage(com.android.repository.api.RepoPackage)

Example 8 with RepoPackage

use of com.android.repository.api.RepoPackage in project android by JetBrains.

the class MultiVersionTreeNode method getDisplayName.

@NotNull
public String getDisplayName() {
    RepoPackage maxPackage = myMaxVersionNode.getPackage();
    String maxName = maxPackage.getDisplayName();
    String maxPath = maxPackage.getPath();
    String suffix = maxPath.substring(maxPath.lastIndexOf(RepoPackage.PATH_SEPARATOR) + 1);
    maxName = StringUtil.trimEnd(maxName, suffix).trim();
    maxName = StringUtil.trimEnd(maxName, ":");
    return maxName;
}
Also used : RepoPackage(com.android.repository.api.RepoPackage) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

RepoPackage (com.android.repository.api.RepoPackage)8 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)3 GradleCoordinate (com.android.ide.common.repository.GradleCoordinate)2 ProgressIndicator (com.android.repository.api.ProgressIndicator)2 RemotePackage (com.android.repository.api.RemotePackage)2 UpdatablePackage (com.android.repository.api.UpdatablePackage)2 AndroidVersion (com.android.sdklib.AndroidVersion)2 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)2 DetailsTypes (com.android.sdklib.repository.meta.DetailsTypes)2 NotNull (org.jetbrains.annotations.NotNull)2 SdkConstants (com.android.SdkConstants)1 RepoManager (com.android.repository.api.RepoManager)1 TypeDetails (com.android.repository.impl.meta.TypeDetails)1 AndroidTargetHash (com.android.sdklib.AndroidTargetHash)1 IAndroidTarget (com.android.sdklib.IAndroidTarget)1 SdkVersionInfo (com.android.sdklib.SdkVersionInfo)1 IdDisplay (com.android.sdklib.repository.IdDisplay)1 AndroidTargetManager (com.android.sdklib.repository.targets.AndroidTargetManager)1 SystemImage (com.android.sdklib.repository.targets.SystemImage)1 GradleDependencyManager (com.android.tools.idea.gradle.dependencies.GradleDependencyManager)1